mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
13013: add tax on product column
This commit is contained in:
@@ -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})"
|
||||
|
||||
@@ -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:,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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|
|
||||
|
||||
Reference in New Issue
Block a user