Skip to main content

Order Bill Communication Templates

Overview

Order bills support four communication channels, each backed by a communication_template record seeded via migration. The system also allows per-client custom templates without any code changes.


System Default Templates (code changes required)

These are the "factory" templates seeded into the DB via migration. There are four templates total (e.g., email body, email subject, SMS, and thermal receipt).

TemplateLocation
Migration (all 4 templates)packages/backend/database/src/migrations/2026-04-17t01-00-00-order-bill-communication-templates.mjs
PDF/HTML template fileapps/backend/src/pdf/infrastructure/templates/order-bill.template.html
PDF template (DB copy)packages/backend/database/src/templates/order-bill.template.html
ESC/POS thermal layoutpackages/receipt-layout/src/document/build-document-lines.tsbuildOrderBillReceiptLines function

Important: The migration uses ON CONFLICT DO NOTHING, so updating the migration file will not update records already in the DB. To change an existing seeded template you must either:

  • Write a new migration with an explicit UPDATE, or
  • Run a direct SQL UPDATE on each environment manually.

Per-Client Custom Templates (no code changes)

The system already supports per-business template overrides. Because communication_template has a business_id column, findByCode(code, businessId) automatically prefers a business-scoped record over the system-wide default.

Steps to create a custom template for a client:

  1. Go to Communication Templates in the admin UI, or call POST /communication-templates directly.
  2. Create a new template with the same channel and a unique code, setting business_id to the client's business ID.
  3. That's it — findByCode will serve the custom template to that business automatically.

This lets you give client A a fully custom email layout and client B different SMS wording, without touching any shared code or affecting other businesses.