Skip to content

Commit cebc226

Browse files
committed
Merge branch 'master' into lg/Add-IPY-Operation-detail
2 parents 59840fd + 5e7b2a9 commit cebc226

File tree

6 files changed

+103
-0
lines changed

6 files changed

+103
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,14 @@ CFONB::OperationDetail.register('FEE', self)
5252
| RCN | `reference`, `purpose` | Client reference and Payment nature/purpose |
5353
| REF | `operation_reference` | Bank operation reference |
5454
| 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 |
5558

5659
TODO:
5760
| Detail Code | Attributes | Description |
5861
| --- | --- | --- |
62+
| IPY | `debtor_identifier` | Identifier of the debtor or payer |
5963
| NPO | `ultimate_debtor` | Name of the ultimate debtor or beneficiary |
6064
| NBU | `ultimate_creditor` | Name of the ultimate creditor or payer |
6165
| RET | `unifi_code`, `sit_code`, `payback_label` | Payback informations |

lib/cfonb.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
require_relative 'cfonb/operation_detail/rcn'
2929
require_relative 'cfonb/operation_detail/ref'
3030
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'
3134

3235
module CFONB
3336
def self.parse(input, optimistic: false)

lib/cfonb/operation_detail/ibe.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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

lib/cfonb/operation_detail/nbu.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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

lib/cfonb/operation_detail/npo.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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

spec/cfonb/operation_spec.rb

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
require 'cfonb'
44
require 'securerandom'
55
require 'ostruct'
6+
require 'securerandom'
67

78
describe CFONB::Operation do
89
subject(:operation) { described_class.new(line) }
@@ -212,6 +213,55 @@
212213
expect(operation.debtor_identifier_type).to eq(debtor_identifier_type)
213214
end
214215
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
215265
end
216266

217267
describe '#type_code' do

0 commit comments

Comments
 (0)