Invoice Extraction Workflow
Automated extraction of supplier invoice data from bulk-scanned PDF documents using Claude AI Vision.
System: Invoice Extraction Server (Node.js + Claude API) Integration: Zoho Creator → Extraction Server → Zoho Creator Processing time: ~2-5 minutes per bulk PDF (depends on page count)
Overview
The invoice extraction workflow processes bulk-scanned PDFs from Australian auto parts suppliers, automatically splitting them into individual invoices and extracting structured data for matching against purchase orders.
What It Extracts
| Field | Description | Example |
|---|---|---|
supplier_name | Supplier/vendor name | "Australian Automotive Group" |
invoice_number | Invoice identifier | "INV-2024-12345" |
customer_account | CrashClaim's account number | "ACC12345" |
po_number | Purchase order reference | "PO-2024-001" |
invoice_date | Invoice date | "15/07/2026" |
vehicle_id / rego | Vehicle registration | "ABC123" |
sub_total | Subtotal excluding GST | 450.50 |
invoice_total | Total including GST | 495.55 |
freight | Freight/delivery charge | 12.00 |
line_items[] | Array of invoice line items | See below |
Line Item Structure:
description- Part descriptionpart_number- Manufacturer part numberquantity- Quantity orderedunit_list- List price ex GSTunit_net- Net price ex GST (expected)total- Line total ex GST
Process Flow
graph TD
A[User uploads bulk PDF to Zoho] --> B[Zoho Creator webhook triggers]
B --> C[Extraction Server: Download PDF]
C --> D[Split PDF into pages]
D --> E[Detect blank pages]
E --> F[Group pages into invoices]
F --> G[Extract data with Claude Vision]
G --> H[Validate extracted data]
H --> I[Send data to Zoho API]
I --> J[Zoho creates/updates records]
J --> K[Send push notification]
K --> L[Complete]
Step-by-Step Process
1. File Upload & Trigger
Who: Parts team, Claims handlers Where: Zoho Creator → Upload Parts/Order Invoice report What happens:
- User uploads bulk-scanned PDF containing multiple invoices
- Zoho Creator webhook fires immediately
- Webhook payload includes:
- Record ID
- File URL
- Environment (dev/production)
2. PDF Download
System: Invoice Extraction Server What happens:
- Server downloads PDF from Zoho Creator using OAuth token
- Saves to temporary directory:
temp/{job_id}/ - Retry mechanism: 3 attempts with 3-second intervals
:::info Retry Logic If the download fails (network error, timeout, etc.), the server automatically retries up to 3 times with a 3-second delay between attempts. This handles transient network issues without manual intervention. :::
3. PDF Processing
Technology: pdf2pic + GraphicsMagick What happens:
- PDF split into individual page images (PNG format)
- Each page converted to high-resolution image for Vision AI
- Blank pages detected using pixel analysis
- Output: Array of page images in
temp/{job_id}/pages/
4. Invoice Grouping
Algorithm: Sequential page analysis What happens:
- Analyzes page patterns to identify invoice boundaries
- Groups consecutive pages belonging to same invoice
- Tracks page ranges:
{invoiceNumber: 1, startPage: 1, endPage: 3}
5. Data Extraction (Claude Vision)
Model: Claude Opus 4 (Anthropic) What happens:
- Each invoice (group of pages) sent to Claude Vision API
- AI extracts all header fields and line items
- Returns structured JSON matching schema
- No retry mechanism - single attempt per invoice
Prompt engineering:
- Supplier-specific extraction rules
- Australian invoice format handling
- GST calculation validation
- Part number normalization
6. Data Validation
Checks performed:
- Required fields present (supplier, invoice number, total)
- Date format validation (dd/MM/yyyy)
- Numeric field validation (totals, quantities)
- GST calculation verification (10% of subtotal)
- Line item total = sum of all line totals
7. Send to Zoho API
Endpoint: Custom Zoho Creator API Environment-aware:
- Development:
dev_invoice_extraction - Production:
Invoice_Extraction_Integration
Payload:
{
"record_id": "1234567890",
"invoice_number": "Invoice_1",
"page_count": 3,
"start_page": 1,
"end_page": 3,
"extraction_success": true,
"supplier_name": "Australian Automotive Group",
"customer_account": "ACC12345",
"po_number": "PO-2024-001",
"invoice_date": "15/07/2026",
"freight": 12.00,
"vehicle_id": "ABC123",
"rego": "ABC123",
"sub_total": 450.50,
"invoice_total": 495.55,
"line_items": [...]
}
No retry mechanism - single attempt
8. Zoho Record Creation
What happens in Zoho:
- Creates individual invoice record per extracted invoice
- Links to original bulk upload record
- Stores extracted data in structured fields
- Updates bulk upload status to "completed"
9. Push Notification
Trigger: After all invoices processed Who gets notified: Parts team Channel: Zoho notification system
Error Handling
| Error Type | Handling |
|---|---|
| File download failure | Retry 3 times with 3s delay, then fail job |
| PDF processing error | Mark invoice as failed, continue with others |
| Claude API error | Mark invoice as failed, log error, no retry |
| Zoho API error | Mark invoice as failed, log error, no retry |
| Validation failure | Mark as failed with validation errors |
:::caution No Automatic Retries for AI/API Calls Claude API calls and Zoho API calls do NOT have automatic retry mechanisms. If these fail, the invoice is marked as failed and requires manual review. :::
Environment Configuration
The system supports two environments:
| Environment | Zoho API | Use Case |
|---|---|---|
| Development | dev_invoice_extraction | Testing, UAT |
| Production | Invoice_Extraction_Integration | Live processing |
Environment is specified in the webhook payload.
Monitoring & Status Tracking
Job Status Endpoint: GET /api/jobs/:job_id
Status values:
processing- Extraction in progresscompleted- All invoices processed successfullyfailed- Critical error occurred
Progress tracking:
- Total invoices detected
- Invoices processed so far
- Invoices failed
- Current step description
Temporary File Cleanup
When: After job completion (success or failure)
What: Deletes entire temp/{job_id}/ directory
Why: Prevent disk space issues, remove sensitive data
Best Practices
For Parts Team
- Scan quality matters - Clear, high-contrast scans extract better
- One supplier per PDF - Better grouping accuracy
- Remove blank pages - Faster processing
- Check extraction results - Review failed invoices manually
For IT/Developers
- Monitor logs - CloudWatch/server logs show extraction issues
- Failed invoice review - Manual intervention needed for extraction failures
- API rate limits - Claude API has rate limits, batch uploads carefully
- Test in dev first - Always test bulk uploads in development environment
Troubleshooting
Common Issues
| Issue | Cause | Solution |
|---|---|---|
| File download fails after 3 retries | Zoho API timeout, invalid URL | Check Zoho file URL, verify OAuth token |
| All invoices fail extraction | Claude API key invalid/expired | Verify ANTHROPIC_API_KEY in environment |
| Wrong invoice grouping | Poor scan quality, missing pages | Rescan with higher quality, include all pages |
| Missing line items | Low image resolution | Increase scan DPI to 300+ |
| Zoho API errors | Wrong environment, invalid payload | Check environment setting, verify API keys |
Technical Details
Server: Node.js 20 + Express
Deployment: Docker container on EC2
Image: AWS ECR (invoice-extraction-server:latest)
Dependencies:
@anthropic-ai/sdk- Claude AI APIpdf2pic- PDF to image conversionsharp- Image processingaxios- HTTP clientpdf-lib- PDF manipulation
Resource requirements:
- Memory: 2GB minimum
- Disk: 10GB temporary storage
- Network: Stable connection to Zoho + Anthropic APIs
Related Documentation
- PO PDF Extraction - Cost Price Report extraction
- Parts Assessment Extraction - Parts & Sublet List extraction
- Reference: Order Parts Form - Destination for matched line items
- Reference: Purchase Order Form - PO matching rules
For technical support or issues, contact the development team.