CAMT.054 support¶
What the loader reads from a camt.054 notification, how each entry and
transaction detail becomes a Transaction, and how amounts are signed.
This page is the README's Features section, included verbatim so the
two cannot drift.
Public API¶
from bankstatementparser_loader_camt054 import (
Camt054NotificationSummary,
Camt054StatementParser,
load_camt054,
load_camt054_file,
summarize_camt054,
)
| Class / Function | Signature | Returns |
|---|---|---|
load_camt054 |
load_camt054(xml_content): a str or bytes |
list[Transaction] |
load_camt054_file |
load_camt054_file(path): a str or os.PathLike |
list[Transaction] |
summarize_camt054 |
summarize_camt054(xml_content): a str or bytes |
Camt054NotificationSummary |
Camt054StatementParser |
Camt054StatementParser(file_name) |
BankStatementParser with parse() (DataFrame), to_transactions() and get_summary() (dict) |
Camt054NotificationSummary is a frozen dataclass with the fields message_id (GrpHdr/MsgId), creation_date (GrpHdr/CreDtTm as a datetime), account_id (the first notification's account), currency (the first transaction's), notification_count, entry_count (the number of transactions, so a batched entry counts once per TxDtls), total_credit and total_debit (both positive Decimals).
Element mapping¶
Elements are matched by local name, whatever the namespace. Each Ntry under each Ntfctn produces one transaction per TxDtls, or one transaction when it has none.
Transaction field |
Source |
|---|---|
account_id |
The notification's Acct/Id/IBAN, else the first Id text under Acct (for example Othr/Id) |
currency |
The Ccy of the amount used, else EUR |
amount |
TxDtls TxAmt/Amt (or Amt) when present and a decimal, else the entry's Amt; signed by CdtDbtInd |
booking_date |
BookgDt/Dt (or DtTm) |
value_date |
ValDt/Dt (or DtTm), else the booking date |
description |
The bank transaction code, then - and RmtInf/Ustrd for a TxDtls; None when both are absent |
reference |
EndToEndId, else TxId, else the detail's AcctSvcrRef, else the entry's AcctSvcrRef |
category |
camt054:<code>, the code being BkTxCd/Prtry/Cd, else BkTxCd/Domn/Cd (or text directly in BkTxCd or Prtry); None without one |
source, source_index |
"camt054" and the transaction's position in the document |
Amount and sign convention¶
An ISO 20022 amount is unsigned: CdtDbtInd CRDT keeps it positive, anything else (DBIT, or a missing indicator) makes it negative. The amount must be ASCII digits with an optional fraction (1250, 89.90); it becomes a decimal.Decimal, never a float. An entry whose Amt is anything else (NaN, 1e5, -5, 1,000.00) is skipped, and a detail amount that is anything else is ignored in favour of the entry's.
Errors¶
load_camt054, load_camt054_file and summarize_camt054 raise xml.etree.ElementTree.ParseError for a document that is not well-formed XML, and a defusedxml DefusedXmlException (a ValueError) for an entity declaration or an external reference. Inside a well-formed document, anything the loader does not model is skipped rather than guessed at. load_camt054_file raises OSError when the file cannot be read.