CommercialDocument
Base schema for all commercial documents (invoices, quotes, delivery notes, orders, credit notes, etc.) - universal across all countries and business types. This schema uses intentional denormalization for addresses to maintain point-in-time historical accuracy.
Properties
| Property | Type | Mode | Description | Required |
|---|---|---|---|---|
| documentNumber | string | stored | Unique document number/reference Example: | Required |
| documentType | DocumentType | stored | Type of document (reference to DocumentType entity) | Required |
| status | string | enum | Current status of the document in its lifecycle Example: | Required |
| version | number | stored | Version number of this document (1 for original, incremented for revisions) Example: | Required |
| previousVersion | CommercialDocument | stored | Reference to the previous version if this is a revision | Optional |
| revisionReason | string | stored | Reason for creating this revision (if applicable) | Optional |
| issueDate | Date | stored | Date when the document was issued Example: | Required |
| validUntil | Date | stored | Validity date (typically used for quotes and offers) Example: | Optional |
| dueDate | Date | stored | Payment due date (for invoices) - if not set, computed from issueDate and paymentTerms Example: | Optional |
| deliveryDate | Date | stored | Actual or expected delivery date (for orders and delivery notes) | Optional |
| issuer | Organization | stored | Organization issuing the document (seller/supplier) | Required |
| issuerName | string | stored | Cached name of issuer organization for quick display and historical accuracy Example: | Optional |
| recipient | Organization | Person | stored | Recipient of the document (buyer/customer) | Required |
| recipientName | string | stored | Cached name of recipient (organization or person) for quick display and historical accuracy Example: | Optional |
| billingAddress | PostalAddress | stored | Billing address at the time of document issuance (snapshot from recipient entity for point-in-time historical accuracy) | Required |
| shippingAddress | PostalAddress | stored | Shipping/delivery address at the time of document issuance (snapshot for point-in-time historical accuracy) | Optional |
| lineItems | CommercialDocumentLine[] | stored | Line items/products in the document (composition relationship - line items are part of the document lifecycle) | Optional |
| lineItemCount | number | computed | Number of line items in this document (computed from lineItems.length) | Optional |
| currency | Currency | stored | Currency used throughout this document - all monetary amounts must use this currency | Required |
| language | Language | stored | Language of the document content (for internationalization) Example: | Optional |
| locale | string | stored | Locale for number and date formatting (e.g., 'en-US', 'fr-FR', 'de-DE') Example: | Optional |
| subtotalAmount | MonetaryAmount | computed | Sum of all line items before taxes and discounts (computed: sum of lineItems[].quantity * lineItems[].unitPrice) | Optional |
| discountPercentage | number | stored | Discount percentage applied to the entire document (alternative to discountAmount) Example: | Optional |
| discountAmount | MonetaryAmount | stored | Fixed discount amount applied to the entire document (alternative to discountPercentage) | Optional |
| discountReason | string | stored | Reason for discount (early payment, bulk order, promotion, customer loyalty, etc.) Example: | Optional |
| taxAmount | MonetaryAmount | computed | Total tax amount across all line items (computed: sum of taxes from lineItems) | Optional |
| taxDetails | TaxEntry[] | computed | Breakdown of taxes by rate and jurisdiction (computed from line items, grouped by tax rate) | Optional |
| isTaxExempt | boolean | stored | Whether this document is exempt from taxes | Optional |
| taxExemptionReason | string | stored | Reason for tax exemption (if applicable) | Optional |
| totalAmount | MonetaryAmount | computed | Final total amount (computed: subtotalAmount + taxAmount - discountAmount). For finalized documents, this value is cached. | Required |
| amountPaid | MonetaryAmount | computed | Total amount paid so far (computed from related payment records) | Optional |
| balanceDue | MonetaryAmount | computed | Remaining amount to be paid (computed: totalAmount - amountPaid) | Optional |
| isOverdue | boolean | computed | Whether payment is past due date (computed: current date > dueDate and balanceDue > 0) | Optional |
| totalsLocked | boolean | stored | Whether computed totals have been calculated and locked (true for finalized documents beyond draft status) | Optional |
| paymentTerms | PaymentTerm | stored | Payment terms and conditions (reference to PaymentTerm entity) | Optional |
| deliveryMethod | string | enum | Shipping/delivery method | Optional |
| trackingNumber | string | stored | Shipping tracking number (if applicable) | Optional |
| carrier | Organization | stored | Shipping carrier organization (reference to carrier/logistics company) | Optional |
| notes | string | stored | Additional notes or comments | Optional |
| internalNotes | string | stored | Internal notes not visible to recipient | Optional |
| termsAndConditions | string | stored | Terms and conditions text applicable to this document | Optional |
| relatedDocuments | CommercialDocument[] | stored | Related documents in the transaction chain (quote -> order -> invoice -> credit note). Note: For complex relationship tracking, consider using a separate CommercialDocumentRelation junction entity. | Optional |
| attachments | Document[] | stored | Attached files (PDF, images, supporting documents, etc.) - references to Document entity | Optional |
| legalEntity | Organization | stored | Legal entity responsible for this document (may differ from issuer for multi-entity organizations) | Optional |
| fiscalYear | number | stored | Fiscal year this document belongs to Example: | Optional |
| fiscalPeriod | string | stored | Fiscal period within the year (Q1, Q2, Q3, Q4, or month) Example: | Optional |
| approvedBy | Person | stored | Person who approved this document (if approval is required) | Optional |
| approvedDate | Date | stored | Date when this document was approved | Optional |
| metadata | object | stored | Country-specific, industry-specific, or custom fields for extensibility | Optional |
Examples
Example 1
{
"@type": "CommercialDocument",
"documentNumber": "INV-2024-001",
"documentType": {
"@type": "DocumentType",
"code": "invoice",
"name": "Invoice"
},
"status": "sent",
"version": 1,
"issueDate": "2024-01-15",
"dueDate": "2024-02-15",
"issuer": {
"@type": "Organization",
"name": "Acme Corp"
},
"issuerName": "Acme Corp",
"recipient": {
"@type": "Organization",
"name": "Client Company"
},
"recipientName": "Client Company",
"billingAddress": {
"@type": "PostalAddress",
"streetAddress": "456 Client Street",
"addressLocality": "New York",
"addressRegion": "NY",
"postalCode": "10001",
"addressCountry": "US"
},
"lineItems": [
{
"@type": "CommercialDocumentLine",
"lineNumber": 1,
"description": "Professional Services - Consulting",
"quantity": 10,
"unitPrice": {
"@type": "MonetaryAmount",
"value": 150,
"currency": {
"@type": "Currency",
"code": "USD",
"symbol": "$"
}
},
"taxRate": 10
}
],
"lineItemCount": 1,
"currency": {
"@type": "Currency",
"code": "USD",
"symbol": "$"
},
"language": "en",
"locale": "en-US",
"subtotalAmount": {
"@type": "MonetaryAmount",
"value": 1500,
"currency": "USD"
},
"taxAmount": {
"@type": "MonetaryAmount",
"value": 150,
"currency": "USD"
},
"totalAmount": {
"@type": "MonetaryAmount",
"value": 1650,
"currency": "USD"
},
"balanceDue": {
"@type": "MonetaryAmount",
"value": 1650,
"currency": "USD"
},
"amountPaid": {
"@type": "MonetaryAmount",
"value": 0,
"currency": "USD"
},
"isOverdue": false,
"totalsLocked": true,
"fiscalYear": 2024,
"fiscalPeriod": "Q1"
}Example 2
{
"@type": "CommercialDocument",
"documentNumber": "QUOTE-2024-042",
"documentType": {
"@type": "DocumentType",
"code": "quote",
"name": "Quotation"
},
"status": "sent",
"version": 1,
"issueDate": "2024-03-01",
"validUntil": "2024-03-31",
"issuer": {
"@type": "Organization",
"name": "Tech Solutions Inc"
},
"issuerName": "Tech Solutions Inc",
"recipient": {
"@type": "Person",
"givenName": "John",
"familyName": "Smith"
},
"recipientName": "John Smith",
"billingAddress": {
"@type": "PostalAddress",
"streetAddress": "789 Customer Ave",
"addressLocality": "Boston",
"addressRegion": "MA",
"postalCode": "02115",
"addressCountry": "US"
},
"shippingAddress": {
"@type": "PostalAddress",
"streetAddress": "789 Customer Ave",
"addressLocality": "Boston",
"addressRegion": "MA",
"postalCode": "02115",
"addressCountry": "US"
},
"lineItems": [
{
"@type": "CommercialDocumentLine",
"lineNumber": 1,
"description": "Website Development",
"quantity": 1,
"unitPrice": {
"@type": "MonetaryAmount",
"value": 5000,
"currency": {
"@type": "Currency",
"code": "USD",
"symbol": "$"
}
},
"taxRate": 10
}
],
"lineItemCount": 1,
"currency": {
"@type": "Currency",
"code": "USD",
"symbol": "$"
},
"language": "en",
"locale": "en-US",
"subtotalAmount": {
"@type": "MonetaryAmount",
"value": 5000,
"currency": "USD"
},
"discountPercentage": 10,
"discountAmount": {
"@type": "MonetaryAmount",
"value": 500,
"currency": "USD"
},
"discountReason": "First-time customer discount",
"taxAmount": {
"@type": "MonetaryAmount",
"value": 450,
"currency": "USD"
},
"totalAmount": {
"@type": "MonetaryAmount",
"value": 4950,
"currency": "USD"
},
"totalsLocked": true,
"notes": "This quote is valid for 30 days. Payment terms: 50% upfront, 50% upon completion.",
"fiscalYear": 2024,
"fiscalPeriod": "Q1"
}