cfonb 1.0.0 → 1.1.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 +4 -4
- data/lib/cfonb/operation_details/base.rb +14 -1
- data/lib/cfonb/operation_details/ibe.rb +1 -1
- data/lib/cfonb/operation_details/ipy.rb +1 -1
- data/lib/cfonb/operation_details/unknown.rb +23 -0
- data/lib/cfonb/operation_details.rb +3 -1
- data/lib/cfonb.rb +1 -0
- data/spec/cfonb/operation_spec.rb +23 -0
- data/spec/cfonb/parser_spec.rb +8 -3
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 057c580fc124d3731dc852832c8c6f601584bbd235604fd5c44605b4509429c0
|
|
4
|
+
data.tar.gz: 037c88124d45e136b909660a8ef7f840a03fa5a7bc06c9e19e592e2eb67080a5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b803bf7c0a2c0803e7ae54ea937d3ccb06eeeced3f7dcc033ce202a658137c41da085adf462c2ebcf9d76352cb3990467a45deeaf0a80ad6c86b713a9733248e
|
|
7
|
+
data.tar.gz: 02c6b90c2732f5da3b481ec2c9b811b17377d0a7e602780d2048baf86499c3115abe4fcff98cd1cf454a80967565167aa6475fd53cc8442e43c14ddad79d89a4
|
|
@@ -7,10 +7,23 @@ module CFONB
|
|
|
7
7
|
base.singleton_class.prepend(
|
|
8
8
|
Module.new do
|
|
9
9
|
def apply(details, line)
|
|
10
|
-
|
|
10
|
+
code = :"@#{line.detail_code}"
|
|
11
|
+
details.instance_variable_set(code, instance_value(details, line, code))
|
|
11
12
|
|
|
12
13
|
super
|
|
13
14
|
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def append_detail?(details, line, code)
|
|
19
|
+
details.instance_variable_defined?(code) && line.detail.is_a?(String)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def instance_value(details, line, code)
|
|
23
|
+
return line.detail unless append_detail?(details, line, code)
|
|
24
|
+
|
|
25
|
+
details.instance_variable_get(code) + "\n#{line.detail}"
|
|
26
|
+
end
|
|
14
27
|
end,
|
|
15
28
|
)
|
|
16
29
|
end
|
|
@@ -7,7 +7,7 @@ module CFONB
|
|
|
7
7
|
|
|
8
8
|
def self.apply(details, line)
|
|
9
9
|
details.creditor_identifier = line.detail[0..34].strip
|
|
10
|
-
details.creditor_identifier_type = line.detail[35..-1]
|
|
10
|
+
details.creditor_identifier_type = line.detail[35..-1]&.strip
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
CFONB::OperationDetails.register('IBE', self)
|
|
@@ -7,7 +7,7 @@ module CFONB
|
|
|
7
7
|
|
|
8
8
|
def self.apply(details, line)
|
|
9
9
|
details.debtor_identifier = line.detail[0..34].strip
|
|
10
|
-
details.debtor_identifier_type = line.detail[35..-1]
|
|
10
|
+
details.debtor_identifier_type = line.detail[35..-1]&.strip
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
CFONB::OperationDetails.register('IPY', self)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module CFONB
|
|
4
|
+
module OperationDetails
|
|
5
|
+
class Unknown < Base
|
|
6
|
+
ATTRIBUTES = %i[unknown].freeze
|
|
7
|
+
|
|
8
|
+
def self.apply(details, line)
|
|
9
|
+
details.unknown ||= {}
|
|
10
|
+
code = line.detail_code
|
|
11
|
+
|
|
12
|
+
details.unknown[code] =
|
|
13
|
+
if details.unknown[code] && line.detail.is_a?(String)
|
|
14
|
+
details.unknown[code] + "\n#{line.detail}"
|
|
15
|
+
else
|
|
16
|
+
line.detail
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
CFONB::OperationDetails.register('Unknown', self)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
data/lib/cfonb.rb
CHANGED
|
@@ -32,6 +32,7 @@ require_relative 'cfonb/operation_details/fee'
|
|
|
32
32
|
require_relative 'cfonb/operation_details/ibe'
|
|
33
33
|
require_relative 'cfonb/operation_details/npo'
|
|
34
34
|
require_relative 'cfonb/operation_details/nbu'
|
|
35
|
+
require_relative 'cfonb/operation_details/unknown'
|
|
35
36
|
|
|
36
37
|
module CFONB
|
|
37
38
|
def self.parse(input, optimistic: false)
|
|
@@ -272,6 +272,29 @@ describe CFONB::Operation do
|
|
|
272
272
|
expect(operation.details.ultimate_creditor).to eq('Patrick')
|
|
273
273
|
end
|
|
274
274
|
end
|
|
275
|
+
|
|
276
|
+
context 'with an unknown detail' do
|
|
277
|
+
let(:detail) do
|
|
278
|
+
OpenStruct.new(
|
|
279
|
+
body: '0530004411001871EUR2 0001016255614090823 AAAEUR200000000000740',
|
|
280
|
+
detail_code: 'AAA',
|
|
281
|
+
detail: 'EUR200000000000740',
|
|
282
|
+
)
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
it 'adds the detail to the unknown details hash' do
|
|
286
|
+
operation.merge_detail(detail)
|
|
287
|
+
|
|
288
|
+
expect(operation.details.unknown).to eq({ 'AAA' => 'EUR200000000000740' })
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
it 'updates the current details in case of duplicated codes' do
|
|
292
|
+
operation.merge_detail(detail)
|
|
293
|
+
operation.merge_detail(detail)
|
|
294
|
+
|
|
295
|
+
expect(operation.details.unknown).to eq({ 'AAA' => "EUR200000000000740\nEUR200000000000740" })
|
|
296
|
+
end
|
|
297
|
+
end
|
|
275
298
|
end
|
|
276
299
|
|
|
277
300
|
describe '#type_code' do
|
data/spec/cfonb/parser_spec.rb
CHANGED
|
@@ -43,12 +43,17 @@ describe CFONB::Parser do
|
|
|
43
43
|
reference: '',
|
|
44
44
|
)
|
|
45
45
|
expect(statements[0].operations[0].details).to have_attributes(
|
|
46
|
-
free_label:
|
|
46
|
+
free_label: "MENSUEAUHTR13133\nMENSUEAUHTR13DUP",
|
|
47
47
|
original_currency: nil,
|
|
48
48
|
original_amount: nil,
|
|
49
49
|
exchange_rate: nil,
|
|
50
50
|
purpose: 'PURPOSE',
|
|
51
51
|
debtor: 'INTERNET SFR',
|
|
52
|
+
unknown: {
|
|
53
|
+
'AAA' => "INTERNETA AAA\nINTERNETA ABB",
|
|
54
|
+
'BBB' => 'INTERNETE BBB',
|
|
55
|
+
'CCC' => 'INTERNETI CCC',
|
|
56
|
+
},
|
|
52
57
|
)
|
|
53
58
|
|
|
54
59
|
expect(statements[0].operations[1]).to have_attributes(
|
|
@@ -272,7 +277,7 @@ describe CFONB::Parser do
|
|
|
272
277
|
|
|
273
278
|
expect(statements[0].operations[0].details).to have_attributes(
|
|
274
279
|
operation_reference: 'REFERENCE',
|
|
275
|
-
free_label:
|
|
280
|
+
free_label: "MENSUEAUHTR13133\nMENSUEAUHTR13DUP",
|
|
276
281
|
debtor: 'INTERNET SFR',
|
|
277
282
|
client_reference: 'OTHER REFERENCE',
|
|
278
283
|
original_currency: nil,
|
|
@@ -705,7 +710,7 @@ describe CFONB::Parser do
|
|
|
705
710
|
expect(operation.details).to have_attributes(
|
|
706
711
|
operation_reference: 'REFERENCE',
|
|
707
712
|
client_reference: 'OTHER REFERENCE',
|
|
708
|
-
free_label: "MENSUEAUHTR13133\nP051928612 22793301700040",
|
|
713
|
+
free_label: "MENSUEAUHTR13133\nMENSUEAUHTR13DUP\nP051928612 22793301700040",
|
|
709
714
|
debtor: 'ELEC ERDF',
|
|
710
715
|
original_currency: nil,
|
|
711
716
|
original_amount: nil,
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cfonb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Johan Le Bray
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2024-
|
|
12
|
+
date: 2024-12-05 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: license_finder
|
|
@@ -112,6 +112,7 @@ files:
|
|
|
112
112
|
- lib/cfonb/operation_details/npy.rb
|
|
113
113
|
- lib/cfonb/operation_details/rcn.rb
|
|
114
114
|
- lib/cfonb/operation_details/ref.rb
|
|
115
|
+
- lib/cfonb/operation_details/unknown.rb
|
|
115
116
|
- lib/cfonb/parser.rb
|
|
116
117
|
- lib/cfonb/refinements/strings.rb
|
|
117
118
|
- lib/cfonb/statement.rb
|