@opencxh/domain 1.244.0 → 1.246.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.
@@ -9,13 +9,28 @@ export interface FillResult {
9
9
  /** Paths that resolved to nothing, in the order they appeared. Deduplicated. */
10
10
  unresolved: string[];
11
11
  }
12
- /** One string, filled in. */
13
- export declare function fillText(text: string, context: TemplateContext): FillResult;
12
+ /**
13
+ * One string, filled in.
14
+ *
15
+ * `missing` is what an unresolved token becomes. Left out, the token itself stays — the raw
16
+ * form, which a template editor needs to see. A reader does not: `{customer.address}` looks
17
+ * like a bug, where "[nog niet bekend]" says what it is. Either way the path is *reported*, so
18
+ * the issue gate judges the same document whichever form was asked for.
19
+ */
20
+ export declare function fillText(text: string, context: TemplateContext, missing?: string): FillResult;
14
21
  /** Does this block appear? A block with no condition always does. */
15
22
  export declare function conditionHolds(condition: TemplateCondition | undefined, context: TemplateContext): boolean;
16
23
  export interface FillDocumentResult {
17
24
  blocks: DocumentBlock[];
18
25
  unresolved: string[];
26
+ /**
27
+ * Slots the template had no placeholder for.
28
+ *
29
+ * A slot the caller computed and the template cannot place is **dropped**, and dropping a
30
+ * quote's totals without a word is how a document goes out missing its total. Reported here so
31
+ * the preview can say it and the issue gate can refuse it.
32
+ */
33
+ unusedSlots: string[];
19
34
  }
20
35
  /**
21
36
  * Blocks the caller computes, keyed by the `block_id` of the template block they replace.
@@ -36,4 +51,6 @@ export type DocumentSlots = Record<string, readonly DocumentBlock[]>;
36
51
  * value is the ordinary case for an invoice, and missing one would leave `{invoice.number}`
37
52
  * printed on a document that went out the door.
38
53
  */
39
- export declare function fillDocument(blocks: readonly DocumentBlock[], context: TemplateContext, conditions?: Record<string, TemplateCondition>, slots?: DocumentSlots): FillDocumentResult;
54
+ export declare function fillDocument(blocks: readonly DocumentBlock[], context: TemplateContext, conditions?: Record<string, TemplateCondition>, slots?: DocumentSlots,
55
+ /** What an unresolved token reads as. See {@link fillText}. */
56
+ missing?: string): FillDocumentResult;
@@ -30,5 +30,8 @@ export interface PricedTransaction {
30
30
  *
31
31
  * `overrideKey` is the "reverse charge / exempt" tick on the transaction: it replaces every line's
32
32
  * rate, because that is a property of the sale and not of the product.
33
+ *
34
+ * An **optional** line is priced like any other and then left out of every sum — see
35
+ * `TransactionLine.optional`.
33
36
  */
34
37
  export declare function transactionTotals(lines: readonly TransactionLine[], rates: readonly TaxRate[], overrideKey?: string): PricedTransaction;
@@ -49,6 +49,8 @@ export declare function transactionContext(transaction: Transaction, sources?: T
49
49
  export declare function transactionSlots(transaction: Transaction, rates?: readonly TaxRate[], labels?: SlotLabels): DocumentSlots;
50
50
  export interface SlotLabels {
51
51
  description: string;
52
+ /** Marks a line that is priced but not counted. */
53
+ optional: string;
52
54
  quantity: string;
53
55
  unitPrice: string;
54
56
  net: string;
@@ -110,6 +110,23 @@ export interface TransactionLine {
110
110
  costPriceCents?: Cents;
111
111
  /** The mapping axis onto a chart of accounts, copied from the product's category. */
112
112
  ledgerCategoryKey?: string;
113
+ /**
114
+ * The work item this line is for. Same referent as {@link Transaction.dealItemId}, one level
115
+ * down: a quote may cover one deal while its lines belong to different items under it.
116
+ *
117
+ * An id and never a copied title — whoever owns the item renames it, and a name stored here
118
+ * would be stale the same afternoon. Not printed on the document; it is what the work is
119
+ * booked against, not what the customer reads.
120
+ */
121
+ dealItemId?: string;
122
+ /**
123
+ * An option: priced and shown, but **not** in the total.
124
+ *
125
+ * The amount still stands on the line — the customer has to be able to read what the option
126
+ * costs — so this is a flag on the line and not a second list. Accepting an option is a new
127
+ * version of the quote with the flag off, the same way every other change to a sent quote is.
128
+ */
129
+ optional?: boolean;
113
130
  }
114
131
  export interface TransactionTotals {
115
132
  netCents: Cents;