Reapply taxes at model level if order address changes

This should be done at the model level
This commit is contained in:
Matt-Yorkley
2023-06-02 13:12:07 +01:00
parent a0f23fc510
commit c5dfecbb69
2 changed files with 9 additions and 8 deletions

View File

@@ -24,7 +24,6 @@ module Spree
end
refresh_shipment_rates
recalculate_taxes
OrderWorkflow.new(@order).advance_to_payment
flash[:success] = Spree.t('customer_details_updated')
@@ -52,13 +51,6 @@ 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!
@order.update_totals_and_states
end
def order_params
params.require(:order).permit(
:email,

View File

@@ -108,6 +108,7 @@ module Spree
before_save :update_payment_fees!, if: :complete?
after_create :create_tax_charge!
after_save :reapply_tax_on_changed_address
after_save_commit DefaultAddressUpdater
@@ -580,6 +581,14 @@ module Spree
private
def reapply_tax_on_changed_address
return if before_payment_state?
return unless tax_address&.saved_changes?
create_tax_charge!
update_totals_and_states
end
def deliver_order_confirmation_email
return if subscription.present?