Parcourir la documentation

DocumentationRelier vos outils

@ekwo-ai/ponto-transactions

Cet article n’existe pour l’instant qu’en anglais.

Reads what the Ponto account information API answers for one account — the account resource and its transaction resources — into a bank statement, in TypeScript, with no dependencies.

Ponto reads a company's accounts at its banks and answers in JSON:API. This reader makes no request: the caller fetches (GET /accounts/{id} and the pages of GET /accounts/{id}/transactions), with its own credentials and its own client, and hands the answer over. What comes back is a statement as the file readers return one — an account, two balances and lines — so it enters a ledger the way a camt.053 does.

import { readPontoTransactions } from '@ekwo-ai/ponto-transactions';

const { statements, violations } = readPontoTransactions(
  { account, transactions }, // the account resource, and every page's `data` together
  { openingBalance: '700.00' }, // the closing balance of the statement before this one
);

const statement = statements[0];
statement.closingBalance; // { type: 'CLBD', amount: '1149.90', currency: 'EUR', date: '2026-11-30' } — the current balance
statement.balanced;       // true: 700.00 plus the lines is the current balance
for (const line of statement.lines) {
  line.amount;        // '-800.00' — signed, a decimal string, never a float
  line.bankReference; // the transaction's id at Ponto, the same in every answer
}

It knows no database and no ledger. The shape it returns is declared in src/types.ts, imported from nowhere, and is field for field the shape @ekwo-ai/camt053 declares for itself; what only an API says comes after (openingImplied). Nothing here assumes a currency, a number of decimals, a country or a language.

The balances

An API gives a balance now, not a statement with two ends. So:

  • The closing balance is the account's currentBalance, dated on its currentBalanceReferenceDate (or on balanceDate when the caller gives one).
  • The opening balance is the caller's to declare: the closing balance of the statement before, which it kept. The lines are then checked against it — opening plus lines is the current balance — and a transaction the answer lacks shows as balance_mismatch, with the difference. It is never corrected: a reader that made it add up would hide which line is missing.
  • openingBalance: 'implied' is for a first statement, with nothing before it: the opening is the current balance less the lines, openingImplied says so, and balanced stays null — a balance worked out from the lines proves nothing about them.

The statement's id is the day of the balance and the id of the newest booked transaction — the latest day, and on that day the greatest id — 2026-11-30/t-3: the same transactions, in any order, always make the same one, so an importer that keys statements recognises a replay.

The statement's period runs from the earliest to the latest of the booked days and the balance day, so it never ends before it starts. A line executed after the balance day widens it to that line's day; the closing balance keeps its own day.

Options

Option What it says
openingBalance A decimal string (1250.00, -40.10), or implied. Left out, the statement has no opening balance.
balanceDate YYYY-MM-DD: the day the balance is of, when the account does not say.
maxTransactions Refuse more transactions than this, unread. Default 100 000.

What is thrown, and what comes back as a violation

Thrown (StatementFileError, with a code): not_a_response (no account, no reference, no currency, a balance that is not an amount, transactions that are not a list), too_large, invalid_option.

Returned in violations, with the line and the transaction id:

code when
balance_mismatch the declared opening plus the lines is not the current balance
invalid_amount, invalid_date the line comes back with null there; an amount with an exponent is refused rather than read
other_currency a transaction in another currency than its account: kept, and an importer refuses it
duplicate_transaction the same id twice — two pages that overlap: the second is returned with status INFO, not booked and not counted in the balance, so it is imported once

What it does not do

  • It makes no request and holds no credential.
  • It reads booked transactions. Ponto lists pending ones at another address; they are not read here.
  • It converts nothing, matches nothing, and moves no date to another time zone: the day is the one the API wrote.

Not verified

The answers in the tests are invented, shaped on Ponto's documentation. Which attributes a given bank fills (remittanceInformationType, internalReference, counterpartReference), and whether currentBalance always includes every transaction listed at the same moment, are known only once real answers are read.

Licence

MIT. See LICENSE.

Rendu à partir de packages/formats/ponto-transactions/README.md, dans le dépôt, à la construction du site. Le lire ou le modifier sur GitHub