Docs

TEMPLATING

Documentation

TEMPLATING

With TEMPLATING you manage templates (e.g., for contract PDFs).

A template defines:

  • Which text appears where (salutation, clauses, terms and conditions)
  • Which data fields are inserted (tenant name, contract number, inventory list, etc.)
  • Optionally: special inventory rows / layout building blocks

TEMPLATING supports the system document types VERTRAG (seed V34) and RECHNUNG (seed V62) as well as tenant-specific custom document types (since M27-06, V63). One default template is maintained per type.


  • Create a template (type VERTRAG, RECHNUNG or a registered custom document type)
  • Create, rename or delete custom document types (M27-06)
  • Mark a template as default per document type
  • Filter the template list by type
  • Preview a template (per type)
  • Manage multiple variants (e.g., "Contract German" vs. "Contract English", invoice templates)

1) Open the template list

  • Admin → Templating (/settings/admin/templating).
  • Optionally filter by type via query parameter: ?type=VERTRAG or ?type=RECHNUNG (no parameter: all types).

2) Create a new template

1. "New" (/settings/admin/templating/new).
2. Fill in the fields:

  • Name
  • Type (system type VERTRAG/RECHNUNG or a registered custom type; default when creating: VERTRAG)
  • Body / HTML with placeholders

3. Save (POST /settings/admin/templating).

> Available placeholders depend on the type. Example for contract: {{vertrag.id}}, {{mieter.name}}, {{inventar}}. If you are unsure, use the preview.
> Custom document types use the generic variable model (union of VERTRAG and RECHNUNG).

3) Edit a template

  • Open the entry (/settings/admin/templating/{id}/edit) → save (POST /settings/admin/templating/{id}).

4) Mark a template as default

  • For each type, exactly one template can be marked as default.
  • POST /settings/admin/templating/{id}/default.
  • This template is used when generating a PDF if no other one is selected.

5) Delete a template

  • POST /settings/admin/templating/{id}/delete.
  • Default templates cannot be deleted without first choosing a different one as default.

6) Preview

  • POST /settings/admin/templating/preview with sample data (parameters vertragId, content, optional type = registered document type and lang = de/en) — shows how the finished document would look with the template, without producing an actual PDF.

7) Manage custom document types (M27-06)

  • The template list contains a separate "Document Types" block (/settings/admin/templating).
  • Create type: key (uppercase letters, digits, _, max. 32 characters, e.g. GUTSCHEIN) + display label → POST /settings/admin/templating/document-types.
  • Rename type: "Bearbeiten" button in the type table (left of "Löschen"); opens the inline form (Speichern/Abbrechen). Only the display label changes, the key stays stable → POST /settings/admin/templating/document-types/{id}.
  • Delete type: only possible while no templates of that type exist → POST /settings/admin/templating/document-types/{id}/delete.
  • The system types VERTRAG and RECHNUNG are locked (no renaming or deletion).
  • Templates may only reference types that exist in the registry; custom types use the generic variable model (union of VERTRAG and RECHNUNG).
  • Sample templates for custom types (copy & paste): How-To/Templates/ at the repository root — 17 ready-to-copy templates (e.g. voucher, quote, termination, return/pickup confirmation, deposit receipt, damage report, extension, payment reminder, dunning, credit note, cancellation, payment confirmation, inquiry/booking confirmation, delivery note, item list), with a README step-by-step guide.

"My placeholder is not replaced"

  • Check the spelling (brackets, dots, casing).
  • The value may be empty (e.g., a tenant without a phone number).

"The PDF looks broken"

  • HTML/CSS errors in the template. Use the preview.
  • Images: must be reachable URLs / embedded data.

"Which template is used in the contract?"

  • Since M27-07, the document type stored on the contract (field "Document

type" in the contract form, default VERTRAG, V64) determines the template:
"Generate PDF" renders the default template of that type. For VERTRAG the
legacy flow (stored protected PDF) additionally applies.

  • The per-contract template selection was removed; ad-hoc rendering is still

possible via the type/template query parameters of /pdf and /generate.


Admin (/settings/admin/templating):

  • GET /settings/admin/templating — list (optional: ?type=)
  • GET /settings/admin/templating/new — new
  • POST /settings/admin/templating — create
  • GET /settings/admin/templating/{id}/edit — edit
  • POST /settings/admin/templating/{id} — save
  • POST /settings/admin/templating/{id}/delete — delete
  • POST /settings/admin/templating/{id}/default — mark as default per type
  • POST /settings/admin/templating/preview — preview (optional: type=, lang=de|en)
  • POST /settings/admin/templating/document-types — create document type (typeKey, label)
  • POST /settings/admin/templating/document-types/{id} — rename document type (label)
  • POST /settings/admin/templating/document-types/{id}/delete — delete document type

  • TEMPLATING is closely tied to VERTRAG (document generation: contract & invoice).
  • Available document types: system types VERTRAG and RECHNUNG (default templates via Flyway: V34 / V62) plus tenant-specific registered custom types (M27-06, table templating_document_type, V63).
  • Templates may only reference registered types; custom types get the generic variable model (union of VERTRAG and RECHNUNG).
  • Since M27-07 (V64), each contract carries a document type (vertrag.document_type); "Generate PDF" on the contract renders the default template of that type (only VERTRAG uses the legacy path with the stored PDF).
  • Keep templates clean and tidy — "one default template per type plus a few variants" is usually better than ten almost-identical files.