Merge branch 'rails3' of github.com:bennibu/foodsoft into rails3
This commit is contained in:
commit
931bb1d7ca
3 changed files with 9 additions and 2 deletions
|
@ -49,6 +49,11 @@ class Article < ActiveRecord::Base
|
|||
end
|
||||
memoize :in_open_order
|
||||
|
||||
# Returns true if the article has been ordered in the given order at least once
|
||||
def ordered_in_order?(order)
|
||||
order.order_articles.where(article_id: id).where('quantity > 0').one?
|
||||
end
|
||||
|
||||
# this method checks, if the shared_article has been changed
|
||||
# unequal attributes will returned in array
|
||||
# if only the timestamps differ and the attributes are equal,
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
= form.hidden_field :stock_article_id
|
||||
= "Menge (#{stock_change.stock_article.quantity_available})"
|
||||
= form.text_field :quantity, :size => 5, :autocomplete => 'off'
|
||||
%b=h truncate(stock_change.stock_article.name)
|
||||
%b= stock_change.stock_article.name
|
||||
= "(#{number_to_currency(stock_change.stock_article.price)} / #{stock_change.stock_article.unit})"
|
||||
|
|
Loading…
Reference in a new issue