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:
Matt-Yorkley
2021-03-09 17:01:44 +00:00
parent a1438bdb3d
commit 6e9ae0b0db
2 changed files with 2 additions and 6 deletions

View File

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

View File

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