styling fixes and fix for supplier deleted products...

This commit is contained in:
2012-12-11 15:39:40 +01:00
parent 627174d493
commit 754806b61f
6 changed files with 22 additions and 11 deletions
+1 -1
View File
@@ -264,7 +264,7 @@ class List
order_total = 0.0
for product_order in order.product_orders
order_total += (product_order.amount * product_order.price).round(2)
ho[:products] << {name: product_order.product.name, id: product_order.product_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}
end
ho[:total_amount] = order_total.round(2)
ho[:state] = order.state
+5
View File
@@ -10,4 +10,9 @@ class ProductOrder
view :by_product_id, key: :product_id
view :by_order_id, key: :order_id
# Getter for product name. If a supplier deletes a product, that has product_orders, the product
# will become nil. This method should handle this case.
def product_name
product.try(:name) || '[deleted]'
end
end