13013: add tax on product column

This commit is contained in:
Ahmed Ejaz
2024-12-08 00:29:48 +05:00
parent 6a613a2203
commit 71b2b7f97f
4 changed files with 22 additions and 15 deletions

View File

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

View File

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

View File

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

View File

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