styling fixes and fix for supplier deleted products...
This commit is contained in:
+1
-1
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user