introduces format_percentage in ReportRowBuilder#format_cell

This commit is contained in:
Mohamed ABDELLANI
2023-01-17 10:50:18 +01:00
parent 4822be532b
commit 92c4bd9eb7
3 changed files with 17 additions and 4 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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)