Docs

DOKUMENTE

Documentation

DOKUMENTE

The DOKUMENTE plugin gives you a central place for all documents of the system:

  • Central overview (/dokumente) of all documents of all document types, filterable by type
  • "New" wizard (/dokumente/new): select a tenant-relevant document type (creatable types clickable, non-creatable types shown as inactive cards with i18n hints), fill in the type-specific fields and create the document
  • Document detail (/dokumente/{uuid}): basic data (type, status, timestamps) + HTML preview (template rendering with generic fallback) + PDF download (/dokumente/{uuid}/pdf, generic endpoint)
  • Edit flow (/dokumente/{uuid}/edit): edit title and type-specific fields, prefilled from the stored document
  • Type registry (Zero-Core): other plugins register their document types (e.g. minutes, invoices, certificates) - the overview grows without any core change
  • Tenant-scoped access: only document types whose (source) plugin is enabled for the tenant are shown
  • Permissions: dokumente.view (overview), dokumente.create (create/edit), dokumente.render (native rendering/download); detail/preview/PDF/edit additionally check the type-specific requiredPermission of the document class
  • Template administration (/settings/admin/dokumente/templates, admin only): the former TEMPLATING admin UI (templates, document-type registry, preview) and the rendering engine are now part of this plugin

The plugin is the foundation; concrete creatable document types (e.g. offers) were added step by step - without creatable types the "New" wizard shows a clean "no types" view. By now the plugin also contains the template administration: the former URLs /settings/admin/templating/** redirect (307) to /settings/admin/dokumente/templates/**, and the plugin key TEMPLATING remains registered as a ghost plugin (tenant resolution extends TEMPLATING → DOKUMENTE, so existing tenants do not need re-activation). Details: docs/plugins/TEMPLATING_en.md.

The VERTRAG document type

The contract is now a document type of the central overview - the code of the former plugin-vertrag was migrated into this plugin:

  • 1:1 index projection: every contract appears in /dokumente with type VERTRAG (type_key='VERTRAG', source_plugin_key='VERTRAG'); title and status (OFFEN/SIGNIERT) are mirrored from the contract. The data itself stays in the contract domain - the dokument row is a pure projection, and in case of divergence the contract wins.
  • Click leads into the contract mask: detail, PDF and edit of a VERTRAG row redirect to /dokumente/vertraege/**; the generic document mask never renders for VERTRAG. In the "New" wizard VERTRAG is creatable - clicking opens the contract mask /dokumente/vertraege/new.
  • Gating stays VERTRAG: plugin key and activation of the contract gating do not change (only the code now lives in DOKUMENTE); permissions are now named dokumente.vertrag.* (old vertrag.* keys as aliases).
  • The plugin-vertrag module no longer exists; the old URLs under /vertrag/** (including the signature link /vertrag/sign/{token}) redirect permanently via 301/307. Details: docs/plugins/VERTRAG_en.md.

  • Open the central overview of all documents (/dokumente) and filter by type
  • Create a new document via the "New" wizard (/dokumente/new)
  • Open a document, view the preview, download it as PDF, or edit it
  • Maintain visibility and permissions of dokumente.view / dokumente.create / dokumente.render per role
  • Enable/disable the DOKUMENTE plugin in the tenant setup

1) Open the document overview

  1. In the sidebar under the "Documents" section click Documents (/dokumente).
  2. The overview shows all documents (type, title, status, created/updated timestamps), newest first.
  3. The type tabs ("All" plus one tab per document type active in the tenant) narrow the list to a type (?type=); the tab badges count with the active search term. "All" is the tab without a type parameter.
  4. Without dokumente.view you get the access-denied view.
  5. With dokumente.create, an additional New button appears on the top right.

2) Create a new document ("New" wizard)

  1. Click New in the overview (/dokumente/new).
  2. Select the document type - ALL tenant-relevant types are listed: CREATABLE types of enabled plugins (the creatable attribute on the document class) as clickable cards; NON-CREATABLE types (code registry + template registry, e.g. receipts, contracts, invoices and custom types) as inactive, dimmed cards without a link and with an i18n hint explaining why the type cannot be created here (keys dokumente.wizard.hint.{TYPE}; fallbacks dokumente.wizard.hint.default and dokumente.wizard.hint.custom). Derived types such as receipts are still only created at their source.
  3. Fill in the title and the type-specific fields (text, dates, numbers, choice fields) in the form; required fields are marked with *.
  4. Click Create: the status becomes DRAFT and you are taken to the detail view of the new document. Validation errors are shown directly in the form.

3) Open, view, and download a document as PDF

  1. Click a document title in the overview (/dokumente/{uuid}).
  2. On the left: basic data (type, status, created/updated). On the right: the HTML preview - the default template of the type from the templating engine, or a generic fallback (basic data + field values) if no template is configured for the type.
  3. Use PDF (/dokumente/{uuid}/pdf?lang=de|en) to download the document as PDF (same content as the preview; inline + no-cache).
  4. Without the type-specific permission (requiredPermission of the document class) you get the access-denied view; unknown UUIDs or types of deactivated plugins return a 404.

4) Edit a document

  1. In the detail view click Edit (/dokumente/{uuid}/edit) if you have the permission (dokumente.create + type permission).
  2. Title and type-specific fields are prefilled from the stored document; click Save.
  3. The status is NOT changed here (status transitions belong to the respective document type); optimistic locking (version) reports concurrent changes with an error message.

5) Maintain permissions

  1. Admin → Users & Permissions → Permissions.
  2. In the Documents section assign the keys dokumente.view, dokumente.create, dokumente.render to roles.
  3. Default grants (shipped defaults): USER_ADMIN has all three keys, USER only dokumente.view.

6) Enable the plugin for a tenant

  1. In the admin backend (tenant administration) open the tenant.
  2. In the plugin list enable DOKUMENTE (or disable it - then the "Documents" section disappears from the navigation and the permissions section).
  3. The admin entry Document templates (/settings/admin/dokumente/templates) is only visible to admin roles.

7) Manage templates

  1. In the sidebar under the "Documents" section click Document Templates (/settings/admin/dokumente/templates).
  2. Create, edit and delete templates, mark a default template per document type, and preview with sample data or a live contract (details: docs/plugins/TEMPLATING_en.md).

8) Receipt from a CAFE order

  1. In the CAFE order view (/cafe/orders, tabs "Running"/"Closed") press the print button (printer icon) in the Action column of an order; visible with cafe.order.manage.
  2. The receipt is created idempotently as a document of type KASSENZETTEL (one document per order, unique index over type + source; printing again reuses the same row) and opens the PDF directly in the browser: GET /dokumente/kassenzettel/{uuid} (legacy path GET /cafe/orders/{uuid}/kassenzettel redirects via HTTP 307) (application/pdf, inline + no-cache, file name kassenzettel-{uuid}.pdf).
  3. Receipt content: operator (tenant domain), order number (#nn within the order day, identical to the order list), date/time, table, "For whom?", user, status, and the line items with student/adult marking and the euro total (bold).
  4. The 80 mm default template is bilingual (?lang=de|en, default de) and can be adjusted under Document Templates like any other template. The KASSENZETTEL type is a system type (is_system, creatable = false) and appears in the "New" wizard as an inactive card with a hint (dokumente.wizard.hint.KASSENZETTEL) - it is only ever created at its source (the CAFE order).
  5. An unknown order UUID or an inactive CAFE/DOKUMENTE plugin returns 404; without cafe.order.manage you get the access-denied view. Details on the CAFE workflow: docs/plugins/CAFE_en.md (section "Manage orders").

9) Create an offer

  1. Click New and pick the Offer type - the type is user-selectable (is_system=false; unlike VERTRAG/RECHNUNG it is not locked). The default template provides the PDF layout.
  2. Fill in the form: Client, Contact person, Valid until (date, locale-formatted), Items (row editor: Description, Quantity, Unit price - the per-row Subtotal is computed automatically and is read-only) and optionally Note.
  3. The Total is derived server-side from the items (2 decimal places, HALF_UP); it is not editable in the form and not persisted.
  4. Validation: a title and at least one item with quantity > 0 are required (error keys dokumente.angebot.error.noPositions / dokumente.angebot.error.mengePositive).
  5. After saving, the offer appears in the list and in the detail view; the PDF renders the item table with the total in DE or EN (?lang=de|en).

Key Effect
dokumente.view Show the central document overview (GET /dokumente)
dokumente.create Create and edit documents (POST /dokumente, /dokumente/{uuid})
dokumente.render Render documents in native formats and download them

In addition to the static keys, detail/preview/PDF/edit check the type-specific requiredPermission() of the document class (dynamic, because it depends on the document type):

Document type requiredPermission()
KASSENZETTEL (derived) cafe.order.manage
ANGEBOT (creatable) dokumente.create

If the permission has not been configured yet (ROLLEN plugin), fail-open applies - as with all other endpoints of the system.

  • Data storage: central table dokument (uuid, type_key, title, status, source_plugin_key, source_uuid, data as TEXT, created_at, updated_at, version). type_key plus optional source reference is unique (unique constraint); version runs optimistic locking (update conflict → error message instead of 500). The row now also carries the contract reference in its own column vertrag_uuid (index idx_dokument_vertrag_uuid, backfilled from existing rows): on create and update the DokumentService mirrors the payload field vertrag_uuid of the library types into that column; index rows (source_uuid set, including the contract projection) stay NULL there because source_uuid already carries the reference.
  • Zero-Core pattern: document types implement the abstract core class Dokument (typeKey, labelKey, requiredPermission, plus the type-specific JSON payload as string; plus creatable(), fields() (field declaration DokumentField with key/labelKey/kind/required/options) and toTemplateModel()) and are registered by their plugin as a DokumentTypeProvider bean. The DokumentRegistry collects all providers (list injection) and filters per tenant via the enabled plugin keys; faulty providers are isolated (log + skip) without breaking the overview. New types are therefore just class + template, without any core change.
  • "New" wizard: GET /dokumente/new lists the creatable tenant types (DokumentRegistry.activeCreatableTypes) as clickable cards and the non-creatable tenant-relevant types as inactive cards (model attribute nonCreatableTypes, type DokumenteController.NonCreatableType(typeKey, label, hintKey)): the union of the code registry (DokumentRegistry.activeTypes(tenant)) and the template registry (TemplatingService.listDocumentTypes(), system + custom types), deduplicated by typeKey (case-insensitive); label by origin (i18n label key / templating.type.{KEY} with DB-label fallback / DB label) and a per-type i18n hint (dokumente.wizard.hint.{KEY}, fallback default, custom types: custom). The backend is unchanged: POST /dokumente still rejects non-creatable types, validates title + required/field checks, builds the JSON payload from the form, and persists the DRAFT. Type resolution runs through DokumentRegistry.findType (case-insensitive, tenant-active types only).
  • Detail/preview/PDF: GET /dokumente/{uuid} renders the preview via the DokumentRenderService - the SINGLE access point to the templating engine (template lookup + rendering + htmlToPdf). This keeps all app.allesda.plugins.dokumente.templating references bundled in exactly this class (imports adjusted after the package move). If no default template exists for the type, a generic HTML layer (basic data + field values with i18n labels) is used; script code in tenant templates is stripped before embedding. GET /dokumente/{uuid}/pdf serves application/pdf (inline + filename, no-cache) and follows the VertragController.getOrGeneratePdf pattern.
  • Edit flow: GET /dokumente/{uuid}/edit prefills the form from the stored JSON payload; POST /dokumente/{uuid} updates title + payload and sets updated_at; the status stays unchanged (status transitions belong to the respective document type; the offer flow builds directly on this update).

The role permission matrix now lists the contract keys under the new category dokumente (dokumente.vertrag.view/create/edit/delete, dokumente.changelog.view, dokumente.options.view/edit) - in the Documents section, while gating remains bound to the plugin key VERTRAG. The old vertrag.* keys remain fully functional as runtime aliases (PermissionAliases), and the old URLs under /vertrag/** - including the public signature link /vertrag/sign/{token} - redirect permanently via 301/307 to /dokumente/**; the redirect will not be removed. Details: docs/plugins/VERTRAG_en.md.

The documents hub is the central entry point for all document kinds:

  • Type tabs instead of a dropdown: The /dokumente page shows an "All" tab plus one tab per document type active in the tenant. Tab badges count with the active search term (single group-by run, no extra query per tab); the search term (?q=) and the active tab (?type=) are preserved in all tab links, in the search form (hidden field) and in the pagination. "All" is the tab without the type parameter; an unknown or inactive type value falls back deterministically to "All".
  • Rich mask inside the tab: Rich document types push their own table fragment into the hub (rich-list SPI richListEnabled()/richListFragment()/richListModel(rows) on the document class). For VERTRAG the tab therefore renders the full contract mask: selection column and bulk action bar (mass delete via POST /dokumente/vertraege/bulk-delete, gated by dokumente.vertrag.delete), "show on one page" (size=5000), own pagination - which keeps the tab context via extraQuery - and the Kanban tab link /kanban?tab=VERTRAG. CSV export runs via the central export page (/export, file /export/vertraege.csv). Types without a valid fragment (or without the rich flag) keep the generic table. The SPI and the fragment contract are documented in How-To/PLUGIN-DEVELOPMENT.md (section "Rich list views").
  • Navigation without dedicated contract items: The sidebar no longer lists contracts as own entries; the Documents section offers Documents (the hub incl. the VERTRAG tab), Document templates, and the admin entries. Search (NavigationSearchProvider) shows contract hits as links into the hub (/dokumente?type=VERTRAG).
  • Legacy URLs and signing area unchanged: /vertrag/** redirects permanently via 301/307 (/vertrag and /vertrag/list -> /dokumente?type=VERTRAG including page/size/q; /vertrag/{uuid} -> detail mask; /vertrag/sign/{token} -> /dokumente/vertraege/sign/{token} including query parameters such as ?lang=de|en). The public signature link stays permitAll; the signing area itself is unchanged.

Acceptance: the cases are pinned by tests - tab counts/search via DokumenteControllerTest, nav snapshot via NavRegistryTest + nav-snapshot.json, redirects via VertragLegacyRedirectTest/VertragEndpointSmokeTest, detail/signature via VertragEndpointSmokeTest, rendered rich mask in tab context (no DB) via VertragTabRichMaskMockMvcTest.