mirror of
https://github.com/internetee/registry.git
synced 2025-08-03 08:22:05 +02:00
Merge pull request #1678 from internetee/1677-fix-description-ref-number
Fix description ref number parsing
This commit is contained in:
commit
dc1136002d
2 changed files with 19 additions and 11 deletions
|
@ -121,6 +121,7 @@ class BankTransaction < ApplicationRecord
|
|||
end
|
||||
|
||||
def ref_number_from_description
|
||||
/(\d{7})/.match(description)[0]
|
||||
match_data = /(\d{7})/.match(description)
|
||||
match_data[0] if match_data.present?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,14 +26,12 @@ class BankTransactionTest < ActiveSupport::TestCase
|
|||
another_item.save
|
||||
another_invoice.reload
|
||||
|
||||
first_transaction = BankTransaction.new(description: 'invoice #2221',
|
||||
sum: 10,
|
||||
first_transaction = BankTransaction.new(sum: 10,
|
||||
description: 'Order nr 1 from registrar 1234567 second number 2345678')
|
||||
|
||||
first_transaction.create_activity(another_invoice.buyer, another_invoice)
|
||||
|
||||
transaction = BankTransaction.new(description: 'invoice #2222',
|
||||
sum: 10,
|
||||
transaction = BankTransaction.new(sum: 10,
|
||||
description: 'Order nr 1 from registrar 1234567 second number 2345678')
|
||||
|
||||
assert_difference 'AccountActivity.count' do
|
||||
|
@ -54,8 +52,7 @@ class BankTransactionTest < ActiveSupport::TestCase
|
|||
another_invoice.reload
|
||||
another_invoice.update(reference_no: '1234567', number: '2221', cancelled_at: Time.zone.now)
|
||||
|
||||
transaction = BankTransaction.new(description: 'invoice #2222',
|
||||
sum: 10,
|
||||
transaction = BankTransaction.new(sum: 10,
|
||||
description: 'Order nr 1 from registrar 1234567 second number 2345678')
|
||||
|
||||
assert_difference 'AccountActivity.count' do
|
||||
|
@ -74,8 +71,7 @@ class BankTransactionTest < ActiveSupport::TestCase
|
|||
another_item.save
|
||||
another_invoice.reload
|
||||
|
||||
transaction = BankTransaction.new(description: 'invoice #2222',
|
||||
sum: 10,
|
||||
transaction = BankTransaction.new(sum: 10,
|
||||
description: 'Order nr 1 from registrar 1234567 second number 2345678')
|
||||
|
||||
assert_difference 'AccountActivity.count' do
|
||||
|
@ -90,8 +86,7 @@ class BankTransactionTest < ActiveSupport::TestCase
|
|||
|
||||
def test_matches_against_invoice_nubmber_and_reference_number_in_description
|
||||
create_payable_invoice(number: '2222', total: 10, reference_no: '1234567')
|
||||
transaction = BankTransaction.new(description: 'invoice #2222',
|
||||
sum: 10,
|
||||
transaction = BankTransaction.new(sum: 10,
|
||||
description: 'Order nr 1 from registrar 1234567 second number 2345678')
|
||||
|
||||
assert_difference 'AccountActivity.count' do
|
||||
|
@ -99,6 +94,18 @@ class BankTransactionTest < ActiveSupport::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_no_errors_if_no_valid_refnumber_in_description
|
||||
create_payable_invoice(number: '2222', total: 10, reference_no: '1234567')
|
||||
transaction = BankTransaction.new(sum: 10,
|
||||
description: 'Order nr 1 from registrar 123456')
|
||||
|
||||
assert_no_difference 'AccountActivity.count' do
|
||||
assert_nothing_raised do
|
||||
transaction.autobind_invoice
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_resets_pending_registrar_balance_reload
|
||||
registrar = registrar_with_pending_balance_auto_reload
|
||||
create_payable_invoice(number: '2222', total: 10, reference_no: '1111')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue