DOKUMENTE
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-specificrequiredPermissionof 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
/dokumentewith typeVERTRAG(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 - thedokumentrow 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 nameddokumente.vertrag.*(oldvertrag.*keys as aliases). - The
plugin-vertragmodule 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.renderper role - Enable/disable the DOKUMENTE plugin in the tenant setup
1) Open the document overview
- In the sidebar under the "Documents" section click Documents (
/dokumente). - The overview shows all documents (type, title, status, created/updated timestamps), newest first.
- 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. - Without
dokumente.viewyou get the access-denied view. - With
dokumente.create, an additional New button appears on the top right.
2) Create a new document ("New" wizard)
- Click New in the overview (
/dokumente/new). - Select the document type - ALL tenant-relevant types are listed: CREATABLE types of enabled plugins (the
creatableattribute 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 (keysdokumente.wizard.hint.{TYPE}; fallbacksdokumente.wizard.hint.defaultanddokumente.wizard.hint.custom). Derived types such as receipts are still only created at their source. - Fill in the title and the type-specific fields (text, dates, numbers, choice fields) in the form; required fields are marked with *.
- Click Create: the status becomes
DRAFTand 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
- Click a document title in the overview (
/dokumente/{uuid}). - 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.
- Use PDF (
/dokumente/{uuid}/pdf?lang=de|en) to download the document as PDF (same content as the preview;inline+ no-cache). - Without the type-specific permission (
requiredPermissionof the document class) you get the access-denied view; unknown UUIDs or types of deactivated plugins return a 404.
4) Edit a document
- In the detail view click Edit (
/dokumente/{uuid}/edit) if you have the permission (dokumente.create+ type permission). - Title and type-specific fields are prefilled from the stored document; click Save.
- 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
- Admin → Users & Permissions → Permissions.
- In the Documents section assign the keys
dokumente.view,dokumente.create,dokumente.renderto roles. - Default grants (shipped defaults):
USER_ADMINhas all three keys,USERonlydokumente.view.
6) Enable the plugin for a tenant
- In the admin backend (tenant administration) open the tenant.
- In the plugin list enable DOKUMENTE (or disable it - then the "Documents" section disappears from the navigation and the permissions section).
- The admin entry Document templates (
/settings/admin/dokumente/templates) is only visible to admin roles.
7) Manage templates
- In the sidebar under the "Documents" section click Document Templates (
/settings/admin/dokumente/templates). - 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
- In the CAFE order view (
/cafe/orders, tabs "Running"/"Closed") press the print button (printer icon) in the Action column of an order; visible withcafe.order.manage. - 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 pathGET /cafe/orders/{uuid}/kassenzettelredirects via HTTP 307) (application/pdf,inline+ no-cache, file namekassenzettel-{uuid}.pdf). - 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).
- The 80 mm default template is bilingual (
?lang=de|en, defaultde) and can be adjusted under Document Templates like any other template. TheKASSENZETTELtype 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). - An unknown order UUID or an inactive CAFE/DOKUMENTE plugin returns 404; without
cafe.order.manageyou get the access-denied view. Details on the CAFE workflow:docs/plugins/CAFE_en.md(section "Manage orders").
9) Create an offer
- 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. - 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.
- The Total is derived server-side from the items (2 decimal places, HALF_UP); it is not editable in the form and not persisted.
- Validation: a title and at least one item with quantity > 0 are required (error keys
dokumente.angebot.error.noPositions/dokumente.angebot.error.mengePositive). - 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_keyplus optional source reference is unique (unique constraint);versionruns optimistic locking (update conflict → error message instead of 500). The row now also carries the contract reference in its own columnvertrag_uuid(indexidx_dokument_vertrag_uuid, backfilled from existing rows): on create and update the DokumentService mirrors the payload fieldvertrag_uuidof the library types into that column; index rows (source_uuid set, including the contract projection) stay NULL there becausesource_uuidalready 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; pluscreatable(),fields()(field declarationDokumentFieldwith key/labelKey/kind/required/options) andtoTemplateModel()) and are registered by their plugin as aDokumentTypeProviderbean. TheDokumentRegistrycollects 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/newlists the creatable tenant types (DokumentRegistry.activeCreatableTypes) as clickable cards and the non-creatable tenant-relevant types as inactive cards (model attributenonCreatableTypes, typeDokumenteController.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}, fallbackdefault, custom types:custom). The backend is unchanged:POST /dokumentestill rejects non-creatable types, validates title + required/field checks, builds the JSON payload from the form, and persists the DRAFT. Type resolution runs throughDokumentRegistry.findType(case-insensitive, tenant-active types only). - Detail/preview/PDF:
GET /dokumente/{uuid}renders the preview via theDokumentRenderService- the SINGLE access point to the templating engine (template lookup + rendering +htmlToPdf). This keeps allapp.allesda.plugins.dokumente.templatingreferences 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}/pdfservesapplication/pdf(inline + filename, no-cache) and follows theVertragController.getOrGeneratePdfpattern. - Edit flow:
GET /dokumente/{uuid}/editprefills the form from the stored JSON payload;POST /dokumente/{uuid}updates title + payload and setsupdated_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
/dokumentepage 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 thetypeparameter; an unknown or inactivetypevalue 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). ForVERTRAGthe tab therefore renders the full contract mask: selection column and bulk action bar (mass delete viaPOST /dokumente/vertraege/bulk-delete, gated bydokumente.vertrag.delete), "show on one page" (size=5000), own pagination - which keeps the tab context viaextraQuery- 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 inHow-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 (/vertragand/vertrag/list->/dokumente?type=VERTRAGincludingpage/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.