mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-21 05:09:15 +00:00
Simplify tax adjustment sums in Order::Updater
This commit is contained in:
@@ -67,8 +67,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 = all_adjustments.tax.inclusive.sum(:amount) +
|
||||
adjustments.admin.sum(:included_tax)
|
||||
order.included_tax_total = all_adjustments.tax.inclusive.sum(:amount)
|
||||
end
|
||||
|
||||
def update_order_total
|
||||
|
||||
@@ -34,12 +34,11 @@ module OrderManagement
|
||||
:sum).and_return(20)
|
||||
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
|
||||
expect(order.adjustment_total).to eq(-5)
|
||||
expect(order.additional_tax_total).to eq(20)
|
||||
expect(order.included_tax_total).to eq(17)
|
||||
expect(order.included_tax_total).to eq(15)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user