Improve stock_article_selections
This commit is contained in:
parent
524819b86f
commit
396a47b6af
10 changed files with 104 additions and 30 deletions
|
|
@ -22,6 +22,11 @@ class StockArticle < Article
|
|||
def self.stock_value
|
||||
available.collect { |a| a.quantity * a.gross_price }.sum
|
||||
end
|
||||
|
||||
def self.elements_for_index
|
||||
StockArticle.includes(:supplier, :article_category).
|
||||
order('suppliers.name, article_categories.name, articles.name')
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,18 @@ class StockArticleSelection < ActiveRecord::Base
|
|||
all_articles = stock_article_ids
|
||||
end
|
||||
|
||||
def deletable_count
|
||||
stock_articles.select { |a| a.quantity_available<=0 }.length
|
||||
end
|
||||
|
||||
def nondeletable_count
|
||||
stock_articles.select { |a| a.quantity_available>0 }.length
|
||||
end
|
||||
|
||||
def deleted_count
|
||||
stock_articles.only_deleted.count
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def include_stock_articles
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue