From 7b457c5ad0ad6b2778a706f85979c5a7e09f1770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Veronika=20Vargov=C3=A1?= Date: Fri, 1 Mar 2024 10:19:04 +0100 Subject: [PATCH] Update camt_parser to parse NtryRef --- lib/camt_parser/general/entry.rb | 4 ++++ spec/camt_parser_entry_spec.rb | 33 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 spec/camt_parser_entry_spec.rb diff --git a/lib/camt_parser/general/entry.rb b/lib/camt_parser/general/entry.rb index e4d0e9d..b676a4e 100644 --- a/lib/camt_parser/general/entry.rb +++ b/lib/camt_parser/general/entry.rb @@ -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 diff --git a/spec/camt_parser_entry_spec.rb b/spec/camt_parser_entry_spec.rb new file mode 100644 index 0000000..c8c0869 --- /dev/null +++ b/spec/camt_parser_entry_spec.rb @@ -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) + + 20231004460032/0000002 + 3600.00 + DBIT + false + BOOK + +
2023-10-04
+
+ +
2023-10-04
+
+
+ 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