Skip to content

Commit

Permalink
Add granularity to Operation details
Browse files Browse the repository at this point in the history
  • Loading branch information
lauragilgz committed Oct 29, 2024
1 parent a996082 commit 00065d3
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 14 deletions.
4 changes: 2 additions & 2 deletions cfonb.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

Gem::Specification.new do |s|
s.name = 'cfonb'
s.version = '0.0.7'
s.required_ruby_version = '>= 3.2.2'
s.version = '1.0.0'
s.required_ruby_version = '>= 3.3.5'
s.summary = 'CFONB parser'
s.description = 'An easy to use CFONB format parser'
s.authors = ['Johan Le Bray', 'Frantisek Rokusek']
Expand Down
8 changes: 7 additions & 1 deletion lib/cfonb/operation_detail/lc2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
module CFONB
module OperationDetail
class LC2
ATTRIBUTES = %i[unstructured_label_2].freeze

def self.apply(operation, line)
operation.label += "\n#{line.detail.strip}"
operation.unstructured_label_2 = if operation.unstructured_label_2.nil?
line.detail.strip.to_s
else
"#{operation.unstructured_label_2}\n#{line.detail.strip}"
end
end

CFONB::OperationDetail.register('LC2', self)
Expand Down
8 changes: 7 additions & 1 deletion lib/cfonb/operation_detail/lcc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
module CFONB
module OperationDetail
class LCC
ATTRIBUTES = %i[unstructured_label].freeze

def self.apply(operation, line)
operation.label += "\n#{line.detail.strip}"
operation.unstructured_label = if operation.unstructured_label.nil?
line.detail.strip.to_s
else
"#{operation.unstructured_label}\n#{line.detail.strip}"
end
end

CFONB::OperationDetail.register('LCC', self)
Expand Down
10 changes: 9 additions & 1 deletion lib/cfonb/operation_detail/lcs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@
module CFONB
module OperationDetail
class LCS
ATTRIBUTES = %i[structured_label].freeze

def self.apply(operation, line)
operation.label += "\n#{line.detail[0..35].strip}"
formatted_label = line.detail[0..35].strip

operation.structured_label = if operation.structured_label.nil?
formatted_label.to_s
else
"#{operation.structured_label}\n#{formatted_label}"
end
end

CFONB::OperationDetail.register('LCS', self)
Expand Down
8 changes: 7 additions & 1 deletion lib/cfonb/operation_detail/lib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
module CFONB
module OperationDetail
class LIB
ATTRIBUTES = %i[free_label].freeze

def self.apply(operation, line)
operation.label += "\n#{line.detail.strip}"
operation.free_label = if operation.free_label.nil?
line.detail.strip.to_s
else
"#{operation.free_label}\n#{line.detail.strip}"
end
end

CFONB::OperationDetail.register('LIB', self)
Expand Down
12 changes: 12 additions & 0 deletions spec/cfonb/operation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@

expect(operation.label).to eq(<<~TXT.strip)
A random operation label
TXT

expect(operation.free_label).to eq(<<~TXT.strip)
Extra label
TXT
end
Expand All @@ -50,6 +53,9 @@

expect(operation.label).to eq(<<~TXT.strip)
A random operation label
TXT

expect(operation.unstructured_label).to eq(<<~TXT.strip)
Extra label
TXT
end
Expand All @@ -63,6 +69,9 @@

expect(operation.label).to eq(<<~TXT.strip)
A random operation label
TXT

expect(operation.unstructured_label_2).to eq(<<~TXT.strip)
Extra label
TXT
end
Expand All @@ -76,6 +85,9 @@

expect(operation.label).to eq(<<~TXT.strip)
A random operation label
TXT

expect(operation.structured_label).to eq(<<~TXT.strip)
Extra label
TXT
end
Expand Down
24 changes: 16 additions & 8 deletions spec/cfonb/parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
exoneration_code: '0',
interbank_code: 'B1',
internal_code: '9162',
label: "PRLV SEPA TEST CABINET\nMENSUEAUHTR13133",
label: 'PRLV SEPA TEST CABINET',
free_label: 'MENSUEAUHTR13133',
number: 0,
reference: 'REFERENCE - OTHER REFERENCE',
purpose: 'PURPOSE',
Expand Down Expand Up @@ -105,7 +106,8 @@
exoneration_code: '',
interbank_code: 'A3',
internal_code: '0158',
label: "PRLV SEPA GROUPAMA CEN\nP051928612 22793301700040",
label: 'PRLV SEPA GROUPAMA CEN',
free_label: 'P051928612 22793301700040',
number: 0,
reference: '',
rejection_code: '',
Expand Down Expand Up @@ -232,7 +234,8 @@
exoneration_code: '0',
interbank_code: 'B1',
internal_code: '9162',
label: "PRLV SEPA TEST CABINET\nMENSUEAUHTR13133",
label: 'PRLV SEPA TEST CABINET',
free_label: 'MENSUEAUHTR13133',
number: 0,
reference: 'REFERENCE - OTHER REFERENCE',
rejection_code: '',
Expand Down Expand Up @@ -301,7 +304,8 @@
exoneration_code: '',
interbank_code: 'A3',
internal_code: '0158',
label: "PRLV SEPA GROUPAMA CEN\nP051928612 22793301700040",
label: 'PRLV SEPA GROUPAMA CEN',
free_label: 'P051928612 22793301700040',
number: 0,
reference: '',
rejection_code: '',
Expand Down Expand Up @@ -503,7 +507,8 @@
exoneration_code: '0',
interbank_code: 'B1',
internal_code: '9162',
label: "PRLV SEPA TEST CABINET\nMENSUEAUHTR13133",
label: 'PRLV SEPA TEST CABINET',
free_label: 'MENSUEAUHTR13133',
number: 0,
reference: 'REFERENCE - OTHER REFERENCE',
rejection_code: '',
Expand Down Expand Up @@ -563,7 +568,8 @@
exoneration_code: '0',
interbank_code: 'B1',
internal_code: '9162',
label: "PRLV SEPA TEST CABINET\nMENSUEAUHTR13133",
label: 'PRLV SEPA TEST CABINET',
free_label: 'MENSUEAUHTR13133',
number: 0,
reference: 'REFERENCE - OTHER REFERENCE',
rejection_code: '',
Expand All @@ -588,7 +594,8 @@
exoneration_code: '0',
interbank_code: 'B1',
internal_code: '9162',
label: "PRLV SEPA TEST CABINET\nMENSUEAUHTR13133",
label: 'PRLV SEPA TEST CABINET',
free_label: 'MENSUEAUHTR13133',
number: 0,
reference: 'REFERENCE - OTHER REFERENCE',
rejection_code: '',
Expand Down Expand Up @@ -621,7 +628,8 @@
exoneration_code: '0',
interbank_code: 'B1',
internal_code: '9162',
label: "PRLV SEPA TEST CABINET\nMENSUEAUHTR13133\nP051928612 22793301700040",
label: 'PRLV SEPA TEST CABINET',
free_label: "MENSUEAUHTR13133\nP051928612 22793301700040",
number: 0,
reference: 'REFERENCE - OTHER REFERENCE',
rejection_code: '',
Expand Down

0 comments on commit 00065d3

Please sign in to comment.