Merge pull request #99 from balkansalat/rails3-fix-stock-ordering-2
Prevent sold-out articles from being removed from stock order when editing
This commit is contained in:
commit
28343fc124
2 changed files with 8 additions and 1 deletions
|
|
@ -38,9 +38,11 @@ class Order < ActiveRecord::Base
|
|||
|
||||
def articles_for_ordering
|
||||
if stockit?
|
||||
# make sure to include those articles which are no longer available
|
||||
# but which have already been ordered in this stock order
|
||||
StockArticle.available.all(:include => :article_category,
|
||||
:order => 'article_categories.name, articles.name').reject{ |a|
|
||||
a.quantity_available <= 0
|
||||
a.quantity_available <= 0 and not a.ordered_in_order?(self)
|
||||
}.group_by { |a| a.article_category.name }
|
||||
else
|
||||
supplier.articles.available.all.group_by { |a| a.article_category.name }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue