mt940 0.7.1 → 0.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a4974b89c12da285719a0002bc6e59fe132940b3
4
- data.tar.gz: f35f1ab7264f07e3a55196bb9adadebc083779fa
3
+ metadata.gz: 794cd939c7e990345e04bd179fcca0b985dc7f8b
4
+ data.tar.gz: 10d1457e0f6b4fc18f483a0871175f72a43775ff
5
5
  SHA512:
6
- metadata.gz: eb4dc9a5a936a255a97dcc605de144481cf72a49956f8d9f85ee583e3192ad72b5751adeb8549db4f8d443512f95e0dfc407566cf83700de83a98a03767253e7
7
- data.tar.gz: 84ea5616194fd6b27c65d296dc9178a155431b7a1b0552bd3ee51a9885f0c8f7499365f245efd16d742534114fb562454469dafddffdcf9f92fff8bb8103fd86
6
+ metadata.gz: f316f5881c67da96a2730633f67d62f8e08f4b38de3e234b1def293232bbd271f8900fab8ecf1eece387d5faae11e34ed218489e2eb52f3f0b8fdf7d411c7294
7
+ data.tar.gz: a913ab92d962f68b164515dd58b96d867da2b51e5250021dfbf2af5db2abbb2c323290c0ed130512c0131b14fd4e4e9fae817835a5bf47ee7607396e64b3fc29
data/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+ * 0.8.0
2
+ - BUG FIX: correct parsing of tag 86 ING in case it doesn't contain an IBAN number
3
+ - Now with a more general IBAN regexp pattern
4
+
5
+ * 0.7.1
6
+ - Small fix, prevent invalid byte sequence in UTF-8 while reading mt940 file
7
+ - Replace more than two or more spaces with only one
8
+
1
9
  * 0.7.0
2
10
  - No support for Ruby 1.8.7, default 2.1.0
3
11
  - I was uncomfortable with using class methods, so I introduced the Mt940::Parser and refactored. See Readme
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mt940 (0.7.1)
4
+ mt940 (0.8.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/README.md CHANGED
@@ -5,7 +5,7 @@ MT940 (Dutch banks only)
5
5
  ![http://travis-ci.org/dovadi/mt940](https://secure.travis-ci.org/dovadi/mt940.png)
6
6
  </a>
7
7
 
8
- Basis parser for MT940 files, see [MT940](http://nl.wikipedia.org/wiki/MT940). This library is only meant for collection the transactions. No bank statements or balance (previous or new) is determined.
8
+ Basis parser for MT940 files, see [MT940](http://nl.wikipedia.org/wiki/MT940). This library is only meant for collecting the transactions. No bank statements or balance (previous or new) is determined.
9
9
 
10
10
  The following Dutch banks are implemented with support for IBAN numbers:
11
11
 
@@ -2,6 +2,7 @@ $:.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/version'
5
6
  require 'mt940/bic_codes'
6
7
  require 'mt940/parser'
7
8
  require 'mt940/base'
@@ -12,7 +12,7 @@ class MT940::Ing < MT940::Base
12
12
 
13
13
  def parse_line_after_sepa
14
14
  if @line.match(MT940::SEPA_PATTERN)
15
- @contra_account = $2
15
+ @contra_account = $1
16
16
  @description = $4.strip
17
17
  end
18
18
  end
@@ -1,9 +1,9 @@
1
1
  module MT940
2
2
 
3
3
  BBAN_PATTERN = '^\d{10}'
4
- IBAN_PATTERN = 'NL\d{2}[A-Z]{4}\d{10}'
4
+ IBAN_PATTERN = '[a-zA-Z]{2}[0-9]{2}[a-zA-Z0-9]{4}[0-9]{7}([a-zA-Z0-9]?){0,16}'
5
5
  BIC_CODE_PATTERN = MT940::BIC_CODES.values.join('|')
6
- SEPA_PATTERN = Regexp.new "(#{BBAN_PATTERN})\\s+(#{IBAN_PATTERN})\\s+(#{BIC_CODE_PATTERN})(.+)$"
6
+ SEPA_PATTERN = Regexp.new "(#{IBAN_PATTERN})\\s+(#{BIC_CODE_PATTERN})(.+)$"
7
7
 
8
8
  class Base
9
9
 
@@ -67,9 +67,10 @@ module MT940
67
67
  def parse_tag_86
68
68
  if @line.match(/^:86:\s?(.*)$/)
69
69
  @line = $1.strip
70
+ @description, @contra_account = nil, nil
70
71
  sepa? ? parse_line_after_sepa : parse_line_before_sepa
71
72
  @transaction.contra_account = @contra_account
72
- @transaction.description = @description
73
+ @transaction.description = @description || @line
73
74
  end
74
75
  end
75
76
 
@@ -1,3 +1,3 @@
1
1
  module MT940
2
- VERSION = '0.7.1'
2
+ VERSION = '0.8.0'
3
3
  end
@@ -5,26 +5,39 @@
5
5
  :25:0654321789
6
6
  :28C:000
7
7
  :60F:C120810EUR68,20
8
+
8
9
  :61:120810C1,41NOV EV41411REP170112
9
10
  :86:0654321789 J. Janssen Factuurnr 123456 klantnr 00123
11
+
10
12
  :61:120810C1,56NOV EREF
11
13
  :86:0123456789 NL69INGB0123456789 INGBNL2A J. Janssen
12
14
  20120123456789 Factuurnr 123456 Klantnr 00123
15
+
13
16
  :61:120810D2,13NVZ NONREF
14
17
  :86:TOTAAL 1 VZ 4444444
18
+
15
19
  :61:120810D1,57NVZ PREF
16
20
  :86:VERZAMEL EUROBETALING M000000001111111 REMI TOTAAL 1 POSTEN
21
+
17
22
  :61:120810C1,44NIC NONREF
18
23
  :86:TOTAAL 1 IC 4444444
24
+
19
25
  :61:120810D1,54NIC EV54541REP180112
20
26
  :86:000754321 KN: EV54541REP180112
21
27
  EV54541REP180112T1630 ING BANK NV INZAKE WEB?AMSTERDAM
28
+
22
29
  :61:120810D1,14NIC MARF
23
30
  :86:0123456789 Europese Incasso doorlopend NL69INGB0123456789 INGBNL2A
24
31
  J. Jansen NL32ZZZ999999991234 MND-120123 20120501P01234785 CONTRIB
25
32
  UTIE MEI 2012
33
+
26
34
  :61:120810C939,60NAC NONREF
27
35
  :86:0675432198 J. JANSSEN AMSTERDAM KN:3300169406045025
36
+
37
+ :61:140301D1234,00NDV NONREF
38
+ :86: Reguliere aflossing
39
+ Starters Investeri 11.22.33.444 Rest hoofdsom EUR 99.000,00
40
+
28
41
  :62F:C120811EUR1005,83
29
42
  :64:C120811EUR1005,83
30
43
  :65:C120811EUR1005,83
@@ -57,7 +57,7 @@ class TestMt940Ing < Test::Unit::TestCase
57
57
  end
58
58
 
59
59
  should 'have the correct number of transactions' do
60
- assert_equal 8, @transactions.size
60
+ assert_equal 9, @transactions.size
61
61
  end
62
62
 
63
63
  context 'Transaction' do
@@ -86,12 +86,24 @@ class TestMt940Ing < Test::Unit::TestCase
86
86
  assert_equal 'Ing', @transaction.bank
87
87
  end
88
88
 
89
- should 'have a description' do
90
- assert_equal 'J. Janssen 20120123456789 Factuurnr 123456 Klantnr 00123', @transactions[1].description
89
+ context 'With an iban number in :86' do
90
+ should 'have a description' do
91
+ assert_equal 'J. Janssen 20120123456789 Factuurnr 123456 Klantnr 00123', @transactions[1].description
92
+ end
93
+
94
+ should 'return the contra_account' do
95
+ assert_equal 'NL69INGB0123456789', @transactions[1].contra_account
96
+ end
91
97
  end
92
98
 
93
- should 'return the contra_account' do
94
- assert_equal 'NL69INGB0123456789', @transactions[1].contra_account
99
+ context 'Without an iban number in :86' do
100
+ should 'have a description' do
101
+ assert_equal 'Reguliere aflossingStarters Investeri 11.22.33.444 Rest hoofdsom EUR 99.000,00', @transactions[8].description
102
+ end
103
+
104
+ should 'return the contra_account' do
105
+ assert_equal nil, @transactions[8].contra_account
106
+ end
95
107
  end
96
108
 
97
109
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mt940
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Oxener
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-06 00:00:00.000000000 Z
11
+ date: 2014-03-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A basic MT940 parser with implementations for Dutch banks.
14
14
  email: frank.oxener@gmail.com