Add more infos to the invoice page

When a foodcoop does not use the balancing feature the invoice page is
the main page for informations. Add all related information to it, so
people do not need to open the balancing page.
This commit is contained in:
Patrick Gansterer 2016-03-04 22:26:55 +01:00
parent f5b6fbcf18
commit 5e744453f8
6 changed files with 37 additions and 1 deletions

View file

@ -20,7 +20,24 @@ class Delivery < ActiveRecord::Base
def includes_article?(article)
self.stock_changes.map{|stock_change| stock_change.stock_article.id}.include? article.id
end
def sum(type = :gross)
total = 0
for sc in stock_changes
article = sc.stock_article
quantity = sc.quantity
case type
when :net
total += quantity * article.price
when :gross
total += quantity * article.gross_price
when :fc
total += quantity * article.fc_price
end
end
total
end
protected
def stock_articles_must_be_unique