mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-13 23:37:47 +00:00
Re-apply taxes in Admin::OrdersController#update
Ensures taxes are updated properly when hitting the "Update and Recalculate Fees" button on the order edit page.
This commit is contained in:
@@ -37,6 +37,11 @@ module Spree
|
||||
def update
|
||||
@order.recreate_all_fees!
|
||||
|
||||
unless @order.cart?
|
||||
@order.create_tax_charge!
|
||||
@order.update_order!
|
||||
end
|
||||
|
||||
unless order_params.present? && @order.update(order_params) && @order.line_items.present?
|
||||
if @order.line_items.empty? && !params[:suppress_error_msg]
|
||||
@order.errors.add(:line_items, Spree.t('errors.messages.blank'))
|
||||
|
||||
@@ -58,12 +58,19 @@ describe Spree::Admin::OrdersController, type: :controller do
|
||||
expect(response.status).to eq 302
|
||||
end
|
||||
|
||||
it "updates distribution charges and redirects to order details page" do
|
||||
expect_any_instance_of(Spree::Order).to receive(:recreate_all_fees!)
|
||||
context "recalculating fees and taxes" do
|
||||
before do
|
||||
allow(Spree::Order).to receive_message_chain(:includes, :find_by!) { order }
|
||||
end
|
||||
|
||||
spree_put :update, params
|
||||
it "updates fees and taxes and redirects to order details page" do
|
||||
expect(order).to receive(:recreate_all_fees!)
|
||||
expect(order).to receive(:create_tax_charge!)
|
||||
|
||||
expect(response).to redirect_to spree.edit_admin_order_path(order)
|
||||
spree_put :update, params
|
||||
|
||||
expect(response).to redirect_to spree.edit_admin_order_path(order)
|
||||
end
|
||||
end
|
||||
|
||||
context "recalculating enterprise fees" do
|
||||
|
||||
Reference in New Issue
Block a user