Merge branch 'rails3-fix-stock-ordering' into rails3-fix-stock-ordering-2
This commit is contained in:
commit
8d0761a6c8
2 changed files with 5 additions and 1 deletions
|
@ -49,6 +49,10 @@ class Article < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
memoize :in_open_order
|
memoize :in_open_order
|
||||||
|
|
||||||
|
def ordered?(order)
|
||||||
|
order.order_articles.where(article_id: id).where('quantity > 0').one?
|
||||||
|
end
|
||||||
|
|
||||||
# this method checks, if the shared_article has been changed
|
# this method checks, if the shared_article has been changed
|
||||||
# unequal attributes will returned in array
|
# unequal attributes will returned in array
|
||||||
# if only the timestamps differ and the attributes are equal,
|
# if only the timestamps differ and the attributes are equal,
|
||||||
|
|
|
@ -40,7 +40,7 @@ class Order < ActiveRecord::Base
|
||||||
if stockit?
|
if stockit?
|
||||||
StockArticle.available.all(:include => :article_category,
|
StockArticle.available.all(:include => :article_category,
|
||||||
:order => 'article_categories.name, articles.name').reject{ |a|
|
:order => 'article_categories.name, articles.name').reject{ |a|
|
||||||
a.quantity_available <= 0
|
a.quantity_available <= 0 and not a.ordered?(self)
|
||||||
}.group_by { |a| a.article_category.name }
|
}.group_by { |a| a.article_category.name }
|
||||||
else
|
else
|
||||||
supplier.articles.available.all.group_by { |a| a.article_category.name }
|
supplier.articles.available.all.group_by { |a| a.article_category.name }
|
||||||
|
|
Loading…
Reference in a new issue