From fc8cd30cce7709a6b353ae05b12da0661ec8b5c9 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Tue, 26 Oct 2021 16:36:21 +0200 Subject: [PATCH] Add the tax_category_id for each adjustement - This tax_category_id could be null - Special case if the originator is a Spree::TaxRate: then use the tax_category_id of the originator Co-Authored-By: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> --- app/serializers/api/adjustment_serializer.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/serializers/api/adjustment_serializer.rb b/app/serializers/api/adjustment_serializer.rb index 741e3699a4..ce6c12bcf4 100644 --- a/app/serializers/api/adjustment_serializer.rb +++ b/app/serializers/api/adjustment_serializer.rb @@ -4,6 +4,15 @@ module Api class AdjustmentSerializer < ActiveModel::Serializer attributes :id, :amount, :label, :eligible, :adjustable_type, :adjustable_id, - :originator_type, :originator_id + :originator_type, :originator_id, + :tax_category_id + + def tax_category_id + if object.originator_type == "Spree::TaxRate" + object.originator.tax_category_id + else + object.tax_category_id + end + end end end