Add view for unpaid invoices

This commit is contained in:
Patrick Gansterer 2017-10-22 02:21:27 +02:00
parent 0de7fc0da5
commit 6989e2f4f7
6 changed files with 41 additions and 1 deletions

View file

@ -7,6 +7,10 @@ class Finance::InvoicesController < ApplicationController
@invoices = Invoice.includes(:supplier, :deliveries, :orders).order('date DESC').page(params[:page]).per(@per_page)
end
def unpaid
@suppliers = Supplier.includes(:invoices).where('invoices.paid_on IS NULL').references(:invoices)
end
def show
end

View file

@ -4,7 +4,7 @@
.span6
%h2
= t('.unpaid_invoices')
%small= link_to t('.show_all'), finance_invoices_path
%small= link_to t('.show_all'), unpaid_finance_invoices_path
%table.table.table-striped
%thead
%tr

View file

@ -0,0 +1,27 @@
- title t('.title')
- for supplier in @suppliers
- invoices = supplier.invoices.unpaid
- if invoices.any?
%h3= supplier.name
- invoices_sum = 0
- invoices_text = []
%p
- for invoice in invoices
- 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)
%br/
%p
- if supplier.iban.present?
%b= heading_helper(Supplier, :iban) + ':'
= supplier.iban
%br/
%b= t('.invoices_text') + ':'
= invoices_text.join(', ')
%br/
%b= t('.invoices_sum') + ':'
= number_to_currency invoices_sum

View file

@ -895,6 +895,10 @@ de:
title: Neue Rechnung anlegen
show:
title: Rechnung %{number}
unpaid:
invoices_text: Verwendungszweck
invoices_sum: Gesamtsumme
title: Unbezahlte Rechnungen
ordergroups:
index:
new_transaction: Neue Überweisungen eingeben

View file

@ -897,6 +897,10 @@ en:
title: Create new invoice
show:
title: Invoice %{number}
unpaid:
invoices_text: Reference
invoices_sum: Total sum
title: Unpaid invoices
ordergroups:
index:
new_transaction: Add new transactions

View file

@ -160,6 +160,7 @@ Foodsoft::Application.routes.draw do
resources :invoices do
get :attachment
get :form_on_supplier_id_change, on: :collection
get :unpaid, on: :collection
end
resources :ordergroups, only: [:index] do