Merge pull request #411 from foodcoop1040/invoice_total
Add more infos to the invoice page
This commit is contained in:
commit
58e84b8923
6 changed files with 37 additions and 1 deletions
|
@ -20,7 +20,24 @@ class Delivery < ActiveRecord::Base
|
||||||
def includes_article?(article)
|
def includes_article?(article)
|
||||||
self.stock_changes.map{|stock_change| stock_change.stock_article.id}.include? article.id
|
self.stock_changes.map{|stock_change| stock_change.stock_article.id}.include? article.id
|
||||||
end
|
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
|
protected
|
||||||
|
|
||||||
def stock_articles_must_be_unique
|
def stock_articles_must_be_unique
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
- title t('.title', number: @invoice.number)
|
- title t('.title', number: @invoice.number)
|
||||||
|
|
||||||
|
- total = 0
|
||||||
|
|
||||||
%p
|
%p
|
||||||
%b= heading_helper(Invoice, :created_at) + ':'
|
%b= heading_helper(Invoice, :created_at) + ':'
|
||||||
= format_time(@invoice.created_at)
|
= format_time(@invoice.created_at)
|
||||||
|
@ -15,15 +17,21 @@
|
||||||
%b= heading_helper(Invoice, :deliveries) + ':'
|
%b= heading_helper(Invoice, :deliveries) + ':'
|
||||||
%span><
|
%span><
|
||||||
- @invoice.deliveries.order(:delivered_on).each_with_index do |delivery, index|
|
- @invoice.deliveries.order(:delivered_on).each_with_index do |delivery, index|
|
||||||
|
- sum = delivery.sum
|
||||||
|
- total += sum
|
||||||
= ', ' if index > 0
|
= ', ' if index > 0
|
||||||
= link_to format_date(delivery.delivered_on), [delivery.supplier,delivery]
|
= link_to format_date(delivery.delivered_on), [delivery.supplier,delivery]
|
||||||
|
= ' (' + number_to_currency(sum) + ')'
|
||||||
- if @invoice.orders.any?
|
- if @invoice.orders.any?
|
||||||
%p
|
%p
|
||||||
%b= heading_helper(Invoice, :orders) + ':'
|
%b= heading_helper(Invoice, :orders) + ':'
|
||||||
%span><
|
%span><
|
||||||
- @invoice.orders.order(:ends).each_with_index do |order, index|
|
- @invoice.orders.order(:ends).each_with_index do |order, index|
|
||||||
|
- sum = order.sum
|
||||||
|
- total += sum
|
||||||
= ', ' if index > 0
|
= ', ' if index > 0
|
||||||
= link_to format_date(order.ends), new_finance_order_path(order_id: order)
|
= link_to format_date(order.ends), new_finance_order_path(order_id: order)
|
||||||
|
= ' (' + number_to_currency(sum) + ')'
|
||||||
|
|
||||||
%p
|
%p
|
||||||
%b= heading_helper(Invoice, :number) + ':'
|
%b= heading_helper(Invoice, :number) + ':'
|
||||||
|
@ -43,6 +51,13 @@
|
||||||
%p
|
%p
|
||||||
%b= heading_helper(Invoice, :deposit_credit) + ':'
|
%b= heading_helper(Invoice, :deposit_credit) + ':'
|
||||||
= number_to_currency @invoice.deposit_credit
|
= number_to_currency @invoice.deposit_credit
|
||||||
|
%p
|
||||||
|
%b= heading_helper(Invoice, :net_amount) + ':'
|
||||||
|
= number_to_currency @invoice.net_amount
|
||||||
|
- if @invoice.deliveries.any? || @invoice.orders.any?
|
||||||
|
%p
|
||||||
|
%b= heading_helper(Invoice, :total) + ':'
|
||||||
|
= number_to_currency total
|
||||||
%p
|
%p
|
||||||
%b= heading_helper(Invoice, :note) + ':'
|
%b= heading_helper(Invoice, :note) + ':'
|
||||||
=h @invoice.note
|
=h @invoice.note
|
||||||
|
|
|
@ -60,6 +60,7 @@ de:
|
||||||
deliveries: Lieferung
|
deliveries: Lieferung
|
||||||
deposit: Pfand berechnet
|
deposit: Pfand berechnet
|
||||||
deposit_credit: Pfand gutgeschrieben
|
deposit_credit: Pfand gutgeschrieben
|
||||||
|
net_amount: Pfandbereinigter Betrag
|
||||||
note: Notiz
|
note: Notiz
|
||||||
number: Nummer
|
number: Nummer
|
||||||
orders: Bestellung
|
orders: Bestellung
|
||||||
|
|
|
@ -60,6 +60,7 @@ en:
|
||||||
deliveries: Delivery
|
deliveries: Delivery
|
||||||
deposit: Deposit charged
|
deposit: Deposit charged
|
||||||
deposit_credit: Deposit returned
|
deposit_credit: Deposit returned
|
||||||
|
net_amount: Amount adjusted for refund
|
||||||
note: Note
|
note: Note
|
||||||
number: Number
|
number: Number
|
||||||
orders: Order
|
orders: Order
|
||||||
|
|
|
@ -60,6 +60,7 @@ fr:
|
||||||
deliveries: Réapprovisionnement
|
deliveries: Réapprovisionnement
|
||||||
deposit: Consigne facturée
|
deposit: Consigne facturée
|
||||||
deposit_credit: Consigne remboursée
|
deposit_credit: Consigne remboursée
|
||||||
|
net_amount: Montant recalculé en excluant les consignes
|
||||||
note: Note
|
note: Note
|
||||||
number: Numéro
|
number: Numéro
|
||||||
orders: Commande
|
orders: Commande
|
||||||
|
|
|
@ -60,6 +60,7 @@ nl:
|
||||||
deliveries: Levering
|
deliveries: Levering
|
||||||
deposit: Statiegeld in rekening gebracht
|
deposit: Statiegeld in rekening gebracht
|
||||||
deposit_credit: Statiegeld teruggekregen
|
deposit_credit: Statiegeld teruggekregen
|
||||||
|
net_amount: Bedrag gecorrigeerd voor statiegeld
|
||||||
note: Notitie
|
note: Notitie
|
||||||
number: Nummer
|
number: Nummer
|
||||||
orders: Bestelling
|
orders: Bestelling
|
||||||
|
|
Loading…
Reference in a new issue