mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Update order total when editing admin adjustments
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user