---
title: Finance document checks
description: What Petawork Finance checks after it reads a document (arithmetic, dates, currency, confidence, party, bank details, duplicates), when a document is confirmed on its own or waits for a person, the exceptions it raises, the confidence floor, and the MCP tools.
section: finance
order: 42
audience: [user, operator, agent]
sources: [services/nodejs-cloud/lib/finance/capture/checks.ts, services/nodejs-cloud/lib/finance/capture/checking.ts, services/nodejs-cloud/lib/finance/capture/mcp.ts, services/nodejs-cloud/migrations/0455_fin_document_checks.sql]
features: [cloud.page-finance]
---

When [extraction](/docs/finance/extraction.md) finishes reading a document, Petawork Finance checks what it read. If every check
passes, the document is **confirmed** straight away. If any check fails, it stays at **needs_review** and the failed
checks are the reasons a person sees. The model is never asked to decide any of this: the checks are plain code.

## The checks {#checks}

| Check | Passes when |
|---|---|
| Read | The read came with no warnings (a capped page count, columns that could not be mapped) |
| Currency | A currency was read and it is an ISO 4217 code |
| Confidence | Every value read is at or above the confidence floor (0.85 unless you change it). A field the document does not show is not counted |
| Lines add up | The lines add up to the subtotal (or to the total, when there is no subtotal and no tax), exactly |
| Line amounts | On each line, quantity × unit price is the amount, within one minor unit |
| Total | Subtotal + tax (+ a tip on a receipt) is the total. For a settlement: gross − fees − tax is net. For a bank statement: opening balance + the lines is the closing balance |
| Tax | The tax is the rate × the subtotal, within one minor unit per line (at least one). When the lines show their own tax, they add up to the tax within the same margin |
| Dates | The document's date is not in the future (a day's margin for time zones) and not more than ten years old; a due date is not before the invoice date; a period or a stay does not end before it starts |
| Party | The vendor is a known [party](/docs/finance/parties.md): matched by tax ID first (a printed label such as `GST` or `NPWP` is ignored), then by name with case, accents and legal forms (`Pte Ltd`, `PT`) ignored. Two parties matching is not a match. A blocked party fails |
| Bank details | The account printed on the invoice is one of the party's **verified** bank accounts, compared by account hash, never in the clear |
| Duplicates | No other live document of your organisation repeats it (see below) |

A check with nothing to look at (no lines, no bank details printed) is skipped and does not hold the document back.
Amounts are compared in minor units as whole numbers, never as floating point.

Which party a document must have depends on its type. Vendor invoices, credit notes and purchase orders need a known
party. A receipt, a hotel folio or a settlement statement from a merchant that is not a party is fine: the party check
is skipped. A bank statement names no party.

## Duplicates {#duplicates}

Another document of the same organisation (not rejected, not itself a duplicate) counts as a possible duplicate when:

- it is **the same file** (the same SHA-256), or
- it is the same type, for **the same party**, with **the same number**, or a number that differs only by a prefix,
  punctuation or leading zeros: `INV-1043`, `inv 1043`, `INV/001043` and `1043` are all `1043`, or
- it is the same type, for the same party, with **the same amount, currency and date** under another number.

"The same party" means the same resolved party, or, when either document has none, the same printed name once
normalised. Another organisation's documents are never compared.

The exact same file sent twice is already caught when it arrives (see [exact duplicates](/docs/finance/documents.md#exact-duplicates));
this check catches the rest.

## Exceptions it raises {#exceptions}

Failed checks that need someone to act go on the [exceptions queue](/docs/finance/exceptions.md), with the document as the subject:

| Exception | When | Severity |
|---|---|---|
| `unknown_party` | A vendor document names a vendor that is not a party | medium |
| `bank_change` | The bank details printed are not the party's verified account | high |
| `duplicate` | Another document repeats it | high for the same file or the same number, medium for a near number or the same amount and date |

Each is raised once. Checking the document again updates the open exception instead of adding another, and a finding
someone already resolved or waived is not raised again. A `bank_change` exception holds the document for review and
blocks nothing else.

Arithmetic, dates, currency and confidence failures raise no exception: the document waits at `needs_review` with the
reasons.

## The confidence floor {#floor}

Any value read below the floor sends its document to `needs_review`. The floor is 0.85 by default and can be set from
0.5 to 1 for your organisation with `finance_capturesetting_update` (or `PATCH /api/v1/finance/capture/settings`). Only
a Finance controller can change it (`policies.write`), never an agent. Each change is an event on the
[audit trail](/docs/finance/audit-trail.md) (`finance.capture_settings.updated`).

## On the Documents page {#page}

**Review** on a row opens the [review screen](/docs/finance/review.md), which shows the checks under the fields read: a tick for each check that passed and a cross with the
reason for each that failed. A reviewer (`capture.review`: controller, AP clerk) can press **Check again** on a
document at `needs_review`, for example after adding its vendor as a party or verifying the vendor's bank account.

## When the checks run {#when}

- Right after a read finishes, in the same step: the document goes from `extracting` to `confirmed` or `needs_review`
  in one event (`finance.document.extracted`, its detail naming the outcome and the failed checks).
- When asked, with `finance_document_check`: on a document at `needs_review` only. A confirmed document is never moved
  back, and duplicates, rejected documents and documents with nothing read are refused. Each run is an event
  (`finance.document.checked`).

Bank details can only be compared when the vault is configured (`VENOM_VAULT_KEYS`). Without it, an invoice that prints
bank details waits for a person.

## MCP tools {#mcp}

| Tool | What it does | OAuth scope |
|---|---|---|
| `finance_document_check` | Check a document at `needs_review` again: `id`. Answers the document and `checks` | `finance:write` |
| `finance_capturesetting_get` | The confidence floor in force, its default and bounds | `finance:read` |
| `finance_capturesetting_update` | Set the confidence floor: `confidence_floor` | `finance:admin` |
| `finance_document_get` | Its `extraction` now carries `checks`: the outcome, the floor used, each check's result, the matched party and any duplicates | `finance:read` |

REST twins: `POST /api/v1/finance/documents/{id}/check`, `GET` and `PATCH /api/v1/finance/capture/settings`.
