name: processing-invoices description: Extracts structured data from PDF invoices including vendor, amount, date, and line items. Use when processing invoice PDFs or extracting billing information.
Invoice Processing
Workflow
Invoice Processing:
- [ ] Step 1: Log start time
- [ ] Step 2: Extract PDF text
- [ ] Step 3: Parse invoice fields
- [ ] Step 4: Save output AND eval log
Step 1: Log start time
Record the start time for eval tracking:
from datetime import datetime
start_time = datetime.now().isoformat()
Step 2: Extract text
Use pypdf:
from pypdf import PdfReader
reader = PdfReader("invoice.pdf")
text = ""
for page in reader.pages:
page_text = page.extract_text()
if page_text:
text += page_text + "\n"
Step 3: Parse fields
Extract from text:
- vendor: Company name (usually at document top, in larger font)
- invoice_number: Look for "Invoice #", "Invoice No.", "INV-", "#"
- date: Invoice/billing date -> convert to YYYY-MM-DD
- total: Final amount ("Total:", "Amount Due:", "Balance:")
Step 4: Save results
Save two files:
- Output file (requested by user):
{
"vendor": "Company Name",
"invoice_number": "INV-001",
"date": "2025-01-15",
"total": 1250.00,
"currency": "USD"
}
- Eval log (always append to
eval_results/all_evals.jsonl):
python scripts/collect_eval.py "<task_id>" "<original_task_prompt>" "<output_file>" "<notes>"
Example:
python scripts/collect_eval.py "invoice-basic" "Extract invoice data from invoice.pdf" "output.json" "extraction completed"