add unit_price_price_and_unit to line_item serializer

*  unit_price_price_and_unit refers UnitPrice which refers to other attributes
that belong to variant and product.
Instead of collecting all the attributes that were using indirectly by the method and adding them to the serializers
I perefered to serialize the result of the method call.
This commit is contained in:
Mohamed ABDELLANI
2023-10-12 16:02:32 +01:00
parent affecf53c6
commit 4634c2d965
2 changed files with 2 additions and 2 deletions

View File

@@ -4,7 +4,7 @@ class Invoice
class DataPresenter
class LineItem < Invoice::DataPresenter::Base
attributes :added_tax, :currency, :included_tax, :price_with_adjustments, :quantity,
:variant_id
:variant_id, :unit_price_price_and_unit
attributes_with_presenter :variant
array_attribute :tax_rates, class_name: 'TaxRate'
invoice_generation_attributes :added_tax, :included_tax, :price_with_adjustments,

View File

@@ -3,7 +3,7 @@
class Invoice
class LineItemSerializer < ActiveModel::Serializer
attributes :id, :added_tax, :currency, :included_tax, :price_with_adjustments, :quantity,
:variant_id
:variant_id, :unit_price_price_and_unit
has_one :variant, serializer: Invoice::VariantSerializer
has_many :tax_rates, serializer: Invoice::TaxRateSerializer
end