diff --git a/app/models/stock_article.rb b/app/models/stock_article.rb index 71679e93..6050c8c4 100644 --- a/app/models/stock_article.rb +++ b/app/models/stock_article.rb @@ -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 = 'finished'").sum(:units_to_order) + joins(:order).where("orders.state = 'open' OR orders.state = 'finished'").sum(:units_to_order) end def self.stock_value