diff --git a/core/app/models/spree/order_cancellations.rb b/core/app/models/spree/order_cancellations.rb index d708dbd4a87..783a5c0cffc 100644 --- a/core/app/models/spree/order_cancellations.rb +++ b/core/app/models/spree/order_cancellations.rb @@ -96,6 +96,16 @@ def reimburse_units(inventory_units, created_by:) reimbursement end + def recalculate_adjustments + @order.line_items.each do |line_item| + line_item.adjustments.select(&:cancellation?).each do |adjustment| + next if adjustment.finalized? + amount = adjustment.source.compute_amount(line_item) + adjustment.update!(amount: amount) + end + end + end + private def short_ship_unit(inventory_unit, created_by: nil) diff --git a/core/app/models/spree/order_updater.rb b/core/app/models/spree/order_updater.rb index 588976fa583..6530337dd9e 100644 --- a/core/app/models/spree/order_updater.rb +++ b/core/app/models/spree/order_updater.rb @@ -217,9 +217,7 @@ def update_taxes end def update_cancellations - line_items.each do |line_item| - line_item.adjustments.select(&:cancellation?).each(&:recalculate) - end + Spree::Config.order_cancellations_class.new(order).recalculate_adjustments end def update_item_totals