Qwaiter supplier on Ember 1.0

This commit is contained in:
2013-09-30 17:49:22 +02:00
parent 6d7647c2c5
commit 8ea2e79dc2
44 changed files with 378 additions and 156 deletions
+11 -1
View File
@@ -1,4 +1,14 @@
class OrderSerializer < Qwaiter::Serializer
embed :ids
attributes :state, :list_id, :section_id
attributes :state, :list_id, :section_id, :product_orders, :price
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
def price
product_orders.inject(0){|sum, po| sum + po[:quantity] * po[:price]}.round(2)
end
end