Skip to content

Commit

Permalink
BankTransaction: Find reference numbers with any length from description
Browse files Browse the repository at this point in the history
  • Loading branch information
karlerikounapuu committed Sep 9, 2020
1 parent 05ca909 commit e61601f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/models/bank_transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ def parsed_ref_number
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
1 change: 1 addition & 0 deletions app/models/billing/reference_no.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit e61601f

Please sign in to comment.