Cleanup code

This commit is contained in:
2014-05-27 17:58:38 +02:00
parent 6953e1ba68
commit 4855b2e8e0
+3 -2
View File
@@ -295,9 +295,10 @@ class List
orders_placed_count = supplier.increment_orders_placed_count! orders_placed_count = supplier.increment_orders_placed_count!
loaded_products = self.class.database.load_document products.keys loaded_products = self.class.database.load_document products.keys
products.each do |product_id, quantity| products.each do |product_id, quantity|
quantity = quantity.to_i
product = loaded_products.find{|p| p.id == product_id} # to get the price product = loaded_products.find{|p| p.id == product_id} # to get the price
ProductOrder.create order: order, product_id: product_id, quantity: quantity, price: product.price, product_name: product.name if quantity > 0 if quantity.to_i > 0
ProductOrder.create(order: order, product_id: product_id, quantity: quantity, price: product.price, product_name: product.name)
end
end end
set_price set_price
save save