Do not subtract articles in open orders when calculating quantity.

This commit is contained in:
Robert Waltemath 2013-03-06 14:19:06 +01:00
parent 5032fbb63d
commit 6bf3b241e6

View file

@ -16,7 +16,7 @@ class StockArticle < Article
# Check for unclosed orders and substract its ordered quantity
def quantity_available
quantity - OrderArticle.where(article_id: id).
joins(:order).where("orders.state = 'open' OR orders.state = 'finished'").sum(:units_to_order)
joins(:order).where("orders.state = 'finished'").sum(:units_to_order)
end
def self.stock_value