Skip to main content
Version: 0.3.0

Base Schema

When authoring custom locales or overriding specific fields, your provided dictionaries are evaluated against the internal base-language and base-region master schemas.

The engine utilizes a Cascading deep-merge strategy. Any key omitted in your custom locale will automatically fall back to the defaults defined in these schemas. This ensures that your invoice template always compiles safely, even if future updates introduce new fields or tax Grounds.


Language Schema (base-language)

The language dictionary acts as the structural template for all translations. It contains exclusively linguistic strings, formatting text, and functions that assemble localized sentences.

info

All string fields within the language schema dictate the static text printed on the document. Functions within payment and global-info are used to syntactically structure dynamic values (like dates and amounts) according to regional grammar rules.

meta

Contains core metadata about the language configuration.

KeyTypeDescription
langstrThe ISO 639-1 language code (e.g., "en", "de").

document

Designations for primary document types.

KeyTypeDescription
invoicestrThe title used for standard invoices (e.g., "Invoice").

address

Labels indicating the address blocks.

KeyTypeDescription
recipientstrLabel above the recipient address (e.g., "Bill To").
senderstrLabel above the sender details (e.g., "From").

reference

Designations for header metadata.

KeyTypeDescription
tax-numberstrLabel for the sender's tax identification (e.g., "Tax ID").
invoice-numberstrLabel for the document identifier (e.g., "Invoice Number").

line-items

Column headers and structural labels for the line-items table.

KeyTypeDescription
positionstrColumn header for the item position index.
descriptionstrColumn header for the item name or description.
quantitystrColumn header for the item amount.
unit-pricestrColumn header for the cost per unit.
pricestrColumn header for the base price.
totalstrColumn header for the final line amount.
vatstrColumn header for the applied tax/VAT rate.
netstrSuffix or label indicating net amounts.
grossstrSuffix or label indicating gross amounts.
discountstrLabel for applied discounts.
surchargestrLabel for applied surcharges.
subtotalstrLabel indicating a running subtotal within the table.

summary

Labels for the calculation footer at the end of the table.

KeyTypeDescription
sumstrLabel for the total sum before taxes.
vat-taxstrLabel for the calculated tax amount.
totalstrLabel for the final amount due.
includingstrShort label for "inclusive of".
excludingstrShort label for "exclusive of".

global-info

Static labels and dynamic text generators placed below the table.

KeyTypeDescription
tax-statement(content, content, content) => contentSentence specifying the universal tax rate applied. Parameters map to (tax-text, rate, vat-tax).
unitstrFallback text if a uniform unit applies to all items.
quantitystrFallback text if a uniform quantity applies to all items.
datestrFallback text if a uniform service date applies to all items.

bank-details

Labels for the payment configuration block.

KeyTypeDescription
account-holderstrLabel for the owner of the bank account.
bankstrLabel for the financial institution.
ibanstrLabel for the International Bank Account Number.
bicstrLabel for the Bank Identifier Code.
referencestrLabel for the payment reference string.

payment

Text blocks and phrasing for payment terms.

KeyTypeDescription
text(content, content) => contentGenerates the final payment instruction sentence. Parameters map to (sum, deadline).
deadline-date(content) => contentText generator for a fixed target date (e.g., [no later than #date]).
deadline-days(int) => strText generator for a relative target date (e.g., [within #str(days) days]).
deadline-soonstrText for immediate/prompt payment.

signature

Greetings and the sign-off area.

KeyTypeDescription
closingstrThe sign-off text (e.g., "Sincerely,").

Standard legal notices.

KeyTypeDescription
vat-exemptionstrThe legal notice for small business exemptions or zero-rated tax scenarios.

errors

Warning messages utilized for incorrect template usage.

KeyTypeDescription
name-missingstrError when the primary name is omitted.
address-missingstrError when the street address is omitted.
city-missingstrError when the city/postal code is omitted.
ambiguous-taxstrError thrown during ambiguous 0% tax resolution.
invalid-taxstrError thrown when an unrecognized tax rate is provided.

Region Schema (base-region)

The region dictionary is responsible for mathematical logic and localized data representation. It dictates how dates are displayed, how currencies are formatted, and how tax structures behave.

danger

Exercise extreme caution when overriding functions in the normalize block. Returning invalid types or unhandled floats here can disrupt Forward/Backward Calculation algorithms, ultimately leading to invalid PDF generation or incorrect invoice totals.

meta

Contains core metadata about the region configuration.

KeyTypeDescription
regionstrThe internal, lower-case identifier of the region (e.g., "de", "us").
country-codestrThe 2-letter ISO 3166-1 alpha-2 country code (e.g., "DE", "CH", "US").

currency

Metadata for the primary currency used in the region. This is essential for structured data payloads like ZUGFeRD or EPC-QR codes.

KeyTypeDescription
codestrThe 3-letter ISO 4217 currency code (e.g., "EUR", "CHF").
symbolstrThe visual symbol of the currency (e.g., "€", "CHF ").
decimalsintThe standard number of subunits/decimal places for financial totals (e.g., 2).
decimals-fineintThe allowed number of decimal places for singular unit prices (usually 4).

normalize

Functions mapping raw inputs to Normalized values.

KeyTypeDescription
moneynumber => numberRounds a numerical value to the standard decimal precision of the region's currency.
money-finenumber => numberRounds a value to a higher precision required for specific unit prices (e.g., fuel).
infer-taxratio => taxInterprets a raw tax value and maps it to a structured regional tax object containing appropriate Grounds.

format

Functions responsible for converting data types into localized strings.

KeyTypeDescription
percent(ratio | number) => strConverts a ratio or number into a localized percentage string.
numbernumber => strFormats a number with regional thousands and decimal separators.
currencynumber => strFormats a value as a currency string with the regional symbol and standard placement.
currency-finenumber => strHigh-precision currency formatting used when unit prices require extra decimals.
date(datetime | (datetime, datetime)) => strFormats a single date or an array defining a date range into a human-readable string.
timedatetime => strFormats a time object into a localized string (e.g., 24h or AM/PM).

tax

Contains default standard tax objects utilized by the region.

KeyTypeDescription
default-vattaxThe standard VAT/Sales Tax rate applied when no specific rate is provided.
small-enterprise-special-schemetaxThe legal tax object used for small businesses or special exemption schemes.

Example: Schema Inspection and Override

When building your own tools or customizing a layout, you can leverage the cascading merge by specifying only the nested keys you wish to alter.

#import "@preview/invoice-pro:0.3.0": invoice, locale

#let custom-lang = (
payment: (
// Update the prompt payment phrasing
deadline-soon: "due immediately upon receipt",
)
)

#show: invoice.with(
locale: locale.build-locale(
custom-lang,
locale.region.en
)
)
note

The normalize.infer-tax function is a vital bridge. Whenever a user types a raw percentage (e.g., 19%) in their line items, this function converts it into a standardized tax object containing the correct Grounds and legal text specific to that region.