@opencxh/domain 1.241.0 → 1.242.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -33,7 +33,7 @@ export type DocumentSlots = Record<string, readonly DocumentBlock[]>;
33
33
  * text lives.
34
34
  *
35
35
  * Every text-bearing field is walked, not just `text` — a token in a table cell or a letterhead
36
- * value is the ordinary case for an invoice, and missing one would leave `{factuur.nummer}`
36
+ * value is the ordinary case for an invoice, and missing one would leave `{invoice.number}`
37
37
  * printed on a document that went out the door.
38
38
  */
39
39
  export declare function fillDocument(blocks: readonly DocumentBlock[], context: TemplateContext, conditions?: Record<string, TemplateCondition>, slots?: DocumentSlots): FillDocumentResult;
@@ -59,7 +59,7 @@ export interface DocumentTemplate {
59
59
  * app that decides it.
60
60
  */
61
61
  export interface TemplateCondition {
62
- /** A path into the same context the tokens read: `klant.incasso`. */
62
+ /** A path into the same context the tokens read: `customer.direct_debit`. */
63
63
  key: string;
64
64
  /** Show when the value equals this. */
65
65
  equals?: unknown;
@@ -0,0 +1,71 @@
1
+ import { DocumentBlock } from '../../platform/document-blocks';
2
+ import { DocumentSlots, TemplateContext } from '../document-template/tokens';
3
+ import { TaxRate } from '../money/tax';
4
+ import { Transaction } from './types';
5
+ /**
6
+ * The seam between a transaction and the paper it is printed on.
7
+ *
8
+ * Two functions and no renderer. The block order lives in a `DocumentTemplate` row, not in code:
9
+ * the moment it is hardcoded here, the template layer is decoration and every house-style change
10
+ * is a deploy. What a template *cannot* express is the line table and the totals — a token
11
+ * replaces text, it cannot build a table out of an array — so those arrive as slots.
12
+ *
13
+ * The consequence for a second consumer (a work order, a timesheet) is that it costs one context,
14
+ * one slot function and one seeded template row. No renderer, no screen, no export.
15
+ */
16
+ /** What a template author addresses. */
17
+ export interface TransactionContextSources {
18
+ companyName?: string;
19
+ /** `Company` carries no address today; the token exists so a template survives when it does. */
20
+ companyCity?: string;
21
+ contactName?: string;
22
+ organizationName?: string;
23
+ /** Who the recipient reads; drives which template row is picked. */
24
+ locale?: string;
25
+ }
26
+ /**
27
+ * The tokens: `{customer.name}`, `{quote.number}`, `{totals.gross}`.
28
+ *
29
+ * English, like every other identifier in this repo. A token is a **path into data**, not a
30
+ * sentence — the Dutch on a quote is the text a template author writes around it.
31
+ *
32
+ * **The cost price and the margin are not in here, and that is load-bearing.** A template author
33
+ * writes `{regel.bedrag}` by hand; if a cost ever landed in this object, `{regel.inkoop}` on a
34
+ * quote would be one typo away from the customer. The shield on the way out of the server
35
+ * (`transactionView`) is the second lock; this one is the first.
36
+ */
37
+ export declare function transactionContext(transaction: Transaction, sources?: TransactionContextSources): TemplateContext;
38
+ /**
39
+ * The blocks a template cannot write itself: the line table and the totals.
40
+ *
41
+ * Keyed by the `block_id` the template author puts on an empty placeholder — `lines` and `totals`.
42
+ * That pairing is a **convention**, not a contract: an author cannot invent a third slot and
43
+ * expect sales to fill it, because the consumer decides what it hands over.
44
+ *
45
+ * Amounts arrive already formatted. The blocks layer never computes; that is the whole reason a
46
+ * totals row carries a string.
47
+ */
48
+ export declare function transactionSlots(transaction: Transaction, rates?: readonly TaxRate[], labels?: SlotLabels): DocumentSlots;
49
+ export interface SlotLabels {
50
+ description: string;
51
+ quantity: string;
52
+ unitPrice: string;
53
+ net: string;
54
+ tax: string;
55
+ gross: string;
56
+ }
57
+ export declare const DUTCH_SLOT_LABELS: SlotLabels;
58
+ /**
59
+ * The default quote template, as a **seed** — not a renderer.
60
+ *
61
+ * Note the split inside it: the token **paths** are English because they address data, the
62
+ * **text** around them is Dutch because a customer reads it.
63
+ *
64
+ * The distinction is the whole point of the template layer: this array is written into a
65
+ * `DocumentTemplate` row the first time an organisation needs one, and from then on the row is
66
+ * the truth. An administrator moves the terms above the lines and that sticks; nobody deploys.
67
+ *
68
+ * The two empty placeholders are the slots {@link transactionSlots} fills. Their `block_id` is
69
+ * the whole contract.
70
+ */
71
+ export declare const DEFAULT_QUOTE_TEMPLATE_BLOCKS: DocumentBlock[];
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,5 @@
1
1
  export * from './convert';
2
+ export * from './document';
2
3
  export * from './keys';
3
4
  export * from './kinds';
4
5
  export * from './types';