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>
This commit is contained in:
Jean-Baptiste Bellet
2021-10-26 16:36:21 +02:00
parent 49efb3bd6e
commit fc8cd30cce

View File

@@ -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