Merge pull request #2096 from internetee/2095-undefined-method-settings

Fix for manual invoice binding
This commit is contained in:
Timo Võhmar 2021-08-11 09:56:54 +03:00 committed by GitHub
commit 8f9b39fce6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View file

@ -92,7 +92,7 @@ class BankTransaction < ApplicationRecord
activity_type: AccountActivity::ADD_CREDIT)
if activity.save
reset_pending_registrar_balance_reload
reset_pending_registrar_balance_reload registrar
true
else
false
@ -105,7 +105,7 @@ class BankTransaction < ApplicationRecord
private
def reset_pending_registrar_balance_reload
def reset_pending_registrar_balance_reload(registrar)
return unless registrar.settings['balance_auto_reload']
registrar.settings['balance_auto_reload'].delete('pending')

View file

@ -180,6 +180,19 @@ class BankTransactionTest < ActiveSupport::TestCase
statement.description = "all invalid 12 123 55 77777 --"
assert_nil statement.parsed_ref_number
end
def test_manual_bind_with_wrong_ref_number
invoice_ref_no = '1111'
bank_transaction_ref_no = '9999'
create_payable_invoice(number: '2222', total: 10, reference_no: invoice_ref_no)
transaction = BankTransaction.new(description: 'invoice #2222',
sum: 10,
reference_no: bank_transaction_ref_no)
assert_difference 'AccountActivity.count' do
transaction.bind_invoice('2222')
end
end
private
def create_payable_invoice(attributes)