Improve parsing of BankTransactionReference
Allow more characters before and after the actual reference. Also use the correct matching method during testing.
This commit is contained in:
parent
88228022e3
commit
ca0398632b
2 changed files with 51 additions and 15 deletions
|
|
@ -2,7 +2,7 @@ class BankTransactionReference
|
|||
|
||||
# parses a string from a bank transaction field
|
||||
def self.parse(data)
|
||||
m = /(^|\s)FS(?<group>\d+)(\.(?<user>\d+))?(?<parts>([A-Za-z]+\d+(\.\d+)?)+)(\s|$)/.match(data)
|
||||
m = /(^|[^\w\.])FS(?<group>\d+)(\.(?<user>\d+))?(?<parts>([A-Za-z]+\d+(\.\d+)?)+)([^\w\.]|$)/.match(data)
|
||||
return unless m
|
||||
|
||||
parts = {}
|
||||
|
|
@ -12,8 +12,8 @@ class BankTransactionReference
|
|||
parts[category] = value
|
||||
end
|
||||
|
||||
ret = { group: m[:group], parts: parts }
|
||||
ret[:user] = m[:user] if m[:user]
|
||||
ret = { group: m[:group].to_i, parts: parts }
|
||||
ret[:user] = m[:user].to_i if m[:user]
|
||||
return ret
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue