cmxl 1.1.0 → 1.1.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 +5 -5
- data/CHANGELOG.mdown +3 -0
- data/lib/cmxl/field.rb +1 -1
- data/lib/cmxl/fields/transaction.rb +2 -2
- data/lib/cmxl/fields/transaction_supplementary.rb +2 -2
- data/lib/cmxl/version.rb +1 -1
- data/spec/fields/transaction_spec.rb +13 -0
- data/spec/fixtures/lines/statement_supplementary_complex.txt +2 -0
- data/spec/fixtures/lines/statement_supplementary_plain.txt +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 037ec6226374da8a4c7f2f32109056c2bdf7219e8a1ef4d2cca79c5e644a0f77
|
4
|
+
data.tar.gz: 8d0f83fe9c414c0416f28383910b91d3d12dcd678664546596266c0e612084e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de2ec010f0e1602366ac9149884b70feb00781a885bd9aee72adecfeeca3e5088f6943752aa9f1b29cf064f8323e55189295c37f82df427b6450ec67e349baf1
|
7
|
+
data.tar.gz: da503e542f541503bc43ea3b25e7e9bf3ef018f4fc34084b1272d1f3d55ad1ff0108d21079cb9819b1c19c853e1ad1ef84aa6af7bd092ecbff1946f3c535046c
|
data/CHANGELOG.mdown
CHANGED
data/lib/cmxl/field.rb
CHANGED
@@ -45,7 +45,7 @@ module Cmxl
|
|
45
45
|
#
|
46
46
|
def self.parse(line)
|
47
47
|
if line.match(/\A:(\d{2,2})(\w)?:(.*)\z/m)
|
48
|
-
tag, modifier, content = $1, $2, $3.gsub(/\r
|
48
|
+
tag, modifier, content = $1, $2, $3.gsub(/\r/, '').gsub(/\n\z/, '') # remove trailing line break to prevent empty field parsing
|
49
49
|
Field.parsers[tag.to_s].new(content, modifier, tag)
|
50
50
|
else
|
51
51
|
raise LineFormatError, "Wrong line format: #{line.dump}" if Cmxl.config[:raise_line_format_errors]
|
@@ -2,7 +2,7 @@ module Cmxl
|
|
2
2
|
module Fields
|
3
3
|
class Transaction < Field
|
4
4
|
self.tag = 61
|
5
|
-
self.parser = %r{^(?<date>\d{6})(?<entry_date>\d{4})?(?<storno_flag>R?)(?<funds_code>[CD]{1})(?<currency_letter>[a-zA-Z])?(?<amount>\d{1,12},\d{0,2})(?<swift_code>(?:N|F).{3})(?<reference>NONREF
|
5
|
+
self.parser = %r{^(?<date>\d{6})(?<entry_date>\d{4})?(?<storno_flag>R?)(?<funds_code>[CD]{1})(?<currency_letter>[a-zA-Z])?(?<amount>\d{1,12},\d{0,2})(?<swift_code>(?:N|F).{3})(?<reference>NONREF|(.(?!\/\/)){,16}([^\/]){,1})((?:\/\/)(?<bank_reference>[^\n]{,16}))?((?:\n)(?<supplementary>.{,34}))?$}
|
6
6
|
|
7
7
|
attr_accessor :details
|
8
8
|
|
@@ -129,7 +129,7 @@ module Cmxl
|
|
129
129
|
'currency_letter' => currency_letter,
|
130
130
|
}.tap do |h|
|
131
131
|
h.merge!(details.to_h) if details
|
132
|
-
h.merge!(supplementary.to_h)
|
132
|
+
h.merge!(supplementary.to_h) if supplementary.source
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
@@ -6,8 +6,8 @@ module Cmxl
|
|
6
6
|
|
7
7
|
class << self
|
8
8
|
def parse(line)
|
9
|
-
initial = $1 if line.match(initial_parser)
|
10
|
-
charges = $1 if line.match(charges_parser)
|
9
|
+
initial = $1 if line && line.match(initial_parser)
|
10
|
+
charges = $1 if line && line.match(charges_parser)
|
11
11
|
new(line, initial, charges)
|
12
12
|
end
|
13
13
|
|
data/lib/cmxl/version.rb
CHANGED
@@ -6,6 +6,7 @@ describe Cmxl::Fields::Transaction do
|
|
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
|
+
subject(:complex_supplementary_transaction) { Cmxl::Fields::Transaction.parse(fixture_line(:statement_supplementary_complex)) }
|
9
10
|
|
10
11
|
let(:fixture) { fixture_line(:statement_line).split(/\n/) }
|
11
12
|
|
@@ -64,4 +65,16 @@ describe Cmxl::Fields::Transaction do
|
|
64
65
|
|
65
66
|
it { expect(supplementary_transaction.supplementary.source).to eql('Card Transaction') }
|
66
67
|
end
|
68
|
+
|
69
|
+
context 'statement with complex supplementary' do
|
70
|
+
it { expect(complex_supplementary_transaction.initial_amount_in_cents).to eql(nil) }
|
71
|
+
it { expect(complex_supplementary_transaction.initial_currency).to eql(nil) }
|
72
|
+
|
73
|
+
it { expect(complex_supplementary_transaction.charges_in_cents).to eql(nil) }
|
74
|
+
it { expect(complex_supplementary_transaction.charges_currency).to eql(nil) }
|
75
|
+
|
76
|
+
it { expect(complex_supplementary_transaction.reference).to eql('FOOBAR/123') }
|
77
|
+
it { expect(complex_supplementary_transaction.bank_reference).to eql('HERP-DERP-REF') }
|
78
|
+
it { expect(complex_supplementary_transaction.supplementary.source).to eql('random text / and stuff') }
|
79
|
+
end
|
67
80
|
end
|
@@ -1,2 +1,2 @@
|
|
1
|
-
:61:0306280628D21,00FMSCNONREF//
|
1
|
+
:61:0306280628D21,00FMSCNONREF//983270000900317
|
2
2
|
Card Transaction
|
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.1.
|
4
|
+
version: 1.1.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: 2018-
|
11
|
+
date: 2018-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -151,6 +151,7 @@ files:
|
|
151
151
|
- spec/fixtures/lines/statement_number.txt
|
152
152
|
- spec/fixtures/lines/statement_ocmt.txt
|
153
153
|
- spec/fixtures/lines/statement_ocmt_chgs.txt
|
154
|
+
- spec/fixtures/lines/statement_supplementary_complex.txt
|
154
155
|
- spec/fixtures/lines/statement_supplementary_plain.txt
|
155
156
|
- spec/fixtures/mt940-deutsche_bank.txt
|
156
157
|
- spec/fixtures/mt940-iso8859-1.txt
|
@@ -184,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
185
|
version: '0'
|
185
186
|
requirements: []
|
186
187
|
rubyforge_project:
|
187
|
-
rubygems_version: 2.
|
188
|
+
rubygems_version: 2.7.6
|
188
189
|
signing_key:
|
189
190
|
specification_version: 4
|
190
191
|
summary: Cmxl is your friendly MT940 bank statement parser
|
@@ -215,6 +216,7 @@ test_files:
|
|
215
216
|
- spec/fixtures/lines/statement_number.txt
|
216
217
|
- spec/fixtures/lines/statement_ocmt.txt
|
217
218
|
- spec/fixtures/lines/statement_ocmt_chgs.txt
|
219
|
+
- spec/fixtures/lines/statement_supplementary_complex.txt
|
218
220
|
- spec/fixtures/lines/statement_supplementary_plain.txt
|
219
221
|
- spec/fixtures/mt940-deutsche_bank.txt
|
220
222
|
- spec/fixtures/mt940-iso8859-1.txt
|