File tree 6 files changed +103
-0
lines changed 6 files changed +103
-0
lines changed Original file line number Diff line number Diff line change @@ -52,10 +52,14 @@ CFONB::OperationDetail.register('FEE', self)
52
52
| RCN | ` reference ` , ` purpose ` | Client reference and Payment nature/purpose |
53
53
| REF | ` operation_reference ` | Bank operation reference |
54
54
| IPY | ` debtor_identifier ` , ` debtor_identifier_type ` | Debtor identifier and debtor identifier type |
55
+ | IBE | ` creditor_identifier ` , ` creditor_identifier_type ` | Creditor identifier and the type of identifier |
56
+ | NPO | ` ultimate_debtor ` | Name of the ultimate debtor or beneficiary |
57
+ | NBU | ` ultimate_creditor ` | Name of the ultimate creditor or payer |
55
58
56
59
TODO:
57
60
| Detail Code | Attributes | Description |
58
61
| --- | --- | --- |
62
+ | IPY | ` debtor_identifier ` | Identifier of the debtor or payer |
59
63
| NPO | ` ultimate_debtor ` | Name of the ultimate debtor or beneficiary |
60
64
| NBU | ` ultimate_creditor ` | Name of the ultimate creditor or payer |
61
65
| RET | ` unifi_code ` , ` sit_code ` , ` payback_label ` | Payback informations |
Original file line number Diff line number Diff line change 28
28
require_relative 'cfonb/operation_detail/rcn'
29
29
require_relative 'cfonb/operation_detail/ref'
30
30
require_relative 'cfonb/operation_detail/fee'
31
+ require_relative 'cfonb/operation_detail/ibe'
32
+ require_relative 'cfonb/operation_detail/npo'
33
+ require_relative 'cfonb/operation_detail/nbu'
31
34
32
35
module CFONB
33
36
def self . parse ( input , optimistic : false )
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ module CFONB
4
+ module OperationDetail
5
+ class IBE
6
+ ATTRIBUTES = %i[ creditor_identifier creditor_identifier_type ] . freeze
7
+
8
+ def self . apply ( operation , line )
9
+ operation . creditor_identifier = line . detail [ 0 ..34 ] . strip
10
+ operation . creditor_identifier_type = line . detail [ 35 ..-1 ] . strip
11
+ end
12
+
13
+ CFONB ::OperationDetail . register ( 'IBE' , self )
14
+ end
15
+ end
16
+ end
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ module CFONB
4
+ module OperationDetail
5
+ class NBU
6
+ ATTRIBUTES = %i[ ultimate_creditor ] . freeze
7
+
8
+ def self . apply ( operation , line )
9
+ operation . ultimate_creditor = line . detail . strip
10
+ end
11
+
12
+ CFONB ::OperationDetail . register ( 'NBU' , self )
13
+ end
14
+ end
15
+ end
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ module CFONB
4
+ module OperationDetail
5
+ class NPO
6
+ ATTRIBUTES = %i[ ultimate_debtor ] . freeze
7
+
8
+ def self . apply ( operation , line )
9
+ operation . ultimate_debtor = line . detail . strip
10
+ end
11
+
12
+ CFONB ::OperationDetail . register ( 'NPO' , self )
13
+ end
14
+ end
15
+ end
Original file line number Diff line number Diff line change 3
3
require 'cfonb'
4
4
require 'securerandom'
5
5
require 'ostruct'
6
+ require 'securerandom'
6
7
7
8
describe CFONB ::Operation do
8
9
subject ( :operation ) { described_class . new ( line ) }
212
213
expect ( operation . debtor_identifier_type ) . to eq ( debtor_identifier_type )
213
214
end
214
215
end
216
+
217
+ context 'with a IBE detail' do
218
+ let ( :creditor_identifier ) { SecureRandom . alphanumeric ( 35 ) }
219
+ let ( :creditor_identifier_type ) { SecureRandom . alphanumeric ( 35 ) }
220
+
221
+ let ( :detail ) do
222
+ OpenStruct . new (
223
+ detail_code : 'IBE' ,
224
+ detail : "#{ creditor_identifier } #{ creditor_identifier_type } " ,
225
+ )
226
+ end
227
+
228
+ it 'adds the IBE information' do
229
+ operation . merge_detail ( detail )
230
+
231
+ expect ( operation . creditor_identifier ) . to eq ( creditor_identifier )
232
+ expect ( operation . creditor_identifier_type ) . to eq ( creditor_identifier_type )
233
+ end
234
+ end
235
+
236
+ context 'with a NPO detail' do
237
+ let ( :detail ) do
238
+ OpenStruct . new (
239
+ detail_code : 'NPO' ,
240
+ detail : 'Patrick ' ,
241
+ )
242
+ end
243
+
244
+ it 'adds the NPO information' do
245
+ operation . merge_detail ( detail )
246
+
247
+ expect ( operation . ultimate_debtor ) . to eq ( 'Patrick' )
248
+ end
249
+ end
250
+
251
+ context 'with a NBU detail' do
252
+ let ( :detail ) do
253
+ OpenStruct . new (
254
+ detail_code : 'NBU' ,
255
+ detail : 'Patrick ' ,
256
+ )
257
+ end
258
+
259
+ it 'adds the NBU information' do
260
+ operation . merge_detail ( detail )
261
+
262
+ expect ( operation . ultimate_creditor ) . to eq ( 'Patrick' )
263
+ end
264
+ end
215
265
end
216
266
217
267
describe '#type_code' do
You can’t perform that action at this time.
0 commit comments