---
title: Reviewing a document
description: The review screen in Petawork Finance (the document beside its fields, each field's source highlighted), confirming, correcting and rejecting, the hints learned from corrections for the next document from the same party, coding suggestions and locks, and the MCP tools.
section: finance
order: 43
audience: [user, operator, agent]
sources: [services/nodejs-cloud/lib/finance/capture/review.ts, services/nodejs-cloud/lib/finance/capture/review-pure.ts, services/nodejs-cloud/lib/finance/capture/hints.ts, services/nodejs-cloud/lib/finance/capture/coding.ts, services/nodejs-cloud/lib/finance/capture/review-mcp.ts, services/nodejs-cloud/lib/finance/capture/page-image.ts, services/nodejs-cloud/lib/finance/capture/accuracy.ts, services/nodejs-cloud/scripts/finance-capture-accuracy.ts, services/nodejs-cloud/components/finance/documents/DocumentReview.tsx, services/nodejs-cloud/migrations/0466_fin_capture_hints.sql]
features: [cloud.page-finance]
---

A document that waits at **needs_review** after its [checks](/docs/finance/checks.md) is reviewed by a person. They confirm what was
read, correct it, or reject the document. Each correction is kept, and Finance learns from it: the next document from
the same party is read with a hint about that field.

## The review screen {#screen}

**Review** on a row in Finance > Documents opens the document's review screen at `/finance/documents?doc=<id>`. Links
to a document from bills, expenses and exceptions open the same screen.

- The document is on one side, its fields on the other. At phone width they stack, with the document first.
- A statement or report imported into [Reconciliation](/docs/finance/reconciliation-sources.md) as records is not read for fields. Its screen
  names the source it went into, the import's state and how many records it added, with a link to the source.
- A PDF is shown page by page. A picture is shown as it is. Click the page to open the original in the viewer.
- Focusing a field turns to its page and outlines where it was read.
- A value read below the organisation's [confidence floor](/docs/finance/checks.md#floor) is marked **low**. A field a person
  changed is marked **corrected**.
- The checks that failed are listed under the fields.

Keys:

| Key | What it does |
|---|---|
| Tab, Alt+↓, Alt+↑ | Next or previous field |
| Ctrl+S (⌘S) | Save the corrections |
| Ctrl+Enter (⌘Enter) | Confirm |

When nothing was read (a vision model is not configured, or the read failed), choose the document's type and enter its
fields by hand.

## Confirm, correct, reject {#actions}

| Action | What happens |
|---|---|
| **Save corrections** | The changed fields are stored on the current read with confidence 1, each change is kept (what was read, what it is now, who changed it, when), and the checks run again. The document stays at `needs_review`. A confirmed document can be corrected too: if a corrected field now fails a check, it goes back to `needs_review` |
| **Confirm** | A document at `needs_review` becomes `confirmed`, with who confirmed it and when, even when a check failed (the event names the failed checks). Save your corrections first |
| **Reject** | As on the list, with a reason |

Money is typed in the document's currency (`1250.50`) and stored in minor units. Dates are `YYYY-MM-DD`. A required
field cannot be emptied. Only the header fields are corrected here; line items are not.

After confirming, the screen offers the next step: **Create bill** for a vendor invoice or credit note, **Add to
expenses** for a receipt, or a link to the bill or expense already made from it.

## Learned hints {#hints}

Each correction becomes a short hint for the document's party and type, one per field, for example:

> invoice_number (the invoice number as printed): on an earlier vendor invoice from this sender it was read as
> "1NV-0100" and a person corrected it to "INV-0100".

The hints for a party and type are added to the next read of a document from that party. They go in the request's user
message, ahead of the document, never in the system prompt, so the prompt cache is unchanged.

- **Which party.** A document read again uses the party its checks found. A new document is matched by the tax ID or
  the name of a party with hints, in the PDF's text layer. A photo or a scanned PDF has no text layer before it is read,
  so its first read goes without hints; **Run again** after the party is known uses them.
- **Limits.** A hint is at most 300 characters. A read gets at most 12 hints and 2,000 characters of them. A party keeps
  at most 40 hints; past that, the oldest one nobody edited is dropped.
- **Editing.** A controller (`policies.write`) can rewrite a hint in their own words or forget it, from the review
  screen or with the tools below. Later corrections of the same field update what was read and corrected but keep the
  controller's words. Agents never edit hints.
- **Isolation.** Hints belong to one organisation and are never sent with another organisation's documents.

The read records which hints it was sent, and the review screen says how many.

## Coding {#coding}

The coding is what a document books to: an account, a tax code and dimensions. The review screen suggests the coding the
party used most in its approved bills and confirmed documents (the newest wins a tie; dimensions only when they agree),
or the expense category's default.

A controller can **lock** a party's coding, or an expense category's. A locked coding is applied when the document is
confirmed, instead of being suggested. A person can still give a different coding: it is kept, and the document and the
event name the fields that differ from the lock (a **deviation**). A party's lock wins over its category's.

## Accuracy {#accuracy}

`bun run finance:accuracy` (in `services/nodejs-cloud`) scores Capture's field accuracy over a set of documents with
the values a person expects and the model reply recorded for each. The replies are held to the schema exactly as a live
read is. It prints accuracy overall, per form (typed, scanned, photographed) and per field, and lists each miss. No model,
network or database is used, so it runs in CI.

The default set is 50 documents in `test/fixtures/finance/accuracy/documents.json`: typed, scanned and photographed
vendor invoices, Indonesian invoices, receipts and credit notes, with mistakes a model makes. Pass another file as the
first argument, `--min 0.9` to fail under a threshold, and `--json` for the report as JSON.

## MCP tools {#mcp}

| Tool | What it does | Role | OAuth scope |
|---|---|---|---|
| `finance_document_correct` | Correct fields: `id`, `fields` `{name: value}`, `doc_type` (nothing read), `coding` | `capture.review` | `finance:write` |
| `finance_document_confirm` | Confirm a document at `needs_review`: `id`, `coding` | `capture.review` | `finance:write` |
| `finance_capturehint_list` | The learned hints: `party_id`, `doc_type` | `capture.read` | `finance:read` |
| `finance_capturehint_update` | Rewrite a hint: `id`, `hint` | `policies.write` | `finance:admin` |
| `finance_capturehint_delete` | Forget a hint (`id`) or every hint of a party (`party_id`, `doc_type`) | `policies.write` | `finance:admin` |
| `finance_codinglock_list` | The coding locks: `party_id` | `capture.read` | `finance:read` |
| `finance_codinglock_set` | Lock a coding: `party_id` or `category`, `account_id`, `tax_code_id`, `dimensions` | `policies.write` | `finance:admin` |
| `finance_codinglock_delete` | Remove a lock: `id` | `policies.write` | `finance:admin` |
| `finance_document_get` | Now also answers `review`: the party, corrections, hints sent, coding, lock, suggestion and next step | `capture.read` | `finance:read` |

REST twins: `POST /api/v1/finance/documents/{id}/correct`, `POST /api/v1/finance/documents/{id}/confirm`,
`GET /api/v1/finance/capture/hints`, `PATCH /api/v1/finance/capture/hints/{id}`,
`POST /api/v1/finance/capture/hints/delete`, `GET` and `PUT /api/v1/finance/capture/coding-locks`,
`DELETE /api/v1/finance/capture/coding-locks/{id}`.

Events: `finance.document.corrected`, `finance.document.confirmed` (also a webhook), `finance.capture_hint.updated`,
`finance.capture_hint.deleted`, `finance.coding_lock.set` and `finance.coding_lock.deleted`, each on the
[event chain](/docs/finance/events.md).
