Class: MT940Structured::Parsers::Ing::TransactionParser

Inherits:
Object
  • Object
show all
Includes:
DateParser, MT940Structured::Parsers::IbanSupport, Types, StructuredDescriptionParser
Defined in:
lib/mt940_structured/parsers/ing/transaction_parser.rb

Direct Known Subclasses

StructuredTransactionParser

Constant Summary

Constants included from Types

MT940Structured::Parsers::Ing::Types::ING_MAPPING

Constants included from MT940Structured::Parsers::IbanSupport

MT940Structured::Parsers::IbanSupport::IBAN_R

Instance Method Summary collapse

Methods included from Types

#human_readable_type

Methods included from StructuredDescriptionParser

#parse_description_after_tag

Methods included from MT940Structured::Parsers::IbanSupport

#iban?, #iban_to_account

Methods included from DateParser

#parse_date

Instance Method Details

#enrich_transaction(transaction, line_86) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/mt940_structured/parsers/ing/transaction_parser.rb', line 19

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. = $1.nil? ? "NONREF" : $1.gsub(/\D/, '').gsub(/^0+/, '')
    else
      transaction.description = description
    end
  end
end

#parse_transaction(line_61) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/mt940_structured/parsers/ing/transaction_parser.rb', line 8

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