From 9bbe57afdafcf25dc538086ab84b9985f9fe814c Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 7 Feb 2021 13:22:26 +0000 Subject: [PATCH] Extract method --- app/models/spree/item_adjustments.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/models/spree/item_adjustments.rb b/app/models/spree/item_adjustments.rb index 15aaafad0c..1dd334f47d 100644 --- a/app/models/spree/item_adjustments.rb +++ b/app/models/spree/item_adjustments.rb @@ -17,9 +17,6 @@ module Spree end def update_adjustments - tax_adjustments = - (item.respond_to?(:all_adjustments) ? item.all_adjustments : item.adjustments).tax - adjustment_total = adjustments.additional.map(&:update!).compact.sum included_tax_total = tax_adjustments.inclusive.reload.map(&:update!).compact.sum additional_tax_total = tax_adjustments.additional.reload.map(&:update!).compact.sum @@ -31,5 +28,11 @@ module Spree updated_at: Time.zone.now ) end + + private + + def tax_adjustments + (item.respond_to?(:all_adjustments) ? item.all_adjustments : item.adjustments).tax + end end end