Skip to content

Commit

Permalink
Add IPY operation detail (#22)
Browse files Browse the repository at this point in the history
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Frantisek Rokusek <[email protected]>
Co-authored-by: RDeckard <[email protected]>
  • Loading branch information
4 people authored Oct 31, 2024
1 parent 5e7b2a9 commit 23f2a03
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 89 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.ruby-version
Gemfile.lock
1 change: 0 additions & 1 deletion .ruby-version

This file was deleted.

2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '3.3.5'
gemspec

group :development do
# License
Expand Down
83 changes: 0 additions & 83 deletions Gemfile.lock

This file was deleted.

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ CFONB::OperationDetail.register('FEE', self)
| NPY | `debtor` | Name of the debtor or payer |
| RCN | `reference`, `purpose` | Client reference and Payment nature/purpose |
| REF | `operation_reference` | Bank operation reference |
| IPY | `debtor_identifier`, `debtor_identifier_type` | Debtor identifier and debtor identifier type |
| IBE | `creditor_identifier`, `creditor_identifier_type` | Creditor identifier and the type of identifier |
| NPO | `ultimate_debtor` | Name of the ultimate debtor or beneficiary |
| NBU | `ultimate_creditor` | Name of the ultimate creditor or payer |
Expand All @@ -59,6 +60,8 @@ TODO:
| Detail Code | Attributes | Description |
| --- | --- | --- |
| IPY | `debtor_identifier` | Identifier of the debtor or payer |
| NPO | `ultimate_debtor` | Name of the ultimate debtor or beneficiary |
| NBU | `ultimate_creditor` | Name of the ultimate creditor or payer |
| RET | `unifi_code`, `sit_code`, `payback_label` | Payback informations |
| CBE | `creditor_account` | Account of the creditor or beneficiary |
| BDB | `creditor_bank` | Bank of the creditor or beneficiary |
Expand Down
2 changes: 1 addition & 1 deletion cfonb.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Gem::Specification.new do |s|
s.name = 'cfonb'
s.version = '0.0.7'
s.required_ruby_version = '>= 3.2.2'
s.required_ruby_version = '>= 3.2'
s.summary = 'CFONB parser'
s.description = 'An easy to use CFONB format parser'
s.authors = ['Johan Le Bray', 'Frantisek Rokusek']
Expand Down
1 change: 1 addition & 0 deletions lib/cfonb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
require_relative 'cfonb/operation_detail/mmo'
require_relative 'cfonb/operation_detail/nbe'
require_relative 'cfonb/operation_detail/npy'
require_relative 'cfonb/operation_detail/ipy'
require_relative 'cfonb/operation_detail/rcn'
require_relative 'cfonb/operation_detail/ref'
require_relative 'cfonb/operation_detail/fee'
Expand Down
2 changes: 1 addition & 1 deletion lib/cfonb/line_parser/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Base
['bank', (2..6)],
['branch', (11..15)],
['currency', (16..18)],
['scale', 19, proc { _1.to_i }],
['scale', 19, proc { _1.to_i }], # rubocop:disable Style/SymbolProc
['account', (21..31)],
['date', (34..39), proc { |value, instance| instance.send(:parse_date, value) }],
].freeze
Expand Down
2 changes: 1 addition & 1 deletion lib/cfonb/line_parser/operation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Operation < Base
['rejection_code', (40..41)],
['value_date', (42..47), proc { |value, instance| instance.send(:parse_date, value) }],
['label', (48..79)],
['number', (81..87), proc { _1.to_i }],
['number', (81..87), proc { _1.to_i }], # rubocop:disable Style/SymbolProc
['exoneration_code', 88],
['unavailability_code', 89],
['reference', (104..119)],
Expand Down
16 changes: 16 additions & 0 deletions lib/cfonb/operation_detail/ipy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

module CFONB
module OperationDetail
class IPY
ATTRIBUTES = %i[debtor_identifier debtor_identifier_type].freeze

def self.apply(operation, line)
operation.debtor_identifier = line.detail[0..34].strip
operation.debtor_identifier_type = line.detail[35..-1].strip
end

CFONB::OperationDetail.register('IPY', self)
end
end
end
22 changes: 21 additions & 1 deletion spec/cfonb/operation_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

require 'cfonb'
require 'ostruct'
require 'securerandom'
require 'ostruct'

describe CFONB::Operation do
subject(:operation) { described_class.new(line) }
Expand Down Expand Up @@ -193,6 +193,26 @@
end
end

context 'with a IPY detail' do
let(:debtor_identifier) { SecureRandom.alphanumeric(35) }
let(:debtor_identifier_type) { SecureRandom.alphanumeric(35) }

let(:detail) do
OpenStruct.new(
body: "0530004411001871EUR2 0001016255614090823 IPY#{debtor_identifier}#{debtor_identifier_type}",
detail_code: 'IPY',
detail: "#{debtor_identifier}#{debtor_identifier_type}",
)
end

it 'adds the debtor_identifier' do
operation.merge_detail(detail)

expect(operation.debtor_identifier).to eq(debtor_identifier)
expect(operation.debtor_identifier_type).to eq(debtor_identifier_type)
end
end

context 'with a IBE detail' do
let(:creditor_identifier) { SecureRandom.alphanumeric(35) }
let(:creditor_identifier_type) { SecureRandom.alphanumeric(35) }
Expand Down

0 comments on commit 23f2a03

Please sign in to comment.