diff --git a/app/lib/articles_csv.rb b/app/lib/articles_csv.rb index 6c46a836..ac8350cd 100644 --- a/app/lib/articles_csv.rb +++ b/app/lib/articles_csv.rb @@ -6,21 +6,21 @@ def header Article.human_attribute_name(:availability_short), Article.human_attribute_name(:order_number), Article.human_attribute_name(:name), - Article.human_attribute_name(:note), - Article.human_attribute_name(:manufacturer), - Article.human_attribute_name(:origin), - Article.human_attribute_name(:unit), - Article.human_attribute_name(:price), - Article.human_attribute_name(:tax), - Article.human_attribute_name(:deposit), Article.human_attribute_name(:supplier_order_unit), - Article.human_attribute_name(:price_unit), - Article.human_attribute_name(:group_order_unit), - Article.human_attribute_name(:group_order_granularity), + Article.human_attribute_name(:custom_unit), + Article.human_attribute_name(:ratios_to_supplier_order_unit), Article.human_attribute_name(:minimum_order_quantity), Article.human_attribute_name(:billing_unit), + Article.human_attribute_name(:group_order_granularity), + Article.human_attribute_name(:group_order_unit), + Article.human_attribute_name(:price), + Article.human_attribute_name(:price_unit), + Article.human_attribute_name(:tax), + Article.human_attribute_name(:deposit), + Article.human_attribute_name(:note), Article.human_attribute_name(:article_category), - Article.human_attribute_name(:ratios_to_supplier_order_unit) + Article.human_attribute_name(:origin), + Article.human_attribute_name(:manufacturer) ] end @@ -30,21 +30,21 @@ def data article.availability ? I18n.t('simple_form.yes') : I18n.t('simple_form.no'), article.order_number, article.name, - article.note, - article.manufacturer, - article.origin, + ArticleUnitsLib.get_translated_name_for_code(article.supplier_order_unit), article.unit, + get_csv_ratios(article), + article.minimum_order_quantity, + ArticleUnitsLib.get_translated_name_for_code(article.billing_unit), + article.group_order_granularity, + ArticleUnitsLib.get_translated_name_for_code(article.group_order_unit), article.price_unit_price, + ArticleUnitsLib.get_translated_name_for_code(article.price_unit), article.tax, article.deposit, - ArticleUnitsLib.get_translated_name_for_code(article.supplier_order_unit), - ArticleUnitsLib.get_translated_name_for_code(article.price_unit), - ArticleUnitsLib.get_translated_name_for_code(article.group_order_unit), - article.group_order_granularity, - article.minimum_order_quantity, - ArticleUnitsLib.get_translated_name_for_code(article.billing_unit), + article.note, article.article_category.try(:name), - get_csv_ratios(article) + article.origin, + article.manufacturer ] end end diff --git a/app/lib/foodsoft_file.rb b/app/lib/foodsoft_file.rb index 17a26ba5..deca4d22 100644 --- a/app/lib/foodsoft_file.rb +++ b/app/lib/foodsoft_file.rb @@ -11,21 +11,21 @@ def self.parse(file, options = {}) article = { availability: row[0]&.strip == I18n.t('simple_form.yes'), order_number: row[1], name: row[2], - note: row[3], - manufacturer: row[4], - origin: row[5], - unit: row[6], - price: row[7], - tax: row[8], - deposit: (row[9].nil? ? '0' : row[9]), - supplier_order_unit: ArticleUnitsLib.get_code_for_unit_name(row[10]), + supplier_order_unit: ArticleUnitsLib.get_code_for_unit_name(row[3]), + unit: row[4], + article_unit_ratios: FoodsoftFile.parse_ratios_cell(row[5]), + minimum_order_quantity: row[6], + billing_unit: ArticleUnitsLib.get_code_for_unit_name(row[7]), + group_order_granularity: row[8], + group_order_unit: ArticleUnitsLib.get_code_for_unit_name(row[9]), + price: row[10], price_unit: ArticleUnitsLib.get_code_for_unit_name(row[11]), - group_order_unit: ArticleUnitsLib.get_code_for_unit_name(row[12]), - group_order_granularity: row[13], - minimum_order_quantity: row[14], - billing_unit: ArticleUnitsLib.get_code_for_unit_name(row[15]), - article_category: row[16], - article_unit_ratios: FoodsoftFile.parse_ratios_cell(row[17]) } + tax: row[12], + deposit: (row[13].nil? ? '0' : row[13]), + note: row[14], + article_category: row[15], + origin: row[16], + manufacturer: row[17] } articles << article end diff --git a/app/views/articles/upload.html.haml b/app/views/articles/upload.html.haml index 8f91d790..b01fe0d2 100644 --- a/app/views/articles/upload.html.haml +++ b/app/views/articles/upload.html.haml @@ -5,66 +5,87 @@ %table.table.table-bordered %thead %tr - %th= t '.field.status' + %th= Article.human_attribute_name(:availability_short) %th= Article.human_attribute_name(:order_number) %th= Article.human_attribute_name(:name) - %th= Article.human_attribute_name(:note) - %th= Article.human_attribute_name(:manufacturer) - %th= Article.human_attribute_name(:origin) - %th= Article.human_attribute_name(:unit) + %th= Article.human_attribute_name(:supplier_order_unit) + %th= Article.human_attribute_name(:custom_unit) + %th= Article.human_attribute_name(:ratios_to_supplier_order_unit) + %th= Article.human_attribute_name(:minimum_order_quantity) + %th= Article.human_attribute_name(:billing_unit) + %th= Article.human_attribute_name(:group_order_granularity) + %th= Article.human_attribute_name(:group_order_unit) %th= Article.human_attribute_name(:price) + %th= Article.human_attribute_name(:price_unit) %th= Article.human_attribute_name(:tax) %th= Article.human_attribute_name(:deposit) - %th= Article.human_attribute_name(:unit_quantity) - %th.muted= t '.fields.reserved' - %th.muted= t '.fields.reserved' + %th= Article.human_attribute_name(:note) %th= Article.human_attribute_name(:article_category) + %th= Article.human_attribute_name(:origin) + %th= Article.human_attribute_name(:manufacturer) %tbody + - kgm = ArticleUnitsLib.get_translated_name_for_code('KGM') + - xjy = ArticleUnitsLib.get_translated_name_for_code('XJY') + - ltr = ArticleUnitsLib.get_translated_name_for_code('LTR') + - xbd = ArticleUnitsLib.get_translated_name_for_code('XBD') + - xbo = ArticleUnitsLib.get_translated_name_for_code('XBO') %tr %td %td 1234A %td= t '.sample.walnuts' + %td= kgm %td - %td= t '.sample.supplier_1' - %td CA - %td 500 gr - %td 8.90 + %td + %td + %td= kgm + %td 0.5 + %td= kgm + %td 17.80 + %td= kgm %td= FoodsoftConfig[:tax_default] || 6 %td 0 - %td 6 - %td %td %td= t '.sample.nuts' + %td CA + %td= t '.sample.supplier_1' %tr %td x %td 4321Z %td= t '.sample.tomato_juice' - %td= t '.sample.organic' - %td= t '.sample.supplier_2' - %td IN - %td 1.5 l + %td= xjy + %td + %td= '1.5 ' + ltr + %td 4 + %td= ltr + %td 1 + %td= xjy %td 4.35 + %td= ltr %td= FoodsoftConfig[:tax_default] || 6 %td 0 - %td 1 - %td - %td + %td= t '.sample.organic' %td= t '.sample.juices' + %td IN + %td= t '.sample.supplier_2' %tr %td %td 4322Q %td= t '.sample.tomato_juice' - %td= t '.sample.organic' - %td= t '.sample.supplier_3' - %td TR - %td 1.2 l + %td= xbd + %td + %td= '6 ' + xbo + ', 1 ' + ltr + %td + %td= xbd + %td 1 + %td= xbo %td 4.02 + %td= xbo %td= FoodsoftConfig[:tax_default] || 6 %td 0 - %td 2 - %td - %td + %td= t '.sample.organic' %td= t '.sample.juices' + %td TR + %td= t '.sample.supplier_3' %p= t '.text_2' diff --git a/config/locales/de.yml b/config/locales/de.yml index 2b26fb4f..01ea2183 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -22,9 +22,17 @@ de: supplier: Lieferantin tax: MwSt unit: Einheit + custom_unit: Benutzerdefinierte Einheit unit_quantity: Gebindegröße unit_quantity_short: GebGr units: Gebinde + supplier_order_unit: von Lieferantin bestellbar in (Einheit) + ratios_to_supplier_order_unit: Inhalt + minimum_order_quantity: Mindestbestellmenge + billing_unit: abgerechnet nach (Einheit) + group_order_granularity: für Mitglieder bestellbar in (Menge) + group_order_unit: für Mitglieder bestellbar in (Einheit) + price_unit: pro (Preiseinheit) article_unit: code: Einheitencode gemäß Empfehlung der United Nations Economic Commission (UNECE) code_short: Code diff --git a/config/locales/en.yml b/config/locales/en.yml index 97db48b7..319f1a1f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -22,10 +22,18 @@ en: supplier: Supplier tax: VAT unit: Unit + custom_unit: Custom unit unit_quantity: Unit quantity unit_quantity_short: U.Q. units: Units - supplier_order_unit: Supplier order unit + supplier_order_unit: orderable from supplier per (unit) + ratios_to_supplier_order_unit: Content + minimum_order_quantity: Minimum order quantity + billing_unit: billed per (unit) + group_order_granularity: members can order per (amount) + group_order_unit: members can order per (unit) + price_unit: per (price unit) + article_unit: code: Unit code according to the recommendation of the United Nations Economic Commission (UNECE) code_short: Code diff --git a/spec/fixtures/foodsoft_file_01.csv b/spec/fixtures/foodsoft_file_01.csv index 95af087c..99e6b4d8 100644 --- a/spec/fixtures/foodsoft_file_01.csv +++ b/spec/fixtures/foodsoft_file_01.csv @@ -1,5 +1,5 @@ -avail.;Order number;Name;Note;Manufacturer;Origin;Unit;Price (net);VAT;Deposit;Supplier order unit;Price unit;Group order unit;Group order granularity;Minimum order quantity;Billing unit;Category;Ratios to supplier order unit -Yes;29932;Walnoten (ongeroosterd);bio ◎;Het grote bomenbos;Veluwe, NL;kg;2.34;6;0;;;;1;;;Nuts; -Yes;28391;Pijnboompitten;dem;Het warme woud;TR;100g;5.56;6;0;;;;1;;;Nuts;10 Piece -Yes;1829;Appelsap (verpakt);;Appelgaarde;DE;4x250ml;3.21;6;0.4;;;;1;;;Drinks;10 Piece -Yes;177813;Tomaten;bio;De röde hof;Best, NL;500 g;1.2;6;0;;;;1;;;Vegetables;20 Piece +avail.;Order number;Name;Supplier order unit;Unit;Ratios to supplier order unit;Minimum order quantity;Billing unit;Group order granularity;Group order unit;Price (net);Price unit;VAT;Deposit;Note;Category;Origin;Manufacturer +Yes;29932;Walnoten (ongeroosterd);;kg;;;;1;;2.34;;6;0;bio ◎;Nuts;Veluwe, NL;Het grote bomenbos +Yes;28391;Pijnboompitten;;100g;10 Piece;;;1;;5.56;;6;0;dem;Nuts;TR;Het warme woud +Yes;1829;Appelsap (verpakt);;4x250ml;10 Piece;;;1;;3.21;;6;0.4;;Drinks;DE;Appelgaarde +Yes;177813;Tomaten;;500 g;20 Piece;;;1;;1.2;;6;0;bio;Vegetables;Best, NL;De röde hof diff --git a/spec/fixtures/foodsoft_file_01.ods b/spec/fixtures/foodsoft_file_01.ods index b18f6620..85a14245 100644 Binary files a/spec/fixtures/foodsoft_file_01.ods and b/spec/fixtures/foodsoft_file_01.ods differ diff --git a/spec/fixtures/foodsoft_file_01.xls b/spec/fixtures/foodsoft_file_01.xls index 409ba1bd..b1d1059f 100644 Binary files a/spec/fixtures/foodsoft_file_01.xls and b/spec/fixtures/foodsoft_file_01.xls differ diff --git a/spec/fixtures/foodsoft_file_01.xlsx b/spec/fixtures/foodsoft_file_01.xlsx index 07fee06d..cf094a79 100644 Binary files a/spec/fixtures/foodsoft_file_01.xlsx and b/spec/fixtures/foodsoft_file_01.xlsx differ diff --git a/spec/fixtures/foodsoft_file_02.csv b/spec/fixtures/foodsoft_file_02.csv index f0e92c3a..866fa0c4 100644 --- a/spec/fixtures/foodsoft_file_02.csv +++ b/spec/fixtures/foodsoft_file_02.csv @@ -1,2 +1,2 @@ -avail.;Order number;Name;Note;Manufacturer;Origin;Unit;Price (net);VAT;Deposit;Supplier order unit;Price unit;Group order unit;Group order granularity;Minimum order quantity;Billing unit;Category;Ratios to supplier order unit -Yes;1;Tomatoes;organic;Tommy farm;Somewhere, UK;500 g;1.2;6;0;;;;1;;;Vegetables;20 Piece +avail.;Order number;Name;Supplier order unit;Unit;Ratios to supplier order unit;Minimum order quantity;Billing unit;Group order granularity;Group order unit;Price (net);Price unit;VAT;Deposit;Note;Category;Origin;Manufacturer +Yes;1;Tomatoes;;500 g;20 Piece;;;1;;1.2;;6;0;organic;Vegetables;Somewhere, UK;Tommy farm