Update Order::Updater to include shipment adjustments

This commit is contained in:
Matt-Yorkley
2021-02-10 19:54:16 +00:00
parent 1aec324269
commit 00f116f35f
2 changed files with 5 additions and 4 deletions

View File

@@ -57,11 +57,12 @@ module OrderManagement
end
def update_adjustment_total
order.adjustment_total = adjustments.eligible.sum(:amount)
order.adjustment_total = adjustments.eligible.sum(:amount) +
all_adjustments.shipping.sum(:amount)
order.additional_tax_total = all_adjustments.tax.additional.sum(:amount)
order.included_tax_total = order.line_item_adjustments.tax.sum(:included_tax) +
all_adjustments.enterprise_fee.sum(:included_tax) +
adjustments.shipping.sum(:included_tax) +
all_adjustments.shipping.sum(:included_tax) +
adjustments.admin.sum(:included_tax)
end

View File

@@ -31,11 +31,11 @@ module OrderManagement
allow(order).to receive_message_chain(:adjustments, :eligible, :sum).and_return(-10)
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(:adjustments, :shipping, :sum).and_return(5)
allow(order).to receive_message_chain(:all_adjustments, :shipping, :sum).and_return(5)
allow(order).to receive_message_chain(:adjustments, :admin, :sum).and_return(2)
updater.update_adjustment_total
expect(order.adjustment_total).to eq(-10)
expect(order.adjustment_total).to eq(-5)
expect(order.additional_tax_total).to eq(20)
expect(order.included_tax_total).to eq(17)
end