From e42ce3cc5b6c436c8f19e35533da71c1893613d8 Mon Sep 17 00:00:00 2001 From: delchev Date: Tue, 4 Aug 2026 16:51:34 +0300 Subject: [PATCH] spec: the print render language - language / languageFrom on snapshot children and notify attachments --- docs/spec/entities.md | 12 ++++++++++++ docs/spec/glue.md | 5 ++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/spec/entities.md b/docs/spec/entities.md index 5c8166a..e12c13c 100644 --- a/docs/spec/entities.md +++ b/docs/spec/entities.md @@ -184,6 +184,18 @@ Two `function` roles attach **files** to a record. Both are composition children A snapshot requires a **document** master (only a document has a print template to render from). Minting a copy is wired into the workflow: bind the generated snapshot handler (named `SnapshotGenerator`) as the `delegate:` of a [service task](/spec/processes#service-tasks) at the step that finalises the document — typically right after *issue*. Re-issuing after an amendment keeps the document's number and mints the next version, which pairs naturally with [`immutableWhen`](#immutablewhen-immutable-user-write-immutability) and an issue-stamped [document number](#document-numbering). +The **language** a copy is minted in is a knob on the snapshot child — `language: ` fixes the print-template language, or `languageFrom: .` reads it per record from a one-hop path on the document master (a to-one relation and a string field of its target holding the code — the customer decides the language their invoice is issued in; the path may cross model boundaries like any other reference): + +```yaml +- name: SalesInvoiceCopy + function: Snapshot + languageFrom: customer.language + relations: + - { name: SalesInvoice, kind: manyToOne, to: SalesInvoice, composition: true, required: true } +``` + +The two knobs are mutually exclusive. Absent both — or when the resolved value is blank — the mint falls back to the first entry of the application's configured language set, resolved at mint time. An unresolvable `languageFrom` path is a generation error, never a silent wrong-language copy. Interactive printing is a separate concern: the print action always renders **live** current data in the language the user picks, while the snapshot panel serves the frozen issued copies — the two coexist on the document's page. + ## Setting entities ```yaml diff --git a/docs/spec/glue.md b/docs/spec/glue.md index 6052741..c9900ea 100644 --- a/docs/spec/glue.md +++ b/docs/spec/glue.md @@ -51,13 +51,16 @@ notifications: Add **`attach: print`** and the message carries the record's **own document** — the record rendered through its [print template](/spec/presentation#printable-documents) and attached. This is the declarative form of the most common outbound action a business document has: the invoice to its customer, the payslip to its employee, a reminder that carries the invoice it is about. +The **render language**: `language:` fixes the print-template language; `languageFrom: .` reads it per record from a one-hop to-one path of the entity the message is about (mutually exclusive with `language:`). Absent both — or when the resolved value is blank — the render falls back to the first entry of the application's configured language set at send time. + ```yaml notify: to: Customer.email # literal / direct field / one-hop relation.field subject: "Invoice {number}" # {field} and {relation.field} interpolation body: "Dear {Customer.name}, please find invoice {number} attached." attach: print # render THIS record's print template and attach it - language: bg # optional print-template language + language: bg # optional FIXED print-template language + # or per record: languageFrom: Customer.locale (a one-hop relation.field holding the code) ``` `attach`'s only value is `print`, and the entity must be a **document** (a header with a line-items child) — that is the shape a print template exists for. Attaching the print of a plain entity is rejected up front rather than silently sending a message without the document it promised. The attachment comes from the record's own data through the same path the interactive print takes, so a document mailed and a document printed are the same document.