diff --git a/README.md b/README.md index 7ab0a18..f2e8878 100644 --- a/README.md +++ b/README.md @@ -30,38 +30,37 @@ gem 'cfonb' ## Available Operation Details `OperationDetails` are lines starting with `05`. They aim at providing additional information about the operation. +Below is the list of additional details available for each operation. -Find bellow the list of additional details available for each operation. -If you encouter new ones, please open an issue or a pull request with the appropriate implementation. +These details can be accessed through `operation.details`, which will provide all the attributes. To fetch a specific attribute, you can use `operation.details.attribute`. For example, `operation.details.unstructured_label`. Ultimately, you can also access the 70 characters of the detail by using its code like `operation.details.mmo` + +If you encounter new ones, please open an issue or a pull request with the appropriate implementation. We aimed at making it as easy as possible to add new details. You just need to do the following on initialization: ```ruby CFONB::OperationDetails.register('FEE', self) ``` -| Detail Code | Attributes | Description | -| ----------- | --------------------------------------------------------------------------------------- | -------------------------------------------------------------------- | -| FEE | `fee`, `fee_currency` | Represents operation fees the bank is applying | -| LCC | `unstructured_label` | Not structured label line 1 (first 70 characters) | -| LC2 | `unstructured_label_2` | Not structured label line 2 (last 70 characters) | -| LCS | `structured_label` | Structured label | -| LIB | `free_label` | Free label | -| MMO | `original_currency`, `original_amount`, `scale`, `exchange_rate`, `exchange_rate_scale` | Amount and currency if it has been converted from a foreign currency | -| NBE | `creditor` | Name of the creditor or beneficiary | -| 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 | +| Detail Code | Attributes | Description | +| ----------- | ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | +| FEE | `fee`, `fee_currency` | Represents operation fees the bank is applying | +| 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 | +| LC2 | `unstructured_label_2` | Not structured label line 2 (last 70 characters) | +| LCC | `unstructured_label` | Not structured label line 1 (first 70 characters) | +| LCS | `structured_label` | Structured label | +| LIB | `free_label` | Free label | +| MMO | `original_currency`, `original_amount`, `exchange_rate` | Amount and currency if it has been converted from a foreign currency. The `original_amount` is unsigned, meaning it is always non-negative. | +| NBE | `creditor` | Name of the creditor or beneficiary | +| NBU | `ultimate_creditor` | Name of the ultimate creditor or payer | +| NPO | `ultimate_debtor` | Name of the ultimate debtor or beneficiary | +| NPY | `debtor` | Name of the debtor or payer | +| RCN | `client_reference`, `purpose` | Client reference and Payment nature/purpose | +| REF | `operation_reference` | Bank operation reference | 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 | diff --git a/cfonb.gemspec b/cfonb.gemspec index f3d542c..9949e72 100644 --- a/cfonb.gemspec +++ b/cfonb.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |s| s.name = 'cfonb' - s.version = '0.0.7' + s.version = '1.0.0' s.required_ruby_version = '>= 3.2' s.summary = 'CFONB parser' s.description = 'An easy to use CFONB format parser' diff --git a/lib/cfonb/operation.rb b/lib/cfonb/operation.rb index 38e333f..44180d7 100644 --- a/lib/cfonb/operation.rb +++ b/lib/cfonb/operation.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true module CFONB + Details = Class.new + class Operation BASE_ATTRIBUTES = %i[ raw @@ -16,6 +18,7 @@ class Operation rejection_code unavailability_code value_date + details ].freeze attr_accessor(*BASE_ATTRIBUTES) @@ -34,11 +37,13 @@ def initialize(line) self.label = line.label.strip self.number = line.number self.reference = line.reference + self.details = Details.new end def merge_detail(line) self.raw += "\n#{line.body}" - OperationDetails.for(line)&.apply(self, line) + + OperationDetails.for(line)&.apply(details, line) end def type_code diff --git a/lib/cfonb/operation_details.rb b/lib/cfonb/operation_details.rb index c0d154f..f9bde87 100644 --- a/lib/cfonb/operation_details.rb +++ b/lib/cfonb/operation_details.rb @@ -6,7 +6,7 @@ module OperationDetails def self.register(code, klass) if klass.const_defined?(:ATTRIBUTES) - Operation.class_eval do + CFONB::Details.class_eval do attr_accessor(*klass::ATTRIBUTES) end end diff --git a/lib/cfonb/operation_details/base.rb b/lib/cfonb/operation_details/base.rb index 8a78911..5c80a98 100644 --- a/lib/cfonb/operation_details/base.rb +++ b/lib/cfonb/operation_details/base.rb @@ -6,8 +6,8 @@ class Base def self.inherited(base) base.singleton_class.prepend( Module.new do - def apply(operation, line) - operation.instance_variable_set(:"@#{line.detail_code}", line.detail) + def apply(details, line) + details.instance_variable_set(:"@#{line.detail_code}", line.detail) super end diff --git a/lib/cfonb/operation_details/fee.rb b/lib/cfonb/operation_details/fee.rb index c633fe8..bf874a3 100644 --- a/lib/cfonb/operation_details/fee.rb +++ b/lib/cfonb/operation_details/fee.rb @@ -5,11 +5,11 @@ module OperationDetails class FEE < Base ATTRIBUTES = %i[fee fee_currency].freeze - def self.apply(operation, line) - operation.fee_currency = line.detail[0..2] + def self.apply(details, line) + details.fee_currency = line.detail[0..2] scale = line.detail[3].to_i - operation.fee = BigDecimal(line.detail[4..17]) / (10**scale) + details.fee = BigDecimal(line.detail[4..17]) / (10**scale) end CFONB::OperationDetails.register('FEE', self) diff --git a/lib/cfonb/operation_details/ibe.rb b/lib/cfonb/operation_details/ibe.rb index 3e49f94..ad8b8b6 100644 --- a/lib/cfonb/operation_details/ibe.rb +++ b/lib/cfonb/operation_details/ibe.rb @@ -5,9 +5,9 @@ module OperationDetails class IBE < Base ATTRIBUTES = %i[creditor_identifier creditor_identifier_type].freeze - def self.apply(operation, line) - operation.creditor_identifier = line.detail[0..34].strip - operation.creditor_identifier_type = line.detail[35..-1].strip + def self.apply(details, line) + details.creditor_identifier = line.detail[0..34].strip + details.creditor_identifier_type = line.detail[35..-1].strip end CFONB::OperationDetails.register('IBE', self) diff --git a/lib/cfonb/operation_details/ipy.rb b/lib/cfonb/operation_details/ipy.rb index b9eb9ac..754f0d1 100644 --- a/lib/cfonb/operation_details/ipy.rb +++ b/lib/cfonb/operation_details/ipy.rb @@ -5,9 +5,9 @@ module OperationDetails class IPY < Base 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 + def self.apply(details, line) + details.debtor_identifier = line.detail[0..34].strip + details.debtor_identifier_type = line.detail[35..-1].strip end CFONB::OperationDetails.register('IPY', self) diff --git a/lib/cfonb/operation_details/lc2.rb b/lib/cfonb/operation_details/lc2.rb index 419abbd..264f032 100644 --- a/lib/cfonb/operation_details/lc2.rb +++ b/lib/cfonb/operation_details/lc2.rb @@ -3,8 +3,10 @@ module CFONB module OperationDetails class LC2 < Base - def self.apply(operation, line) - operation.label += "\n#{line.detail.strip}" + ATTRIBUTES = %i[unstructured_label_2].freeze + + def self.apply(details, line) + details.unstructured_label_2 = line.detail.strip end CFONB::OperationDetails.register('LC2', self) diff --git a/lib/cfonb/operation_details/lcc.rb b/lib/cfonb/operation_details/lcc.rb index f41df5a..1bd7341 100644 --- a/lib/cfonb/operation_details/lcc.rb +++ b/lib/cfonb/operation_details/lcc.rb @@ -3,8 +3,10 @@ module CFONB module OperationDetails class LCC < Base - def self.apply(operation, line) - operation.label += "\n#{line.detail.strip}" + ATTRIBUTES = %i[unstructured_label].freeze + + def self.apply(details, line) + details.unstructured_label = line.detail.strip.to_s end CFONB::OperationDetails.register('LCC', self) diff --git a/lib/cfonb/operation_details/lcs.rb b/lib/cfonb/operation_details/lcs.rb index 1a567f8..81052f8 100644 --- a/lib/cfonb/operation_details/lcs.rb +++ b/lib/cfonb/operation_details/lcs.rb @@ -3,8 +3,10 @@ module CFONB module OperationDetails class LCS < Base - def self.apply(operation, line) - operation.label += "\n#{line.detail[0..35].strip}" + ATTRIBUTES = %i[structured_label].freeze + + def self.apply(details, line) + details.structured_label = line.detail[0..35].strip end CFONB::OperationDetails.register('LCS', self) diff --git a/lib/cfonb/operation_details/lib.rb b/lib/cfonb/operation_details/lib.rb index 40f2a2e..cbf92a9 100644 --- a/lib/cfonb/operation_details/lib.rb +++ b/lib/cfonb/operation_details/lib.rb @@ -3,8 +3,10 @@ module CFONB module OperationDetails class LIB < Base - def self.apply(operation, line) - operation.label += "\n#{line.detail.strip}" + ATTRIBUTES = %i[free_label].freeze + + def self.apply(details, line) + details.free_label = [details.free_label, line.detail.strip].compact.join("\n") end CFONB::OperationDetails.register('LIB', self) diff --git a/lib/cfonb/operation_details/mmo.rb b/lib/cfonb/operation_details/mmo.rb index 8a39d54..27889cd 100644 --- a/lib/cfonb/operation_details/mmo.rb +++ b/lib/cfonb/operation_details/mmo.rb @@ -7,19 +7,17 @@ module OperationDetails class MMO < Base ATTRIBUTES = %i[original_currency original_amount exchange_rate].freeze - def self.apply(operation, line) - operation.original_currency = line.detail[0..2] - + def self.apply(details, line) + details.original_currency = line.detail[0..2] scale = line.detail[3].to_i - sign = operation.amount <=> 0 # the detail amount is unsigned - operation.original_amount = sign * BigDecimal(line.detail[4..17]) / (10**scale) + details.original_amount = BigDecimal(line.detail[4..17]) / (10**scale) exchange_rate_value = line.detail[26..29] return if exchange_rate_value.nil? || exchange_rate_value.strip.empty? exchange_rate_scale = line.detail[18] - operation.exchange_rate = BigDecimal(exchange_rate_value) / (10**BigDecimal(exchange_rate_scale)) + details.exchange_rate = BigDecimal(exchange_rate_value) / (10**BigDecimal(exchange_rate_scale)) end CFONB::OperationDetails.register('MMO', self) diff --git a/lib/cfonb/operation_details/nbe.rb b/lib/cfonb/operation_details/nbe.rb index 02ba66b..795c251 100644 --- a/lib/cfonb/operation_details/nbe.rb +++ b/lib/cfonb/operation_details/nbe.rb @@ -5,8 +5,8 @@ module OperationDetails class NBE < Base ATTRIBUTES = %i[creditor].freeze - def self.apply(operation, line) - operation.creditor = line.detail.strip + def self.apply(details, line) + details.creditor = line.detail.strip end CFONB::OperationDetails.register('NBE', self) diff --git a/lib/cfonb/operation_details/nbu.rb b/lib/cfonb/operation_details/nbu.rb index c999748..8ed5141 100644 --- a/lib/cfonb/operation_details/nbu.rb +++ b/lib/cfonb/operation_details/nbu.rb @@ -5,8 +5,8 @@ module OperationDetails class NBU < Base ATTRIBUTES = %i[ultimate_creditor].freeze - def self.apply(operation, line) - operation.ultimate_creditor = line.detail.strip + def self.apply(details, line) + details.ultimate_creditor = line.detail.strip end CFONB::OperationDetails.register('NBU', self) diff --git a/lib/cfonb/operation_details/npo.rb b/lib/cfonb/operation_details/npo.rb index 8a0a1f6..5ae833a 100644 --- a/lib/cfonb/operation_details/npo.rb +++ b/lib/cfonb/operation_details/npo.rb @@ -5,8 +5,8 @@ module OperationDetails class NPO < Base ATTRIBUTES = %i[ultimate_debtor].freeze - def self.apply(operation, line) - operation.ultimate_debtor = line.detail.strip + def self.apply(details, line) + details.ultimate_debtor = line.detail.strip end CFONB::OperationDetails.register('NPO', self) diff --git a/lib/cfonb/operation_details/npy.rb b/lib/cfonb/operation_details/npy.rb index 7a9cd0d..6cf2f58 100644 --- a/lib/cfonb/operation_details/npy.rb +++ b/lib/cfonb/operation_details/npy.rb @@ -5,8 +5,8 @@ module OperationDetails class NPY < Base ATTRIBUTES = %i[debtor].freeze - def self.apply(operation, line) - operation.debtor = line.detail.strip + def self.apply(details, line) + details.debtor = line.detail.strip end CFONB::OperationDetails.register('NPY', self) diff --git a/lib/cfonb/operation_details/rcn.rb b/lib/cfonb/operation_details/rcn.rb index e9d91f3..ba9d7ce 100644 --- a/lib/cfonb/operation_details/rcn.rb +++ b/lib/cfonb/operation_details/rcn.rb @@ -5,15 +5,11 @@ module OperationDetails class RCN < Base using CFONB::Refinements::Strings - ATTRIBUTES = %i[reference purpose].freeze + ATTRIBUTES = %i[client_reference purpose].freeze - def self.apply(operation, line) - operation.reference = [ - operation.reference, - line.detail[0..34].strip, - ].filter_map(&:presence).join(' - ') - - operation.purpose = line.detail[35..-1]&.strip + def self.apply(details, line) + details.client_reference = line.detail[0..34].strip + details.purpose = line.detail[35..-1]&.strip end CFONB::OperationDetails.register('RCN', self) diff --git a/lib/cfonb/operation_details/ref.rb b/lib/cfonb/operation_details/ref.rb index f71cf59..9ef73c5 100644 --- a/lib/cfonb/operation_details/ref.rb +++ b/lib/cfonb/operation_details/ref.rb @@ -5,13 +5,10 @@ module OperationDetails class REF < Base using CFONB::Refinements::Strings - ATTRIBUTES = %i[reference].freeze + ATTRIBUTES = %i[operation_reference].freeze - def self.apply(operation, line) - operation.reference = [ - operation.reference, - line.detail.strip, - ].filter_map(&:presence).join(' - ') + def self.apply(details, line) + details.operation_reference = line.detail.strip end CFONB::OperationDetails.register('REF', self) diff --git a/spec/cfonb/operation_spec.rb b/spec/cfonb/operation_spec.rb index 36f854c..d31a56f 100644 --- a/spec/cfonb/operation_spec.rb +++ b/spec/cfonb/operation_spec.rb @@ -37,6 +37,9 @@ expect(operation.label).to eq(<<~TXT.strip) A random operation label + TXT + + expect(operation.details.free_label).to eq(<<~TXT.strip) Extra label TXT end @@ -50,6 +53,9 @@ expect(operation.label).to eq(<<~TXT.strip) A random operation label + TXT + + expect(operation.details.unstructured_label).to eq(<<~TXT.strip) Extra label TXT end @@ -63,6 +69,9 @@ expect(operation.label).to eq(<<~TXT.strip) A random operation label + TXT + + expect(operation.details.unstructured_label_2).to eq(<<~TXT.strip) Extra label TXT end @@ -76,6 +85,9 @@ expect(operation.label).to eq(<<~TXT.strip) A random operation label + TXT + + expect(operation.details.structured_label).to eq(<<~TXT.strip) Extra label TXT end @@ -87,9 +99,9 @@ it 'Adds the original currency information' do operation.merge_detail(detail) - expect(operation).to have_attributes( + expect(operation.details).to have_attributes( original_currency: 'USD', - original_amount: -12.34, + original_amount: 12.34, exchange_rate: nil, ) end @@ -100,9 +112,9 @@ it 'Adds the original currency information' do operation.merge_detail(detail) - expect(operation).to have_attributes( + expect(operation.details).to have_attributes( original_currency: 'USD', - original_amount: -8358, + original_amount: 8358, exchange_rate: 1.077, ) end @@ -113,10 +125,9 @@ it 'Adds the original currency information' do operation.merge_detail(detail) - - expect(operation).to have_attributes( + expect(operation.details).to have_attributes( original_currency: 'EUR', - original_amount: -18_756.25, + original_amount: 18_756.25, exchange_rate: nil, ) end @@ -129,7 +140,7 @@ it 'Adds the debtor information' do operation.merge_detail(detail) - expect(operation).to have_attributes(debtor: 'Patrick') + expect(operation.details).to have_attributes(debtor: 'Patrick') end end @@ -139,7 +150,7 @@ it 'Adds the creditor information' do operation.merge_detail(detail) - expect(operation).to have_attributes(creditor: 'Jean-Pierre') + expect(operation.details).to have_attributes(creditor: 'Jean-Pierre') end end @@ -152,11 +163,11 @@ ) end - it 'adds the reference information' do + it 'adds the client reference information' do operation.merge_detail(detail) - expect(operation.reference).to eq('42 - SWILE-CMD-TR-YPDHMA') - expect(operation.purpose).to eq('TICKET RESTO') + expect(operation.details.client_reference).to eq('SWILE-CMD-TR-YPDHMA') + expect(operation.details.purpose).to eq('TICKET RESTO') end end @@ -169,10 +180,10 @@ ) end - it 'adds the reference information' do + it 'adds the operation reference information' do operation.merge_detail(detail) - expect(operation.reference).to eq('42 - PENNYLANE B13A93908C36C82DF5C319/1') + expect(operation.details.operation_reference).to eq('PENNYLANE B13A93908C36C82DF5C319/1') end end @@ -188,8 +199,8 @@ it 'adds the fee information' do operation.merge_detail(detail) - expect(operation.fee_currency).to eq('EUR') - expect(operation.fee).to eq(7.4) + expect(operation.details.fee_currency).to eq('EUR') + expect(operation.details.fee).to eq(7.4) end end @@ -208,8 +219,8 @@ 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) + expect(operation.details.debtor_identifier).to eq(debtor_identifier) + expect(operation.details.debtor_identifier_type).to eq(debtor_identifier_type) end end @@ -227,8 +238,8 @@ it 'adds the IBE information' do operation.merge_detail(detail) - expect(operation.creditor_identifier).to eq(creditor_identifier) - expect(operation.creditor_identifier_type).to eq(creditor_identifier_type) + expect(operation.details.creditor_identifier).to eq(creditor_identifier) + expect(operation.details.creditor_identifier_type).to eq(creditor_identifier_type) end end @@ -243,7 +254,7 @@ it 'adds the NPO information' do operation.merge_detail(detail) - expect(operation.ultimate_debtor).to eq('Patrick') + expect(operation.details.ultimate_debtor).to eq('Patrick') end end @@ -258,7 +269,7 @@ it 'adds the NBU information' do operation.merge_detail(detail) - expect(operation.ultimate_creditor).to eq('Patrick') + expect(operation.details.ultimate_creditor).to eq('Patrick') end end end diff --git a/spec/cfonb/parser_spec.rb b/spec/cfonb/parser_spec.rb index f025846..a6fb0eb 100644 --- a/spec/cfonb/parser_spec.rb +++ b/spec/cfonb/parser_spec.rb @@ -35,16 +35,19 @@ exoneration_code: '0', interbank_code: 'B1', internal_code: '9162', - label: "PRLV SEPA TEST CABINET\nMENSUEAUHTR13133", + label: 'PRLV SEPA TEST CABINET', number: 0, - reference: 'REFERENCE - OTHER REFERENCE', - purpose: 'PURPOSE', rejection_code: '', unavailability_code: '0', value_date: Date.new(2019, 5, 16), + reference: '', + ) + expect(statements[0].operations[0].details).to have_attributes( + free_label: 'MENSUEAUHTR13133', original_currency: nil, original_amount: nil, exchange_rate: nil, + purpose: 'PURPOSE', debtor: 'INTERNET SFR', ) @@ -57,14 +60,19 @@ internal_code: '9162', label: 'VIR SEPA DEMONSTRATION', number: 0, - reference: 'REFERENCE', rejection_code: '', unavailability_code: '0', value_date: Date.new(2019, 5, 16), + reference: 'REFERENCE', + ) + + expect(statements[0].operations[1].details).to have_attributes( + debtor: 'ELEC ERDF', + free_label: nil, original_currency: nil, original_amount: nil, exchange_rate: nil, - debtor: 'ELEC ERDF', + purpose: nil, ) expect(statements[0].operations[2]).to have_attributes( @@ -76,10 +84,15 @@ internal_code: '0117', label: 'F COMMISSION D INTERVENTION', number: 0, - reference: '', rejection_code: '', unavailability_code: '0', value_date: Date.new(2019, 5, 15), + reference: '', + ) + + expect(statements[0].operations[2].details).to have_attributes( + free_label: nil, + purpose: nil, original_currency: nil, original_amount: nil, exchange_rate: nil, @@ -105,15 +118,21 @@ exoneration_code: '', interbank_code: 'A3', internal_code: '0158', - label: "PRLV SEPA GROUPAMA CEN\nP051928612 22793301700040", + label: 'PRLV SEPA GROUPAMA CEN', number: 0, - reference: '', rejection_code: '', unavailability_code: '0', value_date: Date.new(2019, 5, 15), + reference: '', + ) + + expect(statements[1].operations[0].details).to have_attributes( + free_label: 'P051928612 22793301700040', original_currency: nil, original_amount: nil, exchange_rate: nil, + purpose: nil, + debtor: nil, ) expect(statements[1].operations[1]).to have_attributes( @@ -125,13 +144,19 @@ internal_code: '0337', label: 'F FRAIS PRLV IMP 97 49EUR', number: 0, - reference: '', rejection_code: '', unavailability_code: '0', value_date: Date.new(2019, 5, 15), + reference: '', + ) + + expect(statements[1].operations[1].details).to have_attributes( + free_label: nil, original_currency: nil, original_amount: nil, exchange_rate: nil, + purpose: nil, + debtor: nil, ) expect(statements[1].operations[2]).to have_attributes( @@ -143,13 +168,19 @@ internal_code: '0117', label: 'F COMMISSION D INTERVENTION', number: 0, - reference: '', rejection_code: '', unavailability_code: '0', value_date: Date.new(2019, 5, 16), + reference: '', + ) + + expect(statements[1].operations[2].details).to have_attributes( + free_label: nil, original_currency: nil, original_amount: nil, exchange_rate: nil, + purpose: nil, + debtor: nil, ) end end @@ -232,18 +263,22 @@ exoneration_code: '0', interbank_code: 'B1', internal_code: '9162', - label: "PRLV SEPA TEST CABINET\nMENSUEAUHTR13133", + label: 'PRLV SEPA TEST CABINET', number: 0, - reference: 'REFERENCE - OTHER REFERENCE', rejection_code: '', unavailability_code: '0', value_date: Date.new(2019, 5, 16), + ) + + expect(statements[0].operations[0].details).to have_attributes( + operation_reference: 'REFERENCE', + free_label: 'MENSUEAUHTR13133', + debtor: 'INTERNET SFR', + client_reference: 'OTHER REFERENCE', original_currency: nil, original_amount: nil, exchange_rate: nil, - debtor: 'INTERNET SFR', ) - expect(statements[0].operations[1]).to have_attributes( amount: -10.7, currency: 'EUR', @@ -253,10 +288,13 @@ internal_code: '9162', label: 'VIR SEPA DEMONSTRATION', number: 0, - reference: 'REFERENCE', rejection_code: '', unavailability_code: '0', value_date: Date.new(2019, 5, 16), + reference: 'REFERENCE', + ) + + expect(statements[0].operations[1].details).to have_attributes( original_currency: nil, original_amount: nil, exchange_rate: nil, @@ -272,10 +310,13 @@ internal_code: '0117', label: 'F COMMISSION D INTERVENTION', number: 0, - reference: '', rejection_code: '', unavailability_code: '0', value_date: Date.new(2019, 5, 15), + reference: '', + ) + + expect(statements[0].operations[2].details).to have_attributes( original_currency: nil, original_amount: nil, exchange_rate: nil, @@ -301,12 +342,16 @@ exoneration_code: '', interbank_code: 'A3', internal_code: '0158', - label: "PRLV SEPA GROUPAMA CEN\nP051928612 22793301700040", + label: 'PRLV SEPA GROUPAMA CEN', number: 0, - reference: '', rejection_code: '', unavailability_code: '0', value_date: Date.new(2019, 5, 15), + reference: '', + ) + + expect(statements[1].operations[0].details).to have_attributes( + free_label: 'P051928612 22793301700040', original_currency: nil, original_amount: nil, exchange_rate: nil, @@ -321,10 +366,13 @@ internal_code: '0337', label: 'F FRAIS PRLV IMP 97 49EUR', number: 0, - reference: '', rejection_code: '', unavailability_code: '0', value_date: Date.new(2019, 5, 15), + reference: '', + ) + + expect(statements[1].operations[1].details).to have_attributes( original_currency: nil, original_amount: nil, exchange_rate: nil, @@ -339,10 +387,13 @@ internal_code: '0117', label: 'F COMMISSION D INTERVENTION', number: 0, - reference: '', rejection_code: '', unavailability_code: '0', value_date: Date.new(2019, 5, 16), + reference: '', + ) + + expect(statements[1].operations[2].details).to have_attributes( original_currency: nil, original_amount: nil, exchange_rate: nil, @@ -365,14 +416,17 @@ internal_code: '9162', label: 'VIR SEPA DEMONSTRATION', number: 0, - reference: '', rejection_code: '', unavailability_code: '0', value_date: Date.new(2019, 5, 16), + reference: '', + ) + + expect(statements[0].operations[0].details).to have_attributes( + debtor: 'ELEC ERDF', original_currency: nil, original_amount: nil, exchange_rate: nil, - debtor: 'ELEC ERDF', ) end end @@ -392,14 +446,16 @@ internal_code: '9162', label: 'VIR SEPA DEMONSTRATION', number: 0, - reference: '', rejection_code: '', unavailability_code: '0', value_date: Date.new(2019, 5, 16), + reference: '', + ) + expect(statements[0].operations[0].details).to have_attributes( + debtor: 'ELEC ERDF', original_currency: nil, original_amount: nil, exchange_rate: nil, - debtor: 'ELEC ERDF', ) end end @@ -419,14 +475,16 @@ internal_code: '9162', label: 'VIR SEPA DEMONSTRATION', number: 0, - reference: '', rejection_code: '', unavailability_code: '0', value_date: Date.new(2019, 5, 16), + reference: '', + ) + expect(statements[0].operations[0].details).to have_attributes( + debtor: 'ELEC ERDF', original_currency: nil, original_amount: nil, exchange_rate: nil, - debtor: 'ELEC ERDF', ) end end @@ -446,14 +504,16 @@ internal_code: '9162', label: 'VIR SEPA DEMONSTRATION', number: 0, - reference: '', rejection_code: '', unavailability_code: '0', value_date: Date.new(2019, 5, 16), + reference: '', + ) + expect(statements[0].operations[0].details).to have_attributes( + debtor: 'ELEC ERDF', original_currency: nil, original_amount: nil, exchange_rate: nil, - debtor: 'ELEC ERDF', ) expect(statements[0].operations[1]).to have_attributes( amount: -7.9, @@ -464,10 +524,12 @@ internal_code: '0117', label: 'F COMMISSION D INTERVENTION', number: 0, - reference: '', rejection_code: '', unavailability_code: '0', value_date: Date.new(2019, 5, 16), + reference: '', + ) + expect(statements[0].operations[1].details).to have_attributes( original_currency: nil, original_amount: nil, exchange_rate: nil, @@ -503,16 +565,20 @@ exoneration_code: '0', interbank_code: 'B1', internal_code: '9162', - label: "PRLV SEPA TEST CABINET\nMENSUEAUHTR13133", + label: 'PRLV SEPA TEST CABINET', number: 0, - reference: 'REFERENCE - OTHER REFERENCE', rejection_code: '', unavailability_code: '0', value_date: Date.new(2019, 5, 16), + ) + expect(operation.details).to have_attributes( + operation_reference: 'REFERENCE', + client_reference: 'OTHER REFERENCE', + debtor: 'INTERNET SFR', + free_label: 'MENSUEAUHTR13133', original_currency: nil, original_amount: nil, exchange_rate: nil, - debtor: 'INTERNET SFR', ) end end @@ -563,16 +629,20 @@ exoneration_code: '0', interbank_code: 'B1', internal_code: '9162', - label: "PRLV SEPA TEST CABINET\nMENSUEAUHTR13133", + label: 'PRLV SEPA TEST CABINET', number: 0, - reference: 'REFERENCE - OTHER REFERENCE', rejection_code: '', unavailability_code: '0', value_date: Date.new(2019, 5, 16), + ) + expect(operation.details).to have_attributes( + operation_reference: 'REFERENCE', + client_reference: 'OTHER REFERENCE', + free_label: 'MENSUEAUHTR13133', + debtor: 'INTERNET SFR', original_currency: nil, original_amount: nil, exchange_rate: nil, - debtor: 'INTERNET SFR', ) end end @@ -588,16 +658,20 @@ exoneration_code: '0', interbank_code: 'B1', internal_code: '9162', - label: "PRLV SEPA TEST CABINET\nMENSUEAUHTR13133", + label: 'PRLV SEPA TEST CABINET', number: 0, - reference: 'REFERENCE - OTHER REFERENCE', rejection_code: '', unavailability_code: '0', value_date: Date.new(2019, 5, 16), + ) + expect(operation.details).to have_attributes( + client_reference: 'OTHER REFERENCE', + operation_reference: 'REFERENCE', + free_label: 'MENSUEAUHTR13133', + debtor: 'INTERNET SFR', original_currency: nil, original_amount: nil, exchange_rate: nil, - debtor: 'INTERNET SFR', ) end end @@ -621,16 +695,21 @@ exoneration_code: '0', interbank_code: 'B1', internal_code: '9162', - label: "PRLV SEPA TEST CABINET\nMENSUEAUHTR13133\nP051928612 22793301700040", + label: 'PRLV SEPA TEST CABINET', number: 0, - reference: 'REFERENCE - OTHER REFERENCE', rejection_code: '', unavailability_code: '0', value_date: Date.new(2019, 5, 16), + ) + + expect(operation.details).to have_attributes( + operation_reference: 'REFERENCE', + client_reference: 'OTHER REFERENCE', + free_label: "MENSUEAUHTR13133\nP051928612 22793301700040", + debtor: 'ELEC ERDF', original_currency: nil, original_amount: nil, exchange_rate: nil, - debtor: 'ELEC ERDF', ) end end