mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-01 21:47:16 +00:00
Solves Psych::DisallowedClass errors Example: https://github.com/openfoodfoundation/openfoodnetwork/actions/runs/14739687958/job/41374343627?pr=13232 unit_price returns object with amount and unit, as mentioned in https://github.com/openfoodfoundation/openfoodnetwork/pull/6905\#discussion_r578401368
19 lines
673 B
Ruby
19 lines
673 B
Ruby
# frozen_string_literal: false
|
|
|
|
class Invoice
|
|
class LineItemSerializer < ActiveModel::Serializer
|
|
attributes :id, :added_tax, :currency, :included_tax, :price_with_adjustments, :quantity,
|
|
:variant_id, :unit_price, :unit_presentation,
|
|
:enterprise_fee_additional_tax, :enterprise_fee_included_tax
|
|
has_one :variant, serializer: Invoice::VariantSerializer
|
|
|
|
def enterprise_fee_additional_tax
|
|
EnterpriseFeeAdjustments.new(object.enterprise_fee_adjustments).total_additional_tax
|
|
end
|
|
|
|
def enterprise_fee_included_tax
|
|
EnterpriseFeeAdjustments.new(object.enterprise_fee_adjustments).total_included_tax
|
|
end
|
|
end
|
|
end
|