Skip to content

Expose raw CAMT documents on StatementResponse - #48

Open
vzwick wants to merge 1 commit into
robocode13:mainfrom
vzwick:feat/expose-raw-camt
Open

vzwick wants to merge 1 commit into
robocode13:mainfrom
vzwick:feat/expose-raw-camt

Conversation

@vzwick

@vzwick vzwick commented Nov 16, 2026

Copy link
Copy Markdown

getAccountStatements() parses CAMT into Statement / Transaction, which covers the common fields. Some CAMT data has no place in Transaction, though, and callers currently have no way to reach it. One example is the return information of a returned SEPA direct debit (TxDtls/RtrInf/Rsn/Cd, e.g. MS03, AC04). Another is bank-specific remittance tags such as OAMT+…/COAM+…/CHGS+….

This PR adds an optional rawCamt?: string[] to StatementResponse:

  • It holds the CAMT documents exactly as received, after the existing latin1 → UTF-8 decoding. There is one entry per document, across all HICAZ segments, so parted responses are covered too.
  • It is only set for CAMT (HKCAZ) responses, and is purely additive: no existing behaviour changes.
  • The array is assigned before parsing starts, so the raw documents stay available even if the parser fails, which is when callers need them most.

Tests (in partedResponse.test.ts):

  • the raw documents of every segment are exposed
  • the raw documents are kept when parsing fails

Checked locally: vitest run (179/179), tsc --noEmit, biome check.

🤖 Generated with Claude Code

Adds an optional rawCamt?: string[] to StatementResponse with the CAMT
documents as received (after latin1->UTF-8 decoding), across all HICAZ
segments. Assigned before parsing so the documents survive a parser
failure. Gives callers access to fields not mapped to Transaction, e.g.
return information (RtrInf) of returned SEPA direct debits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fl034

fl034 commented Nov 17, 2026

Copy link
Copy Markdown

+1 for exposing the raw statements. We fetch camt.052 daily for bookkeeping and keep the bank's answer as the retained original (German GoBD), and currently do that with a local patch.

One request for whichever of #44 / #48 lands: please also expose the documents as bytes, before the latin1 → UTF-8 decoding (or the latin1 string, which maps 1:1 to bytes). The decoded string is enough for parsing, but it is not byte-exact for archiving: invalid UTF-8 turns into U+FFFD, and a hash over the re-encoded text can differ from the one over what the bank sent. Something like bytes: Uint8Array next to content would cover both uses.

#44 and #48 overlap; it might help to settle on one shape (#44 also covers MT940).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants