@kreiseck/kasseneck-api 1.26.0 → 1.27.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.
Files changed (64) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/cjs/models/receipt-errors.d.ts +1 -1
  3. package/dist/cjs/models/receipt-errors.js +2 -0
  4. package/dist/cjs/models/receipt-item.d.ts +10 -0
  5. package/dist/cjs/models/receipt-item.js +8 -0
  6. package/dist/cjs/pos/artikel.d.ts +17 -0
  7. package/dist/cjs/pos/artikel.js +7 -0
  8. package/dist/cjs/pos/index.d.ts +1 -0
  9. package/dist/cjs/pos/index.js +13 -3
  10. package/dist/cjs/pos/texte.d.ts +13 -0
  11. package/dist/cjs/pos/texte.js +5 -0
  12. package/dist/cjs/pos/zusaetze.d.ts +70 -0
  13. package/dist/cjs/pos/zusaetze.js +159 -0
  14. package/dist/cjs/receipt/grid.js +16 -3
  15. package/dist/cjs/receipt/layout.js +16 -9
  16. package/dist/cjs/stored/vokabular.d.ts +1 -1
  17. package/dist/cjs/stored/vokabular.js +7 -4
  18. package/dist/cjs/version.d.ts +1 -1
  19. package/dist/cjs/version.js +1 -1
  20. package/dist/esm/models/receipt-errors.d.ts +1 -1
  21. package/dist/esm/models/receipt-errors.js +2 -0
  22. package/dist/esm/models/receipt-item.d.ts +10 -0
  23. package/dist/esm/models/receipt-item.js +8 -0
  24. package/dist/esm/pos/artikel.d.ts +17 -0
  25. package/dist/esm/pos/artikel.js +6 -0
  26. package/dist/esm/pos/index.d.ts +1 -0
  27. package/dist/esm/pos/index.js +1 -0
  28. package/dist/esm/pos/texte.d.ts +13 -0
  29. package/dist/esm/pos/texte.js +5 -0
  30. package/dist/esm/pos/zusaetze.d.ts +70 -0
  31. package/dist/esm/pos/zusaetze.js +148 -0
  32. package/dist/esm/receipt/grid.js +16 -3
  33. package/dist/esm/receipt/layout.js +16 -9
  34. package/dist/esm/stored/vokabular.d.ts +1 -1
  35. package/dist/esm/stored/vokabular.js +7 -4
  36. package/dist/esm/version.d.ts +1 -1
  37. package/dist/esm/version.js +1 -1
  38. package/fixtures/add-on-cases.json +103 -0
  39. package/fixtures/expected/add-ons.grid32.txt +31 -0
  40. package/fixtures/expected/add-ons.grid48.txt +27 -0
  41. package/fixtures/expected/add-ons.lines.json +270 -0
  42. package/fixtures/expected/add-ons.sheet32.json +212 -0
  43. package/fixtures/expected/add-ons.sheet48.json +188 -0
  44. package/fixtures/hobex-hps-codes.json +1 -1
  45. package/fixtures/invoice-api.schema.json +1 -1
  46. package/fixtures/invoice-texts.json +1 -1
  47. package/fixtures/manifest.json +8 -0
  48. package/fixtures/pos-texts.json +16 -1
  49. package/fixtures/receipts/add-ons.json +70 -0
  50. package/fixtures/surface.json +10 -1
  51. package/fixtures/v3/antworten/belege.json +1 -1
  52. package/fixtures/v3/antworten/belegmail.json +1 -1
  53. package/fixtures/v3/antworten/berichte.json +1 -1
  54. package/fixtures/v3/antworten/kasse-belege.json +1 -1
  55. package/fixtures/v3/antworten/kasse.json +2 -2
  56. package/fixtures/v3/antworten/lager.json +1 -1
  57. package/fixtures/v3/antworten/rechnungen.json +1 -1
  58. package/fixtures/v3/antworten/storno.json +1 -1
  59. package/fixtures/v3/stored/belege.json +1 -1
  60. package/fixtures/v3/stored/kasse.json +2 -2
  61. package/fixtures/v3/stored/rechnungen.json +1 -1
  62. package/fixtures/v3/v3-vokabular.json +31 -12
  63. package/fixtures/v3/zahlbetrag-faelle.json +1 -1
  64. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -4,6 +4,17 @@ Was vor 0.7.0 geschah, steht in der Commit-Historie (`git log`); ab hier wird
4
4
  es hier geführt. Ein Eintrag nennt die Änderung **und ihren Grund** —
5
5
  nur der Grund überlebt den nächsten Umbau.
6
6
 
7
+ ## 1.27.0 - 2026-11-05
8
+
9
+ Add-on tiles: tapping a main service opens a sheet with its add-ons (nail art, repair per nail, hand massage …); each add-on becomes its own receipt line pointing at its main line. Additive; articles, groups and receipts without the new fields read, print and send exactly as before (all existing goldens unchanged).
10
+
11
+ - **`ArticleGroup.addOns`** and **`PosArticle.addOns`** (`string[] | null`, stored `zusaetze`): the group's list in sheet order; on the article `null` = as the group, `[]` = none, otherwise its own list. The reader always sets both. Reason: a nail studio sells many add-ons that otherwise sit in their own group and have to be searched for at the till.
12
+ - **`ReceiptItem.addOnOf`** (stored `zusatzZu`): index of the main line in the same receipt, read and written only as a whole number ≥ 0. The server checks it (`invalid_add_on_reference`, now in `RECEIPT_ERROR_CODES`); it never touches totals, counter or signature.
13
+ - **Helpers** `addOnsFor` (effective list: the article itself, unknown, inactive and non-selectable articles and duplicates drop out silently), `isSelectableAddOn` (reason `inactive|own_list|asks_price|reference|asks_quantity|no_price|service_voucher`: an add-on is booked without prompts and opens no sheet of its own), `addOnReferencesValid`, `addOnsOfItem` (cancellation pre-selects a main line's add-ons), `addOnRemap`, `addOnDisplayOrder`, `orderAddOnLines` (cart lines with the parent's line id -> receipt order and index), `ADD_ONS_MAX` (30). Contract cases `fixtures/add-on-cases.json`, the same as the backend (`zusatz-faelle.json`) and the Dart package.
14
+ - **Receipt layout:** add-ons stand directly under their main line (stable, also when the receipt lists them later), indented with „+ “; a wrapped name continues under the quantity. The grid applies the same hanging indent to a left column that starts with spaces (as it already did for text lines). New golden `add-ons`.
15
+ - **Texts:** labels `addons.title` „Zusätze zu {name}“, `addons.none` „Ohne Zusatz“, `addons.done` „Fertig“, `addons.open` „Zusätze“.
16
+ - Contract `v3` re-fetched from the backend (`addOns` on articles and groups, `addOnOf` on receipt items).
17
+
7
18
  ## 1.26.0 - 2026-11-04
8
19
 
9
20
  Tile with amount and reference: a tile can ask, when tapped, for the amount and/or a reference (fee note, order number). Additive; articles without the new fields read as before.
@@ -18,7 +18,7 @@ import { KasseneckApiError } from '../client/errors.js';
18
18
  * ...) stehen in [PAYMENT_ERROR_CODES]. Ein Code ausserhalb bleibt ueber
19
19
  * `KasseneckApiError.code` lesbar.
20
20
  */
21
- export declare const RECEIPT_ERROR_CODES: readonly ["cancellation_reference_unavailable", "cashregister_closed", "cashregister_decommissioned", "final_receipt_expired", "final_receipt_not_allowed", "idempotency_conflict", "module_inactive", "not_permitted", "receipt_limit_exceeded", "receipt_not_found", "receipt_outcome_unknown", "receipt_type_invalid", "server_error", "signature_incomplete", "signature_missing", "signing_failed", "small_business_vat_not_allowed", "tip_invalid", "tip_not_allowed", "tip_recipient_unknown", "validation", "voucher_balance_changed", "account_not_found", "action_confirmation_required", "admin_required", "api_not_approved", "app_check_invalid", "app_check_missing", "cashregister_not_assigned", "cashregister_not_found", "cashregister_token_invalid", "cashregister_token_missing", "dialect_mismatch", "internal_translation_error", "live_not_enabled", "method_not_allowed", "mfa_required", "not_found", "password_change_required", "register_user_no_business", "register_user_not_allowed", "register_user_not_found", "response_translation_failed", "second_factor_required", "session_expired", "session_other_cashregister", "unauthorized", "user_disabled", "user_verification_failed", "route_missing", "response_unreadable"];
21
+ export declare const RECEIPT_ERROR_CODES: readonly ["cancellation_reference_unavailable", "cashregister_closed", "cashregister_decommissioned", "final_receipt_expired", "final_receipt_not_allowed", "idempotency_conflict", "invalid_add_on_reference", "module_inactive", "not_permitted", "receipt_limit_exceeded", "receipt_not_found", "receipt_outcome_unknown", "receipt_type_invalid", "server_error", "signature_incomplete", "signature_missing", "signing_failed", "small_business_vat_not_allowed", "tip_invalid", "tip_not_allowed", "tip_recipient_unknown", "validation", "voucher_balance_changed", "account_not_found", "action_confirmation_required", "admin_required", "api_not_approved", "app_check_invalid", "app_check_missing", "cashregister_not_assigned", "cashregister_not_found", "cashregister_token_invalid", "cashregister_token_missing", "dialect_mismatch", "internal_translation_error", "live_not_enabled", "method_not_allowed", "mfa_required", "not_found", "password_change_required", "register_user_no_business", "register_user_not_allowed", "register_user_not_found", "response_translation_failed", "second_factor_required", "session_expired", "session_other_cashregister", "unauthorized", "user_disabled", "user_verification_failed", "route_missing", "response_unreadable"];
22
22
  export type ReceiptErrorCode = (typeof RECEIPT_ERROR_CODES)[number];
23
23
  export declare function isReceiptErrorCode(value: unknown): value is ReceiptErrorCode;
24
24
  /** Der Code eines geworfenen Fehlers, wenn er in [RECEIPT_ERROR_CODES] steht; sonst `undefined`. */
@@ -34,6 +34,8 @@ exports.RECEIPT_ERROR_CODES = Object.freeze([
34
34
  // Seit 1.15.0 (Vertrag): derselbe idempotencyKey mit anderem Inhalt, nichts geschrieben. Seit 1.22.0 sendet
35
35
  // dieses Paket den Schluessel, wenn der Aufrufer ihn angibt (`idempotencyKey` an sellReceipt/createReceipt).
36
36
  'idempotency_conflict',
37
+ // Seit 1.27.0 (Zusatz-Kacheln): addOnOf zeigt nicht nach vorne auf eine Warenposition, die selbst kein Zusatz ist.
38
+ 'invalid_add_on_reference',
37
39
  'module_inactive',
38
40
  'not_permitted',
39
41
  'receipt_limit_exceeded',
@@ -61,6 +61,12 @@ export interface ReceiptItem {
61
61
  originalIndex?: number;
62
62
  /** Nur an Storno-Zeilen mit `articleId`: wohin die Ware ging (Lager-Kern Stufe 2). */
63
63
  returnDisposition?: ReturnDisposition;
64
+ /**
65
+ * Zusatz-Kacheln (1.27.0): Index der Hauptposition im selben Beleg; nur an
66
+ * Zusatzpositionen. Der Server prueft: ganze Zahl, zeigt nach vorne auf eine
67
+ * Warenposition, die selbst kein Zusatz ist (`invalid_add_on_reference`).
68
+ */
69
+ addOnOf?: number;
64
70
  }
65
71
  /** Empfaenger einer Trinkgeld-Position (Kassen-Benutzer, Snapshot des Namens). */
66
72
  export interface TipRecipient {
@@ -99,6 +105,8 @@ export interface ReceiptItemPayload {
99
105
  keptByEmployee?: boolean;
100
106
  /** Artikel-Verweis, siehe [ReceiptItem.articleId]. */
101
107
  articleId?: string;
108
+ /** Hauptposition eines Zusatzes, siehe [ReceiptItem.addOnOf]. */
109
+ addOnOf?: number;
102
110
  }
103
111
  /**
104
112
  * Nutzlast-Form, die dieses Paket **liest** — v2 und v1 nebeneinander, alles
@@ -144,6 +152,8 @@ export interface ReceiptItemPayloadRead {
144
152
  originalIndex?: number | null;
145
153
  /** Storno-Zeile mit `articleId`: Rueckgabe-Wahl, siehe [ReceiptItem.returnDisposition]. */
146
154
  returnDisposition?: string | null;
155
+ /** Hauptposition eines Zusatzes, siehe [ReceiptItem.addOnOf]. */
156
+ addOnOf?: number | null;
147
157
  }
148
158
  export declare function toReceiptItemPayload(item: ReceiptItem): ReceiptItemPayload;
149
159
  /**
@@ -68,6 +68,9 @@ function toReceiptItemPayload(item) {
68
68
  // Artikel-Verweis reist mit (Erloesgruppen im Bericht); leere Werte nicht.
69
69
  if (item.articleId != null && item.articleId !== '')
70
70
  nutzlast.articleId = item.articleId;
71
+ // Zusatz-Kacheln: Verweis auf die Hauptposition nur, wenn gesetzt.
72
+ if (istIndex(item.addOnOf))
73
+ nutzlast.addOnOf = item.addOnOf;
71
74
  return nutzlast;
72
75
  }
73
76
  /**
@@ -118,8 +121,13 @@ function fromReceiptItemPayload(payload) {
118
121
  // unbekannter Wert faellt weg wie am Rand des Servers).
119
122
  ...(Number.isInteger(payload.originalIndex) && payload.originalIndex >= 0 ? { originalIndex: payload.originalIndex } : {}),
120
123
  ...((0, cancellation_js_1.isReturnDisposition)(payload.returnDisposition) ? { returnDisposition: payload.returnDisposition } : {}),
124
+ // Zusatz-Kacheln: Verweis auf die Hauptposition (nur eine ganze Zahl >= 0).
125
+ ...(istIndex(payload.addOnOf) ? { addOnOf: payload.addOnOf } : {}),
121
126
  };
122
127
  }
128
+ function istIndex(wert) {
129
+ return Number.isInteger(wert) && wert >= 0;
130
+ }
123
131
  /** Erster brauchbarer Zahlenwert der Reihe; `null`/`undefined`/NaN zaehlen nicht. */
124
132
  function ersteZahl(...werte) {
125
133
  for (const wert of werte) {
@@ -14,6 +14,13 @@ export interface ArticleGroup {
14
14
  symbol: string | null;
15
15
  sort: number;
16
16
  vatRate: number | null;
17
+ /**
18
+ * Zusaetze der Gruppe (Zusatz-Kacheln, 1.27.0): Artikel-Kennungen in der
19
+ * Reihenfolge des Fensters; null = keine. Optional, damit bestehende Literale
20
+ * weiter uebersetzen; der Leser setzt das Feld immer. Wirksam wird die Liste
21
+ * erst ueber [addOnsFor].
22
+ */
23
+ addOns?: string[] | null;
17
24
  }
18
25
  export interface ArticleGroupPayload {
19
26
  id?: string | null;
@@ -22,7 +29,10 @@ export interface ArticleGroupPayload {
22
29
  symbol?: string | null;
23
30
  sort?: number | null;
24
31
  vatRate?: number | null;
32
+ addOns?: unknown;
25
33
  }
34
+ /** Zusatzliste am Draht: nur eine Liste von Texten zaehlt, sonst null. Paketintern. */
35
+ export declare function addOnListe(wert: unknown): string[] | null;
26
36
  export declare function fromArticleGroupPayload(p: ArticleGroupPayload): ArticleGroup;
27
37
  /**
28
38
  * Mengenregel eines Artikels (Draht `quantityRule`): `piece` = ganze Stueck
@@ -105,6 +115,12 @@ export interface PosArticle {
105
115
  askPrice?: boolean;
106
116
  /** Kasse fragt beim Antippen eine Referenz ab; null = aus. Der Leser setzt es immer. */
107
117
  reference?: PosReference | null;
118
+ /**
119
+ * Eigene Zusatzliste (Zusatz-Kacheln, 1.27.0): null = wie die Gruppe, [] =
120
+ * keine, sonst die Liste in der Reihenfolge des Fensters. Der Leser setzt es
121
+ * immer; wirksam wird es ueber [addOnsFor].
122
+ */
123
+ addOns?: string[] | null;
108
124
  }
109
125
  /**
110
126
  * Kann die Kachel gebucht werden? Mit festem Preis immer, ohne Preis nur mit
@@ -144,6 +160,7 @@ export interface PosArticlePayload {
144
160
  serviceVoucher?: boolean | null;
145
161
  askPrice?: boolean | null;
146
162
  reference?: unknown;
163
+ addOns?: unknown;
147
164
  }
148
165
  export declare function fromPosArticlePayload(p: PosArticlePayload): PosArticle;
149
166
  /**
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.QUANTITY_RULES = void 0;
4
+ exports.addOnListe = addOnListe;
4
5
  exports.fromArticleGroupPayload = fromArticleGroupPayload;
5
6
  exports.quantityRuleForUnit = quantityRuleForUnit;
6
7
  exports.quantityDefaults = quantityDefaults;
@@ -13,6 +14,10 @@ exports.listMyArticleGroups = listMyArticleGroups;
13
14
  exports.listMyArticles = listMyArticles;
14
15
  const errors_js_1 = require("../client/errors.js");
15
16
  const kachel_referenz_js_1 = require("./kachel-referenz.js");
17
+ /** Zusatzliste am Draht: nur eine Liste von Texten zaehlt, sonst null. Paketintern. */
18
+ function addOnListe(wert) {
19
+ return Array.isArray(wert) ? wert.filter((s) => typeof s === 'string' && s !== '') : null;
20
+ }
16
21
  function fromArticleGroupPayload(p) {
17
22
  return {
18
23
  id: p.id ?? '',
@@ -21,6 +26,7 @@ function fromArticleGroupPayload(p) {
21
26
  symbol: p.symbol ?? null,
22
27
  sort: typeof p.sort === 'number' ? p.sort : 0,
23
28
  vatRate: typeof p.vatRate === 'number' ? p.vatRate : null,
29
+ addOns: addOnListe(p.addOns),
24
30
  };
25
31
  }
26
32
  /**
@@ -99,6 +105,7 @@ function fromPosArticlePayload(p) {
99
105
  serviceVoucher: p.serviceVoucher === true,
100
106
  askPrice: p.askPrice === true,
101
107
  reference: (0, kachel_referenz_js_1.fromReferencePayload)(p.reference),
108
+ addOns: addOnListe(p.addOns),
102
109
  };
103
110
  }
104
111
  /**
@@ -9,6 +9,7 @@
9
9
  export { type PosTheme, type PosFontSize, type PosWatermark, type PosQuantity, type PosTipMode, type PosCheckoutMode, type PosCardProvider, type PosReceiptOutput, type PosShortcutAction, type PosShortcutMap, POS_SHORTCUT_ACTIONS, POS_SHORTCUT_DEFAULTS, type PosLayout, type PosCategoryPosition, type PosTileHeight, type PosPrinterType, type PosTerminalVia, type PosTerminalType, type PosPaperSize, type PosCodePage, type PosCut, type PosDrawerAutoOpen, type PosQrMode, type PosLogoSize, type PosSettingsFontSize, type PosTileStyle, type PosAutoLogoutMinutes, type PosDiscount, type PosWatermarkSide, type PosWatermarkStrength, type PosLogoScale, type PosWatermarkScale, type PosDoneScreenSeconds, type PosToggleMap, type PosBusinessSettings, type PosDeviceSettings, type PosSettings, POS_BUSINESS_DEFAULTS, POS_DEVICE_DEFAULTS, POS_DEVICE_OPTIONAL_FIELDS, POS_BUSINESS_OPTIONAL_FIELDS, posTipKeptByDefault, POS_BUSINESS_VALUES, POS_DEVICE_VALUES, mergePosSettings, sanitizePosSettings, unknownPosSettingValues, posSettingsChanges, type PosOpen, POS_SHORTCUT_SHARED_PAIRS, posShortcutConflict, THEME, FONT_SIZE, WATERMARK, QUANTITY, TIP_MODE, CHECKOUT_MODE, CARD_PROVIDER, RECEIPT_OUTPUT, LAYOUT, CATEGORY_POSITION, TILE_HEIGHT, PRINTER_TYPE, TERMINAL_VIA, TERMINAL_TYPE, PAPER_SIZE, CODE_PAGE, CUT, DRAWER_AUTO_OPEN, QR_MODE, LOGO_SIZE, SETTINGS_FONT_SIZE, TILE_STYLE, AUTO_LOGOUT_MINUTES, DISCOUNT, WATERMARK_SIDE, WATERMARK_STRENGTH, LOGO_SCALE, WATERMARK_SCALE, DONE_SCREEN_SECONDS, } from './settings.js';
10
10
  export { type ArticleGroup, type ArticleGroupPayload, fromArticleGroupPayload, type PosArticle, type PosArticlePayload, fromPosArticlePayload, listMyArticleGroups, listMyArticles, QUANTITY_RULES, type QuantityRule, type QuantityDefaults, quantityRuleForUnit, quantityDefaults, allowedQuantity, isBookableArticle, tilePrompts, } from './artikel.js';
11
11
  export { REFERENCE_MODES, type ReferenceMode, type PosReference, REFERENCE_INPUT_MAX, REFERENCE_LABEL_MAX, REFERENCE_HINT_MAX, REFERENCE_PATTERN_MAX, REFERENCE_PATTERN_TEMPLATES, cleanReferenceText, isValidReferencePattern, isDigitsOnlyPattern, type ReferenceCheckResult, checkReference, referenceLineName, fromReferencePayload, } from './kachel-referenz.js';
12
+ export { ADD_ONS_MAX, ADD_ON_BLOCK_REASONS, type AddOnBlockReason, isSelectableAddOn, addOnsFor, addOnReferencesValid, addOnsOfItem, addOnRemap, addOnDisplayOrder, orderAddOnLines, } from './zusaetze.js';
12
13
  export { getPosSettings, setMyPosSettings, setMyRegisterDeviceSettings, setMyPosLogo, posSettingsFromWire, type SetMyPosLogoOptions, } from './client.js';
13
14
  export { POS_ERROR_CODES, type PosErrorCode, isPosErrorCode, posErrorCode, isPosError, type PosFieldError, posFieldErrors, } from './errors.js';
14
15
  export { distributeDiscount } from '../receipt/discount.js';
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.quantityRuleForUnit = exports.QUANTITY_RULES = exports.listMyArticles = exports.listMyArticleGroups = exports.fromPosArticlePayload = exports.fromArticleGroupPayload = exports.DONE_SCREEN_SECONDS = exports.WATERMARK_SCALE = exports.LOGO_SCALE = exports.WATERMARK_STRENGTH = exports.WATERMARK_SIDE = exports.DISCOUNT = exports.AUTO_LOGOUT_MINUTES = exports.TILE_STYLE = exports.SETTINGS_FONT_SIZE = exports.LOGO_SIZE = exports.QR_MODE = exports.DRAWER_AUTO_OPEN = exports.CUT = exports.CODE_PAGE = exports.PAPER_SIZE = exports.TERMINAL_TYPE = exports.TERMINAL_VIA = exports.PRINTER_TYPE = exports.TILE_HEIGHT = exports.CATEGORY_POSITION = exports.LAYOUT = exports.RECEIPT_OUTPUT = exports.CARD_PROVIDER = exports.CHECKOUT_MODE = exports.TIP_MODE = exports.QUANTITY = exports.WATERMARK = exports.FONT_SIZE = exports.THEME = exports.posShortcutConflict = exports.POS_SHORTCUT_SHARED_PAIRS = exports.posSettingsChanges = exports.unknownPosSettingValues = exports.sanitizePosSettings = exports.mergePosSettings = exports.POS_DEVICE_VALUES = exports.POS_BUSINESS_VALUES = exports.posTipKeptByDefault = exports.POS_BUSINESS_OPTIONAL_FIELDS = exports.POS_DEVICE_OPTIONAL_FIELDS = exports.POS_DEVICE_DEFAULTS = exports.POS_BUSINESS_DEFAULTS = exports.POS_SHORTCUT_DEFAULTS = exports.POS_SHORTCUT_ACTIONS = void 0;
4
- exports.listMyStocktakeCounts = exports.listMyStocktakeItems = exports.listMyStocktakes = exports.setMyCashregisterStockLocation = exports.listMyStock = exports.listMyStockLocations = exports.STOCK_LOCATION_TYPES = exports.reportConnectState = exports.inspectionInfoLines = exports.inspectionInfoRows = exports.getRegisterInspectionInfo = exports.depFolderName = exports.listMyTipRecipients = exports.getPrintJob = exports.createPrintJob = exports.listMyPrinters = exports.isPrintJobFinished = exports.PRINT_JOB_SOURCES = exports.PRINT_JOB_STATUSES = exports.voucherPermsOf = exports.stockViewOf = exports.receiptsScopeOf = exports.cancelScopeOf = exports.distributeDiscount = exports.posFieldErrors = exports.isPosError = exports.posErrorCode = exports.isPosErrorCode = exports.POS_ERROR_CODES = exports.posSettingsFromWire = exports.setMyPosLogo = exports.setMyRegisterDeviceSettings = exports.setMyPosSettings = exports.getPosSettings = exports.fromReferencePayload = exports.referenceLineName = exports.checkReference = exports.isDigitsOnlyPattern = exports.isValidReferencePattern = exports.cleanReferenceText = exports.REFERENCE_PATTERN_TEMPLATES = exports.REFERENCE_PATTERN_MAX = exports.REFERENCE_HINT_MAX = exports.REFERENCE_LABEL_MAX = exports.REFERENCE_INPUT_MAX = exports.REFERENCE_MODES = exports.tilePrompts = exports.isBookableArticle = exports.allowedQuantity = exports.quantityDefaults = void 0;
5
- exports.CANCELLATION_PAYMENT_ERROR_MESSAGES = exports.receiptEmailErrorMessage = exports.RECEIPT_EMAIL_ERROR_MESSAGES = exports.messageAppliesTo = exports.messageText = exports.messageOutcome = exports.findErrorRule = exports.CALLS_WITH_EFFECT = exports.ERROR_OUTCOME_RULES = exports.ERROR_CODE_RULES = exports.ERROR_RULES = exports.MESSAGES = exports.isReturnDisposition = exports.RETURN_DISPOSITIONS = exports.RECEIPT_OUTPUT_RESULTS = exports.RECEIPT_OUTPUT_KINDS = exports.cashMovementLayout = exports.shiftReceiptLayout = exports.AFTER_COUNT_TYPES = exports.SHIFT_RECEIPT_KINDS = exports.MANUAL_OPENING_REASONS = exports.OPENING_REASONS = exports.CASH_LOCATIONS = exports.MANUAL_MOVEMENT_TYPES = exports.MOVEMENT_TYPES = exports.EUR_DENOMINATIONS = exports.durationText = exports.shiftTipLines = exports.newIdempotencyKey = exports.parseCentsAllowZero = exports.sumDenominations = exports.closeMyShift = exports.getMyShiftReport = exports.logMyDrawerOpenings = exports.recordMyCashMovement = exports.openMyShift = exports.getMyDrawerState = exports.VOUCHER_TYPE_VALIDITY_PATTERNS = exports.VOUCHER_AMOUNT_MODES = exports.VOUCHER_TYPE_KINDS = exports.VOUCHER_PAYOUTS = exports.posVoucherSettingsFromWire = exports.VOUCHER_SETTINGS_DEFAULTS = exports.reprintVoucherLabel = exports.checkVoucher = exports.VOUCHER_STATUSES = exports.VOUCHER_KINDS = exports.parseQuantityMilli = exports.voidMyStocktakeCount = exports.recordMyStocktakeCount = void 0;
6
- exports.receiptOutputLabel = exports.RETURN_DISPOSITION_LABELS = exports.labelText = exports.LABELS = exports.voucherErrorMessage = exports.VOUCHER_ERROR_MESSAGES = exports.cancellationErrorMessage = exports.CANCELLATION_VOUCHER_ERROR_MESSAGES = exports.cancellationPaymentErrorMessage = void 0;
4
+ exports.inspectionInfoRows = exports.getRegisterInspectionInfo = exports.depFolderName = exports.listMyTipRecipients = exports.getPrintJob = exports.createPrintJob = exports.listMyPrinters = exports.isPrintJobFinished = exports.PRINT_JOB_SOURCES = exports.PRINT_JOB_STATUSES = exports.voucherPermsOf = exports.stockViewOf = exports.receiptsScopeOf = exports.cancelScopeOf = exports.distributeDiscount = exports.posFieldErrors = exports.isPosError = exports.posErrorCode = exports.isPosErrorCode = exports.POS_ERROR_CODES = exports.posSettingsFromWire = exports.setMyPosLogo = exports.setMyRegisterDeviceSettings = exports.setMyPosSettings = exports.getPosSettings = exports.orderAddOnLines = exports.addOnDisplayOrder = exports.addOnRemap = exports.addOnsOfItem = exports.addOnReferencesValid = exports.addOnsFor = exports.isSelectableAddOn = exports.ADD_ON_BLOCK_REASONS = exports.ADD_ONS_MAX = exports.fromReferencePayload = exports.referenceLineName = exports.checkReference = exports.isDigitsOnlyPattern = exports.isValidReferencePattern = exports.cleanReferenceText = exports.REFERENCE_PATTERN_TEMPLATES = exports.REFERENCE_PATTERN_MAX = exports.REFERENCE_HINT_MAX = exports.REFERENCE_LABEL_MAX = exports.REFERENCE_INPUT_MAX = exports.REFERENCE_MODES = exports.tilePrompts = exports.isBookableArticle = exports.allowedQuantity = exports.quantityDefaults = void 0;
5
+ exports.ERROR_CODE_RULES = exports.ERROR_RULES = exports.MESSAGES = exports.isReturnDisposition = exports.RETURN_DISPOSITIONS = exports.RECEIPT_OUTPUT_RESULTS = exports.RECEIPT_OUTPUT_KINDS = exports.cashMovementLayout = exports.shiftReceiptLayout = exports.AFTER_COUNT_TYPES = exports.SHIFT_RECEIPT_KINDS = exports.MANUAL_OPENING_REASONS = exports.OPENING_REASONS = exports.CASH_LOCATIONS = exports.MANUAL_MOVEMENT_TYPES = exports.MOVEMENT_TYPES = exports.EUR_DENOMINATIONS = exports.durationText = exports.shiftTipLines = exports.newIdempotencyKey = exports.parseCentsAllowZero = exports.sumDenominations = exports.closeMyShift = exports.getMyShiftReport = exports.logMyDrawerOpenings = exports.recordMyCashMovement = exports.openMyShift = exports.getMyDrawerState = exports.VOUCHER_TYPE_VALIDITY_PATTERNS = exports.VOUCHER_AMOUNT_MODES = exports.VOUCHER_TYPE_KINDS = exports.VOUCHER_PAYOUTS = exports.posVoucherSettingsFromWire = exports.VOUCHER_SETTINGS_DEFAULTS = exports.reprintVoucherLabel = exports.checkVoucher = exports.VOUCHER_STATUSES = exports.VOUCHER_KINDS = exports.parseQuantityMilli = exports.voidMyStocktakeCount = exports.recordMyStocktakeCount = exports.listMyStocktakeCounts = exports.listMyStocktakeItems = exports.listMyStocktakes = exports.setMyCashregisterStockLocation = exports.listMyStock = exports.listMyStockLocations = exports.STOCK_LOCATION_TYPES = exports.reportConnectState = exports.inspectionInfoLines = void 0;
6
+ exports.receiptOutputLabel = exports.RETURN_DISPOSITION_LABELS = exports.labelText = exports.LABELS = exports.voucherErrorMessage = exports.VOUCHER_ERROR_MESSAGES = exports.cancellationErrorMessage = exports.CANCELLATION_VOUCHER_ERROR_MESSAGES = exports.cancellationPaymentErrorMessage = exports.CANCELLATION_PAYMENT_ERROR_MESSAGES = exports.receiptEmailErrorMessage = exports.RECEIPT_EMAIL_ERROR_MESSAGES = exports.messageAppliesTo = exports.messageText = exports.messageOutcome = exports.findErrorRule = exports.CALLS_WITH_EFFECT = exports.ERROR_OUTCOME_RULES = void 0;
7
7
  /**
8
8
  * Kachel-Kasse: Einstellungen, Artikelgruppen/Artikel fuer Kacheln,
9
9
  * Rabattverteilung, Drucker, Trinkgeld-Empfaenger, Lager (Standorte, Bestand,
@@ -82,6 +82,16 @@ Object.defineProperty(exports, "isDigitsOnlyPattern", { enumerable: true, get: f
82
82
  Object.defineProperty(exports, "checkReference", { enumerable: true, get: function () { return kachel_referenz_js_1.checkReference; } });
83
83
  Object.defineProperty(exports, "referenceLineName", { enumerable: true, get: function () { return kachel_referenz_js_1.referenceLineName; } });
84
84
  Object.defineProperty(exports, "fromReferencePayload", { enumerable: true, get: function () { return kachel_referenz_js_1.fromReferencePayload; } });
85
+ var zusaetze_js_1 = require("./zusaetze.js");
86
+ Object.defineProperty(exports, "ADD_ONS_MAX", { enumerable: true, get: function () { return zusaetze_js_1.ADD_ONS_MAX; } });
87
+ Object.defineProperty(exports, "ADD_ON_BLOCK_REASONS", { enumerable: true, get: function () { return zusaetze_js_1.ADD_ON_BLOCK_REASONS; } });
88
+ Object.defineProperty(exports, "isSelectableAddOn", { enumerable: true, get: function () { return zusaetze_js_1.isSelectableAddOn; } });
89
+ Object.defineProperty(exports, "addOnsFor", { enumerable: true, get: function () { return zusaetze_js_1.addOnsFor; } });
90
+ Object.defineProperty(exports, "addOnReferencesValid", { enumerable: true, get: function () { return zusaetze_js_1.addOnReferencesValid; } });
91
+ Object.defineProperty(exports, "addOnsOfItem", { enumerable: true, get: function () { return zusaetze_js_1.addOnsOfItem; } });
92
+ Object.defineProperty(exports, "addOnRemap", { enumerable: true, get: function () { return zusaetze_js_1.addOnRemap; } });
93
+ Object.defineProperty(exports, "addOnDisplayOrder", { enumerable: true, get: function () { return zusaetze_js_1.addOnDisplayOrder; } });
94
+ Object.defineProperty(exports, "orderAddOnLines", { enumerable: true, get: function () { return zusaetze_js_1.orderAddOnLines; } });
85
95
  var client_js_1 = require("./client.js");
86
96
  Object.defineProperty(exports, "getPosSettings", { enumerable: true, get: function () { return client_js_1.getPosSettings; } });
87
97
  Object.defineProperty(exports, "setMyPosSettings", { enumerable: true, get: function () { return client_js_1.setMyPosSettings; } });
@@ -2084,6 +2084,19 @@ declare const BESCHRIFTUNGEN_ROH: {
2084
2084
  readonly 'tile_prompt.apply_anyway': {
2085
2085
  readonly text: "Trotzdem übernehmen";
2086
2086
  };
2087
+ readonly 'addons.title': {
2088
+ readonly text: "Zusätze zu {name}";
2089
+ readonly placeholders: readonly ["name"];
2090
+ };
2091
+ readonly 'addons.none': {
2092
+ readonly text: "Ohne Zusatz";
2093
+ };
2094
+ readonly 'addons.done': {
2095
+ readonly text: "Fertig";
2096
+ };
2097
+ readonly 'addons.open': {
2098
+ readonly text: "Zusätze";
2099
+ };
2087
2100
  readonly 'voucher.tab': {
2088
2101
  readonly text: "Gutscheine";
2089
2102
  };
@@ -1060,6 +1060,11 @@ const BESCHRIFTUNGEN_ROH = {
1060
1060
  'tile_prompt.quantity': { text: 'Menge' },
1061
1061
  'tile_prompt.apply': { text: 'Übernehmen' },
1062
1062
  'tile_prompt.apply_anyway': { text: 'Trotzdem übernehmen' },
1063
+ // Zusatz-Kacheln (1.27.0): Fenster nach dem Antippen einer Hauptleistung, Knopf an der Korbzeile.
1064
+ 'addons.title': { text: 'Zusätze zu {name}', placeholders: ['name'] },
1065
+ 'addons.none': { text: 'Ohne Zusatz' },
1066
+ 'addons.done': { text: 'Fertig' },
1067
+ 'addons.open': { text: 'Zusätze' },
1063
1068
  // Gutschein-Sorten als Kacheln im Reiter „Gutscheine“ (Stufe 4b, 1.17.0): Kachel je Sorte mit Betrag
1064
1069
  // oder „Betrag eingeben“, darunter klein die Art; dazu die feste Kachel „Leistungsgutschein“.
1065
1070
  'voucher.tab': { text: 'Gutscheine' },
@@ -0,0 +1,70 @@
1
+ import type { ArticleGroup, PosArticle } from './artikel.js';
2
+ /**
3
+ * Zusatz-Kacheln (1.27.0): Tippt man eine Hauptleistung an, oeffnet die Kasse
4
+ * ein Fenster mit ihren Zusaetzen. Die Liste steht an der Gruppe, je Artikel
5
+ * abweichend (`addOns`: null = wie die Gruppe, [] = keine, sonst eigene Liste).
6
+ * Jeder Zusatz wird eine eigene Belegposition mit `addOnOf` = Index der
7
+ * Hauptposition. Die Regeln rechnen Backend (`gemeinsam/zusatz-core.js`), npm
8
+ * und Dart gleich; der Vertrag sind die Pruefaelle `fixtures/add-on-cases.json`.
9
+ */
10
+ /** Hoechstens so viele Zusaetze je Liste (der Server weist mehr ab). */
11
+ export declare const ADD_ONS_MAX = 30;
12
+ /** Warum ein Artikel kein Zusatz sein kann (Panel zeigt den Grund an). */
13
+ export declare const ADD_ON_BLOCK_REASONS: readonly ["inactive", "own_list", "asks_price", "reference", "asks_quantity", "no_price", "service_voucher"];
14
+ export type AddOnBlockReason = typeof ADD_ON_BLOCK_REASONS[number];
15
+ type ZusatzArtikel = Pick<PosArticle, 'id' | 'active' | 'unitPriceCents'> & Partial<Pick<PosArticle, 'addOns' | 'askPrice' | 'reference' | 'askQuantity' | 'serviceVoucher'>>;
16
+ type ArtikelNachId<T> = ReadonlyMap<string, T> | Readonly<Record<string, T>>;
17
+ /**
18
+ * Taugt der Artikel als Zusatz? `null` = ja. Im Fenster wird ohne Abfrage
19
+ * gebucht: Betrag, Referenz oder Menge fragen geht nicht, ein Preis muss
20
+ * feststehen (0 erlaubt), ein Leistungsgutschein liefe am Gutschein-Weg vorbei,
21
+ * und ein Artikel mit eigener Liste oeffnete selbst ein Fenster (eine Ebene).
22
+ */
23
+ export declare function isSelectableAddOn(a: ZusatzArtikel): AddOnBlockReason | null;
24
+ /**
25
+ * Wirksame Zusatzliste eines Artikels: eigene Liste (auch leer) vor der der
26
+ * Gruppe; still heraus fallen der Artikel selbst, Unbekanntes, Dubletten und
27
+ * alles, was nicht als Zusatz taugt. Leer = kein Fenster.
28
+ */
29
+ export declare function addOnsFor<T extends ZusatzArtikel>(article: ZusatzArtikel, group: Pick<ArticleGroup, 'addOns'> | null | undefined, articleById: ArtikelNachId<T>): string[];
30
+ type MitVerweis = {
31
+ addOnOf?: number | null;
32
+ };
33
+ /**
34
+ * Halten die Verweise den Server-Regeln stand? Ganze Zahl, zeigt nach vorne
35
+ * auf eine Warenposition, die selbst kein Zusatz ist (sonst antwortet
36
+ * createReceipt mit `invalid_add_on_reference`).
37
+ */
38
+ export declare function addOnReferencesValid(items: readonly (MitVerweis & {
39
+ kind?: string | null;
40
+ })[]): boolean;
41
+ /** Indizes der Zusaetze einer Hauptposition (Storno: mit vormerken, abwaehlbar). */
42
+ export declare function addOnsOfItem(items: readonly MitVerweis[], index: number): number[];
43
+ /**
44
+ * Storno: Verweis je Storno-Position (in der Reihenfolge der stornierten
45
+ * Positionen, Menge > 0). Ein Zusatz behaelt ihn nur, wenn seine Hauptposition
46
+ * mit storniert wird, umgerechnet auf den neuen Index; sonst `null`.
47
+ */
48
+ export declare function addOnRemap(items: readonly MitVerweis[], quantities: readonly number[]): (number | null)[];
49
+ /** Ist Position `i` ein gueltiger Zusatz (Verweis nach vorne auf eine Hauptposition)? Paketintern (Layout). */
50
+ export declare function istGueltigerZusatz(items: readonly MitVerweis[], i: number): boolean;
51
+ /**
52
+ * Bon-Reihenfolge: jede Hauptposition, direkt gefolgt von ihren Zusaetzen
53
+ * (stabil). Positionen mit ungueltigem Verweis bleiben an ihrem Platz.
54
+ */
55
+ export declare function addOnDisplayOrder(items: readonly MitVerweis[]): number[];
56
+ /**
57
+ * Warenkorb -> Belegpositionen: Zeilen tragen die Zeilen-Id ihrer Hauptzeile
58
+ * (`addOnOf`). Sortiert jeden Zusatz hinter seine Hauptzeile (stabil) und
59
+ * rechnet den Verweis in den Index um. Fehlt die Hauptzeile (geloescht oder
60
+ * vorher herausgefiltert, etwa ein Gutschein-Verkauf), bleibt die Zeile ohne
61
+ * Verweis an ihrem Platz.
62
+ */
63
+ export declare function orderAddOnLines<T extends {
64
+ id: string;
65
+ addOnOf?: string | null;
66
+ }>(lines: readonly T[]): {
67
+ line: T;
68
+ addOnOf: number | null;
69
+ }[];
70
+ export {};
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ADD_ON_BLOCK_REASONS = exports.ADD_ONS_MAX = void 0;
4
+ exports.isSelectableAddOn = isSelectableAddOn;
5
+ exports.addOnsFor = addOnsFor;
6
+ exports.addOnReferencesValid = addOnReferencesValid;
7
+ exports.addOnsOfItem = addOnsOfItem;
8
+ exports.addOnRemap = addOnRemap;
9
+ exports.istGueltigerZusatz = istGueltigerZusatz;
10
+ exports.addOnDisplayOrder = addOnDisplayOrder;
11
+ exports.orderAddOnLines = orderAddOnLines;
12
+ /**
13
+ * Zusatz-Kacheln (1.27.0): Tippt man eine Hauptleistung an, oeffnet die Kasse
14
+ * ein Fenster mit ihren Zusaetzen. Die Liste steht an der Gruppe, je Artikel
15
+ * abweichend (`addOns`: null = wie die Gruppe, [] = keine, sonst eigene Liste).
16
+ * Jeder Zusatz wird eine eigene Belegposition mit `addOnOf` = Index der
17
+ * Hauptposition. Die Regeln rechnen Backend (`gemeinsam/zusatz-core.js`), npm
18
+ * und Dart gleich; der Vertrag sind die Pruefaelle `fixtures/add-on-cases.json`.
19
+ */
20
+ /** Hoechstens so viele Zusaetze je Liste (der Server weist mehr ab). */
21
+ exports.ADD_ONS_MAX = 30;
22
+ /** Warum ein Artikel kein Zusatz sein kann (Panel zeigt den Grund an). */
23
+ exports.ADD_ON_BLOCK_REASONS = ['inactive', 'own_list', 'asks_price', 'reference', 'asks_quantity', 'no_price', 'service_voucher'];
24
+ const eigeneListe = (a) => Array.isArray(a.addOns) && a.addOns.length > 0;
25
+ /**
26
+ * Taugt der Artikel als Zusatz? `null` = ja. Im Fenster wird ohne Abfrage
27
+ * gebucht: Betrag, Referenz oder Menge fragen geht nicht, ein Preis muss
28
+ * feststehen (0 erlaubt), ein Leistungsgutschein liefe am Gutschein-Weg vorbei,
29
+ * und ein Artikel mit eigener Liste oeffnete selbst ein Fenster (eine Ebene).
30
+ */
31
+ function isSelectableAddOn(a) {
32
+ if (a.active === false)
33
+ return 'inactive';
34
+ if (eigeneListe(a))
35
+ return 'own_list';
36
+ if (a.askPrice === true)
37
+ return 'asks_price';
38
+ if (a.reference != null)
39
+ return 'reference';
40
+ if (a.askQuantity === true)
41
+ return 'asks_quantity';
42
+ if (typeof a.unitPriceCents !== 'number' || !Number.isInteger(a.unitPriceCents) || a.unitPriceCents < 0)
43
+ return 'no_price';
44
+ if (a.serviceVoucher === true)
45
+ return 'service_voucher';
46
+ return null;
47
+ }
48
+ function nachId(karte, id) {
49
+ if (karte instanceof Map)
50
+ return karte.get(id);
51
+ return Object.prototype.hasOwnProperty.call(karte, id) ? karte[id] : undefined;
52
+ }
53
+ /**
54
+ * Wirksame Zusatzliste eines Artikels: eigene Liste (auch leer) vor der der
55
+ * Gruppe; still heraus fallen der Artikel selbst, Unbekanntes, Dubletten und
56
+ * alles, was nicht als Zusatz taugt. Leer = kein Fenster.
57
+ */
58
+ function addOnsFor(article, group, articleById) {
59
+ const liste = Array.isArray(article.addOns) ? article.addOns : (group && Array.isArray(group.addOns) ? group.addOns : []);
60
+ const raus = [];
61
+ for (const id of liste) {
62
+ if (typeof id !== 'string' || id === article.id || raus.includes(id))
63
+ continue;
64
+ const z = nachId(articleById, id);
65
+ if (!z || isSelectableAddOn(z) !== null)
66
+ continue;
67
+ raus.push(id);
68
+ }
69
+ return raus;
70
+ }
71
+ const hatVerweis = (it) => it != null && typeof it === 'object' && Object.prototype.hasOwnProperty.call(it, 'addOnOf') && it.addOnOf !== undefined;
72
+ // Positionsarten, die nie Zusatz oder Hauptposition sind (Trinkgeld, Rabatt, Gutschein).
73
+ const OHNE_ZUSATZ = new Set(['tip', 'discount', 'voucher', 'voucher_float']);
74
+ /**
75
+ * Halten die Verweise den Server-Regeln stand? Ganze Zahl, zeigt nach vorne
76
+ * auf eine Warenposition, die selbst kein Zusatz ist (sonst antwortet
77
+ * createReceipt mit `invalid_add_on_reference`).
78
+ */
79
+ function addOnReferencesValid(items) {
80
+ return items.every((it, i) => {
81
+ if (!hatVerweis(it))
82
+ return true;
83
+ const z = it.addOnOf;
84
+ if (typeof z !== 'number' || !Number.isInteger(z) || z < 0 || z >= i)
85
+ return false;
86
+ const ziel = items[z];
87
+ if (OHNE_ZUSATZ.has(it.kind ?? '') || OHNE_ZUSATZ.has(ziel?.kind ?? ''))
88
+ return false;
89
+ return !hatVerweis(ziel);
90
+ });
91
+ }
92
+ /** Indizes der Zusaetze einer Hauptposition (Storno: mit vormerken, abwaehlbar). */
93
+ function addOnsOfItem(items, index) {
94
+ const raus = [];
95
+ items.forEach((it, i) => { if (hatVerweis(it) && it.addOnOf === index)
96
+ raus.push(i); });
97
+ return raus;
98
+ }
99
+ /**
100
+ * Storno: Verweis je Storno-Position (in der Reihenfolge der stornierten
101
+ * Positionen, Menge > 0). Ein Zusatz behaelt ihn nur, wenn seine Hauptposition
102
+ * mit storniert wird, umgerechnet auf den neuen Index; sonst `null`.
103
+ */
104
+ function addOnRemap(items, quantities) {
105
+ const neu = new Map();
106
+ const raus = [];
107
+ items.forEach((it, i) => {
108
+ if (!((quantities[i] ?? 0) > 0))
109
+ return;
110
+ neu.set(i, raus.length);
111
+ raus.push(hatVerweis(it) && neu.has(it.addOnOf) ? neu.get(it.addOnOf) : null);
112
+ });
113
+ return raus;
114
+ }
115
+ /** Ist Position `i` ein gueltiger Zusatz (Verweis nach vorne auf eine Hauptposition)? Paketintern (Layout). */
116
+ function istGueltigerZusatz(items, i) {
117
+ const it = items[i];
118
+ return it != null && hatVerweis(it) && Number.isInteger(it.addOnOf)
119
+ && it.addOnOf >= 0 && it.addOnOf < i && !hatVerweis(items[it.addOnOf]);
120
+ }
121
+ /**
122
+ * Bon-Reihenfolge: jede Hauptposition, direkt gefolgt von ihren Zusaetzen
123
+ * (stabil). Positionen mit ungueltigem Verweis bleiben an ihrem Platz.
124
+ */
125
+ function addOnDisplayOrder(items) {
126
+ const gueltig = (_it, i) => istGueltigerZusatz(items, i);
127
+ const raus = [];
128
+ items.forEach((it, i) => {
129
+ if (gueltig(it, i))
130
+ return;
131
+ raus.push(i);
132
+ items.forEach((z, j) => { if (j > i && gueltig(z, j) && z.addOnOf === i)
133
+ raus.push(j); });
134
+ });
135
+ return raus;
136
+ }
137
+ /**
138
+ * Warenkorb -> Belegpositionen: Zeilen tragen die Zeilen-Id ihrer Hauptzeile
139
+ * (`addOnOf`). Sortiert jeden Zusatz hinter seine Hauptzeile (stabil) und
140
+ * rechnet den Verweis in den Index um. Fehlt die Hauptzeile (geloescht oder
141
+ * vorher herausgefiltert, etwa ein Gutschein-Verkauf), bleibt die Zeile ohne
142
+ * Verweis an ihrem Platz.
143
+ */
144
+ function orderAddOnLines(lines) {
145
+ const ids = new Set(lines.map((l) => l.id));
146
+ const istZusatz = (l) => typeof l.addOnOf === 'string' && l.addOnOf !== l.id && ids.has(l.addOnOf)
147
+ && !lines.some((h) => h.id === l.addOnOf && typeof h.addOnOf === 'string' && ids.has(h.addOnOf));
148
+ const raus = [];
149
+ for (const l of lines) {
150
+ if (istZusatz(l))
151
+ continue;
152
+ const index = raus.length;
153
+ raus.push({ line: l, addOnOf: null });
154
+ for (const z of lines)
155
+ if (istZusatz(z) && z.addOnOf === l.id)
156
+ raus.push({ line: z, addOnOf: index });
157
+ }
158
+ return raus;
159
+ }
@@ -105,7 +105,19 @@ function renderReceiptGrid(layout, options = {}) {
105
105
  const breiten = gridColumnWidths(z.columns.map((c) => c.width), zeichen);
106
106
  // Inhalt jeder nicht-letzten Spalte um 1 Zeichen schmaler: garantierter Abstand.
107
107
  const inhalt = breiten.map((b, i) => (i < breiten.length - 1 ? Math.max(1, b - 1) : b));
108
- const teile = z.columns.map((c, i) => (0, escpos_js_1.wrapText)(c.text, inhalt[i]));
108
+ // Haengender Einzug wie bei Textzeilen: eine linksbuendige Spalte mit
109
+ // fuehrenden Leerzeichen bricht mit demselben Einzug um; ein Spiegelstrich
110
+ // „+ “ danach zaehlt mit (Zusatzzeile „ + 1 x …“: Fortsetzung unter der
111
+ // Menge). Ohne fuehrende Leerzeichen dieselben Zeichen wie bisher.
112
+ const einzugVon = (c, i) => {
113
+ const e = c.align === 'left' ? (/^ +(?:\+ )?/.exec(c.text)?.[0].length ?? 0) : 0;
114
+ return e > 0 && e < inhalt[i] && c.text.slice(e).trim() !== '' ? e : 0;
115
+ };
116
+ const einzuege = z.columns.map(einzugVon);
117
+ const umbrechen = (text, breite, e) => (e > 0
118
+ ? (0, escpos_js_1.wrapText)(text.slice(e), breite - e).map((t, k) => (k === 0 ? text.slice(0, e) : ' '.repeat(e)) + t)
119
+ : (0, escpos_js_1.wrapText)(text, breite));
120
+ const teile = z.columns.map((c, i) => umbrechen(c.text, inhalt[i], einzuege[i]));
109
121
  // Fliessregel: laeuft nach der ersten Zeile nur noch EINE Spalte weiter (die anderen sind
110
122
  // fertig), bekommt ihr Rest die volle Breite -- auf 58 mm sonst 18-Zeichen-Schnipsel.
111
123
  // Laufen mehrere weiter, bleibt das Raster (sonst verschoeben sich die Nachbarn).
@@ -124,8 +136,9 @@ function renderReceiptGrid(layout, options = {}) {
124
136
  const i = weiterlaufend[0];
125
137
  // Rest aus dem Originaltext (nicht aus den schmal umbrochenen Stuecken), damit
126
138
  // Bindestrich-/Hartbrueche der schmalen Spalte nicht als Leerzeichen zurueckbleiben.
127
- const rest = restNach(z.columns[i].text, teile[i][0]);
128
- for (const t of (0, escpos_js_1.wrapText)(rest, zeichen))
139
+ const e = einzuege[i];
140
+ const rest = e > 0 ? restNach(z.columns[i].text.slice(e), teile[i][0].slice(e)) : restNach(z.columns[i].text, teile[i][0]);
141
+ for (const t of (e > 0 ? (0, escpos_js_1.wrapText)(rest, zeichen - e).map((x) => ' '.repeat(e) + x) : (0, escpos_js_1.wrapText)(rest, zeichen)))
129
142
  lines.push({ text: ausrichten(t, zeichen, z.columns[i].align), kind: 'columns', bold: z.bold === true });
130
143
  }
131
144
  break;
@@ -14,6 +14,7 @@ const index_js_1 = require("../enums/index.js");
14
14
  const index_js_2 = require("../models/index.js");
15
15
  const vienna_time_js_1 = require("../vienna-time.js");
16
16
  const errors_js_1 = require("../client/errors.js");
17
+ const zusaetze_js_1 = require("../pos/zusaetze.js");
17
18
  exports.CURRENT_LAYOUT_RULESET = 2;
18
19
  /** Die Optionen von [buildReceiptLayout]; jede andere wird abgewiesen. */
19
20
  const LAYOUT_OPTIONEN = new Set(['paperSize', 'ruleset', 'testCashregister', 'testSignature', 'registrationInfo']);
@@ -830,8 +831,10 @@ function trinkgeldZeilen(name, teile) {
830
831
  * Aufteilung als Fussnote darunter (siehe trinkgeldZeilen).
831
832
  */
832
833
  const rabattZeilen = trinkgeldZeilen;
833
- /** Positionszeile: Menge, Bezeichnung, ab Menge 2 der Einzelpreis. */
834
- function positionsZeile(item, satz) {
834
+ /** Vorsatz einer Zusatzzeile (Zusatz-Kacheln, 1.27.0): eingerueckt unter der Hauptposition. */
835
+ const ZUSATZ_VORSATZ = ' + ';
836
+ /** Positionszeile: Menge, Bezeichnung, ab Menge 2 der Einzelpreis; ein Zusatz eingerueckt mit „+ “. */
837
+ function positionsZeile(item, satz, zusatz = false) {
835
838
  const menge = String(item.quantity);
836
839
  // Vorbild: Menge auf zwei Zeichen auffuellen, danach ' x ' — bei drei- und
837
840
  // mehrstelligen Mengen faellt das Leerzeichen dahinter weg.
@@ -841,7 +844,7 @@ function positionsZeile(item, satz) {
841
844
  return {
842
845
  kind: 'columns',
843
846
  columns: [
844
- { text: `${kopf}${item.name}${einzelpreis}`, width: 7, align: 'left' },
847
+ { text: `${zusatz ? ZUSATZ_VORSATZ : ''}${kopf}${item.name}${einzelpreis}`, width: 7, align: 'left' },
845
848
  { text: `${formatCents((0, index_js_2.receiptItemTotalCents)(item))} ${satz.category}`, width: 5, align: 'right' },
846
849
  ],
847
850
  };
@@ -1165,22 +1168,26 @@ function buildReceiptLayout(receipt, company, options = {}) {
1165
1168
  .reduce((summe, it) => summe + (0, index_js_2.receiptItemTotalCents)(it), 0);
1166
1169
  let zwischensummeGezeigt = false;
1167
1170
  const gutscheinZuordnung = gutscheinPositionen(receipt);
1171
+ // Zusatz-Kacheln: Zusaetze direkt unter ihrer Hauptposition (stabil); ohne
1172
+ // Verweise ist die Reihenfolge die des Belegs (byte-gleich).
1173
+ const reihe = (0, zusaetze_js_1.addOnDisplayOrder)(receipt.items);
1174
+ const an = (k) => receipt.items[reihe[k]];
1168
1175
  let i = 0;
1169
- while (i < receipt.items.length) {
1170
- const item = receipt.items[i];
1176
+ while (i < reihe.length) {
1177
+ const item = an(i);
1171
1178
  if (!(0, index_js_2.isTipItem)(item) && !(0, index_js_2.isDiscountItem)(item)) {
1172
1179
  const satz = steuersatz(item.vat);
1173
1180
  gruppeVon(satz).bruttoCents += (0, index_js_2.receiptItemTotalCents)(item);
1174
- const gutschein = gutscheinZuordnung.get(i);
1175
- lines.push(...(gutschein ? gutscheinPositionsZeilen(item, satz, gutschein) : [positionsZeile(item, satz)]));
1181
+ const gutschein = gutscheinZuordnung.get(reihe[i]);
1182
+ lines.push(...(gutschein ? gutscheinPositionsZeilen(item, satz, gutschein) : [positionsZeile(item, satz, (0, zusaetze_js_1.istGueltigerZusatz)(receipt.items, reihe[i]))]));
1176
1183
  i += 1;
1177
1184
  continue;
1178
1185
  }
1179
1186
  const artVon = (it) => ((0, index_js_2.isTipItem)(it) ? 'tip' : 'discount');
1180
1187
  const art = artVon(item);
1181
1188
  const gruppe = [];
1182
- while (i < receipt.items.length && artVon(receipt.items[i]) === art && !(!(0, index_js_2.isTipItem)(receipt.items[i]) && !(0, index_js_2.isDiscountItem)(receipt.items[i])) && receipt.items[i].name === item.name) {
1183
- gruppe.push(receipt.items[i]);
1189
+ while (i < reihe.length && artVon(an(i)) === art && !(!(0, index_js_2.isTipItem)(an(i)) && !(0, index_js_2.isDiscountItem)(an(i))) && an(i).name === item.name) {
1190
+ gruppe.push(an(i));
1184
1191
  i += 1;
1185
1192
  }
1186
1193
  const teile = [];
@@ -1,5 +1,5 @@
1
1
  /** Fingerabdruck des Vertrags-Exports, aus dem diese Datei stammt (`_quelle.sha256`). */
2
- export declare const VOKABULAR_QUELLE = "a17db090c6fb519a9fb0c707461a1da228f4c6ce8e6a6e23cc6e20e2702baf0f";
2
+ export declare const VOKABULAR_QUELLE = "842340e1f94c14fab01ffe96277d76dff4482b97df2e355daa583ff49c2db634";
3
3
  /** Schema-Notation des Vertrags: Blatt 'aussen': 'innen', Objekt { __: 'innen', ... }, Liste [ { __: 'innen', ... } ]. */
4
4
  export type SchemaEintrag = string | SchemaObjekt | readonly [SchemaObjekt];
5
5
  export interface SchemaObjekt {