cfonb 0.0.6 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cfonb/line_parser/base.rb +1 -1
- data/lib/cfonb/line_parser/operation.rb +1 -1
- data/lib/cfonb/line_parser/{operation_detail.rb → operation_details.rb} +1 -1
- data/lib/cfonb/operation.rb +6 -1
- data/lib/cfonb/operation_details/base.rb +19 -0
- data/lib/cfonb/operation_details/fee.rb +18 -0
- data/lib/cfonb/operation_details/ibe.rb +16 -0
- data/lib/cfonb/operation_details/ipy.rb +16 -0
- data/lib/cfonb/operation_details/lc2.rb +15 -0
- data/lib/cfonb/operation_details/lcc.rb +15 -0
- data/lib/cfonb/operation_details/lcs.rb +15 -0
- data/lib/cfonb/operation_details/lib.rb +15 -0
- data/lib/cfonb/operation_details/mmo.rb +26 -0
- data/lib/cfonb/operation_details/nbe.rb +15 -0
- data/lib/cfonb/operation_details/nbu.rb +15 -0
- data/lib/cfonb/operation_details/npo.rb +15 -0
- data/lib/cfonb/operation_details/npy.rb +15 -0
- data/lib/cfonb/operation_details/rcn.rb +18 -0
- data/lib/cfonb/operation_details/ref.rb +17 -0
- data/lib/cfonb/{operation_detail.rb → operation_details.rb} +2 -2
- data/lib/cfonb.rb +17 -12
- data/spec/cfonb/line_parser/{operation_detail_spec.rb → operation_details_spec.rb} +1 -1
- data/spec/cfonb/operation_spec.rb +108 -13
- data/spec/cfonb/parser_spec.rb +120 -41
- metadata +22 -17
- data/lib/cfonb/operation_detail/fee.rb +0 -18
- data/lib/cfonb/operation_detail/lc2.rb +0 -13
- data/lib/cfonb/operation_detail/lcc.rb +0 -13
- data/lib/cfonb/operation_detail/lcs.rb +0 -13
- data/lib/cfonb/operation_detail/lib.rb +0 -13
- data/lib/cfonb/operation_detail/mmo.rb +0 -27
- data/lib/cfonb/operation_detail/nbe.rb +0 -15
- data/lib/cfonb/operation_detail/npy.rb +0 -15
- data/lib/cfonb/operation_detail/rcn.rb +0 -22
- data/lib/cfonb/operation_detail/ref.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f80902862080f864dd6e69edc2f15d1d07d863fef754f47eb70bf052d4628cc2
|
4
|
+
data.tar.gz: 3258fdf0214ee434a09643ce033cc4fbf56500ad5d3633b3e424ed36f0d0a93d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0b35b9c4d7aa76957195c087e26f9777dad59308fcdb12a02c77da031d86798c726b3dc90e9fb9756c995414d34ce92f7d35638bed80fe10f5ff5c64e332659
|
7
|
+
data.tar.gz: b55fa730f6659cd878fa46a965a832bc3eb3b26e0fca3182a43af4b04bb4827995d73bfee61c7c1cb39674f01074f31a255ab060caf3fd0b3c0dc05a9c563f46
|
@@ -12,7 +12,7 @@ module CFONB
|
|
12
12
|
['bank', (2..6)],
|
13
13
|
['branch', (11..15)],
|
14
14
|
['currency', (16..18)],
|
15
|
-
['scale', 19, proc { _1.to_i }],
|
15
|
+
['scale', 19, proc { _1.to_i }], # rubocop:disable Style/SymbolProc
|
16
16
|
['account', (21..31)],
|
17
17
|
['date', (34..39), proc { |value, instance| instance.send(:parse_date, value) }],
|
18
18
|
].freeze
|
@@ -9,7 +9,7 @@ module CFONB
|
|
9
9
|
['rejection_code', (40..41)],
|
10
10
|
['value_date', (42..47), proc { |value, instance| instance.send(:parse_date, value) }],
|
11
11
|
['label', (48..79)],
|
12
|
-
['number', (81..87), proc { _1.to_i }],
|
12
|
+
['number', (81..87), proc { _1.to_i }], # rubocop:disable Style/SymbolProc
|
13
13
|
['exoneration_code', 88],
|
14
14
|
['unavailability_code', 89],
|
15
15
|
['reference', (104..119)],
|
data/lib/cfonb/operation.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module CFONB
|
4
|
+
Details = Class.new
|
5
|
+
|
4
6
|
class Operation
|
5
7
|
BASE_ATTRIBUTES = %i[
|
6
8
|
raw
|
@@ -16,6 +18,7 @@ module CFONB
|
|
16
18
|
rejection_code
|
17
19
|
unavailability_code
|
18
20
|
value_date
|
21
|
+
details
|
19
22
|
].freeze
|
20
23
|
|
21
24
|
attr_accessor(*BASE_ATTRIBUTES)
|
@@ -34,11 +37,13 @@ module CFONB
|
|
34
37
|
self.label = line.label.strip
|
35
38
|
self.number = line.number
|
36
39
|
self.reference = line.reference
|
40
|
+
self.details = Details.new
|
37
41
|
end
|
38
42
|
|
39
43
|
def merge_detail(line)
|
40
44
|
self.raw += "\n#{line.body}"
|
41
|
-
|
45
|
+
|
46
|
+
OperationDetails.for(line)&.apply(details, line)
|
42
47
|
end
|
43
48
|
|
44
49
|
def type_code
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CFONB
|
4
|
+
module OperationDetails
|
5
|
+
class Base
|
6
|
+
def self.inherited(base)
|
7
|
+
base.singleton_class.prepend(
|
8
|
+
Module.new do
|
9
|
+
def apply(details, line)
|
10
|
+
details.instance_variable_set(:"@#{line.detail_code}", line.detail)
|
11
|
+
|
12
|
+
super
|
13
|
+
end
|
14
|
+
end,
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CFONB
|
4
|
+
module OperationDetails
|
5
|
+
class FEE < Base
|
6
|
+
ATTRIBUTES = %i[fee fee_currency].freeze
|
7
|
+
|
8
|
+
def self.apply(details, line)
|
9
|
+
details.fee_currency = line.detail[0..2]
|
10
|
+
scale = line.detail[3].to_i
|
11
|
+
|
12
|
+
details.fee = BigDecimal(line.detail[4..17]) / (10**scale)
|
13
|
+
end
|
14
|
+
|
15
|
+
CFONB::OperationDetails.register('FEE', self)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CFONB
|
4
|
+
module OperationDetails
|
5
|
+
class IBE < Base
|
6
|
+
ATTRIBUTES = %i[creditor_identifier creditor_identifier_type].freeze
|
7
|
+
|
8
|
+
def self.apply(details, line)
|
9
|
+
details.creditor_identifier = line.detail[0..34].strip
|
10
|
+
details.creditor_identifier_type = line.detail[35..-1].strip
|
11
|
+
end
|
12
|
+
|
13
|
+
CFONB::OperationDetails.register('IBE', self)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CFONB
|
4
|
+
module OperationDetails
|
5
|
+
class IPY < Base
|
6
|
+
ATTRIBUTES = %i[debtor_identifier debtor_identifier_type].freeze
|
7
|
+
|
8
|
+
def self.apply(details, line)
|
9
|
+
details.debtor_identifier = line.detail[0..34].strip
|
10
|
+
details.debtor_identifier_type = line.detail[35..-1].strip
|
11
|
+
end
|
12
|
+
|
13
|
+
CFONB::OperationDetails.register('IPY', self)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CFONB
|
4
|
+
module OperationDetails
|
5
|
+
class LC2 < Base
|
6
|
+
ATTRIBUTES = %i[unstructured_label_2].freeze
|
7
|
+
|
8
|
+
def self.apply(details, line)
|
9
|
+
details.unstructured_label_2 = line.detail.strip
|
10
|
+
end
|
11
|
+
|
12
|
+
CFONB::OperationDetails.register('LC2', self)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CFONB
|
4
|
+
module OperationDetails
|
5
|
+
class LCC < Base
|
6
|
+
ATTRIBUTES = %i[unstructured_label].freeze
|
7
|
+
|
8
|
+
def self.apply(details, line)
|
9
|
+
details.unstructured_label = line.detail.strip.to_s
|
10
|
+
end
|
11
|
+
|
12
|
+
CFONB::OperationDetails.register('LCC', self)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CFONB
|
4
|
+
module OperationDetails
|
5
|
+
class LCS < Base
|
6
|
+
ATTRIBUTES = %i[structured_label].freeze
|
7
|
+
|
8
|
+
def self.apply(details, line)
|
9
|
+
details.structured_label = line.detail[0..35].strip
|
10
|
+
end
|
11
|
+
|
12
|
+
CFONB::OperationDetails.register('LCS', self)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CFONB
|
4
|
+
module OperationDetails
|
5
|
+
class LIB < Base
|
6
|
+
ATTRIBUTES = %i[free_label].freeze
|
7
|
+
|
8
|
+
def self.apply(details, line)
|
9
|
+
details.free_label = [details.free_label, line.detail.strip].compact.join("\n")
|
10
|
+
end
|
11
|
+
|
12
|
+
CFONB::OperationDetails.register('LIB', self)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bigdecimal'
|
4
|
+
|
5
|
+
module CFONB
|
6
|
+
module OperationDetails
|
7
|
+
class MMO < Base
|
8
|
+
ATTRIBUTES = %i[original_currency original_amount exchange_rate].freeze
|
9
|
+
|
10
|
+
def self.apply(details, line)
|
11
|
+
details.original_currency = line.detail[0..2]
|
12
|
+
scale = line.detail[3].to_i
|
13
|
+
|
14
|
+
details.original_amount = BigDecimal(line.detail[4..17]) / (10**scale)
|
15
|
+
exchange_rate_value = line.detail[26..29]
|
16
|
+
|
17
|
+
return if exchange_rate_value.nil? || exchange_rate_value.strip.empty?
|
18
|
+
|
19
|
+
exchange_rate_scale = line.detail[18]
|
20
|
+
details.exchange_rate = BigDecimal(exchange_rate_value) / (10**BigDecimal(exchange_rate_scale))
|
21
|
+
end
|
22
|
+
|
23
|
+
CFONB::OperationDetails.register('MMO', self)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CFONB
|
4
|
+
module OperationDetails
|
5
|
+
class NBE < Base
|
6
|
+
ATTRIBUTES = %i[creditor].freeze
|
7
|
+
|
8
|
+
def self.apply(details, line)
|
9
|
+
details.creditor = line.detail.strip
|
10
|
+
end
|
11
|
+
|
12
|
+
CFONB::OperationDetails.register('NBE', self)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CFONB
|
4
|
+
module OperationDetails
|
5
|
+
class NBU < Base
|
6
|
+
ATTRIBUTES = %i[ultimate_creditor].freeze
|
7
|
+
|
8
|
+
def self.apply(details, line)
|
9
|
+
details.ultimate_creditor = line.detail.strip
|
10
|
+
end
|
11
|
+
|
12
|
+
CFONB::OperationDetails.register('NBU', self)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CFONB
|
4
|
+
module OperationDetails
|
5
|
+
class NPO < Base
|
6
|
+
ATTRIBUTES = %i[ultimate_debtor].freeze
|
7
|
+
|
8
|
+
def self.apply(details, line)
|
9
|
+
details.ultimate_debtor = line.detail.strip
|
10
|
+
end
|
11
|
+
|
12
|
+
CFONB::OperationDetails.register('NPO', self)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CFONB
|
4
|
+
module OperationDetails
|
5
|
+
class NPY < Base
|
6
|
+
ATTRIBUTES = %i[debtor].freeze
|
7
|
+
|
8
|
+
def self.apply(details, line)
|
9
|
+
details.debtor = line.detail.strip
|
10
|
+
end
|
11
|
+
|
12
|
+
CFONB::OperationDetails.register('NPY', self)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CFONB
|
4
|
+
module OperationDetails
|
5
|
+
class RCN < Base
|
6
|
+
using CFONB::Refinements::Strings
|
7
|
+
|
8
|
+
ATTRIBUTES = %i[client_reference purpose].freeze
|
9
|
+
|
10
|
+
def self.apply(details, line)
|
11
|
+
details.client_reference = line.detail[0..34].strip
|
12
|
+
details.purpose = line.detail[35..-1]&.strip
|
13
|
+
end
|
14
|
+
|
15
|
+
CFONB::OperationDetails.register('RCN', self)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CFONB
|
4
|
+
module OperationDetails
|
5
|
+
class REF < Base
|
6
|
+
using CFONB::Refinements::Strings
|
7
|
+
|
8
|
+
ATTRIBUTES = %i[operation_reference].freeze
|
9
|
+
|
10
|
+
def self.apply(details, line)
|
11
|
+
details.operation_reference = line.detail.strip
|
12
|
+
end
|
13
|
+
|
14
|
+
CFONB::OperationDetails.register('REF', self)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module CFONB
|
4
|
-
module
|
4
|
+
module OperationDetails
|
5
5
|
@details = {}
|
6
6
|
|
7
7
|
def self.register(code, klass)
|
8
8
|
if klass.const_defined?(:ATTRIBUTES)
|
9
|
-
|
9
|
+
CFONB::Details.class_eval do
|
10
10
|
attr_accessor(*klass::ATTRIBUTES)
|
11
11
|
end
|
12
12
|
end
|
data/lib/cfonb.rb
CHANGED
@@ -8,25 +8,30 @@ require_relative 'cfonb/error'
|
|
8
8
|
require_relative 'cfonb/parser'
|
9
9
|
require_relative 'cfonb/statement'
|
10
10
|
require_relative 'cfonb/operation'
|
11
|
-
require_relative 'cfonb/
|
11
|
+
require_relative 'cfonb/operation_details'
|
12
12
|
|
13
13
|
require_relative 'cfonb/line_parser'
|
14
14
|
require_relative 'cfonb/line_parser/base'
|
15
15
|
require_relative 'cfonb/line_parser/previous_balance'
|
16
16
|
require_relative 'cfonb/line_parser/operation'
|
17
|
-
require_relative 'cfonb/line_parser/
|
17
|
+
require_relative 'cfonb/line_parser/operation_details'
|
18
18
|
require_relative 'cfonb/line_parser/new_balance'
|
19
19
|
|
20
|
-
require_relative 'cfonb/
|
21
|
-
require_relative 'cfonb/
|
22
|
-
require_relative 'cfonb/
|
23
|
-
require_relative 'cfonb/
|
24
|
-
require_relative 'cfonb/
|
25
|
-
require_relative 'cfonb/
|
26
|
-
require_relative 'cfonb/
|
27
|
-
require_relative 'cfonb/
|
28
|
-
require_relative 'cfonb/
|
29
|
-
require_relative 'cfonb/
|
20
|
+
require_relative 'cfonb/operation_details/base'
|
21
|
+
require_relative 'cfonb/operation_details/lib'
|
22
|
+
require_relative 'cfonb/operation_details/lcc'
|
23
|
+
require_relative 'cfonb/operation_details/lc2'
|
24
|
+
require_relative 'cfonb/operation_details/lcs'
|
25
|
+
require_relative 'cfonb/operation_details/mmo'
|
26
|
+
require_relative 'cfonb/operation_details/nbe'
|
27
|
+
require_relative 'cfonb/operation_details/npy'
|
28
|
+
require_relative 'cfonb/operation_details/ipy'
|
29
|
+
require_relative 'cfonb/operation_details/rcn'
|
30
|
+
require_relative 'cfonb/operation_details/ref'
|
31
|
+
require_relative 'cfonb/operation_details/fee'
|
32
|
+
require_relative 'cfonb/operation_details/ibe'
|
33
|
+
require_relative 'cfonb/operation_details/npo'
|
34
|
+
require_relative 'cfonb/operation_details/nbu'
|
30
35
|
|
31
36
|
module CFONB
|
32
37
|
def self.parse(input, optimistic: false)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'cfonb'
|
4
|
+
require 'securerandom'
|
4
5
|
require 'ostruct'
|
5
6
|
|
6
7
|
describe CFONB::Operation do
|
@@ -36,6 +37,9 @@ describe CFONB::Operation do
|
|
36
37
|
|
37
38
|
expect(operation.label).to eq(<<~TXT.strip)
|
38
39
|
A random operation label
|
40
|
+
TXT
|
41
|
+
|
42
|
+
expect(operation.details.free_label).to eq(<<~TXT.strip)
|
39
43
|
Extra label
|
40
44
|
TXT
|
41
45
|
end
|
@@ -49,6 +53,9 @@ describe CFONB::Operation do
|
|
49
53
|
|
50
54
|
expect(operation.label).to eq(<<~TXT.strip)
|
51
55
|
A random operation label
|
56
|
+
TXT
|
57
|
+
|
58
|
+
expect(operation.details.unstructured_label).to eq(<<~TXT.strip)
|
52
59
|
Extra label
|
53
60
|
TXT
|
54
61
|
end
|
@@ -62,6 +69,9 @@ describe CFONB::Operation do
|
|
62
69
|
|
63
70
|
expect(operation.label).to eq(<<~TXT.strip)
|
64
71
|
A random operation label
|
72
|
+
TXT
|
73
|
+
|
74
|
+
expect(operation.details.unstructured_label_2).to eq(<<~TXT.strip)
|
65
75
|
Extra label
|
66
76
|
TXT
|
67
77
|
end
|
@@ -75,6 +85,9 @@ describe CFONB::Operation do
|
|
75
85
|
|
76
86
|
expect(operation.label).to eq(<<~TXT.strip)
|
77
87
|
A random operation label
|
88
|
+
TXT
|
89
|
+
|
90
|
+
expect(operation.details.structured_label).to eq(<<~TXT.strip)
|
78
91
|
Extra label
|
79
92
|
TXT
|
80
93
|
end
|
@@ -86,9 +99,9 @@ describe CFONB::Operation do
|
|
86
99
|
it 'Adds the original currency information' do
|
87
100
|
operation.merge_detail(detail)
|
88
101
|
|
89
|
-
expect(operation).to have_attributes(
|
102
|
+
expect(operation.details).to have_attributes(
|
90
103
|
original_currency: 'USD',
|
91
|
-
original_amount:
|
104
|
+
original_amount: 12.34,
|
92
105
|
exchange_rate: nil,
|
93
106
|
)
|
94
107
|
end
|
@@ -99,13 +112,26 @@ describe CFONB::Operation do
|
|
99
112
|
it 'Adds the original currency information' do
|
100
113
|
operation.merge_detail(detail)
|
101
114
|
|
102
|
-
expect(operation).to have_attributes(
|
115
|
+
expect(operation.details).to have_attributes(
|
103
116
|
original_currency: 'USD',
|
104
|
-
original_amount:
|
117
|
+
original_amount: 8358,
|
105
118
|
exchange_rate: 1.077,
|
106
119
|
)
|
107
120
|
end
|
108
121
|
end
|
122
|
+
|
123
|
+
context 'when exchange rate is missing' do
|
124
|
+
let(:detail) { OpenStruct.new(body: '', detail_code: 'MMO', detail: 'EUR200000001875625 04') }
|
125
|
+
|
126
|
+
it 'Adds the original currency information' do
|
127
|
+
operation.merge_detail(detail)
|
128
|
+
expect(operation.details).to have_attributes(
|
129
|
+
original_currency: 'EUR',
|
130
|
+
original_amount: 18_756.25,
|
131
|
+
exchange_rate: nil,
|
132
|
+
)
|
133
|
+
end
|
134
|
+
end
|
109
135
|
end
|
110
136
|
|
111
137
|
context 'with a NPY detail' do
|
@@ -114,7 +140,7 @@ describe CFONB::Operation do
|
|
114
140
|
it 'Adds the debtor information' do
|
115
141
|
operation.merge_detail(detail)
|
116
142
|
|
117
|
-
expect(operation).to have_attributes(debtor: 'Patrick')
|
143
|
+
expect(operation.details).to have_attributes(debtor: 'Patrick')
|
118
144
|
end
|
119
145
|
end
|
120
146
|
|
@@ -124,7 +150,7 @@ describe CFONB::Operation do
|
|
124
150
|
it 'Adds the creditor information' do
|
125
151
|
operation.merge_detail(detail)
|
126
152
|
|
127
|
-
expect(operation).to have_attributes(creditor: 'Jean-Pierre')
|
153
|
+
expect(operation.details).to have_attributes(creditor: 'Jean-Pierre')
|
128
154
|
end
|
129
155
|
end
|
130
156
|
|
@@ -137,11 +163,11 @@ describe CFONB::Operation do
|
|
137
163
|
)
|
138
164
|
end
|
139
165
|
|
140
|
-
it 'adds the reference information' do
|
166
|
+
it 'adds the client reference information' do
|
141
167
|
operation.merge_detail(detail)
|
142
168
|
|
143
|
-
expect(operation.
|
144
|
-
expect(operation.purpose).to eq('TICKET RESTO')
|
169
|
+
expect(operation.details.client_reference).to eq('SWILE-CMD-TR-YPDHMA')
|
170
|
+
expect(operation.details.purpose).to eq('TICKET RESTO')
|
145
171
|
end
|
146
172
|
end
|
147
173
|
|
@@ -154,10 +180,10 @@ describe CFONB::Operation do
|
|
154
180
|
)
|
155
181
|
end
|
156
182
|
|
157
|
-
it 'adds the reference information' do
|
183
|
+
it 'adds the operation reference information' do
|
158
184
|
operation.merge_detail(detail)
|
159
185
|
|
160
|
-
expect(operation.
|
186
|
+
expect(operation.details.operation_reference).to eq('PENNYLANE B13A93908C36C82DF5C319/1')
|
161
187
|
end
|
162
188
|
end
|
163
189
|
|
@@ -173,8 +199,77 @@ describe CFONB::Operation do
|
|
173
199
|
it 'adds the fee information' do
|
174
200
|
operation.merge_detail(detail)
|
175
201
|
|
176
|
-
expect(operation.fee_currency).to eq('EUR')
|
177
|
-
expect(operation.fee).to eq(7.4)
|
202
|
+
expect(operation.details.fee_currency).to eq('EUR')
|
203
|
+
expect(operation.details.fee).to eq(7.4)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
context 'with a IPY detail' do
|
208
|
+
let(:debtor_identifier) { SecureRandom.alphanumeric(35) }
|
209
|
+
let(:debtor_identifier_type) { SecureRandom.alphanumeric(35) }
|
210
|
+
|
211
|
+
let(:detail) do
|
212
|
+
OpenStruct.new(
|
213
|
+
body: "0530004411001871EUR2 0001016255614090823 IPY#{debtor_identifier}#{debtor_identifier_type}",
|
214
|
+
detail_code: 'IPY',
|
215
|
+
detail: "#{debtor_identifier}#{debtor_identifier_type}",
|
216
|
+
)
|
217
|
+
end
|
218
|
+
|
219
|
+
it 'adds the debtor_identifier' do
|
220
|
+
operation.merge_detail(detail)
|
221
|
+
|
222
|
+
expect(operation.details.debtor_identifier).to eq(debtor_identifier)
|
223
|
+
expect(operation.details.debtor_identifier_type).to eq(debtor_identifier_type)
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
context 'with a IBE detail' do
|
228
|
+
let(:creditor_identifier) { SecureRandom.alphanumeric(35) }
|
229
|
+
let(:creditor_identifier_type) { SecureRandom.alphanumeric(35) }
|
230
|
+
|
231
|
+
let(:detail) do
|
232
|
+
OpenStruct.new(
|
233
|
+
detail_code: 'IBE',
|
234
|
+
detail: "#{creditor_identifier}#{creditor_identifier_type}",
|
235
|
+
)
|
236
|
+
end
|
237
|
+
|
238
|
+
it 'adds the IBE information' do
|
239
|
+
operation.merge_detail(detail)
|
240
|
+
|
241
|
+
expect(operation.details.creditor_identifier).to eq(creditor_identifier)
|
242
|
+
expect(operation.details.creditor_identifier_type).to eq(creditor_identifier_type)
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
context 'with a NPO detail' do
|
247
|
+
let(:detail) do
|
248
|
+
OpenStruct.new(
|
249
|
+
detail_code: 'NPO',
|
250
|
+
detail: 'Patrick ',
|
251
|
+
)
|
252
|
+
end
|
253
|
+
|
254
|
+
it 'adds the NPO information' do
|
255
|
+
operation.merge_detail(detail)
|
256
|
+
|
257
|
+
expect(operation.details.ultimate_debtor).to eq('Patrick')
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
context 'with a NBU detail' do
|
262
|
+
let(:detail) do
|
263
|
+
OpenStruct.new(
|
264
|
+
detail_code: 'NBU',
|
265
|
+
detail: 'Patrick ',
|
266
|
+
)
|
267
|
+
end
|
268
|
+
|
269
|
+
it 'adds the NBU information' do
|
270
|
+
operation.merge_detail(detail)
|
271
|
+
|
272
|
+
expect(operation.details.ultimate_creditor).to eq('Patrick')
|
178
273
|
end
|
179
274
|
end
|
180
275
|
end
|
data/spec/cfonb/parser_spec.rb
CHANGED
@@ -35,16 +35,19 @@ describe CFONB::Parser do
|
|
35
35
|
exoneration_code: '0',
|
36
36
|
interbank_code: 'B1',
|
37
37
|
internal_code: '9162',
|
38
|
-
label:
|
38
|
+
label: 'PRLV SEPA TEST CABINET',
|
39
39
|
number: 0,
|
40
|
-
reference: 'REFERENCE - OTHER REFERENCE',
|
41
|
-
purpose: 'PURPOSE',
|
42
40
|
rejection_code: '',
|
43
41
|
unavailability_code: '0',
|
44
42
|
value_date: Date.new(2019, 5, 16),
|
43
|
+
reference: '',
|
44
|
+
)
|
45
|
+
expect(statements[0].operations[0].details).to have_attributes(
|
46
|
+
free_label: 'MENSUEAUHTR13133',
|
45
47
|
original_currency: nil,
|
46
48
|
original_amount: nil,
|
47
49
|
exchange_rate: nil,
|
50
|
+
purpose: 'PURPOSE',
|
48
51
|
debtor: 'INTERNET SFR',
|
49
52
|
)
|
50
53
|
|
@@ -57,14 +60,19 @@ describe CFONB::Parser do
|
|
57
60
|
internal_code: '9162',
|
58
61
|
label: 'VIR SEPA DEMONSTRATION',
|
59
62
|
number: 0,
|
60
|
-
reference: 'REFERENCE',
|
61
63
|
rejection_code: '',
|
62
64
|
unavailability_code: '0',
|
63
65
|
value_date: Date.new(2019, 5, 16),
|
66
|
+
reference: 'REFERENCE',
|
67
|
+
)
|
68
|
+
|
69
|
+
expect(statements[0].operations[1].details).to have_attributes(
|
70
|
+
debtor: 'ELEC ERDF',
|
71
|
+
free_label: nil,
|
64
72
|
original_currency: nil,
|
65
73
|
original_amount: nil,
|
66
74
|
exchange_rate: nil,
|
67
|
-
|
75
|
+
purpose: nil,
|
68
76
|
)
|
69
77
|
|
70
78
|
expect(statements[0].operations[2]).to have_attributes(
|
@@ -76,10 +84,15 @@ describe CFONB::Parser do
|
|
76
84
|
internal_code: '0117',
|
77
85
|
label: 'F COMMISSION D INTERVENTION',
|
78
86
|
number: 0,
|
79
|
-
reference: '',
|
80
87
|
rejection_code: '',
|
81
88
|
unavailability_code: '0',
|
82
89
|
value_date: Date.new(2019, 5, 15),
|
90
|
+
reference: '',
|
91
|
+
)
|
92
|
+
|
93
|
+
expect(statements[0].operations[2].details).to have_attributes(
|
94
|
+
free_label: nil,
|
95
|
+
purpose: nil,
|
83
96
|
original_currency: nil,
|
84
97
|
original_amount: nil,
|
85
98
|
exchange_rate: nil,
|
@@ -105,15 +118,21 @@ describe CFONB::Parser do
|
|
105
118
|
exoneration_code: '',
|
106
119
|
interbank_code: 'A3',
|
107
120
|
internal_code: '0158',
|
108
|
-
label:
|
121
|
+
label: 'PRLV SEPA GROUPAMA CEN',
|
109
122
|
number: 0,
|
110
|
-
reference: '',
|
111
123
|
rejection_code: '',
|
112
124
|
unavailability_code: '0',
|
113
125
|
value_date: Date.new(2019, 5, 15),
|
126
|
+
reference: '',
|
127
|
+
)
|
128
|
+
|
129
|
+
expect(statements[1].operations[0].details).to have_attributes(
|
130
|
+
free_label: 'P051928612 22793301700040',
|
114
131
|
original_currency: nil,
|
115
132
|
original_amount: nil,
|
116
133
|
exchange_rate: nil,
|
134
|
+
purpose: nil,
|
135
|
+
debtor: nil,
|
117
136
|
)
|
118
137
|
|
119
138
|
expect(statements[1].operations[1]).to have_attributes(
|
@@ -125,13 +144,19 @@ describe CFONB::Parser do
|
|
125
144
|
internal_code: '0337',
|
126
145
|
label: 'F FRAIS PRLV IMP 97 49EUR',
|
127
146
|
number: 0,
|
128
|
-
reference: '',
|
129
147
|
rejection_code: '',
|
130
148
|
unavailability_code: '0',
|
131
149
|
value_date: Date.new(2019, 5, 15),
|
150
|
+
reference: '',
|
151
|
+
)
|
152
|
+
|
153
|
+
expect(statements[1].operations[1].details).to have_attributes(
|
154
|
+
free_label: nil,
|
132
155
|
original_currency: nil,
|
133
156
|
original_amount: nil,
|
134
157
|
exchange_rate: nil,
|
158
|
+
purpose: nil,
|
159
|
+
debtor: nil,
|
135
160
|
)
|
136
161
|
|
137
162
|
expect(statements[1].operations[2]).to have_attributes(
|
@@ -143,13 +168,19 @@ describe CFONB::Parser do
|
|
143
168
|
internal_code: '0117',
|
144
169
|
label: 'F COMMISSION D INTERVENTION',
|
145
170
|
number: 0,
|
146
|
-
reference: '',
|
147
171
|
rejection_code: '',
|
148
172
|
unavailability_code: '0',
|
149
173
|
value_date: Date.new(2019, 5, 16),
|
174
|
+
reference: '',
|
175
|
+
)
|
176
|
+
|
177
|
+
expect(statements[1].operations[2].details).to have_attributes(
|
178
|
+
free_label: nil,
|
150
179
|
original_currency: nil,
|
151
180
|
original_amount: nil,
|
152
181
|
exchange_rate: nil,
|
182
|
+
purpose: nil,
|
183
|
+
debtor: nil,
|
153
184
|
)
|
154
185
|
end
|
155
186
|
end
|
@@ -232,18 +263,22 @@ describe CFONB::Parser do
|
|
232
263
|
exoneration_code: '0',
|
233
264
|
interbank_code: 'B1',
|
234
265
|
internal_code: '9162',
|
235
|
-
label:
|
266
|
+
label: 'PRLV SEPA TEST CABINET',
|
236
267
|
number: 0,
|
237
|
-
reference: 'REFERENCE - OTHER REFERENCE',
|
238
268
|
rejection_code: '',
|
239
269
|
unavailability_code: '0',
|
240
270
|
value_date: Date.new(2019, 5, 16),
|
271
|
+
)
|
272
|
+
|
273
|
+
expect(statements[0].operations[0].details).to have_attributes(
|
274
|
+
operation_reference: 'REFERENCE',
|
275
|
+
free_label: 'MENSUEAUHTR13133',
|
276
|
+
debtor: 'INTERNET SFR',
|
277
|
+
client_reference: 'OTHER REFERENCE',
|
241
278
|
original_currency: nil,
|
242
279
|
original_amount: nil,
|
243
280
|
exchange_rate: nil,
|
244
|
-
debtor: 'INTERNET SFR',
|
245
281
|
)
|
246
|
-
|
247
282
|
expect(statements[0].operations[1]).to have_attributes(
|
248
283
|
amount: -10.7,
|
249
284
|
currency: 'EUR',
|
@@ -253,10 +288,13 @@ describe CFONB::Parser do
|
|
253
288
|
internal_code: '9162',
|
254
289
|
label: 'VIR SEPA DEMONSTRATION',
|
255
290
|
number: 0,
|
256
|
-
reference: 'REFERENCE',
|
257
291
|
rejection_code: '',
|
258
292
|
unavailability_code: '0',
|
259
293
|
value_date: Date.new(2019, 5, 16),
|
294
|
+
reference: 'REFERENCE',
|
295
|
+
)
|
296
|
+
|
297
|
+
expect(statements[0].operations[1].details).to have_attributes(
|
260
298
|
original_currency: nil,
|
261
299
|
original_amount: nil,
|
262
300
|
exchange_rate: nil,
|
@@ -272,10 +310,13 @@ describe CFONB::Parser do
|
|
272
310
|
internal_code: '0117',
|
273
311
|
label: 'F COMMISSION D INTERVENTION',
|
274
312
|
number: 0,
|
275
|
-
reference: '',
|
276
313
|
rejection_code: '',
|
277
314
|
unavailability_code: '0',
|
278
315
|
value_date: Date.new(2019, 5, 15),
|
316
|
+
reference: '',
|
317
|
+
)
|
318
|
+
|
319
|
+
expect(statements[0].operations[2].details).to have_attributes(
|
279
320
|
original_currency: nil,
|
280
321
|
original_amount: nil,
|
281
322
|
exchange_rate: nil,
|
@@ -301,12 +342,16 @@ describe CFONB::Parser do
|
|
301
342
|
exoneration_code: '',
|
302
343
|
interbank_code: 'A3',
|
303
344
|
internal_code: '0158',
|
304
|
-
label:
|
345
|
+
label: 'PRLV SEPA GROUPAMA CEN',
|
305
346
|
number: 0,
|
306
|
-
reference: '',
|
307
347
|
rejection_code: '',
|
308
348
|
unavailability_code: '0',
|
309
349
|
value_date: Date.new(2019, 5, 15),
|
350
|
+
reference: '',
|
351
|
+
)
|
352
|
+
|
353
|
+
expect(statements[1].operations[0].details).to have_attributes(
|
354
|
+
free_label: 'P051928612 22793301700040',
|
310
355
|
original_currency: nil,
|
311
356
|
original_amount: nil,
|
312
357
|
exchange_rate: nil,
|
@@ -321,10 +366,13 @@ describe CFONB::Parser do
|
|
321
366
|
internal_code: '0337',
|
322
367
|
label: 'F FRAIS PRLV IMP 97 49EUR',
|
323
368
|
number: 0,
|
324
|
-
reference: '',
|
325
369
|
rejection_code: '',
|
326
370
|
unavailability_code: '0',
|
327
371
|
value_date: Date.new(2019, 5, 15),
|
372
|
+
reference: '',
|
373
|
+
)
|
374
|
+
|
375
|
+
expect(statements[1].operations[1].details).to have_attributes(
|
328
376
|
original_currency: nil,
|
329
377
|
original_amount: nil,
|
330
378
|
exchange_rate: nil,
|
@@ -339,10 +387,13 @@ describe CFONB::Parser do
|
|
339
387
|
internal_code: '0117',
|
340
388
|
label: 'F COMMISSION D INTERVENTION',
|
341
389
|
number: 0,
|
342
|
-
reference: '',
|
343
390
|
rejection_code: '',
|
344
391
|
unavailability_code: '0',
|
345
392
|
value_date: Date.new(2019, 5, 16),
|
393
|
+
reference: '',
|
394
|
+
)
|
395
|
+
|
396
|
+
expect(statements[1].operations[2].details).to have_attributes(
|
346
397
|
original_currency: nil,
|
347
398
|
original_amount: nil,
|
348
399
|
exchange_rate: nil,
|
@@ -365,14 +416,17 @@ describe CFONB::Parser do
|
|
365
416
|
internal_code: '9162',
|
366
417
|
label: 'VIR SEPA DEMONSTRATION',
|
367
418
|
number: 0,
|
368
|
-
reference: '',
|
369
419
|
rejection_code: '',
|
370
420
|
unavailability_code: '0',
|
371
421
|
value_date: Date.new(2019, 5, 16),
|
422
|
+
reference: '',
|
423
|
+
)
|
424
|
+
|
425
|
+
expect(statements[0].operations[0].details).to have_attributes(
|
426
|
+
debtor: 'ELEC ERDF',
|
372
427
|
original_currency: nil,
|
373
428
|
original_amount: nil,
|
374
429
|
exchange_rate: nil,
|
375
|
-
debtor: 'ELEC ERDF',
|
376
430
|
)
|
377
431
|
end
|
378
432
|
end
|
@@ -392,14 +446,16 @@ describe CFONB::Parser do
|
|
392
446
|
internal_code: '9162',
|
393
447
|
label: 'VIR SEPA DEMONSTRATION',
|
394
448
|
number: 0,
|
395
|
-
reference: '',
|
396
449
|
rejection_code: '',
|
397
450
|
unavailability_code: '0',
|
398
451
|
value_date: Date.new(2019, 5, 16),
|
452
|
+
reference: '',
|
453
|
+
)
|
454
|
+
expect(statements[0].operations[0].details).to have_attributes(
|
455
|
+
debtor: 'ELEC ERDF',
|
399
456
|
original_currency: nil,
|
400
457
|
original_amount: nil,
|
401
458
|
exchange_rate: nil,
|
402
|
-
debtor: 'ELEC ERDF',
|
403
459
|
)
|
404
460
|
end
|
405
461
|
end
|
@@ -419,14 +475,16 @@ describe CFONB::Parser do
|
|
419
475
|
internal_code: '9162',
|
420
476
|
label: 'VIR SEPA DEMONSTRATION',
|
421
477
|
number: 0,
|
422
|
-
reference: '',
|
423
478
|
rejection_code: '',
|
424
479
|
unavailability_code: '0',
|
425
480
|
value_date: Date.new(2019, 5, 16),
|
481
|
+
reference: '',
|
482
|
+
)
|
483
|
+
expect(statements[0].operations[0].details).to have_attributes(
|
484
|
+
debtor: 'ELEC ERDF',
|
426
485
|
original_currency: nil,
|
427
486
|
original_amount: nil,
|
428
487
|
exchange_rate: nil,
|
429
|
-
debtor: 'ELEC ERDF',
|
430
488
|
)
|
431
489
|
end
|
432
490
|
end
|
@@ -446,14 +504,16 @@ describe CFONB::Parser do
|
|
446
504
|
internal_code: '9162',
|
447
505
|
label: 'VIR SEPA DEMONSTRATION',
|
448
506
|
number: 0,
|
449
|
-
reference: '',
|
450
507
|
rejection_code: '',
|
451
508
|
unavailability_code: '0',
|
452
509
|
value_date: Date.new(2019, 5, 16),
|
510
|
+
reference: '',
|
511
|
+
)
|
512
|
+
expect(statements[0].operations[0].details).to have_attributes(
|
513
|
+
debtor: 'ELEC ERDF',
|
453
514
|
original_currency: nil,
|
454
515
|
original_amount: nil,
|
455
516
|
exchange_rate: nil,
|
456
|
-
debtor: 'ELEC ERDF',
|
457
517
|
)
|
458
518
|
expect(statements[0].operations[1]).to have_attributes(
|
459
519
|
amount: -7.9,
|
@@ -464,10 +524,12 @@ describe CFONB::Parser do
|
|
464
524
|
internal_code: '0117',
|
465
525
|
label: 'F COMMISSION D INTERVENTION',
|
466
526
|
number: 0,
|
467
|
-
reference: '',
|
468
527
|
rejection_code: '',
|
469
528
|
unavailability_code: '0',
|
470
529
|
value_date: Date.new(2019, 5, 16),
|
530
|
+
reference: '',
|
531
|
+
)
|
532
|
+
expect(statements[0].operations[1].details).to have_attributes(
|
471
533
|
original_currency: nil,
|
472
534
|
original_amount: nil,
|
473
535
|
exchange_rate: nil,
|
@@ -503,16 +565,20 @@ describe CFONB::Parser do
|
|
503
565
|
exoneration_code: '0',
|
504
566
|
interbank_code: 'B1',
|
505
567
|
internal_code: '9162',
|
506
|
-
label:
|
568
|
+
label: 'PRLV SEPA TEST CABINET',
|
507
569
|
number: 0,
|
508
|
-
reference: 'REFERENCE - OTHER REFERENCE',
|
509
570
|
rejection_code: '',
|
510
571
|
unavailability_code: '0',
|
511
572
|
value_date: Date.new(2019, 5, 16),
|
573
|
+
)
|
574
|
+
expect(operation.details).to have_attributes(
|
575
|
+
operation_reference: 'REFERENCE',
|
576
|
+
client_reference: 'OTHER REFERENCE',
|
577
|
+
debtor: 'INTERNET SFR',
|
578
|
+
free_label: 'MENSUEAUHTR13133',
|
512
579
|
original_currency: nil,
|
513
580
|
original_amount: nil,
|
514
581
|
exchange_rate: nil,
|
515
|
-
debtor: 'INTERNET SFR',
|
516
582
|
)
|
517
583
|
end
|
518
584
|
end
|
@@ -563,16 +629,20 @@ describe CFONB::Parser do
|
|
563
629
|
exoneration_code: '0',
|
564
630
|
interbank_code: 'B1',
|
565
631
|
internal_code: '9162',
|
566
|
-
label:
|
632
|
+
label: 'PRLV SEPA TEST CABINET',
|
567
633
|
number: 0,
|
568
|
-
reference: 'REFERENCE - OTHER REFERENCE',
|
569
634
|
rejection_code: '',
|
570
635
|
unavailability_code: '0',
|
571
636
|
value_date: Date.new(2019, 5, 16),
|
637
|
+
)
|
638
|
+
expect(operation.details).to have_attributes(
|
639
|
+
operation_reference: 'REFERENCE',
|
640
|
+
client_reference: 'OTHER REFERENCE',
|
641
|
+
free_label: 'MENSUEAUHTR13133',
|
642
|
+
debtor: 'INTERNET SFR',
|
572
643
|
original_currency: nil,
|
573
644
|
original_amount: nil,
|
574
645
|
exchange_rate: nil,
|
575
|
-
debtor: 'INTERNET SFR',
|
576
646
|
)
|
577
647
|
end
|
578
648
|
end
|
@@ -588,16 +658,20 @@ describe CFONB::Parser do
|
|
588
658
|
exoneration_code: '0',
|
589
659
|
interbank_code: 'B1',
|
590
660
|
internal_code: '9162',
|
591
|
-
label:
|
661
|
+
label: 'PRLV SEPA TEST CABINET',
|
592
662
|
number: 0,
|
593
|
-
reference: 'REFERENCE - OTHER REFERENCE',
|
594
663
|
rejection_code: '',
|
595
664
|
unavailability_code: '0',
|
596
665
|
value_date: Date.new(2019, 5, 16),
|
666
|
+
)
|
667
|
+
expect(operation.details).to have_attributes(
|
668
|
+
client_reference: 'OTHER REFERENCE',
|
669
|
+
operation_reference: 'REFERENCE',
|
670
|
+
free_label: 'MENSUEAUHTR13133',
|
671
|
+
debtor: 'INTERNET SFR',
|
597
672
|
original_currency: nil,
|
598
673
|
original_amount: nil,
|
599
674
|
exchange_rate: nil,
|
600
|
-
debtor: 'INTERNET SFR',
|
601
675
|
)
|
602
676
|
end
|
603
677
|
end
|
@@ -621,16 +695,21 @@ describe CFONB::Parser do
|
|
621
695
|
exoneration_code: '0',
|
622
696
|
interbank_code: 'B1',
|
623
697
|
internal_code: '9162',
|
624
|
-
label:
|
698
|
+
label: 'PRLV SEPA TEST CABINET',
|
625
699
|
number: 0,
|
626
|
-
reference: 'REFERENCE - OTHER REFERENCE',
|
627
700
|
rejection_code: '',
|
628
701
|
unavailability_code: '0',
|
629
702
|
value_date: Date.new(2019, 5, 16),
|
703
|
+
)
|
704
|
+
|
705
|
+
expect(operation.details).to have_attributes(
|
706
|
+
operation_reference: 'REFERENCE',
|
707
|
+
client_reference: 'OTHER REFERENCE',
|
708
|
+
free_label: "MENSUEAUHTR13133\nP051928612 22793301700040",
|
709
|
+
debtor: 'ELEC ERDF',
|
630
710
|
original_currency: nil,
|
631
711
|
original_amount: nil,
|
632
712
|
exchange_rate: nil,
|
633
|
-
debtor: 'ELEC ERDF',
|
634
713
|
)
|
635
714
|
end
|
636
715
|
end
|
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: 0.0
|
4
|
+
version: 1.0.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:
|
12
|
+
date: 2024-11-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: license_finder
|
@@ -93,25 +93,30 @@ files:
|
|
93
93
|
- lib/cfonb/line_parser/base.rb
|
94
94
|
- lib/cfonb/line_parser/new_balance.rb
|
95
95
|
- lib/cfonb/line_parser/operation.rb
|
96
|
-
- lib/cfonb/line_parser/
|
96
|
+
- lib/cfonb/line_parser/operation_details.rb
|
97
97
|
- lib/cfonb/line_parser/previous_balance.rb
|
98
98
|
- lib/cfonb/operation.rb
|
99
|
-
- lib/cfonb/
|
100
|
-
- lib/cfonb/
|
101
|
-
- lib/cfonb/
|
102
|
-
- lib/cfonb/
|
103
|
-
- lib/cfonb/
|
104
|
-
- lib/cfonb/
|
105
|
-
- lib/cfonb/
|
106
|
-
- lib/cfonb/
|
107
|
-
- lib/cfonb/
|
108
|
-
- lib/cfonb/
|
109
|
-
- lib/cfonb/
|
99
|
+
- lib/cfonb/operation_details.rb
|
100
|
+
- lib/cfonb/operation_details/base.rb
|
101
|
+
- lib/cfonb/operation_details/fee.rb
|
102
|
+
- lib/cfonb/operation_details/ibe.rb
|
103
|
+
- lib/cfonb/operation_details/ipy.rb
|
104
|
+
- lib/cfonb/operation_details/lc2.rb
|
105
|
+
- lib/cfonb/operation_details/lcc.rb
|
106
|
+
- lib/cfonb/operation_details/lcs.rb
|
107
|
+
- lib/cfonb/operation_details/lib.rb
|
108
|
+
- lib/cfonb/operation_details/mmo.rb
|
109
|
+
- lib/cfonb/operation_details/nbe.rb
|
110
|
+
- lib/cfonb/operation_details/nbu.rb
|
111
|
+
- lib/cfonb/operation_details/npo.rb
|
112
|
+
- lib/cfonb/operation_details/npy.rb
|
113
|
+
- lib/cfonb/operation_details/rcn.rb
|
114
|
+
- lib/cfonb/operation_details/ref.rb
|
110
115
|
- lib/cfonb/parser.rb
|
111
116
|
- lib/cfonb/refinements/strings.rb
|
112
117
|
- lib/cfonb/statement.rb
|
113
118
|
- spec/cfonb/line_parser/new_balance_spec.rb
|
114
|
-
- spec/cfonb/line_parser/
|
119
|
+
- spec/cfonb/line_parser/operation_details_spec.rb
|
115
120
|
- spec/cfonb/line_parser/operation_spec.rb
|
116
121
|
- spec/cfonb/line_parser/previous_balance_spec.rb
|
117
122
|
- spec/cfonb/operation_spec.rb
|
@@ -129,14 +134,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
129
134
|
requirements:
|
130
135
|
- - ">="
|
131
136
|
- !ruby/object:Gem::Version
|
132
|
-
version: 3.2
|
137
|
+
version: '3.2'
|
133
138
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
139
|
requirements:
|
135
140
|
- - ">="
|
136
141
|
- !ruby/object:Gem::Version
|
137
142
|
version: '0'
|
138
143
|
requirements: []
|
139
|
-
rubygems_version: 3.
|
144
|
+
rubygems_version: 3.5.16
|
140
145
|
signing_key:
|
141
146
|
specification_version: 4
|
142
147
|
summary: CFONB parser
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module CFONB
|
4
|
-
module OperationDetail
|
5
|
-
class FEE
|
6
|
-
ATTRIBUTES = %i[fee fee_currency].freeze
|
7
|
-
|
8
|
-
def self.apply(operation, line)
|
9
|
-
operation.fee_currency = line.detail[0..2]
|
10
|
-
scale = line.detail[3].to_i
|
11
|
-
|
12
|
-
operation.fee = BigDecimal(line.detail[4..17]) / (10**scale)
|
13
|
-
end
|
14
|
-
|
15
|
-
CFONB::OperationDetail.register('FEE', self)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'bigdecimal'
|
4
|
-
|
5
|
-
module CFONB
|
6
|
-
module OperationDetail
|
7
|
-
class MMO
|
8
|
-
ATTRIBUTES = %i[original_currency original_amount exchange_rate].freeze
|
9
|
-
|
10
|
-
def self.apply(operation, line)
|
11
|
-
operation.original_currency = line.detail[0..2]
|
12
|
-
|
13
|
-
scale = line.detail[3].to_i
|
14
|
-
sign = operation.amount <=> 0 # the detail amount is unsigned
|
15
|
-
|
16
|
-
operation.original_amount = sign * BigDecimal(line.detail[4..17]) / (10**scale)
|
17
|
-
exchange_rate_value = line.detail[26..29]
|
18
|
-
return unless exchange_rate_value
|
19
|
-
|
20
|
-
exchange_rate_scale = line.detail[18]
|
21
|
-
operation.exchange_rate = BigDecimal(exchange_rate_value) / (10**BigDecimal(exchange_rate_scale))
|
22
|
-
end
|
23
|
-
|
24
|
-
CFONB::OperationDetail.register('MMO', self)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module CFONB
|
4
|
-
module OperationDetail
|
5
|
-
class NBE
|
6
|
-
ATTRIBUTES = %i[creditor].freeze
|
7
|
-
|
8
|
-
def self.apply(operation, line)
|
9
|
-
operation.creditor = line.detail.strip
|
10
|
-
end
|
11
|
-
|
12
|
-
CFONB::OperationDetail.register('NBE', self)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module CFONB
|
4
|
-
module OperationDetail
|
5
|
-
class NPY
|
6
|
-
ATTRIBUTES = %i[debtor].freeze
|
7
|
-
|
8
|
-
def self.apply(operation, line)
|
9
|
-
operation.debtor = line.detail.strip
|
10
|
-
end
|
11
|
-
|
12
|
-
CFONB::OperationDetail.register('NPY', self)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module CFONB
|
4
|
-
module OperationDetail
|
5
|
-
class RCN
|
6
|
-
using CFONB::Refinements::Strings
|
7
|
-
|
8
|
-
ATTRIBUTES = %i[reference purpose].freeze
|
9
|
-
|
10
|
-
def self.apply(operation, line)
|
11
|
-
operation.reference = [
|
12
|
-
operation.reference,
|
13
|
-
line.detail[0..34].strip,
|
14
|
-
].filter_map(&:presence).join(' - ')
|
15
|
-
|
16
|
-
operation.purpose = line.detail[35..-1]&.strip
|
17
|
-
end
|
18
|
-
|
19
|
-
CFONB::OperationDetail.register('RCN', self)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module CFONB
|
4
|
-
module OperationDetail
|
5
|
-
class REF
|
6
|
-
using CFONB::Refinements::Strings
|
7
|
-
|
8
|
-
ATTRIBUTES = %i[reference].freeze
|
9
|
-
|
10
|
-
def self.apply(operation, line)
|
11
|
-
operation.reference = [
|
12
|
-
operation.reference,
|
13
|
-
line.detail.strip,
|
14
|
-
].filter_map(&:presence).join(' - ')
|
15
|
-
end
|
16
|
-
|
17
|
-
CFONB::OperationDetail.register('REF', self)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|