Add expected_amount to Invoice
expected_amount returns the sum of all associated orders together with the transport costs.
This commit is contained in:
parent
093313f0f3
commit
052d297bff
4 changed files with 31 additions and 2 deletions
|
|
@ -29,10 +29,14 @@
|
|||
%dd><
|
||||
- @invoice.orders.order(:ends).each_with_index do |order, index|
|
||||
- sum = order.sum
|
||||
- total += sum
|
||||
- transport = order.transport || 0
|
||||
- total += sum + transport
|
||||
= ', ' if index > 0
|
||||
= link_to format_date(order.ends), new_finance_order_path(order_id: order)
|
||||
= ' (' + number_to_currency(sum) + ')'
|
||||
= ' (' + number_to_currency(sum)
|
||||
- if transport != 0
|
||||
= ' + ' + number_to_currency(transport)
|
||||
= ')'
|
||||
|
||||
%dt= heading_helper(Invoice, :number) + ':'
|
||||
%dd= @invoice.number
|
||||
|
|
|
|||
|
|
@ -8,12 +8,17 @@
|
|||
- invoices_text = []
|
||||
%p
|
||||
- for invoice in invoices
|
||||
- invoice_amount_diff = invoice.expected_amount - invoice.net_amount
|
||||
- invoices_sum += invoice.amount
|
||||
- invoices_text << invoice.number
|
||||
= link_to finance_invoice_path(invoice) do
|
||||
= format_date invoice.date
|
||||
= ' ' + invoice.number
|
||||
= ' ' + number_to_currency(invoice.amount)
|
||||
- if invoice_amount_diff != 0
|
||||
%span{style: "color:#{invoice_amount_diff < 0 ? 'red' : 'green'}"}
|
||||
= invoice_amount_diff > 0 ? '+' : '-'
|
||||
= number_to_currency(invoice_amount_diff.abs)
|
||||
- if invoice.attachment_data?
|
||||
= link_to finance_invoice_attachment_path(invoice) do
|
||||
= glyph :download
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue