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

@ -0,0 +1,5 @@
class RenameInvoiceItemsAmountToQuantity < ActiveRecord::Migration
def change
rename_column :invoice_items, :amount, :quantity
end
end

View file

@ -0,0 +1,5 @@
class AddInvoiceItemsInvoiceIdFk < ActiveRecord::Migration
def change
add_foreign_key :invoice_items, :invoices, name: 'invoice_items_invoice_id_fk'
end
end

View file

@ -0,0 +1,5 @@
class ChangeInvoiceItemsInvoiceIdToNotNull < ActiveRecord::Migration
def change
change_column_null :invoice_items, :invoice_id, false
end
end

View file

@ -0,0 +1,5 @@
class ChangeInvoiceItemsQuantityToNotNull < ActiveRecord::Migration
def change
change_column_null :invoice_items, :quantity, false
end
end

View file

@ -0,0 +1,5 @@
class ChangeInvoiceItemsUnitToNotNull < ActiveRecord::Migration
def change
change_column_null :invoice_items, :unit, false
end
end

View file

@ -0,0 +1,5 @@
class ChangeInvoiceItemsPriceToNotNull < ActiveRecord::Migration
def change
change_column_null :invoice_items, :price, false
end
end

View file

@ -0,0 +1,5 @@
class ChangeInvoicesDueDateToDate < ActiveRecord::Migration
def change
change_column :invoices, :due_date, :date, null: false
end
end

View file

@ -0,0 +1,5 @@
class AddInvoicesIssueDate < ActiveRecord::Migration
def change
add_column :invoices, :issue_date, :date
end
end

View file

@ -0,0 +1,5 @@
class RemoveInvoicesPaidAt < ActiveRecord::Migration
def change
remove_column :invoices, :paid_at
end
end

View file

@ -0,0 +1,5 @@
class RemoveInvoicesPaymentTerm < ActiveRecord::Migration
def change
remove_column :invoices, :payment_term
end
end