gehirnpups

This commit is contained in:
viehlieb 2023-01-20 14:21:41 +01:00
parent 0ca60f53a6
commit 7a058847eb
3 changed files with 67 additions and 50 deletions

View file

@ -52,10 +52,14 @@ module FoodsoftArticleImport
# (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?
category = row[:name]
yield nil, nil, linenum
next
end
# skip products without a number
row[:number].blank? and next
if row[:number].blank?
yield nil, nil, linenum
next
end
# extract name and unit
errors = []
notes = []
@ -67,7 +71,10 @@ module FoodsoftArticleImport
manufacturer = nil
prod_category = nil
RES_PARSE_UNIT.each do |re|
m=name.match(re) or next
m=name.match(re)
unless m
yield nil, nil, linenum
end
unit = self.normalize_unit(m[3])
name = name.sub(re, '').sub(/\(\s*\)\s*$/,'').sub(/\s+/, ' ').sub(/\.\s*$/, '').strip
break

View file

@ -33,13 +33,15 @@ module FoodsoftArticleImport
end
# check if the line is empty
next if row[1].blank? || row[1] == "-"
unless row[1].blank? || row[1] == "-"
# Split string and remove beginning "
matched = row[2].gsub(/^\"/, "").gsub(/\"$/, "").match(REGEX[:main])
next if matched.nil?
if matched.nil?
puts "No regular article data for #{row[1]}: #{row[2]}"
yield nil, nil, nil
else
name, units, price_high, price_low = matched.captures
# Try to get origin
@ -86,5 +88,9 @@ module FoodsoftArticleImport
yield article, nil, i
end
end
yield nil, nil, i
end
end
end
end

View file

@ -25,10 +25,14 @@ module FoodsoftArticleImport::Foodsoft
# skip first header row
if header_row
header_row = false
yield nil, nil, i
next
end
# skip empty lines
next if row[2].blank?
if row[2].blank?
yield nil, nil, i
next
end
article = {:number => row[1],
:name => row[2],