Working in progress app

This commit is contained in:
2015-10-07 16:23:49 +02:00
parent a4f6470d3d
commit b540f5945e
5 changed files with 42 additions and 1 deletions
+1
View File
@@ -292,6 +292,7 @@ class List
return unless order.id
orders_placed_count = supplier.increment_orders_placed_count!
loaded_products = self.class.database.load_document product_orders.map{|po| po['product_id'] || po['product']}
#loaded_products = loaded_products.compact.include_relation(:product_category).select{|product| product.active? and product.product_category.try(:active?)}
product_orders.each do |product_order|
next unless product = loaded_products.find{|p| p.id == product_order['product_id'] or p.id == product_order['product']} # to get the price and current product name
quantity = product_order['quantity'].to_i
+6
View File
@@ -69,6 +69,12 @@ class ProductCategory
product_categories
end
def active?(time = Time.now)
return true unless time_zone = supplier.time_zone.presence # cannot do activity magic without the appropriate time zone
true
end
def to_client_format
return {} unless products.present?
{name: name, products: products.to_a.map{|p| p.as_json}}