change article attributes
This commit is contained in:
parent
cdaacbf5b9
commit
025a3cdacd
6 changed files with 14 additions and 14 deletions
|
@ -55,7 +55,7 @@ module FoodsoftArticleImport
|
||||||
s = "#{article[:name]}-#{article[:unit_quantity]}x#{article[:unit]}"
|
s = "#{article[:name]}-#{article[:unit_quantity]}x#{article[:unit]}"
|
||||||
s = s.downcase.gsub(/[^a-z0-9.]/,'')
|
s = s.downcase.gsub(/[^a-z0-9.]/,'')
|
||||||
# prefix abbreviated sha1-hash with colon to indicate that it's a generated number
|
# prefix abbreviated sha1-hash with colon to indicate that it's a generated number
|
||||||
article[:number] = ':' + Digest::SHA1.hexdigest(s)[-7..-1]
|
article[:order_number] = ':' + Digest::SHA1.hexdigest(s)[-7..-1]
|
||||||
article
|
article
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -50,13 +50,13 @@ module FoodsoftArticleImport
|
||||||
linenum += 1
|
linenum += 1
|
||||||
row[:name].blank? and next
|
row[:name].blank? and next
|
||||||
# (sub)categories are in first two content cells - assume if there's a price it's a product
|
# (sub)categories are in first two content cells - assume if there's a price it's a product
|
||||||
if row[:number].blank? && row[:unit_price].blank?
|
if row[:order_number].blank? && row[:unit_price].blank?
|
||||||
category = row[:name]
|
category = row[:name]
|
||||||
yield nil, nil, linenum
|
yield nil, nil, linenum
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
# skip products without a number
|
# skip products without a number
|
||||||
if row[:number].blank?
|
if row[:order_number].blank?
|
||||||
yield nil, nil, linenum
|
yield nil, nil, linenum
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
@ -65,7 +65,7 @@ module FoodsoftArticleImport
|
||||||
notes = []
|
notes = []
|
||||||
unit_price = row[:unit_price]
|
unit_price = row[:unit_price]
|
||||||
pack_price = row[:pack_price]
|
pack_price = row[:pack_price]
|
||||||
number = row[:number]
|
number = row[:order_number]
|
||||||
name = row[:name]
|
name = row[:name]
|
||||||
unit = nil
|
unit = nil
|
||||||
manufacturer = nil
|
manufacturer = nil
|
||||||
|
@ -129,7 +129,7 @@ module FoodsoftArticleImport
|
||||||
errors << check_price(unit, unit_quantity, unit_price, pack_price)
|
errors << check_price(unit, unit_quantity, unit_price, pack_price)
|
||||||
# create new article
|
# create new article
|
||||||
name.gsub!(/\s+/, ' ')
|
name.gsub!(/\s+/, ' ')
|
||||||
article = {:number => number,
|
article = {:order_number => number,
|
||||||
:name => name.strip,
|
:name => name.strip,
|
||||||
:note => notes.count > 0 && notes.map(&:strip).join("; "),
|
:note => notes.count > 0 && notes.map(&:strip).join("; "),
|
||||||
:manufacturer => manufacturer,
|
:manufacturer => manufacturer,
|
||||||
|
@ -139,7 +139,7 @@ module FoodsoftArticleImport
|
||||||
:unit_quantity => unit_quantity,
|
:unit_quantity => unit_quantity,
|
||||||
:tax => 6,
|
:tax => 6,
|
||||||
:deposit => 0,
|
:deposit => 0,
|
||||||
:category => prod_category || category
|
:article_category => prod_category || category
|
||||||
}
|
}
|
||||||
errors.compact!
|
errors.compact!
|
||||||
if errors.count > 0
|
if errors.count > 0
|
||||||
|
|
|
@ -61,11 +61,11 @@ module FoodsoftArticleImport
|
||||||
unless row[0] == "" || row[0].nil?
|
unless row[0] == "" || row[0].nil?
|
||||||
article = {
|
article = {
|
||||||
:name => row[6],
|
:name => row[6],
|
||||||
:number => row[0],
|
:order_number => row[0],
|
||||||
:note => row[7],
|
:note => row[7],
|
||||||
:manufacturer => self.translate(:manufacturer, row[10]),
|
:manufacturer => self.translate(:manufacturer, row[10]),
|
||||||
:origin => row[12],
|
:origin => row[12],
|
||||||
:category => self.translate(:category, row[16]),
|
:article_category => self.translate(:category, row[16]),
|
||||||
:unit => row[23],
|
:unit => row[23],
|
||||||
:price => row[37],
|
:price => row[37],
|
||||||
:tax => self.translate(:tax, row[33]),
|
:tax => self.translate(:tax, row[33]),
|
||||||
|
|
|
@ -70,7 +70,7 @@ module FoodsoftArticleImport
|
||||||
end
|
end
|
||||||
|
|
||||||
article = {
|
article = {
|
||||||
:number => row[1],
|
:order_number => row[1],
|
||||||
:name => name,
|
:name => name,
|
||||||
:origin => origin,
|
:origin => origin,
|
||||||
:manufacturer => manufacturer,
|
:manufacturer => manufacturer,
|
||||||
|
|
|
@ -39,7 +39,7 @@ module FoodsoftArticleImport
|
||||||
@@codes[:indeling][row.search('subindeling').text.to_i]
|
@@codes[:indeling][row.search('subindeling').text.to_i]
|
||||||
].compact.join(' - ')
|
].compact.join(' - ')
|
||||||
|
|
||||||
article = {:number => row.search('bestelnummer').text,
|
article = {:order_number => row.search('bestelnummer').text,
|
||||||
#:ean => row.search('eancode').text,
|
#:ean => row.search('eancode').text,
|
||||||
:name => row.search('omschrijving').text,
|
:name => row.search('omschrijving').text,
|
||||||
:note => row.search('kwaliteit').text,
|
:note => row.search('kwaliteit').text,
|
||||||
|
@ -50,7 +50,7 @@ module FoodsoftArticleImport
|
||||||
:unit_quantity => row.search('sve').text,
|
:unit_quantity => row.search('sve').text,
|
||||||
:tax => row.search('btw').text,
|
:tax => row.search('btw').text,
|
||||||
:deposit => deposit,
|
:deposit => deposit,
|
||||||
:category => category}
|
:article_category => category}
|
||||||
|
|
||||||
yield article, (row.search('status') == 'Actief' ? :outlisted : nil), i
|
yield article, (row.search('status') == 'Actief' ? :outlisted : nil), i
|
||||||
end
|
end
|
||||||
|
|
|
@ -34,7 +34,7 @@ module FoodsoftArticleImport::Foodsoft
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
article = {:number => row[1],
|
article = {:order_number => row[1],
|
||||||
:name => row[2],
|
:name => row[2],
|
||||||
:note => row[3],
|
:note => row[3],
|
||||||
:manufacturer => row[4],
|
:manufacturer => row[4],
|
||||||
|
@ -45,9 +45,9 @@ module FoodsoftArticleImport::Foodsoft
|
||||||
:unit_quantity => row[10],
|
:unit_quantity => row[10],
|
||||||
:scale_quantity => row[11],
|
:scale_quantity => row[11],
|
||||||
:scale_price => row[12],
|
:scale_price => row[12],
|
||||||
:category => row[13]}
|
:article_category => row[13]}
|
||||||
article.merge!(:deposit => row[9]) unless row[9].nil?
|
article.merge!(:deposit => row[9]) unless row[9].nil?
|
||||||
article[:number].blank? and ArticleImport.generate_number(article)
|
article[:order_number].blank? and ArticleImport.generate_number(article)
|
||||||
if row[6].nil? || row[7].nil? or row[8].nil?
|
if row[6].nil? || row[7].nil? or row[8].nil?
|
||||||
yield article, "Error: unit, price and tax must be entered", i
|
yield article, "Error: unit, price and tax must be entered", i
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Reference in a new issue