Ensure order association is set correctly when adding admin adjustments

This commit is contained in:
Matt-Yorkley
2021-03-15 11:15:23 +00:00
parent 8531d82f02
commit 3219ea231d
2 changed files with 9 additions and 0 deletions

View File

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

View File

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