Skip to content

Commit

Permalink
add unit_price_price_and_unit to line_item serializer
Browse files Browse the repository at this point in the history
*  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.
  • Loading branch information
abdellani committed Oct 12, 2023
1 parent df18fac commit a45535f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/invoice/data_presenter/line_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
invoice_generation_attributes :added_tax, :included_tax, :price_with_adjustments,
:quantity, :variant_id
Expand Down
2 changes: 1 addition & 1 deletion app/serializers/invoice/line_item_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
end
end

0 comments on commit a45535f

Please sign in to comment.