# Reconcile a statement

> Upload a PDF, CSV or Excel bank statement, review the accounts it covers, import the lines, and reconcile each period against the ledger: gaps are drafted, differences are booked or excluded, and balances are kept by date.

Source: /help/en/bank/reconcile-a-statement

Reconciliation is where the month closes on the bank side: the closing balance printed on the statement must equal what the books hold for that account on that date. Alya Books starts a reconciliation the moment a statement is imported, so there is no separate "start reconciliation" step, and drafts one for every month missing between two statements so a gap never stays silent.

## 1. Upload a statement

On the **Bank** page open the **Statements** tab and click **Upload statement**.

- **PDF or image**: the statement is read by the AI reader into one block per account it covers (IBAN or last four digits, period, opening and closing balance, rows). Up to 70 MB. The reader needs the platform's AI model: where none is configured the upload is refused (`ai_unavailable`) and the statement goes in as CSV or Excel rows instead; only the local developer stack answers a sample statement. A block whose currency differs from the account you pick is refused at import (`currency_mismatch`): pick the account in that currency, or leave the block out.
- **CSV or Excel**: the usual columns (date, amount or debit/credit, description, reference, counterparty) are recognised as before and become one block. A tab-separated `.txt` or `.tsv` export is accepted too and is read the same way as a CSV.

Nothing is imported yet: the statement waits in the list as **To review**.

## 2. Review and match the accounts

Click **Review**. For each block, pick the **bank account** it belongs to (Alya Books proposes one from the IBAN) and tick the blocks to import. A statement that covers several accounts imports only the ones you tick; you can come back for the others. **Reject** discards a wrong file with a reason. The bin icon on a row **deletes** the statement together with the lines it imported and the balances it stored; a statement whose lines are already matched is refused (`statement_has_matched_lines`, with the count) until you unmatch them on the **Transactions** tab.

**Import selected** writes the lines into the bank transactions (rows already imported are skipped by their reference), stores the block's closing balance as the account's balance on the period end, starts the **reconciliation of the period** and runs the matcher. The transactions appear on the **Transactions** tab with their review state.

## 3. Review states

Every bank line shows one of four states beside its matching status:

| State | Meaning |
|---|---|
| **Needs review** | Nothing decided yet (unmatched, or a suggestion waiting) |
| **Ready to post** | Matched to a document, the payment has not reached the ledger yet |
| **Synced** | The payment's ledger entry is posted (or the line booked its own entry) |
| **Excluded** | Ignored: a transfer, a fee handled elsewhere, a duplicate; not counted in the reconciliation |

The state follows the ledger by itself: undoing a payment or reversing its entry moves the line back.

## 4. Reconcile the period

Open the **Reconciliations** tab. Each row is one bank account and period with the **statement side** (opening and closing from the statement) and the **ledger side** (the posted lines of the account's ledger account), the **difference** and the line counts. A row marked **Gap** was drafted for a month without a statement.

Open a period to work it:

- **Post** a needs-review line that names an invoice or bill number (the existing match flow), or match it from the Transactions tab.
- **Exclude** a line that does not belong to the books; **Restore** puts it back.
- **Book difference** posts the remaining difference to the rounding account through the ledger (module bank, label *Bank reconciliation difference*), when a few fils or a bank fee cannot be traced.
- **Reconcile** closes the period. It succeeds only when the difference is zero; otherwise the answer names the statement and ledger closing balances.
- A reconciled period is read-only. **Reopen** with a reason records the reason in the audit log and lets you work it again.
- A **gap** without a statement can be closed by hand: **Enter balances** stores the statement opening and closing you read from the bank, then **Reconcile**.

Importing a statement for a period that is already reconciled is refused (`period_reconciled`): reopen it first.

## 5. Balances by date

Every imported statement stores its closing balance for the period end, and you can store one by hand from the **Balance by date** link on a bank account card (pick a date, enter the balance). The popover shows the latest stored balance on or before the date beside the ledger balance of the same date. Cash reports and the API read the same figures: `GET /bank/accounts/{id}/balances?date=`, `PUT /bank/accounts/{id}/balances`.

## Ledger check

**Reports → Trial balance → Ledger check** adds two findings: *reconciliation_difference* for an open period whose statement and ledger closing balances differ, and *statement_not_imported* for a statement left in review.

## API and MCP

`POST /bank/statements` (multipart file, `{storagePath}`, `{base64}` or `{rows}`), `GET /bank/statements/{id}`, `POST /bank/statements/{id}/import`, `GET /bank/reconciliations`, `GET /bank/reconciliations/{id}`, `POST …/reconcile`, `POST …/reopen`, `POST …/exclude`, `POST …/book-difference`, `PUT …/balances`. MCP: `upload_bank_statement`, `import_bank_statement` (with `statementId` and `accounts`), `list_bank_reconciliations`, `get_bank_reconciliation`, `reconcile_bank_period`, `get_bank_balance`.
