From a475a27f791b01cfd43b1745140e42b7538589e8 Mon Sep 17 00:00:00 2001 From: wvengen Date: Fri, 6 Dec 2013 22:43:36 +0100 Subject: [PATCH] i18n cleanup (affects foodcoops#137) --- app/models/stock_article.rb | 8 ++++++-- app/views/stockit/index.html.haml | 20 ++++++++++---------- config/locales/en.yml | 12 ++---------- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/app/models/stock_article.rb b/app/models/stock_article.rb index 5d45802e..0948b257 100644 --- a/app/models/stock_article.rb +++ b/app/models/stock_article.rb @@ -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 diff --git a/app/views/stockit/index.html.haml b/app/views/stockit/index.html.haml index c2899d9e..ee65cea4 100644 --- a/app/views/stockit/index.html.haml +++ b/app/views/stockit/index.html.haml @@ -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 diff --git a/config/locales/en.yml b/config/locales/en.yml index a48acd92..06d90481 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -95,8 +95,10 @@ en: stock_article: available: Available price: Price + quantity: In stock quantity_available: Available quantity quantity_available_short: Avail. + quantity_ordered: Ordered stock_taking: date: Date note: Note @@ -1428,16 +1430,6 @@ en: form: price_hint: To avoid choas, it is not possible to edit the prices of already added stock articles until further notice. index: - article: - article: Article - available: available - category: Category - ordered: ordered - price: Price - stock: In stock - supplier: Supplier - unit: Unit - vat: VAT confirm_delete: Are you sure you want to delete? new_delivery: New delivery ... new_stock_article: Add new stock article