mt940 0.6.6 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,17 +3,9 @@ require 'helper'
3
3
  class TestMt940Base < Test::Unit::TestCase
4
4
 
5
5
  context 'MT940::Base' do
6
- should 'read the transactions with the filename of the MT940 file' do
7
- file_name = File.dirname(__FILE__) + '/fixtures/ing.txt'
8
- @transactions = MT940::Base.transactions(file_name)
9
- assert_equal 6, @transactions.size
10
- end
11
-
12
6
  should 'read the transactions with the handle to the mt940 file itself' do
13
7
  file_name = File.dirname(__FILE__) + '/fixtures/ing.txt'
14
- file = File.open(file_name)
15
- @transactions = MT940::Base.transactions(file)
16
- assert_equal 6, @transactions.size
8
+ assert_equal 6, MT940::Parser.new(file_name).transactions.size
17
9
  end
18
10
 
19
11
  #Tempfile is used by Paperclip, so the following will work:
@@ -22,30 +14,30 @@ class TestMt940Base < Test::Unit::TestCase
22
14
  file = Tempfile.new('temp')
23
15
  file.write(':940:')
24
16
  file.rewind
25
- @transactions = MT940::Base.transactions(file)
26
- assert_equal 0, @transactions.size
17
+ assert_equal 0, MT940::Parser.new(file).transactions.size
27
18
  file.unlink
28
19
  end
29
20
 
30
21
  should 'raise an exception if the file does not exist' do
31
22
  file_name = File.dirname(__FILE__) + '/fixtures/123.txt'
32
23
  assert_raise Errno::ENOENT do
33
- @transactions = MT940::Base.transactions(file_name)
24
+ file = MT940::Parser.new(file_name)
34
25
  end
35
26
  end
36
27
 
37
- should 'raise an ArgumentError if a wrong argument was given' do
38
- assert_raise ArgumentError do
39
- MT940::Base.transactions(Hash.new)
28
+ should 'raise an NoFileGiven if a wrong argument was given' do
29
+ assert_raise MT940::NoFileGiven do
30
+ MT940::Parser.new(Hash.new)
40
31
  end
41
32
  end
42
33
  end
43
34
 
44
35
  context 'Unknown MT940 file' do
45
- should 'return its bank' do
36
+ should 'raise an UnknownBank if bank could not be determined' do
46
37
  file_name = File.dirname(__FILE__) + '/fixtures/unknown.txt'
47
- @transactions = MT940::Base.transactions(file_name)
48
- assert_equal 'Unknown', @transactions.first.bank
38
+ assert_raise MT940::UnknownBank do
39
+ MT940::Parser.new(file_name)
40
+ end
49
41
  end
50
42
  end
51
43
 
@@ -2,45 +2,99 @@ require 'helper'
2
2
 
3
3
  class TestMt940Ing < Test::Unit::TestCase
4
4
 
5
- def setup
6
- file_name = File.dirname(__FILE__) + '/fixtures/ing.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 6, @transactions.size
13
- end
14
-
15
- context 'Transaction' do
16
- should 'have a bank_account' do
17
- assert_equal '001234567', @transaction.bank_account
5
+ context 'Before SEPA' do
6
+ setup do
7
+ file_name = File.dirname(__FILE__) + '/fixtures/ing.txt'
8
+ @transactions = MT940::Parser.new(file_name).transactions
18
9
  end
19
-
20
- should 'have an amount' do
21
- assert_equal -25.03, @transaction.amount
10
+
11
+ should 'have the correct number of transactions' do
12
+ assert_equal 6, @transactions.size
22
13
  end
23
14
 
24
- should 'have a currency' do
25
- assert_equal 'EUR', @transaction.currency
26
- end
15
+ context 'Transaction' do
27
16
 
28
- should 'have a date' do
29
- assert_equal Date.new(2010,7,22), @transaction.date
30
- end
17
+ setup do
18
+ @transaction = @transactions.first
19
+ end
31
20
 
32
- should 'return its bank' do
33
- assert_equal 'Ing', @transaction.bank
34
- end
21
+ should 'have a bank_account' do
22
+ assert_equal '001234567', @transaction.bank_account
23
+ end
24
+
25
+ should 'have an amount' do
26
+ assert_equal -25.03, @transaction.amount
27
+ end
28
+
29
+ should 'have a currency' do
30
+ assert_equal 'EUR', @transaction.currency
31
+ end
32
+
33
+ should 'have a date' do
34
+ assert_equal Date.new(2010,7,22), @transaction.date
35
+ end
36
+
37
+ should 'return its bank' do
38
+ assert_equal 'Ing', @transaction.bank
39
+ end
40
+
41
+ should 'have a description' do
42
+ assert_equal 'EJ46GREENP100610T1456 CLIEOP TMG GPHONGKONG AMSTERDAM', @transactions.last.description
43
+ end
44
+
45
+ should 'return the contra_account' do
46
+ assert_equal '123456789', @transactions.last.contra_account
47
+ end
35
48
 
36
- should 'have a description' do
37
- assert_equal 'EJ46GREENP100610T1456 CLIEOP TMG GPHONGKONG AMSTERDAM', @transactions.last.description
38
49
  end
50
+ end
39
51
 
40
- should 'return the contra_account' do
41
- assert_equal '123456789', @transactions.last.contra_account
52
+ context 'After SEPA' do
53
+ setup do
54
+ # Fixture contains a mixture of transactions with and without iban numbers
55
+ file_name = File.dirname(__FILE__) + '/fixtures/ing_sepa.txt'
56
+ @transactions = MT940::Parser.new(file_name).transactions
57
+ end
58
+
59
+ should 'have the correct number of transactions' do
60
+ assert_equal 8, @transactions.size
42
61
  end
43
62
 
63
+ context 'Transaction' do
64
+
65
+ setup do
66
+ @transaction = @transactions.first
67
+ end
68
+
69
+ should 'have a bank_account' do
70
+ assert_equal '654321789', @transaction.bank_account
71
+ end
72
+
73
+ should 'have an amount' do
74
+ assert_equal 1.41, @transaction.amount
75
+ end
76
+
77
+ should 'have a currency' do
78
+ assert_equal 'EUR', @transaction.currency
79
+ end
80
+
81
+ should 'have a date' do
82
+ assert_equal Date.new(2012,8,10), @transaction.date
83
+ end
84
+
85
+ should 'return its bank' do
86
+ assert_equal 'Ing', @transaction.bank
87
+ end
88
+
89
+ should 'have a description' do
90
+ assert_equal 'J. Janssen 20120123456789 Factuurnr 123456 Klantnr 00123', @transactions[1].description
91
+ end
92
+
93
+ should 'return the contra_account' do
94
+ assert_equal 'NL69INGB0123456789', @transactions[1].contra_account
95
+ end
96
+
97
+ end
44
98
  end
45
99
 
46
100
  end
@@ -2,57 +2,126 @@ require 'helper'
2
2
 
3
3
  class TestMt940Rabobank < Test::Unit::TestCase
4
4
 
5
- def setup
6
- file_name = File.dirname(__FILE__) + '/fixtures/rabobank.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 3, @transactions.size
13
- end
5
+ context 'Before SEPA' do
6
+ setup do
7
+ file_name = File.dirname(__FILE__) + '/fixtures/rabobank.txt'
8
+ @transactions = MT940::Parser.new(file_name).transactions
9
+ end
14
10
 
15
- context 'Transaction' do
16
- should 'have a bank_account' do
17
- assert_equal '129199348', @transaction.bank_account
11
+ should 'have the correct number of transactions' do
12
+ assert_equal 3, @transactions.size
18
13
  end
19
14
 
20
- context 'Contra account' do
21
- should 'be determined in case of a GIRO account' do
22
- assert_equal '121470966', @transaction.contra_account
15
+ context 'Transaction' do
16
+
17
+ setup do
18
+ @transaction = @transactions.first
23
19
  end
24
20
 
25
- should 'be determined in case of a regular bank' do
26
- assert_equal '733959555', @transactions[1].contra_account
21
+ should 'have a bank_account' do
22
+ assert_equal '129199348', @transaction.bank_account
27
23
  end
28
24
 
29
- should 'be determined in case of a NONREF' do
30
- assert_equal 'NONREF', @transactions.last.contra_account
25
+ context 'Contra account' do
26
+ should 'be determined in case of a GIRO account' do
27
+ assert_equal '121470966', @transaction.contra_account
28
+ end
29
+
30
+ should 'be determined in case of a regular bank' do
31
+ assert_equal '733959555', @transactions[1].contra_account
32
+ end
33
+
34
+ should 'be determined in case of a NONREF' do
35
+ assert_equal 'NONREF', @transactions.last.contra_account
36
+ end
31
37
  end
32
- end
33
38
 
34
- should 'have an amount' do
35
- assert_equal -1213.28, @transaction.amount
36
- end
39
+ should 'have an amount' do
40
+ assert_equal -1213.28, @transaction.amount
41
+ end
37
42
 
38
- should 'have a currency' do
39
- assert_equal 'EUR', @transaction.currency
40
- end
43
+ should 'have a currency' do
44
+ assert_equal 'EUR', @transaction.currency
45
+ end
46
+
47
+ should 'have a contra_account_owner' do
48
+ assert_equal 'W.P. Jansen', @transaction.contra_account_owner
49
+ end
50
+
51
+ should 'have a description' do
52
+ assert_equal 'Terugboeking NIET AKKOORD MET AFSCHRIJVING KOSTEN KINDEROPVANG JUNI 20095731', @transaction.description
53
+ end
54
+
55
+ should 'have a date' do
56
+ assert_equal Date.new(2011,5,27), @transaction.date
57
+ end
58
+
59
+ should 'return its bank' do
60
+ assert_equal 'Rabobank', @transaction.bank
61
+ end
41
62
 
42
- should 'have a contra_account_owner' do
43
- assert_equal 'W.P. Jansen', @transaction.contra_account_owner
44
63
  end
45
64
 
46
- should 'have a description' do
47
- assert_equal 'Terugboeking NIET AKKOORD MET AFSCHRIJVING KOSTEN KINDEROPVANG JUNI 20095731', @transaction.description
65
+ end
66
+
67
+ context 'After SEPA' do
68
+ setup do
69
+ file_name = File.dirname(__FILE__) + '/fixtures/rabobank_sepa.txt'
70
+ @transactions = MT940::Parser.new(file_name).transactions
48
71
  end
49
72
 
50
- should 'have a date' do
51
- assert_equal Date.new(2011,5,27), @transaction.date
73
+ should 'have the correct number of transactions' do
74
+ assert_equal 12, @transactions.size
52
75
  end
53
76
 
54
- should 'return its bank' do
55
- assert_equal 'Rabobank', @transaction.bank
77
+ context 'Transaction' do
78
+
79
+ setup do
80
+ @transaction = @transactions.first
81
+ end
82
+
83
+ should 'have a bank_account' do
84
+ assert_equal 'NL50RABO0123456789', @transaction.bank_account
85
+ end
86
+
87
+ context 'Contra account' do
88
+ should 'be determined in case of a GIRO account' do
89
+ assert_equal 'NL96RBOS0523149468', @transaction.contra_account
90
+ end
91
+
92
+ should 'be determined in case of a regular bank' do
93
+ assert_equal '0663616476', @transactions[1].contra_account
94
+ end
95
+
96
+ should 'be determined in case of Postbank account' do
97
+ assert_equal 'P004500018', @transactions[4].contra_account
98
+ end
99
+ end
100
+
101
+ should 'have an amount' do
102
+ assert_equal -127.50, @transaction.amount
103
+ end
104
+
105
+ should 'have a currency' do
106
+ assert_equal 'EUR', @transaction.currency
107
+ end
108
+
109
+ should 'not be able to determine a contra_account_owner' do
110
+ assert !@transaction.contra_account_owner
111
+ end
112
+
113
+ should 'have a description' do
114
+ assert_equal 'DIVV afd parkeergebouwewn Factuur 307472', @transactions[4].description
115
+ end
116
+
117
+ should 'have a date' do
118
+ assert_equal Date.new(2013,4,3), @transaction.date
119
+ end
120
+
121
+ should 'return its bank' do
122
+ assert_equal 'Rabobank', @transaction.bank
123
+ end
124
+
56
125
  end
57
126
 
58
127
  end
@@ -2,43 +2,120 @@ require 'helper'
2
2
 
3
3
  class TestMt940Triodos < Test::Unit::TestCase
4
4
 
5
- def setup
6
- file_name = File.dirname(__FILE__) + '/fixtures/triodos.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 2, @transactions.size
13
- end
5
+ context 'Before sepa' do
14
6
 
15
- context 'Transaction' do
16
- should 'have a bank_account' do
17
- assert_equal '390123456', @transaction.bank_account
7
+ setup do
8
+ file_name = File.dirname(__FILE__) + '/fixtures/triodos.txt'
9
+ @transactions = MT940::Parser.new(file_name).transactions
18
10
  end
19
-
20
- should 'have an amount' do
21
- assert_equal -15.7, @transaction.amount
11
+
12
+ should 'have the correct number of transactions' do
13
+ assert_equal 2, @transactions.size
22
14
  end
23
15
 
24
- should 'have a currency' do
25
- assert_equal 'EUR', @transaction.currency
26
- end
16
+ context 'Transaction' do
27
17
 
28
- should 'have a description' do
29
- assert_equal 'ALGEMENE TUSSENREKENING KOSTEN VAN 01-10-2010 TOT EN M ET 31-12-20100390123456', @transaction.description
30
- end
18
+ setup do
19
+ @transaction = @transactions.first
20
+ end
21
+
22
+ should 'have a bank_account' do
23
+ assert_equal '390123456', @transaction.bank_account
24
+ end
25
+
26
+ should 'have an amount' do
27
+ assert_equal -15.7, @transaction.amount
28
+ end
29
+
30
+ should 'have a currency' do
31
+ assert_equal 'EUR', @transaction.currency
32
+ end
33
+
34
+ should 'have a description' do
35
+ assert_equal 'ALGEMENE TUSSENREKENING KOSTEN VAN 01-10-2010 TOT EN MET 31-12-2010', @transaction.description
36
+ end
37
+
38
+ should 'have a date' do
39
+ assert_equal Date.new(2011,1,1), @transaction.date
40
+ end
41
+
42
+ should 'return its bank' do
43
+ assert_equal 'Triodos', @transaction.bank
44
+ end
45
+
46
+ should 'return the contra_account' do
47
+ assert_equal '987654321', @transaction.contra_account
48
+ end
31
49
 
32
- should 'have a date' do
33
- assert_equal Date.new(2011,1,1), @transaction.date
34
50
  end
35
51
 
36
- should 'return its bank' do
37
- assert_equal 'Triodos', @transaction.bank
52
+ end
53
+
54
+ context 'After sepa' do
55
+
56
+ setup do
57
+ file_name = File.dirname(__FILE__) + '/fixtures/triodos_sepa.txt'
58
+ @transactions = MT940::Parser.new(file_name).transactions
59
+ end
60
+
61
+ should 'have the correct number of transactions' do
62
+ assert_equal 8, @transactions.size
38
63
  end
39
64
 
40
- should 'return the contra_account' do
41
- assert_equal '987654321', @transaction.contra_account
65
+ context 'Transaction' do
66
+
67
+ setup do
68
+ @transaction = @transactions.first
69
+ end
70
+
71
+ should 'have a bank_account' do
72
+ assert_equal '666666666', @transaction.bank_account
73
+ end
74
+
75
+ should 'have an amount' do
76
+ assert_equal -10.00, @transaction.amount
77
+ end
78
+
79
+ should 'have a currency' do
80
+ assert_equal 'EUR', @transaction.currency
81
+ end
82
+
83
+ context 'description' do
84
+
85
+ setup do
86
+ @description = 'TENAAMSTELLING TEGENREKENING EN ADRES TEGENREKENING EN PLAATS TEGENREKENING EN EEN LANGE OMSCHRIJVING VAN DE TRANSACTIE'
87
+ end
88
+
89
+ should 'have the description in case of BBAN' do
90
+ assert_equal @description, @transaction.description
91
+ end
92
+
93
+ should 'have the description in case of IBAN' do
94
+ assert_equal @description, @transactions[2].description
95
+ end
96
+
97
+ end
98
+
99
+ should 'have a date' do
100
+ assert_equal Date.new(2012,11,23), @transaction.date
101
+ end
102
+
103
+ should 'return its bank' do
104
+ assert_equal 'Triodos', @transaction.bank
105
+ end
106
+
107
+ context 'contra_account' do
108
+
109
+ should 'return the contra_account in case of a BBAN' do
110
+ assert_equal '555555555', @transaction.contra_account
111
+ end
112
+
113
+ should 'return the contra_account in case of a IBAN' do
114
+ assert_equal 'AA99BBBB0555555555', @transactions[2].contra_account
115
+ end
116
+
117
+ end
118
+
42
119
  end
43
120
 
44
121
  end
metadata CHANGED
@@ -1,66 +1,60 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: mt940
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 6
8
- - 6
9
- version: 0.6.6
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.0
10
5
  platform: ruby
11
- authors:
6
+ authors:
12
7
  - Frank Oxener
13
8
  autorequire:
14
9
  bindir: bin
15
10
  cert_chain: []
16
-
17
- date: 2012-04-25 00:00:00 +02:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- name: shoulda
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 0
29
- version: "0"
30
- type: :development
31
- version_requirements: *id001
11
+ date: 2014-01-09 00:00:00.000000000 Z
12
+ dependencies: []
32
13
  description: A basic MT940 parser with implementations for Dutch banks.
33
14
  email: frank.oxener@gmail.com
34
15
  executables: []
35
-
36
16
  extensions: []
37
-
38
- extra_rdoc_files:
17
+ extra_rdoc_files:
39
18
  - LICENSE.txt
40
19
  - README.md
41
- files:
42
- - .document
43
- - .gitignore
44
- - .travis.yml
20
+ files:
21
+ - ".document"
22
+ - ".gitignore"
23
+ - ".ruby-gemset"
24
+ - ".ruby-version"
25
+ - ".travis.yml"
45
26
  - CHANGELOG
46
27
  - Gemfile
47
28
  - Gemfile.lock
29
+ - Guardfile
48
30
  - LICENSE.txt
49
31
  - README.md
50
32
  - Rakefile
33
+ - docs/Formaatverschillen_SEPA_MT940_MT942_v1-2.pdf
34
+ - docs/MT940_Technische_handleiding_Mijn_ING_Zakelijk_tcm7-117274.pdf
35
+ - docs/MT940_voorbeeldbestanden_abnamro.txt
36
+ - docs/formaatbeschrijving_xml_sepa_dd_29541336.pdf
37
+ - docs/sepa_mt940_mingz_formaatbeschrijving_tcm7-133393.pdf
38
+ - docs/triodos_mt940.pdf
51
39
  - lib/mt940.rb
52
40
  - lib/mt940/banks/abnamro.rb
53
41
  - lib/mt940/banks/ing.rb
54
42
  - lib/mt940/banks/rabobank.rb
55
43
  - lib/mt940/banks/triodos.rb
56
44
  - lib/mt940/base.rb
45
+ - lib/mt940/bic_codes.rb
46
+ - lib/mt940/parser.rb
57
47
  - lib/mt940/transaction.rb
58
48
  - lib/mt940/version.rb
59
49
  - mt940.gemspec
60
50
  - test/fixtures/abnamro.txt
51
+ - test/fixtures/abnamro_sepa.txt
61
52
  - test/fixtures/ing.txt
53
+ - test/fixtures/ing_sepa.txt
62
54
  - test/fixtures/rabobank.txt
55
+ - test/fixtures/rabobank_sepa.txt
63
56
  - test/fixtures/triodos.txt
57
+ - test/fixtures/triodos_sepa.txt
64
58
  - test/fixtures/unknown.txt
65
59
  - test/helper.rb
66
60
  - test/mt940_abnamro_test.rb
@@ -68,41 +62,39 @@ files:
68
62
  - test/mt940_ing_test.rb
69
63
  - test/mt940_rabobank_test.rb
70
64
  - test/mt940_triodos_test.rb
71
- has_rdoc: true
72
65
  homepage: http://github.com/dovadi/mt940
73
- licenses:
66
+ licenses:
74
67
  - MIT
68
+ metadata: {}
75
69
  post_install_message:
76
70
  rdoc_options: []
77
-
78
- require_paths:
71
+ require_paths:
79
72
  - lib
80
- required_ruby_version: !ruby/object:Gem::Requirement
81
- requirements:
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
82
75
  - - ">="
83
- - !ruby/object:Gem::Version
84
- segments:
85
- - 0
86
- version: "0"
87
- required_rubygems_version: !ruby/object:Gem::Requirement
88
- requirements:
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
89
80
  - - ">="
90
- - !ruby/object:Gem::Version
91
- segments:
92
- - 0
93
- version: "0"
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
94
83
  requirements: []
95
-
96
84
  rubyforge_project: mt940
97
- rubygems_version: 1.3.6
85
+ rubygems_version: 2.2.0
98
86
  signing_key:
99
- specification_version: 3
87
+ specification_version: 4
100
88
  summary: MT940 parser
101
- test_files:
89
+ test_files:
102
90
  - test/fixtures/abnamro.txt
91
+ - test/fixtures/abnamro_sepa.txt
103
92
  - test/fixtures/ing.txt
93
+ - test/fixtures/ing_sepa.txt
104
94
  - test/fixtures/rabobank.txt
95
+ - test/fixtures/rabobank_sepa.txt
105
96
  - test/fixtures/triodos.txt
97
+ - test/fixtures/triodos_sepa.txt
106
98
  - test/fixtures/unknown.txt
107
99
  - test/helper.rb
108
100
  - test/mt940_abnamro_test.rb
@@ -110,3 +102,4 @@ test_files:
110
102
  - test/mt940_ing_test.rb
111
103
  - test/mt940_rabobank_test.rb
112
104
  - test/mt940_triodos_test.rb
105
+ has_rdoc: