Overview

The Invoice model extracts and structures information from invoices, capturing comprehensive details including vendor and customer information, line items, payment details, and tax information.

Schema Structure

Root Level Fields

FieldTypeDescription
CustomerNamestring?Customer being invoiced
CustomerIdstring?Reference ID for the customer
PurchaseOrderstring?Purchase order reference number
InvoiceIdstring?Invoice number or identifier
InvoiceDatestring?Date the invoice was issued
DueDatestring?Due date for payment
VendorNamestring?Name of the vendor issuing the invoice
VendorAddressAddress?Mailing address for the vendor
VendorAddressRecipientstring?Name associated with the vendor address
CustomerAddressAddress?Mailing address for the customer
CustomerAddressRecipientstring?Name associated with the customer address
BillingAddressAddress?Explicit billing address
BillingAddressRecipientstring?Name associated with the billing address
ShippingAddressAddress?Explicit shipping address
ShippingAddressRecipientstring?Name associated with the shipping address
SubTotalnumber?Subtotal amount
TotalDiscountnumber?Total discount amount
TotalTaxnumber?Total tax amount
InvoiceTotalnumber?Total invoice amount
AmountDuenumber?Total amount due
PreviousUnpaidBalancenumber?Previous unpaid balance
RemittanceAddressAddress?Explicit remittance address
RemittanceAddressRecipientstring?Name associated with the remittance address
ServiceAddressAddress?Explicit service address
ServiceAddressRecipientstring?Name associated with the service address
ServiceStartDatestring?First date of service period
ServiceEndDatestring?End date of service period
VendorTaxIdstring?Tax ID of the vendor
CustomerTaxIdstring?Tax ID of the customer
PaymentTermstring?Payment terms
KVKNumberstring?KVK number for Netherlands businesses

Line Item Fields

Each item in the Items array contains:

FieldTypeDescription
Amountnumber?Total amount for this line item
Datestring?Date corresponding to the line item
Descriptionstring?Item description
Quantitynumber?Quantity of each item
ProductCodestring?Product code or SKU
Taxnumber?Tax amount for this line item
TaxRatestring?Tax rate for this line item
Unitstring?Unit of measure
UnitPricenumber?Price per unit

Tax Detail Fields

Each tax detail in the TaxDetails array contains:

FieldTypeDescription
Amountnumber?Tax amount
Ratestring?Tax rate as a percentage

Payment Detail Fields

Each payment detail in the PaymentDetails array contains:

FieldTypeDescription
IBANstring?International bank account number
SWIFTstring?SWIFT/BIC code
BankAccountNumberstring?Bank account number
BPayBillerCodestring?BPay biller code
BPayReferencestring?BPay reference number

Installment Fields

Each installment in the PaidInFourInstallements array contains:

FieldTypeDescription
Amountnumber?Installment amount
DueDatestring?Due date for the installment

Type Definitions

import type {
  Invoice,
  InvoicePaymentDetail,
  InvoiceTaxDetail,
  InvoiceInstallment,
  InvoiceLineItem,
  InvoiceResponse,
  StrictInvoiceResponse
} from '@your-package/models';

Validation Rules

Basic Validation

  • All fields are optional by default
  • Arrays (PaymentDetails, TaxDetails, Items, PaidInFourInstallements) default to empty arrays if not specified

Strict Validation

The following fields are required in strict mode:

  • InvoiceId
  • InvoiceDate
  • CustomerName
  • InvoiceTotal
  • Items (minimum 1 item)

Example Usage

import { validateInvoice } from '@your-package/models';

// Example invoice data
const invoiceData = {
  InvoiceId: "INV-2024-001",
  CustomerName: "John Doe",
  InvoiceDate: "2024-01-01",
  InvoiceTotal: 1100,
  Items: [{
    Description: "Professional Services",
    Quantity: 10,
    UnitPrice: 100,
    Amount: 1000
  }]
};

// Validate the invoice
const validatedInvoice = validateInvoice(invoiceData);

// Access validated data through result property
console.log(validatedInvoice.result.InvoiceTotal);

Date Handling

The model accepts dates in multiple formats:

  • ISO 8601 datetime strings
  • YYYY-MM-DD format strings

All dates are converted to ISO format during validation.