mt940 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +17 -0
- data/LICENSE.txt +20 -0
- data/README.md +40 -0
- data/Rakefile +45 -0
- data/VERSION +1 -0
- data/lib/mt940/banks/abnamro.rb +23 -0
- data/lib/mt940/banks/ing.rb +23 -0
- data/lib/mt940/banks/rabobank.rb +19 -0
- data/lib/mt940/banks/triodos.rb +23 -0
- data/lib/mt940/base.rb +24 -0
- data/lib/mt940/transaction.rb +16 -0
- data/lib/mt940.rb +9 -0
- data/test/fixtures/abnamro.txt +41 -0
- data/test/fixtures/ing.txt +24 -0
- data/test/fixtures/rabobank.txt +24 -0
- data/test/fixtures/triodos.txt +14 -0
- data/test/helper.rb +18 -0
- data/test/test_mt940.rb +13 -0
- data/test/test_mt940_abnamro.rb +29 -0
- data/test/test_mt940_ing.rb +29 -0
- data/test/test_mt940_rabobank.rb +37 -0
- data/test/test_mt940_triodos.rb +29 -0
- metadata +125 -0
data/.document
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Frank Oxener - Agile Dovadi BV
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
MT940
|
2
|
+
======
|
3
|
+
|
4
|
+
Basis parser for MT940 files, see [MT940](http://nl.wikipedia.org/wiki/MT940)
|
5
|
+
|
6
|
+
The following Dutch banks are implemented:
|
7
|
+
|
8
|
+
* ABN Amro
|
9
|
+
* ING
|
10
|
+
* Rabobank
|
11
|
+
* Triodos
|
12
|
+
|
13
|
+
Usage
|
14
|
+
=====
|
15
|
+
|
16
|
+
* At this moment there is no automatic determination which bank needs to be parsed. So you need to choose the corresponding MT940 subclass for the specific bank you want to parse.
|
17
|
+
|
18
|
+
`file_name = File.dirname(__FILE__) + 'ing.940'`
|
19
|
+
`@transactions = MT940::ING.transactions(file_name)`
|
20
|
+
|
21
|
+
* Independent of the bank, a transaction always consists of an amount and a description.
|
22
|
+
* With some implementations the contra_account with its owner is extracted as well.
|
23
|
+
|
24
|
+
|
25
|
+
Contributing to MT940
|
26
|
+
=====================
|
27
|
+
|
28
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
29
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
30
|
+
* Fork the project
|
31
|
+
* Start a feature/bugfix branch
|
32
|
+
* Commit and push until you are happy with your contribution
|
33
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
34
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
35
|
+
|
36
|
+
Copyright
|
37
|
+
==========
|
38
|
+
|
39
|
+
Copyright (c) 2011 Frank Oxener - Agile Dovadi BV. See LICENSE.txt for further details.
|
40
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "mt940"
|
18
|
+
gem.homepage = "http://github.com/dovadi/mt940"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{MT940 parser}
|
21
|
+
gem.description = %Q{A basic MT940 parser with implementations for Dutch banks.}
|
22
|
+
gem.email = "frank.oxener@gmail.com"
|
23
|
+
gem.authors = ["dovadi"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
task :default => :test
|
36
|
+
|
37
|
+
require 'rake/rdoctask'
|
38
|
+
Rake::RDocTask.new do |rdoc|
|
39
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
40
|
+
|
41
|
+
rdoc.rdoc_dir = 'rdoc'
|
42
|
+
rdoc.title = "mt940 #{version}"
|
43
|
+
rdoc.rdoc_files.include('README*')
|
44
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
45
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class MT940::Abnamro < MT940::Base
|
2
|
+
|
3
|
+
def parse
|
4
|
+
tag86 = false
|
5
|
+
@lines.each do |line|
|
6
|
+
if line.match(/^:25:(\d*)/)
|
7
|
+
@bank_account = $1
|
8
|
+
tag86 = false
|
9
|
+
elsif line.match(/^:61:\d{6}\d{4}(C|D)(\d+),(\d{0,2})/) #:61:1105240524D9,N192NONREF
|
10
|
+
type = $1 == 'D' ? -1 : 1
|
11
|
+
@transaction = MT940::Transaction.new(:bank_account => @bank_account, :amount => type * ($2 + '.' + $3).to_f)
|
12
|
+
@transactions << @transaction
|
13
|
+
tag86 = false
|
14
|
+
elsif line.match(/^:86:(.*)$/)
|
15
|
+
@transaction.description = $1.strip
|
16
|
+
tag86 = true
|
17
|
+
elsif tag86 && line.match(/^[^:]/)
|
18
|
+
@transaction.description += ' ' + line.strip.gsub(/\n/,'')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class MT940::ING < MT940::Base
|
2
|
+
|
3
|
+
def parse
|
4
|
+
tag86 = false
|
5
|
+
@lines.each do |line|
|
6
|
+
if line.match(/^:25:(\d{10})/)
|
7
|
+
@bank_account = $1
|
8
|
+
tag86 = false
|
9
|
+
elsif line.match(/^:61:(\d{6})(C|D)(\d+),(\d{0,2})/)
|
10
|
+
type = $2 == 'D' ? -1 : 1
|
11
|
+
@transaction = MT940::Transaction.new(:bank_account => @bank_account, :amount => type * ($3 + '.' + $4).to_f)
|
12
|
+
@transactions << @transaction
|
13
|
+
tag86 = false
|
14
|
+
elsif line.match(/^:86:\s?(.*)$/)
|
15
|
+
tag86 = true
|
16
|
+
@transaction.description = $1
|
17
|
+
elsif tag86 && line.match(/^[^:]/)
|
18
|
+
@transaction.description += ' ' + line.strip.gsub(/\n/,'')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class MT940::Rabobank < MT940::Base
|
2
|
+
|
3
|
+
def parse
|
4
|
+
@lines.each do |line|
|
5
|
+
if line.match(/^:25:(\d{4}.\d{2}.\d{3})/)
|
6
|
+
@bank_account = $1
|
7
|
+
elsif line.match(/^:61:\d{6}(C|D)(\d+),(\d{0,2})\w{4}(.{16})(.+)$/)
|
8
|
+
type = $1 == 'D' ? -1 : 1
|
9
|
+
@transaction = MT940::Transaction.new(:bank_account => @bank_account, :amount => type * ($2 + '.' + $3).to_f)
|
10
|
+
@transaction.contra_account = $4.strip
|
11
|
+
@transaction.contra_account_name = $5.strip
|
12
|
+
@transactions << @transaction
|
13
|
+
elsif line.match(/^:86:(.*)$/)
|
14
|
+
@transaction.description = $1.strip
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class MT940::Triodos < MT940::Base
|
2
|
+
|
3
|
+
def parse
|
4
|
+
tag86 = false
|
5
|
+
@lines.each do |line|
|
6
|
+
if line.match(/^:25:TRIODOSBANK\/(\d*)$/)
|
7
|
+
@bank_account = $1
|
8
|
+
tag86 = false
|
9
|
+
elsif line.match(/^:61:\d{6}(C|D)(\d+),(\d{0,2})/) #:61:1105240524D9,N192NONREF
|
10
|
+
type = $1 == 'D' ? -1 : 1
|
11
|
+
@transaction = MT940::Transaction.new(:bank_account => @bank_account, :amount => type * ($2 + '.' + $3).to_f)
|
12
|
+
@transactions << @transaction
|
13
|
+
tag86 = false
|
14
|
+
elsif line.match(/^:86:(.*)$/)
|
15
|
+
@transaction.description = $1.strip.gsub(/>\d{2}/,'')
|
16
|
+
tag86 = true
|
17
|
+
elsif tag86 && line.match(/^[^:]/)
|
18
|
+
@transaction.description += line.strip.gsub(/\n/,'').gsub(/>\d{2}/,'')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/lib/mt940/base.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
module MT940
|
2
|
+
|
3
|
+
class Base
|
4
|
+
|
5
|
+
def self.transactions(file_name)
|
6
|
+
instance = self.new(file_name)
|
7
|
+
instance.parse
|
8
|
+
instance.instance_variable_get('@transactions')
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def initialize(file_name)
|
14
|
+
@transactions = []
|
15
|
+
@lines = File.readlines(file_name)
|
16
|
+
end
|
17
|
+
|
18
|
+
def parse
|
19
|
+
raise NoMethodError, 'Code must be implemented in subclass'
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module MT940
|
2
|
+
|
3
|
+
class Transaction
|
4
|
+
|
5
|
+
attr_accessor :bank_account, :contra_account, :amount, :description, :contra_account_name
|
6
|
+
|
7
|
+
def initialize(attributes = {})
|
8
|
+
@bank_account = attributes[:bank_account]
|
9
|
+
@amount = attributes[:amount]
|
10
|
+
@description = attributes[:description]
|
11
|
+
@contra_account_name = attributes[:contra_account_name]
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
data/lib/mt940.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
+
|
4
|
+
require 'mt940/base'
|
5
|
+
require 'mt940/transaction'
|
6
|
+
require 'mt940/banks/ing'
|
7
|
+
require 'mt940/banks/rabobank'
|
8
|
+
require 'mt940/banks/abnamro'
|
9
|
+
require 'mt940/banks/triodos'
|
@@ -0,0 +1,41 @@
|
|
1
|
+
ABNANL2A
|
2
|
+
940
|
3
|
+
ABNANL2A
|
4
|
+
:20:ABN AMRO BANK NV
|
5
|
+
:25:517852257
|
6
|
+
:28:19321/1
|
7
|
+
:60F:C110522EUR3236,28
|
8
|
+
:61:1105240524D9,N192NONREF
|
9
|
+
:86:GIRO 428428 KPN - DIGITENNE BETALINGSKENM. 000000042188659
|
10
|
+
5314606715 BETREFT FACTUUR D.D. 20-05-2011
|
11
|
+
INCL. 1,44 BTW
|
12
|
+
:61:1105210523D11,59N426NONREF
|
13
|
+
:86:BEA NR:XXX1234 21.05.11/12.54 DIRCKIII FIL2500 KATWIJK,PAS999
|
14
|
+
:61:1105230523D11,63N426NONREF
|
15
|
+
:86:BEA NR:XXX1234 23.05.11/09.08 DIGROS FIL1015 KATWIJK Z,PAS999
|
16
|
+
:61:1105220523D11,8N426NONREF
|
17
|
+
:86:BEA NR:XXX1234 22.05.11/14.25 MC DONALDS A44 LEIDEN,PAS999
|
18
|
+
:61:1105210523D13,45N426NONREF
|
19
|
+
:86:BEA NR:XXX1234 21.05.11/12.09 PRINCE FIL. 55 KATWIJK Z,PAS999
|
20
|
+
:61:1105210523D15,49N426NONREF
|
21
|
+
:86:BEA NR:XXX1234 21.05.11/12.55 DIRX FIL6017 KATWIJK ZH ,PAS999
|
22
|
+
|
23
|
+
:61:1105210523D107,N426NONREF
|
24
|
+
:86:BEA NR:XXX1234 21.05.11/12.04 HANS ANDERS OPT./056 KAT,PAS999
|
25
|
+
:61:1105220523D141,48N426NONREF
|
26
|
+
:86:BEA NR:XXX1234 22.05.11/13.45 MYCOM DEN HAAG S-GRAVEN,PAS999
|
27
|
+
:62F:C110523EUR876,84
|
28
|
+
-
|
29
|
+
ABNANL2A
|
30
|
+
940
|
31
|
+
ABNANL2A
|
32
|
+
:20:ABN AMRO BANK NV
|
33
|
+
:25:517852257
|
34
|
+
:28:19322/1
|
35
|
+
:60F:C110523EUR2876,84
|
36
|
+
:61:1105240524D9,49N426NONREF
|
37
|
+
:86:BEA NR:XXX1234 24.05.11/09.18 PETS PLACE KATWIJK KATWI,PAS999
|
38
|
+
:61:1105240524D15,N426NONREF
|
39
|
+
:86:BEA NR:XXX1234 24.05.11/09.17 BRAINWASH KATWIJK KATWIJ,PAS999
|
40
|
+
:62F:C110524EUR1849,75
|
41
|
+
-
|
@@ -0,0 +1,24 @@
|
|
1
|
+
0000 01INGBNL2AXXXX00001
|
2
|
+
0000 01INGBNL2AXXXX00001
|
3
|
+
940 00
|
4
|
+
:20:MPBZ
|
5
|
+
:25:0001234567
|
6
|
+
:28C:000
|
7
|
+
:60F:C100722EUR0,00
|
8
|
+
:61:100722D25,03NOV NONREF
|
9
|
+
:86: RC AFREKENING BETALINGSVERKEER
|
10
|
+
BETREFT REKENING 4715589 PERIODE: 01-10-2010 / 31-12-2010
|
11
|
+
ING Bank N.V. tarifering ING
|
12
|
+
:61:100722D3,03NOV NONREF
|
13
|
+
:86:0111111111 GPSEOUL SPOEDBETALING MPBZS1016000047 GPSEOUL
|
14
|
+
:61:100722D1,11NGT TMG TANGO
|
15
|
+
:86:0111111111 ING iDEAL KN: TMG TANGO TRANSACTIENR 0050000534527978 10062010 15:32 TMG TANGO ING Bank inzake GPKyoto
|
16
|
+
:61:100722D20,00NGM NONREF
|
17
|
+
:86: ABN AMRO BANK>AMSTERDAM 22072010 09:57 002 5595781
|
18
|
+
:61:100722D1,10NGT NONREF
|
19
|
+
:86:0111111111 GPPeking 170000001AC
|
20
|
+
:61:100722C3,68NVZ NONREF
|
21
|
+
:86:0111111111 EJ46GREENP100610T1456 CLIEOP TMG GPHONGKONG AMSTERDAM
|
22
|
+
:62F:C100723EUR3,47
|
23
|
+
:86:D000004C000002D25,24C28,71
|
24
|
+
-XXX
|
@@ -0,0 +1,24 @@
|
|
1
|
+
:940:
|
2
|
+
|
3
|
+
:20:940A110615
|
4
|
+
:25:1291.99.348EUR
|
5
|
+
:28:00000/00
|
6
|
+
:60F:C110614EUR000000000473,17
|
7
|
+
:61:110615D000000000077,35N071P005675159 Uitgeverij De Druif
|
8
|
+
:86:Factuurnummer 234578
|
9
|
+
:62F:C110615EUR000000000395,82
|
10
|
+
|
11
|
+
:20:940A110616
|
12
|
+
:25:1291.99.348EUR
|
13
|
+
:28:00000/00
|
14
|
+
:60F:C110615EUR0000000001000,89
|
15
|
+
:62F:C110616EUR0000000001000,89
|
16
|
+
|
17
|
+
:20:940A110617
|
18
|
+
:25:1291.99.348EUR
|
19
|
+
:28:00000/00
|
20
|
+
:60F:C110616EUR0000000001295,82
|
21
|
+
:61:110617D000000000044,95N0600733959555 T-MOBILE NETHERLANDS BV
|
22
|
+
:86:BETALINGSKENM. 123456789
|
23
|
+
:86:FACTUURNUMMER 987654321
|
24
|
+
:62F:C110617EUR0000000001250,87
|
@@ -0,0 +1,14 @@
|
|
1
|
+
:20:1308728725026/1
|
2
|
+
:25:TRIODOSBANK/0390123456
|
3
|
+
:28:1
|
4
|
+
:60F:C110101EUR4975,09
|
5
|
+
:61:110101D15,70N000NONREF
|
6
|
+
:86:000>100000000000
|
7
|
+
>20ALGEMENE TUSSENREKENING KOS>21TEN VAN 01-10-2010 TOT EN M
|
8
|
+
>22ET 31-12-2010>310390123456
|
9
|
+
:61:110125D700,00N000NONREF
|
10
|
+
:86:000>100133967858
|
11
|
+
>20 HUUR>21 KANTOOR - FEB 2010
|
12
|
+
:62F:C110201EUR4370,79
|
13
|
+
-
|
14
|
+
|
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'mt940'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|
data/test/test_mt940.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestMt940 < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@file_name = File.dirname(__FILE__) + '/fixtures/ing.txt'
|
7
|
+
end
|
8
|
+
|
9
|
+
should 'raise a NoMethodError if not implemented' do
|
10
|
+
assert_raise(NoMethodError) { MT940::Base.get_transactions(@file_name) }
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestMt940Abnamro < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
file_name = File.dirname(__FILE__) + '/fixtures/abnamro.txt'
|
7
|
+
@transactions = MT940::Abnamro.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
|
14
|
+
|
15
|
+
context 'Transaction' do
|
16
|
+
should 'have a bank_account' do
|
17
|
+
assert_equal '517852257', @transaction.bank_account
|
18
|
+
end
|
19
|
+
|
20
|
+
should 'have an amount' do
|
21
|
+
assert_equal -9.00, @transaction.amount
|
22
|
+
end
|
23
|
+
|
24
|
+
should 'have a description' do
|
25
|
+
assert_equal 'GIRO 428428 KPN - DIGITENNE BETALINGSKENM. 000000042188659 5314606715 BETREFT FACTUUR D.D. 20-05-2011 INCL. 1,44 BTW', @transaction.description
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestMt940Ing < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
file_name = File.dirname(__FILE__) + '/fixtures/ing.txt'
|
7
|
+
@transactions = MT940::ING.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 '0001234567', @transaction.bank_account
|
18
|
+
end
|
19
|
+
|
20
|
+
should 'have an amount' do
|
21
|
+
assert_equal -25.03, @transaction.amount
|
22
|
+
end
|
23
|
+
|
24
|
+
should 'have a description' do
|
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
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestMt940Rabobank < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
file_name = File.dirname(__FILE__) + '/fixtures/rabobank.txt'
|
7
|
+
@transactions = MT940::Rabobank.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
|
14
|
+
|
15
|
+
context 'Transaction' do
|
16
|
+
should 'have a bank_account' do
|
17
|
+
assert_equal '1291.99.348', @transaction.bank_account
|
18
|
+
end
|
19
|
+
|
20
|
+
should 'have a contra_account' do
|
21
|
+
assert_equal 'P005675159', @transaction.contra_account
|
22
|
+
end
|
23
|
+
|
24
|
+
should 'have an amount' do
|
25
|
+
assert_equal -77.35, @transaction.amount
|
26
|
+
end
|
27
|
+
|
28
|
+
should 'have a contra_account_name' do
|
29
|
+
assert_equal 'Uitgeverij De Druif', @transaction.contra_account_name
|
30
|
+
end
|
31
|
+
|
32
|
+
should 'have a description' do
|
33
|
+
assert_equal 'Factuurnummer 234578', @transaction.description
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestMt940Triodos < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
file_name = File.dirname(__FILE__) + '/fixtures/triodos.txt'
|
7
|
+
@transactions = MT940::Triodos.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
|
14
|
+
|
15
|
+
context 'Transaction' do
|
16
|
+
should 'have a bank_account' do
|
17
|
+
assert_equal '0390123456', @transaction.bank_account
|
18
|
+
end
|
19
|
+
|
20
|
+
should 'have an amount' do
|
21
|
+
assert_equal -15.7, @transaction.amount
|
22
|
+
end
|
23
|
+
|
24
|
+
should 'have a description' do
|
25
|
+
assert_equal '0000000000000ALGEMENE TUSSENREKENING KOSTEN VAN 01-10-2010 TOT EN MET 31-12-20100390123456', @transaction.description
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mt940
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- dovadi
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-06-23 00:00:00 +02:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
segments:
|
26
|
+
- 0
|
27
|
+
version: "0"
|
28
|
+
prerelease: false
|
29
|
+
type: :development
|
30
|
+
name: shoulda
|
31
|
+
version_requirements: *id001
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
segments:
|
38
|
+
- 1
|
39
|
+
- 0
|
40
|
+
- 0
|
41
|
+
version: 1.0.0
|
42
|
+
prerelease: false
|
43
|
+
type: :development
|
44
|
+
name: bundler
|
45
|
+
version_requirements: *id002
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ~>
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
segments:
|
52
|
+
- 1
|
53
|
+
- 6
|
54
|
+
- 2
|
55
|
+
version: 1.6.2
|
56
|
+
prerelease: false
|
57
|
+
type: :development
|
58
|
+
name: jeweler
|
59
|
+
version_requirements: *id003
|
60
|
+
description: A basic MT940 parser with implementations for Dutch banks.
|
61
|
+
email: frank.oxener@gmail.com
|
62
|
+
executables: []
|
63
|
+
|
64
|
+
extensions: []
|
65
|
+
|
66
|
+
extra_rdoc_files:
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
files:
|
70
|
+
- .document
|
71
|
+
- Gemfile
|
72
|
+
- Gemfile.lock
|
73
|
+
- LICENSE.txt
|
74
|
+
- README.md
|
75
|
+
- Rakefile
|
76
|
+
- VERSION
|
77
|
+
- lib/mt940.rb
|
78
|
+
- lib/mt940/banks/abnamro.rb
|
79
|
+
- lib/mt940/banks/ing.rb
|
80
|
+
- lib/mt940/banks/rabobank.rb
|
81
|
+
- lib/mt940/banks/triodos.rb
|
82
|
+
- lib/mt940/base.rb
|
83
|
+
- lib/mt940/transaction.rb
|
84
|
+
- test/fixtures/abnamro.txt
|
85
|
+
- test/fixtures/ing.txt
|
86
|
+
- test/fixtures/rabobank.txt
|
87
|
+
- test/fixtures/triodos.txt
|
88
|
+
- test/helper.rb
|
89
|
+
- test/test_mt940.rb
|
90
|
+
- test/test_mt940_abnamro.rb
|
91
|
+
- test/test_mt940_ing.rb
|
92
|
+
- test/test_mt940_rabobank.rb
|
93
|
+
- test/test_mt940_triodos.rb
|
94
|
+
has_rdoc: true
|
95
|
+
homepage: http://github.com/dovadi/mt940
|
96
|
+
licenses:
|
97
|
+
- MIT
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
|
101
|
+
require_paths:
|
102
|
+
- lib
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
segments:
|
108
|
+
- 0
|
109
|
+
version: "0"
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
segments:
|
115
|
+
- 0
|
116
|
+
version: "0"
|
117
|
+
requirements: []
|
118
|
+
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 1.3.6
|
121
|
+
signing_key:
|
122
|
+
specification_version: 3
|
123
|
+
summary: MT940 parser
|
124
|
+
test_files: []
|
125
|
+
|