Add automatic generation of financial transactions and links

This commit is contained in:
Patrick Gansterer 2017-01-26 13:27:30 +01:00
parent 91eeac6c40
commit 8e2ca5e7d7
11 changed files with 284 additions and 0 deletions

View file

@ -0,0 +1,20 @@
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)
return unless m
parts = {}
m[:parts].scan(/([A-Za-z]+)(\d+(\.\d+)?)/) do |category, value|
value = value.to_f
value += parts[category] if parts[category]
parts[category] = value
end
ret = { group: m[:group], parts: parts }
ret[:user] = m[:user] if m[:user]
return ret
end
end