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
|
end
|
||||||
|
|
||||||
def ref_number_from_description
|
def ref_number_from_description
|
||||||
(Billing::ReferenceNo::MULTI_REGEXP.match(description) || []).captures.each do |match|
|
matches = description.to_s.scan(Billing::ReferenceNo::MULTI_REGEXP).flatten
|
||||||
break match if match.length == 7 || valid_ref_no?(match)
|
matches.detect { |m| break m if m.length == 7 || valid_ref_no?(m) }
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def valid_ref_no?(match)
|
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -136,8 +136,8 @@ class InvoiceTest < ActiveSupport::TestCase
|
||||||
transaction.reference_no = registrar.reference_no
|
transaction.reference_no = registrar.reference_no
|
||||||
transaction.sum = 250
|
transaction.sum = 250
|
||||||
|
|
||||||
Invoice.create_from_transaction!(transaction)
|
assert_emails 1 do
|
||||||
|
Invoice.create_from_transaction!(transaction)
|
||||||
assert_emails 1
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue