From db07a73bd7cfec14c2b9873aaf671dad41bb194a Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Tue, 16 Feb 2021 18:55:01 +0000 Subject: [PATCH] Ensure Adjustment#update! returns an amount --- app/models/spree/adjustment.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/models/spree/adjustment.rb b/app/models/spree/adjustment.rb index 164f292bbf..03d147f0b7 100644 --- a/app/models/spree/adjustment.rb +++ b/app/models/spree/adjustment.rb @@ -101,15 +101,17 @@ module Spree # object on the association would be in a old state and therefore the # adjustment calculations would not performed on proper values def update!(calculable = nil, force: false) - return if immutable? && !force - return if originator.blank? + return amount if immutable? && !force - amount = originator.compute_amount(calculable || adjustable) + if originator.present? + amount = originator.compute_amount(calculable || adjustable) + update_columns( + amount: amount, + updated_at: Time.zone.now, + ) + end - update_columns( - amount: amount, - updated_at: Time.zone.now, - ) + amount end def currency