mt940 0.6.6 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +3 -2
- data/CHANGELOG +5 -0
- data/Gemfile +6 -1
- data/Gemfile.lock +37 -3
- data/Guardfile +10 -0
- data/LICENSE.txt +1 -1
- data/README.md +8 -8
- data/docs/Formaatverschillen_SEPA_MT940_MT942_v1-2.pdf +0 -0
- data/docs/MT940_Technische_handleiding_Mijn_ING_Zakelijk_tcm7-117274.pdf +0 -0
- data/docs/MT940_voorbeeldbestanden_abnamro.txt +213 -0
- data/docs/formaatbeschrijving_xml_sepa_dd_29541336.pdf +0 -0
- data/docs/sepa_mt940_mingz_formaatbeschrijving_tcm7-133393.pdf +0 -0
- data/docs/triodos_mt940.pdf +0 -0
- data/lib/mt940/banks/abnamro.rb +21 -19
- data/lib/mt940/banks/ing.rb +17 -7
- data/lib/mt940/banks/rabobank.rb +38 -15
- data/lib/mt940/banks/triodos.rb +38 -7
- data/lib/mt940/base.rb +57 -61
- data/lib/mt940/bic_codes.rb +74 -0
- data/lib/mt940/parser.rb +53 -0
- data/lib/mt940/version.rb +1 -1
- data/lib/mt940.rb +2 -0
- data/mt940.gemspec +0 -2
- data/test/fixtures/abnamro_sepa.txt +12 -0
- data/test/fixtures/ing_sepa.txt +33 -0
- data/test/fixtures/rabobank_sepa.txt +74 -0
- data/test/fixtures/triodos_sepa.txt +62 -0
- data/test/helper.rb +1 -0
- data/test/mt940_abnamro_test.rb +90 -32
- data/test/mt940_base_test.rb +10 -18
- data/test/mt940_ing_test.rb +83 -29
- data/test/mt940_rabobank_test.rb +103 -34
- data/test/mt940_triodos_test.rb +104 -27
- metadata +45 -52
data/lib/mt940/base.rb
CHANGED
@@ -1,100 +1,96 @@
|
|
1
1
|
module MT940
|
2
2
|
|
3
|
+
BBAN_PATTERN = '^\d{10}'
|
4
|
+
IBAN_PATTERN = 'NL\d{2}[A-Z]{4}\d{10}'
|
5
|
+
BIC_CODE_PATTERN = MT940::BIC_CODES.values.join('|')
|
6
|
+
SEPA_PATTERN = Regexp.new "(#{BBAN_PATTERN})\\s+(#{IBAN_PATTERN})\\s+(#{BIC_CODE_PATTERN})(.+)$"
|
7
|
+
|
3
8
|
class Base
|
4
9
|
|
5
|
-
attr_accessor :bank
|
6
|
-
|
7
|
-
def
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
klass = determine_bank(first_line, second_line)
|
13
|
-
file.rewind
|
14
|
-
instance = klass.new(file)
|
15
|
-
file.close
|
16
|
-
instance.parse
|
17
|
-
else
|
18
|
-
raise ArgumentError.new('No file is given!')
|
10
|
+
attr_accessor :bank, :transactions
|
11
|
+
|
12
|
+
def initialize(file)
|
13
|
+
@transactions, @lines = [], []
|
14
|
+
@bank = self.class.to_s.split('::').last
|
15
|
+
file.readlines.each do |line|
|
16
|
+
begin_of_line?(line) ? @lines << line : @lines[-1] += line
|
19
17
|
end
|
20
18
|
end
|
21
19
|
|
22
20
|
def parse
|
23
|
-
@tag86 = false
|
24
21
|
@lines.each do |line|
|
25
|
-
@line = line
|
26
|
-
@line.match(/^:(\d{2}F?):/)
|
22
|
+
@line = line.strip.gsub(/\n/,'')
|
23
|
+
if @line.match(/^:(\d{2}F?):/)
|
24
|
+
case $1
|
25
|
+
when '25'
|
26
|
+
parse_tag_25
|
27
|
+
when '60F'
|
28
|
+
parse_tag_60F
|
29
|
+
when '61'
|
30
|
+
parse_tag_61
|
31
|
+
@transactions << @transaction if @transaction
|
32
|
+
when '86'
|
33
|
+
parse_tag_86 if @transaction
|
34
|
+
when '62F'
|
35
|
+
@transaction = nil #Ignore 'eindsaldo'
|
36
|
+
end
|
37
|
+
end
|
27
38
|
end
|
28
|
-
@transactions
|
29
39
|
end
|
30
40
|
|
31
41
|
private
|
32
42
|
|
33
|
-
def
|
34
|
-
|
35
|
-
if file.match(/\.rb$/)
|
36
|
-
klass = eval(file.gsub(/\.rb$/,'').capitalize)
|
37
|
-
bank = klass.determine_bank(*args)
|
38
|
-
return bank if bank
|
39
|
-
end
|
40
|
-
end
|
41
|
-
self
|
42
|
-
end
|
43
|
-
|
44
|
-
def initialize(file)
|
45
|
-
@transactions = []
|
46
|
-
@bank = self.class.to_s.split('::').last
|
47
|
-
@bank = 'Unknown' if @bank == 'Base'
|
48
|
-
@lines = file.readlines
|
43
|
+
def begin_of_line?(line)
|
44
|
+
line.match /^:|^940|^0000\s|^ABNA/
|
49
45
|
end
|
50
46
|
|
51
47
|
def parse_tag_25
|
52
48
|
@line.gsub!('.','')
|
53
|
-
if @line.match(/^:\d{2}:[^\d]*(\d*)/)
|
54
|
-
@bank_account = $1.gsub(/^0/,'')
|
55
|
-
@tag86 = false
|
56
|
-
end
|
49
|
+
@bank_account = $1.gsub(/^0/,'') if @line.match(/^:\d{2}:[^\d]*(\d*)/)
|
57
50
|
end
|
58
51
|
|
59
52
|
def parse_tag_60F
|
60
53
|
@currency = @line[12..14]
|
61
54
|
end
|
62
55
|
|
63
|
-
def parse_tag_61
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
@transaction
|
68
|
-
@
|
69
|
-
@tag86 = false
|
56
|
+
def parse_tag_61(pattern = nil)
|
57
|
+
pattern = pattern || /^:61:(\d{6})(C|D)(\d+),(\d{0,2})/
|
58
|
+
match = @line.match(pattern)
|
59
|
+
if match
|
60
|
+
@transaction = create_transaction(match)
|
61
|
+
@transaction.date = parse_date(match[1])
|
70
62
|
end
|
63
|
+
match
|
71
64
|
end
|
72
65
|
|
73
66
|
def parse_tag_86
|
74
|
-
if
|
75
|
-
@
|
76
|
-
|
77
|
-
|
67
|
+
if @line.match(/^:86:\s?(.*)$/)
|
68
|
+
@line = $1.strip
|
69
|
+
sepa? ? parse_line_after_sepa : parse_line_before_sepa
|
70
|
+
@transaction.contra_account = @contra_account
|
71
|
+
@transaction.description = @description
|
78
72
|
end
|
79
73
|
end
|
80
74
|
|
81
|
-
def
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
75
|
+
def hashify_description(description)
|
76
|
+
hash = {}
|
77
|
+
description.gsub!(/[^A-Z]\/[^A-Z]/,' ') #Remove single forward slashes '/', which are not part of a swift code
|
78
|
+
description[1..-1].split('/').each_slice(2).each do |first, second|
|
79
|
+
hash[first] = second
|
86
80
|
end
|
81
|
+
hash
|
87
82
|
end
|
88
83
|
|
89
|
-
def
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
84
|
+
def create_transaction(match)
|
85
|
+
type = match[2] == 'D' ? -1 : 1
|
86
|
+
MT940::Transaction.new(:bank_account => @bank_account,
|
87
|
+
:amount => type * (match[3] + '.' + match[4]).to_f,
|
88
|
+
:bank => @bank,
|
89
|
+
:currency => @currency)
|
94
90
|
end
|
95
91
|
|
96
|
-
|
97
|
-
|
92
|
+
def parse_date(string)
|
93
|
+
Date.new(2000 + string[0..1].to_i, string[2..3].to_i, string[4..5].to_i) if string
|
98
94
|
end
|
99
95
|
|
100
96
|
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module MT940
|
2
|
+
|
3
|
+
BIC_CODES =
|
4
|
+
|
5
|
+
{
|
6
|
+
ABNA: 'ABNANL2A',
|
7
|
+
AEGO: 'AEGONL2U',
|
8
|
+
ANDL: 'ANDLNL2A',
|
9
|
+
ARBN: 'ARBNNL22',
|
10
|
+
ARSN: 'ARSNNL21',
|
11
|
+
ARTE: 'ARTENL2A',
|
12
|
+
ASNB: 'ASNBNL21',
|
13
|
+
ASRB: 'ASRBNL2R',
|
14
|
+
ATBA: 'ATBANL2A',
|
15
|
+
BBRU: 'BBRUNL2X',
|
16
|
+
BCDM: 'BCDMNL22',
|
17
|
+
BCIT: 'BCITNL2A',
|
18
|
+
BICK: 'BICKNL2A',
|
19
|
+
BKMG: 'BKMGNL2A',
|
20
|
+
BLGW: 'BLGWNL21',
|
21
|
+
BNGH: 'BNGHNL2G',
|
22
|
+
BNPA: 'BNPANL2A',
|
23
|
+
BOFA: 'BOFANLNX',
|
24
|
+
BOFS: 'BOFSNL21002',
|
25
|
+
BOTK: 'BOTKNL2X',
|
26
|
+
CITC: 'CITCNL2A',
|
27
|
+
CITI: 'CITINL2X',
|
28
|
+
COBA: 'COBANL2X',
|
29
|
+
DEUT: 'DEUTNL2N',
|
30
|
+
DHBN: 'DHBNNL2R',
|
31
|
+
DLBK: 'DLBKNL2A',
|
32
|
+
DNIB: 'DNIBNL2G',
|
33
|
+
FBHL: 'FBHLNL2A',
|
34
|
+
FLOR: 'FLORNL2A',
|
35
|
+
FRBK: 'FRBKNL2L',
|
36
|
+
FRGH: 'FRGHNL21',
|
37
|
+
FTSB: 'ABNANL2A',
|
38
|
+
FVLB: 'FVLBNL22',
|
39
|
+
GILL: 'GILLNL2A',
|
40
|
+
HAND: 'HANDNL2A',
|
41
|
+
HHBA: 'HHBANL22',
|
42
|
+
HSBC: 'HSBCNL2A',
|
43
|
+
ICBK: 'ICBKNL2A',
|
44
|
+
INGB: 'INGBNL2A',
|
45
|
+
INSI: 'INSINL2A',
|
46
|
+
ISBK: 'ISBKNL2A',
|
47
|
+
KABA: 'KABANL2A',
|
48
|
+
KASA: 'KASANL2A',
|
49
|
+
KNAB: 'KNABNL2H',
|
50
|
+
KOEX: 'KOEXNL2A',
|
51
|
+
KRED: 'KREDNL2X',
|
52
|
+
LOCY: 'LOCYNL2A',
|
53
|
+
LOYD: 'LOYDNL2A',
|
54
|
+
LPLN: 'LPLNNL2F',
|
55
|
+
MHCB: 'MHCBNL2A',
|
56
|
+
NNBA: 'NNBANL2G',
|
57
|
+
NWAB: 'NWABNL2G',
|
58
|
+
OVBN: 'OVBNNL22',
|
59
|
+
RABO: 'RABONL2U',
|
60
|
+
RBOS: 'RBOSNL2A',
|
61
|
+
RBRB: 'RBRBNL21',
|
62
|
+
SNSB: 'SNSBNL2A',
|
63
|
+
SOGE: 'SOGENL2A',
|
64
|
+
STAL: 'STALNL2G',
|
65
|
+
TEBU: 'TEBUNL2A',
|
66
|
+
TRIO: 'TRIONL2U',
|
67
|
+
UBSW: 'UBSWNL2A',
|
68
|
+
UGBI: 'UGBINL2A',
|
69
|
+
VOWA: 'VOWANL21',
|
70
|
+
VPVG: 'VPVGNL22',
|
71
|
+
ZWLB: 'ZWLBNL21'
|
72
|
+
}
|
73
|
+
|
74
|
+
end
|
data/lib/mt940/parser.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
module MT940
|
2
|
+
|
3
|
+
class NoFileGiven < Exception; end
|
4
|
+
class UnknownBank < Exception; end
|
5
|
+
|
6
|
+
class Parser
|
7
|
+
|
8
|
+
attr_accessor :transactions
|
9
|
+
|
10
|
+
def initialize(file)
|
11
|
+
file = File.open(file) if file.is_a?(String)
|
12
|
+
if file.is_a?(File) || file.is_a?(Tempfile)
|
13
|
+
process(file)
|
14
|
+
file.close
|
15
|
+
else
|
16
|
+
raise NoFileGiven.new('No file is given!')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def process(file)
|
23
|
+
begin
|
24
|
+
bank_class = determine_bank_class(file)
|
25
|
+
instance = bank_class.new(file)
|
26
|
+
instance.parse
|
27
|
+
@transactions = instance.transactions
|
28
|
+
rescue NoMethodError => exception
|
29
|
+
if exception.message == "undefined method `new' for nil:NilClass"
|
30
|
+
raise UnknownBank.new('Could not determine bank!')
|
31
|
+
else
|
32
|
+
raise exception
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def determine_bank_class(file)
|
38
|
+
first_line = file.readline
|
39
|
+
case first_line
|
40
|
+
when /^:940:/
|
41
|
+
Rabobank
|
42
|
+
when /INGBNL/
|
43
|
+
Ing
|
44
|
+
when /ABNANL/
|
45
|
+
Abnamro
|
46
|
+
when /^:20:/
|
47
|
+
Triodos
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
data/lib/mt940/version.rb
CHANGED
data/lib/mt940.rb
CHANGED
@@ -2,6 +2,8 @@ $:.unshift(File.dirname(__FILE__)) unless
|
|
2
2
|
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
3
|
|
4
4
|
require 'tempfile'
|
5
|
+
require 'mt940/bic_codes'
|
6
|
+
require 'mt940/parser'
|
5
7
|
require 'mt940/base'
|
6
8
|
require 'mt940/transaction'
|
7
9
|
require 'mt940/banks/ing'
|
data/mt940.gemspec
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
ABNANL2A
|
2
|
+
940
|
3
|
+
ABNANL2A
|
4
|
+
:20:ABN AMRO BANK NV
|
5
|
+
:25:123456789
|
6
|
+
:28:13901/1
|
7
|
+
:60F:C120517EUR1945,64
|
8
|
+
:61:1209270927C0,01N944NONREF
|
9
|
+
:86:/TRTP/IDEAL/IBAN/NL73ANDL0123456789/BIC/ANDLNL20/NAME/NAAMXXX
|
10
|
+
1/REMI/Dit zijn de omschrijvingsregels/EREF/INNDNL2U200001001348
|
11
|
+
24001/ORDP//ID/1234567890AQCDEFGHIJ1234567890KLMNO
|
12
|
+
:62F:C120518EUR1945,65
|
@@ -0,0 +1,33 @@
|
|
1
|
+
0000 01INGBNL2AXXXX00001
|
2
|
+
0000 01INGBNL2AXXXX00001
|
3
|
+
940 00
|
4
|
+
:20:MPBZ
|
5
|
+
:25:0654321789
|
6
|
+
:28C:000
|
7
|
+
:60F:C120810EUR68,20
|
8
|
+
:61:120810C1,41NOV EV41411REP170112
|
9
|
+
:86:0654321789 J. Janssen Factuurnr 123456 klantnr 00123
|
10
|
+
:61:120810C1,56NOV EREF
|
11
|
+
:86:0123456789 NL69INGB0123456789 INGBNL2A J. Janssen
|
12
|
+
20120123456789 Factuurnr 123456 Klantnr 00123
|
13
|
+
:61:120810D2,13NVZ NONREF
|
14
|
+
:86:TOTAAL 1 VZ 4444444
|
15
|
+
:61:120810D1,57NVZ PREF
|
16
|
+
:86:VERZAMEL EUROBETALING M000000001111111 REMI TOTAAL 1 POSTEN
|
17
|
+
:61:120810C1,44NIC NONREF
|
18
|
+
:86:TOTAAL 1 IC 4444444
|
19
|
+
:61:120810D1,54NIC EV54541REP180112
|
20
|
+
:86:000754321 KN: EV54541REP180112
|
21
|
+
EV54541REP180112T1630 ING BANK NV INZAKE WEB?AMSTERDAM
|
22
|
+
:61:120810D1,14NIC MARF
|
23
|
+
:86:0123456789 Europese Incasso doorlopend NL69INGB0123456789 INGBNL2A
|
24
|
+
J. Jansen NL32ZZZ999999991234 MND-120123 20120501P01234785 CONTRIB
|
25
|
+
UTIE MEI 2012
|
26
|
+
:61:120810C939,60NAC NONREF
|
27
|
+
:86:0675432198 J. JANSSEN AMSTERDAM KN:3300169406045025
|
28
|
+
:62F:C120811EUR1005,83
|
29
|
+
:64:C120811EUR1005,83
|
30
|
+
:65:C120811EUR1005,83
|
31
|
+
:65:C120811EUR1005,83
|
32
|
+
:86:D000004C000004D6,38C944,01
|
33
|
+
-XXX
|
@@ -0,0 +1,74 @@
|
|
1
|
+
:940:
|
2
|
+
:20:940S130403
|
3
|
+
:25:NL50RABO0123456789
|
4
|
+
:28C:0
|
5
|
+
:60F:C130402EUR000000001147,95
|
6
|
+
|
7
|
+
:61:130403D000000000127,50N102EREF
|
8
|
+
NL96RBOS0523149468
|
9
|
+
:86:/EREF/02-04-2013 22:56 1120000153447185/BENM//NAME/Nespresso Nede
|
10
|
+
rland B.V./REMI/674725433 1120000153447185 14144467636004962
|
11
|
+
/ISDT/2013-04-03
|
12
|
+
|
13
|
+
:61:130403C000000000169,90N122NONREF
|
14
|
+
0663616476
|
15
|
+
:86:/ORDP//NAME/Bedrijf B.V./REMI/NR.201303-111/11.3.2013
|
16
|
+
NR.201303-112/11.3.2013/ISDT/2013-04-03
|
17
|
+
|
18
|
+
:61:131125C000000000173,50N541NONREF
|
19
|
+
NL02INGB0002447973
|
20
|
+
:86:/ORDP//NAME/Hr R Kuil en/of Mw A Kuil-Germain/REMI/861835-5746311
|
21
|
+
43
|
22
|
+
|
23
|
+
:61:131206C000000000171,66N122NONREF
|
24
|
+
0444656227
|
25
|
+
:86:/ORDP//NAME/D VAN WAARD CJ/REMI//IBS.00008908/ 1001680-P796142 KI
|
26
|
+
NDEROPVANG
|
27
|
+
|
28
|
+
:62F:C130403EUR000000001190,35
|
29
|
+
|
30
|
+
:20:940S130404
|
31
|
+
:25:NL50RABO0123456789
|
32
|
+
:28C:0
|
33
|
+
:60F:C130403EUR000000001190,35
|
34
|
+
|
35
|
+
:61:130404D000000000585,60N071NONREF
|
36
|
+
P004500018
|
37
|
+
:86:/BENM//NAME/DIVV afd parkeergebouwewn/REMI/Factuur 307472/ISDT/20
|
38
|
+
13-04-04
|
39
|
+
|
40
|
+
:61:130404C000000001640,76N127NONREF
|
41
|
+
0117888613
|
42
|
+
:86:/ORDP//NAME/DLN CONSULTING/REMI/factuurnummer 201303-128cursus ce
|
43
|
+
rtified PO/ISDT/2013-04-04
|
44
|
+
|
45
|
+
:61:130404D000000000674,73N060NONREF
|
46
|
+
P004238192
|
47
|
+
:86:/BENM//NAME/INFRACOM INTERNET BV/REMI/BETALINGSKENM. 231732INCASS
|
48
|
+
O FACTUUR 231732INCASSO 02-04-2013INFRACOM INTERNET BV*ZWOLLE
|
49
|
+
/ISDT/2013-04-04
|
50
|
+
|
51
|
+
:61:130401D000000000130,29N093NONREF
|
52
|
+
:86:/REMI/KostenPeriode 01-01-2013 t/m 31-03-2013/ISDT/2013-04-01
|
53
|
+
|
54
|
+
:61:130404C000000002050,95N122NONREF
|
55
|
+
0691765731
|
56
|
+
:86:/ORDP//NAME/Wehkamp BV
|
57
|
+
04
|
58
|
+
|
59
|
+
:61:130404C000000001923,90N541EREF
|
60
|
+
NL82RBOS0602069890
|
61
|
+
:86:/EREF/1134027115/ORDP//NAME/BEDRIJF NV/ADDR/STRAATWEG 68 123
|
62
|
+
2 AA AMSTERDAM THE NETHERLANDS NL/REMI/Ref: 201302-080/ISDT/2013-04-
|
63
|
+
04
|
64
|
+
|
65
|
+
:61:130404C000000013431,00N122NONREF
|
66
|
+
0477502946
|
67
|
+
:86:/ORDP//NAME/EVEREST BV/REMI/12420/20001512 201303-088 XX201303-08
|
68
|
+
8XX ZILVERLINE TRAINING1098 TW AMSTERDAM/ISDT/2013-04-04
|
69
|
+
|
70
|
+
:61:130920C000000000384,75N541NONREF
|
71
|
+
NL54INGB0006752576
|
72
|
+
:86:/ACCW/NL54INGB0006752576,INGBNL2A/ORDP//NAME/Hr A B Huibers en/of
|
73
|
+
Mw S L Huibers-Huveneers/REMI/1000122-P5549161
|
74
|
+
:62F:C130404EUR000000018846,34
|
@@ -0,0 +1,62 @@
|
|
1
|
+
:20:1352294232659/1
|
2
|
+
:25:TRIODOSBANK/0666666666
|
3
|
+
:28:1
|
4
|
+
:60F:C121123EUR1000,00
|
5
|
+
|
6
|
+
:61:121123D10,00NIT NONREF
|
7
|
+
:86:000>100555555555
|
8
|
+
>20TENAAMSTELLING TEGENREKENIN>21G EN ADRES TEGENREKENING EN >22 PLAATS TEGENREKENING EN EE>23N LANGE OMSCHRIJVING VAN DE >24 TRANSACTIE
|
9
|
+
>310666666666
|
10
|
+
|
11
|
+
:61:121123D250,00NAC NONREF
|
12
|
+
:86:000>100555555555
|
13
|
+
>20TENAAMSTELLING TEGENREKENIN>21G 1111222233334444 >310666666666
|
14
|
+
|
15
|
+
:61:121123C150,00NET NONREF
|
16
|
+
:86:000>100000000000
|
17
|
+
>20BBBBAA2U
|
18
|
+
>21AA99BBBB0555555555
|
19
|
+
>22TENAAMSTELLING TEGENREKENIN>23G EN ADRES TEGENREKENING EN >24 PLAATS TEGENREKENING EN EE>25N LANGE OMSCHRIJVING VAN DE >26 TRANSACTIE
|
20
|
+
>310666666666
|
21
|
+
|
22
|
+
:61:121123D40,00NET NONREF
|
23
|
+
:86:000>100000000000
|
24
|
+
>20BBBBAA2U
|
25
|
+
>21AA99BBBB0555555555
|
26
|
+
>22TENAAMSTELLING TEGENREKENIN>23G EN ADRES TEGENREKENING EN >24 PLAATS TEGENREKENING EN EE>25N LANGE OMSCHRIJVING VAN DE >26 TRANSACTIE 111122223333444>274
|
27
|
+
>310666666666
|
28
|
+
|
29
|
+
:62F:C121123EUR850,00
|
30
|
+
-
|
31
|
+
|
32
|
+
:20:1352294232659/2
|
33
|
+
:25:TRIODOSBANK/0999999999
|
34
|
+
:28:1
|
35
|
+
:60F:C121123EUR950,12
|
36
|
+
|
37
|
+
:61:121123D8,95NIT NONREF
|
38
|
+
:86:000>100888888888
|
39
|
+
>20TENAAMSTELLING TEGENREKENIN>21G EN ADRES TEGENREKENING EN >22 PLAATS TEGENREKENING EN EE>23N LANGE OMSCHRIJVING VAN DE
|
40
|
+
>24 TRANSACTIE
|
41
|
+
>310999999999
|
42
|
+
|
43
|
+
:61:121123D25,25NAC NONREF
|
44
|
+
:86:000>100888888888
|
45
|
+
>20TENAAMSTELLING TEGENREKENIN>21G 1111222233334444 >310999999999
|
46
|
+
|
47
|
+
:61:121123C150,00NET NONREF
|
48
|
+
:86:000>100000000000
|
49
|
+
>20BBBBAA2U
|
50
|
+
>21AA99BBBB0888888888
|
51
|
+
>22TENAAMSTELLING TEGENREKENIN>23G EN ADRES TEGENREKENING EN >24 PLAATS TEGENREKENING EN EE>25N LANGE OMSCHRIJVING VAN DE >26 TRANSACTIE
|
52
|
+
>310999999999
|
53
|
+
|
54
|
+
:61:121123D56,78NET NONREF
|
55
|
+
:86:000>100000000000
|
56
|
+
>20BBBBAA2U
|
57
|
+
>21AA99BBBB0888888888
|
58
|
+
>22TENAAMSTELLING TEGENREKENIN>23G EN ADRES TEGENREKENING EN >24 PLAATS TEGENREKENING EN EE>25N LANGE OMSCHRIJVING VAN DE >26 TRANSACTIE 111122223333444>274
|
59
|
+
>310999999999
|
60
|
+
|
61
|
+
:62F:C121123EUR1009,14
|
62
|
+
-
|
data/test/helper.rb
CHANGED
data/test/mt940_abnamro_test.rb
CHANGED
@@ -2,56 +2,114 @@ require 'helper'
|
|
2
2
|
|
3
3
|
class TestMt940Abnamro < Test::Unit::TestCase
|
4
4
|
|
5
|
-
|
6
|
-
file_name = File.dirname(__FILE__) + '/fixtures/abnamro.txt'
|
7
|
-
@transactions = MT940::Base.transactions(file_name)
|
8
|
-
@transaction = @transactions.first
|
9
|
-
end
|
10
|
-
|
11
|
-
should 'have the correct number of transactions' do
|
12
|
-
assert_equal 10, @transactions.size
|
13
|
-
end
|
5
|
+
context 'Before SEPA' do
|
14
6
|
|
15
|
-
|
16
|
-
|
17
|
-
|
7
|
+
setup do
|
8
|
+
file_name = File.dirname(__FILE__) + '/fixtures/abnamro.txt'
|
9
|
+
@transactions = MT940::Parser.new(file_name).transactions
|
18
10
|
end
|
19
|
-
|
20
|
-
should 'have
|
21
|
-
assert_equal
|
11
|
+
|
12
|
+
should 'have the correct number of transactions' do
|
13
|
+
assert_equal 10, @transactions.size
|
22
14
|
end
|
23
15
|
|
24
|
-
context '
|
25
|
-
|
26
|
-
|
16
|
+
context 'Transaction' do
|
17
|
+
|
18
|
+
setup do
|
19
|
+
@transaction = @transactions.first
|
27
20
|
end
|
28
21
|
|
29
|
-
should 'have
|
30
|
-
assert_equal '
|
22
|
+
should 'have a bank_account' do
|
23
|
+
assert_equal '517852257', @transaction.bank_account
|
31
24
|
end
|
32
|
-
end
|
33
25
|
|
34
|
-
|
35
|
-
|
36
|
-
|
26
|
+
should 'have an amount' do
|
27
|
+
assert_equal -9.00, @transaction.amount
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'Description' do
|
31
|
+
should 'have the correct description in case of a GIRO account' do
|
32
|
+
assert_equal ' KPN - DIGITENNE BETALINGSKENM. 0000000421886595314606715 BETREFT FACTUUR D.D. 20-05-2011INCL. 1,44 BTW', @transaction.description
|
33
|
+
end
|
34
|
+
|
35
|
+
should 'have the correct description in case of a regular bank' do
|
36
|
+
assert_equal ' MYCOM DEN HAAG S-GRAVEN,PAS999', @transactions.last.description
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
should 'have a date' do
|
41
|
+
assert_equal Date.new(2011,5,24), @transaction.date
|
42
|
+
end
|
43
|
+
|
44
|
+
should 'return its bank' do
|
45
|
+
assert_equal 'Abnamro', @transaction.bank
|
46
|
+
end
|
37
47
|
|
38
|
-
|
39
|
-
|
48
|
+
should 'have a currency' do
|
49
|
+
assert_equal 'EUR', @transaction.currency
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'Contra account' do
|
53
|
+
should 'be determined in case of a GIRO account' do
|
54
|
+
assert_equal '000428428', @transaction.contra_account
|
55
|
+
end
|
56
|
+
|
57
|
+
should 'be determined in case of a regular bank' do
|
58
|
+
assert_equal '528939882', @transactions.last.contra_account
|
59
|
+
end
|
60
|
+
end
|
40
61
|
end
|
41
62
|
|
42
|
-
|
43
|
-
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'After SEPA' do
|
66
|
+
|
67
|
+
setup do
|
68
|
+
file_name = File.dirname(__FILE__) + '/fixtures/abnamro_sepa.txt'
|
69
|
+
@transactions = MT940::Parser.new(file_name).transactions
|
70
|
+
end
|
71
|
+
|
72
|
+
should 'have the correct number of transactions' do
|
73
|
+
assert_equal 1, @transactions.size
|
44
74
|
end
|
45
75
|
|
46
|
-
context '
|
76
|
+
context 'Transaction' do
|
77
|
+
|
78
|
+
setup do
|
79
|
+
@transaction = @transactions.first
|
80
|
+
end
|
81
|
+
|
82
|
+
should 'have a bank_account' do
|
83
|
+
assert_equal '123456789', @transaction.bank_account
|
84
|
+
end
|
85
|
+
|
86
|
+
should 'have a date' do
|
87
|
+
assert_equal Date.new(2012,9,27), @transaction.date
|
88
|
+
end
|
89
|
+
|
90
|
+
should 'have an amount' do
|
91
|
+
assert_equal 0.01, @transaction.amount
|
92
|
+
end
|
93
|
+
|
94
|
+
should 'return its bank' do
|
95
|
+
assert_equal 'Abnamro', @transaction.bank
|
96
|
+
end
|
97
|
+
|
98
|
+
should 'have a currency' do
|
99
|
+
assert_equal 'EUR', @transaction.currency
|
100
|
+
end
|
101
|
+
|
47
102
|
should 'be determined in case of a GIRO account' do
|
48
|
-
assert_equal '
|
103
|
+
assert_equal 'NL73ANDL0123456789', @transaction.contra_account
|
49
104
|
end
|
50
105
|
|
51
|
-
should '
|
52
|
-
assert_equal '
|
106
|
+
should 'have the correct description in case of a regular bank' do
|
107
|
+
assert_equal 'Dit zijn de omschrijvingsregels', @transactions.last.description
|
53
108
|
end
|
109
|
+
|
54
110
|
end
|
111
|
+
|
55
112
|
end
|
56
113
|
|
114
|
+
|
57
115
|
end
|