BankTransaction: Find reference numbers with any length from description

This commit is contained in:
Karl Erik Õunapuu 2020-09-09 12:25:29 +03:00
parent 05ca909741
commit e61601fdd7
No known key found for this signature in database
GPG key ID: C9DD647298A34764
2 changed files with 4 additions and 2 deletions

View file

@ -121,7 +121,8 @@ class BankTransaction < ApplicationRecord
end
def ref_number_from_description
match_data = /(\d{7})/.match(description)
match_data[0] if match_data.present?
(Billing::ReferenceNo::MULTI_REGEXP.match(description) || []).captures.each do |match|
break match if match.length == 7 || Registrar.where(reference_no: match).present?
end
end
end

View file

@ -1,6 +1,7 @@
module Billing
class ReferenceNo
REGEXP = /\A\d{2,20}\z/
MULTI_REGEXP = /(\d{2,20})/
def self.generate
base = Base.generate