mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 14:44:47 +02:00
added test for transaction with binded invoice which already paid
This commit is contained in:
parent
39f349f2fa
commit
8f3f5f7302
1 changed files with 25 additions and 0 deletions
|
@ -13,6 +13,8 @@ class ProcessPaymentsTaskTest < ActiveSupport::TestCase
|
|||
total: payment_amount,
|
||||
currency: @payment_currency,
|
||||
reference_no: @payment_reference_number)
|
||||
@account_activity = account_activities(:one)
|
||||
|
||||
Setting.registry_iban = beneficiary_iban
|
||||
|
||||
Lhv::ConnectApi.class_eval do
|
||||
|
@ -29,6 +31,29 @@ class ProcessPaymentsTaskTest < ActiveSupport::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_cannot_create_new_invoice_if_transaction_binded_to_paid_invoice
|
||||
@invoice.update(total: 10)
|
||||
assert_not @invoice.paid?
|
||||
|
||||
@account_activity.update(activity_type: "add_credit", bank_transaction: nil)
|
||||
@invoice.update(account_activity: @account_activity, total: 10)
|
||||
assert @invoice.paid?
|
||||
|
||||
transaction = BankTransaction.new
|
||||
transaction.description = "Invoice no. #{@invoice.number}"
|
||||
transaction.sum = 10
|
||||
transaction.reference_no = @invoice.reference_no
|
||||
transaction.save
|
||||
assert transaction.valid?
|
||||
|
||||
assert_no_difference 'AccountActivity.count' do
|
||||
assert_no_difference 'Invoice.count' do
|
||||
Invoice.create_from_transaction!(transaction) unless transaction.autobindable?
|
||||
transaction.autobind_invoice
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_doubles_are_valid
|
||||
assert Lhv::ConnectApi.method_defined?(:credit_debit_notification_messages)
|
||||
assert Lhv::ConnectApi::Messages::CreditDebitNotification.method_defined?(:bank_account_iban)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue