mirror of
https://github.com/internetee/registry.git
synced 2025-07-24 03:30:33 +02:00
Validate given reference number
This commit is contained in:
parent
15470b7ec4
commit
166ff44491
2 changed files with 6 additions and 1 deletions
|
@ -118,7 +118,7 @@ class BankTransaction < ApplicationRecord
|
|||
|
||||
def ref_number_from_description
|
||||
(Billing::ReferenceNo::MULTI_REGEXP.match(description) || []).captures.each do |match|
|
||||
break match if match.length == 7 || Registrar.where(reference_no: match).present?
|
||||
break match if match.length == 7 || Billing::ReferenceNo.valid?(match)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,5 +7,10 @@ module Billing
|
|||
base = Base.generate
|
||||
"#{base}#{base.check_digit}"
|
||||
end
|
||||
|
||||
def self.valid?(ref)
|
||||
base = Base.new(ref.to_s[0...-1])
|
||||
ref.to_s == "#{base}#{base.check_digit}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue