---
id: SCR-ACC-BKS-014
title: Document template editor
route: '/console/{tenantId}/configuration/accounting/documentTemplates/{templateId}'
surface: console
product_area: accounting
module: books
revision: 1
status: draft
design_intent: proposed
implementation_evidence: observed
inference: []
source_sha:
  react-console: baf6dae382d6f41dce976c7f848667ccc37e076f
  services-accounting: f47cb263875bbc0c5640fba7dae6785ec32695f8
purpose: >-
  Edit and preview document content with its merge fields, or inspect built-in
  content and duplicate it for customization.
supports:
  - JNY-ACC-BKS-004
  - JNY-ACC-BKS-005
  - CAP-ACC-BKS-014
permission: accounting.document-templates.read; saving needs create or update
entry_from:
  - '''/console/{tenantId}/configuration/accounting/documentTemplates'' (list)'
exits_to:
  - '''/console/{tenantId}/configuration/accounting/documentTemplates'' (list)'
displays:
  - field: >-
      Template identifying details, availability, source and kind-specific
      email, recipient or file controls
    source: getDocumentTemplate
  - field: 'Merge-field catalogue with types, descriptions, examples and filters'
    source: listDocumentTemplateVariables
  - field: Unsaved sample render with missing fields and template problems
    source: previewDocumentTemplate
actions:
  - label: Save (new)
    operation_id: createDocumentTemplate
    permission: accounting.document-templates.create
    confirm: false
  - label: Save
    operation_id: updateDocumentTemplate
    permission: accounting.document-templates.update
    confirm: false
  - label: Duplicate
    operation_id: duplicateDocumentTemplate
    permission: accounting.document-templates.create
    confirm: false
  - label: Preview
    operation_id: previewDocumentTemplate
    permission: accounting.document-templates.read
    confirm: false
states:
  - loading
  - error
  - read-only
  - inactive
validation:
  - BR-CAP-ACC-BKS-014-01
  - BR-CAP-ACC-BKS-014-02
  - BR-CAP-ACC-BKS-014-03
  - BR-CAP-ACC-BKS-014-04
  - BR-CAP-ACC-BKS-014-07
  - BR-CAP-ACC-BKS-014-08
  - BR-CAP-ACC-BKS-014-10
patterns:
  - Full-width source editor with merge-field picker and document preview
  - Kind-specific email and statement-recipient controls
  - >-
    Read-only built-in and permission-restricted forms with duplicate-to-edit
    action
  - Unsaved-changes protection
  - Initial loading indicator and inline failure notice
component: components/document-templates/template-editor-page.tsx
evidence:
  - >-
    react-console at baf6dae3:
    components/document-templates/template-editor-page.tsx
  - >-
    react-console:components/configuration/config-list-screen.tsx:changeStatus;
    components/configuration/standard.tsx:standardCapabilities (shared-list
    behavior where applicable)
controls: [TC-IAM-001, TC-IAM-002, TC-IAM-004, TC-IAM-005, TC-AZ-001, TC-AZ-002, TC-AZ-003, TC-AZ-004, TC-AZ-005, TC-AZ-006, TC-TEN-001, TC-TEN-002, TC-TEN-003, TC-LOG-001, TC-LOG-002, TC-LOG-003, TC-LOG-004, TC-LOG-005, TC-PI-001]
---

# Document template editor

## What the Screen Is For

Edit and preview document content with its merge fields, or inspect built-in content and duplicate it for customization.

## What It Shows and Lets People Do

The dedicated page opens existing content or a new draft of the selected kind. Saving creates or replaces customer content, and duplication opens an editable copy. The source editor and merge-field picker drive a debounced sample preview. The preview retains its last successful render while another request runs or fails.

## States and Errors

The console entry gate accepts read, create or edit permission, while fetching an existing template still requires service read permission. Built-ins and forms without edit permission are read-only. New creation and existing replacement have separate write gates. Liquid problems and empty sample fields appear in the preview; recipient limits and source validation apply on save. A failed initial load stays on the page as an inline notice. Successful creation replaces the route with the existing template’s edit page.

## Patterns It Must Respect

Full-width source editor with merge-field picker and document preview. Kind-specific email and statement-recipient controls. Read-only built-in and permission-restricted forms with duplicate-to-edit action. Unsaved-changes protection. Initial loading indicator and inline failure notice.
