Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extracts msg+id from file if btch is present. #2

Merged
merged 1 commit into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/camt_parser/053/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
358 changes: 358 additions & 0 deletions spec/fixtures/valid_example_with_btch.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,358 @@
<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.053.001.02" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:camt.053.001.02 camt.053.001.02.xsd">

<BkToCstmrStmt>
<GrpHdr>
<MsgId>053D2013-12-27T22:05:03.0N130000005</MsgId>
<CreDtTm>2013-12-27T22:04:52.0+01:00</CreDtTm>
<MsgPgntn>
<PgNb>1</PgNb>
<LastPgInd>true</LastPgInd>
</MsgPgntn>
</GrpHdr>
<Stmt>
<Id>0352C5320131227220503</Id>
<ElctrncSeqNb>130000005</ElctrncSeqNb>
<CreDtTm>2013-12-27T22:04:52.0+01:00</CreDtTm>
<Acct>
<Id>
<IBAN>DE14740618130000033626</IBAN>
</Id>
<Ccy>EUR</Ccy>
<Ownr>
<Nm>Testkonto Nummer 1</Nm>
</Ownr>
<Svcr>
<FinInstnId>
<BIC>GENODEF1PFK</BIC>
<Nm>VR-Bank Rottal-Inn eG</Nm>
<Othr>
<Id>DE 129267947</Id>
<Issr>UmsStId</Issr>
</Othr>
</FinInstnId>
</Svcr>
</Acct>
<Bal>
<Tp>
<CdOrPrtry>
<Cd>PRCD</Cd>
</CdOrPrtry>
</Tp>
<Amt Ccy="EUR">33.06</Amt>
<CdtDbtInd>CRDT</CdtDbtInd>
<Dt>
<Dt>2013-12-27</Dt>
</Dt>
</Bal>
<Bal>
<Tp>
<CdOrPrtry>
<Cd>CLBD</Cd>
</CdOrPrtry>
</Tp>
<Amt Ccy="EUR">23.06</Amt>
<CdtDbtInd>CRDT</CdtDbtInd>
<Dt>
<Dt>2013-12-27</Dt>
</Dt>
</Bal>
<Ntry>
<Amt Ccy="EUR">2.00</Amt>
<CdtDbtInd>DBIT</CdtDbtInd>
<Sts>BOOK</Sts>
<BookgDt>
<Dt>2013-12-27</Dt>
</BookgDt>
<ValDt>
<Dt>2013-12-27</Dt>
</ValDt>
<AcctSvcrRef>2013122710583450000</AcctSvcrRef>
<BkTxCd/>
<NtryDtls>
<Btch>
<MsgId>EBICS-BOX/123</MsgId>
<PmtInfId>EBICS-BOX/40D02152A6325132B31AFE/1</PmtInfId>
<NbOfTxs>00000001</NbOfTxs>
</Btch>
<TxDtls>
<BkTxCd>
<Prtry>
<Cd>NTRF+020</Cd>
<Issr>ZKA</Issr>
</Prtry>
</BkTxCd>
<RltdPties>
<Dbtr>
<Nm>Wayne Enterprises</Nm>
</Dbtr>
<DbtrAcct>
<Id>
<IBAN>DE24302201900609832118</IBAN>
</Id>
</DbtrAcct>
<Cdtr>
<Nm>Testkonto Nummer 2</Nm>
<PstlAdr>
<AdrLine>Berlin</AdrLine>
<AdrLine>Infinite Loop 2</AdrLine>
<AdrLine>12345</AdrLine>
</PstlAdr>
</Cdtr>
<CdtrAcct>
<Id>
<IBAN>DE09300606010012345671</IBAN>
</Id>
<Tp>
<Cd>CACC</Cd>
</Tp>
</CdtrAcct>
</RltdPties>
<RltdAgts>
<DbtrAgt>
<FinInstnId>
<BIC>DAAEDEDDXXX</BIC>
<ClrSysMmbId>
<ClrSysId>
<Cd>ABCDEF</Cd>
</ClrSysId>
<MmbId>1232344234234</MmbId>
</ClrSysMmbId>
</FinInstnId>
</DbtrAgt>
<CdtrAgt>
<FinInstnId>
<BIC>DAAEDEDDXXX</BIC>
<ClrSysMmbId>
<ClrSysId>
<Cd>ABCDEF</Cd>
</ClrSysId>
<MmbId>123456789</MmbId>
</ClrSysMmbId>
<Nm>Bank</Nm>
<PstlAdr>
<AdrLine>Infinite Loop 1</AdrLine>
<AdrLine>Berlin</AdrLine>
</PstlAdr>
</FinInstnId>
</CdtrAgt>
</RltdAgts>
<RmtInf>
<Ustrd>TEST BERWEISUNG MITTELS BLZUND KONTONUMMER - DTA</Ustrd>
</RmtInf>
</TxDtls>
</NtryDtls>
<AddtlNtryInf>Überweisungs-Gutschrift; GVC: SEPA Credit Transfer (Einzelbuchung-Haben)</AddtlNtryInf>
</Ntry>
<Ntry>
<Amt Ccy="EUR">3.00</Amt>
<CdtDbtInd>DBIT</CdtDbtInd>
<Sts>BOOK</Sts>
<BookgDt>
<Dt>2013-12-27</Dt>
</BookgDt>
<ValDt>
<Dt>2013-12-27</Dt>
</ValDt>
<AcctSvcrRef>2013122710583600000</AcctSvcrRef>
<BkTxCd/>
<NtryDtls>
<TxDtls>
<Refs>
<MsgId>CCTI/VRNWSW/b044f24cddb92a502b8a1b5</MsgId>
<EndToEndId>NOTPROVIDED</EndToEndId>
</Refs>
<BkTxCd>
<Prtry>
<Cd>NMSC+201</Cd>
<Issr>ZKA</Issr>
</Prtry>
</BkTxCd>
<RltdPties>
<Dbtr>
<Nm>Testkonto Nummer 1</Nm>
</Dbtr>
<DbtrAcct>
<Id>
<IBAN>DE14740618130000033626</IBAN>
</Id>
</DbtrAcct>
<UltmtDbtr>
<Nm>keine Information vorhanden</Nm>
</UltmtDbtr>
<Cdtr>
<Nm>Testkonto Nummer 2</Nm>
</Cdtr>
<CdtrAcct>
<Id>
<IBAN>DE58740618130100033626</IBAN>
</Id>
</CdtrAcct>
<UltmtCdtr>
<Nm>keine Information vorhanden</Nm>
</UltmtCdtr>
</RltdPties>
<RltdAgts>
<CdtrAgt>
<FinInstnId>
<BIC>GENODEF1PFK</BIC>
</FinInstnId>
</CdtrAgt>
</RltdAgts>
<RmtInf>
<Ustrd>Test+berweisung mit BIC und IBAN SEPA IBAN: DE58740618130100033626 BIC: GENODEF1PFK</Ustrd>
</RmtInf>
</TxDtls>
</NtryDtls>
</Ntry>
<Ntry>
<Amt Ccy="EUR">1.00</Amt>
<CdtDbtInd>CRDT</CdtDbtInd>
<Sts>BOOK</Sts>
<BookgDt>
<Dt>2013-12-27</Dt>
</BookgDt>
<ValDt>
<Dt>2013-12-27</Dt>
</ValDt>
<AcctSvcrRef>2013122711085260000</AcctSvcrRef>
<BkTxCd/>
<NtryDtls>
<TxDtls>
<BkTxCd>
<Prtry>
<Cd>NMSC+051</Cd>
<Issr>ZKA</Issr>
</Prtry>
</BkTxCd>
<RltdPties>
<Dbtr>
<Nm>Testkonto Nummer 2</Nm>
</Dbtr>
<DbtrAcct>
<Id>
<Othr>
<Id> 740618130100033626</Id>
<SchmeNm>
<Cd>BBAN</Cd>
</SchmeNm>
</Othr>
</Id>
</DbtrAcct>
</RltdPties>
<RmtInf>
<Ustrd>R CKBUCHUNG</Ustrd>
</RmtInf>
</TxDtls>
</NtryDtls>
</Ntry>
<Ntry>
<Amt Ccy="EUR">6.00</Amt>
<CdtDbtInd>DBIT</CdtDbtInd>
<Sts>BOOK</Sts>
<BookgDt>
<Dt>2013-12-27</Dt>
</BookgDt>
<ValDt>
<Dt>2013-12-27</Dt>
</ValDt>
<AcctSvcrRef>2013122711513230000</AcctSvcrRef>
<BkTxCd/>
<NtryDtls>
<Btch>
<PmtInfId>STZV-PmInf27122013-11:02-2</PmtInfId>
<NbOfTxs>2</NbOfTxs>
</Btch>
<TxDtls>
<Refs>
<MsgId>STZV-Msg27122013-11:02</MsgId>
<EndToEndId>STZV-EtE27122013-11:02-1</EndToEndId>
</Refs>
<AmtDtls>
<TxAmt>
<Amt Ccy="EUR">3.50</Amt>
</TxAmt>
</AmtDtls>
<BkTxCd>
<Prtry>
<Cd>NMSC+201</Cd>
<Issr>ZKA</Issr>
</Prtry>
</BkTxCd>
<RltdPties>
<Dbtr>
<Nm>Testkonto Nummer 2</Nm>
</Dbtr>
<DbtrAcct>
<Id>
<IBAN>DE58740618130100033626</IBAN>
</Id>
</DbtrAcct>
<UltmtDbtr>
<Nm>keine Information vorhanden</Nm>
</UltmtDbtr>
<Cdtr>
<Nm>Testkonto Nummer 1</Nm>
</Cdtr>
<CdtrAcct>
<Id>
<IBAN>DE14740618130000033626</IBAN>
</Id>
</CdtrAcct>
<UltmtCdtr>
<Nm>Testkonto</Nm>
</UltmtCdtr>
</RltdPties>
<RmtInf>
<Ustrd>Sammelueberwseisung 2. Zahlung TAN:283044 </Ustrd>
</RmtInf>
</TxDtls>
<TxDtls>
<Refs>
<MsgId>STZV-Msg27122013-11:02</MsgId>
<EndToEndId>STZV-EtE27122013-11:02-2</EndToEndId>
</Refs>
<AmtDtls>
<TxAmt>
<Amt Ccy="EUR">2.50</Amt>
</TxAmt>
</AmtDtls>
<BkTxCd>
<Prtry>
<Cd>NMSC+201</Cd>
<Issr>ZKA</Issr>
</Prtry>
</BkTxCd>
<RltdPties>
<Dbtr>
<Nm>Testkonto Nummer 2</Nm>
</Dbtr>
<DbtrAcct>
<Id>
<IBAN>DE58740618130100033626</IBAN>
</Id>
</DbtrAcct>
<UltmtDbtr>
<Nm>keine Information vorhanden</Nm>
</UltmtDbtr>
<Cdtr>
<Nm>Testkonto Nummer 1</Nm>
</Cdtr>
<CdtrAcct>
<Id>
<IBAN>DE14740618130000033626</IBAN>
</Id>
</CdtrAcct>
<UltmtCdtr>
<Nm>Testkonto</Nm>
</UltmtCdtr>
</RltdPties>
<RmtInf>
<Ustrd>Sammelueberweisung 1. Zahlung TAN:283044 </Ustrd>
</RmtInf>
</TxDtls>
</NtryDtls>
</Ntry>
</Stmt>
</BkToCstmrStmt>
</Document>
1 change: 1 addition & 0 deletions spec/lib/camt_parser/053/entry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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") }
Expand Down
14 changes: 14 additions & 0 deletions spec/lib/camt_parser/053/entry_with_btch_spec.rb
Original file line number Diff line number Diff line change
@@ -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