diff --git a/app/controllers/finance/invoices_controller.rb b/app/controllers/finance/invoices_controller.rb index 3c2da9d8..af3e123b 100644 --- a/app/controllers/finance/invoices_controller.rb +++ b/app/controllers/finance/invoices_controller.rb @@ -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 diff --git a/app/views/finance/index.html.haml b/app/views/finance/index.html.haml index 976b89bb..563c0411 100644 --- a/app/views/finance/index.html.haml +++ b/app/views/finance/index.html.haml @@ -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 diff --git a/app/views/finance/invoices/unpaid.html.haml b/app/views/finance/invoices/unpaid.html.haml new file mode 100644 index 00000000..971579cd --- /dev/null +++ b/app/views/finance/invoices/unpaid.html.haml @@ -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 diff --git a/config/locales/de.yml b/config/locales/de.yml index 10b1d3da..59ab52b6 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -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 diff --git a/config/locales/en.yml b/config/locales/en.yml index ca22948a..2d10eb29 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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 diff --git a/config/routes.rb b/config/routes.rb index 5b12e328..28a1e678 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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