From 89889bc280ad3a476ec807131399cf07fa7533aa Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 7 Feb 2021 13:20:59 +0000 Subject: [PATCH] Record tax totals in ItemAdjustments --- app/models/spree/item_adjustments.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/spree/item_adjustments.rb b/app/models/spree/item_adjustments.rb index c6cb1238c4..15aaafad0c 100644 --- a/app/models/spree/item_adjustments.rb +++ b/app/models/spree/item_adjustments.rb @@ -17,9 +17,16 @@ module Spree end def update_adjustments - adjustment_total = adjustments.map(&:update!).compact.sum + 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 item.update_columns( + included_tax_total: included_tax_total, + additional_tax_total: additional_tax_total, adjustment_total: adjustment_total, updated_at: Time.zone.now )