mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Ensure order association is set correctly when adding admin adjustments
This commit is contained in:
@@ -5,6 +5,7 @@ module Spree
|
||||
destroy.after :reload_order
|
||||
|
||||
prepend_before_action :set_included_tax, only: [:create, :update]
|
||||
before_action :set_order_id, only: [:create, :update]
|
||||
before_action :set_default_tax_rate, only: :edit
|
||||
before_action :enable_updates, only: :update
|
||||
|
||||
@@ -22,6 +23,10 @@ module Spree
|
||||
parent.all_adjustments.eligible.find(params[:id])
|
||||
end
|
||||
|
||||
def set_order_id
|
||||
@adjustment.order_id = parent.id
|
||||
end
|
||||
|
||||
# Choose a default tax rate to show on the edit form. The adjustment stores its included
|
||||
# tax in dollars, but doesn't store the source of the tax (ie. TaxRate that generated it).
|
||||
# We guess which tax rate here, choosing:
|
||||
|
||||
@@ -21,6 +21,7 @@ module Spree
|
||||
expect(a.label).to eq('Testing included tax')
|
||||
expect(a.amount).to eq(110)
|
||||
expect(a.included_tax).to eq(0)
|
||||
expect(a.order_id).to eq(order.id)
|
||||
end
|
||||
|
||||
it "calculates included tax when a tax rate is provided" do
|
||||
@@ -31,6 +32,7 @@ module Spree
|
||||
expect(a.label).to eq('Testing included tax')
|
||||
expect(a.amount).to eq(110)
|
||||
expect(a.included_tax).to eq(10)
|
||||
expect(a.order_id).to eq(order.id)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -47,6 +49,7 @@ module Spree
|
||||
expect(a.label).to eq('Testing included tax')
|
||||
expect(a.amount).to eq(110)
|
||||
expect(a.included_tax).to eq(0)
|
||||
expect(a.order_id).to eq(order.id)
|
||||
end
|
||||
|
||||
it "calculates included tax when a tax rate is provided" do
|
||||
@@ -57,6 +60,7 @@ module Spree
|
||||
expect(a.label).to eq('Testing included tax')
|
||||
expect(a.amount).to eq(110)
|
||||
expect(a.included_tax).to eq(10)
|
||||
expect(a.order_id).to eq(order.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user