cmxl 0.2.0 → 0.2.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
2
  SHA1:
3
- metadata.gz: 42504a4554682fd712473e3e744db2892083965e
4
- data.tar.gz: 3830a7a989cb7f5d490122d2079e67a45dcc75a3
3
+ metadata.gz: cd3e4666e761be27044a4b4e97aabb85ad3d714d
4
+ data.tar.gz: 2333bb6d9680fbf7ffafd4488f53760cbce29960
5
5
  SHA512:
6
- metadata.gz: 4fc0b6927125e065f9c5b9f8c15f2e6ee7d35feb938a72f9bfde9e059e672389e2a00c6e747e81dacf50ca062a8eb1dd39cac7c30272d40fd282022124ddd56a
7
- data.tar.gz: f64a53ecbf51cedbaf80fdcad20a9e0e1aa47bd9780cb05768401d3449756344ad4956e4bb4eaef10bfe2851409b72c95cdc6ba0298582a95a51ce1568c1d766
6
+ metadata.gz: 3bbb768c8b133798c7208f38d62def5b8282661c8eca73a0178eea1826170e1d69bdc200b23ae42b30af38e738368d7641f2babe3c178fc8b5752ff58e0348b7
7
+ data.tar.gz: 5fcd0c23e6bdbdb8b1c3465089c76025dc19bce761eb7f7b848287ae82a5138d669857c1719fbc345f0df5377ab69889c7387b4c5a03ab56c9a4c331cbfb5c23
@@ -1,15 +1,13 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 1.9.3
5
- - 2.0.0
6
- - 2.1.8
7
- - 2.2.4
8
- - 2.3.0
9
- - jruby
10
- matrix:
11
- allow_failures:
12
- - rvm: 1.9.3
4
+ - 2.2.8
5
+ - 2.3.4
6
+ - 2.4.3
7
+ - 2.5.0
8
+ - jruby-9.1.10.0
9
+ before_install:
10
+ gem update --system
13
11
  after_success:
14
12
  - bundle exec codeclimate-test-reporter
15
13
  addons:
@@ -1,3 +1,9 @@
1
+ # 0.2.1
2
+ * addressing an bug that occoured for transactions submitted end of
3
+ but were fetched in the new year -> those ended up with the wrong year
4
+ on the entry date
5
+ * MT942 support for field 13
6
+
1
7
  # 0.2.0
2
8
  * added several balance related accessors (#7)
3
9
  * configuration option for `statement separator` (#5)
@@ -0,0 +1,12 @@
1
+ module Cmxl
2
+ module Fields
3
+ class EntryDate < Field
4
+ self.tag = 13
5
+ self.parser = DATE
6
+
7
+ def date
8
+ to_date(source)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -23,7 +23,9 @@ module Cmxl
23
23
 
24
24
  def sepa
25
25
  if self.information =~ /([A-Z]{4})\+/
26
- Hash[*self.information.split(/([A-Z]{4})\+/)[1..-1]]
26
+ Hash[
27
+ *self.information.split(/([A-Z]{4})\+/)[1..-1].tap {|info| info << "" if info.size.odd? }
28
+ ]
27
29
  else
28
30
  {}
29
31
  end
@@ -37,8 +37,15 @@ module Cmxl
37
37
  def date
38
38
  to_date(self.data['date'])
39
39
  end
40
+
40
41
  def entry_date
41
- to_date(self.data['entry_date'], self.date.year) if self.data['entry_date'] && self.date
42
+ if self.data['entry_date'] && self.date
43
+ if date.month == 1 && date.month < to_date(self.data['entry_date'], self.date.year).month
44
+ to_date(self.data['entry_date'], self.date.year - 1)
45
+ else
46
+ to_date(self.data['entry_date'], self.date.year)
47
+ end
48
+ end
42
49
  end
43
50
 
44
51
  # Fields from details
@@ -73,7 +73,7 @@ module Cmxl
73
73
  end
74
74
 
75
75
  def generation_date
76
- self.field(20).date
76
+ self.field(20).date || self.field(13).date
77
77
  end
78
78
 
79
79
  def account_identification
@@ -1,3 +1,3 @@
1
1
  module Cmxl
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe Cmxl::Fields::EntryDate do
4
+ context 'iban' do
5
+ subject { Cmxl::Fields::EntryDate.parse( fixture_line(:entry_date) ) }
6
+
7
+ it { expect(subject.date).to eql(Date.parse('2017/12/29')) }
8
+ end
9
+ end
@@ -73,4 +73,12 @@ describe Cmxl::Fields::StatementDetails do
73
73
  it { expect(subject.to_hash).to eql(subject.to_h) }
74
74
  end
75
75
 
76
+ describe 'information parsing with empty fields on the end' do
77
+ subject { Cmxl::Fields::StatementDetails.parse(fixture_line(:statement_details_empty_fields)) }
78
+
79
+ it { expect(subject.sepa).to eql({
80
+ "EREF" => "S1001675",
81
+ "SVWZ" => ""
82
+ }) }
83
+ end
76
84
  end
@@ -0,0 +1 @@
1
+ :13D:1712290540+0100
@@ -0,0 +1 @@
1
+ :86:166?00SEPA-CT HABEN EINZELBUCHUNG?1097261?20EREF+S1001675?21SVWZ+?30DEUTDEDB510?31DE23510700240352432900?32John Doe
@@ -1 +1,2 @@
1
1
  :61:1409010902DR000000000001,62NTRF0000549855700010//025498557/000001
2
+ :61:1401041229DR000000000001,62NTRF0000549855700010//025498557/000001
@@ -90,6 +90,18 @@ describe Cmxl do
90
90
  end
91
91
  end
92
92
 
93
+ describe 'statement issued over a years boudary' do
94
+ subject { Cmxl.parse( mt940_file('statement-mt940') ).first.transactions.last }
95
+
96
+ it 'includes correct entry date' do
97
+ expect(subject.entry_date).to eq(Date.new(2013,12,29))
98
+ end
99
+
100
+ it 'includes correct date' do
101
+ expect(subject.date).to eq(Date.new(2014,01,04))
102
+ end
103
+ end
104
+
93
105
  describe 'statement with detailed end balance' do
94
106
  subject { Cmxl.parse( mt940_file('mt940-with-detailed-end-balance') ).first.transactions.first }
95
107
 
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: 0.2.0
4
+ version: 0.2.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: 2016-11-08 00:00:00.000000000 Z
11
+ date: 2018-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -103,6 +103,7 @@ files:
103
103
  - lib/cmxl/fields/account_identification.rb
104
104
  - lib/cmxl/fields/available_balance.rb
105
105
  - lib/cmxl/fields/closing_balance.rb
106
+ - lib/cmxl/fields/entry_date.rb
106
107
  - lib/cmxl/fields/reference.rb
107
108
  - lib/cmxl/fields/statement_details.rb
108
109
  - lib/cmxl/fields/statement_number.rb
@@ -114,6 +115,7 @@ files:
114
115
  - spec/fields/account_identification_spec.rb
115
116
  - spec/fields/available_balance_spec.rb
116
117
  - spec/fields/closing_balance_spec.rb
118
+ - spec/fields/entry_date_spec.rb
117
119
  - spec/fields/reference_spec.rb
118
120
  - spec/fields/statement_details_spec.rb
119
121
  - spec/fields/statement_number_spec.rb
@@ -125,8 +127,10 @@ files:
125
127
  - spec/fixtures/lines/account_identification_legacy.txt
126
128
  - spec/fixtures/lines/available_balance.txt
127
129
  - spec/fixtures/lines/closing_balance.txt
130
+ - spec/fixtures/lines/entry_date.txt
128
131
  - spec/fixtures/lines/reference.txt
129
132
  - spec/fixtures/lines/statement_details.txt
133
+ - spec/fixtures/lines/statement_details_empty_fields.txt
130
134
  - spec/fixtures/lines/statement_line.txt
131
135
  - spec/fixtures/lines/statement_number.txt
132
136
  - spec/fixtures/mt940-deutsche_bank.txt
@@ -161,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
165
  version: '0'
162
166
  requirements: []
163
167
  rubyforge_project:
164
- rubygems_version: 2.5.1
168
+ rubygems_version: 2.6.14
165
169
  signing_key:
166
170
  specification_version: 4
167
171
  summary: Cmxl is your friendly MT940 bank statement parser
@@ -171,6 +175,7 @@ test_files:
171
175
  - spec/fields/account_identification_spec.rb
172
176
  - spec/fields/available_balance_spec.rb
173
177
  - spec/fields/closing_balance_spec.rb
178
+ - spec/fields/entry_date_spec.rb
174
179
  - spec/fields/reference_spec.rb
175
180
  - spec/fields/statement_details_spec.rb
176
181
  - spec/fields/statement_number_spec.rb
@@ -182,8 +187,10 @@ test_files:
182
187
  - spec/fixtures/lines/account_identification_legacy.txt
183
188
  - spec/fixtures/lines/available_balance.txt
184
189
  - spec/fixtures/lines/closing_balance.txt
190
+ - spec/fixtures/lines/entry_date.txt
185
191
  - spec/fixtures/lines/reference.txt
186
192
  - spec/fixtures/lines/statement_details.txt
193
+ - spec/fixtures/lines/statement_details_empty_fields.txt
187
194
  - spec/fixtures/lines/statement_line.txt
188
195
  - spec/fixtures/lines/statement_number.txt
189
196
  - spec/fixtures/mt940-deutsche_bank.txt