@kreiseck/kasseneck-api 1.27.0 → 1.29.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 (104) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +84 -0
  3. package/dist/cjs/client/api.d.ts +15 -0
  4. package/dist/cjs/client/api.js +8 -0
  5. package/dist/cjs/client/aufrufe.d.ts +4 -4
  6. package/dist/cjs/client/aufrufe.js +31 -0
  7. package/dist/cjs/client/index.d.ts +1 -0
  8. package/dist/cjs/client/index.js +17 -1
  9. package/dist/cjs/client/terminal.d.ts +206 -0
  10. package/dist/cjs/client/terminal.js +288 -0
  11. package/dist/cjs/index.d.ts +1 -1
  12. package/dist/cjs/index.js +17 -1
  13. package/dist/cjs/pos/aufrunden.d.ts +6 -0
  14. package/dist/cjs/pos/aufrunden.js +59 -0
  15. package/dist/cjs/pos/client.js +12 -1
  16. package/dist/cjs/pos/index.d.ts +4 -3
  17. package/dist/cjs/pos/index.js +17 -4
  18. package/dist/cjs/pos/schicht-lesen.d.ts +2 -1
  19. package/dist/cjs/pos/schicht-lesen.js +48 -1
  20. package/dist/cjs/pos/schicht-typen.d.ts +106 -3
  21. package/dist/cjs/pos/schicht-typen.js +14 -4
  22. package/dist/cjs/pos/schicht.d.ts +28 -2
  23. package/dist/cjs/pos/schicht.js +19 -0
  24. package/dist/cjs/pos/settings.d.ts +39 -0
  25. package/dist/cjs/pos/settings.js +65 -4
  26. package/dist/cjs/pos/texte.d.ts +292 -0
  27. package/dist/cjs/pos/texte.js +108 -0
  28. package/dist/cjs/receipt/shift-sheet.js +29 -0
  29. package/dist/cjs/stored/einstellungen.js +31 -4
  30. package/dist/cjs/stored/vokabular.d.ts +1 -1
  31. package/dist/cjs/stored/vokabular.js +29 -2
  32. package/dist/cjs/version.d.ts +1 -1
  33. package/dist/cjs/version.js +1 -1
  34. package/dist/esm/client/api.d.ts +15 -0
  35. package/dist/esm/client/api.js +8 -0
  36. package/dist/esm/client/aufrufe.d.ts +4 -4
  37. package/dist/esm/client/aufrufe.js +31 -0
  38. package/dist/esm/client/index.d.ts +1 -0
  39. package/dist/esm/client/index.js +1 -0
  40. package/dist/esm/client/terminal.d.ts +206 -0
  41. package/dist/esm/client/terminal.js +278 -0
  42. package/dist/esm/index.d.ts +1 -1
  43. package/dist/esm/index.js +1 -1
  44. package/dist/esm/pos/aufrunden.d.ts +6 -0
  45. package/dist/esm/pos/aufrunden.js +56 -0
  46. package/dist/esm/pos/client.js +13 -2
  47. package/dist/esm/pos/index.d.ts +4 -3
  48. package/dist/esm/pos/index.js +5 -4
  49. package/dist/esm/pos/schicht-lesen.d.ts +2 -1
  50. package/dist/esm/pos/schicht-lesen.js +47 -1
  51. package/dist/esm/pos/schicht-typen.d.ts +106 -3
  52. package/dist/esm/pos/schicht-typen.js +13 -3
  53. package/dist/esm/pos/schicht.d.ts +28 -2
  54. package/dist/esm/pos/schicht.js +19 -1
  55. package/dist/esm/pos/settings.d.ts +39 -0
  56. package/dist/esm/pos/settings.js +60 -3
  57. package/dist/esm/pos/texte.d.ts +292 -0
  58. package/dist/esm/pos/texte.js +108 -0
  59. package/dist/esm/receipt/shift-sheet.js +29 -0
  60. package/dist/esm/stored/einstellungen.js +32 -5
  61. package/dist/esm/stored/vokabular.d.ts +1 -1
  62. package/dist/esm/stored/vokabular.js +29 -2
  63. package/dist/esm/version.d.ts +1 -1
  64. package/dist/esm/version.js +1 -1
  65. package/fixtures/duplicate-cases.json +6 -0
  66. package/fixtures/expected/duplicate.shift-close.hex +28 -27
  67. package/fixtures/expected/shift-close-blind.grid32.txt +1 -0
  68. package/fixtures/expected/shift-close-blind.grid48.txt +1 -0
  69. package/fixtures/expected/shift-close-blind.lines.json +6 -0
  70. package/fixtures/expected/shift-close-put-in.grid32.txt +1 -0
  71. package/fixtures/expected/shift-close-put-in.grid48.txt +1 -0
  72. package/fixtures/expected/shift-close-put-in.lines.json +6 -0
  73. package/fixtures/expected/shift-close-take-out.grid32.txt +1 -0
  74. package/fixtures/expected/shift-close-take-out.grid48.txt +1 -0
  75. package/fixtures/expected/shift-close-take-out.lines.json +6 -0
  76. package/fixtures/expected/shift-close.grid32.txt +1 -0
  77. package/fixtures/expected/shift-close.grid48.txt +1 -0
  78. package/fixtures/expected/shift-close.lines.json +6 -0
  79. package/fixtures/expected/shift-interim.grid32.txt +1 -0
  80. package/fixtures/expected/shift-interim.grid48.txt +1 -0
  81. package/fixtures/expected/shift-interim.lines.json +6 -0
  82. package/fixtures/hobex-hps-codes.json +1 -1
  83. package/fixtures/invoice-api.schema.json +1 -1
  84. package/fixtures/invoice-texts.json +1 -1
  85. package/fixtures/pos-texts.json +337 -1
  86. package/fixtures/renames-1.0.json +30 -0
  87. package/fixtures/shift-ablauf-cases.json +182 -0
  88. package/fixtures/shift-receipts.json +15 -15
  89. package/fixtures/surface.json +59 -4
  90. package/fixtures/tip-round-up-cases.json +27 -0
  91. package/fixtures/v3/antworten/belege.json +2 -2
  92. package/fixtures/v3/antworten/belegmail.json +2 -2
  93. package/fixtures/v3/antworten/berichte.json +2 -2
  94. package/fixtures/v3/antworten/kasse-belege.json +2 -2
  95. package/fixtures/v3/antworten/kasse.json +504 -4
  96. package/fixtures/v3/antworten/lager.json +1 -1
  97. package/fixtures/v3/antworten/rechnungen.json +2 -2
  98. package/fixtures/v3/antworten/storno.json +2 -2
  99. package/fixtures/v3/stored/belege.json +2 -2
  100. package/fixtures/v3/stored/kasse.json +520 -12
  101. package/fixtures/v3/stored/rechnungen.json +2 -2
  102. package/fixtures/v3/v3-vokabular.json +184 -11
  103. package/fixtures/v3/zahlbetrag-faelle.json +2 -2
  104. package/package.json +1 -1
@@ -0,0 +1,278 @@
1
+ import { KasseneckValidationError } from './errors.js';
2
+ /**
3
+ * Kartenterminal am Handy (nur unter `/v3`): Kasseneck verwaltet die Zugaenge
4
+ * der Terminal-App, die Terminal-IDs (TID) je Betrieb und den Code, den der
5
+ * Anbieter beim Umzug einer TID auf ein anderes Geraet per E-Mail schickt.
6
+ * Die App holt sich Zugang, TID und Code von hier; am Geraet tippt niemand
7
+ * E-Mail, Passwort oder TID.
8
+ *
9
+ * **Anmeldung:** der `api_key` des Betriebs als Bearer. Ein `cashregister-token`
10
+ * (wie ihn `apiKeyAuth` mitsendet) stoert nicht, wird aber nicht gebraucht; eine
11
+ * App ohne Kasse nimmt eine Anmeldung nur mit dem Schluessel (etwa
12
+ * `inventoryKeyAuth` aus `./inventory`). Das Geraet weist sich zusaetzlich mit
13
+ * `deviceId` + `deviceSecret` aus, die es einmal mit [registerTerminalDevice]
14
+ * bekommt. Am Kassenweg gibt es die Aufrufe noch nicht.
15
+ *
16
+ * **Geheimnisse:** `deviceSecret`, `password` und `code` stehen nur in den
17
+ * Antworten bzw. Anfragen. Das Paket schreibt sie in kein Log und in keinen
18
+ * Fehler (das Geraetegeheimnis geht als `secretParams` an den Transport); die
19
+ * App darf sie ebenfalls nie loggen und speichert `deviceSecret` im sicheren
20
+ * Speicher des Geraets.
21
+ *
22
+ * Geprueft wird hier nur die Form; was der Server nicht annimmt, lehnt er mit
23
+ * einem Code aus [TERMINAL_ERROR_CODES] ab.
24
+ */
25
+ /** Plattform des Geraets. */
26
+ export const TERMINAL_PLATFORMS = Object.freeze(['android', 'ios']);
27
+ /**
28
+ * Einrichtungsstand der Terminal-App am Geraet: TID zugewiesen, wartet auf den
29
+ * Code, wird eingerichtet, bereit, fehlgeschlagen.
30
+ */
31
+ export const TERMINAL_SETUP_STATES = Object.freeze(['assigned', 'waiting_for_code', 'setting_up', 'ready', 'failed']);
32
+ /**
33
+ * Stand einer Code-Anfrage: keine Anfrage, sucht, gefunden, zugestellt,
34
+ * unklar (mehrere Geraete warteten gleichzeitig), kein Code gefunden,
35
+ * abgelaufen.
36
+ */
37
+ export const TERMINAL_CODE_STATUSES = Object.freeze(['none', 'searching', 'found', 'delivered', 'unclear', 'no_code', 'expired']);
38
+ /** Woher ein Code kam: aus dem Postfach oder vom Support eingetragen. */
39
+ export const TERMINAL_CODE_SOURCES = Object.freeze(['mailbox', 'support']);
40
+ /**
41
+ * Fehlercodes der sieben Aufrufe (`code` des [KasseneckApiError]) wie im
42
+ * Vertrag des Backends (`errorCodes.terminal` in `fixtures/v3/v3-vokabular.json`),
43
+ * in dessen Reihenfolge; dazu kommen die gemeinsamen Codes von Anmeldung und
44
+ * Rand. Ein Code ausserhalb bleibt ueber `KasseneckApiError.code` lesbar.
45
+ */
46
+ export const TERMINAL_ERROR_CODES = Object.freeze([
47
+ 'terminal_not_enabled', // dem Betrieb ist keine aktive TID zugeordnet
48
+ 'terminal_test_environment', // nur in der Live-Umgebung (kein kr_test_-Schluessel)
49
+ 'terminal_device_unknown', // deviceId oder deviceSecret falsch (gleiche Antwort fuer beides)
50
+ 'terminal_device_blocked', // das Geraet ist gesperrt
51
+ 'invalid_terminal_device', // Angaben zum Geraet unvollstaendig oder ungueltig
52
+ 'too_many_terminal_devices', // Obergrenze der Geraete je Betrieb oder der Anmeldungen je Tag erreicht
53
+ 'terminal_not_in_business', // die TID gibt es nicht oder sie gehoert einem anderen Betrieb (gleiche Antwort)
54
+ 'terminal_code_manual', // Konto ohne Postfach: die App fragt nach dem Code
55
+ 'terminal_code_rate_limited', // hoechstens 6 Code-Anfragen je Geraet und Stunde
56
+ 'terminal_not_assigned', // dem Geraet ist keine TID zugeordnet: zuerst getTerminalAccess
57
+ 'server_error',
58
+ ]);
59
+ /** Laengen der Texte, die der Server annimmt (nach Abzug von Leerraum am Rand). */
60
+ export const TERMINAL_LABEL_MAX = 60;
61
+ export const TERMINAL_APP_MAX = 40;
62
+ export const TERMINAL_REQUESTED_BY_MAX = 80;
63
+ // ---- Hilfen -------------------------------------------------------------------------------------
64
+ function eingabefehler(name, grund) {
65
+ return new KasseneckValidationError(name, grund, 'request');
66
+ }
67
+ function antwortfehler(name, grund) {
68
+ return new KasseneckValidationError(name, grund, 'response');
69
+ }
70
+ const istObjekt = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
71
+ const istText = (v) => typeof v === 'string' && v.trim() !== '';
72
+ const textOderNull = (v) => (typeof v === 'string' ? v : null);
73
+ /** Pflichttext mit Hoechstlaenge (nach Abzug von Leerraum am Rand, wie der Server). */
74
+ function pruefeText(name, feld, wert, max) {
75
+ if (typeof wert !== 'string' || wert.trim() === '')
76
+ throw eingabefehler(name, `${feld} fehlt oder ist leer`);
77
+ if (wert.trim().length > max)
78
+ throw eingabefehler(name, `${feld}: hoechstens ${max} Zeichen`);
79
+ return wert;
80
+ }
81
+ function pruefePlattform(name, wert) {
82
+ if (!TERMINAL_PLATFORMS.includes(wert))
83
+ throw eingabefehler(name, 'platform muss android oder ios sein');
84
+ return wert;
85
+ }
86
+ /** Ausweis des Geraets pruefen; die Meldung nennt nie das Geheimnis. */
87
+ function ausweis(name, options) {
88
+ if (!istObjekt(options))
89
+ throw eingabefehler(name, 'Anfrage muss ein Objekt sein');
90
+ if (!istText(options.deviceId))
91
+ throw eingabefehler(name, 'deviceId fehlt oder ist leer');
92
+ if (!istText(options.deviceSecret))
93
+ throw eingabefehler(name, 'deviceSecret fehlt oder ist leer');
94
+ return { params: { deviceId: options.deviceId, deviceSecret: options.deviceSecret }, geheim: options.deviceSecret };
95
+ }
96
+ /** Optionale Felder nur, wenn gesetzt. */
97
+ function optional(name, params, options) {
98
+ if (options.platform !== undefined)
99
+ params['platform'] = pruefePlattform(name, options.platform);
100
+ if (options.app !== undefined)
101
+ params['app'] = pruefeText(name, 'app', options.app, TERMINAL_APP_MAX);
102
+ if (options.label !== undefined)
103
+ params['label'] = pruefeText(name, 'label', options.label, TERMINAL_LABEL_MAX);
104
+ if (options.requestedBy !== undefined)
105
+ params['requestedBy'] = pruefeText(name, 'requestedBy', options.requestedBy, TERMINAL_REQUESTED_BY_MAX);
106
+ }
107
+ function setupAus(name, wert) {
108
+ if (!istObjekt(wert) || typeof wert['state'] !== 'string')
109
+ throw antwortfehler(name, 'Antwort ohne setup.state');
110
+ return { state: wert['state'], since: textOderNull(wert['since']) };
111
+ }
112
+ /** Zugang aus der Antwort; die Meldungen nennen nie Login, Passwort oder TID. */
113
+ function zugangAus(name, d) {
114
+ if (!istText(d['username']) || !istText(d['password']) || !istText(d['terminalId']) || typeof d['accountId'] !== 'string') {
115
+ throw antwortfehler(name, 'Zugang unvollstaendig (username, password, terminalId, accountId)');
116
+ }
117
+ if (typeof d['autoCode'] !== 'boolean')
118
+ throw antwortfehler(name, 'Antwort ohne autoCode');
119
+ const format = d['codeFormat'];
120
+ if (!istObjekt(format) || !(typeof format['length'] === 'number' && Number.isSafeInteger(format['length']) && format['length'] > 0) ||
121
+ !Array.isArray(format['labels']) || !format['labels'].every((l) => typeof l === 'string')) {
122
+ throw antwortfehler(name, 'Antwort ohne gueltiges codeFormat (length, labels)');
123
+ }
124
+ return {
125
+ available: true,
126
+ username: d['username'],
127
+ password: d['password'],
128
+ terminalId: d['terminalId'],
129
+ terminalName: textOderNull(d['terminalName']),
130
+ accountId: d['accountId'],
131
+ autoCode: d['autoCode'],
132
+ codeFormat: { length: format['length'], labels: [...format['labels']] },
133
+ setup: setupAus(name, d['setup']),
134
+ updatedAt: textOderNull(d['updatedAt']),
135
+ };
136
+ }
137
+ function listeAus(name, d) {
138
+ const roh = d['terminals'];
139
+ if (typeof d['reason'] !== 'string' || !Array.isArray(roh))
140
+ throw antwortfehler(name, 'Antwort ohne reason oder terminals');
141
+ const terminals = [];
142
+ for (const t of roh) {
143
+ if (!istObjekt(t) || !istText(t['terminalId']))
144
+ throw antwortfehler(name, 'Eintrag in terminals ohne terminalId');
145
+ terminals.push({
146
+ terminalId: t['terminalId'],
147
+ name: textOderNull(t['name']),
148
+ lastUsedBy: textOderNull(t['lastUsedBy']),
149
+ lastUsedAt: textOderNull(t['lastUsedAt']),
150
+ });
151
+ }
152
+ return { available: false, reason: d['reason'], terminals };
153
+ }
154
+ async function zugangRufen(transport, name, params, geheim) {
155
+ const daten = await transport(name, params, undefined, [geheim]);
156
+ if (!istObjekt(daten) || typeof daten['available'] !== 'boolean')
157
+ throw antwortfehler(name, 'Antwort ohne available');
158
+ return daten['available'] ? zugangAus(name, daten) : listeAus(name, daten);
159
+ }
160
+ // ---- Aufrufe ------------------------------------------------------------------------------------
161
+ /**
162
+ * Meldet ein Geraet einmal an (`registerTerminalDevice`) und liefert seinen
163
+ * Ausweis. `deviceSecret` steht nur in dieser Antwort: im sicheren Speicher
164
+ * ablegen, nie loggen. Hoechstens 20 Geraete je Betrieb und 10 Anmeldungen je
165
+ * Tag (`too_many_terminal_devices`). Eine Wiederholung nach unklarem Ausgang
166
+ * legt ein weiteres Geraet an.
167
+ */
168
+ export async function registerTerminalDevice(transport, options) {
169
+ const name = 'registerTerminalDevice';
170
+ if (!istObjekt(options))
171
+ throw eingabefehler(name, 'Anfrage muss ein Objekt sein');
172
+ const params = {
173
+ label: pruefeText(name, 'label', options.label, TERMINAL_LABEL_MAX),
174
+ platform: pruefePlattform(name, options.platform),
175
+ app: pruefeText(name, 'app', options.app, TERMINAL_APP_MAX),
176
+ };
177
+ optional(name, params, { requestedBy: options.requestedBy });
178
+ const daten = await transport(name, params);
179
+ if (!istObjekt(daten) || !istText(daten['deviceId']) || !istText(daten['deviceSecret'])) {
180
+ throw antwortfehler(name, 'Antwort ohne deviceId oder deviceSecret');
181
+ }
182
+ return { deviceId: daten['deviceId'], deviceSecret: daten['deviceSecret'] };
183
+ }
184
+ /**
185
+ * Zugang und TID fuer dieses Geraet (`getTerminalAccess`). Das Geraet behaelt
186
+ * seine TID; ohne eine bekommt es eine freie seines Betriebs. Ist keine frei,
187
+ * kommt `available: false` mit den TIDs des eigenen Betriebs zur Auswahl fuer
188
+ * [claimTerminal]. Die App ruft das bei jedem Start und mindestens einmal am
189
+ * Tag. `password` nie loggen.
190
+ */
191
+ export async function getTerminalAccess(transport, options) {
192
+ const name = 'getTerminalAccess';
193
+ const { params, geheim } = ausweis(name, options);
194
+ optional(name, params, { platform: options.platform, app: options.app, label: options.label });
195
+ return zugangRufen(transport, name, params, geheim);
196
+ }
197
+ /**
198
+ * Uebernimmt eine TID des eigenen Betriebs (`claimTerminal`); das Geraet, das
199
+ * sie bisher nutzte, verliert sie. Antwort wie [getTerminalAccess] mit
200
+ * Zugang. Eine fremde oder unbekannte TID ist `terminal_not_in_business`.
201
+ */
202
+ export async function claimTerminal(transport, options) {
203
+ const name = 'claimTerminal';
204
+ const { params, geheim } = ausweis(name, options);
205
+ if (!istText(options.terminalId))
206
+ throw eingabefehler(name, 'terminalId fehlt oder ist leer');
207
+ params['terminalId'] = options.terminalId;
208
+ optional(name, params, { label: options.label });
209
+ const ergebnis = await zugangRufen(transport, name, params, geheim);
210
+ if (!ergebnis.available)
211
+ throw antwortfehler(name, 'Antwort ohne Zugang');
212
+ return ergebnis;
213
+ }
214
+ /**
215
+ * Fragt den Code fuer die TID dieses Geraets an (`requestTerminalCode`); nur
216
+ * bei Konten mit Postfach (`TerminalAccess.autoCode`), sonst
217
+ * `terminal_code_manual`. Eine offene Anfrage juenger als 6 Minuten bleibt
218
+ * (doppeltes Tippen schadet nicht); hoechstens 6 Anfragen je Stunde
219
+ * (`terminal_code_rate_limited`). Den Code holt danach [getTerminalCode].
220
+ */
221
+ export async function requestTerminalCode(transport, options) {
222
+ const name = 'requestTerminalCode';
223
+ const { params, geheim } = ausweis(name, options);
224
+ params['platform'] = pruefePlattform(name, options.platform);
225
+ optional(name, params, { requestedBy: options.requestedBy });
226
+ const daten = await transport(name, params, undefined, [geheim]);
227
+ if (!istObjekt(daten) || typeof daten['status'] !== 'string')
228
+ throw antwortfehler(name, 'Antwort ohne status');
229
+ return { status: daten['status'] };
230
+ }
231
+ /**
232
+ * Stand der Code-Anfrage und der Einrichtung (`getTerminalCode`); ohne Anfrage
233
+ * `status: 'none'`. Bei `found` steht der Code genau in dieser Antwort: auf
234
+ * Android wird er dabei verbraucht (eine verlorene Antwort verliert ihn), auf
235
+ * iOS bleibt er bis `validUntil` lesbar. Den Code nie loggen.
236
+ */
237
+ export async function getTerminalCode(transport, options) {
238
+ const name = 'getTerminalCode';
239
+ const { params, geheim } = ausweis(name, options);
240
+ const daten = await transport(name, params, undefined, [geheim]);
241
+ if (!istObjekt(daten) || typeof daten['status'] !== 'string')
242
+ throw antwortfehler(name, 'Antwort ohne status');
243
+ const ergebnis = { status: daten['status'], setup: setupAus(name, daten['setup']) };
244
+ if (daten['code'] !== undefined && daten['code'] !== null) {
245
+ if (!istText(daten['code']))
246
+ throw antwortfehler(name, 'code ist kein Text');
247
+ ergebnis.code = daten['code'];
248
+ if (typeof daten['source'] === 'string')
249
+ ergebnis.source = daten['source'];
250
+ ergebnis.validUntil = textOderNull(daten['validUntil']);
251
+ }
252
+ return ergebnis;
253
+ }
254
+ /**
255
+ * Meldet den Ausgang der Anmeldung in der Terminal-App (`reportTerminalLogin`).
256
+ * Antwort: nichts. Eine andere als die zugewiesene TID schreibt der Server
257
+ * nicht.
258
+ */
259
+ export async function reportTerminalLogin(transport, options) {
260
+ const name = 'reportTerminalLogin';
261
+ const { params, geheim } = ausweis(name, options);
262
+ if (!istText(options.terminalId))
263
+ throw eingabefehler(name, 'terminalId fehlt oder ist leer');
264
+ if (typeof options.success !== 'boolean')
265
+ throw eingabefehler(name, 'success muss true oder false sein');
266
+ if (typeof options.newOnDevice !== 'boolean')
267
+ throw eingabefehler(name, 'newOnDevice muss true oder false sein');
268
+ params['terminalId'] = options.terminalId;
269
+ params['success'] = options.success;
270
+ params['newOnDevice'] = options.newOnDevice;
271
+ await transport(name, params, undefined, [geheim]);
272
+ }
273
+ /** Meldet, dass die Terminal-App fertig eingerichtet ist (`reportTerminalReady`). Antwort: nichts. */
274
+ export async function reportTerminalReady(transport, options) {
275
+ const name = 'reportTerminalReady';
276
+ const { params, geheim } = ausweis(name, options);
277
+ await transport(name, params, undefined, [geheim]);
278
+ }
@@ -1,6 +1,6 @@
1
1
  export { ReceiptType, type ReceiptTypeKey, VatRate, type VatRateKey, KeckPaymentMethod, type KeckPaymentMethodKey, CreditCardProvider, type CreditCardProviderKey, VoucherType, type VoucherTypeKey, VoucherAction, type VoucherActionKey, StripeLinkMode, type StripeLinkModeKey, } from './enums/index.js';
2
2
  export { type ReceiptItem, type ReceiptItemPayload, type ReceiptItemPayloadRead, toReceiptItemPayload, fromReceiptItemPayload, receiptItemTotalCents, receiptItemIsValid, negateReceiptItem, type TipRecipient, isTipItem, isVoucherItem, isVoucherFloatItem, type Voucher, type VoucherArticle, type IssuedVoucher, type ReturnIssuedVoucher, type VoucherPayload, toVoucherPayload, fromVoucherPayload, voucherIsValid, type Receipt, type RegistrationInfo, type ReceiptPayload, type ReceiptPayloadRead, toReceiptPayload, fromReceiptPayload, receiptSubSumCents, receiptSumCents, receiptValueVoucherSign, type CancellationOf, type CancellationItem, type Cancellation, type CancellationReason, type CancellationErrorCode, type CancellationStatus, type ReturnDisposition, RETURN_DISPOSITIONS, CANCELLATION_REASONS, CANCELLATION_STATUSES, CANCELLATION_ERROR_CODES, CANCELLATION_RESERVATION_MS, isCancellationReason, isReturnDisposition, isCancellationErrorCode, cancellationErrorCode, isCancellationError, cancellationFieldErrors, type CancellationFieldError, type ReceiptPayment, type ReceiptPaymentPayload, type ReceiptPaymentInput, fromReceiptPaymentPayload, toReceiptPaymentPayload, type PaymentErrorCode, PAYMENT_ERROR_CODES, isPaymentErrorCode, paymentErrorCode, isPaymentError, paymentFieldErrors, type PaymentFieldError, type ReceiptEmailErrorCode, type ReceiptEmailVia, RECEIPT_EMAIL_ERROR_CODES, RECEIPT_EMAIL_SEND_ERROR_CODES, type ReceiptEmailSendErrorCode, RECEIPT_EMAIL_VIAS, isReceiptEmailErrorCode, receiptEmailErrorCode, isReceiptEmailError, receiptEmailFieldErrors, type ReceiptEmailFieldError, RECEIPT_OUTPUT_KINDS, type ReceiptOutputKind, RECEIPT_OUTPUT_LOG_KINDS, type ReceiptOutputLogKind, RECEIPT_OUTPUT_RESULTS, type ReceiptOutputResult, RECEIPT_OUTPUT_ENTRIES_MAX, type ReceiptOutput, type ReceiptOutputActor, RECEIPT_OUTPUT_ENTRY_ERROR_CODES, type ReceiptOutputEntryErrorCode, RECEIPT_OUTPUT_ERROR_CODES, type ReceiptOutputErrorCode, isReceiptOutputErrorCode, receiptOutputErrorCode, isReceiptOutputError, receiptOutputFieldErrors, type ReceiptOutputFieldError, type ReceiptErrorCode, type ReceiptFieldError, RECEIPT_ERROR_CODES, isReceiptErrorCode, receiptErrorCode, isReceiptError, receiptFieldErrors, remainingQuantities, TIP_REFUND_SOURCES, type TipRefundSource, isTipRefundSource, openStaffTipCents, cancellationItemsForTip, cancellationCashRefundCents, asksTipRefundSource, asksRefundTip, type ReceiptCompany, type ReceiptCompanyPayload, fromReceiptCompanyPayload, receiptCompanyTaxInfo, type Cashregister, type CashregisterOnboarding, type CashregisterPayload, type CashregisterOnboardingPayload, type CashregisterAutoLogout, type CashregisterAutoLogoutPayload, fromCashregisterPayload, type ReceiptSummary, type ReceiptSummaryPayload, fromReceiptSummaryPayload, type ZeroKind, ZERO_KINDS, isZeroKind, type ReportMonth, reportMonthFromDate, previousReportMonth, nextReportMonth, reportMonthKey, reportMonthReadable, type StripeUrlSession, type StripeUrlSessionPayload, toStripeUrlSessionPayload, fromStripeUrlSessionPayload, type HobexReceipt, type HobexReceiptPayload, toHobexReceiptPayload, fromHobexReceiptPayload, hobexReceiptToCardPaymentData, hobexReceiptNeedsSignature, } from './models/index.js';
3
- export { type AuthCredentials, type KasseneckAuth, type ApiKeyAuthOptions, type RegisterUserAuthOptions, apiKeyAuth, registerUserAuth, DEFAULT_BASE_URL, POS_BASE_URL, DEFAULT_TIMEOUT_MS, type HttpResponseLike, type HttpRequestInit, type FetchLike, type TransportOptions, type TransportBodyFields, type TransportCallOptions, type KasseneckTransport, type KasseneckBinaryTransport, type KasseneckPdfOrDataTransport, type PdfOrData, ALL_CALLS, type ApiCall, PUBLIC_CALLS, POS_CALLS, UNKNOWN_OUTCOME_CALLS, type PublicCall, type PosCall, createTransport, createBinaryTransport, createPdfOrDataTransport, createFileOrDataTransport, type FileOrData, type FileOrDataCallOptions, type KasseneckFileOrDataTransport, KasseneckApiError, KasseneckAuthError, KasseneckHttpError, KasseneckNetworkError, KasseneckValidationError, type ValidationScope, type KasseneckError, type HttpFailureReason, type CauseDigest, type ErrorOutcome, CLIENT_ERROR_CODES, type ClientErrorCode, isKasseneckApiError, isKasseneckAuthError, isKasseneckHttpError, isKasseneckNetworkError, isKasseneckValidationError, isOutcomeUnknown, type ReceiptCommonOptions, type SellReceiptOptions, type TipOptions, type TipRecipientShare, type CancelReceiptOptions, type CancelReceiptResult, type ReceiptWithCompany, sellReceipt, sellReceiptWithCompany, paymentsExpectedCents, cardRefundReference, receiptLayoutFromResult, cancelReceipt, zeroReceipt, getReceipt, getReceiptWithCompany, generateFullReceiptId, getFirstReceiptDate, listMyReceipts, type ListMyReceiptsOptions, type ReceiptList, type ReceiptListStats, listMyCashregisters, checkVoucherCombinationError, type SendReceiptEmailOptions, type SendReceiptEmailResult, sendReceiptEmail, type ReceiptOutputEntry, type LogReceiptOutputsOptions, type LogReceiptOutputsResult, type RejectedReceiptOutput, logReceiptOutputs, downloadDailyReport, downloadMonthlyReport, getCashregisterReport, type CashregisterReportPeriod, getReportV2, type ReportV2, type ReportV2Metadata, type ReportV2Options, listReceipts, listAllReceipts, fromListReceiptsSummaryPayload, listedReceiptWithCompany, LIST_RECEIPTS_VIEWS, LIST_RECEIPTS_ORDERS, LIST_RECEIPTS_LIMIT_MAX, LIST_RECEIPTS_DAYS_MAX, LIST_ALL_RECEIPTS_MAX_PAGES, LIST_RECEIPTS_ERROR_CODES, type ListReceiptsErrorCode, type ListReceiptsView, type ListReceiptsOrder, type ListReceiptsOptions, type ListReceiptsWindow, type ListReceiptsGrossByRate, type ListReceiptsSummary, type ListReceiptsDaySummary, type ListReceiptsPage, type ListedReceipt, createDepExport, getDepExport, waitForDepExport, getDepExportFile, createDepHandoverLink, revokeDepHandoverLink, DepExportTimeoutError, DepExportChecksumError, DEP_EXPORT_STATUSES, DEP_EXPORT_FILES, DEP_EXPORT_ERROR_CODES, DEP_EXPORT_FAILURES, DEP_EXPORT_POLL_START_MS, DEP_EXPORT_POLL_FACTOR, DEP_EXPORT_POLL_MAX_MS, DEP_EXPORT_WAIT_TIMEOUT_MS, DEP_EXPORT_DOWNLOAD_TIMEOUT_MS, type DepExportStatus, type DepExportFileKind, type DepExportErrorCode, type DepExportFailure, type CreateDepExportOptions, type CreateDepExportResult, type DepExportGap, type DepExportChainBreak, type DepExportFindings, type DepExportItems, type DepHandoverLinkInfo, type DepExport, type WaitForDepExportOptions, type GetDepExportFileOptions, type DepExportFile, type DepHandoverLink, type RevokedDepHandoverLink, type ListedFullReceipt, type ListReceiptsHeader, type CashboxStatus, type SignatureStatus, getCashboxStatus, getSignatureStatus, type KasseneckApi, createKasseneckApi, } from './client/index.js';
3
+ export { type AuthCredentials, type KasseneckAuth, type ApiKeyAuthOptions, type RegisterUserAuthOptions, apiKeyAuth, registerUserAuth, DEFAULT_BASE_URL, POS_BASE_URL, DEFAULT_TIMEOUT_MS, type HttpResponseLike, type HttpRequestInit, type FetchLike, type TransportOptions, type TransportBodyFields, type TransportCallOptions, type KasseneckTransport, type KasseneckBinaryTransport, type KasseneckPdfOrDataTransport, type PdfOrData, ALL_CALLS, type ApiCall, PUBLIC_CALLS, POS_CALLS, UNKNOWN_OUTCOME_CALLS, type PublicCall, type PosCall, createTransport, createBinaryTransport, createPdfOrDataTransport, createFileOrDataTransport, type FileOrData, type FileOrDataCallOptions, type KasseneckFileOrDataTransport, KasseneckApiError, KasseneckAuthError, KasseneckHttpError, KasseneckNetworkError, KasseneckValidationError, type ValidationScope, type KasseneckError, type HttpFailureReason, type CauseDigest, type ErrorOutcome, CLIENT_ERROR_CODES, type ClientErrorCode, isKasseneckApiError, isKasseneckAuthError, isKasseneckHttpError, isKasseneckNetworkError, isKasseneckValidationError, isOutcomeUnknown, type ReceiptCommonOptions, type SellReceiptOptions, type TipOptions, type TipRecipientShare, type CancelReceiptOptions, type CancelReceiptResult, type ReceiptWithCompany, sellReceipt, sellReceiptWithCompany, paymentsExpectedCents, cardRefundReference, receiptLayoutFromResult, cancelReceipt, zeroReceipt, getReceipt, getReceiptWithCompany, generateFullReceiptId, getFirstReceiptDate, listMyReceipts, type ListMyReceiptsOptions, type ReceiptList, type ReceiptListStats, listMyCashregisters, checkVoucherCombinationError, type SendReceiptEmailOptions, type SendReceiptEmailResult, sendReceiptEmail, type ReceiptOutputEntry, type LogReceiptOutputsOptions, type LogReceiptOutputsResult, type RejectedReceiptOutput, logReceiptOutputs, downloadDailyReport, downloadMonthlyReport, getCashregisterReport, type CashregisterReportPeriod, getReportV2, type ReportV2, type ReportV2Metadata, type ReportV2Options, listReceipts, listAllReceipts, fromListReceiptsSummaryPayload, listedReceiptWithCompany, LIST_RECEIPTS_VIEWS, LIST_RECEIPTS_ORDERS, LIST_RECEIPTS_LIMIT_MAX, LIST_RECEIPTS_DAYS_MAX, LIST_ALL_RECEIPTS_MAX_PAGES, LIST_RECEIPTS_ERROR_CODES, type ListReceiptsErrorCode, type ListReceiptsView, type ListReceiptsOrder, type ListReceiptsOptions, type ListReceiptsWindow, type ListReceiptsGrossByRate, type ListReceiptsSummary, type ListReceiptsDaySummary, type ListReceiptsPage, type ListedReceipt, createDepExport, getDepExport, waitForDepExport, getDepExportFile, createDepHandoverLink, revokeDepHandoverLink, DepExportTimeoutError, DepExportChecksumError, DEP_EXPORT_STATUSES, DEP_EXPORT_FILES, DEP_EXPORT_ERROR_CODES, DEP_EXPORT_FAILURES, DEP_EXPORT_POLL_START_MS, DEP_EXPORT_POLL_FACTOR, DEP_EXPORT_POLL_MAX_MS, DEP_EXPORT_WAIT_TIMEOUT_MS, DEP_EXPORT_DOWNLOAD_TIMEOUT_MS, type DepExportStatus, type DepExportFileKind, type DepExportErrorCode, type DepExportFailure, type CreateDepExportOptions, type CreateDepExportResult, type DepExportGap, type DepExportChainBreak, type DepExportFindings, type DepExportItems, type DepHandoverLinkInfo, type DepExport, type WaitForDepExportOptions, type GetDepExportFileOptions, type DepExportFile, type DepHandoverLink, type RevokedDepHandoverLink, registerTerminalDevice, getTerminalAccess, claimTerminal, requestTerminalCode, getTerminalCode, reportTerminalLogin, reportTerminalReady, TERMINAL_PLATFORMS, TERMINAL_SETUP_STATES, TERMINAL_CODE_STATUSES, TERMINAL_CODE_SOURCES, TERMINAL_ERROR_CODES, TERMINAL_LABEL_MAX, TERMINAL_APP_MAX, TERMINAL_REQUESTED_BY_MAX, type TerminalPlatform, type TerminalSetupState, type TerminalCodeStatus, type TerminalCodeSource, type TerminalErrorCode, type TerminalDeviceCredentials, type RegisterTerminalDeviceOptions, type RegisteredTerminalDevice, type GetTerminalAccessOptions, type ClaimTerminalOptions, type RequestTerminalCodeOptions, type ReportTerminalLoginOptions, type TerminalSetup, type TerminalCodeFormat, type TerminalAccess, type TerminalListEntry, type TerminalAccessUnavailable, type TerminalAccessResult, type TerminalCodeRequest, type TerminalCode, type ListedFullReceipt, type ListReceiptsHeader, type CashboxStatus, type SignatureStatus, getCashboxStatus, getSignatureStatus, type KasseneckApi, createKasseneckApi, } from './client/index.js';
4
4
  export { type ReceiptDueTip, type ReceiptDueTipRecipient, type ReceiptDueOptions, type ReceiptDueBuckets, type ReceiptDueBreakdown, type ReceiptDueErrorReason, receiptDueCents, receiptDueBreakdown, ReceiptDueError, RECEIPT_DUE_ERROR_REASONS, isReceiptDueError, type VoucherDueInfo, type VoucherDueArticle, type VoucherDueType, type VoucherRedeemContext, voucherRedeemMaxCents, VOUCHER_ZERO_RATE_BUCKET_FROM, } from './receipt/due.js';
5
5
  export { parseServerTimeStamp, toViennaWallClock, type ViennaWallClock } from './vienna-time.js';
6
6
  export { type PosBusinessSettings, type PosDeviceSettings, type PosSettings, type ArticleGroup, type PosArticle, POS_BUSINESS_DEFAULTS, POS_DEVICE_DEFAULTS, mergePosSettings, fromArticleGroupPayload, fromPosArticlePayload, listMyArticleGroups, listMyArticles, getPosSettings, setMyPosSettings, setMyRegisterDeviceSettings, distributeDiscount, cancelScopeOf, receiptsScopeOf, stockViewOf, voucherPermsOf, } from './pos/index.js';
package/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export { ReceiptType, VatRate, KeckPaymentMethod, CreditCardProvider, VoucherType, VoucherAction, StripeLinkMode, } from './enums/index.js';
2
2
  export { toReceiptItemPayload, fromReceiptItemPayload, receiptItemTotalCents, receiptItemIsValid, negateReceiptItem, isTipItem, isVoucherItem, isVoucherFloatItem, toVoucherPayload, fromVoucherPayload, voucherIsValid, toReceiptPayload, fromReceiptPayload, receiptSubSumCents, receiptSumCents, receiptValueVoucherSign, RETURN_DISPOSITIONS, CANCELLATION_REASONS, CANCELLATION_STATUSES, CANCELLATION_ERROR_CODES, CANCELLATION_RESERVATION_MS, isCancellationReason, isReturnDisposition, isCancellationErrorCode, cancellationErrorCode, isCancellationError, cancellationFieldErrors, fromReceiptPaymentPayload, toReceiptPaymentPayload, PAYMENT_ERROR_CODES, isPaymentErrorCode, paymentErrorCode, isPaymentError, paymentFieldErrors, RECEIPT_EMAIL_ERROR_CODES, RECEIPT_EMAIL_SEND_ERROR_CODES, RECEIPT_EMAIL_VIAS, isReceiptEmailErrorCode, receiptEmailErrorCode, isReceiptEmailError, receiptEmailFieldErrors, RECEIPT_OUTPUT_KINDS, RECEIPT_OUTPUT_LOG_KINDS, RECEIPT_OUTPUT_RESULTS, RECEIPT_OUTPUT_ENTRIES_MAX, RECEIPT_OUTPUT_ENTRY_ERROR_CODES, RECEIPT_OUTPUT_ERROR_CODES, isReceiptOutputErrorCode, receiptOutputErrorCode, isReceiptOutputError, receiptOutputFieldErrors, RECEIPT_ERROR_CODES, isReceiptErrorCode, receiptErrorCode, isReceiptError, receiptFieldErrors, remainingQuantities, TIP_REFUND_SOURCES, isTipRefundSource, openStaffTipCents, cancellationItemsForTip, cancellationCashRefundCents, asksTipRefundSource, asksRefundTip, fromReceiptCompanyPayload, receiptCompanyTaxInfo, fromCashregisterPayload, fromReceiptSummaryPayload, ZERO_KINDS, isZeroKind, reportMonthFromDate, previousReportMonth, nextReportMonth, reportMonthKey, reportMonthReadable, toStripeUrlSessionPayload, fromStripeUrlSessionPayload, toHobexReceiptPayload, fromHobexReceiptPayload, hobexReceiptToCardPaymentData, hobexReceiptNeedsSignature, } from './models/index.js';
3
- export { apiKeyAuth, registerUserAuth, DEFAULT_BASE_URL, POS_BASE_URL, DEFAULT_TIMEOUT_MS, ALL_CALLS, PUBLIC_CALLS, POS_CALLS, UNKNOWN_OUTCOME_CALLS, createTransport, createBinaryTransport, createPdfOrDataTransport, createFileOrDataTransport, KasseneckApiError, KasseneckAuthError, KasseneckHttpError, KasseneckNetworkError, KasseneckValidationError, CLIENT_ERROR_CODES, isKasseneckApiError, isKasseneckAuthError, isKasseneckHttpError, isKasseneckNetworkError, isKasseneckValidationError, isOutcomeUnknown, sellReceipt, sellReceiptWithCompany, paymentsExpectedCents, cardRefundReference, receiptLayoutFromResult, cancelReceipt, zeroReceipt, getReceipt, getReceiptWithCompany, generateFullReceiptId, getFirstReceiptDate, listMyReceipts, listMyCashregisters, checkVoucherCombinationError, sendReceiptEmail, logReceiptOutputs, downloadDailyReport, downloadMonthlyReport, getCashregisterReport, getReportV2, listReceipts, listAllReceipts, fromListReceiptsSummaryPayload, listedReceiptWithCompany, LIST_RECEIPTS_VIEWS, LIST_RECEIPTS_ORDERS, LIST_RECEIPTS_LIMIT_MAX, LIST_RECEIPTS_DAYS_MAX, LIST_ALL_RECEIPTS_MAX_PAGES, LIST_RECEIPTS_ERROR_CODES, createDepExport, getDepExport, waitForDepExport, getDepExportFile, createDepHandoverLink, revokeDepHandoverLink, DepExportTimeoutError, DepExportChecksumError, DEP_EXPORT_STATUSES, DEP_EXPORT_FILES, DEP_EXPORT_ERROR_CODES, DEP_EXPORT_FAILURES, DEP_EXPORT_POLL_START_MS, DEP_EXPORT_POLL_FACTOR, DEP_EXPORT_POLL_MAX_MS, DEP_EXPORT_WAIT_TIMEOUT_MS, DEP_EXPORT_DOWNLOAD_TIMEOUT_MS, getCashboxStatus, getSignatureStatus, createKasseneckApi, } from './client/index.js';
3
+ export { apiKeyAuth, registerUserAuth, DEFAULT_BASE_URL, POS_BASE_URL, DEFAULT_TIMEOUT_MS, ALL_CALLS, PUBLIC_CALLS, POS_CALLS, UNKNOWN_OUTCOME_CALLS, createTransport, createBinaryTransport, createPdfOrDataTransport, createFileOrDataTransport, KasseneckApiError, KasseneckAuthError, KasseneckHttpError, KasseneckNetworkError, KasseneckValidationError, CLIENT_ERROR_CODES, isKasseneckApiError, isKasseneckAuthError, isKasseneckHttpError, isKasseneckNetworkError, isKasseneckValidationError, isOutcomeUnknown, sellReceipt, sellReceiptWithCompany, paymentsExpectedCents, cardRefundReference, receiptLayoutFromResult, cancelReceipt, zeroReceipt, getReceipt, getReceiptWithCompany, generateFullReceiptId, getFirstReceiptDate, listMyReceipts, listMyCashregisters, checkVoucherCombinationError, sendReceiptEmail, logReceiptOutputs, downloadDailyReport, downloadMonthlyReport, getCashregisterReport, getReportV2, listReceipts, listAllReceipts, fromListReceiptsSummaryPayload, listedReceiptWithCompany, LIST_RECEIPTS_VIEWS, LIST_RECEIPTS_ORDERS, LIST_RECEIPTS_LIMIT_MAX, LIST_RECEIPTS_DAYS_MAX, LIST_ALL_RECEIPTS_MAX_PAGES, LIST_RECEIPTS_ERROR_CODES, createDepExport, getDepExport, waitForDepExport, getDepExportFile, createDepHandoverLink, revokeDepHandoverLink, DepExportTimeoutError, DepExportChecksumError, DEP_EXPORT_STATUSES, DEP_EXPORT_FILES, DEP_EXPORT_ERROR_CODES, DEP_EXPORT_FAILURES, DEP_EXPORT_POLL_START_MS, DEP_EXPORT_POLL_FACTOR, DEP_EXPORT_POLL_MAX_MS, DEP_EXPORT_WAIT_TIMEOUT_MS, DEP_EXPORT_DOWNLOAD_TIMEOUT_MS, registerTerminalDevice, getTerminalAccess, claimTerminal, requestTerminalCode, getTerminalCode, reportTerminalLogin, reportTerminalReady, TERMINAL_PLATFORMS, TERMINAL_SETUP_STATES, TERMINAL_CODE_STATUSES, TERMINAL_CODE_SOURCES, TERMINAL_ERROR_CODES, TERMINAL_LABEL_MAX, TERMINAL_APP_MAX, TERMINAL_REQUESTED_BY_MAX, getCashboxStatus, getSignatureStatus, createKasseneckApi, } from './client/index.js';
4
4
  export { receiptDueCents, receiptDueBreakdown, ReceiptDueError, RECEIPT_DUE_ERROR_REASONS, isReceiptDueError, voucherRedeemMaxCents, VOUCHER_ZERO_RATE_BUCKET_FROM, } from './receipt/due.js';
5
5
  export { parseServerTimeStamp, toViennaWallClock } from './vienna-time.js';
6
6
  export { POS_BUSINESS_DEFAULTS, POS_DEVICE_DEFAULTS, mergePosSettings, fromArticleGroupPayload, fromPosArticlePayload, listMyArticleGroups, listMyArticles, getPosSettings, setMyPosSettings, setMyRegisterDeviceSettings, distributeDiscount, cancelScopeOf, receiptsScopeOf, stockViewOf, voucherPermsOf, } from './pos/index.js';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Aufrunden-Vorschlaege fuer Trinkgeld: genau drei aufsteigende Gesamtbetraege
3
+ * in Cent ueber dem Bezugsbetrag. Nur Ganzzahlen; die Pruefaelle stehen in
4
+ * `fixtures/tip-round-up-cases.json` (gleich im Dart-Zwilling).
5
+ */
6
+ export declare function roundUpSuggestions(amountCents: number): number[];
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Aufrunden-Vorschlaege fuer Trinkgeld: genau drei aufsteigende Gesamtbetraege
3
+ * in Cent ueber dem Bezugsbetrag. Nur Ganzzahlen; die Pruefaelle stehen in
4
+ * `fixtures/tip-round-up-cases.json` (gleich im Dart-Zwilling).
5
+ */
6
+ function steps(t) {
7
+ if (t < 1500)
8
+ return [50, 100];
9
+ if (t < 5000)
10
+ return [100, 500];
11
+ if (t < 20000)
12
+ return [500, 1000];
13
+ return [1000, 5000];
14
+ }
15
+ const ceilDiv = (a, b) => Math.floor((a + b - 1) / b);
16
+ export function roundUpSuggestions(amountCents) {
17
+ if (!Number.isInteger(amountCents) || amountCents <= 0)
18
+ return [];
19
+ const t = amountCents;
20
+ const [small, large] = steps(t);
21
+ const lo = Math.max(ceilDiv(t * 102, 100), t + 20);
22
+ const hi = Math.floor((t * (t < 1000 ? 125 : 120)) / 100);
23
+ const set = new Set();
24
+ for (const s of [small, large])
25
+ for (let m = ceilDiv(lo, s) * s; m <= hi; m += s)
26
+ set.add(m);
27
+ const candidates = [...set].sort((a, b) => a - b);
28
+ const chosen = new Set();
29
+ if (candidates.length > 0) {
30
+ const firstRound = candidates.find((k) => k % large === 0);
31
+ chosen.add(firstRound !== undefined && (firstRound - t) * 100 <= t * 10 ? firstRound : candidates[0]);
32
+ }
33
+ for (const target of [110, 115]) {
34
+ const free = candidates.filter((k) => !chosen.has(k));
35
+ if (free.length === 0)
36
+ break;
37
+ const dist = (k) => Math.abs(k * 100 - t * target);
38
+ const round = free.find((k) => k % large === 0 && dist(k) <= t * 3);
39
+ if (round !== undefined) {
40
+ chosen.add(round);
41
+ continue;
42
+ }
43
+ let best = free[0];
44
+ for (const k of free)
45
+ if (dist(k) < dist(best))
46
+ best = k;
47
+ chosen.add(best);
48
+ }
49
+ let next = chosen.size > 0 ? Math.max(...chosen) : ceilDiv(lo, small) * small - small;
50
+ while (chosen.size < 3) {
51
+ next = (Math.floor(next / small) + 1) * small;
52
+ if (next >= lo)
53
+ chosen.add(next);
54
+ }
55
+ return [...chosen].sort((a, b) => a - b);
56
+ }
@@ -1,6 +1,6 @@
1
1
  import { KasseneckValidationError } from '../client/errors.js';
2
2
  import { posVoucherSettingsFromWire } from './gutschein.js';
3
- import { POS_BUSINESS_DEFAULTS, POS_DEVICE_DEFAULTS, POS_BUSINESS_VALUES, POS_DEVICE_VALUES, POS_SHORTCUT_ACTIONS, POS_DEVICE_OPTIONAL_FIELDS, POS_BUSINESS_OPTIONAL_FIELDS, mergePosSettings, posShortcutConflict, _istAltwert0x, _optionalerWert, } from './settings.js';
3
+ import { POS_BUSINESS_DEFAULTS, POS_DEVICE_DEFAULTS, POS_BUSINESS_VALUES, POS_DEVICE_VALUES, POS_SHORTCUT_ACTIONS, POS_DEVICE_OPTIONAL_FIELDS, POS_BUSINESS_OPTIONAL_FIELDS, POS_BUSINESS_OPTIONAL_CHOICES, POS_DEVICE_OPTIONAL_CHOICES, mergePosSettings, posShortcutConflict, _istAltwert0x, _optionalerWert, } from './settings.js';
4
4
  /*
5
5
  * Die Einstellungs-Aufrufe am Draht `/api/v3`: Parameter und Antwort heissen
6
6
  * `business`/`device`, Schluessel und Werte englisch (Nachtrag §11.7.2).
@@ -144,10 +144,21 @@ function pruefeTeil(name, teil, block, standard, werte) {
144
144
  throw new KasseneckValidationError(name, `${teil}.${schluessel}: true oder false erwartet`, 'request');
145
145
  continue;
146
146
  }
147
- if (!Object.prototype.hasOwnProperty.call(standard, schluessel)) {
147
+ const wahl = teil === 'business' ? POS_BUSINESS_OPTIONAL_CHOICES : POS_DEVICE_OPTIONAL_CHOICES;
148
+ if (!Object.prototype.hasOwnProperty.call(standard, schluessel) && !wahl.includes(schluessel)) {
148
149
  throw new KasseneckValidationError(name, `${teil}.${schluessel}: unbekanntes Feld`, 'request');
149
150
  }
150
151
  const erlaubt = Object.prototype.hasOwnProperty.call(werte, schluessel) ? werte[schluessel] : undefined;
152
+ if (schluessel === 'tipKinds' && !Array.isArray(wert)) {
153
+ throw new KasseneckValidationError(name, `${teil}.${schluessel}: eine Liste von Trinkgeld-Arten erwartet`, 'request');
154
+ }
155
+ // Eine Liste (tipKinds): nichtleer, jeder Eintrag aus der Wertemenge, ohne Dubletten.
156
+ if (erlaubt && Array.isArray(wert)) {
157
+ if (wert.length === 0 || new Set(wert).size !== wert.length || !wert.every((e) => erlaubt.includes(e))) {
158
+ throw new KasseneckValidationError(name, `${teil}.${schluessel}: ungueltiger Wert (erlaubt: ${erlaubt.join(', ')}, jede Art hoechstens einmal)`, 'request');
159
+ }
160
+ continue;
161
+ }
151
162
  if (erlaubt && !erlaubt.includes(wert)) {
152
163
  // Kein Altwert: dann ein Wert, den der Server kennt und dieses Paket
153
164
  // nicht. Er kam beim Lesen herein; wer den ganzen Block zurueckschickt,
@@ -6,7 +6,7 @@
6
6
  * die Backend-Functions (die Rewrites-Waechter der Web-App leiten daraus ab)
7
7
  * und sprechen den Kassenweg `/api/v3` (Schluessel und Werte englisch).
8
8
  */
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';
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, POS_BUSINESS_OPTIONAL_CHOICES, POS_DEVICE_OPTIONAL_CHOICES, posTipKeptByDefault, posTipKinds, posTipStart, posCartWidth, POS_BUSINESS_VALUES, POS_DEVICE_VALUES, mergePosSettings, sanitizePosSettings, unknownPosSettingValues, posSettingsChanges, type PosOpen, POS_SHORTCUT_SHARED_PAIRS, posShortcutConflict, THEME, FONT_SIZE, WATERMARK, QUANTITY, TIP_MODE, TIP_KINDS, TIP_START, CART_WIDTH, type PosTipKind, type PosCartWidth, 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
12
  export { ADD_ONS_MAX, ADD_ON_BLOCK_REASONS, type AddOnBlockReason, isSelectableAddOn, addOnsFor, addOnReferencesValid, addOnsOfItem, addOnRemap, addOnDisplayOrder, orderAddOnLines, } from './zusaetze.js';
@@ -24,9 +24,10 @@ export { type ListMyStocktakesOptions, type ListMyStocktakeItemsOptions, type Li
24
24
  export type { Stocktake, StocktakeItem, StocktakeCount, StocktakeCountResult, StocktakeItemPage, StocktakeCountPage, StocktakeActor, StocktakeProgress, StocktakeReview, StocktakeRecount, StocktakeScope, } from '../inventory/typen.js';
25
25
  export type { StocktakeStatus } from '../inventory/vertrag.js';
26
26
  export { VOUCHER_KINDS, VOUCHER_STATUSES, checkVoucher, reprintVoucherLabel, VOUCHER_SETTINGS_DEFAULTS, posVoucherSettingsFromWire, VOUCHER_PAYOUTS, VOUCHER_TYPE_KINDS, VOUCHER_AMOUNT_MODES, VOUCHER_TYPE_VALIDITY_PATTERNS, type VoucherKind, type VoucherStatus, type VoucherValidity, type VoucherArticle, type VoucherCheck, type PosVoucherSettings, type PosVoucherReturnType, type VoucherPayout, type VoucherTypeKind, type PosVoucherType, type VoucherLabelTemplate, } from './gutschein.js';
27
- export { type GetMyDrawerStateOptions, type OpenMyShiftOptions, type RecordMyCashMovementOptions, type DrawerOpeningEntry, type LogMyDrawerOpeningsOptions, type GetMyShiftReportOptions, type TipPayout, type CloseMyShiftOptions, type AfterCountOption, getMyDrawerState, openMyShift, recordMyCashMovement, logMyDrawerOpenings, getMyShiftReport, closeMyShift, sumDenominations, parseCentsAllowZero, newIdempotencyKey, shiftTipLines, durationText, type ShiftTipLine, type ShiftTipLineKey, } from './schicht.js';
28
- export { EUR_DENOMINATIONS, MOVEMENT_TYPES, MANUAL_MOVEMENT_TYPES, CASH_LOCATIONS, OPENING_REASONS, MANUAL_OPENING_REASONS, SHIFT_RECEIPT_KINDS, AFTER_COUNT_TYPES, type AfterCountType, type AfterCount, type EurDenomination, type MovementType, type ManualMovementType, type CashLocation, type OpeningReason, type ManualOpeningReason, type ShiftReceiptKind, type ShiftStatus, type ShiftActorRole, type Denominations, type ShiftActor, type DrawerInfo, type DrawerRights, type NonCashAmount, type ShiftTipTotals, type ShiftTip, type ShiftRunningTotals, type ShiftReconciliation, type Shift, type TipClaim, type DrawerOpening, type DrawerState, type CashMovement, type ShiftReceiptHeader, type ShiftReceiptMovement, type ShiftReceiptTip, type ShiftSummaryReceipt, type CashMovementReceipt, type ShiftReceipt, type OpenShiftResult, type CashMovementResult, type DrawerOpeningsResult, type ShiftReport, type CloseShiftResult, } from './schicht-typen.js';
27
+ export { type GetMyDrawerStateOptions, type OpenMyShiftOptions, type RecordMyCashMovementOptions, type DrawerOpeningEntry, type LogMyDrawerOpeningsOptions, type GetMyShiftReportOptions, type TipPayout, type CloseMyShiftOptions, type AfterCountOption, type RecordMyShiftCountOptions, getMyDrawerState, openMyShift, recordMyCashMovement, logMyDrawerOpenings, getMyShiftReport, closeMyShift, recordMyShiftCount, sumDenominations, parseCentsAllowZero, newIdempotencyKey, shiftTipLines, durationText, type ShiftTipLine, type ShiftTipLineKey, } from './schicht.js';
28
+ export { EUR_DENOMINATIONS, MOVEMENT_TYPES, MANUAL_MOVEMENT_TYPES, CASH_LOCATIONS, OPENING_REASONS, MANUAL_OPENING_REASONS, SHIFT_RECEIPT_KINDS, AFTER_COUNT_TYPES, type AfterCountType, type AfterCount, EXPECTED_PART_KEYS, DIFFERENCE_PART_TYPES, type ExpectedPartKey, type ShiftExpectedPart, type DifferencePartType, type ShiftDifferencePart, type LastShift, type ShiftCountResult, type EurDenomination, type MovementType, type ManualMovementType, type CashLocation, type OpeningReason, type ManualOpeningReason, type ShiftReceiptKind, type ShiftStatus, type ShiftActorRole, type Denominations, type ShiftActor, type DrawerInfo, type DrawerRights, type NonCashAmount, type ShiftTipTotals, type ShiftTip, type ShiftOwnerTip, type ShiftRunningTotals, type ShiftReconciliation, type Shift, type TipClaim, type DrawerOpening, type DrawerState, type CashMovement, type ShiftReceiptHeader, type ShiftReceiptMovement, type ShiftReceiptTip, type ShiftSummaryReceipt, type CashMovementReceipt, type ShiftReceipt, type OpenShiftResult, type CashMovementResult, type DrawerOpeningsResult, type ShiftReport, type CloseShiftResult, } from './schicht-typen.js';
29
29
  export { type ShiftReceiptLayoutOptions, shiftReceiptLayout, cashMovementLayout } from '../receipt/shift-sheet.js';
30
30
  export { RECEIPT_OUTPUT_KINDS, RECEIPT_OUTPUT_RESULTS, type ReceiptOutputKind, type ReceiptOutputResult } from '../models/receipt-output.js';
31
31
  export { RETURN_DISPOSITIONS, isReturnDisposition, type ReturnDisposition } from '../models/cancellation.js';
32
32
  export { MESSAGES, ERROR_RULES, ERROR_CODE_RULES, ERROR_OUTCOME_RULES, CALLS_WITH_EFFECT, findErrorRule, messageOutcome, messageText, messageAppliesTo, RECEIPT_EMAIL_ERROR_MESSAGES, receiptEmailErrorMessage, CANCELLATION_PAYMENT_ERROR_MESSAGES, cancellationPaymentErrorMessage, CANCELLATION_VOUCHER_ERROR_MESSAGES, cancellationErrorMessage, VOUCHER_ERROR_MESSAGES, voucherErrorMessage, LABELS, labelText, RETURN_DISPOSITION_LABELS, receiptOutputLabel, type TextEntry, type MessageKey, type ErrorKind, type ErrorRule, type ErrorRuleDetail, type Surface, type ReceiptEmailMessageCode, type CancellationPaymentMessageCode, type LabelKey, } from './texte.js';
33
+ export { roundUpSuggestions } from './aufrunden.js';
@@ -6,9 +6,9 @@
6
6
  * die Backend-Functions (die Rewrites-Waechter der Web-App leiten daraus ab)
7
7
  * und sprechen den Kassenweg `/api/v3` (Schluessel und Werte englisch).
8
8
  */
9
- export { POS_SHORTCUT_ACTIONS, POS_SHORTCUT_DEFAULTS, 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, POS_SHORTCUT_SHARED_PAIRS, posShortcutConflict,
9
+ export { POS_SHORTCUT_ACTIONS, POS_SHORTCUT_DEFAULTS, POS_BUSINESS_DEFAULTS, POS_DEVICE_DEFAULTS, POS_DEVICE_OPTIONAL_FIELDS, POS_BUSINESS_OPTIONAL_FIELDS, POS_BUSINESS_OPTIONAL_CHOICES, POS_DEVICE_OPTIONAL_CHOICES, posTipKeptByDefault, posTipKinds, posTipStart, posCartWidth, POS_BUSINESS_VALUES, POS_DEVICE_VALUES, mergePosSettings, sanitizePosSettings, unknownPosSettingValues, posSettingsChanges, POS_SHORTCUT_SHARED_PAIRS, posShortcutConflict,
10
10
  // Die Enums als Laufzeitlisten, benannt nach ihrem Feld.
11
- 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';
11
+ THEME, FONT_SIZE, WATERMARK, QUANTITY, TIP_MODE, TIP_KINDS, TIP_START, CART_WIDTH, 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';
12
12
  export { fromArticleGroupPayload, fromPosArticlePayload, listMyArticleGroups, listMyArticles, QUANTITY_RULES, quantityRuleForUnit, quantityDefaults, allowedQuantity, isBookableArticle, tilePrompts, } from './artikel.js';
13
13
  export { REFERENCE_MODES, REFERENCE_INPUT_MAX, REFERENCE_LABEL_MAX, REFERENCE_HINT_MAX, REFERENCE_PATTERN_MAX, REFERENCE_PATTERN_TEMPLATES, cleanReferenceText, isValidReferencePattern, isDigitsOnlyPattern, checkReference, referenceLineName, fromReferencePayload, } from './kachel-referenz.js';
14
14
  export { ADD_ONS_MAX, ADD_ON_BLOCK_REASONS, isSelectableAddOn, addOnsFor, addOnReferencesValid, addOnsOfItem, addOnRemap, addOnDisplayOrder, orderAddOnLines, } from './zusaetze.js';
@@ -31,8 +31,8 @@ export { listMyStocktakes, listMyStocktakeItems, listMyStocktakeCounts, recordMy
31
31
  // Gutschein pruefen und Etikett nachdrucken an der Kasse; Gutschein-Sorten (Stufe 4b, 1.17.0).
32
32
  export { VOUCHER_KINDS, VOUCHER_STATUSES, checkVoucher, reprintVoucherLabel, VOUCHER_SETTINGS_DEFAULTS, posVoucherSettingsFromWire, VOUCHER_PAYOUTS, VOUCHER_TYPE_KINDS, VOUCHER_AMOUNT_MODES, VOUCHER_TYPE_VALIDITY_PATTERNS, } from './gutschein.js';
33
33
  // Schicht, Kassenstand und Lade-Protokoll (1.9.0): Aufrufe, Kataloge, Helfer, Bons.
34
- export { getMyDrawerState, openMyShift, recordMyCashMovement, logMyDrawerOpenings, getMyShiftReport, closeMyShift, sumDenominations, parseCentsAllowZero, newIdempotencyKey, shiftTipLines, durationText, } from './schicht.js';
35
- export { EUR_DENOMINATIONS, MOVEMENT_TYPES, MANUAL_MOVEMENT_TYPES, CASH_LOCATIONS, OPENING_REASONS, MANUAL_OPENING_REASONS, SHIFT_RECEIPT_KINDS, AFTER_COUNT_TYPES, } from './schicht-typen.js';
34
+ export { getMyDrawerState, openMyShift, recordMyCashMovement, logMyDrawerOpenings, getMyShiftReport, closeMyShift, recordMyShiftCount, sumDenominations, parseCentsAllowZero, newIdempotencyKey, shiftTipLines, durationText, } from './schicht.js';
35
+ export { EUR_DENOMINATIONS, MOVEMENT_TYPES, MANUAL_MOVEMENT_TYPES, CASH_LOCATIONS, OPENING_REASONS, MANUAL_OPENING_REASONS, SHIFT_RECEIPT_KINDS, AFTER_COUNT_TYPES, EXPECTED_PART_KEYS, DIFFERENCE_PART_TYPES, } from './schicht-typen.js';
36
36
  export { shiftReceiptLayout, cashMovementLayout } from '../receipt/shift-sheet.js';
37
37
  // Ausgaben eines Belegs (Belegdetail: Art und Ergebnis -> Beschriftung); dieselben Listen wie an der Wurzel.
38
38
  export { RECEIPT_OUTPUT_KINDS, RECEIPT_OUTPUT_RESULTS } from '../models/receipt-output.js';
@@ -40,3 +40,4 @@ export { RECEIPT_OUTPUT_KINDS, RECEIPT_OUTPUT_RESULTS } from '../models/receipt-
40
40
  export { RETURN_DISPOSITIONS, isReturnDisposition } from '../models/cancellation.js';
41
41
  // Was die Kasse selbst sagt: ein Katalog fuer Browser-Kasse und App.
42
42
  export { MESSAGES, ERROR_RULES, ERROR_CODE_RULES, ERROR_OUTCOME_RULES, CALLS_WITH_EFFECT, findErrorRule, messageOutcome, messageText, messageAppliesTo, RECEIPT_EMAIL_ERROR_MESSAGES, receiptEmailErrorMessage, CANCELLATION_PAYMENT_ERROR_MESSAGES, cancellationPaymentErrorMessage, CANCELLATION_VOUCHER_ERROR_MESSAGES, cancellationErrorMessage, VOUCHER_ERROR_MESSAGES, voucherErrorMessage, LABELS, labelText, RETURN_DISPOSITION_LABELS, receiptOutputLabel, } from './texte.js';
43
+ export { roundUpSuggestions } from './aufrunden.js';
@@ -12,7 +12,7 @@
12
12
  * stehen im Modell genau dann, wenn der Server sie sendet.
13
13
  */
14
14
  import { type ValidationScope } from '../client/errors.js';
15
- import type { CashMovement, CashMovementReceipt, CashMovementResult, DrawerOpeningsResult, OpenShiftResult, ShiftReport, CloseShiftResult, DrawerState, Shift, ShiftSummaryReceipt } from './schicht-typen.js';
15
+ import type { CashMovement, CashMovementReceipt, CashMovementResult, DrawerOpeningsResult, OpenShiftResult, ShiftReport, CloseShiftResult, ShiftCountResult, DrawerState, Shift, ShiftSummaryReceipt } from './schicht-typen.js';
16
16
  type Roh = Record<string, unknown>;
17
17
  /** Wer liest (fuer die Meldung) und wo im Rumpf. */
18
18
  export interface Ort {
@@ -33,6 +33,7 @@ export declare function schichtBon(ort: Ort, w: unknown): ShiftSummaryReceipt;
33
33
  export declare function bewegungsBon(ort: Ort, w: unknown): CashMovementReceipt;
34
34
  export declare function abschluss(ort: Ort, w: unknown): CloseShiftResult;
35
35
  export declare function geoeffnet(ort: Ort, w: unknown): OpenShiftResult;
36
+ export declare function gezaehlt(ort: Ort, w: unknown): ShiftCountResult;
36
37
  export declare function gebucht(ort: Ort, w: unknown): CashMovementResult;
37
38
  export declare function gemeldet(ort: Ort, w: unknown): DrawerOpeningsResult;
38
39
  export declare function bericht(ort: Ort, w: unknown): ShiftReport;
@@ -117,7 +117,7 @@ function trinkgeldMitOffen(ort, w) {
117
117
  }
118
118
  function laufstand(ort, w) {
119
119
  const o = pflichtObjekt(ort, w);
120
- return {
120
+ const raus = {
121
121
  cashSalesCents: ganzzahl(ort, o, 'cashSalesCents'),
122
122
  cashCancellationsCents: ganzzahl(ort, o, 'cashCancellationsCents'),
123
123
  nonCashByMethod: liste(ort, o, 'nonCashByMethod', unbar),
@@ -130,6 +130,16 @@ function laufstand(ort, w) {
130
130
  tips: liste(ort, o, 'tips', trinkgeld),
131
131
  openingsWithoutSale: ganzzahl(ort, o, 'openingsWithoutSale'),
132
132
  };
133
+ // Nur Anzeige (1.28.0); der Server sendet beides nur, wenn es etwas gibt -- gelesen wie gesendet.
134
+ if (o.ownerTips !== undefined && o.ownerTips !== null)
135
+ raus.ownerTips = liste(ort, o, 'ownerTips', inhaberTrinkgeld);
136
+ if (o.unassignedTipCents !== undefined && o.unassignedTipCents !== null)
137
+ raus.unassignedTipCents = ganzzahl(ort, o, 'unassignedTipCents');
138
+ return raus;
139
+ }
140
+ function inhaberTrinkgeld(ort, w) {
141
+ const o = pflichtObjekt(ort, w);
142
+ return { registerUserId: kennung(ort, o, 'registerUserId'), name: text(o.name), cents: ganzzahl(ort, o, 'cents') };
133
143
  }
134
144
  /** Entnehmen oder Einlegen nach dem Zaehlen; die Art bleibt offen fuer kuenftige Werte (Text). */
135
145
  function nachZaehlung(ort, w) {
@@ -152,6 +162,14 @@ function abgleich(ort, w) {
152
162
  }
153
163
  return { matches: wahr(ort, o, 'matches'), deviations };
154
164
  }
165
+ function sollTeil(ort, w) {
166
+ const o = pflichtObjekt(ort, w);
167
+ return { key: kennung(ort, o, 'key'), cents: ganzzahl(ort, o, 'cents') };
168
+ }
169
+ function differenzTeil(ort, w) {
170
+ const o = pflichtObjekt(ort, w);
171
+ return { type: kennung(ort, o, 'type'), cents: ganzzahl(ort, o, 'cents'), at: text(o.at) };
172
+ }
155
173
  /** Eine Schicht; was nur mit `cashView` kommt, steht nur, wenn gesendet. */
156
174
  export function schicht(ort, w) {
157
175
  const o = pflichtObjekt(ort, w);
@@ -187,6 +205,14 @@ export function schicht(ort, w) {
187
205
  // Nur wenn beim Abschluss Geld entnommen oder eingelegt wurde.
188
206
  wennWert(r, o, 'afterCount', () => nachZaehlung(unter(ort, 'afterCount'), o.afterCount));
189
207
  wennWert(r, o, 'leftInDrawerCents', () => ganzzahl(ort, o, 'leftInDrawerCents'));
208
+ // Ablauf der Kasse: nur, wenn der Server sie sendet.
209
+ wennWert(r, o, 'openingCounted', () => wahr(ort, o, 'openingCounted'));
210
+ wennWert(r, o, 'expectedParts', () => liste(ort, o, 'expectedParts', sollTeil));
211
+ wennWert(r, o, 'cashTipsInDrawerCents', () => ganzzahl(ort, o, 'cashTipsInDrawerCents'));
212
+ wennWert(r, o, 'interimCounts', () => ganzzahl(ort, o, 'interimCounts'));
213
+ wennWert(r, o, 'interimDifferenceCents', () => ganzzahl(ort, o, 'interimDifferenceCents'));
214
+ wennWert(r, o, 'differenceParts', () => liste(ort, o, 'differenceParts', differenzTeil));
215
+ wennWert(r, o, 'countedBeforePayoutCents', () => ganzzahl(ort, o, 'countedBeforePayoutCents'));
190
216
  return raus;
191
217
  }
192
218
  function schichtOderNull(ort, w) {
@@ -207,6 +233,12 @@ function oeffnung(ort, w) {
207
233
  ok: wahr(ort, o, 'ok'),
208
234
  };
209
235
  }
236
+ function letzteSchicht(ort, w) {
237
+ if (w === null)
238
+ return null;
239
+ const o = pflichtObjekt(ort, w);
240
+ return { number: ganzzahl(ort, o, 'number'), closedAt: kennung(ort, o, 'closedAt'), closedByName: text(o.closedByName) };
241
+ }
210
242
  export function ladeStand(ort, w) {
211
243
  const o = pflichtObjekt(ort, w);
212
244
  const lade = pflichtObjekt(unter(ort, 'drawer'), o.drawer);
@@ -236,6 +268,8 @@ export function ladeStand(ort, w) {
236
268
  wennDa(r, o, 'expectedCents', () => ganzzahlOderNull(ort, o, 'expectedCents'));
237
269
  wennDa(r, o, 'recentOpenings', () => liste(ort, o, 'recentOpenings', oeffnung));
238
270
  wennWert(r, o, 'suggestedFromShiftNumber', () => ganzzahl(ort, o, 'suggestedFromShiftNumber'));
271
+ // Letzte Schicht der Lade: `null` ist eine Aussage („keine“), darum bleibt es stehen.
272
+ wennDa(r, o, 'lastShift', () => (o.lastShift === undefined ? null : letzteSchicht(unter(ort, 'lastShift'), o.lastShift)));
239
273
  // Wechselgeld der Lade: nur wenn eingestellt.
240
274
  wennWert(raus.drawer, lade, 'changeFloatCents', () => ganzzahl(ladeOrt, lade, 'changeFloatCents'));
241
275
  return raus;
@@ -322,6 +356,12 @@ export function schichtBon(ort, w) {
322
356
  const r = raus;
323
357
  wennWert(r, o, 'afterCount', () => nachZaehlung(unter(ort, 'afterCount'), o.afterCount));
324
358
  wennDa(r, o, 'leftInDrawerCents', () => ganzzahlOderNull(ort, o, 'leftInDrawerCents'));
359
+ // Ablauf der Kasse: nur, wenn der Server sie sendet (die Bons davor tragen sie nicht).
360
+ wennWert(r, o, 'openingCounted', () => wahr(ort, o, 'openingCounted'));
361
+ wennWert(r, o, 'interimDifferenceCents', () => ganzzahl(ort, o, 'interimDifferenceCents'));
362
+ wennWert(r, o, 'differenceParts', () => liste(ort, o, 'differenceParts', differenzTeil));
363
+ wennDa(r, o, 'countedBeforePayoutCents', () => ganzzahlOderNull(ort, o, 'countedBeforePayoutCents'));
364
+ wennDa(r, o, 'countedBeforePayoutDenominations', () => stueckelung(ort, o, 'countedBeforePayoutDenominations'));
325
365
  return raus;
326
366
  }
327
367
  /** Bon-Daten einer Kassenbewegung; eine andere Art ist ein Fehler. */
@@ -374,6 +414,12 @@ export function geoeffnet(ort, w) {
374
414
  wennDa(raus, o, 'handoverDifferenceCents', () => ganzzahlOderNull(ort, o, 'handoverDifferenceCents'));
375
415
  return raus;
376
416
  }
417
+ export function gezaehlt(ort, w) {
418
+ const o = pflichtObjekt(ort, w);
419
+ const z = pflichtObjekt(unter(ort, 'count'), o.count);
420
+ const zOrt = unter(ort, 'count');
421
+ return { count: { expectedCents: ganzzahl(zOrt, z, 'expectedCents'), countedCents: ganzzahl(zOrt, z, 'countedCents'), differenceCents: ganzzahl(zOrt, z, 'differenceCents') } };
422
+ }
377
423
  export function gebucht(ort, w) {
378
424
  const o = pflichtObjekt(ort, w);
379
425
  return { movement: bewegung(unter(ort, 'movement'), o.movement), receipt: bewegungsBon(unter(ort, 'receipt'), o.receipt) };