mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
introduces format_percentage in ReportRowBuilder#format_cell
This commit is contained in:
@@ -1373,6 +1373,7 @@ en:
|
||||
total_by_customer: Total By Customer
|
||||
total_by_supplier: Total By Supplier
|
||||
supplier_totals: Order Cycle Supplier Totals
|
||||
percentage: "%{value} %"
|
||||
supplier_totals_by_distributor: Order Cycle Supplier Totals by Distributor
|
||||
totals_by_supplier: Order Cycle Distributor Totals by Supplier
|
||||
customer_totals: Order Cycle Customer Totals
|
||||
|
||||
@@ -85,6 +85,9 @@ module Reporting
|
||||
# Numeric
|
||||
elsif report.columns_format[column] == :numeric
|
||||
format_numeric(value)
|
||||
# Percentage, a number between 0 and 1
|
||||
elsif report.columns_format[column] == :percentage
|
||||
format_percentage(value)
|
||||
# Boolean
|
||||
elsif value.in? [true, false]
|
||||
format_boolean(value)
|
||||
@@ -124,5 +127,11 @@ module Reporting
|
||||
def format_numeric(value)
|
||||
number_with_delimiter(value)
|
||||
end
|
||||
|
||||
def format_percentage(value)
|
||||
return '' if value.blank?
|
||||
|
||||
I18n.t('admin.reports.percentage', value: value * 100)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -51,6 +51,12 @@ module Reporting
|
||||
}
|
||||
end
|
||||
|
||||
def columns_format
|
||||
{
|
||||
tax_rate: :percentage
|
||||
}
|
||||
end
|
||||
|
||||
def rules
|
||||
[
|
||||
{
|
||||
@@ -108,10 +114,7 @@ module Reporting
|
||||
end
|
||||
|
||||
def tax_rate_amount(query_result_row)
|
||||
amount = tax_rate(query_result_row)&.amount
|
||||
return if amount.nil?
|
||||
|
||||
"#{amount * 100} %"
|
||||
tax_rate(query_result_row)&.amount
|
||||
end
|
||||
|
||||
def total_excl_tax(query_result_row)
|
||||
|
||||
Reference in New Issue
Block a user