Refactor and improve invoices

- `runner 'Invoice.cancel_overdue_invoices'` in `schedule.rb` is
changed to `rake 'invoices:cancel_overdue'`.
- `invoices.payment_term` database column is removed and its value is
hardcoded in UI.
- `invoices.paid_at` is removed as unused
- `invoices.due_date` column's type is now `date`.
- `Invoice#invoice_items` renamed to `Invoice#items` and `Invoice`
interface to get a list of items is unified.
- Default date format in UI.
- Default translations are used.
- Tests improved.
- Specs converted to tests and removed along with factories.
- Database structure improved.
This commit is contained in:
Artur Beljajev 2018-10-17 12:21:04 +03:00
parent d86ec026e3
commit a97728c0f3
65 changed files with 758 additions and 341 deletions

View file

@ -16,18 +16,18 @@
%th{class: 'col-xs-3'}
= sort_link(@q, :sort_receipt_date, "Receipt date")
%tbody
- @invoices.each do |x|
- @invoices.each do |invoice|
%tr
%td= link_to(x, [:admin, x])
%td= link_to(x.buyer_name, admin_registrar_path(x.buyer_id))
- if x.cancelled?
%td= link_to(invoice, [:admin, invoice])
%td= link_to(invoice.buyer_name, admin_registrar_path(invoice.buyer_id))
- if invoice.cancelled?
%td.text-grey= t(:cancelled)
- else
%td= l(x.due_date, format: :date_long)
%td= l invoice.due_date
- if x.binded?
%td= l(x.receipt_date, format: :date_long)
- elsif x.cancelled?
- if invoice.paid?
%td= l invoice.receipt_date
- elsif invoice.cancelled?
%td.text-grey= t(:cancelled)
- else
%td.text-danger= t(:unpaid)

View file

@ -4,11 +4,11 @@
= @invoice
.col-sm-8
%h1.text-right.text-center-xs
- unless @invoice.binded?
- if @invoice.unpaid?
= link_to(t(:payment_received), new_admin_bank_statement_path(invoice_id: @invoice.id), class: 'btn btn-default')
= link_to(t(:download), admin_invoice_download_pdf_path(@invoice), class: 'btn btn-default')
= link_to(t(:forward), admin_invoice_forward_path(@invoice), class: 'btn btn-default')
- if !@invoice.cancelled? && !@invoice.binded?
- if @invoice.cancellable?
= link_to(t(:cancel), cancel_admin_invoice_path(@invoice), method: :patch, class: 'btn btn-warning')
= link_to(t(:back), admin_invoices_path, class: 'btn btn-default')
%hr