Skip to main content
Version: 0.3.0

Tax API

The tax module provides a standardized way to define tax rates, exemption reasons, and specific tax categories. This module is built around the UNTDID 5305 (Tax Category Code) standard, which is crucial for international e-invoicing and frameworks like ZUGFeRD.

While simple ratios (e.g., 19%) can often be used directly on items, using the tax module is mandatory for 0% tax rates, exemptions, reverse charges, or when your region has multiple tax categories sharing the same percentage.


Core Tax Functions

These are the most common tax categories, available directly from the main tax module.

info

The grounds parameter: All tax functions accept an optional grounds parameter (a string). This is used to provide the legal justification for the tax application. Providing a grounds text is highly recommended (and often legally required) for any 0% tax rate or exemption.

FunctionCodeDescription
vat(rate, grounds: none)SStandard Rate: The default VAT/GST rate for your region (e.g., tax.vat(19%)).
lower-rate(rate, grounds: none)AALower Rate: Used for reduced tax brackets like food or books.
exempt(grounds: none)EExempt from Tax: General tax exemption (always 0%).
reverse-charge(grounds: none)AEVAT Reverse Charge: Tax liability is shifted to the recipient (always 0%).
intra-community(grounds: none)KIntra-community Supply: VAT exempt for EEA intra-community supply of goods and services (always 0%).
export(grounds: none)GFree export item: Tax not charged for exports outside the tax zone (always 0%).
outside-scope(grounds: none)OOutside Scope: Services that fall completely outside the scope of the tax system (always 0%).
zero(grounds: none)ZZero Rated Goods: Standard zero-rated items (always 0%).

Example Usage:

#import "@preview/invoice-pro:0.1.0": item, tax

item(
name: "Consulting (B2B EU)",
price: 1500.00,
tax: tax.reverse-charge(grounds: "Tax liability of the recipient according to...")
)

Special Tax Functions (tax.special)

For less common scenarios, industry-specific margin schemes, or specific regional taxes, the module provides a special submodule.

You can access these via tax.special.<function-name>.

Margin Schemes

FunctionCodeDescription
margin-travel(rate, grounds: none)DVAT margin scheme for travel agents.
margin-second-hand(rate, grounds: none)FVAT margin scheme for second-hand goods.
margin-art(rate, grounds: none)IVAT margin scheme for works of art.
margin-antiques(rate, grounds: none)JVAT margin scheme for collector’s items and antiques.

Regional Taxes

FunctionCodeDescription
canary-islands(rate, grounds: none)LCanary Islands general indirect tax (IGIC).
ceuta-melilla(rate, grounds: none)MTax for production, services and importation in Ceuta and Melilla (IPSI).

Special Scenarios & Duties

FunctionCodeDescription
exempt-for-resale(grounds: none)ABExempt for resale (always 0%).
vat-not-due(rate, grounds: none)ACValue Added Tax not now due for payment.
mixed(rate, grounds: none)AMixed tax rate.
transferred(rate, grounds: none)BTransferred VAT.
duty-paid(rate, grounds: none)CDuty paid by supplier.
higher-rate(rate, grounds: none)HHigher tax rate.
standard-additional(rate, grounds: none)NStandard rate additional VAT.

Custom Tax Categories (tax.new)

If you encounter a specific requirement that is not covered by the standard library functions above, you can define a custom tax category using the internal tax.new function.

warning

Only use this if you know exactly which UNTDID 5305 tax category code your accounting software or e-invoicing standard expects.

KeyTypeDescription
rateratioThe numeric tax rate (e.g., 19% or 0%).
categorystrThe official UN/CEFACT EDIFACT 5305 tax category code (e.g., "S", "Z").
labelstrA human-readable identifier or label for the tax type.
groundsstr | noneThe legal justification for this tax setting.

Example:

#import "@preview/invoice-pro:0.1.0": tax

#let custom-tax = tax.new(
rate: 0%,
category: "E",
label: "custom-exemption",
grounds: "Exempt based on local regulation paragraph 42."
)