Recalculate taxes when an order's customer details are changed

This commit is contained in:
Matt-Yorkley
2021-06-28 15:35:01 +01:00
parent d55079f474
commit 41757254d6

View File

@@ -26,6 +26,7 @@ module Spree
end
refresh_shipment_rates
recalculate_taxes
OrderWorkflow.new(@order).advance_to_payment
flash[:success] = Spree.t('customer_details_updated')
@@ -47,6 +48,15 @@ module Spree
@order.shipments.map(&:refresh_rates)
end
def recalculate_taxes
# If the order's address has been changed, the tax zone could be different,
# which means a different set of tax rates might be applicable.
@order.create_tax_charge!
Spree::TaxRate.adjust(@order, @order.adjustments.admin)
@order.updater.update_totals_and_states
end
def order_params
params.require(:order).permit(
:email,