Invoice Processor
Extracts structured financial data from invoice PDFs, scanned images, and email attachments — capturing vendor details, line items, totals, and payment terms — and routes invoices through configurable approval workflows with validation and exception handling.
When to Use
- User provides an invoice PDF or image and needs the data extracted
- Accounts payable workflow requires automated invoice ingestion
- Multiple invoices need to be batch-processed and entered into a system
- An invoice needs to be validated against a purchase order or contract
- Invoice data needs to be exported to an accounting system (QuickBooks, Xero, SAP, NetSuite)
- User asks to automate the invoice approval routing process
- Duplicate or fraudulent invoices need to be detected
Process
Ingest the document:
- Accept: PDF, JPEG/PNG scan, TIFF, email attachment, or forwarded email body
- Detect document type: standard invoice, credit memo, pro forma invoice, receipt, or statement
- Assess quality: if the document is blurry, skewed, or low-resolution, attempt deskewing and enhance contrast before extraction; flag if quality is too low for reliable extraction
Extract structured fields using OCR and NLP:
Header fields:
- Invoice number / reference ID
- Invoice date and due date
- PO number (if referenced)
- Vendor name, address, tax ID / VAT number, contact email/phone
- Bill-to name and address
- Ship-to name and address (if different)
- Payment terms (e.g., "Net 30", "Due on receipt")
- Currency
Line items (for each line):
- Description / item name
- Quantity
- Unit price
- Discount (if applicable)
- Line total (quantity × unit price − discount)
Footer fields:
- Subtotal
- Tax amount and tax rate(s)
- Shipping / handling charges
- Total amount due
- Bank details / payment instructions (IBAN, ACH, wire)
Validate extracted data:
- Verify arithmetic: confirm subtotal = sum of line totals; total = subtotal + tax + shipping
- Flag discrepancies (e.g., line items sum to $1,480 but subtotal reads $1,450) as extraction errors or document errors
- Cross-reference against any provided PO: check vendor, amounts, and line items match
- Detect potential duplicates: flag invoices with same vendor + amount + invoice number as a prior processed invoice
- Validate dates: due date should be ≥ invoice date; invoice date should not be more than 90 days in the past (flag as stale)
Flag exceptions:
- 🔴 High priority: arithmetic mismatch, duplicate invoice, missing mandatory fields (invoice number, amount, vendor), amounts above approval threshold
- 🟡 Medium: missing PO reference, date anomalies, unfamiliar vendor name, unusually large line item
- 🟢 Low: minor formatting issues, optional fields absent
Route for approval:
- Apply approval routing rules based on: invoice amount, vendor, department/cost center, or expense category
- Default rules (customizable):
- ≤ $500: auto-approve if PO matches
- $500–$5,000: line manager approval
$5,000: finance director approval
- Output: approval task assigned to the appropriate approver with invoice summary attached
Export to accounting system:
- Format the extracted data as the target system's required format (JSON, CSV, XML, API payload)
- Map fields to accounting system schema (e.g., vendor → supplier_name, total_due → invoice_amount)
- Include: extracted values, confidence scores, and flags for human review
Output Format
Extracted Invoice Data
{
"document_type": "Invoice",
"extraction_confidence": 0.97,
"flags": [],
"header": {
"invoice_number": "INV-2025-00482",
"invoice_date": "2025-06-01",
"due_date": "2025-07-01",
"payment_terms": "Net 30",
"po_number": "PO-8821",
"currency": "USD",
"vendor": {
"name": "Acme Design Studio",
"address": "123 Creative Blvd, Austin, TX 78701",
"tax_id": "82-1234567",
"email": "billing@acmedesign.com"
},
"bill_to": {
"name": "Globex Corporation",
"address": "456 Corporate Ave, New York, NY 10001"
}
},
"line_items": [
{ "description": "Logo Redesign", "qty": 1, "unit_price": 2500.00, "total": 2500.00 },
{ "description": "Brand Style Guide", "qty": 1, "unit_price": 1500.00, "total": 1500.00 }
],
"totals": {
"subtotal": 4000.00,
"tax_rate_pct": 8.25,
"tax_amount": 330.00,
"shipping": 0.00,
"total_due": 4330.00
},
"payment_instructions": {
"bank": "Chase Bank",
"account": "****4821",
"routing": "021000021"
},
"validation": {
"arithmetic_check": "PASS",
"duplicate_check": "PASS",
"po_match": "PASS"
},
"routing": {
"approval_required": true,
"approver": "finance_director@globex.com",
"reason": "Amount $4,330 exceeds $5,000 manager threshold — routed to Finance Director"
}
}
Exception Report
🔴 EXCEPTION: INV-2025-00483
Issue: Arithmetic mismatch — line items sum to $1,480.00 but subtotal reads $1,450.00. Difference: $30.00.
Action: Flagged for manual review. Do NOT auto-approve until vendor confirms correct total.
Assigned to: ap-review@company.com
Examples
Example Input
Extract all data from this invoice PDF and check if the math is correct. Route it for approval.
Example Output
✅ Extraction complete (confidence: 96%)
Invoice: INV-2025-00482 | Vendor: Acme Design Studio | Total Due: $4,330.00
Due Date: July 1, 2025 | PO Match: ✅ PO-8821
Line Items:
1. Logo Redesign × 1 — $2,500.00
2. Brand Style Guide × 1 — $1,500.00
Subtotal: $4,000.00 + 8.25% tax ($330.00) = $4,330.00 ✅ Math verified.
No duplicates found. Routing to finance_director@globex.com for approval ($4,330 > $5,000 threshold).
Boundaries
- Do NOT auto-approve invoices without human sign-off when amounts exceed the defined threshold.
- Flag all arithmetic mismatches and duplicate invoice candidates for human review — never process them silently.
- Do NOT store invoice data, including bank account or tax ID details, beyond the immediate processing task.
- Treat all extracted financial data as confidential — do not log or expose vendor banking details in plain-text outputs that could be intercepted.
- If extraction confidence is below 85% for critical fields (total amount, vendor name, invoice number), flag for manual re-entry rather than proceeding with low-quality data.
- Do NOT make payment on behalf of the user — output is for review and system ingestion only.
1---2name: invoice-processor3description: Extracts structured line items, totals, and vendor data from invoice PDFs or images and routes them for approval. Invoke when asked to process an invoice, extract invoice data, parse a bill, automate accounts payable, or route invoices for approval.4---56# Invoice Processor78Extracts structured financial data from invoice PDFs, scanned images, and email attachments — capturing vendor details, line items, totals, and payment terms — and routes invoices through configurable approval workflows with validation and exception handling.910## When to Use1112- User provides an invoice PDF or image and needs the data extracted13- Accounts payable workflow requires automated invoice ingestion14- Multiple invoices need to be batch-processed and entered into a system15- An invoice needs to be validated against a purchase order or contract16- Invoice data needs to be exported to an accounting system (QuickBooks, Xero, SAP, NetSuite)17- User asks to automate the invoice approval routing process18- Duplicate or fraudulent invoices need to be detected1920## Process21221. **Ingest the document**:23 - Accept: PDF, JPEG/PNG scan, TIFF, email attachment, or forwarded email body24 - Detect document type: standard invoice, credit memo, pro forma invoice, receipt, or statement25 - Assess quality: if the document is blurry, skewed, or low-resolution, attempt deskewing and enhance contrast before extraction; flag if quality is too low for reliable extraction26272. **Extract structured fields using OCR and NLP**:2829 **Header fields**:30 - Invoice number / reference ID31 - Invoice date and due date32 - PO number (if referenced)33 - Vendor name, address, tax ID / VAT number, contact email/phone34 - Bill-to name and address35 - Ship-to name and address (if different)36 - Payment terms (e.g., "Net 30", "Due on receipt")37 - Currency3839 **Line items** (for each line):40 - Description / item name41 - Quantity42 - Unit price43 - Discount (if applicable)44 - Line total (quantity × unit price − discount)4546 **Footer fields**:47 - Subtotal48 - Tax amount and tax rate(s)49 - Shipping / handling charges50 - Total amount due51 - Bank details / payment instructions (IBAN, ACH, wire)52533. **Validate extracted data**:54 - Verify arithmetic: confirm subtotal = sum of line totals; total = subtotal + tax + shipping55 - Flag discrepancies (e.g., line items sum to $1,480 but subtotal reads $1,450) as extraction errors or document errors56 - Cross-reference against any provided PO: check vendor, amounts, and line items match57 - Detect potential duplicates: flag invoices with same vendor + amount + invoice number as a prior processed invoice58 - Validate dates: due date should be ≥ invoice date; invoice date should not be more than 90 days in the past (flag as stale)59604. **Flag exceptions**:61 - 🔴 **High priority**: arithmetic mismatch, duplicate invoice, missing mandatory fields (invoice number, amount, vendor), amounts above approval threshold62 - 🟡 **Medium**: missing PO reference, date anomalies, unfamiliar vendor name, unusually large line item63 - 🟢 **Low**: minor formatting issues, optional fields absent64655. **Route for approval**:66 - Apply approval routing rules based on: invoice amount, vendor, department/cost center, or expense category67 - Default rules (customizable):68 - ≤ $500: auto-approve if PO matches69 - $500–$5,000: line manager approval70 - > $5,000: finance director approval71 - Output: approval task assigned to the appropriate approver with invoice summary attached72736. **Export to accounting system**:74 - Format the extracted data as the target system's required format (JSON, CSV, XML, API payload)75 - Map fields to accounting system schema (e.g., vendor → supplier_name, total_due → invoice_amount)76 - Include: extracted values, confidence scores, and flags for human review7778## Output Format7980### Extracted Invoice Data81```json82{83 "document_type": "Invoice",84 "extraction_confidence": 0.97,85 "flags": [],86 "header": {87 "invoice_number": "INV-2025-00482",88 "invoice_date": "2025-06-01",89 "due_date": "2025-07-01",90 "payment_terms": "Net 30",91 "po_number": "PO-8821",92 "currency": "USD",93 "vendor": {94 "name": "Acme Design Studio",95 "address": "123 Creative Blvd, Austin, TX 78701",96 "tax_id": "82-1234567",97 "email": "billing@acmedesign.com"98 },99 "bill_to": {100 "name": "Globex Corporation",101 "address": "456 Corporate Ave, New York, NY 10001"102 }103 },104 "line_items": [105 { "description": "Logo Redesign", "qty": 1, "unit_price": 2500.00, "total": 2500.00 },106 { "description": "Brand Style Guide", "qty": 1, "unit_price": 1500.00, "total": 1500.00 }107 ],108 "totals": {109 "subtotal": 4000.00,110 "tax_rate_pct": 8.25,111 "tax_amount": 330.00,112 "shipping": 0.00,113 "total_due": 4330.00114 },115 "payment_instructions": {116 "bank": "Chase Bank",117 "account": "****4821",118 "routing": "021000021"119 },120 "validation": {121 "arithmetic_check": "PASS",122 "duplicate_check": "PASS",123 "po_match": "PASS"124 },125 "routing": {126 "approval_required": true,127 "approver": "finance_director@globex.com",128 "reason": "Amount $4,330 exceeds $5,000 manager threshold — routed to Finance Director"129 }130}131```132133### Exception Report134```135🔴 EXCEPTION: INV-2025-00483136Issue: Arithmetic mismatch — line items sum to $1,480.00 but subtotal reads $1,450.00. Difference: $30.00.137Action: Flagged for manual review. Do NOT auto-approve until vendor confirms correct total.138Assigned to: ap-review@company.com139```140141## Examples142143### Example Input144```145Extract all data from this invoice PDF and check if the math is correct. Route it for approval.146```147148### Example Output149```150✅ Extraction complete (confidence: 96%)151152Invoice: INV-2025-00482 | Vendor: Acme Design Studio | Total Due: $4,330.00153Due Date: July 1, 2025 | PO Match: ✅ PO-8821154155Line Items:1561. Logo Redesign × 1 — $2,500.001572. Brand Style Guide × 1 — $1,500.00158Subtotal: $4,000.00 + 8.25% tax ($330.00) = $4,330.00 ✅ Math verified.159160No duplicates found. Routing to finance_director@globex.com for approval ($4,330 > $5,000 threshold).161```162163## Boundaries164165- Do NOT auto-approve invoices without human sign-off when amounts exceed the defined threshold.166- Flag all arithmetic mismatches and duplicate invoice candidates for human review — never process them silently.167- Do NOT store invoice data, including bank account or tax ID details, beyond the immediate processing task.168- Treat all extracted financial data as confidential — do not log or expose vendor banking details in plain-text outputs that could be intercepted.169- If extraction confidence is below 85% for critical fields (total amount, vendor name, invoice number), flag for manual re-entry rather than proceeding with low-quality data.170- Do NOT make payment on behalf of the user — output is for review and system ingestion only.