mt940_parser 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +10 -0
- data/Gemfile +3 -9
- data/Rakefile +22 -52
- data/VERSION +1 -0
- data/lib/mt940/customer_statement_message.rb +4 -7
- data/lib/mt940/errors.rb +17 -0
- data/lib/mt940/version.rb +8 -0
- data/lib/mt940.rb +70 -61
- data/mt940_parser.gemspec +14 -60
- data/test/fixtures/amount_formats.txt +6 -0
- data/test/fixtures/amount_formats.yml +49 -0
- data/test/fixtures/sepa_mt9401.yml +35 -35
- data/test/helper.rb +6 -0
- data/test/test_customer_statement_message.rb +3 -1
- metadata +27 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f235b2d445bfb06eed8db5a7f82580d3a493c2d
|
4
|
+
data.tar.gz: 4020b7d563f4848e5444005a7368079f4b2b44fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7771e18e4e0005a5ce95b71d4c3a601b237c14b01ff9bd322894182472ef7a8f927e57e22e591381c55c4f338ae519173558d0bc8bb06f60982ca03ada135a6
|
7
|
+
data.tar.gz: 0a4e1efc1502b343c0170fdaf15f993ec6d367918de6e0e35363c8d0e3c6ebde94218b691c6c04fa94401f065215a8bff88ef3bb4912ed14390bea0281ff24e2
|
data/.gitignore
ADDED
data/Gemfile
CHANGED
@@ -1,13 +1,7 @@
|
|
1
|
-
source "
|
2
|
-
|
3
|
-
|
4
|
-
# gem "activesupport", ">= 2.3.5"
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
gemspec
|
5
4
|
|
6
|
-
# Add dependencies to develop your gem here.
|
7
|
-
# Include everything needed to run rake, tests, features, etc.
|
8
5
|
group :development do
|
9
|
-
gem "bundler"
|
10
|
-
gem "jeweler"
|
11
|
-
gem "test-unit"
|
12
6
|
gem "byebug", platform: :mri
|
13
7
|
end
|
data/Rakefile
CHANGED
@@ -1,58 +1,28 @@
|
|
1
|
-
|
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 'rake'
|
1
|
+
# vim: set filetype=ruby et sw=2 ts=2:
|
11
2
|
|
12
|
-
|
13
|
-
require 'jeweler'
|
14
|
-
Jeweler::Tasks.new do |gem|
|
15
|
-
gem.name = "mt940_parser"
|
16
|
-
gem.summary = %Q{MT940 parses account statements in the SWIFT MT940 format.}
|
17
|
-
gem.license = "MIT"
|
18
|
-
gem.email = "developers@betterplace.org"
|
19
|
-
gem.homepage = "http://github.com/betterplace/mt940_parser"
|
20
|
-
gem.authors = ["Thies C. Arntzen", "Phillip Oertel"]
|
21
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
22
|
-
end
|
23
|
-
Jeweler::GemcutterTasks.new
|
24
|
-
rescue LoadError
|
25
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
26
|
-
end
|
3
|
+
require 'gem_hadar'
|
27
4
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
5
|
+
GemHadar do
|
6
|
+
name 'mt940_parser'
|
7
|
+
module_type :class
|
8
|
+
path_name 'mt940'
|
9
|
+
path_module 'MT940'
|
10
|
+
author [ "Thies C. Arntzen", "Phillip Oertel" ]
|
11
|
+
email 'developers@betterplace.org'
|
12
|
+
homepage "http://github.com/betterplace/mt940_parser"
|
13
|
+
summary 'MT940 parses account statements in the SWIFT MT940 format.'
|
14
|
+
description 'Ruby library that parses account statements in the SWIFT MT940 format.'
|
15
|
+
test_dir 'test'
|
16
|
+
test_files Dir['test/**/test_*.rb']
|
17
|
+
spec_dir 'spec'
|
18
|
+
ignore '.*.sw[pon]', 'pkg', 'Gemfile.lock', '.rvmrc', 'coverage',
|
19
|
+
'.DS_Store', '.ruby-gemset', '.ruby-version', '.bundle', '.AppleDouble'
|
20
|
+
|
21
|
+
readme 'README.rdoc'
|
22
|
+
licenses 'MIT'
|
34
23
|
|
35
|
-
|
36
|
-
|
37
|
-
Rcov::RcovTask.new do |test|
|
38
|
-
test.libs << 'test'
|
39
|
-
test.pattern = 'test/**/test_*.rb'
|
40
|
-
test.verbose = true
|
41
|
-
end
|
42
|
-
rescue LoadError
|
43
|
-
task :rcov do
|
44
|
-
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
45
|
-
end
|
24
|
+
development_dependency 'test-unit'
|
25
|
+
development_dependency 'simplecov'
|
46
26
|
end
|
47
27
|
|
48
28
|
task :default => :test
|
49
|
-
|
50
|
-
require 'rdoc/task'
|
51
|
-
RDoc::Task.new do |rdoc|
|
52
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
53
|
-
|
54
|
-
rdoc.rdoc_dir = 'rdoc'
|
55
|
-
rdoc.title = "mt940 #{version}"
|
56
|
-
rdoc.rdoc_files.include('README*')
|
57
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
58
|
-
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.4.0
|
@@ -2,7 +2,6 @@
|
|
2
2
|
# MT940.parse command. use it in order to make dealing with
|
3
3
|
# the data easier
|
4
4
|
class MT940
|
5
|
-
|
6
5
|
class CustomerStatementMessage
|
7
6
|
|
8
7
|
attr_reader :statement_lines
|
@@ -37,15 +36,15 @@ class MT940
|
|
37
36
|
private
|
38
37
|
|
39
38
|
def ensure_is_info_line!(line)
|
40
|
-
unless line.is_a?
|
41
|
-
raise
|
39
|
+
unless line.is_a? MT940::StatementLineInformation
|
40
|
+
raise MT940::UnexpectedStructureError,
|
41
|
+
"Unexpected Structure; expected StatementLineInformation, "\
|
42
|
+
"but was #{line.class}"
|
42
43
|
end
|
43
44
|
end
|
44
|
-
|
45
45
|
end
|
46
46
|
|
47
47
|
class StatementLineBundle
|
48
|
-
|
49
48
|
METHOD_MAP = {
|
50
49
|
:amount => :line,
|
51
50
|
:funds_code => :line,
|
@@ -68,7 +67,5 @@ class MT940
|
|
68
67
|
object = instance_variable_get("@#{METHOD_MAP[method.to_sym]}")
|
69
68
|
object.send(method)
|
70
69
|
end
|
71
|
-
|
72
70
|
end
|
73
|
-
|
74
71
|
end
|
data/lib/mt940/errors.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
class MT940
|
2
|
+
module Errors
|
3
|
+
class MT940Error < StandardError; end
|
4
|
+
|
5
|
+
class FieldNotImplementedError < MT940Error; end
|
6
|
+
|
7
|
+
class ParseError < MT940Error; end
|
8
|
+
|
9
|
+
class WrongLineFormatError < ParseError; end
|
10
|
+
|
11
|
+
class InvalidAmountFormatError < ParseError; end
|
12
|
+
|
13
|
+
class UnexpectedStructureError < ParseError; end
|
14
|
+
end
|
15
|
+
|
16
|
+
include Errors
|
17
|
+
end
|
data/lib/mt940.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
|
+
require 'mt940/version'
|
2
|
+
require 'mt940/errors'
|
1
3
|
require 'mt940/customer_statement_message'
|
4
|
+
require 'bigdecimal'
|
2
5
|
|
3
6
|
class MT940
|
4
7
|
class Field
|
5
8
|
attr_reader :modifier, :content
|
6
9
|
|
7
|
-
DATE
|
10
|
+
DATE = /(\d{2})(\d{2})(\d{2})/
|
8
11
|
SHORT_DATE = /(\d{2})(\d{2})/
|
9
12
|
|
10
13
|
class << self
|
@@ -23,42 +26,44 @@ class MT940
|
|
23
26
|
'64' => ValutaBalance,
|
24
27
|
'65' => FutureValutaBalance,
|
25
28
|
'86' => StatementLineInformation
|
26
|
-
}
|
27
|
-
|
28
|
-
|
29
|
+
}.fetch(number) do
|
30
|
+
raise FieldNotImplementedError, "Field #{number} is not implemented"
|
31
|
+
end
|
29
32
|
|
30
33
|
klass.new(modifier, content)
|
31
34
|
else
|
32
|
-
raise
|
35
|
+
raise WrongLineFormatError, "Wrong line format: #{line.dump}"
|
33
36
|
end
|
34
37
|
end
|
35
38
|
end
|
36
39
|
|
37
40
|
def initialize(modifier, content)
|
38
41
|
@modifier = modifier
|
39
|
-
@content
|
42
|
+
@content = content
|
40
43
|
parse_content(content)
|
41
44
|
end
|
42
45
|
|
43
46
|
private
|
44
|
-
def parse_amount_in_cents(amount)
|
45
|
-
# don't use Integer(amount) function, because amount can be "008" - interpreted as octal number ("010" = 8)
|
46
|
-
amount.gsub(',', '').to_i
|
47
|
-
end
|
48
47
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
48
|
+
def parse_amount_in_cents(amount)
|
49
|
+
amount =~ /\A(\d+)(,\d*)?\z/ or
|
50
|
+
raise InvalidAmountFormatError, "invalid amount #{amount.inspect}"
|
51
|
+
(100 * BigDecimal.new(amount.sub(?,, ?.))).floor
|
52
|
+
end
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
54
|
+
def parse_date(date)
|
55
|
+
date.match(DATE)
|
56
|
+
Date.new("20#{$1}".to_i, $2.to_i, $3.to_i)
|
57
|
+
end
|
58
|
+
|
59
|
+
def parse_entry_date(raw_entry_date, value_date)
|
60
|
+
raw_entry_date.match(SHORT_DATE)
|
61
|
+
entry_date = Date.new(value_date.year, $1.to_i, $2.to_i)
|
62
|
+
unless entry_date.year == value_date.year
|
63
|
+
raise "Unhandled case: value date and entry date are in different years"
|
61
64
|
end
|
65
|
+
entry_date
|
66
|
+
end
|
62
67
|
end
|
63
68
|
|
64
69
|
# 20
|
@@ -111,30 +116,33 @@ class MT940
|
|
111
116
|
def parse_content(content)
|
112
117
|
content.match(CONTENT)
|
113
118
|
|
114
|
-
@balance_type =
|
119
|
+
@balance_type =
|
120
|
+
case @modifier
|
115
121
|
when 'F'
|
116
122
|
:start
|
117
123
|
when 'M'
|
118
124
|
:intermediate
|
119
|
-
|
125
|
+
end
|
120
126
|
|
121
|
-
@sign =
|
127
|
+
@sign =
|
128
|
+
case $1
|
122
129
|
when 'C'
|
123
130
|
:credit
|
124
131
|
when 'D'
|
125
132
|
:debit
|
126
|
-
|
133
|
+
end
|
127
134
|
|
128
|
-
raw_date
|
135
|
+
raw_date = $2
|
129
136
|
@currency = $3
|
130
|
-
@amount
|
137
|
+
@amount = parse_amount_in_cents($4)
|
131
138
|
|
132
|
-
@date =
|
139
|
+
@date =
|
140
|
+
case raw_date
|
133
141
|
when 'ALT', '0'
|
134
142
|
nil
|
135
143
|
when DATE
|
136
144
|
Date.new("20#{$1}".to_i, $2.to_i, $3.to_i)
|
137
|
-
|
145
|
+
end
|
138
146
|
end
|
139
147
|
end
|
140
148
|
|
@@ -147,9 +155,10 @@ class MT940
|
|
147
155
|
def parse_content(content)
|
148
156
|
content.match(CONTENT)
|
149
157
|
|
150
|
-
raw_date
|
158
|
+
raw_date = $1
|
151
159
|
raw_entry_date = $2
|
152
|
-
@funds_code =
|
160
|
+
@funds_code =
|
161
|
+
case $3
|
153
162
|
when 'C'
|
154
163
|
:credit
|
155
164
|
when 'D'
|
@@ -158,7 +167,7 @@ class MT940
|
|
158
167
|
:return_credit
|
159
168
|
when 'RD'
|
160
169
|
:return_debit
|
161
|
-
|
170
|
+
end
|
162
171
|
|
163
172
|
@amount = parse_amount_in_cents($4)
|
164
173
|
@swift_code = $5
|
@@ -195,34 +204,36 @@ class MT940
|
|
195
204
|
content.match(/^(\d{3})((.).*)$/)
|
196
205
|
@code = $1.to_i
|
197
206
|
|
198
|
-
details
|
207
|
+
details = []
|
199
208
|
account_holder = []
|
200
209
|
|
201
210
|
if seperator = $3
|
202
|
-
sub_fields = $2.scan(
|
203
|
-
|
211
|
+
sub_fields = $2.scan(
|
212
|
+
/#{Regexp.escape(seperator)}(\d{2})([^#{Regexp.escape(seperator)}]*)/
|
213
|
+
)
|
204
214
|
|
205
215
|
sub_fields.each do |(code, content)|
|
206
216
|
case code.to_i
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
217
|
+
when 0
|
218
|
+
@transaction_description = content
|
219
|
+
when 10
|
220
|
+
@prima_nota = content
|
221
|
+
when 20..29, 60..63
|
222
|
+
details << content
|
223
|
+
when 30
|
224
|
+
@bank_code = content
|
225
|
+
when 31
|
226
|
+
@account_number = content
|
227
|
+
when 32..33
|
228
|
+
account_holder << content
|
229
|
+
when 34
|
230
|
+
@text_key_extension = content
|
221
231
|
else
|
222
232
|
@not_implemented_fields ||= []
|
223
|
-
@not_implemented_fields << [code, content]
|
224
|
-
|
225
|
-
|
233
|
+
@not_implemented_fields << [ code, content ]
|
234
|
+
if $DEBUG
|
235
|
+
warn "code not implemented: code:#{code} content: #{content.inspect}"
|
236
|
+
end
|
226
237
|
end
|
227
238
|
end
|
228
239
|
end
|
@@ -232,22 +243,20 @@ class MT940
|
|
232
243
|
end
|
233
244
|
end
|
234
245
|
|
235
|
-
|
236
246
|
class << self
|
237
247
|
def parse(text)
|
238
|
-
|
239
|
-
new_text = text.encode('utf-8').strip
|
248
|
+
new_text = text.encode('UTF-8').strip
|
240
249
|
new_text << "\r\n" if new_text[-1,1] == '-'
|
241
250
|
raw_sheets = new_text.split(/^-\s*\r\n/).map { |sheet| sheet.gsub(/\r\n(?!:)/, '') }
|
242
251
|
sheets = raw_sheets.map { |raw_sheet| parse_sheet(raw_sheet) }
|
243
252
|
end
|
244
253
|
|
245
|
-
|
246
254
|
private
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
255
|
+
|
256
|
+
def parse_sheet(sheet)
|
257
|
+
lines = sheet.split("\r\n")
|
258
|
+
fields = lines.reject { |line| line.empty? }.map { |line| Field.for(line) }
|
259
|
+
fields
|
260
|
+
end
|
252
261
|
end
|
253
262
|
end
|
data/mt940_parser.gemspec
CHANGED
@@ -1,86 +1,40 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
1
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: mt940_parser 1.
|
2
|
+
# stub: mt940_parser 1.4.0 ruby lib
|
6
3
|
|
7
4
|
Gem::Specification.new do |s|
|
8
5
|
s.name = "mt940_parser"
|
9
|
-
s.version = "1.
|
6
|
+
s.version = "1.4.0"
|
10
7
|
|
11
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
9
|
s.require_paths = ["lib"]
|
13
10
|
s.authors = ["Thies C. Arntzen", "Phillip Oertel"]
|
14
|
-
s.date = "2015-
|
11
|
+
s.date = "2015-05-11"
|
12
|
+
s.description = "Ruby library that parses account statements in the SWIFT MT940 format."
|
15
13
|
s.email = "developers@betterplace.org"
|
16
|
-
s.extra_rdoc_files = [
|
17
|
-
|
18
|
-
"README.rdoc"
|
19
|
-
]
|
20
|
-
s.files = [
|
21
|
-
".document",
|
22
|
-
".specification",
|
23
|
-
".travis.yml",
|
24
|
-
"Gemfile",
|
25
|
-
"LICENSE",
|
26
|
-
"README.rdoc",
|
27
|
-
"Rakefile",
|
28
|
-
"VERSION.yml",
|
29
|
-
"docs/0E0Y00DNY.pdf",
|
30
|
-
"docs/FinTS_4.0_Formals.pdf",
|
31
|
-
"docs/FinTS_4.0_Messages_Finanzdatenformate.pdf",
|
32
|
-
"docs/MT940_Deutschland_Structure2002.pdf",
|
33
|
-
"docs/SEPA_20MT940__Schnittstellenbeschreibung.pdf",
|
34
|
-
"docs/mt940.pdf",
|
35
|
-
"docs/swift_mt940_942.pdf",
|
36
|
-
"docs/uebersicht_der_geschaeftsvorfallcodes_und_buchungs_textschluessel.pdf",
|
37
|
-
"lib/mt940.rb",
|
38
|
-
"lib/mt940/customer_statement_message.rb",
|
39
|
-
"mt940_parser.gemspec",
|
40
|
-
"test/fixtures/currency_in_25.txt",
|
41
|
-
"test/fixtures/currency_in_25.yml",
|
42
|
-
"test/fixtures/empty_86.txt",
|
43
|
-
"test/fixtures/empty_86.yml",
|
44
|
-
"test/fixtures/empty_entry_date.txt",
|
45
|
-
"test/fixtures/empty_entry_date.yml",
|
46
|
-
"test/fixtures/empty_line.txt",
|
47
|
-
"test/fixtures/empty_line.yml",
|
48
|
-
"test/fixtures/missing_crlf_at_end.txt",
|
49
|
-
"test/fixtures/missing_crlf_at_end.yml",
|
50
|
-
"test/fixtures/sepa_mt9401.txt",
|
51
|
-
"test/fixtures/sepa_mt9401.yml",
|
52
|
-
"test/fixtures/sepa_snippet.txt",
|
53
|
-
"test/fixtures/sepa_snippet_broken.txt",
|
54
|
-
"test/fixtures/with_binary_character.txt",
|
55
|
-
"test/fixtures/with_binary_character.yml",
|
56
|
-
"test/helper.rb",
|
57
|
-
"test/test_customer_statement_message.rb",
|
58
|
-
"test/test_mt940.rb"
|
59
|
-
]
|
14
|
+
s.extra_rdoc_files = ["README.rdoc", "lib/mt940.rb", "lib/mt940/customer_statement_message.rb", "lib/mt940/errors.rb", "lib/mt940/version.rb"]
|
15
|
+
s.files = [".document", ".gitignore", ".specification", ".travis.yml", "Gemfile", "LICENSE", "README.rdoc", "Rakefile", "VERSION", "VERSION.yml", "docs/0E0Y00DNY.pdf", "docs/FinTS_4.0_Formals.pdf", "docs/FinTS_4.0_Messages_Finanzdatenformate.pdf", "docs/MT940_Deutschland_Structure2002.pdf", "docs/SEPA_20MT940__Schnittstellenbeschreibung.pdf", "docs/mt940.pdf", "docs/swift_mt940_942.pdf", "docs/uebersicht_der_geschaeftsvorfallcodes_und_buchungs_textschluessel.pdf", "lib/mt940.rb", "lib/mt940/customer_statement_message.rb", "lib/mt940/errors.rb", "lib/mt940/version.rb", "mt940_parser.gemspec", "test/fixtures/amount_formats.txt", "test/fixtures/amount_formats.yml", "test/fixtures/currency_in_25.txt", "test/fixtures/currency_in_25.yml", "test/fixtures/empty_86.txt", "test/fixtures/empty_86.yml", "test/fixtures/empty_entry_date.txt", "test/fixtures/empty_entry_date.yml", "test/fixtures/empty_line.txt", "test/fixtures/empty_line.yml", "test/fixtures/missing_crlf_at_end.txt", "test/fixtures/missing_crlf_at_end.yml", "test/fixtures/sepa_mt9401.txt", "test/fixtures/sepa_mt9401.yml", "test/fixtures/sepa_snippet.txt", "test/fixtures/sepa_snippet_broken.txt", "test/fixtures/with_binary_character.txt", "test/fixtures/with_binary_character.yml", "test/helper.rb", "test/test_customer_statement_message.rb", "test/test_mt940.rb"]
|
60
16
|
s.homepage = "http://github.com/betterplace/mt940_parser"
|
61
17
|
s.licenses = ["MIT"]
|
18
|
+
s.rdoc_options = ["--title", "Mt940Parser - MT940 parses account statements in the SWIFT MT940 format.", "--main", "README.rdoc"]
|
62
19
|
s.rubygems_version = "2.4.6"
|
63
20
|
s.summary = "MT940 parses account statements in the SWIFT MT940 format."
|
21
|
+
s.test_files = ["test/test_customer_statement_message.rb", "test/test_mt940.rb"]
|
64
22
|
|
65
23
|
if s.respond_to? :specification_version then
|
66
24
|
s.specification_version = 4
|
67
25
|
|
68
26
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
69
|
-
s.add_development_dependency(%q<
|
70
|
-
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
27
|
+
s.add_development_dependency(%q<gem_hadar>, ["~> 1.2.1"])
|
71
28
|
s.add_development_dependency(%q<test-unit>, [">= 0"])
|
72
|
-
s.add_development_dependency(%q<
|
29
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
73
30
|
else
|
74
|
-
s.add_dependency(%q<
|
75
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
31
|
+
s.add_dependency(%q<gem_hadar>, ["~> 1.2.1"])
|
76
32
|
s.add_dependency(%q<test-unit>, [">= 0"])
|
77
|
-
s.add_dependency(%q<
|
33
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
78
34
|
end
|
79
35
|
else
|
80
|
-
s.add_dependency(%q<
|
81
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
36
|
+
s.add_dependency(%q<gem_hadar>, ["~> 1.2.1"])
|
82
37
|
s.add_dependency(%q<test-unit>, [">= 0"])
|
83
|
-
s.add_dependency(%q<
|
38
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
84
39
|
end
|
85
40
|
end
|
86
|
-
|
@@ -0,0 +1,49 @@
|
|
1
|
+
---
|
2
|
+
- - !ruby/object:MT940::AccountBalance
|
3
|
+
modifier: F
|
4
|
+
content: C100318EUR380115,12
|
5
|
+
balance_type: :start
|
6
|
+
sign: :credit
|
7
|
+
currency: EUR
|
8
|
+
amount: 38011512
|
9
|
+
date: 2010-03-18
|
10
|
+
- !ruby/object:MT940::AccountBalance
|
11
|
+
modifier: F
|
12
|
+
content: C100318EUR380115,1
|
13
|
+
balance_type: :start
|
14
|
+
sign: :credit
|
15
|
+
currency: EUR
|
16
|
+
amount: 38011510
|
17
|
+
date: 2010-03-18
|
18
|
+
- !ruby/object:MT940::AccountBalance
|
19
|
+
modifier: F
|
20
|
+
content: C100318EUR380115,
|
21
|
+
balance_type: :start
|
22
|
+
sign: :credit
|
23
|
+
currency: EUR
|
24
|
+
amount: 38011500
|
25
|
+
date: 2010-03-18
|
26
|
+
- !ruby/object:MT940::AccountBalance
|
27
|
+
modifier: F
|
28
|
+
content: C100318EUR0,12
|
29
|
+
balance_type: :start
|
30
|
+
sign: :credit
|
31
|
+
currency: EUR
|
32
|
+
amount: 12
|
33
|
+
date: 2010-03-18
|
34
|
+
- !ruby/object:MT940::AccountBalance
|
35
|
+
modifier: F
|
36
|
+
content: C100318EUR00,12
|
37
|
+
balance_type: :start
|
38
|
+
sign: :credit
|
39
|
+
currency: EUR
|
40
|
+
amount: 12
|
41
|
+
date: 2010-03-18
|
42
|
+
- !ruby/object:MT940::AccountBalance
|
43
|
+
modifier: F
|
44
|
+
content: C100318EUR001,12
|
45
|
+
balance_type: :start
|
46
|
+
sign: :credit
|
47
|
+
currency: EUR
|
48
|
+
amount: 112
|
49
|
+
date: 2010-03-18
|
@@ -26,7 +26,7 @@
|
|
26
26
|
modifier:
|
27
27
|
content: 0709040904CR300,NTRFTFNr 40005 MSGID//0724710345313905
|
28
28
|
funds_code: :credit
|
29
|
-
amount:
|
29
|
+
amount: 30000
|
30
30
|
swift_code: NTRF
|
31
31
|
reference: TFNr 40005 MSGID
|
32
32
|
transaction_description: 0724710345313905
|
@@ -74,7 +74,7 @@
|
|
74
74
|
modifier:
|
75
75
|
content: 0709040904CR15000,NTRFTFNr 40005 MSGID//0724710345313900
|
76
76
|
funds_code: :credit
|
77
|
-
amount:
|
77
|
+
amount: 1500000
|
78
78
|
swift_code: NTRF
|
79
79
|
reference: TFNr 40005 MSGID
|
80
80
|
transaction_description: 0724710345313900
|
@@ -209,7 +209,7 @@
|
|
209
209
|
balance_type: :start
|
210
210
|
sign: :debit
|
211
211
|
currency: EUR
|
212
|
-
amount:
|
212
|
+
amount: 97049990
|
213
213
|
date: 2007-09-03
|
214
214
|
- !ruby/object:MT940::StatementLine
|
215
215
|
modifier:
|
@@ -257,7 +257,7 @@
|
|
257
257
|
modifier:
|
258
258
|
content: 0709040904DR500250,NTRFKREF+//BD7CFA74485E7E69
|
259
259
|
funds_code: :debit
|
260
|
-
amount:
|
260
|
+
amount: 50025000
|
261
261
|
swift_code: NTRF
|
262
262
|
reference: KREF+
|
263
263
|
transaction_description: BD7CFA74485E7E69
|
@@ -500,7 +500,7 @@
|
|
500
500
|
modifier:
|
501
501
|
content: 0709040904CR250000,NTRFNONREF//0724710290628244
|
502
502
|
funds_code: :credit
|
503
|
-
amount:
|
503
|
+
amount: 25000000
|
504
504
|
swift_code: NTRF
|
505
505
|
reference: NONREF
|
506
506
|
transaction_description: 0724710290628244
|
@@ -531,7 +531,7 @@
|
|
531
531
|
modifier:
|
532
532
|
content: 0709040904CR300000,NTRFNONREF//0724710290631813
|
533
533
|
funds_code: :credit
|
534
|
-
amount:
|
534
|
+
amount: 30000000
|
535
535
|
swift_code: NTRF
|
536
536
|
reference: NONREF
|
537
537
|
transaction_description: 0724710290631813
|
@@ -560,7 +560,7 @@
|
|
560
560
|
modifier:
|
561
561
|
content: 0709040904CR500000,NTRFNONREF//0724710290630146
|
562
562
|
funds_code: :credit
|
563
|
-
amount:
|
563
|
+
amount: 50000000
|
564
564
|
swift_code: NTRF
|
565
565
|
reference: NONREF
|
566
566
|
transaction_description: 0724710290630146
|
@@ -713,7 +713,7 @@
|
|
713
713
|
modifier:
|
714
714
|
content: 0709040904DR500250,NTRFTFNr 01006 PayId//E87048E11B394C1E
|
715
715
|
funds_code: :debit
|
716
|
-
amount:
|
716
|
+
amount: 50025000
|
717
717
|
swift_code: NTRF
|
718
718
|
reference: TFNr 01006 PayId
|
719
719
|
transaction_description: E87048E11B394C1E
|
@@ -804,7 +804,7 @@
|
|
804
804
|
balance_type: :start
|
805
805
|
sign: :credit
|
806
806
|
currency: EUR
|
807
|
-
amount:
|
807
|
+
amount: 20396020
|
808
808
|
date: 2007-09-04
|
809
809
|
- !ruby/object:MT940::ValutaBalance
|
810
810
|
modifier:
|
@@ -812,7 +812,7 @@
|
|
812
812
|
balance_type:
|
813
813
|
sign: :credit
|
814
814
|
currency: EUR
|
815
|
-
amount:
|
815
|
+
amount: 20396020
|
816
816
|
date: 2007-09-04
|
817
817
|
- - !ruby/object:MT940::Job
|
818
818
|
modifier:
|
@@ -835,7 +835,7 @@
|
|
835
835
|
balance_type: :start
|
836
836
|
sign: :debit
|
837
837
|
currency: EUR
|
838
|
-
amount:
|
838
|
+
amount: 4043220
|
839
839
|
date: 2007-09-03
|
840
840
|
- !ruby/object:MT940::StatementLine
|
841
841
|
modifier:
|
@@ -1181,7 +1181,7 @@
|
|
1181
1181
|
modifier:
|
1182
1182
|
content: 0709040904CR50,NTRFTFNr 40016 MSGID//0724710324649377
|
1183
1183
|
funds_code: :credit
|
1184
|
-
amount:
|
1184
|
+
amount: 5000
|
1185
1185
|
swift_code: NTRF
|
1186
1186
|
reference: TFNr 40016 MSGID
|
1187
1187
|
transaction_description: 0724710324649377
|
@@ -1307,7 +1307,7 @@
|
|
1307
1307
|
modifier:
|
1308
1308
|
content: 0709040904DR2550,NTRFKREF+//31408CF87AD5901E
|
1309
1309
|
funds_code: :debit
|
1310
|
-
amount:
|
1310
|
+
amount: 255000
|
1311
1311
|
swift_code: NTRF
|
1312
1312
|
reference: KREF+
|
1313
1313
|
transaction_description: 31408CF87AD5901E
|
@@ -1428,7 +1428,7 @@
|
|
1428
1428
|
modifier:
|
1429
1429
|
content: 0709040904DR402104,NTRFNONREF//57B4197CC644DE8F
|
1430
1430
|
funds_code: :debit
|
1431
|
-
amount:
|
1431
|
+
amount: 40210400
|
1432
1432
|
swift_code: NTRF
|
1433
1433
|
reference: NONREF
|
1434
1434
|
transaction_description: 57B4197CC644DE8F
|
@@ -2091,7 +2091,7 @@
|
|
2091
2091
|
modifier:
|
2092
2092
|
content: 0709040904DR342104,NTRFKREF+//A26B6D6B5E821EA9
|
2093
2093
|
funds_code: :debit
|
2094
|
-
amount:
|
2094
|
+
amount: 34210400
|
2095
2095
|
swift_code: NTRF
|
2096
2096
|
reference: KREF+
|
2097
2097
|
transaction_description: A26B6D6B5E821EA9
|
@@ -2111,7 +2111,7 @@
|
|
2111
2111
|
modifier:
|
2112
2112
|
content: 0709040904DR962104,NTRFKREF+//493189D221858097
|
2113
2113
|
funds_code: :debit
|
2114
|
-
amount:
|
2114
|
+
amount: 96210400
|
2115
2115
|
swift_code: NTRF
|
2116
2116
|
reference: KREF+
|
2117
2117
|
transaction_description: 493189D221858097
|
@@ -2135,7 +2135,7 @@
|
|
2135
2135
|
modifier:
|
2136
2136
|
content: 0709040904DR1522104,NTRFNONREF//75C62EC25E19D187
|
2137
2137
|
funds_code: :debit
|
2138
|
-
amount:
|
2138
|
+
amount: 152210400
|
2139
2139
|
swift_code: NTRF
|
2140
2140
|
reference: NONREF
|
2141
2141
|
transaction_description: 75C62EC25E19D187
|
@@ -2231,7 +2231,7 @@
|
|
2231
2231
|
balance_type: :start
|
2232
2232
|
sign: :credit
|
2233
2233
|
currency: EUR
|
2234
|
-
amount:
|
2234
|
+
amount: 2798010
|
2235
2235
|
date: 2007-09-04
|
2236
2236
|
- !ruby/object:MT940::ValutaBalance
|
2237
2237
|
modifier:
|
@@ -2239,7 +2239,7 @@
|
|
2239
2239
|
balance_type:
|
2240
2240
|
sign: :credit
|
2241
2241
|
currency: EUR
|
2242
|
-
amount:
|
2242
|
+
amount: 2798010
|
2243
2243
|
date: 2007-09-04
|
2244
2244
|
- - !ruby/object:MT940::Job
|
2245
2245
|
modifier:
|
@@ -2617,7 +2617,7 @@
|
|
2617
2617
|
modifier:
|
2618
2618
|
content: 0709040904DR342104,NTRFKREF+//D4AF9E363A92E76F
|
2619
2619
|
funds_code: :debit
|
2620
|
-
amount:
|
2620
|
+
amount: 34210400
|
2621
2621
|
swift_code: NTRF
|
2622
2622
|
reference: KREF+
|
2623
2623
|
transaction_description: D4AF9E363A92E76F
|
@@ -2749,7 +2749,7 @@
|
|
2749
2749
|
balance_type: :start
|
2750
2750
|
sign: :credit
|
2751
2751
|
currency: EUR
|
2752
|
-
amount:
|
2752
|
+
amount: 20396020
|
2753
2753
|
date: 2007-09-04
|
2754
2754
|
- !ruby/object:MT940::ValutaBalance
|
2755
2755
|
modifier:
|
@@ -2757,7 +2757,7 @@
|
|
2757
2757
|
balance_type:
|
2758
2758
|
sign: :credit
|
2759
2759
|
currency: EUR
|
2760
|
-
amount:
|
2760
|
+
amount: 20396020
|
2761
2761
|
date: 2007-09-04
|
2762
2762
|
- - !ruby/object:MT940::Job
|
2763
2763
|
modifier:
|
@@ -3003,7 +3003,7 @@
|
|
3003
3003
|
modifier:
|
3004
3004
|
content: 0709040904DR1500,NTRFKREF+//536D80EFEC56ACF8
|
3005
3005
|
funds_code: :debit
|
3006
|
-
amount:
|
3006
|
+
amount: 150000
|
3007
3007
|
swift_code: NTRF
|
3008
3008
|
reference: KREF+
|
3009
3009
|
transaction_description: 536D80EFEC56ACF8
|
@@ -3029,7 +3029,7 @@
|
|
3029
3029
|
balance_type: :start
|
3030
3030
|
sign: :credit
|
3031
3031
|
currency: EUR
|
3032
|
-
amount:
|
3032
|
+
amount: 112525040
|
3033
3033
|
date: 2007-09-04
|
3034
3034
|
- !ruby/object:MT940::ValutaBalance
|
3035
3035
|
modifier:
|
@@ -3066,7 +3066,7 @@
|
|
3066
3066
|
modifier:
|
3067
3067
|
content: 0709040904CR300,NTRFTFNr 40001 MSGID//0724710345316116
|
3068
3068
|
funds_code: :credit
|
3069
|
-
amount:
|
3069
|
+
amount: 30000
|
3070
3070
|
swift_code: NTRF
|
3071
3071
|
reference: TFNr 40001 MSGID
|
3072
3072
|
transaction_description: '0724710345316116'
|
@@ -3114,7 +3114,7 @@
|
|
3114
3114
|
modifier:
|
3115
3115
|
content: 0709040904CR15000,NTRFTFNr 40001 MSGID//0724710345316110
|
3116
3116
|
funds_code: :credit
|
3117
|
-
amount:
|
3117
|
+
amount: 1500000
|
3118
3118
|
swift_code: NTRF
|
3119
3119
|
reference: TFNr 40001 MSGID
|
3120
3120
|
transaction_description: '0724710345316110'
|
@@ -3345,7 +3345,7 @@
|
|
3345
3345
|
modifier:
|
3346
3346
|
content: 0709040904DR125300,1NTRFKREF+//F2CA963F5C750549
|
3347
3347
|
funds_code: :debit
|
3348
|
-
amount:
|
3348
|
+
amount: 12530010
|
3349
3349
|
swift_code: NTRF
|
3350
3350
|
reference: KREF+
|
3351
3351
|
transaction_description: F2CA963F5C750549
|
@@ -3402,13 +3402,13 @@
|
|
3402
3402
|
balance_type: :start
|
3403
3403
|
sign: :debit
|
3404
3404
|
currency: EUR
|
3405
|
-
amount:
|
3405
|
+
amount: 45000
|
3406
3406
|
date: 2007-09-03
|
3407
3407
|
- !ruby/object:MT940::StatementLine
|
3408
3408
|
modifier:
|
3409
3409
|
content: 0709040904DR150,NTRFKREF+//FFCD94B7601B6E06
|
3410
3410
|
funds_code: :debit
|
3411
|
-
amount:
|
3411
|
+
amount: 15000
|
3412
3412
|
swift_code: NTRF
|
3413
3413
|
reference: KREF+
|
3414
3414
|
transaction_description: FFCD94B7601B6E06
|
@@ -3434,7 +3434,7 @@
|
|
3434
3434
|
balance_type: :start
|
3435
3435
|
sign: :debit
|
3436
3436
|
currency: EUR
|
3437
|
-
amount:
|
3437
|
+
amount: 60000
|
3438
3438
|
date: 2007-09-04
|
3439
3439
|
- !ruby/object:MT940::ValutaBalance
|
3440
3440
|
modifier:
|
@@ -3442,7 +3442,7 @@
|
|
3442
3442
|
balance_type:
|
3443
3443
|
sign: :debit
|
3444
3444
|
currency: EUR
|
3445
|
-
amount:
|
3445
|
+
amount: 60000
|
3446
3446
|
date: 2007-09-04
|
3447
3447
|
- - !ruby/object:MT940::Job
|
3448
3448
|
modifier:
|
@@ -3465,13 +3465,13 @@
|
|
3465
3465
|
balance_type: :start
|
3466
3466
|
sign: :debit
|
3467
3467
|
currency: EUR
|
3468
|
-
amount:
|
3468
|
+
amount: 45000
|
3469
3469
|
date: 2007-09-03
|
3470
3470
|
- !ruby/object:MT940::StatementLine
|
3471
3471
|
modifier:
|
3472
3472
|
content: 0709040904DR150,NTRFKREF+//DED4A9D0CA11033B
|
3473
3473
|
funds_code: :debit
|
3474
|
-
amount:
|
3474
|
+
amount: 15000
|
3475
3475
|
swift_code: NTRF
|
3476
3476
|
reference: KREF+
|
3477
3477
|
transaction_description: DED4A9D0CA11033B
|
@@ -3497,7 +3497,7 @@
|
|
3497
3497
|
balance_type: :start
|
3498
3498
|
sign: :debit
|
3499
3499
|
currency: EUR
|
3500
|
-
amount:
|
3500
|
+
amount: 60000
|
3501
3501
|
date: 2007-09-04
|
3502
3502
|
- !ruby/object:MT940::ValutaBalance
|
3503
3503
|
modifier:
|
@@ -3505,7 +3505,7 @@
|
|
3505
3505
|
balance_type:
|
3506
3506
|
sign: :debit
|
3507
3507
|
currency: EUR
|
3508
|
-
amount:
|
3508
|
+
amount: 60000
|
3509
3509
|
date: 2007-09-04
|
3510
3510
|
- - !ruby/object:MT940::Job
|
3511
3511
|
modifier:
|
data/test/helper.rb
CHANGED
@@ -76,7 +76,9 @@ class TestCustomerStatementMessage < Test::Unit::TestCase
|
|
76
76
|
|
77
77
|
def test_parsing_a_file_with_broken_structure_should_raise_an_exception
|
78
78
|
file = File.dirname(__FILE__) + "/fixtures/sepa_snippet_broken.txt"
|
79
|
-
assert_raise(
|
79
|
+
assert_raise(MT940::UnexpectedStructureError) do
|
80
|
+
MT940::CustomerStatementMessage.parse_file(file)
|
81
|
+
end
|
80
82
|
end
|
81
83
|
|
82
84
|
def test_should_raise_method_missing_when_asking_statement_lines_for_unknown_stuff
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mt940_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thies C. Arntzen
|
@@ -9,36 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-05-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: gem_hadar
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: 1.2.1
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - "
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
28
|
-
- !ruby/object:Gem::Dependency
|
29
|
-
name: jeweler
|
30
|
-
requirement: !ruby/object:Gem::Requirement
|
31
|
-
requirements:
|
32
|
-
- - ">="
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: '0'
|
35
|
-
type: :development
|
36
|
-
prerelease: false
|
37
|
-
version_requirements: !ruby/object:Gem::Requirement
|
38
|
-
requirements:
|
39
|
-
- - ">="
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
version: '0'
|
27
|
+
version: 1.2.1
|
42
28
|
- !ruby/object:Gem::Dependency
|
43
29
|
name: test-unit
|
44
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -54,7 +40,7 @@ dependencies:
|
|
54
40
|
- !ruby/object:Gem::Version
|
55
41
|
version: '0'
|
56
42
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
43
|
+
name: simplecov
|
58
44
|
requirement: !ruby/object:Gem::Requirement
|
59
45
|
requirements:
|
60
46
|
- - ">="
|
@@ -67,21 +53,26 @@ dependencies:
|
|
67
53
|
- - ">="
|
68
54
|
- !ruby/object:Gem::Version
|
69
55
|
version: '0'
|
70
|
-
description:
|
56
|
+
description: Ruby library that parses account statements in the SWIFT MT940 format.
|
71
57
|
email: developers@betterplace.org
|
72
58
|
executables: []
|
73
59
|
extensions: []
|
74
60
|
extra_rdoc_files:
|
75
|
-
- LICENSE
|
76
61
|
- README.rdoc
|
62
|
+
- lib/mt940.rb
|
63
|
+
- lib/mt940/customer_statement_message.rb
|
64
|
+
- lib/mt940/errors.rb
|
65
|
+
- lib/mt940/version.rb
|
77
66
|
files:
|
78
67
|
- ".document"
|
68
|
+
- ".gitignore"
|
79
69
|
- ".specification"
|
80
70
|
- ".travis.yml"
|
81
71
|
- Gemfile
|
82
72
|
- LICENSE
|
83
73
|
- README.rdoc
|
84
74
|
- Rakefile
|
75
|
+
- VERSION
|
85
76
|
- VERSION.yml
|
86
77
|
- docs/0E0Y00DNY.pdf
|
87
78
|
- docs/FinTS_4.0_Formals.pdf
|
@@ -93,7 +84,11 @@ files:
|
|
93
84
|
- docs/uebersicht_der_geschaeftsvorfallcodes_und_buchungs_textschluessel.pdf
|
94
85
|
- lib/mt940.rb
|
95
86
|
- lib/mt940/customer_statement_message.rb
|
87
|
+
- lib/mt940/errors.rb
|
88
|
+
- lib/mt940/version.rb
|
96
89
|
- mt940_parser.gemspec
|
90
|
+
- test/fixtures/amount_formats.txt
|
91
|
+
- test/fixtures/amount_formats.yml
|
97
92
|
- test/fixtures/currency_in_25.txt
|
98
93
|
- test/fixtures/currency_in_25.yml
|
99
94
|
- test/fixtures/empty_86.txt
|
@@ -118,7 +113,11 @@ licenses:
|
|
118
113
|
- MIT
|
119
114
|
metadata: {}
|
120
115
|
post_install_message:
|
121
|
-
rdoc_options:
|
116
|
+
rdoc_options:
|
117
|
+
- "--title"
|
118
|
+
- Mt940Parser - MT940 parses account statements in the SWIFT MT940 format.
|
119
|
+
- "--main"
|
120
|
+
- README.rdoc
|
122
121
|
require_paths:
|
123
122
|
- lib
|
124
123
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -137,4 +136,6 @@ rubygems_version: 2.4.6
|
|
137
136
|
signing_key:
|
138
137
|
specification_version: 4
|
139
138
|
summary: MT940 parses account statements in the SWIFT MT940 format.
|
140
|
-
test_files:
|
139
|
+
test_files:
|
140
|
+
- test/test_customer_statement_message.rb
|
141
|
+
- test/test_mt940.rb
|