Naming fixes

This commit is contained in:
2013-09-24 09:18:48 +02:00
parent 5650ada04c
commit faec08c26b
4 changed files with 10 additions and 8 deletions
+5 -3
View File
@@ -110,12 +110,14 @@ class Order
return @with_products_as_json if @with_products_as_json.present?
product_orders.include_relation(:product)
ho = as_json
ho[:products] = []
# products are depricated. It is a name for something it is not!!!!!
ho[:products] = []
ho[:product_orders] = []
order_total = 0.0
for product_order in product_orders
order_total += (product_order.amount * product_order.price).round(2)
# Use product order id as id since the price can be different for products and the state should be preserved
ho[:products] << {name: product_order.product.name, id: product_order.id, number: product_order.amount, price: product_order.price}
ho[:products] << {name: product_order.product.name, id: product_order.product_id, number: product_order.amount, price: product_order.price}
ho[:product_orders] << {product_name: product_order.product.name, id: product_order.id, quantity: product_order.amount, price: product_order.price}
end
ho[:total_amount] = order_total.round(2)
@with_products_as_json = ho