Skip to content

Commit

Permalink
Article CSV: fix #47 and partly #46
Browse files Browse the repository at this point in the history
- rearrange CSV columns as I suggested in #47
- add locales for column headings according to my suggestions in #50 (to do: adjust terms across menus -- post-merge?)
- update documentation of CSV layout (#46)

TO DO:
#83, #81 (more important)
#80, #82 (less important)
  • Loading branch information
twothreenine committed Jul 22, 2024
1 parent 5be0082 commit cb6b868
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 64 deletions.
42 changes: 21 additions & 21 deletions app/lib/articles_csv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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,
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
Expand Down
28 changes: 14 additions & 14 deletions app/lib/foodsoft_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
72 changes: 44 additions & 28 deletions app/views/articles/upload.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,66 +5,82 @@
%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
%tr
%td
%td 1234A
%td= t '.sample.walnuts'
%td= ArticleUnitsLib.get_translated_name_for_code('KGM')
%td
%td= t '.sample.supplier_1'
%td CA
%td 500 gr
%td 8.90
%td
%td
%td= ArticleUnitsLib.get_translated_name_for_code('KGM')
%td 0.5
%td= ArticleUnitsLib.get_translated_name_for_code('KGM')
%td 17.80
%td= ArticleUnitsLib.get_translated_name_for_code('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= ArticleUnitsLib.get_translated_name_for_code('XJY')
%td
%td= '1.5 ' + ArticleUnitsLib.get_translated_name_for_code('LTR')
%td
%td
%td 1
%td= ArticleUnitsLib.get_translated_name_for_code('XJY')
%td 4.35
%td= ArticleUnitsLib.get_translated_name_for_code('XJY')
%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= ArticleUnitsLib.get_translated_name_for_code('XBO')
%td
%td= '1.2 ' + ArticleUnitsLib.get_translated_name_for_code('LTR')
%td 4
%td= ArticleUnitsLib.get_translated_name_for_code('LTR')
%td 1
%td= ArticleUnitsLib.get_translated_name_for_code('XBO')
%td 4.02
%td= ArticleUnitsLib.get_translated_name_for_code('LTR')
%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'

Expand Down
8 changes: 8 additions & 0 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cb6b868

Please sign in to comment.