InvoiceTemplate
The InvoiceTemplate interface represents a reusable invoice template that can be used to quickly generate new invoices with predefined items, customer details, and settings.
Unique identifier for the template
Display name for the template (e.g., “Monthly Retainer”, “Consulting Services”)
Optional description explaining when or how to use this template
customer
Partial<Customer>
required
Show Partial customer object
Partial customer information. All customer fields are optional, allowing templates to specify only common fields like country or state. See Customer for available fields.
items
Partial<InvoiceItem>[]
required
Show Array of partial invoice items
Predefined line items with optional fields. Typically includes description and rate, while quantity can be filled in when creating an invoice. See InvoiceItem for available fields.
Optional default notes or terms to include on invoices created from this template
Optional default tax rate as a percentage (e.g., 10 for 10%)
Three-letter ISO 4217 currency code (e.g., “USD”, “EUR”, “GBP”)
Timestamp when the template was created in ISO 8601 format
TypeScript definition
export interface InvoiceTemplate {
id : string ;
name : string ;
description ?: string ;
customer : Partial < Customer >;
items : Partial < InvoiceItem >[];
notes ?: string ;
taxRate ?: number ;
currency : string ;
createdAt : string ;
}
Example
const template : InvoiceTemplate = {
id: "tmpl_abc123" ,
name: "Web Development - Monthly Retainer" ,
description: "Standard monthly retainer for ongoing web development services" ,
customer: {
// Leave most fields empty for flexibility
country: "United States" ,
state: "CA"
},
items: [
{
description: "Monthly Development Hours" ,
rate: 150 ,
// quantity will be filled in per invoice
},
{
description: "Project Management" ,
quantity: 1 ,
rate: 500
},
{
description: "Hosting & Maintenance" ,
quantity: 1 ,
rate: 200
}
],
notes: "Payment due within 30 days. Includes up to 2 hours of support." ,
taxRate: 8.5 ,
currency: "USD" ,
createdAt: "2026-01-15T12:00:00Z"
};
Creating invoices from templates
Templates serve as blueprints for new invoices. When creating an invoice from a template:
Copy predefined items and fill in missing quantities
Merge template customer data with specific customer details
Use template defaults for currency, tax rate, and notes
Generate new invoice-specific fields (id, invoiceNumber, dates, status)
import type { Invoice , InvoiceTemplate } from './types' ;
function createInvoiceFromTemplate (
template : InvoiceTemplate ,
customer : Customer ,
overrides ?: Partial < Invoice >
) : Invoice {
return {
id: generateId (),
invoiceNumber: generateInvoiceNumber (),
date: new Date (). toISOString (),
dueDate: addDays ( new Date (), 30 ). toISOString (),
status: "draft" ,
customer: {
... template . customer ,
... customer // Override template customer with actual customer
},
items: template . items . map ( item => ({
id: generateId (),
description: item . description || "" ,
quantity: item . quantity || 1 ,
rate: item . rate || 0 ,
discount: item . discount ,
taxRate: item . taxRate
})),
notes: template . notes ,
taxRate: template . taxRate ,
currency: template . currency ,
createdAt: new Date (). toISOString (),
updatedAt: new Date (). toISOString (),
... overrides
};
}
Use cases
Templates are useful for:
Recurring services : Monthly retainers with standard line items
Package deals : Predefined service bundles at set prices
Industry-specific invoices : Templates for common services in your industry
Multi-currency invoicing : Separate templates for different currencies
Regional variations : Templates with different tax rates or terms by region