Add non_cancelled scope to autobind invoices

See https://github.com/internetee/registry/issues/1496#issuecomment-579870465
This commit is contained in:
Alex Sherman 2020-01-29 22:47:01 +05:00
parent 19cd5ecd95
commit 5c59119c2c
2 changed files with 29 additions and 1 deletions

View file

@ -41,6 +41,28 @@ class BankTransactionTest < ActiveSupport::TestCase
end
end
def test_binds_if_this_sum_cancelled_invoice_already_present
create_payable_invoice(number: '2222', total: 10, reference_no: '1234567')
another_invoice = @invoice.dup
another_invoice.save(validate: false)
another_item = @invoice.items.first.dup
another_item.invoice = another_invoice
another_item.save
another_invoice.reload
another_invoice.update(reference_no: '1234567', number: '2221', cancelled_at: Time.zone.now)
transaction = BankTransaction.new(description: 'invoice #2222',
sum: 10,
description: 'Order nr 1 from registrar 1234567 second number 2345678')
assert_difference 'AccountActivity.count' do
transaction.autobind_invoice
end
end
def test_marks_the_first_one_as_paid_if_same_sum
create_payable_invoice(number: '2222', total: 10, reference_no: '1234567')
another_invoice = @invoice.dup