mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 22:54:47 +02:00
Match bank transaction against invoice reference number instead of
registrar's
This commit is contained in:
parent
5738c17731
commit
a43a1ac3e3
2 changed files with 22 additions and 1 deletions
|
@ -31,7 +31,7 @@ class BankTransaction < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def registrar
|
def registrar
|
||||||
@registrar ||= Registrar.find_by(reference_no: reference_no)
|
@registrar ||= Invoice.find_by(reference_no: reference_no)&.buyer
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
21
test/models/bank_transaction_test.rb
Normal file
21
test/models/bank_transaction_test.rb
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class BankTransactionTest < ActiveSupport::TestCase
|
||||||
|
def test_matches_against_invoice_reference_number
|
||||||
|
invoices(:valid).update!(number: '2222', total: 10, reference_no: '1111')
|
||||||
|
transaction = BankTransaction.new(description: 'invoice #2222', sum: 10, reference_no: '1111')
|
||||||
|
|
||||||
|
assert_difference 'AccountActivity.count' do
|
||||||
|
transaction.autobind_invoice
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_does_not_match_against_registrar_reference_number
|
||||||
|
registrars(:bestnames).update!(reference_no: '1111')
|
||||||
|
transaction = BankTransaction.new(description: 'invoice #2222', sum: 10, reference_no: '1111')
|
||||||
|
|
||||||
|
assert_no_difference 'AccountActivity.count' do
|
||||||
|
transaction.autobind_invoice
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue