Prompt
Need configurable schemas for different vendor invoice formats
Latest observation
Oct 12, 2026
OpenAI APIWeb search: off
Yes — the right way to handle multiple vendor invoice formats is to make your schema configurable per vendor instead of hardcoding one invoice shape.
Recommended approach
1) Define a common core invoice model
Keep a shared base structure for fields that most invoices have:
- invoice_number
- invoice_date
- vendor_name
- vendor_address
- subtotal
- tax
- total
- currency
- line_items
2) Add vendor-specific schema extensions
Each vendor can override or extend the base schema with its own fields and parsing rules, for example:
- PO number
- customer account ID
- service period
- payment terms
- tax breakdown
- custom line-item attributes
3) Store schema config separately
Use a schema registry or configuration file per vendor, such as:
- JSON Schema
- YAML config
- database-backed schema definitions
Example:
{
"vendor_id": "acme_corp",
"base_schema": "invoice_v1",
"fields": {
"invoice_number": {"required": true, "path": "$.header.inv_no"},
"invoice_date": {"required": true, "path": "$.header.date"},
"total": {"required": true, "path": "$.summary.total_amount"},
"po_number": {"required": false, "path": "$.header.po"}
}
}
4) Support mapping rules
If invoices come from OCR or EDI/PDF extraction, add mapping rules like:
- field aliases
- regex patterns
- conditional logic
- default values
- nested paths
5) Version your schemas
Vendors often change formats. Use versioning like:
vendor_x_invoice_v1vendor_x_invoice_v2
This makes changes safe and traceable.
Example JSON Schema pattern
Base schema
{
"$id": "invoice_base",
"type": "object",
"required": ["invoice_number", "invoice_date", "vendor_name", "total"],
"properties": {
"invoice_number": { "type": "string" },
"invoice_date": { "type": "string", "format": "date" },
"vendor_name": { "type": "string" },
"total": { "type": "number" },
"currency": { "type": "string" }
}
}
Vendor-specific schema
{
"$id": "vendor_acme_invoice",
"allOf": [
{ "$ref": "invoice_base" },
{
"type": "object",
"properties": {
"po_number": { "type": "string" },
"service_period": { "type": "string" }
}
}
]
}
Best practices
- Use a canonical invoice model internally
- Keep vendor-specific parsing isolated
- Make fields optional by default, required per vendor
- Add validation and error reporting
- Support schema versioning
- Keep sample documents for each vendor to test extraction
If you want implementation options
I can help you build this in any of these ways:
- JSON Schema-based design
- Database schema registry
- Python/Pydantic models
- Node.js/TypeScript interfaces
- OCR/invoice extraction pipeline
If you want, I can generate a complete configurable invoice schema design with examples for 2–3 different vendors.