mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 18:56:05 +02:00
Fix parsing from ref number
This commit is contained in:
parent
18aa7e3d63
commit
8a5208057a
2 changed files with 6 additions and 7 deletions
|
@ -118,12 +118,11 @@ class BankTransaction < ApplicationRecord
|
|||
end
|
||||
|
||||
def ref_number_from_description
|
||||
(Billing::ReferenceNo::MULTI_REGEXP.match(description) || []).captures.each do |match|
|
||||
break match if match.length == 7 || valid_ref_no?(match)
|
||||
end
|
||||
matches = description.to_s.scan(Billing::ReferenceNo::MULTI_REGEXP).flatten
|
||||
matches.detect { |m| break m if m.length == 7 || valid_ref_no?(m) }
|
||||
end
|
||||
|
||||
def valid_ref_no?(match)
|
||||
return true if Billing::ReferenceNo.valid?(match) && Registrar.find_by(reference_no: match).any?
|
||||
return true if Billing::ReferenceNo.valid?(match) && Registrar.find_by(reference_no: match)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -136,8 +136,8 @@ class InvoiceTest < ActiveSupport::TestCase
|
|||
transaction.reference_no = registrar.reference_no
|
||||
transaction.sum = 250
|
||||
|
||||
Invoice.create_from_transaction!(transaction)
|
||||
|
||||
assert_emails 1
|
||||
assert_emails 1 do
|
||||
Invoice.create_from_transaction!(transaction)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue