
May 12, 2026
Updating custom templates for cancellations
With version 1.34.0, Cakedesk now supports cancellation invoices and cancellation credit notes.
Built-in templates already handle these new document types. If you use a custom template, it is worth checking whether your template hard-codes invoice titles or document types.
#Summary
To make a custom template ready for cancellations:
- Use
getDocumentTitle()for the main document title - Handle
document.type === 'CANCELLATION'if you use your own conditional logic - Use
document.canceledInvoiceif you want to show which document is being canceled
#Use 'getDocumentTitle()' for the title
Before cancellations, many templates used a condition like this:
<h1>
<%= document.type === 'PROPOSAL'
? t('proposal')
: document.type === 'CREDIT_NOTE'
? t('creditNote')
: t('invoice') %>
</h1>
This works for invoices, credit notes, and proposals, but it would label cancellation documents as normal invoices.
The recommended update is to use the helper function instead:
<h1><%= getDocumentTitle() %></h1>
getDocumentTitle() returns the correct title for:
- invoices
- credit notes
- cancellation invoices
- cancellation credit notes
- proposals
For German documents, for example, it can return "Rechnung", "Gutschrift", "Stornorechnung", "Stornogutschrift", or "Angebot: Mein Angebotstitel".
#Showing the canceled document
Cancellation documents include a new document.canceledInvoice object. It contains information about the document that was canceled directly:
<% if (document.canceledInvoice) { %>
<p>
Cancels document <%= document.canceledInvoice.invoiceId %>
from <%= formatDate(document.canceledInvoice.invoiceDate) %>.
</p>
<% } %>
The following fields are available:
document.canceledInvoice.invoiceIddocument.canceledInvoice.invoiceDatedocument.canceledInvoice.typedocument.canceledInvoice.rootType
rootType is useful when a cancellation is canceled again. It tells you whether the cancellation chain originally started from an invoice or from a credit note.
#Totals and amounts
Cakedesk creates cancellation documents by reversing the original line item and discount amounts. If your template already renders totals with getSummaryItems(), you do not need to change anything.
If you render totals manually, test your template with a cancellation invoice and make sure negative values display cleanly.
#New built-in template strings
Cakedesk also adds two built-in template strings for cancellations:
cancellationInvoicecancellationCreditNote
You usually do not need to use these strings directly if you use getDocumentTitle(). The helper already uses them internally.
#Older invoice templates
Older invoice-only templates can keep using the invoice variable. The new cancellation type is available there as well:
<% if (invoice.type === 'CANCELLATION') { %>
<h1><%= getDocumentTitle() %></h1>
<% } %>
For new templates, the unified document variable is recommended.