Many improvements and fixes

This commit is contained in:
2014-07-22 17:37:33 +02:00
parent 8ca59c4e38
commit 3202ba8f19
23 changed files with 75 additions and 61 deletions
@@ -23,7 +23,7 @@ Qsupplier.App.Order = DS.Model.extend
@set 'state', 'cancelled'
total: (->
@get('product_orders').getEach('total').reduce(((sum, total) -> sum + total), 0)
).property('product_orders.@each.quantity', 'product_orders.@each.product.@each.price')
).property('product_orders.@each.total')
display: (->
@get('product_orders').map((po) -> "#{po.get('quantity')} x #{po.get('product.name')}").join(', ')
@@ -1,8 +1,9 @@
attr = DS.attr
Qsupplier.App.ProductOrder = DS.Model.extend
quantity: attr 'number', defaultValue: 1
price: attr 'number'
product: DS.belongsTo('product')
order: DS.belongsTo('order')
increment: ->
@set('quantity', @get('quantity') + 1)
total: (-> @get('quantity') * @get('product.price')).property('quantity', 'product.price')
total: (-> @get('quantity') * @get('price')).property('quantity', 'price')