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 = s.downcase.gsub(/[^a-z0-9.]/,'')
|
||||
# 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
|
||||
end
|
||||
|
||||
|
|
|
@ -50,13 +50,13 @@ module FoodsoftArticleImport
|
|||
linenum += 1
|
||||
row[:name].blank? and next
|
||||
# (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]
|
||||
yield nil, nil, linenum
|
||||
next
|
||||
end
|
||||
# skip products without a number
|
||||
if row[:number].blank?
|
||||
if row[:order_number].blank?
|
||||
yield nil, nil, linenum
|
||||
next
|
||||
end
|
||||
|
@ -65,7 +65,7 @@ module FoodsoftArticleImport
|
|||
notes = []
|
||||
unit_price = row[:unit_price]
|
||||
pack_price = row[:pack_price]
|
||||
number = row[:number]
|
||||
number = row[:order_number]
|
||||
name = row[:name]
|
||||
unit = nil
|
||||
manufacturer = nil
|
||||
|
@ -129,7 +129,7 @@ module FoodsoftArticleImport
|
|||
errors << check_price(unit, unit_quantity, unit_price, pack_price)
|
||||
# create new article
|
||||
name.gsub!(/\s+/, ' ')
|
||||
article = {:number => number,
|
||||
article = {:order_number => number,
|
||||
:name => name.strip,
|
||||
:note => notes.count > 0 && notes.map(&:strip).join("; "),
|
||||
:manufacturer => manufacturer,
|
||||
|
@ -139,7 +139,7 @@ module FoodsoftArticleImport
|
|||
:unit_quantity => unit_quantity,
|
||||
:tax => 6,
|
||||
:deposit => 0,
|
||||
:category => prod_category || category
|
||||
:article_category => prod_category || category
|
||||
}
|
||||
errors.compact!
|
||||
if errors.count > 0
|
||||
|
|
|
@ -61,11 +61,11 @@ module FoodsoftArticleImport
|
|||
unless row[0] == "" || row[0].nil?
|
||||
article = {
|
||||
:name => row[6],
|
||||
:number => row[0],
|
||||
:order_number => row[0],
|
||||
:note => row[7],
|
||||
:manufacturer => self.translate(:manufacturer, row[10]),
|
||||
:origin => row[12],
|
||||
:category => self.translate(:category, row[16]),
|
||||
:article_category => self.translate(:category, row[16]),
|
||||
:unit => row[23],
|
||||
:price => row[37],
|
||||
:tax => self.translate(:tax, row[33]),
|
||||
|
|
|
@ -70,7 +70,7 @@ module FoodsoftArticleImport
|
|||
end
|
||||
|
||||
article = {
|
||||
:number => row[1],
|
||||
:order_number => row[1],
|
||||
:name => name,
|
||||
:origin => origin,
|
||||
:manufacturer => manufacturer,
|
||||
|
|
|
@ -39,7 +39,7 @@ module FoodsoftArticleImport
|
|||
@@codes[:indeling][row.search('subindeling').text.to_i]
|
||||
].compact.join(' - ')
|
||||
|
||||
article = {:number => row.search('bestelnummer').text,
|
||||
article = {:order_number => row.search('bestelnummer').text,
|
||||
#:ean => row.search('eancode').text,
|
||||
:name => row.search('omschrijving').text,
|
||||
:note => row.search('kwaliteit').text,
|
||||
|
@ -50,7 +50,7 @@ module FoodsoftArticleImport
|
|||
:unit_quantity => row.search('sve').text,
|
||||
:tax => row.search('btw').text,
|
||||
:deposit => deposit,
|
||||
:category => category}
|
||||
:article_category => category}
|
||||
|
||||
yield article, (row.search('status') == 'Actief' ? :outlisted : nil), i
|
||||
end
|
||||
|
|
|
@ -34,7 +34,7 @@ module FoodsoftArticleImport::Foodsoft
|
|||
next
|
||||
end
|
||||
|
||||
article = {:number => row[1],
|
||||
article = {:order_number => row[1],
|
||||
:name => row[2],
|
||||
:note => row[3],
|
||||
:manufacturer => row[4],
|
||||
|
@ -45,9 +45,9 @@ module FoodsoftArticleImport::Foodsoft
|
|||
:unit_quantity => row[10],
|
||||
:scale_quantity => row[11],
|
||||
:scale_price => row[12],
|
||||
:category => row[13]}
|
||||
:article_category => row[13]}
|
||||
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?
|
||||
yield article, "Error: unit, price and tax must be entered", i
|
||||
else
|
||||
|
|
Loading…
Add table
Reference in a new issue