mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Update Order::Updater to include shipment adjustments
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user