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).
| Template | Location |
|---|---|
| Migration (all 4 templates) | packages/backend/database/src/migrations/2026-04-17t01-00-00-order-bill-communication-templates.mjs |
| PDF/HTML template file | apps/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 layout | packages/receipt-layout/src/document/build-document-lines.ts — buildOrderBillReceiptLines 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
UPDATEon 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:
- Go to Communication Templates in the admin UI, or call
POST /communication-templatesdirectly. - Create a new template with the same
channeland a uniquecode, settingbusiness_idto the client's business ID. - That's it —
findByCodewill 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.