Files
openfoodnetwork/app/serializers/api/admin/standing_line_item_serializer.rb
2018-02-09 14:44:07 +11:00

22 lines
564 B
Ruby

module Api
module Admin
class StandingLineItemSerializer < ActiveModel::Serializer
attributes :id, :variant_id, :quantity, :description, :price_estimate
def description
"#{object.variant.product.name} - #{object.variant.full_name}"
end
def price_estimate
if object.price_estimate
object.price_estimate
elsif options[:fee_calculator]
(object.variant.price + options[:fee_calculator].indexed_fees_for(object.variant)).to_f
else
"?"
end
end
end
end
end