Skip to main content

Template Variables Reference

This document lists all available variables that can be used in PDF templates for different document types.

Common Variables (All Documents)​

VariableTypeDescriptionExample
{{documentNumber}}StringDocument number/ID"SALE-2024-001"
{{locationName}}StringLocation/branch name"Main Store"
{{currency.symbol}}StringCurrency symbol"$", "Q"
{{currency.name}}StringCurrency name"USD", "GTQ"

Sale Document Variables​

Basic Information​

{{documentNumber}}
- Sale document number
{{saleDate}}
- Sale date (use with formatDate helper)
{{status}}
- Sale status (DRAFT, COMPLETED, etc.)
{{locationName}}
- Branch/location name
{{note}}
- Additional notes

Customer Information​

{{taxId}}
- Customer tax ID/NIT
{{taxName}}
- Customer name
{{taxAddress}}
- Customer address
{{customer.taxId}}
- Alternative: Customer tax ID
{{customer.taxName}}
- Alternative: Customer name
{{customer.taxAddress}}
- Alternative: Customer address

FEL (Electronic Tax Document) Information​

{{felAuthorization}}
- FEL authorization number
{{felSerialNumber}}
- FEL serial number
{{felNumber}}
- FEL document number
{{felDateDte}}
- FEL DTE date
{{felCertificationDate}}
- FEL certification date

Items (Array)​

{{#each items}}
{{this.itemType}}
- 'product' or 'service'
{{this.name}}
- Product/service name
{{this.quantity}}
- Quantity sold
{{this.unitPrice}}
- Price per unit
{{this.amount}}
- Total amount (quantity Γ— unitPrice)

{{#if this.inventoryDetails}}
{{#each this.inventoryDetails}}
{{this.quantity}}
- Batch quantity
{{this.batchNumber}}
- Batch number
{{this.serialNumber}}
- Serial number
{{this.productionDate}}
- Production date
{{this.expirationDate}}
- Expiration date
{{/each}}
{{/if}}
{{/each}}

Totals​

{{subtotal}}
- Subtotal before taxes
{{tax}}
- Total tax amount
{{totalAmount}}
- Total amount (including taxes)
{{totalBaseAmount}}
- Total in base currency

Payment Details (Array)​

{{#each paymentDetail}}
{{this.paymentMethodName}}
- Payment method name (Cash, Card, etc.)
{{this.amount}}
- Amount in transaction currency
{{this.baseAmount}}
- Amount in base currency
{{this.exchangeRate}}
- Exchange rate used
{{this.currency.symbol}}
- Currency symbol
{{this.currency.name}}
- Currency name
{{/each}}

{{paymentTotalAmount}}
- Total paid in transaction currency
{{paymentTotalBaseAmount}}
- Total paid in base currency

Purchase Document Variables​

Basic Information​

{{documentNumber}}
- Purchase document number
{{purchaseDate}}
- Purchase date
{{status}}
- Purchase status
{{locationName}}
- Branch/location name
{{notes}}
- Additional notes

Supplier Information​

{{supplier.name}}
- Supplier name
{{supplier.taxId}}
- Supplier tax ID
{{supplier.taxAddress}}
- Supplier address
{{supplier.contact}}
- Supplier contact info

Items (Array)​

{{#each items}}
{{this.product.name}}
- Product name
{{this.quantity}}
- Quantity purchased
{{this.unitPrice}}
- Purchase price per unit
{{this.amount}}
- Total amount

{{#if this.inventoryDetails}}
{{#each this.inventoryDetails}}
{{this.batchNumber}}
{{this.serialNumber}}
{{this.productionDate}}
{{this.expirationDate}}
{{/each}}
{{/if}}
{{/each}}

Totals​

{{subtotal}}
- Subtotal before taxes
{{tax}}
- Total tax amount
{{totalAmount}}
- Total amount
{{totalBaseAmount}}
- Total in base currency

Payment Details​

{{#each paymentDetail}}
{{this.paymentMethodName}}
{{this.amount}}
{{this.baseAmount}}
{{this.currency.symbol}}
{{/each}}

{{paymentTotalAmount}}
{{paymentTotalBaseAmount}}
{{paymentTerms}}
- Payment terms description

Service Booking Variables​

Basic Information​

{{documentNumber}}
- Booking number
{{bookingDate}}
- Booking date
{{scheduledDate}}
- Scheduled service date
{{status}}
- Booking status
{{locationName}}
- Service location

Customer Information​

{{customer.name}}
- Customer name
{{customer.phone}}
- Customer phone
{{customer.email}}
- Customer email
{{customer.taxId}}
- Customer tax ID

Service Details​

{{#each services}}
{{this.serviceName}}
- Service name
{{this.description}}
- Service description
{{this.duration}}
- Service duration
{{this.price}}
- Service price
{{this.assignedTo}}
- Staff member assigned
{{/each}}

Vehicle Information (if applicable)​

{{vehicle.make}}
- Vehicle make
{{vehicle.model}}
- Vehicle model
{{vehicle.year}}
- Vehicle year
{{vehicle.plateNumber}}
- License plate
{{vehicle.vin}}
- VIN number

Handlebars Helpers​

Date Formatting​

{{formatDate dateVariable "format"}}

Examples:
{{formatDate saleDate "dd/MM/yyyy"}}
β†’ 25/01/2024
{{formatDate saleDate "dd MMM, yyyy"}}
β†’ 25 Jan, 2024
{{formatDate saleDate "dd/MM/yyyy HH:mm"}}
β†’ 25/01/2024 14:30

Currency Formatting​

{{formatCurrency amount symbol}}

Examples:
{{formatCurrency totalAmount "$"}}
β†’ $123.45
{{formatCurrency totalAmount "Q"}}
β†’ Q123.45
{{formatCurrency totalAmount currency.symbol}}
β†’ $123.45

Number Formatting​

{{formatNumber number}}

Examples:
{{formatNumber quantity}}
β†’ 1,234.56
{{formatNumber this.quantity}}
β†’ 100

Conditional Rendering​

If Statement​

{{#if variable}}
Content shown when variable exists and is truthy
{{/if}}

{{#if variable}}
Content shown when true
{{else}}
Content shown when false
{{/if}}

Unless Statement​

{{#unless variable}}
Content shown when variable is falsy
{{/unless}}

Each Loop​

{{#each items}}
{{this.name}} - Current item property
{{@index}} - Current iteration index (0-based)
{{@first}} - true if first iteration
{{@last}} - true if last iteration
{{../parentVariable}} - Access parent scope variable
{{/each}}

With Block​

{{#with customer}}
{{name}}
- Access nested properties
{{taxId}}
{{taxAddress}}
{{/with}}

Example Template Snippets​

Basic Header​

<div class="header">
<div class="company-name">FlowPOS</div>
<div class="location">{{locationName}}</div>
<div class="document-number">No. {{documentNumber}}</div>
<div class="date">{{formatDate saleDate "dd/MM/yyyy HH:mm"}}</div>
</div>

Customer Info Section​

<div class="customer-info">
<div class="info-row">
<span class="label">Cliente:</span>
<span>{{taxName}}</span>
</div>
<div class="info-row">
<span class="label">NIT:</span>
<span>{{taxId}}</span>
</div>
{{#if taxAddress}}
<div class="info-row">
<span class="label">DirecciΓ³n:</span>
<span>{{taxAddress}}</span>
</div>
{{/if}}
</div>

Items Table​

<table class="items-table">
<thead>
<tr>
<th>Producto</th>
<th>Cantidad</th>
<th>Precio</th>
<th>Total</th>
</tr>
</thead>
<tbody>
{{#each items}}
<tr>
<td>{{this.name}}</td>
<td>{{formatNumber this.quantity}}</td>
<td>{{formatCurrency this.unitPrice ../currency.symbol}}</td>
<td>{{formatCurrency this.amount ../currency.symbol}}</td>
</tr>
{{/each}}
</tbody>
</table>

Totals Section​

<div class="totals">
<div class="total-row">
<span>Subtotal:</span>
<span>{{formatCurrency subtotal currency.symbol}}</span>
</div>
<div class="total-row">
<span>IVA:</span>
<span>{{formatCurrency tax currency.symbol}}</span>
</div>
<div class="total-row grand-total">
<span>TOTAL:</span>
<span>{{formatCurrency totalAmount currency.symbol}}</span>
</div>
</div>

Payment Methods​

<div class="payment-methods">
<h3>Forma de Pago</h3>
{{#each paymentDetail}}
<div class="payment-row">
<span>{{this.paymentMethodName}}</span>
<span>{{formatCurrency this.amount this.currency.symbol}}</span>
</div>
{{/each}}
</div>

Best Practices​

  1. Always check for variable existence before using it:

    {{#if variable}}
    {{variable}}
    {{/if}}
  2. Use helpers for formatting:

    • Always use formatCurrency for money amounts
    • Always use formatDate for dates
    • Use formatNumber for quantities
  3. Access parent scope in loops:

    {{#each items}}
    {{formatCurrency this.amount ../currency.symbol}}
    {{/each}}
  4. Handle missing data gracefully:

    {{#if customer.email}}
    Email:
    {{customer.email}}
    {{else}}
    Email: No disponible
    {{/if}}
  5. Use descriptive CSS classes for styling consistency

  6. Test templates with various data scenarios before deployment


Embedded Media Variables​

These variables are injected at render time by the backend and do not come from the document record itself.

logoDataUrl​

A base64 data-URL PNG of the business logo, fetched from GCS and cache-busted with the business updatedAt timestamp.

{{#if logoDataUrl}}
<img src="{{logoDataUrl}}" alt="Logo" class="receipt-logo" />
{{/if}}

The variable is omitted (not undefined, simply absent from the template context) when:

  • The business has no logoUrl configured.
  • The GCS fetch fails or times out (3 s hard limit).

qrDataUrl​

A base64 data-URL PNG of a QR code pointing to the document's public validate page. Requires the FRONTEND_URL environment variable to be set to a valid https:// URL (or http://localhost).

Document typeQR target URL
Quote{FRONTEND_URL}/quotes/validate?quoteId=<uuid>
Sale{FRONTEND_URL}/sales/validate?saleId=<uuid>
Order bill{FRONTEND_URL}/bills/validate?billId=<uuid>
{{#if qrDataUrl}}
<div style="text-align:center;margin:16px 0 8px;">
<img src="{{qrDataUrl}}" alt="QR" width="100" height="100"
style="display:block;margin:0 auto;" />
<p style="font-size:9px;color:#555;margin-top:3px;">Scan to view online</p>
</div>
{{/if}}

The variable is omitted when:

  • FRONTEND_URL is not set or is not a valid https:// (or localhost) URL.
  • QR encoding fails for any reason (errors are swallowed to prevent PDF generation failures).

QR code options: errorCorrectionLevel: "M", margin: 1.