mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
fix reported issues:
- wrong enterprise fees - always 0 tax on fees
This commit is contained in:
committed by
Rachel Arnould
parent
ed559b5257
commit
298c0e8d7f
@@ -109,9 +109,10 @@ module Reporting
|
||||
proc do |line_item|
|
||||
total_price = total_excl_vat_and_fees.call(line_item)
|
||||
total_fees = total_fees_excl_vat.call(line_item)
|
||||
total_fees_tax = total_vat_on_fees.call(line_item)
|
||||
tax = total_tax.call(line_item)
|
||||
|
||||
total_price + total_fees + tax
|
||||
total_price + total_fees + total_fees_tax + tax
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -25,11 +25,22 @@ module Reporting
|
||||
line_item.order_cycle
|
||||
end
|
||||
|
||||
def suppliers_adjustments(line_item, adjustment_type = 'EnterpriseFee')
|
||||
adjustments = line_item.adjustments
|
||||
return adjustments if adjustment_type == 'Spree::TaxRate'
|
||||
|
||||
supplier_name = supplier(line_item).name
|
||||
adjustments.select do |adjustment|
|
||||
label = adjustment.label
|
||||
|
||||
label.include?('supplier') && label.include?(supplier_name)
|
||||
end
|
||||
end
|
||||
|
||||
def adjustments_by_type(line_item, type, included: false)
|
||||
total_amount = 0.0
|
||||
adjustment_type = type == :tax ? 'Spree::TaxRate' : 'EnterpriseFee'
|
||||
adjustments = line_item.adjustments
|
||||
adjustments.each do |adjustment|
|
||||
suppliers_adjustments(line_item, adjustment_type).each do |adjustment|
|
||||
if adjustment.originator_type == adjustment_type
|
||||
amount = included == adjustment.included ? adjustment.amount : 0.0
|
||||
total_amount += amount
|
||||
@@ -41,13 +52,11 @@ module Reporting
|
||||
|
||||
def tax_on_fees(line_item, included: false)
|
||||
total_amount = 0.0
|
||||
adjustments = line_item.adjustments
|
||||
|
||||
adjustments.each do |adjustment|
|
||||
suppliers_adjustments(line_item).each do |adjustment|
|
||||
next unless adjustment.originator_type == 'EnterpriseFee'
|
||||
|
||||
adjustment.adjustments.each do |fee_adjustment|
|
||||
next unless adjustment.originator_type == 'Spree::TaxRate'
|
||||
next unless fee_adjustment.originator_type == 'Spree::TaxRate'
|
||||
|
||||
amount = included == fee_adjustment.included ? fee_adjustment.amount : 0.0
|
||||
total_amount += amount
|
||||
|
||||
Reference in New Issue
Block a user