mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Simplify order.adjustment_total sum
This commit is contained in:
@@ -57,8 +57,7 @@ module OrderManagement
|
||||
end
|
||||
|
||||
def update_adjustment_total
|
||||
order.adjustment_total = adjustments.eligible.sum(:amount) +
|
||||
all_adjustments.shipping.sum(:amount)
|
||||
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.sum(:included_tax) +
|
||||
all_adjustments.enterprise_fee.sum(:included_tax) +
|
||||
|
||||
@@ -28,7 +28,7 @@ module OrderManagement
|
||||
end
|
||||
|
||||
it "updates adjustment totals" do
|
||||
allow(order).to receive_message_chain(:adjustments, :eligible, :sum).and_return(-10)
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user