Simplify tax adjustment sums in Order::Updater

This commit is contained in:
Matt-Yorkley
2021-06-16 22:24:36 +01:00
parent 12c9914d1b
commit 3ae31ec1ce
2 changed files with 2 additions and 4 deletions

View File

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

View File

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