From ec0d9b60663d8a151e66ab25fd6bf9ccc9e15acf Mon Sep 17 00:00:00 2001 From: Andreas Finke Date: Wed, 13 Apr 2022 23:52:22 +0100 Subject: [PATCH] Extracts msg+id from file if btch is present. --- lib/camt_parser/053/entry.rb | 4 + spec/fixtures/valid_example_with_btch.xml | 358 ++++++++++++++++++ spec/lib/camt_parser/053/entry_spec.rb | 1 + .../camt_parser/053/entry_with_btch_spec.rb | 14 + 4 files changed, 377 insertions(+) create mode 100755 spec/fixtures/valid_example_with_btch.xml create mode 100644 spec/lib/camt_parser/053/entry_with_btch_spec.rb diff --git a/lib/camt_parser/053/entry.rb b/lib/camt_parser/053/entry.rb index c278801..f7d055a 100644 --- a/lib/camt_parser/053/entry.rb +++ b/lib/camt_parser/053/entry.rb @@ -111,6 +111,10 @@ def creditor_identifier def information @information ||= @xml_data.xpath('NtryDtls/TxDtls/Refs/PmtInfId/text()').text end + + def msg_id + @msg_id ||= @xml_data.xpath('NtryDtls/Btch/MsgId/text()').text + end end end end diff --git a/spec/fixtures/valid_example_with_btch.xml b/spec/fixtures/valid_example_with_btch.xml new file mode 100755 index 0000000..030e2ec --- /dev/null +++ b/spec/fixtures/valid_example_with_btch.xml @@ -0,0 +1,358 @@ + + + + + + 053D2013-12-27T22:05:03.0N130000005 + 2013-12-27T22:04:52.0+01:00 + + 1 + true + + + + 0352C5320131227220503 + 130000005 + 2013-12-27T22:04:52.0+01:00 + + + DE14740618130000033626 + + EUR + + Testkonto Nummer 1 + + + + GENODEF1PFK + VR-Bank Rottal-Inn eG + + DE 129267947 + UmsStId + + + + + + + + PRCD + + + 33.06 + CRDT +
+
2013-12-27
+ +
+ + + + CLBD + + + 23.06 + CRDT +
+
2013-12-27
+ +
+ + 2.00 + DBIT + BOOK + +
2013-12-27
+
+ +
2013-12-27
+
+ 2013122710583450000 + + + + EBICS-BOX/123 + EBICS-BOX/40D02152A6325132B31AFE/1 + 00000001 + + + + + NTRF+020 + ZKA + + + + + Wayne Enterprises + + + + DE24302201900609832118 + + + + Testkonto Nummer 2 + + Berlin + Infinite Loop 2 + 12345 + + + + + DE09300606010012345671 + + + CACC + + + + + + + DAAEDEDDXXX + + + ABCDEF + + 1232344234234 + + + + + + DAAEDEDDXXX + + + ABCDEF + + 123456789 + + Bank + + Infinite Loop 1 + Berlin + + + + + + TEST BERWEISUNG MITTELS BLZUND KONTONUMMER - DTA + + + + Überweisungs-Gutschrift; GVC: SEPA Credit Transfer (Einzelbuchung-Haben) +
+ + 3.00 + DBIT + BOOK + +
2013-12-27
+
+ +
2013-12-27
+
+ 2013122710583600000 + + + + + CCTI/VRNWSW/b044f24cddb92a502b8a1b5 + NOTPROVIDED + + + + NMSC+201 + ZKA + + + + + Testkonto Nummer 1 + + + + DE14740618130000033626 + + + + keine Information vorhanden + + + Testkonto Nummer 2 + + + + DE58740618130100033626 + + + + keine Information vorhanden + + + + + + GENODEF1PFK + + + + + Test+berweisung mit BIC und IBAN SEPA IBAN: DE58740618130100033626 BIC: GENODEF1PFK + + + +
+ + 1.00 + CRDT + BOOK + +
2013-12-27
+
+ +
2013-12-27
+
+ 2013122711085260000 + + + + + + NMSC+051 + ZKA + + + + + Testkonto Nummer 2 + + + + + 740618130100033626 + + BBAN + + + + + + + R CKBUCHUNG + + + +
+ + 6.00 + DBIT + BOOK + +
2013-12-27
+
+ +
2013-12-27
+
+ 2013122711513230000 + + + + STZV-PmInf27122013-11:02-2 + 2 + + + + STZV-Msg27122013-11:02 + STZV-EtE27122013-11:02-1 + + + + 3.50 + + + + + NMSC+201 + ZKA + + + + + Testkonto Nummer 2 + + + + DE58740618130100033626 + + + + keine Information vorhanden + + + Testkonto Nummer 1 + + + + DE14740618130000033626 + + + + Testkonto + + + + Sammelueberwseisung 2. Zahlung TAN:283044 + + + + + STZV-Msg27122013-11:02 + STZV-EtE27122013-11:02-2 + + + + 2.50 + + + + + NMSC+201 + ZKA + + + + + Testkonto Nummer 2 + + + + DE58740618130100033626 + + + + keine Information vorhanden + + + Testkonto Nummer 1 + + + + DE14740618130000033626 + + + + Testkonto + + + + Sammelueberweisung 1. Zahlung TAN:283044 + + + +
+
+
+
diff --git a/spec/lib/camt_parser/053/entry_spec.rb b/spec/lib/camt_parser/053/entry_spec.rb index b6255f7..955c67a 100644 --- a/spec/lib/camt_parser/053/entry_spec.rb +++ b/spec/lib/camt_parser/053/entry_spec.rb @@ -27,6 +27,7 @@ specify { expect(ex_entry.debit?).to eq(true) } specify { expect(ex_entry.credit?).to eq(false) } specify { expect(ex_entry.sign).to eq(-1) } + specify { expect(ex_entry.msg_id).to eq("") } specify { expect(ex_entry.name).to eq("Testkonto Nummer 2") } specify { expect(ex_entry.iban).to eq("DE09300606010012345671") } diff --git a/spec/lib/camt_parser/053/entry_with_btch_spec.rb b/spec/lib/camt_parser/053/entry_with_btch_spec.rb new file mode 100644 index 0000000..44fb809 --- /dev/null +++ b/spec/lib/camt_parser/053/entry_with_btch_spec.rb @@ -0,0 +1,14 @@ +require 'spec_helper' + +describe CamtParser::Format053::Entry do + let(:camt) { CamtParser::File.parse('spec/fixtures/valid_example_with_btch.xml') } + let(:statements) { camt.statements } + let(:ex_stmt) { camt.statements[0] } + let(:entries) { ex_stmt.entries } + let(:ex_entry) { ex_stmt.entries[0] } + + specify { expect(entries).to all(be_kind_of(described_class)) } + + specify { expect(ex_entry.msg_id).to eq("EBICS-BOX/123") } + +end