Update order total when editing admin adjustments

This commit is contained in:
Matt-Yorkley
2021-03-15 11:46:14 +00:00
parent 2341494555
commit 6f35e4e662
2 changed files with 11 additions and 2 deletions

View File

@@ -2,17 +2,18 @@ module Spree
module Admin
class AdjustmentsController < ::Admin::ResourceController
belongs_to 'spree/order', find_by: :number
destroy.after :reload_order
prepend_before_action :set_included_tax, only: [:create, :update]
before_action :set_order_id, only: [:create, :update]
after_action :update_order, only: [:create, :update, :destroy]
before_action :set_default_tax_rate, only: :edit
before_action :enable_updates, only: :update
private
def reload_order
def update_order
@order.reload
@order.update!
end
def collection

View File

@@ -22,6 +22,8 @@ module Spree
expect(a.amount).to eq(110)
expect(a.included_tax).to eq(0)
expect(a.order_id).to eq(order.id)
expect(order.reload.total).to eq 110
end
it "calculates included tax when a tax rate is provided" do
@@ -33,6 +35,8 @@ module Spree
expect(a.amount).to eq(110)
expect(a.included_tax).to eq(10)
expect(a.order_id).to eq(order.id)
expect(order.reload.total).to eq 110
end
end
@@ -50,6 +54,8 @@ module Spree
expect(a.amount).to eq(110)
expect(a.included_tax).to eq(0)
expect(a.order_id).to eq(order.id)
expect(order.reload.total).to eq 110
end
it "calculates included tax when a tax rate is provided" do
@@ -61,6 +67,8 @@ module Spree
expect(a.amount).to eq(110)
expect(a.included_tax).to eq(10)
expect(a.order_id).to eq(order.id)
expect(order.reload.total).to eq 110
end
end
end