diff --git a/lib/foodsoft_article_import/bioromeo.rb b/lib/foodsoft_article_import/bioromeo.rb index 9014041..a7f1ff4 100644 --- a/lib/foodsoft_article_import/bioromeo.rb +++ b/lib/foodsoft_article_import/bioromeo.rb @@ -136,10 +136,10 @@ module FoodsoftArticleImport } errors.compact! if errors.count > 0 - yield article, errors.join("\n") + yield article, errors.join("\n"), linenum else # outlisting not used by supplier - yield article, nil + yield article, nil, linenum end end end diff --git a/lib/foodsoft_article_import/bnn.rb b/lib/foodsoft_article_import/bnn.rb index 21bffc8..0dfa703 100644 --- a/lib/foodsoft_article_import/bnn.rb +++ b/lib/foodsoft_article_import/bnn.rb @@ -56,7 +56,15 @@ module FoodsoftArticleImport encoding = opts[:encoding] || OPTIONS[:encoding] col_sep = opts[:col_sep] || OPTIONS[:col_sep] self.load_codes(custom_file) - CSV.foreach(file, {col_sep: col_sep, encoding: encoding, headers: true}) do |row| + CSV.foreach(file, {col_sep: col_sep, encoding: encoding, headers: true}).with_index(1) do |row, i| + puts " + " + "______________" + " + " + "______________" + " + " + "______________" + " + " + "#{i}#{row}" + " + " + "______________"+ " + " + "______________"+ " + " + "______________" # check if the line is empty unless row[0] == "" || row[0].nil? article = { @@ -86,9 +94,9 @@ module FoodsoftArticleImport # N=neu, A=Änderung, X=ausgelistet, R=Restbestand, # V=vorübergehend ausgelistet, W=wiedergelistet elsif row[1] == "X" || row[1] == "V" - yield article, :outlisted + yield article, :outlisted, i else - yield article, nil + yield article, nil, i end end end diff --git a/lib/foodsoft_article_import/borkenstein.rb b/lib/foodsoft_article_import/borkenstein.rb index e02c4ff..c8d4f20 100644 --- a/lib/foodsoft_article_import/borkenstein.rb +++ b/lib/foodsoft_article_import/borkenstein.rb @@ -24,7 +24,7 @@ module FoodsoftArticleImport file.set_encoding(opts[:encoding] || OPTIONS[:encoding]) col_sep = opts[:col_sep] || OPTIONS[:col_sep] - CSV.new(file, {col_sep: col_sep, :headers => false}).each do |row| + CSV.new(file, {col_sep: col_sep, :headers => false}).each.with_index(1) do |row, i| # Set manufacturer if row[1] == "-" @@ -86,7 +86,7 @@ module FoodsoftArticleImport raise "Fehler: Einheit, Preis und MwSt. müssen gegeben sein: #{article.inspect}" end - yield article, nil + yield article, nil, i end end end diff --git a/lib/foodsoft_article_import/dnb_xml.rb b/lib/foodsoft_article_import/dnb_xml.rb index ae04870..efd21a6 100644 --- a/lib/foodsoft_article_import/dnb_xml.rb +++ b/lib/foodsoft_article_import/dnb_xml.rb @@ -20,7 +20,7 @@ module FoodsoftArticleImport Nokogiri::XML::ParseOptions::NONET + Nokogiri::XML::ParseOptions::COMPACT # do not modify doc! ) - doc.search('product').each do |row| + doc.search('product').each.with_index(1) do |row, i| # create a new article unit = row.search('eenheid').text unit = case(unit) @@ -52,7 +52,7 @@ module FoodsoftArticleImport :deposit => deposit, :category => category} - yield article, (row.search('status') == 'Actief' ? :outlisted : nil) + yield article, (row.search('status') == 'Actief' ? :outlisted : nil), i end end diff --git a/lib/foodsoft_article_import/foodsoft.rb b/lib/foodsoft_article_import/foodsoft.rb index 12d43d4..f837eee 100644 --- a/lib/foodsoft_article_import/foodsoft.rb +++ b/lib/foodsoft_article_import/foodsoft.rb @@ -21,7 +21,7 @@ module FoodsoftArticleImport::Foodsoft ss = FoodsoftArticleImport.open_spreadsheet(file, **opts) header_row = true - ss.sheet(0).each do |row| + ss.sheet(0).each.with_index(1) do |row, i| # skip first header row if header_row header_row = false @@ -45,9 +45,9 @@ module FoodsoftArticleImport::Foodsoft article.merge!(:deposit => row[9]) unless row[9].nil? article[: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" + yield article, "Error: unit, price and tax must be entered", i else - yield article, (row[0]=='x' ? :outlisted : nil) + yield article, (row[0]=='x' ? :outlisted : nil), i end end end