Skip to content

Commit

Permalink
Update camt_parser to parse NtryRef
Browse files Browse the repository at this point in the history
  • Loading branch information
Mant-Ve authored Mar 4, 2024
2 parents 207eb87 + 7b457c5 commit b7598ab
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/camt_parser/general/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ def batch_detail
@batch_detail ||= xml_data.xpath('NtryDtls/Btch').empty? ? nil : CamtParser::BatchDetail.new(@xml_data.xpath('NtryDtls/Btch'))
end

def ntry_ref
@ntry_ref ||= xml_data.at_xpath('.//NtryRef').text
end

private

def parse_transactions
Expand Down
33 changes: 33 additions & 0 deletions spec/camt_parser_entry_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

require 'rspec'
require 'date'
require_relative '../lib/camt_parser/general/entry'

RSpec.describe CamtParser::Entry do
let(:xml_data) do
Nokogiri::XML(<<~XML)
<Ntry>
<NtryRef>20231004460032/0000002</NtryRef>
<Amt Ccy="EUR">3600.00</Amt>
<CdtDbtInd>DBIT</CdtDbtInd>
<RvslInd>false</RvslInd>
<Sts>BOOK</Sts>
<BookgDt>
<Dt>2023-10-04</Dt>
</BookgDt>
<ValDt>
<Dt>2023-10-04</Dt>
</ValDt>
</Ntry>
XML
end

subject(:entry) { described_class.new(xml_data) }

describe '#ntry_ref' do
it 'returns the correct NtryRef value' do
expect(entry.ntry_ref).to eq('20231004460032/0000002')
end
end
end

0 comments on commit b7598ab

Please sign in to comment.