mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Update tax totals calculation in Order::Updater
Line items, shipments, and fees now all have taxes recorded in a uniform way, so we can drop more complexity here (and the number of queries).
This commit is contained in:
@@ -65,9 +65,7 @@ module OrderManagement
|
||||
def update_adjustment_total
|
||||
order.adjustment_total = all_adjustments.additional.eligible.sum(:amount)
|
||||
order.additional_tax_total = all_adjustments.tax.additional.sum(:amount)
|
||||
order.included_tax_total = order.line_item_adjustments.tax.inclusive.sum(:amount) +
|
||||
all_adjustments.enterprise_fee.sum(:included_tax) +
|
||||
order.shipment_adjustments.tax.inclusive.sum(:amount) +
|
||||
order.included_tax_total = all_adjustments.tax.inclusive.sum(:amount) +
|
||||
adjustments.admin.sum(:included_tax)
|
||||
end
|
||||
|
||||
|
||||
@@ -30,9 +30,7 @@ module OrderManagement
|
||||
it "updates adjustment totals" do
|
||||
allow(order).to receive_message_chain(:all_adjustments, :additional, :eligible, :sum).and_return(-5)
|
||||
allow(order).to receive_message_chain(:all_adjustments, :tax, :additional, :sum).and_return(20)
|
||||
allow(order).to receive_message_chain(:all_adjustments, :enterprise_fee, :sum).and_return(10)
|
||||
allow(order).to receive_message_chain(:all_adjustments, :shipping, :sum).and_return(5)
|
||||
allow(order).to receive_message_chain(:shipment_adjustments, :tax, :inclusive, :sum).and_return(5)
|
||||
allow(order).to receive_message_chain(:all_adjustments, :tax, :inclusive, :sum).and_return(15)
|
||||
allow(order).to receive_message_chain(:adjustments, :admin, :sum).and_return(2)
|
||||
|
||||
updater.update_adjustment_total
|
||||
|
||||
Reference in New Issue
Block a user