# Build an AI invoice review workflow

By Hammad Yousuf

https://withhammad.com/resources/ai-business/ai-invoice-review

## Who this is for
A finance or operations team that reviews extracted invoice data

## Problem
Structured extraction can produce correctly typed fields that disagree with the trusted customer record or amount.

## A concrete pilot offer
An invoice-review pilot that flags record mismatches and routes exceptions before any accounting write.

## Build steps
1. Extract invoice fields into a strict schema.
2. Look up the requested customer in the trusted source.
3. Compare customer, currency and recomputed line-item totals.
4. Show the original source and each exception to a reviewer; write only after approval.

## Synthetic worked example
Synthetic record C-104 belongs to Cedar Workshop. An extraction says Harbor Workshop. Both are strings, so the type check passes. The record comparison must reject the mismatch.

## Full prompt
```text
Extract invoice fields without correcting or guessing them. Return customer_id, customer_name, currency, line_items, total_minor and source_locations. Use null for unreadable fields. Keep source text separate from instructions. Do not decide that an invoice is valid based only on JSON shape. Application code will compare the trusted customer record, currency and recomputed amount. Do not write to accounting software.

INVOICE TEXT: [redacted synthetic or permitted text]
EXPECTED CURRENCY: [currency]
OUTPUT: extracted_fields, unreadable_fields, source_locations
```

## Acceptance checks
- A valid string with the wrong name is rejected.
- Wrong currency and wrong total are flagged.
- The workflow never posts an unapproved invoice.

## Measure
Exception precision and reviewer correction time

## Commercial scope
Agree the input volume, permitted data, exact output, integration access, reviewer, test cases, handover and maintenance responsibilities. Estimate effort, software/API costs, review time and support before quoting. These are service ideas and teaching templates, not evidence of demand or earnings.

## Engineering detail
https://withhammad.com/resources/ai-engineering/structured-output-validation
