i18n cleanup (affects foodcoops#137)

This commit is contained in:
wvengen 2013-12-06 22:43:36 +01:00
parent 043607f20d
commit a475a27f79
3 changed files with 18 additions and 22 deletions

View file

@ -14,10 +14,14 @@ class StockArticle < Article
# Check for unclosed orders and substract its ordered quantity
def quantity_available
quantity - OrderArticle.where(article_id: id).
quantity - quantity_ordered
end
def quantity_ordered
OrderArticle.where(article_id: id).
joins(:order).where("orders.state = 'open' OR orders.state = 'finished'").sum(:units_to_order)
end
def quantity_history
stock_changes.reorder('stock_changes.created_at ASC').map{|s| s.quantity}.cumulative_sum
end

View file

@ -32,22 +32,22 @@
%table.table.table-hover#articles
%thead
%tr
%th= t '.article.article'
%th= t '.article.stock'
%th= t '.article.ordered'
%th= t '.article.available'
%th= t '.article.unit'
%th= t '.article.price'
%th= t '.article.vat'
%th= t '.article.supplier'
%th= t '.article.category'
%th= Article.model_name.human
%th= heading_helper StockArticle, :quantity
%th= heading_helper StockArticle, :quantity_ordered
%th= heading_helper StockArticle, :available
%th= heading_helper StockArticle, :unit
%th= heading_helper StockArticle, :price
%th= heading_helper StockArticle, :tax
%th= heading_helper StockArticle, :supplier
%th= heading_helper StockArticle, :article_category
%th
%tbody
- for article in @stock_articles
%tr{:class => stock_article_classes(article), :id => "stockArticle-#{article.id}"}
%td= link_to article.name, article
%td= article.quantity
%td= article.quantity - article.quantity_available
%td= article.quantity_ordered
%th= article.quantity_available
%td= article.unit
%td= article.price