mt940 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -0
- data/README.md +10 -4
- data/VERSION +1 -1
- data/lib/mt940/banks/abnamro.rb +4 -3
- data/lib/mt940/banks/rabobank.rb +6 -5
- data/lib/mt940/base.rb +5 -0
- data/lib/mt940/transaction.rb +4 -2
- data/mt940.gemspec +2 -2
- data/test/test_mt940_abnamro.rb +5 -0
- data/test/test_mt940_ing.rb +4 -0
- data/test/test_mt940_rabobank.rb +7 -2
- data/test/test_mt940_triodos.rb +5 -0
- metadata +3 -3
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -13,12 +13,18 @@ The following Dutch banks are implemented:
|
|
13
13
|
Usage
|
14
14
|
=====
|
15
15
|
|
16
|
-
|
16
|
+
file_name = File.dirname(__FILE__) + 'ing.940'
|
17
17
|
|
18
|
-
|
18
|
+
@transactions = MT940:::Base.transactions(file_name)
|
19
19
|
|
20
|
-
* Independent of the bank, a transaction always consists of
|
21
|
-
|
20
|
+
* Independent of the bank, a transaction always consists of:
|
21
|
+
|
22
|
+
- accountnumber
|
23
|
+
- date
|
24
|
+
- amount (which is negative in case of a withdrawal)
|
25
|
+
- description
|
26
|
+
|
27
|
+
* With the Rabobank the contra_account with its owner is extracted as well.
|
22
28
|
|
23
29
|
|
24
30
|
Contributing to MT940
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/lib/mt940/banks/abnamro.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
class MT940::Abnamro < MT940::Base
|
2
2
|
|
3
3
|
def parse_tag_61
|
4
|
-
if @line.match(/^:61
|
5
|
-
type = $
|
6
|
-
@transaction = MT940::Transaction.new(:bank_account => @bank_account, :amount => type * ($
|
4
|
+
if @line.match(/^:61:(\d{6})\d{4}(C|D)(\d+),(\d{0,2})/)
|
5
|
+
type = $2 == 'D' ? -1 : 1
|
6
|
+
@transaction = MT940::Transaction.new(:bank_account => @bank_account, :amount => type * ($3 + '.' + $4).to_f)
|
7
|
+
@transaction.date = parse_date($1)
|
7
8
|
@transactions << @transaction
|
8
9
|
@tag86 = false
|
9
10
|
end
|
data/lib/mt940/banks/rabobank.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
class MT940::Rabobank < MT940::Base
|
2
2
|
|
3
3
|
def parse_tag_61
|
4
|
-
if @line.match(/^:61
|
5
|
-
type = $
|
6
|
-
@transaction = MT940::Transaction.new(:bank_account => @bank_account, :amount => type * ($
|
7
|
-
@transaction.
|
8
|
-
@transaction.
|
4
|
+
if @line.match(/^:61:(\d{6})(C|D)(\d+),(\d{0,2})\w{4}(.{16})(.+)$/)
|
5
|
+
type = $2 == 'D' ? -1 : 1
|
6
|
+
@transaction = MT940::Transaction.new(:bank_account => @bank_account, :amount => type * ($3 + '.' + $4).to_f)
|
7
|
+
@transaction.date = parse_date($1)
|
8
|
+
@transaction.contra_account = $5.strip
|
9
|
+
@transaction.contra_account_owner = $6.strip
|
9
10
|
@transactions << @transaction
|
10
11
|
end
|
11
12
|
end
|
data/lib/mt940/base.rb
CHANGED
@@ -46,6 +46,7 @@ module MT940
|
|
46
46
|
if @line.match(/^:61:(\d{6})(C|D)(\d+),(\d{0,2})/)
|
47
47
|
type = $2 == 'D' ? -1 : 1
|
48
48
|
@transaction = MT940::Transaction.new(:bank_account => @bank_account, :amount => type * ($3 + '.' + $4).to_f)
|
49
|
+
@transaction.date = parse_date($1)
|
49
50
|
@transactions << @transaction
|
50
51
|
@tag86 = false
|
51
52
|
end
|
@@ -62,6 +63,10 @@ module MT940
|
|
62
63
|
@transaction.description += ' ' + @line.gsub(/\n/,'').gsub(/>\d{2}/,'') if @tag86
|
63
64
|
end
|
64
65
|
|
66
|
+
def parse_date(string)
|
67
|
+
Date.new(2000 + string[0..1].to_i, string[2..3].to_i, string[4..5].to_i) if string
|
68
|
+
end
|
69
|
+
|
65
70
|
#Fail silently
|
66
71
|
def method_missing(*args)
|
67
72
|
end
|
data/lib/mt940/transaction.rb
CHANGED
@@ -2,13 +2,15 @@ module MT940
|
|
2
2
|
|
3
3
|
class Transaction
|
4
4
|
|
5
|
-
attr_accessor :bank_account, :contra_account, :amount, :description, :
|
5
|
+
attr_accessor :bank_account, :contra_account, :amount, :description, :contra_account_owner, :date
|
6
6
|
|
7
7
|
def initialize(attributes = {})
|
8
8
|
@bank_account = attributes[:bank_account]
|
9
9
|
@amount = attributes[:amount]
|
10
10
|
@description = attributes[:description]
|
11
|
-
@
|
11
|
+
@date = attributes[:date]
|
12
|
+
@contra_account = attributes[:contra_account]
|
13
|
+
@contra_account_name = attributes[:contra_account_owner]
|
12
14
|
end
|
13
15
|
|
14
16
|
end
|
data/mt940.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{mt940}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["dovadi"]
|
12
|
-
s.date = %q{2011-06-
|
12
|
+
s.date = %q{2011-06-27}
|
13
13
|
s.description = %q{A basic MT940 parser with implementations for Dutch banks.}
|
14
14
|
s.email = %q{frank.oxener@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/test/test_mt940_abnamro.rb
CHANGED
@@ -24,6 +24,11 @@ class TestMt940Abnamro < Test::Unit::TestCase
|
|
24
24
|
should 'have a description' do
|
25
25
|
assert_equal 'GIRO 428428 KPN - DIGITENNE BETALINGSKENM. 000000042188659 5314606715 BETREFT FACTUUR D.D. 20-05-2011 INCL. 1,44 BTW', @transaction.description
|
26
26
|
end
|
27
|
+
|
28
|
+
should 'have a date' do
|
29
|
+
assert_equal Date.new(2011,5,24), @transaction.date
|
30
|
+
end
|
31
|
+
|
27
32
|
end
|
28
33
|
|
29
34
|
end
|
data/test/test_mt940_ing.rb
CHANGED
@@ -24,6 +24,10 @@ class TestMt940Ing < Test::Unit::TestCase
|
|
24
24
|
should 'have a description' do
|
25
25
|
assert_equal 'RC AFREKENING BETALINGSVERKEER BETREFT REKENING 4715589 PERIODE: 01-10-2010 / 31-12-2010 ING Bank N.V. tarifering ING', @transaction.description
|
26
26
|
end
|
27
|
+
|
28
|
+
should 'have a date' do
|
29
|
+
assert_equal Date.new(2010,7,22), @transaction.date
|
30
|
+
end
|
27
31
|
end
|
28
32
|
|
29
33
|
end
|
data/test/test_mt940_rabobank.rb
CHANGED
@@ -25,13 +25,18 @@ class TestMt940Rabobank < Test::Unit::TestCase
|
|
25
25
|
assert_equal -77.35, @transaction.amount
|
26
26
|
end
|
27
27
|
|
28
|
-
should 'have a
|
29
|
-
assert_equal 'Uitgeverij De Druif', @transaction.
|
28
|
+
should 'have a contra_account_owner' do
|
29
|
+
assert_equal 'Uitgeverij De Druif', @transaction.contra_account_owner
|
30
30
|
end
|
31
31
|
|
32
32
|
should 'have a description' do
|
33
33
|
assert_equal 'Factuurnummer 234578', @transaction.description
|
34
34
|
end
|
35
|
+
|
36
|
+
should 'have a date' do
|
37
|
+
assert_equal Date.new(2011,6,15), @transaction.date
|
38
|
+
end
|
39
|
+
|
35
40
|
end
|
36
41
|
|
37
42
|
end
|
data/test/test_mt940_triodos.rb
CHANGED
@@ -24,6 +24,11 @@ class TestMt940Triodos < Test::Unit::TestCase
|
|
24
24
|
should 'have a description' do
|
25
25
|
assert_equal '0000000000000 ALGEMENE TUSSENREKENING KOSTEN VAN 01-10-2010 TOT EN M ET 31-12-20100390123456', @transaction.description
|
26
26
|
end
|
27
|
+
|
28
|
+
should 'have a date' do
|
29
|
+
assert_equal Date.new(2011,1,1), @transaction.date
|
30
|
+
end
|
31
|
+
|
27
32
|
end
|
28
33
|
|
29
34
|
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 3
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.3.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- dovadi
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-06-
|
17
|
+
date: 2011-06-27 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|