mirror of
https://github.com/internetee/registry.git
synced 2025-06-09 22:24:47 +02:00
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:
parent
d86ec026e3
commit
a97728c0f3
65 changed files with 758 additions and 341 deletions
53
test/models/invoice/payable_test.rb
Normal file
53
test/models/invoice/payable_test.rb
Normal file
|
@ -0,0 +1,53 @@
|
|||
require 'test_helper'
|
||||
|
||||
class InvoiceTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
@invoice = invoices(:one)
|
||||
end
|
||||
|
||||
def test_unpaid_scope_returns_unpaid_invoices
|
||||
@invoice.account_activity = nil
|
||||
assert Invoice.unpaid.include?(@invoice), 'Should return unpaid invoice'
|
||||
end
|
||||
|
||||
def test_unpaid_scope_does_not_return_paid_invoices
|
||||
assert @invoice.paid?
|
||||
assert_not Invoice.unpaid.include?(@invoice), 'Should not return paid invoice'
|
||||
end
|
||||
|
||||
def test_paid_when_there_is_an_account_activity
|
||||
assert @invoice.account_activity
|
||||
|
||||
assert @invoice.paid?
|
||||
assert_not @invoice.unpaid?
|
||||
end
|
||||
|
||||
def test_unpaid_when_there_is_no_account_activity
|
||||
@invoice.account_activity = nil
|
||||
|
||||
assert @invoice.unpaid?
|
||||
assert_not @invoice.paid?
|
||||
end
|
||||
|
||||
def test_payable_when_unpaid_and_not_cancelled
|
||||
@invoice.account_activity = nil
|
||||
@invoice.cancelled_at = nil
|
||||
|
||||
assert @invoice.payable?
|
||||
end
|
||||
|
||||
def test_not_payable_when_already_paid
|
||||
assert @invoice.paid?
|
||||
assert_not @invoice.payable?
|
||||
end
|
||||
|
||||
def test_not_payable_when_cancelled
|
||||
@invoice.cancelled_at = '2010-07-05'
|
||||
assert_not @invoice.payable?
|
||||
end
|
||||
|
||||
def test_returns_receipt_date
|
||||
assert_equal Time.zone.parse('2010-07-05 10:00'), @invoice.account_activity.created_at
|
||||
assert_equal Date.parse('2010-07-05'), @invoice.receipt_date
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue