class OrderSerializer < Qwaiter::Serializer
  embed :ids, include: true
  attributes :state, :list_id, :section_id, :table_id #, :price

  # todo, put this logic in Ember
  #def product_orders
    #@product_orders ||= object.product_orders.include_relation(:product) .map do |product_order|
      #{product_name: product_order.product.name, id: product_order.id, quantity: product_order.quantity, price: product_order.price}
    #end
  #end

  # todo, put this logic in Ember
  #def price
    #product_orders.inject(0){|sum, po| sum + po[:quantity] * po[:price]}.round(2)
  #end

  has_many :product_orders
end
