Merge branch 'master' into 1101-topping-up-credit-account-without-an-invoice

This commit is contained in:
Karl Erik Õunapuu 2020-09-10 13:57:27 +03:00 committed by GitHub
commit df79982881
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 4 deletions

View file

@ -120,7 +120,12 @@ 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 || valid_ref_no?(match)
end
end
def valid_ref_no?(match)
return true if Billing::ReferenceNo.valid?(match) && Registrar.find_by(reference_no: match).any?
end
end