cmxl 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 82b72d8655b552c6a10bae7df6882bf313ea472b
4
- data.tar.gz: 630a7f8c31eee13bec9ca238ea492f0bad384515
2
+ SHA256:
3
+ metadata.gz: 037ec6226374da8a4c7f2f32109056c2bdf7219e8a1ef4d2cca79c5e644a0f77
4
+ data.tar.gz: 8d0f83fe9c414c0416f28383910b91d3d12dcd678664546596266c0e612084e6
5
5
  SHA512:
6
- metadata.gz: dcfab68cd74b8c40ccd21799693f20be692ae3a38c2edfc02c06972ebd0148e06a91c3031d715fb5f97b6d8d923d7802db2763ee01d91e5ba34f3b201f678438
7
- data.tar.gz: f7936f2ba25cd820f81241a46588ff03dd66f8cf9b3dd4165e9eb5c372eec020a0f82b0053d5a39756e1c554471299fd6879501663ff2e4343de115191374a2c
6
+ metadata.gz: de2ec010f0e1602366ac9149884b70feb00781a885bd9aee72adecfeeca3e5088f6943752aa9f1b29cf064f8323e55189295c37f82df427b6450ec67e349baf1
7
+ data.tar.gz: da503e542f541503bc43ea3b25e7e9bf3ef018f4fc34084b1272d1f3d55ad1ff0108d21079cb9819b1c19c853e1ad1ef84aa6af7bd092ecbff1946f3c535046c
@@ -1,3 +1,6 @@
1
+ # 1.1.1
2
+ * [BUGFIX] prevents short bank references from swallowing supplementary details delimiter
3
+
1
4
  # 1.1.0
2
5
  * [FEATURE] adds support for supplementary details in transactions (Field 61, Subfield 9) (#18)
3
6
 
@@ -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?\n\z/, '') # remove trailing line break to prevent empty field parsing
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|.{0,16})((?:\/\/)(?<bank_reference>[^\n]*))?((?:[\n])?(?<supplementary>.{,34}))$}
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) unless supplementary.source.empty?
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
 
@@ -1,3 +1,3 @@
1
1
  module Cmxl
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
@@ -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
@@ -0,0 +1,2 @@
1
+ :61:180627D79,NMSCFOOBAR/123//HERP-DERP-REF
2
+ random text / and stuff
@@ -1,2 +1,2 @@
1
- :61:0306280628D21,00FMSCNONREF//98327000090031789
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.0
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-04-25 00:00:00.000000000 Z
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.5.1
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