diff --git a/config/locales/en.yml b/config/locales/en.yml index b67986c78c..26d12688c5 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -3321,6 +3321,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using report_header_admin_handling_fees: "Admin & Handling (%{currency})" report_header_ship_price: "Ship (%{currency})" report_header_producer_charges_gst: Producer charges GST? + report_header_total_tax_on_product: Total tax on product report_header_pay_fee_price: "Pay fee (%{currency})" report_header_total_price: "Total (%{currency})" report_header_product_total_price: "Product Total (%{currency})" diff --git a/lib/reporting/reports/suppliers/base.rb b/lib/reporting/reports/suppliers/base.rb index dadc4a2b78..e1e8cc0d0d 100644 --- a/lib/reporting/reports/suppliers/base.rb +++ b/lib/reporting/reports/suppliers/base.rb @@ -44,6 +44,7 @@ module Reporting total_excl_fees_and_tax:, total_excl_vat:, total_fees_excl_tax:, + total_tax_on_product:, total_tax_on_fees:, total_tax:, total:, diff --git a/lib/reporting/reports/suppliers/helpers/columns_helper.rb b/lib/reporting/reports/suppliers/helpers/columns_helper.rb index f110822cbd..6e853d8969 100644 --- a/lib/reporting/reports/suppliers/helpers/columns_helper.rb +++ b/lib/reporting/reports/suppliers/helpers/columns_helper.rb @@ -25,7 +25,7 @@ module Reporting def producer_charges_gst proc do |line_items| - supplier(line_items).charges_sales_tax ? I18n.t(:yes) : I18n.t(:no) + supplier(line_items).charges_sales_tax end end @@ -86,8 +86,7 @@ module Reporting def total_excl_vat proc do |line_item| - total_fees = adjustments_by_type(line_item, :fees) - total_excl_fees_and_tax.call(line_item) + total_fees + total_excl_fees_and_tax.call(line_item) + total_fees_excl_tax.call(line_item) end end @@ -98,11 +97,7 @@ module Reporting end end - def total_tax_on_fees - proc { |line_item| tax_on_fees(line_item) + tax_on_fees(line_item, included: true) } - end - - def total_tax + def total_tax_on_product proc do |line_item| excluded_tax = adjustments_by_type(line_item, :tax) included_tax = adjustments_by_type(line_item, :tax, included: true) @@ -111,14 +106,19 @@ module Reporting end end + def total_tax_on_fees + proc { |line_item| tax_on_fees(line_item) + tax_on_fees(line_item, included: true) } + end + + def total_tax + proc do |line_item| + total_tax_on_product.call(line_item) + total_tax_on_fees.call(line_item) + end + end + def total proc do |line_item| - total_price = total_excl_fees_and_tax.call(line_item) - total_fees = total_fees_excl_tax.call(line_item) - total_fees_tax = total_tax_on_fees.call(line_item) - tax = total_tax.call(line_item) - - total_price + total_fees + total_fees_tax + tax + total_excl_vat.call(line_item) + total_tax.call(line_item) end end end diff --git a/lib/reporting/reports/suppliers/helpers/line_items_access_helper.rb b/lib/reporting/reports/suppliers/helpers/line_items_access_helper.rb index 3152cac7dd..4b1f16a35c 100644 --- a/lib/reporting/reports/suppliers/helpers/line_items_access_helper.rb +++ b/lib/reporting/reports/suppliers/helpers/line_items_access_helper.rb @@ -38,8 +38,11 @@ module Reporting end def adjustments_by_type(line_item, type, included: false) + is_tax = type == :tax + return 0.0 if is_tax && !supplier(line_item).charges_sales_tax + total_amount = 0.0 - adjustment_type = type == :tax ? 'Spree::TaxRate' : 'EnterpriseFee' + adjustment_type = is_tax ? 'Spree::TaxRate' : 'EnterpriseFee' suppliers_adjustments(line_item, adjustment_type).each do |adjustment| amount = included == adjustment.included ? adjustment.amount : 0.0 total_amount += amount @@ -49,6 +52,8 @@ module Reporting end def tax_on_fees(line_item, included: false) + return 0.0 unless supplier(line_item).charges_sales_tax + total_amount = 0.0 suppliers_adjustments(line_item).each do |adjustment| adjustment.adjustments.tax.each do |fee_adjustment|