Reports fix formatting cells

This commit is contained in:
Sebastian Castro
2022-05-04 15:57:31 +02:00
committed by Jean-Baptiste Bellet
parent 35b5ca3a51
commit 89212736e9
3 changed files with 11 additions and 11 deletions

View File

@@ -80,6 +80,9 @@ module Reporting
# Quantity
elsif report.columns_format[column] == :quantity && report.html_render?
format_quantity(value)
# Numeric
elsif report.columns_format[column] == :numeric
format_numeric(value)
# Boolean
elsif value.in? [true, false]
format_boolean(value)
@@ -89,9 +92,6 @@ module Reporting
# Date
elsif value.is_a?(Date)
format_date(value)
# Numeric
elsif value.is_a?(Numeric)
format_numeric(value)
# Default
else
value
@@ -100,7 +100,7 @@ module Reporting
# rubocop:enable Metrics/CyclomaticComplexity
def format_currency(value)
number_to_currency(value, unit: Spree::Money.currency_symbol)
value.present? ? number_to_currency(value, unit: Spree::Money.currency_symbol) : ""
end
def format_quantity(value)

View File

@@ -20,13 +20,13 @@ module Reporting
end
def order_number_column(order)
if raw_render?
order.number
else
if html_render?
url = Spree::Core::Engine.routes.url_helpers.edit_admin_order_path(order.number)
<<-HTML
<a href=#{url} class="edit-order" target="_blank">#{order.number}</a>
HTML
else
order.number
end
end
end

View File

@@ -182,8 +182,8 @@ describe '
expect(page).to have_content order1.number.to_s
# And the totals and sales tax should be correct
expect(page).to have_content "1,512.99" # items total
expect(page).to have_content "1,500.45" # taxable items total
expect(page).to have_content "1512.99" # items total
expect(page).to have_content "1500.45" # taxable items total
expect(page).to have_content "250.08" # sales tax
expect(page).to have_content "20.0" # enterprise fee tax
@@ -559,7 +559,7 @@ describe '
xero_invoice_header,
xero_invoice_summary_row('Total untaxable produce (no tax)', 12.54,
'GST Free Income'),
xero_invoice_summary_row('Total taxable produce (tax inclusive)', '1,500.45',
xero_invoice_summary_row('Total taxable produce (tax inclusive)', 1500.45,
'GST on Income'),
xero_invoice_summary_row('Total untaxable fees (no tax)', 10.0,
'GST Free Income'),
@@ -589,7 +589,7 @@ describe '
xero_invoice_header,
xero_invoice_summary_row('Total untaxable produce (no tax)', 12.54,
'GST Free Income', opts),
xero_invoice_summary_row('Total taxable produce (tax inclusive)', '1,500.45',
xero_invoice_summary_row('Total taxable produce (tax inclusive)', 1500.45,
'GST on Income', opts),
xero_invoice_summary_row('Total untaxable fees (no tax)', 10.0,
'GST Free Income', opts),