Avoid auto-formatting currencies

Each report can define formats for each column. But currency formatting
was also applied to all columns that had "price" in the name. Removing
this automation gives us more control and we can decide for each case.

At the moment, the currency formatting in Excel spreadsheets is not
ideal and it's easier to keep it as number.

This PR introduces a visual regression as prices are not formatted as
nicely but the columns can be used in calculations.
This commit is contained in:
Maikel Linke
2022-05-26 16:30:52 +10:00
parent 40f3d4df4f
commit e37ec4b552
2 changed files with 5 additions and 5 deletions

View File

@@ -75,7 +75,7 @@ module Reporting
return "" if value.nil?
# Currency
if report.columns_format[column] == :currency || column.to_s.include?("price")
if report.columns_format[column] == :currency
format_currency(value)
# Quantity
elsif report.columns_format[column] == :quantity && report.html_render?

View File

@@ -310,17 +310,17 @@ describe '
expect(page).to have_table_row [product1.supplier.name, product1.supplier.address.city,
"Product Name",
product1.properties.map(&:presentation).join(", "),
product1.primary_taxon.name, "Test", "$100.00",
product1.primary_taxon.name, "Test", "100.0",
product1.group_buy_unit_size.to_s, "", "sku1"]
expect(page).to have_table_row [product1.supplier.name, product1.supplier.address.city,
"Product Name",
product1.properties.map(&:presentation).join(", "),
product1.primary_taxon.name, "Something", "$80.00",
product1.primary_taxon.name, "Something", "80.0",
product1.group_buy_unit_size.to_s, "", "sku2"]
expect(page).to have_table_row [product2.supplier.name, product1.supplier.address.city,
"Product 2",
product1.properties.map(&:presentation).join(", "),
product2.primary_taxon.name, "100g", "$99.00",
product2.primary_taxon.name, "100g", "99.0",
product1.group_buy_unit_size.to_s, "", "product_sku"]
end
@@ -332,7 +332,7 @@ describe '
expect(page).to have_table_row ['PRODUCT', 'Description', 'Qty', 'Pack Size', 'Unit',
'Unit Price', 'Total', 'GST incl.',
'Grower and growing method', 'Taxon'].map(&:upcase)
expect(page).to have_table_row ['Product 2', '100g', '', '100', 'g', '$99.00', '', '0',
expect(page).to have_table_row ['Product 2', '100g', '', '100', 'g', '99.0', '', '0',
'Supplier Name (Organic - NASAA 12345)', 'Taxon Name']
end
end