Variables
The following variables are available in the template.ejs file of all
templates. They provide a unified way to access the data of both invoices and
proposals.
#Variables
document | Document | The document that is being rendered (invoice or proposal). |
documentType |
'INVOICE' | 'PROPOSAL' |
The type of document being rendered. |
showCakedeskBranding |
boolean |
Whether or not to display Cakedesk branding on the document. |
paymentQrCodeSvg |
string |
The HTML code for the payment QR code SVG. Empty string when no QR code is available (including all proposals). |
#Document
type |
'INVOICE' | 'CREDIT_NOTE' | 'PROPOSAL' |
The specific type of the document. |
id |
string | Invoice or proposal number.
|
language |
string | The language of the document.
|
date |
string | The date of the document.
|
title |
string |
The proposal title. Empty string for invoices. |
hasDeliveryDate |
boolean |
Does the document include a delivery date? Only relevant for invoices. |
deliveryDateType |
'deliveryDate' | 'serviceDate' |
The type of delivery date. |
deliveryDate |
string |
The delivery date of the document. |
introText | RichText | Text displayed before the items. Set from the proposal text for proposals. Empty string for invoices. |
outroText | RichText | Text displayed after the items. Set from the invoice text for invoices. Empty string for proposals. |
buyer | Buyer | The client. |
seller | Seller | You. |
items | Item[] | The individual line items that make up the document. |
discounts | Discount[] | The discounts applied to this document. |
taxSubtotals | TaxSubtotal[] | An array of tax subtotals, including entries for |
totalDiscounts | MoneyValue | The total discount amount. |
totalTaxes | MoneyValue | The total amount of taxes. |
subtotal | MoneyValue | The total amount without taxes. |
subtotalAfterDiscounts | MoneyValue | The total amount without taxes, after applying any discounts. |
total | MoneyValue | The total amount including taxes. |
hasVat |
boolean |
Does the document include VAT? |
hasQuantities |
boolean |
Does the document include quantities for each individual item? |
#E-invoice fields
The following fields are only available for e-invoices. They are not displayed by the built-in templates.
projectReferenceId |
string | undefined |
The project reference number (BT-11). |
projectReferenceName |
string | undefined |
The project name (BT-11-0). |
contractReferenceId |
string | undefined |
The contract reference number (BT-12). |
buyerOrderReferenceId |
string | undefined |
The buyer's order reference number (BT-13). |
sellerOrderReferenceId |
string | undefined |
The seller's order reference number (BT-14). |
#Buyer
id |
string | The client's user-facing ID.
|
name |
string | The full name of the client.
|
vatId |
string | The VAT ID or GST ID of the client, depending on the client's country.
|
taxId |
string | The Tax ID of the client.
|
address | Address | The address of the client. |
email |
string |
The email address of the client. |
#Seller
name |
string | Your company name.
|
vatId |
string | Your VAT ID or GST ID, depending on your country.
|
taxId |
string | Your Tax ID (Steuernummer).
|
phone |
string | Your phone number.
|
email |
string | Your email.
|
website |
string | Your website.
|
address | Address | Your address. |
accountHolderName |
string |
Your account holder name that you setup under Settings > Invoices. |
iban |
string |
Your IBAN that you setup under Settings > Invoices. |
bic |
string |
Your BIC that you setup under Settings > Invoices. |
#Address
To display an address, formatted correctly for its respective country, it's recommended to use the joinAddress helper.
address |
string | The address part of the address. Usually contains street and street number but can include other
information as well and span multiple lines. For countries whose address format is unknown, the
entire address will be entered in this field, separated by new lines ('\n').
|
zipCode |
string | The zip code of the address
|
city |
string | The city.
|
countryCode |
string | The country code.
|
#Item
title |
string |
The title of the line item. |
description | RichText | An optional description for the item. Can be an empty string. |
unitPrice | MoneyValue | The price of a single unit of that item. Only relevant if document.hasQuantities is true. |
quantity |
number |
How many of this item were sold. Only relevant if document.hasQuantities is true. |
unit | Unit | null | The unit type for this item, or |
amount | MoneyValue | The total price of this item (excluding VAT). |
total | MoneyValue | The total price of this item, including subitems (excluding VAT). |
items | Item[] | Only the top-level items can have child items. |
vatPercentage |
number | null | How much VAT is applied for this item. Only relevant if |
#Unit
An object describing a unit, for example "hours" or "days" or "kg". To display a unit in a template, it's recommended to use the formatQuantity or formatUnit helper.
unitId |
string | A unique slug-like identifier of the unit. Can be used in templates to check if a certain type of unit is provided for an item. |
label.plural | MultiLangString | The label for this unit if quantity is 0 or greater than 1. |
label.singular | MultiLangString | The label for this unit if quantity is 1. |
#Example
{
"unitId": "hours",
"label": {
"plural": {
"en": "Hours",
"de": "Stunden"
},
"singular": {
"en": "Hour",
"de": "Stunde"
}
}
}
#Discount
kind |
'percentage' | 'fixed' |
What kind of discount is applied. |
title |
string | Optional title for the discount.
|
percentage |
number | The percentage of the discount. Only relevant if |
fixedAmount | MoneyValue | The fixed amount of the discount. Only relevant if kind is fixed. |
#TaxSubtotal
vatPercentage |
number | The VAT percentage of this tax subtotal.
|
baseAmount | MoneyValue | The base amount before applying discounts. Includes VAT if hasVat is true. |
baseAmountAfterDiscounts | MoneyValue | The base amount after applying discounts. Includes VAT if hasVat is true. |
discountAmount | MoneyValue | The total amount of all applied discounts. |
subtotal | MoneyValue | The amount of this tax subtotal. |
#MoneyValue
currency |
string | The currency of this particular value.
|
amount |
number | The amount for this particular value, in cents.
|
#RichText
Variables with type RichText are strings of HTML markup. It can include the following tags:
<p><ul><ol><li><strong>
#MultiLangString
An object containing one or more languages as a key and strings as values.
It is not guaranteed that each language is present as a key, or that each key has a value.
#Example
{ "en": "Hello", "de": "Hallo" }