Many improvements and fixes
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user