Parse ISO 20022 camt.053 (Bank to Customer Statement) messages.
Supports schema versions 001.02 through 001.14. The output is always the same struct tree regardless of input version.
Quick start
xml = File.read!("statement.xml")
case ISO20022.Camt053.parse(xml) do
{:ok, doc} ->
Enum.each(doc.statements, fn stmt ->
IO.puts("Account: #{stmt.account.iban}")
closing = Enum.find(stmt.balances, &(&1.type == :closing_booked))
IO.puts("Closing balance: #{closing.amount} #{closing.currency}")
end)
{:error, reason} ->
IO.inspect(reason, label: "parse error")
endReturn values
{:ok, %ISO20022.Camt053.Document{}}on success{:error, {:parse_error, reason}}— malformed XML{:error, {:unsupported_version, namespace}}— namespace not recognised as camt.053{:error, {:missing_required_field, path}}— mandatory element absent{:error, {:invalid_amount | :invalid_date | :invalid_datetime, value, path}}— bad value
Struct hierarchy
Document
├── group_header: GroupHeader
└── statements: [Statement]
├── account: Account
├── balances: [Balance]
└── entries: [Entry]
└── details: [EntryDetails]
└── transaction_details: [TransactionDetails]
Summary
Functions
Parses a camt.053 XML document from a binary string.
Like parse/1 but raises ISO20022.ParseError on failure.
Functions
@spec parse(binary()) :: {:ok, ISO20022.Camt053.Document.t()} | {:error, term()}
Parses a camt.053 XML document from a binary string.
Returns {:ok, %Document{}} on success, or {:error, reason} on failure.
@spec parse!(binary()) :: ISO20022.Camt053.Document.t()
Like parse/1 but raises ISO20022.ParseError on failure.