cfonb 1.0.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 +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 +34 -0
- data/spec/cfonb/parser_spec.rb +9 -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: '09ba2c778bfad0f2b60f224bd4e13a67b9cb15d3f02062036c0a9ae7ed407b9e'
|
4
|
+
data.tar.gz: 13430b0b63638d05fc0127780b767bc746cdd5caaa65a671d017c4339111e63d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '097f4da9225e785f732dbedcd31e2465c2794a9533dbbaa4dd64d70f11cac80d2e57dbcc9f1346c72d055c351884649ded431b49114b4da4a9156155ac2d2eae'
|
7
|
+
data.tar.gz: eb270fd78d5cbbf9c1a05779f876859544687891099ecbf9236e42a7230da8f7b6b2c0ab4831495279e137919adcb8273d9a755b0b68e8d6440c02d5ab846c56
|
@@ -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.gsub(' ', '_')}"
|
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.gsub(' ', '_')
|
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,40 @@ 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 A AEUR200000000000740',
|
280
|
+
detail_code: 'A A',
|
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({ 'A_A' => '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({ 'A_A' => "EUR200000000000740\nEUR200000000000740" })
|
296
|
+
end
|
297
|
+
|
298
|
+
it 'does not add any detail if they are empty' do
|
299
|
+
detail = OpenStruct.new(
|
300
|
+
body: '0530004411001871EUR2 0001016255614090823',
|
301
|
+
detail_code: '',
|
302
|
+
detail: 'EUR200000000000740',
|
303
|
+
)
|
304
|
+
operation.merge_detail(detail)
|
305
|
+
|
306
|
+
expect(operation.details.unknown).to be_nil
|
307
|
+
end
|
308
|
+
end
|
275
309
|
end
|
276
310
|
|
277
311
|
describe '#type_code' do
|
data/spec/cfonb/parser_spec.rb
CHANGED
@@ -43,12 +43,18 @@ 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
|
+
'N_Y' => 'EXAMPLE WITH EMPTY SPACE',
|
57
|
+
},
|
52
58
|
)
|
53
59
|
|
54
60
|
expect(statements[0].operations[1]).to have_attributes(
|
@@ -272,7 +278,7 @@ describe CFONB::Parser do
|
|
272
278
|
|
273
279
|
expect(statements[0].operations[0].details).to have_attributes(
|
274
280
|
operation_reference: 'REFERENCE',
|
275
|
-
free_label:
|
281
|
+
free_label: "MENSUEAUHTR13133\nMENSUEAUHTR13DUP",
|
276
282
|
debtor: 'INTERNET SFR',
|
277
283
|
client_reference: 'OTHER REFERENCE',
|
278
284
|
original_currency: nil,
|
@@ -705,7 +711,7 @@ describe CFONB::Parser do
|
|
705
711
|
expect(operation.details).to have_attributes(
|
706
712
|
operation_reference: 'REFERENCE',
|
707
713
|
client_reference: 'OTHER REFERENCE',
|
708
|
-
free_label: "MENSUEAUHTR13133\nP051928612 22793301700040",
|
714
|
+
free_label: "MENSUEAUHTR13133\nMENSUEAUHTR13DUP\nP051928612 22793301700040",
|
709
715
|
debtor: 'ELEC ERDF',
|
710
716
|
original_currency: nil,
|
711
717
|
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.1
|
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-30 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
|