diff --git a/app/models/spree/order.rb b/app/models/spree/order.rb index 817a0d716b..556b8b0c13 100644 --- a/app/models/spree/order.rb +++ b/app/models/spree/order.rb @@ -293,6 +293,8 @@ module Spree # Creates new tax charges if there are any applicable rates. If prices already # include taxes then price adjustments are created instead. def create_tax_charge! + clear_legacy_taxes! + Spree::TaxRate.adjust(self, line_items) Spree::TaxRate.adjust(self, shipments) if shipments.any? Spree::TaxRate.adjust(self, all_adjustments.enterprise_fee) @@ -592,6 +594,13 @@ module Spree @fee_handler ||= OrderFeesHandler.new(self) end + def clear_legacy_taxes! + # For instances that use additional taxes, old orders can have taxes recorded in + # lump-sum amounts per-order. We clear them here before re-applying the order's taxes, + # which will now be applied per-item. + adjustments.tax.additional.delete_all + end + def process_each_payment raise Core::GatewayError, Spree.t(:no_pending_payments) if pending_payments.empty?