cmxl 1.4.0 → 1.4.1
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/CHANGELOG.mdown +5 -0
- data/lib/cmxl/fields/transaction.rb +13 -7
- data/lib/cmxl/statement.rb +2 -5
- data/lib/cmxl/version.rb +1 -1
- data/spec/fields/transaction_spec.rb +16 -2
- data/spec/fixtures/lines/statement_line.txt +2 -0
- data/spec/fixtures/mt940-with-colon-after-line-break.txt +11 -0
- data/spec/statement_spec.rb +8 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41f6f1b53eb060758d035fe5d0b3475b42b12bf10c749418a3b72b3c98482140
|
4
|
+
data.tar.gz: 1e5f3ee6fcbbdca480600b029c573ccc614a2adba34e66c440286a99d5be963b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f4af37922a0e6d14795c7274a64a60697660b6e0f7399947e7bdae6973b4ea3dbe22a3e73e2923004a16ce215577565ac4f609283752401359228d8709e7c57
|
7
|
+
data.tar.gz: 0a9aecfe5f17a5bd09dcce8e96c45af26c3d89c79ce505aad9806849e1fbaa082dccb02d562ff8552283a14d6027a4f5b11de3a1237dc790d0c609bdc1f15d1f
|
data/CHANGELOG.mdown
CHANGED
@@ -59,13 +59,19 @@ module Cmxl
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def entry_date
|
62
|
-
if data['entry_date']
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
62
|
+
return if !date || !data['entry_date']
|
63
|
+
|
64
|
+
e_date = to_date(data['entry_date'], date.year)
|
65
|
+
# we assume that valuta (date) and entry_date have a close connection. so valuta and entry_date should not be
|
66
|
+
# further apart than one month. this leads to some edge cases
|
67
|
+
|
68
|
+
# valuta is in january while entry_date is in december => entry_date was done the year before
|
69
|
+
e_date = to_date(data['entry_date'], date.year - 1) if date.month == 1 && e_date.month == 12
|
70
|
+
|
71
|
+
# valuta is in december but entry_date is in january => entry_date is actually in the year after valuta
|
72
|
+
e_date = to_date(data['entry_date'], date.year + 1) if date.month == 12 && e_date.month == 1
|
73
|
+
|
74
|
+
e_date
|
69
75
|
end
|
70
76
|
|
71
77
|
def supplementary
|
data/lib/cmxl/statement.rb
CHANGED
@@ -26,12 +26,9 @@ module Cmxl
|
|
26
26
|
def parse!
|
27
27
|
self.fields = []
|
28
28
|
|
29
|
-
|
30
|
-
# do not remove line breaks within transaction lines as they are used to determine field details
|
31
|
-
# e.g. :61:-supplementary
|
32
|
-
source.split("\n:").each(&:strip!).each do |line|
|
33
|
-
line = ":#{line}" unless line =~ /^:/ # prepend lost : via split
|
29
|
+
lines = source.split(/(:[0-9A-Z]{2,3}:)/m).reject(&:empty?).each_slice(2).map(&:join)
|
34
30
|
|
31
|
+
lines.map do |line|
|
35
32
|
if line =~ /\A:86:/
|
36
33
|
if field = fields.last
|
37
34
|
field.add_meta_data(line)
|
data/lib/cmxl/version.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Cmxl::Fields::Transaction do
|
4
|
-
subject(:debit_transaction) { Cmxl::Fields::Transaction.parse(fixture
|
5
|
-
subject(:storno_credit_transaction) { Cmxl::Fields::Transaction.parse(fixture
|
4
|
+
subject(:debit_transaction) { Cmxl::Fields::Transaction.parse(fixture[0]) }
|
5
|
+
subject(:storno_credit_transaction) { Cmxl::Fields::Transaction.parse(fixture[1]) }
|
6
6
|
subject(:ocmt_transaction) { Cmxl::Fields::Transaction.parse(fixture_line(:statement_ocmt)) }
|
7
7
|
subject(:ocmt_cghs_transaction) { Cmxl::Fields::Transaction.parse(fixture_line(:statement_ocmt_chgs)) }
|
8
8
|
subject(:supplementary_transaction) { Cmxl::Fields::Transaction.parse(fixture_line(:statement_supplementary_plain)) }
|
9
9
|
subject(:complex_supplementary_transaction) { Cmxl::Fields::Transaction.parse(fixture_line(:statement_supplementary_complex)) }
|
10
|
+
subject(:valuta_after_enty_date) { Cmxl::Fields::Transaction.parse(fixture[3]) }
|
11
|
+
subject(:entry_before_valuta_transaction) { Cmxl::Fields::Transaction.parse(fixture[2]) }
|
10
12
|
|
11
13
|
let(:fixture) { fixture_line(:statement_line).split(/\n/) }
|
12
14
|
|
@@ -77,4 +79,16 @@ describe Cmxl::Fields::Transaction do
|
|
77
79
|
it { expect(complex_supplementary_transaction.bank_reference).to eql('HERP-DERP-REF') }
|
78
80
|
it { expect(complex_supplementary_transaction.supplementary.source).to eql('random text / and stuff') }
|
79
81
|
end
|
82
|
+
|
83
|
+
context 'valuta and entry-date assumptions' do
|
84
|
+
it 'entry_date before valuta is recognized correclty when including year-change' do
|
85
|
+
expect(entry_before_valuta_transaction.date).to eql(Date.new(2014, 1, 10))
|
86
|
+
expect(entry_before_valuta_transaction.entry_date).to eql(Date.new(2013, 12, 24))
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'entry_date after valuta is recognized correctly when including year-change' do
|
90
|
+
expect(valuta_after_enty_date.date).to eql(Date.new(2014, 12, 24))
|
91
|
+
expect(valuta_after_enty_date.entry_date).to eql(Date.new(2015, 1, 2))
|
92
|
+
end
|
93
|
+
end
|
80
94
|
end
|
@@ -1,2 +1,4 @@
|
|
1
1
|
:61:1409010902DR000000000001,62NTRF0000549855700010//025498557/000001
|
2
2
|
:61:1409010902RCR000000000001,62NTRF0000549855700010//025498557/000001
|
3
|
+
:61:1401101224CR000000000001,62NTRF0000549855700010//025498557/000001
|
4
|
+
:61:1412240102CR000000000001,62NTRF0000549855700010//025498557/000001
|
@@ -0,0 +1,11 @@
|
|
1
|
+
:20:131110
|
2
|
+
:25:45050050/76198810
|
3
|
+
:28:27/01
|
4
|
+
:60F:C131016DEM84349,74
|
5
|
+
:61:131017D6800,NCHK16703074
|
6
|
+
/OCMT/CAD47,11
|
7
|
+
:86:106?109075/658?20EREF+000000000193592204?21MREF+CN3R3U?22CRED+DE7
|
8
|
+
600200000132558?23SVWZ+STARTER//8449273399/US?24 22-04-2019T03:46
|
9
|
+
:08 Karten?25nr. 5355999999999975 Origi?26nal 49,00 USD 1 EUR/1,
|
10
|
+
12385?27 USD Entgelt 0,44 EUR?30DEUTDEDBFRA?31DE1950070024000402
|
11
|
+
0480?32DEUTSCHE BANK
|
data/spec/statement_spec.rb
CHANGED
@@ -120,6 +120,14 @@ describe Cmxl do
|
|
120
120
|
expect(subject.bic).to eq('10020030')
|
121
121
|
end
|
122
122
|
end
|
123
|
+
|
124
|
+
describe 'statement with colon right after linebreak' do
|
125
|
+
subject { Cmxl.parse(mt940_file('mt940-with-colon-after-line-break')).first.transactions.first }
|
126
|
+
|
127
|
+
it 'has the right details' do
|
128
|
+
expect(subject.to_h['details']).to eq('?109075/658?20EREF+000000000193592204?21MREF+CN3R3U?22CRED+DE7600200000132558?23SVWZ+STARTER//8449273399/US?24 22-04-2019T03:46:08 Karten?25nr. 5355999999999975 Origi?26nal 49,00 USD 1 EUR/1,12385?27 USD Entgelt 0,44 EUR?30DEUTDEDBFRA?31DE19500700240004020480?32DEUTSCHE BANK')
|
129
|
+
end
|
130
|
+
end
|
123
131
|
end
|
124
132
|
|
125
133
|
context 'mt942' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cmxl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Bumann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -165,6 +165,7 @@ files:
|
|
165
165
|
- spec/fixtures/mt940-deutsche_bank.txt
|
166
166
|
- spec/fixtures/mt940-headers.txt
|
167
167
|
- spec/fixtures/mt940-iso8859-1.txt
|
168
|
+
- spec/fixtures/mt940-with-colon-after-line-break.txt
|
168
169
|
- spec/fixtures/mt940-with-detailed-end-balance.txt
|
169
170
|
- spec/fixtures/mt940.txt
|
170
171
|
- spec/fixtures/mt942.txt
|
@@ -239,6 +240,7 @@ test_files:
|
|
239
240
|
- spec/fixtures/mt940-deutsche_bank.txt
|
240
241
|
- spec/fixtures/mt940-headers.txt
|
241
242
|
- spec/fixtures/mt940-iso8859-1.txt
|
243
|
+
- spec/fixtures/mt940-with-colon-after-line-break.txt
|
242
244
|
- spec/fixtures/mt940-with-detailed-end-balance.txt
|
243
245
|
- spec/fixtures/mt940.txt
|
244
246
|
- spec/fixtures/mt942.txt
|