Models
Receipt
Documentation for the Receipt document model
Overview
The Receipt model extracts and structures information from receipts, including merchant information, line items, payments, and tax details.
Schema Structure
Root Level Fields
Field | Type | Description |
---|---|---|
MerchantName | string? | Name of the merchant issuing the receipt |
MerchantPhoneNumber | string? | Listed phone number of merchant |
MerchantAddress | Address? | Listed address of merchant |
Total | number? | Full transaction total of receipt |
Subtotal | number? | Subtotal before taxes |
TotalTax | number? | Total tax amount |
Tip | number? | Tip amount |
TransactionDate | string? | Date the receipt was issued |
TransactionTime | string? | Time the receipt was issued |
CountryRegion | string? | Country or region where receipt was issued |
ReceiptType | string? | Type of receipt |
Line Item Fields
Each item in the Items
array contains:
Field | Type | Description |
---|---|---|
Description | string? | Item description |
TotalPrice | number? | Total price for this line item |
Quantity | number? | Quantity of each item |
Price | number? | Individual price of each item unit |
ProductCode | string? | Product code or SKU |
QuantityUnit | string? | Unit of measure |
Payment Fields
Each payment in the Payments
array contains:
Field | Type | Description |
---|---|---|
Method | string? | Method of payment |
Amount | number? | Amount of payment |
Tax Detail Fields
Each tax detail in the TaxDetails
array contains:
Field | Type | Description |
---|---|---|
Amount | number? | Tax amount |
Rate | number? | Tax rate as a percentage |
NetAmount | number? | Net amount before tax |
Description | string? | Description of the tax |
Type Definitions
Validation Rules
Basic Validation
- All fields are optional by default
- Items, Payments, and TaxDetails default to empty arrays if not specified
Strict Validation
The following fields are required in strict mode:
- MerchantName
- Total
- TransactionDate
- Items (minimum 1 item)
Example Usage
Date Handling
The model accepts dates in multiple formats:
- ISO 8601 datetime strings
- YYYY-MM-DD format
All dates are converted to ISO format during validation.
Best Practices
- Always validate receipts:
- Access data through the result property:
- Handle optional fields appropriately:
- Check arrays before processing:
- Calculate totals carefully: