Sha256: 63571f534eea50559af1c0b1b3f7707081828ce561c3b5b4dd8e08ffbdbba8aa
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
module MT940Structured::Parsers::Ing class TransactionParser include MT940Structured::Parsers::DateParser include MT940Structured::Parsers::IbanSupport include MT940Structured::Parsers::StructuredDescriptionParser include MT940Structured::Parsers::Ing::Types def parse_transaction(line_61) if line_61.match(/^:61:(\d{6})(C|D)(\d+),(\d{0,2})N(\S+)/) sign = $2 == 'D' ? -1 : 1 transaction = MT940::Transaction.new(:amount => sign * ($3 + '.' + $4).to_f) transaction.type = human_readable_type($5.strip) transaction.date = parse_date($1) transaction end end def enrich_transaction(transaction, line_86) if line_86.match(/^:86:\s?(.*)\Z/m) description = $1.gsub(/>\d{2}/, '').strip if description.match(/([P|\d]\d{9})?(.+)/) transaction.description = $2.strip transaction.contra_account = $1.nil? ? "NONREF" : $1.gsub(/\D/, '').gsub(/^0+/, '') else transaction.description = description end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
zilverline-mt940-2.0 | lib/mt940_structured/parsers/ing/transaction_parser.rb |