@kreiseck/kasseneck-api 1.10.0 → 1.11.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 (150) hide show
  1. package/CHANGELOG.md +245 -0
  2. package/dist/cjs/client/aufrufe.d.ts +5 -5
  3. package/dist/cjs/client/aufrufe.js +22 -2
  4. package/dist/cjs/client/errors.js +2 -0
  5. package/dist/cjs/client/receipts.d.ts +34 -1
  6. package/dist/cjs/client/receipts.js +34 -1
  7. package/dist/cjs/client/reports.d.ts +4 -4
  8. package/dist/cjs/client/reports.js +4 -4
  9. package/dist/cjs/index.d.ts +1 -1
  10. package/dist/cjs/index.js +9 -2
  11. package/dist/cjs/inventory/vertrag.d.ts +1 -1
  12. package/dist/cjs/inventory/vertrag.js +2 -0
  13. package/dist/cjs/invoice/vertrag.d.ts +1 -1
  14. package/dist/cjs/invoice/vertrag.js +2 -0
  15. package/dist/cjs/models/cancellation.d.ts +49 -1
  16. package/dist/cjs/models/cancellation.js +139 -1
  17. package/dist/cjs/models/index.d.ts +1 -1
  18. package/dist/cjs/models/index.js +9 -2
  19. package/dist/cjs/models/payment-errors.d.ts +1 -1
  20. package/dist/cjs/models/payment-errors.js +2 -0
  21. package/dist/cjs/models/receipt-email.d.ts +1 -1
  22. package/dist/cjs/models/receipt-email.js +2 -0
  23. package/dist/cjs/models/receipt-errors.d.ts +1 -1
  24. package/dist/cjs/models/receipt-errors.js +2 -0
  25. package/dist/cjs/models/receipt-item.d.ts +10 -0
  26. package/dist/cjs/models/receipt-item.js +3 -0
  27. package/dist/cjs/pos/client.js +10 -0
  28. package/dist/cjs/pos/errors.d.ts +4 -3
  29. package/dist/cjs/pos/errors.js +21 -2
  30. package/dist/cjs/pos/index.d.ts +6 -2
  31. package/dist/cjs/pos/index.js +33 -3
  32. package/dist/cjs/pos/schicht-lesen.d.ts +39 -0
  33. package/dist/cjs/pos/schicht-lesen.js +405 -0
  34. package/dist/cjs/pos/schicht-typen.d.ts +380 -0
  35. package/dist/cjs/pos/schicht-typen.js +59 -0
  36. package/dist/cjs/pos/schicht.d.ts +208 -0
  37. package/dist/cjs/pos/schicht.js +235 -0
  38. package/dist/cjs/pos/settings.d.ts +37 -1
  39. package/dist/cjs/pos/settings.js +43 -3
  40. package/dist/cjs/pos/texte.d.ts +627 -0
  41. package/dist/cjs/pos/texte.js +236 -0
  42. package/dist/cjs/react/index.js +1 -1
  43. package/dist/cjs/receipt/grid.js +2 -2
  44. package/dist/cjs/receipt/layout.d.ts +5 -0
  45. package/dist/cjs/receipt/shift-sheet.d.ts +33 -0
  46. package/dist/cjs/receipt/shift-sheet.js +207 -0
  47. package/dist/cjs/register/errors.d.ts +1 -1
  48. package/dist/cjs/register/errors.js +2 -0
  49. package/dist/cjs/stored/draht.d.ts +1 -1
  50. package/dist/cjs/stored/draht.js +4 -3
  51. package/dist/cjs/stored/einstellungen.js +26 -3
  52. package/dist/cjs/stored/vokabular.d.ts +1 -1
  53. package/dist/cjs/stored/vokabular.js +118 -12
  54. package/dist/cjs/version.d.ts +1 -1
  55. package/dist/cjs/version.js +1 -1
  56. package/dist/esm/client/aufrufe.d.ts +5 -5
  57. package/dist/esm/client/aufrufe.js +22 -2
  58. package/dist/esm/client/errors.js +2 -0
  59. package/dist/esm/client/receipts.d.ts +34 -1
  60. package/dist/esm/client/receipts.js +35 -2
  61. package/dist/esm/client/reports.d.ts +4 -4
  62. package/dist/esm/client/reports.js +4 -4
  63. package/dist/esm/index.d.ts +1 -1
  64. package/dist/esm/index.js +1 -1
  65. package/dist/esm/inventory/vertrag.d.ts +1 -1
  66. package/dist/esm/inventory/vertrag.js +2 -0
  67. package/dist/esm/invoice/vertrag.d.ts +1 -1
  68. package/dist/esm/invoice/vertrag.js +2 -0
  69. package/dist/esm/models/cancellation.d.ts +49 -1
  70. package/dist/esm/models/cancellation.js +132 -0
  71. package/dist/esm/models/index.d.ts +1 -1
  72. package/dist/esm/models/index.js +1 -1
  73. package/dist/esm/models/payment-errors.d.ts +1 -1
  74. package/dist/esm/models/payment-errors.js +2 -0
  75. package/dist/esm/models/receipt-email.d.ts +1 -1
  76. package/dist/esm/models/receipt-email.js +2 -0
  77. package/dist/esm/models/receipt-errors.d.ts +1 -1
  78. package/dist/esm/models/receipt-errors.js +2 -0
  79. package/dist/esm/models/receipt-item.d.ts +10 -0
  80. package/dist/esm/models/receipt-item.js +3 -0
  81. package/dist/esm/pos/client.js +11 -1
  82. package/dist/esm/pos/errors.d.ts +4 -3
  83. package/dist/esm/pos/errors.js +21 -2
  84. package/dist/esm/pos/index.d.ts +6 -2
  85. package/dist/esm/pos/index.js +7 -2
  86. package/dist/esm/pos/schicht-lesen.d.ts +39 -0
  87. package/dist/esm/pos/schicht-lesen.js +392 -0
  88. package/dist/esm/pos/schicht-typen.d.ts +380 -0
  89. package/dist/esm/pos/schicht-typen.js +56 -0
  90. package/dist/esm/pos/schicht.d.ts +208 -0
  91. package/dist/esm/pos/schicht.js +222 -0
  92. package/dist/esm/pos/settings.d.ts +37 -1
  93. package/dist/esm/pos/settings.js +40 -2
  94. package/dist/esm/pos/texte.d.ts +627 -0
  95. package/dist/esm/pos/texte.js +236 -0
  96. package/dist/esm/react/index.js +1 -1
  97. package/dist/esm/receipt/grid.js +2 -2
  98. package/dist/esm/receipt/layout.d.ts +5 -0
  99. package/dist/esm/receipt/shift-sheet.d.ts +33 -0
  100. package/dist/esm/receipt/shift-sheet.js +203 -0
  101. package/dist/esm/register/errors.d.ts +1 -1
  102. package/dist/esm/register/errors.js +2 -0
  103. package/dist/esm/stored/draht.d.ts +1 -1
  104. package/dist/esm/stored/draht.js +4 -3
  105. package/dist/esm/stored/einstellungen.js +27 -4
  106. package/dist/esm/stored/vokabular.d.ts +1 -1
  107. package/dist/esm/stored/vokabular.js +118 -12
  108. package/dist/esm/version.d.ts +1 -1
  109. package/dist/esm/version.js +1 -1
  110. package/fixtures/cancellation-tip-cases.json +679 -0
  111. package/fixtures/expected/cash-movement.grid32.txt +15 -0
  112. package/fixtures/expected/cash-movement.grid48.txt +15 -0
  113. package/fixtures/expected/cash-movement.lines.json +171 -0
  114. package/fixtures/expected/shift-close-blind.grid32.txt +28 -0
  115. package/fixtures/expected/shift-close-blind.grid48.txt +27 -0
  116. package/fixtures/expected/shift-close-blind.lines.json +275 -0
  117. package/fixtures/expected/shift-close-put-in.grid32.txt +38 -0
  118. package/fixtures/expected/shift-close-put-in.grid48.txt +35 -0
  119. package/fixtures/expected/shift-close-put-in.lines.json +403 -0
  120. package/fixtures/expected/shift-close-take-out.grid32.txt +38 -0
  121. package/fixtures/expected/shift-close-take-out.grid48.txt +35 -0
  122. package/fixtures/expected/shift-close-take-out.lines.json +403 -0
  123. package/fixtures/expected/shift-close.grid32.txt +37 -0
  124. package/fixtures/expected/shift-close.grid48.txt +35 -0
  125. package/fixtures/expected/shift-close.lines.json +413 -0
  126. package/fixtures/expected/shift-interim.grid32.txt +28 -0
  127. package/fixtures/expected/shift-interim.grid48.txt +27 -0
  128. package/fixtures/expected/shift-interim.lines.json +293 -0
  129. package/fixtures/hobex-hps-codes.json +1 -1
  130. package/fixtures/invoice-api.schema.json +1 -1
  131. package/fixtures/invoice-texts.json +1 -1
  132. package/fixtures/pos-message-cases.json +45 -0
  133. package/fixtures/pos-texts.json +723 -1
  134. package/fixtures/receipt-due-generated.json +1 -1
  135. package/fixtures/shift-cases.json +87 -0
  136. package/fixtures/shift-receipts.json +41 -0
  137. package/fixtures/surface.json +119 -3
  138. package/fixtures/v3/antworten/belege.json +1 -1
  139. package/fixtures/v3/antworten/belegmail.json +1 -1
  140. package/fixtures/v3/antworten/kasse-belege.json +1 -1
  141. package/fixtures/v3/antworten/kasse.json +10874 -4865
  142. package/fixtures/v3/antworten/lager.json +1 -1
  143. package/fixtures/v3/antworten/rechnungen.json +1 -1
  144. package/fixtures/v3/antworten/storno.json +1 -1
  145. package/fixtures/v3/stored/belege.json +18 -6
  146. package/fixtures/v3/stored/kasse.json +4667 -183
  147. package/fixtures/v3/stored/rechnungen.json +1 -1
  148. package/fixtures/v3/v3-vokabular.json +739 -32
  149. package/fixtures/v3/zahlbetrag-faelle.json +1 -1
  150. package/package.json +1 -1
@@ -126,7 +126,7 @@ export type InventoryErrorCode = (typeof INVENTORY_ERROR_CODES)[number];
126
126
  * `route_missing` (Code des Pakets). Dieselbe Ableitung wie bei der
127
127
  * Rechnungs-API.
128
128
  */
129
- export declare const INVENTORY_REQUEST_ERROR_CODES: readonly ["account_not_found", "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", "session_expired", "session_other_cashregister", "unauthorized", "user_disabled", "user_verification_failed", "route_missing"];
129
+ export declare const INVENTORY_REQUEST_ERROR_CODES: readonly ["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"];
130
130
  export type InventoryRequestErrorCode = (typeof INVENTORY_REQUEST_ERROR_CODES)[number];
131
131
  /**
132
132
  * Hinweise einer Buchung (`warnings[].code`, `warningCodes.inventory`). Sie sind
@@ -300,6 +300,7 @@ exports.INVENTORY_ERROR_CODES = [
300
300
  */
301
301
  exports.INVENTORY_REQUEST_ERROR_CODES = [
302
302
  'account_not_found',
303
+ 'action_confirmation_required',
303
304
  'admin_required',
304
305
  'api_not_approved',
305
306
  'app_check_invalid',
@@ -319,6 +320,7 @@ exports.INVENTORY_REQUEST_ERROR_CODES = [
319
320
  'register_user_not_allowed',
320
321
  'register_user_not_found',
321
322
  'response_translation_failed',
323
+ 'second_factor_required',
322
324
  'session_expired',
323
325
  'session_other_cashregister',
324
326
  'unauthorized',
@@ -37,7 +37,7 @@ export type InvoiceErrorCode = (typeof INVOICE_ERROR_CODES)[number];
37
37
  * genau der Katalog des Servers (das Backend vergleicht ihn mit dem Schema);
38
38
  * die Helfer in `./invoice` erkennen beide Listen.
39
39
  */
40
- export declare const INVOICE_REQUEST_ERROR_CODES: readonly ["account_not_found", "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", "session_expired", "session_other_cashregister", "unauthorized", "user_disabled", "user_verification_failed", "route_missing"];
40
+ export declare const INVOICE_REQUEST_ERROR_CODES: readonly ["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"];
41
41
  export type InvoiceRequestErrorCode = (typeof INVOICE_REQUEST_ERROR_CODES)[number];
42
42
  /** Gruende einer Gutschrift. Der Server druckt den deutschen Anzeigetext. */
43
43
  export declare const CREDIT_NOTE_REASONS: readonly ["cancellation", "price_reduction", "return", "incorrect_invoice", "other"];
@@ -91,6 +91,7 @@ exports.INVOICE_ERROR_CODES = [
91
91
  */
92
92
  exports.INVOICE_REQUEST_ERROR_CODES = [
93
93
  'account_not_found',
94
+ 'action_confirmation_required',
94
95
  'admin_required',
95
96
  'api_not_approved',
96
97
  'app_check_invalid',
@@ -110,6 +111,7 @@ exports.INVOICE_REQUEST_ERROR_CODES = [
110
111
  'register_user_not_allowed',
111
112
  'register_user_not_found',
112
113
  'response_translation_failed',
114
+ 'second_factor_required',
113
115
  'session_expired',
114
116
  'session_other_cashregister',
115
117
  'unauthorized',
@@ -1,5 +1,6 @@
1
1
  import { KasseneckApiError } from '../client/errors.js';
2
2
  import type { Receipt } from './receipt.js';
3
+ import type { ReceiptPaymentInput } from './receipt-payment.js';
3
4
  /**
4
5
  * Storno-Metadaten — Zwilling von `functions/storno-core.js`.
5
6
  *
@@ -53,7 +54,7 @@ export declare function isReturnDisposition(value: unknown): value is ReturnDisp
53
54
  * [PAYMENT_ERROR_CODES]. Ein Code ausserhalb bleibt ueber
54
55
  * `KasseneckApiError.code` lesbar.
55
56
  */
56
- export declare const CANCELLATION_ERROR_CODES: readonly ["receipt_not_found", "receipt_type_not_cancellable", "training_receipt", "already_cancelled", "invalid_line", "quantity_exceeds_remaining", "unknown_reason", "note_too_long", "invalid_items", "cashregister_not_assigned", "not_permitted", "own_receipts_only", "cashregister_incomplete", "cancellation_failed", "cancellation_payments_required", "cancellation_refund_exceeds_payment", "cancellation_refund_reference_required", "cancellation_refund_reference_unknown", "cancellation_outcome_unknown", "invalid_return_disposition", "account_not_found", "admin_required", "api_not_approved", "app_check_invalid", "app_check_missing", "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", "session_expired", "session_other_cashregister", "unauthorized", "user_disabled", "user_verification_failed", "validation", "route_missing", "response_unreadable"];
57
+ export declare const CANCELLATION_ERROR_CODES: readonly ["receipt_not_found", "receipt_type_not_cancellable", "training_receipt", "already_cancelled", "invalid_line", "quantity_exceeds_remaining", "unknown_reason", "note_too_long", "invalid_items", "cashregister_not_assigned", "not_permitted", "own_receipts_only", "cashregister_incomplete", "cancellation_failed", "cancellation_payments_required", "cancellation_refund_exceeds_payment", "cancellation_refund_reference_required", "cancellation_refund_reference_unknown", "cancellation_outcome_unknown", "invalid_return_disposition", "tip_refund_conflict", "invalid_tip_refund_source", "tip_refund_source_requires_cash", "tip_keep_not_possible_with_voucher", "account_not_found", "action_confirmation_required", "admin_required", "api_not_approved", "app_check_invalid", "app_check_missing", "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", "validation", "route_missing", "response_unreadable"];
57
58
  export type CancellationErrorCode = (typeof CANCELLATION_ERROR_CODES)[number];
58
59
  export declare function isCancellationErrorCode(value: unknown): value is CancellationErrorCode;
59
60
  /** Der Code eines geworfenen Fehlers, wenn er in [CANCELLATION_ERROR_CODES] steht; sonst `undefined`. */
@@ -131,3 +132,50 @@ export interface CancellationFieldError {
131
132
  }
132
133
  /** Die Feldfehler einer `validation`-Antwort; leer, wenn es keine sind. */
133
134
  export declare function cancellationFieldErrors(error: unknown): CancellationFieldError[];
135
+ /**
136
+ * Woher das Trinkgeld beim Storno zurueckkommt: `drawer` – die Lade zahlt es aus („offen“ sinkt,
137
+ * kann negativ werden); `employee` – die Mitarbeiterin gibt es selbst („verdient“ und „schon
138
+ * genommen“ sinken, die Lade bleibt unberuehrt). Nur bei Barrueckgabe.
139
+ */
140
+ export declare const TIP_REFUND_SOURCES: readonly ["drawer", "employee"];
141
+ export type TipRefundSource = (typeof TIP_REFUND_SOURCES)[number];
142
+ export declare function isTipRefundSource(value: unknown): value is TipRefundSource;
143
+ /**
144
+ * Noch nicht storniertes Mitarbeiter-Trinkgeld in Cent. Groesser 0 heisst: das Storno fragt
145
+ * „Trinkgeld auch zurueckgeben?“ (auch beim Teilstorno). Inhaber-Trinkgeld ist Umsatz und folgt
146
+ * der Ware -- dafuer gibt es keine Frage.
147
+ */
148
+ export declare function openStaffTipCents(receipt: Receipt, nowMs?: number): number;
149
+ /**
150
+ * Fragt das Storno „Trinkgeld auch zurueckgeben?“ – nur bei noch offenem Mitarbeiter-Trinkgeld und
151
+ * ohne Wertgutschein am Beleg. Einen Wertgutschein spiegelt nur ein Storno, der alles nimmt; darum
152
+ * geht das Trinkgeld dort immer mit (der Server weist `refundTip: false` mit
153
+ * `tip_keep_not_possible_with_voucher` ab), die Kasse zeigt stattdessen
154
+ * `cancellation.tip_refunded_with_voucher` und sendet `refundTip: true`. Die Frage nach der Quelle
155
+ * bleibt ([asksTipRefundSource]).
156
+ */
157
+ export declare function asksRefundTip(receipt: Receipt, nowMs?: number): boolean;
158
+ /**
159
+ * Die Positionen, die nach der Antwort auf „Trinkgeld auch zurueckgeben?“ hinausgehen -- dieselbe
160
+ * Regel wie im Backend. `items` fehlt = ganzer Beleg.
161
+ * - Ja: zum Teilstorno kommt das offene Trinkgeld dazu; der ganze Beleg bleibt `undefined`.
162
+ * - Nein: ohne das Mitarbeiter-Trinkgeld; der ganze Beleg wird zur Liste aller Restmengen ausser dem
163
+ * Trinkgeld (leer = nichts mehr zu stornieren). Ist kein Mitarbeiter-Trinkgeld mehr offen (keines
164
+ * oder schon storniert), bleibt der Wunsch, wie er ist – „Nein“ wirkt dann wie keine Wahl.
165
+ */
166
+ export declare function cancellationItemsForTip(receipt: Receipt, items: readonly CancellationItem[] | undefined, refundTip: boolean, nowMs?: number): CancellationItem[] | undefined;
167
+ /**
168
+ * Was dieses Storno bar zurueckgibt (positiv, Cent): mit Rueckzahlungen deren Barteil; ohne
169
+ * (der Server spiegelt die eine Zahlung des Originals) alles, wenn das Original bar bezahlt war.
170
+ * Bei mehr als einer Zahlung ohne Angabe 0: welcher Teil bar zurueckgeht, ist dann offen (ein
171
+ * Teilstorno verlangt ohnehin `payments`). Beide Kassen schicken bei mehr als einer Zahlung darum
172
+ * immer die Rueckzahlungen mit und rechnen hier mit ihnen.
173
+ */
174
+ export declare function cancellationCashRefundCents(receipt: Receipt, payments: readonly ReceiptPaymentInput[] | undefined, dueCents: number): number;
175
+ /**
176
+ * Fragt das Storno nach „Ja“ auch „Woher kommt das Trinkgeld zurueck?“ – nur, wenn das Bargeld des
177
+ * Stornos (`cashRefundCents`, siehe [cancellationCashRefundCents]) das offene Mitarbeiter-Trinkgeld
178
+ * deckt und die Mitarbeiterin wenigstens eines davon schon hatte. Bei Kartenrueckgabe geht es auf
179
+ * die Karte zurueck; ueber Lohn behaltenes Trinkgeld kommt immer aus der Lade.
180
+ */
181
+ export declare function asksTipRefundSource(receipt: Receipt, cashRefundCents: number, nowMs?: number): boolean;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CANCELLATION_RESERVATION_MS = exports.CANCELLATION_STATUSES = exports.CANCELLATION_ERROR_CODES = exports.RETURN_DISPOSITIONS = exports.CANCELLATION_REASONS = void 0;
3
+ exports.TIP_REFUND_SOURCES = exports.CANCELLATION_RESERVATION_MS = exports.CANCELLATION_STATUSES = exports.CANCELLATION_ERROR_CODES = exports.RETURN_DISPOSITIONS = exports.CANCELLATION_REASONS = void 0;
4
4
  exports.isCancellationReason = isCancellationReason;
5
5
  exports.isReturnDisposition = isReturnDisposition;
6
6
  exports.isCancellationErrorCode = isCancellationErrorCode;
@@ -8,7 +8,14 @@ exports.cancellationErrorCode = cancellationErrorCode;
8
8
  exports.isCancellationError = isCancellationError;
9
9
  exports.remainingQuantities = remainingQuantities;
10
10
  exports.cancellationFieldErrors = cancellationFieldErrors;
11
+ exports.isTipRefundSource = isTipRefundSource;
12
+ exports.openStaffTipCents = openStaffTipCents;
13
+ exports.asksRefundTip = asksRefundTip;
14
+ exports.cancellationItemsForTip = cancellationItemsForTip;
15
+ exports.cancellationCashRefundCents = cancellationCashRefundCents;
16
+ exports.asksTipRefundSource = asksTipRefundSource;
11
17
  const fehlercodes_js_1 = require("../client/fehlercodes.js");
18
+ const receipt_item_js_1 = require("./receipt-item.js");
12
19
  /**
13
20
  * Storno-Metadaten — Zwilling von `functions/storno-core.js`.
14
21
  *
@@ -85,8 +92,14 @@ exports.CANCELLATION_ERROR_CODES = Object.freeze([
85
92
  'cancellation_refund_reference_unknown', // refundOf nennt keine Zahlung des Originals
86
93
  'cancellation_outcome_unknown', // Ausgang unklar: nachlesen, nie wiederholen
87
94
  'invalid_return_disposition', // Rueckgabe-Wahl nicht restock, defective oder disposed (Lager)
95
+ // Trinkgeld beim Storno (refundTip/tipRefundSource, Schichten-Spec Nachtrag 5)
96
+ 'tip_refund_conflict', // Wahl passt nicht zum Storno (Trinkgeld trotz Nein, Quelle ohne Trinkgeld)
97
+ 'invalid_tip_refund_source', // tipRefundSource nicht drawer oder employee
98
+ 'tip_refund_source_requires_cash', // eine Quelle nur, wenn das Bargeld des Stornos das Trinkgeld deckt
99
+ 'tip_keep_not_possible_with_voucher', // refundTip false an einem Beleg mit Wertgutschein (das Trinkgeld geht mit)
88
100
  // Anmeldung und Rand (errorCodes.auth ohne Partner-Zugang, errorCodes.edge)
89
101
  'account_not_found',
102
+ 'action_confirmation_required',
90
103
  'admin_required',
91
104
  'api_not_approved',
92
105
  'app_check_invalid',
@@ -105,6 +118,7 @@ exports.CANCELLATION_ERROR_CODES = Object.freeze([
105
118
  'register_user_not_allowed',
106
119
  'register_user_not_found',
107
120
  'response_translation_failed',
121
+ 'second_factor_required',
108
122
  'session_expired',
109
123
  'session_other_cashregister',
110
124
  'unauthorized',
@@ -157,3 +171,127 @@ function remainingQuantities(receipt, nowMs = Date.now()) {
157
171
  function cancellationFieldErrors(error) {
158
172
  return (0, fehlercodes_js_1.feldfehlerVon)(error);
159
173
  }
174
+ // --- Trinkgeld beim Storno (Schichten-Spec, Nachtrag 5, R56–R58) --------------------------------
175
+ //
176
+ // Enthaelt ein Beleg noch nicht storniertes Mitarbeiter-Trinkgeld, fragt die Kasse „Trinkgeld auch
177
+ // zurueckgeben?“ (`refundTip`) und bei Barrueckgabe „Woher kommt das Trinkgeld zurueck?“
178
+ // (`tipRefundSource`). Die Regeln stehen hier, damit Web-Kasse und Kassen-App dasselbe fragen;
179
+ // Zwilling von functions/gemeinsam/storno-core.js (wunschMitTrinkgeld, trinkgeldQuelleAnwenden).
180
+ // Faelle mit dem Dart-Zwilling: fixtures/cancellation-tip-cases.json.
181
+ /**
182
+ * Woher das Trinkgeld beim Storno zurueckkommt: `drawer` – die Lade zahlt es aus („offen“ sinkt,
183
+ * kann negativ werden); `employee` – die Mitarbeiterin gibt es selbst („verdient“ und „schon
184
+ * genommen“ sinken, die Lade bleibt unberuehrt). Nur bei Barrueckgabe.
185
+ */
186
+ exports.TIP_REFUND_SOURCES = Object.freeze(['drawer', 'employee']);
187
+ function isTipRefundSource(value) {
188
+ return typeof value === 'string' && exports.TIP_REFUND_SOURCES.includes(value);
189
+ }
190
+ /** Barzahlarten -- Zwilling von `BAR_ZAHLARTEN` (functions/gemeinsam/tip-core.js). */
191
+ const BAR_ZAHLARTEN = ['cash', 'uberCash', 'boltCash'];
192
+ /** Zahlart als Nutzlast-Schluessel (Enum-Objekt oder Text). */
193
+ function zahlartWert(m) {
194
+ if (m !== null && typeof m === 'object' && typeof m.value === 'string')
195
+ return m.value;
196
+ return typeof m === 'string' ? m : '';
197
+ }
198
+ const istMitarbeiterTrinkgeld = (item) => (0, receipt_item_js_1.isTipItem)(item) && item.recipient?.owner !== true;
199
+ /**
200
+ * Hatte die Mitarbeiterin dieses Trinkgeld schon in der Hand (sofort erhalten, mit Empfaenger)?
201
+ * Ohne Merkmal (Altbestand) gilt wie im Backend: bar = erhalten, sonst nicht.
202
+ */
203
+ function hatteSie(item, receipt) {
204
+ if (!item.recipient?.registerUserId)
205
+ return false;
206
+ if (typeof item.receivedImmediately === 'boolean')
207
+ return item.receivedImmediately;
208
+ return BAR_ZAHLARTEN.includes(zahlartWert(item.paymentMethod ?? receipt.paymentMethod));
209
+ }
210
+ /** Indizes des noch nicht stornierten Mitarbeiter-Trinkgelds mit ihrem Rest. */
211
+ function offenesTrinkgeld(receipt, nowMs) {
212
+ const rest = remainingQuantities(receipt, nowMs);
213
+ return receipt.items
214
+ .map((item, index) => ({ item, index, quantity: rest[index] ?? 0 }))
215
+ .filter(({ item, quantity }) => quantity > 0 && istMitarbeiterTrinkgeld(item))
216
+ .map(({ index, quantity }) => ({ index, quantity }));
217
+ }
218
+ /**
219
+ * Noch nicht storniertes Mitarbeiter-Trinkgeld in Cent. Groesser 0 heisst: das Storno fragt
220
+ * „Trinkgeld auch zurueckgeben?“ (auch beim Teilstorno). Inhaber-Trinkgeld ist Umsatz und folgt
221
+ * der Ware -- dafuer gibt es keine Frage.
222
+ */
223
+ function openStaffTipCents(receipt, nowMs = Date.now()) {
224
+ return offenesTrinkgeld(receipt, nowMs).reduce((s, { index, quantity }) => s + quantity * (receipt.items[index]?.priceCents ?? 0), 0);
225
+ }
226
+ /** Traegt der Beleg einen Wertgutschein (verkauft oder eingeloest)? Zwilling von storno-core.hatWertgutschein. */
227
+ function hatWertgutschein(receipt) {
228
+ return (receipt.vouchers ?? []).some((v) => v != null && zahlartWert(v.type) === 'value');
229
+ }
230
+ /**
231
+ * Fragt das Storno „Trinkgeld auch zurueckgeben?“ – nur bei noch offenem Mitarbeiter-Trinkgeld und
232
+ * ohne Wertgutschein am Beleg. Einen Wertgutschein spiegelt nur ein Storno, der alles nimmt; darum
233
+ * geht das Trinkgeld dort immer mit (der Server weist `refundTip: false` mit
234
+ * `tip_keep_not_possible_with_voucher` ab), die Kasse zeigt stattdessen
235
+ * `cancellation.tip_refunded_with_voucher` und sendet `refundTip: true`. Die Frage nach der Quelle
236
+ * bleibt ([asksTipRefundSource]).
237
+ */
238
+ function asksRefundTip(receipt, nowMs = Date.now()) {
239
+ return openStaffTipCents(receipt, nowMs) > 0 && !hatWertgutschein(receipt);
240
+ }
241
+ /**
242
+ * Die Positionen, die nach der Antwort auf „Trinkgeld auch zurueckgeben?“ hinausgehen -- dieselbe
243
+ * Regel wie im Backend. `items` fehlt = ganzer Beleg.
244
+ * - Ja: zum Teilstorno kommt das offene Trinkgeld dazu; der ganze Beleg bleibt `undefined`.
245
+ * - Nein: ohne das Mitarbeiter-Trinkgeld; der ganze Beleg wird zur Liste aller Restmengen ausser dem
246
+ * Trinkgeld (leer = nichts mehr zu stornieren). Ist kein Mitarbeiter-Trinkgeld mehr offen (keines
247
+ * oder schon storniert), bleibt der Wunsch, wie er ist – „Nein“ wirkt dann wie keine Wahl.
248
+ */
249
+ function cancellationItemsForTip(receipt, items, refundTip, nowMs = Date.now()) {
250
+ const trinkgeld = new Set(receipt.items.map((item, i) => (istMitarbeiterTrinkgeld(item) ? i : -1)).filter((i) => i >= 0));
251
+ if (trinkgeld.size === 0)
252
+ return items === undefined ? undefined : [...items];
253
+ if (refundTip) {
254
+ if (items === undefined)
255
+ return undefined;
256
+ const genannt = new Set(items.map((x) => x.index));
257
+ return [...items, ...offenesTrinkgeld(receipt, nowMs).filter((x) => !genannt.has(x.index))];
258
+ }
259
+ if (items !== undefined)
260
+ return items.filter((x) => !trinkgeld.has(x.index));
261
+ if (offenesTrinkgeld(receipt, nowMs).length === 0)
262
+ return undefined;
263
+ const rest = remainingQuantities(receipt, nowMs);
264
+ return rest.map((quantity, index) => ({ index, quantity })).filter((x) => x.quantity > 0 && !trinkgeld.has(x.index));
265
+ }
266
+ /**
267
+ * Was dieses Storno bar zurueckgibt (positiv, Cent): mit Rueckzahlungen deren Barteil; ohne
268
+ * (der Server spiegelt die eine Zahlung des Originals) alles, wenn das Original bar bezahlt war.
269
+ * Bei mehr als einer Zahlung ohne Angabe 0: welcher Teil bar zurueckgeht, ist dann offen (ein
270
+ * Teilstorno verlangt ohnehin `payments`). Beide Kassen schicken bei mehr als einer Zahlung darum
271
+ * immer die Rueckzahlungen mit und rechnen hier mit ihnen.
272
+ */
273
+ function cancellationCashRefundCents(receipt, payments, dueCents) {
274
+ if (payments !== undefined) {
275
+ return payments.reduce((s, z) => (zahlartWert(z.method) === 'cash' ? s - z.amountCents : s), 0);
276
+ }
277
+ const zahlungen = receipt.payments ?? [];
278
+ if (zahlungen.length > 1)
279
+ return 0;
280
+ const methode = zahlungen.length === 1 ? zahlartWert(zahlungen[0].method) : zahlartWert(receipt.paymentMethod);
281
+ return methode === 'cash' ? dueCents : 0;
282
+ }
283
+ /**
284
+ * Fragt das Storno nach „Ja“ auch „Woher kommt das Trinkgeld zurueck?“ – nur, wenn das Bargeld des
285
+ * Stornos (`cashRefundCents`, siehe [cancellationCashRefundCents]) das offene Mitarbeiter-Trinkgeld
286
+ * deckt und die Mitarbeiterin wenigstens eines davon schon hatte. Bei Kartenrueckgabe geht es auf
287
+ * die Karte zurueck; ueber Lohn behaltenes Trinkgeld kommt immer aus der Lade.
288
+ */
289
+ function asksTipRefundSource(receipt, cashRefundCents, nowMs = Date.now()) {
290
+ // Ohne diese Frage (Karte) und mit `refundTip: true` gilt beim Server: aus der Lade, kein `direkt`.
291
+ const offen = offenesTrinkgeld(receipt, nowMs);
292
+ if (offen.length === 0)
293
+ return false;
294
+ if (!offen.some(({ index }) => hatteSie(receipt.items[index], receipt)))
295
+ return false;
296
+ return cashRefundCents >= openStaffTipCents(receipt, nowMs);
297
+ }
@@ -1,7 +1,7 @@
1
1
  export { type ReceiptItem, type ReceiptItemPayload, type ReceiptItemPayloadRead, toReceiptItemPayload, fromReceiptItemPayload, receiptItemTotalCents, receiptItemIsValid, negateReceiptItem, type TipRecipient, isTipItem, isDiscountItem, } from './receipt-item.js';
2
2
  export { type Voucher, type VoucherPayload, toVoucherPayload, fromVoucherPayload, voucherIsValid } from './voucher.js';
3
3
  export { type Receipt, type RegistrationInfo, type ReceiptPayload, type ReceiptPayloadRead, toReceiptPayload, fromReceiptPayload, readRegistrationInfo, receiptSubSumCents, receiptSumCents, } from './receipt.js';
4
- export { 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, remainingQuantities, } from './cancellation.js';
4
+ export { 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, remainingQuantities, TIP_REFUND_SOURCES, type TipRefundSource, isTipRefundSource, openStaffTipCents, cancellationItemsForTip, cancellationCashRefundCents, asksTipRefundSource, asksRefundTip, } from './cancellation.js';
5
5
  export { type ReceiptPayment, type ReceiptPaymentPayload, type ReceiptPaymentInput, fromReceiptPaymentPayload, toReceiptPaymentPayload, } from './receipt-payment.js';
6
6
  export { type PaymentErrorCode, PAYMENT_ERROR_CODES, isPaymentErrorCode, paymentErrorCode, isPaymentError, paymentFieldErrors, type PaymentFieldError } from './payment-errors.js';
7
7
  export { type ReceiptEmailErrorCode, type ReceiptEmailVia, RECEIPT_EMAIL_ERROR_CODES, RECEIPT_EMAIL_SEND_ERROR_CODES, type ReceiptEmailSendErrorCode, RECEIPT_EMAIL_VIAS, isReceiptEmailErrorCode, receiptEmailErrorCode, isReceiptEmailError, receiptEmailFieldErrors, type ReceiptEmailFieldError, } from './receipt-email.js';
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fromReceiptSummaryPayload = exports.fromCashregisterPayload = exports.receiptCompanyTaxInfo = exports.fromReceiptCompanyPayload = exports.receiptFieldErrors = exports.isReceiptError = exports.receiptErrorCode = exports.isReceiptErrorCode = exports.RECEIPT_ERROR_CODES = exports.receiptEmailFieldErrors = exports.isReceiptEmailError = exports.receiptEmailErrorCode = exports.isReceiptEmailErrorCode = exports.RECEIPT_EMAIL_VIAS = exports.RECEIPT_EMAIL_SEND_ERROR_CODES = exports.RECEIPT_EMAIL_ERROR_CODES = exports.paymentFieldErrors = exports.isPaymentError = exports.paymentErrorCode = exports.isPaymentErrorCode = exports.PAYMENT_ERROR_CODES = exports.toReceiptPaymentPayload = exports.fromReceiptPaymentPayload = exports.remainingQuantities = exports.cancellationFieldErrors = exports.isCancellationError = exports.cancellationErrorCode = exports.isCancellationErrorCode = exports.isReturnDisposition = exports.isCancellationReason = exports.CANCELLATION_RESERVATION_MS = exports.CANCELLATION_ERROR_CODES = exports.CANCELLATION_STATUSES = exports.CANCELLATION_REASONS = exports.RETURN_DISPOSITIONS = exports.receiptSumCents = exports.receiptSubSumCents = exports.readRegistrationInfo = exports.fromReceiptPayload = exports.toReceiptPayload = exports.voucherIsValid = exports.fromVoucherPayload = exports.toVoucherPayload = exports.isDiscountItem = exports.isTipItem = exports.negateReceiptItem = exports.receiptItemIsValid = exports.receiptItemTotalCents = exports.fromReceiptItemPayload = exports.toReceiptItemPayload = void 0;
4
- exports.hobexReceiptNeedsSignature = exports.hobexReceiptToCardPaymentData = exports.fromHobexReceiptPayload = exports.toHobexReceiptPayload = exports.fromStripeUrlSessionPayload = exports.toStripeUrlSessionPayload = exports.reportMonthReadable = exports.reportMonthKey = exports.nextReportMonth = exports.previousReportMonth = exports.reportMonthFromDate = exports.isZeroKind = exports.ZERO_KINDS = void 0;
3
+ exports.isReceiptErrorCode = exports.RECEIPT_ERROR_CODES = exports.receiptEmailFieldErrors = exports.isReceiptEmailError = exports.receiptEmailErrorCode = exports.isReceiptEmailErrorCode = exports.RECEIPT_EMAIL_VIAS = exports.RECEIPT_EMAIL_SEND_ERROR_CODES = exports.RECEIPT_EMAIL_ERROR_CODES = exports.paymentFieldErrors = exports.isPaymentError = exports.paymentErrorCode = exports.isPaymentErrorCode = exports.PAYMENT_ERROR_CODES = exports.toReceiptPaymentPayload = exports.fromReceiptPaymentPayload = exports.asksRefundTip = exports.asksTipRefundSource = exports.cancellationCashRefundCents = exports.cancellationItemsForTip = exports.openStaffTipCents = exports.isTipRefundSource = exports.TIP_REFUND_SOURCES = exports.remainingQuantities = exports.cancellationFieldErrors = exports.isCancellationError = exports.cancellationErrorCode = exports.isCancellationErrorCode = exports.isReturnDisposition = exports.isCancellationReason = exports.CANCELLATION_RESERVATION_MS = exports.CANCELLATION_ERROR_CODES = exports.CANCELLATION_STATUSES = exports.CANCELLATION_REASONS = exports.RETURN_DISPOSITIONS = exports.receiptSumCents = exports.receiptSubSumCents = exports.readRegistrationInfo = exports.fromReceiptPayload = exports.toReceiptPayload = exports.voucherIsValid = exports.fromVoucherPayload = exports.toVoucherPayload = exports.isDiscountItem = exports.isTipItem = exports.negateReceiptItem = exports.receiptItemIsValid = exports.receiptItemTotalCents = exports.fromReceiptItemPayload = exports.toReceiptItemPayload = void 0;
4
+ exports.hobexReceiptNeedsSignature = exports.hobexReceiptToCardPaymentData = exports.fromHobexReceiptPayload = exports.toHobexReceiptPayload = exports.fromStripeUrlSessionPayload = exports.toStripeUrlSessionPayload = exports.reportMonthReadable = exports.reportMonthKey = exports.nextReportMonth = exports.previousReportMonth = exports.reportMonthFromDate = exports.isZeroKind = exports.ZERO_KINDS = exports.fromReceiptSummaryPayload = exports.fromCashregisterPayload = exports.receiptCompanyTaxInfo = exports.fromReceiptCompanyPayload = exports.receiptFieldErrors = exports.isReceiptError = exports.receiptErrorCode = void 0;
5
5
  var receipt_item_js_1 = require("./receipt-item.js");
6
6
  Object.defineProperty(exports, "toReceiptItemPayload", { enumerable: true, get: function () { return receipt_item_js_1.toReceiptItemPayload; } });
7
7
  Object.defineProperty(exports, "fromReceiptItemPayload", { enumerable: true, get: function () { return receipt_item_js_1.fromReceiptItemPayload; } });
@@ -33,6 +33,13 @@ Object.defineProperty(exports, "cancellationErrorCode", { enumerable: true, get:
33
33
  Object.defineProperty(exports, "isCancellationError", { enumerable: true, get: function () { return cancellation_js_1.isCancellationError; } });
34
34
  Object.defineProperty(exports, "cancellationFieldErrors", { enumerable: true, get: function () { return cancellation_js_1.cancellationFieldErrors; } });
35
35
  Object.defineProperty(exports, "remainingQuantities", { enumerable: true, get: function () { return cancellation_js_1.remainingQuantities; } });
36
+ Object.defineProperty(exports, "TIP_REFUND_SOURCES", { enumerable: true, get: function () { return cancellation_js_1.TIP_REFUND_SOURCES; } });
37
+ Object.defineProperty(exports, "isTipRefundSource", { enumerable: true, get: function () { return cancellation_js_1.isTipRefundSource; } });
38
+ Object.defineProperty(exports, "openStaffTipCents", { enumerable: true, get: function () { return cancellation_js_1.openStaffTipCents; } });
39
+ Object.defineProperty(exports, "cancellationItemsForTip", { enumerable: true, get: function () { return cancellation_js_1.cancellationItemsForTip; } });
40
+ Object.defineProperty(exports, "cancellationCashRefundCents", { enumerable: true, get: function () { return cancellation_js_1.cancellationCashRefundCents; } });
41
+ Object.defineProperty(exports, "asksTipRefundSource", { enumerable: true, get: function () { return cancellation_js_1.asksTipRefundSource; } });
42
+ Object.defineProperty(exports, "asksRefundTip", { enumerable: true, get: function () { return cancellation_js_1.asksRefundTip; } });
36
43
  var receipt_payment_js_1 = require("./receipt-payment.js");
37
44
  Object.defineProperty(exports, "fromReceiptPaymentPayload", { enumerable: true, get: function () { return receipt_payment_js_1.fromReceiptPaymentPayload; } });
38
45
  Object.defineProperty(exports, "toReceiptPaymentPayload", { enumerable: true, get: function () { return receipt_payment_js_1.toReceiptPaymentPayload; } });
@@ -19,7 +19,7 @@ import { KasseneckApiError } from '../client/errors.js';
19
19
  * ...) und zuletzt `route_missing` (Code des Pakets). Ein Code ausserhalb
20
20
  * bleibt ueber `KasseneckApiError.code` lesbar.
21
21
  */
22
- export declare const PAYMENT_ERROR_CODES: readonly ["payments_invalid", "payment_method_invalid", "payment_amount_invalid", "payment_tendered_invalid", "payment_provider_invalid", "payment_provider_not_allowed", "payments_sum_mismatch", "payments_due_negative", "payments_not_allowed", "payments_conflict", "payments_required", "payment_method_not_supported", "tip_payment_method_invalid", "tip_payment_method_required", "tip_exceeds_payment", "payment_refund_not_allowed", "payment_tip_invalid", "tip_conflict", "account_not_found", "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", "session_expired", "session_other_cashregister", "unauthorized", "user_disabled", "user_verification_failed", "validation", "route_missing"];
22
+ export declare const PAYMENT_ERROR_CODES: readonly ["payments_invalid", "payment_method_invalid", "payment_amount_invalid", "payment_tendered_invalid", "payment_provider_invalid", "payment_provider_not_allowed", "payments_sum_mismatch", "payments_due_negative", "payments_not_allowed", "payments_conflict", "payments_required", "payment_method_not_supported", "tip_payment_method_invalid", "tip_payment_method_required", "tip_exceeds_payment", "payment_refund_not_allowed", "payment_tip_invalid", "tip_conflict", "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", "validation", "route_missing"];
23
23
  export type PaymentErrorCode = (typeof PAYMENT_ERROR_CODES)[number];
24
24
  /** Erkennt einen Code aus [PAYMENT_ERROR_CODES], exakt (klein, wie unter `/v3`). */
25
25
  export declare function isPaymentErrorCode(value: unknown): value is PaymentErrorCode;
@@ -47,6 +47,7 @@ exports.PAYMENT_ERROR_CODES = Object.freeze([
47
47
  'tip_conflict', // tip und payments[].tipCents zugleich
48
48
  // Anmeldung und Rand (errorCodes.auth ohne Partner-Zugang, errorCodes.edge)
49
49
  'account_not_found',
50
+ 'action_confirmation_required',
50
51
  'admin_required',
51
52
  'api_not_approved',
52
53
  'app_check_invalid',
@@ -66,6 +67,7 @@ exports.PAYMENT_ERROR_CODES = Object.freeze([
66
67
  'register_user_not_allowed',
67
68
  'register_user_not_found',
68
69
  'response_translation_failed',
70
+ 'second_factor_required',
69
71
  'session_expired',
70
72
  'session_other_cashregister',
71
73
  'unauthorized',
@@ -11,7 +11,7 @@ export type ReceiptEmailSendErrorCode = (typeof RECEIPT_EMAIL_SEND_ERROR_CODES)[
11
11
  * als [KasseneckApiError.code] durch; ein Code ausserhalb bleibt dort lesbar.
12
12
  * Zuletzt `route_missing` (Code des Pakets).
13
13
  */
14
- export declare const RECEIPT_EMAIL_ERROR_CODES: readonly ["invalid_address", "receipt_not_found", "too_many_requests", "send_failed", "account_not_found", "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", "session_expired", "session_other_cashregister", "unauthorized", "user_disabled", "user_verification_failed", "validation", "route_missing"];
14
+ export declare const RECEIPT_EMAIL_ERROR_CODES: readonly ["invalid_address", "receipt_not_found", "too_many_requests", "send_failed", "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", "validation", "route_missing"];
15
15
  export type ReceiptEmailErrorCode = (typeof RECEIPT_EMAIL_ERROR_CODES)[number];
16
16
  export declare function isReceiptEmailErrorCode(value: unknown): value is ReceiptEmailErrorCode;
17
17
  /** Der Code eines geworfenen Fehlers, wenn er in [RECEIPT_EMAIL_ERROR_CODES] steht; sonst `undefined`. */
@@ -26,6 +26,7 @@ exports.RECEIPT_EMAIL_ERROR_CODES = Object.freeze([
26
26
  ...exports.RECEIPT_EMAIL_SEND_ERROR_CODES,
27
27
  // Anmeldung und Rand (errorCodes.auth ohne Partner-Zugang, errorCodes.edge)
28
28
  'account_not_found',
29
+ 'action_confirmation_required',
29
30
  'admin_required',
30
31
  'api_not_approved',
31
32
  'app_check_invalid',
@@ -45,6 +46,7 @@ exports.RECEIPT_EMAIL_ERROR_CODES = Object.freeze([
45
46
  'register_user_not_allowed',
46
47
  'register_user_not_found',
47
48
  'response_translation_failed',
49
+ 'second_factor_required',
48
50
  'session_expired',
49
51
  'session_other_cashregister',
50
52
  'unauthorized',
@@ -16,7 +16,7 @@ import { KasseneckApiError } from '../client/errors.js';
16
16
  * ...) stehen in [PAYMENT_ERROR_CODES]. Ein Code ausserhalb bleibt ueber
17
17
  * `KasseneckApiError.code` lesbar.
18
18
  */
19
- export declare const RECEIPT_ERROR_CODES: readonly ["cancellation_reference_unavailable", "cashregister_closed", "cashregister_decommissioned", "final_receipt_expired", "final_receipt_not_allowed", "module_inactive", "not_permitted", "receipt_limit_exceeded", "receipt_not_found", "receipt_outcome_unknown", "receipt_type_invalid", "signature_incomplete", "signature_missing", "signing_failed", "small_business_vat_not_allowed", "tip_invalid", "tip_not_allowed", "tip_recipient_unknown", "validation", "account_not_found", "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", "session_expired", "session_other_cashregister", "unauthorized", "user_disabled", "user_verification_failed", "route_missing", "response_unreadable"];
19
+ export declare const RECEIPT_ERROR_CODES: readonly ["cancellation_reference_unavailable", "cashregister_closed", "cashregister_decommissioned", "final_receipt_expired", "final_receipt_not_allowed", "module_inactive", "not_permitted", "receipt_limit_exceeded", "receipt_not_found", "receipt_outcome_unknown", "receipt_type_invalid", "signature_incomplete", "signature_missing", "signing_failed", "small_business_vat_not_allowed", "tip_invalid", "tip_not_allowed", "tip_recipient_unknown", "validation", "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"];
20
20
  export type ReceiptErrorCode = (typeof RECEIPT_ERROR_CODES)[number];
21
21
  export declare function isReceiptErrorCode(value: unknown): value is ReceiptErrorCode;
22
22
  /** Der Code eines geworfenen Fehlers, wenn er in [RECEIPT_ERROR_CODES] steht; sonst `undefined`. */
@@ -45,6 +45,7 @@ exports.RECEIPT_ERROR_CODES = Object.freeze([
45
45
  'validation',
46
46
  // Anmeldung und Rand (errorCodes.auth ohne Partner-Zugang, errorCodes.edge)
47
47
  'account_not_found',
48
+ 'action_confirmation_required',
48
49
  'admin_required',
49
50
  'api_not_approved',
50
51
  'app_check_invalid',
@@ -64,6 +65,7 @@ exports.RECEIPT_ERROR_CODES = Object.freeze([
64
65
  'register_user_not_allowed',
65
66
  'register_user_not_found',
66
67
  'response_translation_failed',
68
+ 'second_factor_required',
67
69
  'session_expired',
68
70
  'session_other_cashregister',
69
71
  'unauthorized',
@@ -46,6 +46,12 @@ export interface ReceiptItem {
46
46
  * behaelt der Betrieb es und schuldet es (`false`)? Fehlt bei Altbelegen.
47
47
  */
48
48
  receivedImmediately?: boolean;
49
+ /**
50
+ * Nur Personal-Trinkgeld bar: die Mitarbeiterin hat es beim Verkauf gleich
51
+ * eingesteckt („gleich behalten“). Nur ein Merkmal fuer den Kassenstand;
52
+ * fehlt sonst.
53
+ */
54
+ keptByEmployee?: boolean;
49
55
  /**
50
56
  * Artikel-Verweis (Artikelstamm) — Grundlage der Erloesgruppen-Zuordnung
51
57
  * im Bericht. Optional; Handeingaben haben keinen.
@@ -81,6 +87,8 @@ export interface ReceiptItemPayload {
81
87
  recipient?: TipRecipient | null;
82
88
  paymentMethod?: string;
83
89
  receivedImmediately?: boolean;
90
+ /** Trinkgeld-Position, siehe [ReceiptItem.keptByEmployee]; nur `true`. */
91
+ keptByEmployee?: boolean;
84
92
  /** Artikel-Verweis, siehe [ReceiptItem.articleId]. */
85
93
  articleId?: string;
86
94
  }
@@ -106,6 +114,8 @@ export interface ReceiptItemPayloadRead {
106
114
  paymentMethod?: string | null;
107
115
  /** Trinkgeld-Position, siehe [ReceiptItem.receivedImmediately]. */
108
116
  receivedImmediately?: boolean | null;
117
+ /** Trinkgeld-Position, siehe [ReceiptItem.keptByEmployee]. */
118
+ keptByEmployee?: boolean | null;
109
119
  /** v2: Menge */
110
120
  quantity?: number | null;
111
121
  /** v2: Einzelpreis in Cent */
@@ -39,6 +39,8 @@ function toReceiptItemPayload(item) {
39
39
  nutzlast.paymentMethod = item.paymentMethod;
40
40
  if (typeof item.receivedImmediately === 'boolean')
41
41
  nutzlast.receivedImmediately = item.receivedImmediately;
42
+ if (item.keptByEmployee === true)
43
+ nutzlast.keptByEmployee = true;
42
44
  }
43
45
  // Rabatt-Kennzeichnung reist mit — sonst kaeme ein Storno dieser Position
44
46
  // am Bon wieder als gewoehnliche Warenzeile mit "1 x" an.
@@ -84,6 +86,7 @@ function fromReceiptItemPayload(payload) {
84
86
  recipient: payload.recipient ?? null,
85
87
  ...(payload.paymentMethod != null ? { paymentMethod: payload.paymentMethod } : {}),
86
88
  ...(typeof payload.receivedImmediately === 'boolean' ? { receivedImmediately: payload.receivedImmediately } : {}),
89
+ ...(payload.keptByEmployee === true ? { keptByEmployee: true } : {}),
87
90
  }
88
91
  : payload.kind === 'discount'
89
92
  ? { kind: 'discount' }
@@ -139,6 +139,16 @@ function pruefeTeil(name, teil, block, standard, werte) {
139
139
  throw new errors_js_1.KasseneckValidationError(name, `${teil}: keine Einstellungen uebergeben`, 'request');
140
140
  }
141
141
  for (const [schluessel, wert] of gesendet) {
142
+ if (teil === 'device' && settings_js_1.POS_DEVICE_OPTIONAL_FIELDS.includes(schluessel)) {
143
+ if (!(0, settings_js_1._optionalerWert)(wert, true))
144
+ throw new errors_js_1.KasseneckValidationError(name, `${teil}.${schluessel}: Kennung oder null erwartet`, 'request');
145
+ continue;
146
+ }
147
+ if (teil === 'business' && settings_js_1.POS_BUSINESS_OPTIONAL_FIELDS.includes(schluessel)) {
148
+ if (typeof wert !== 'boolean')
149
+ throw new errors_js_1.KasseneckValidationError(name, `${teil}.${schluessel}: true oder false erwartet`, 'request');
150
+ continue;
151
+ }
142
152
  if (!Object.prototype.hasOwnProperty.call(standard, schluessel)) {
143
153
  throw new errors_js_1.KasseneckValidationError(name, `${teil}.${schluessel}: unbekanntes Feld`, 'request');
144
154
  }
@@ -1,13 +1,14 @@
1
1
  import { KasseneckApiError } from '../client/errors.js';
2
2
  /**
3
3
  * Fehler der Kassen-Aufrufe um den Verkauf herum (Einstellungen, Logo,
4
- * Artikel, Drucker, Trinkgeld-Empfaenger, Lager, Inventur zaehlen) auswerten:
4
+ * Artikel, Drucker, Trinkgeld-Empfaenger, Lager, Inventur zaehlen, Schicht,
5
+ * Kassenstand und Lade-Protokoll) auswerten:
5
6
  * am `code`, nie am Text.
6
7
  * Belege, Storno und Belegmail haben eigene Listen (`RECEIPT_ERROR_CODES`,
7
8
  * `CANCELLATION_ERROR_CODES`, `RECEIPT_EMAIL_ERROR_CODES`), die Anmeldung
8
9
  * `REGISTER_ERROR_CODES` im Unterpfad `./register`.
9
10
  *
10
- * Abgeleitet aus dem Vertrags-Export (Fehlerfaelle dieser achtzehn Endpunkte in
11
+ * Abgeleitet aus dem Vertrags-Export (Fehlerfaelle dieser 24 Endpunkte in
11
12
  * `fixtures/v3/antworten/kasse.json` und ihre Handler-Codes); ein Test haelt
12
13
  * die Liste deckungsgleich. `validation` traegt `data.errors[]` mit dem
13
14
  * aeusseren Feldpfad (`business.theme`, `device.shortcuts.splitPayment`).
@@ -20,7 +21,7 @@ import { KasseneckApiError } from '../client/errors.js';
20
21
  * ueber `KasseneckApiError.code` lesbar; die Kasse braucht dafuer einen
21
22
  * Rueckfallzweig.
22
23
  */
23
- export declare const POS_ERROR_CODES: readonly ["account_not_found", "admin_required", "api_not_approved", "app_check_invalid", "app_check_missing", "article_not_found", "article_not_in_scope", "article_not_tracked", "cashregister_not_assigned", "cashregister_not_found", "cashregister_token_invalid", "cashregister_token_missing", "count_already_voided", "count_not_found", "device_not_found", "dialect_mismatch", "idempotency_conflict", "idempotency_key_required", "internal_translation_error", "invalid_cursor", "invalid_quantity", "invalid_serial", "live_not_enabled", "location_inactive", "location_not_found", "logo_invalid", "logo_invalid_type", "logo_too_large", "method_not_allowed", "mfa_required", "module_inactive", "not_found", "not_permitted", "password_change_required", "print_job_not_found", "print_layout_failed", "printer_not_found", "register_user_no_business", "register_user_not_allowed", "register_user_not_found", "response_translation_failed", "serial_already_counted", "serial_not_allowed", "serial_required", "server_error", "session_expired", "session_other_cashregister", "stocktake_closed", "stocktake_closing", "stocktake_not_found", "stocktake_not_open", "too_many_counts", "unauthorized", "user_disabled", "user_verification_failed", "validation", "route_missing"];
24
+ export declare const POS_ERROR_CODES: readonly ["account_not_found", "action_confirmation_required", "admin_required", "after_count_not_permitted", "api_not_approved", "app_check_invalid", "app_check_missing", "article_not_found", "article_not_in_scope", "article_not_tracked", "cash_movement_exceeds_balance", "cashregister_not_assigned", "cashregister_not_found", "cashregister_token_invalid", "cashregister_token_missing", "comment_required", "count_already_voided", "count_not_found", "device_not_found", "dialect_mismatch", "drawer_inactive", "drawer_not_found", "idempotency_conflict", "idempotency_key_required", "internal_translation_error", "invalid_amount", "invalid_cursor", "invalid_denominations", "invalid_movement_type", "invalid_quantity", "invalid_serial", "live_not_enabled", "location_inactive", "location_not_found", "logo_invalid", "logo_invalid_type", "logo_too_large", "method_not_allowed", "mfa_required", "module_inactive", "not_found", "not_permitted", "note_required", "password_change_required", "print_job_not_found", "print_layout_failed", "printer_not_found", "recount_exhausted", "register_user_no_business", "register_user_not_allowed", "register_user_not_found", "response_translation_failed", "second_factor_required", "serial_already_counted", "serial_not_allowed", "serial_required", "server_error", "session_expired", "session_other_cashregister", "shift_already_open", "shift_closed", "shift_mode_off", "shift_not_open", "stocktake_closed", "stocktake_closing", "stocktake_not_found", "stocktake_not_open", "tip_payout_exceeds_claim", "too_many_counts", "transfer_same_drawer", "unauthorized", "user_disabled", "user_verification_failed", "validation", "route_missing"];
24
25
  export type PosErrorCode = typeof POS_ERROR_CODES[number];
25
26
  export declare function isPosErrorCode(value: unknown): value is PosErrorCode;
26
27
  /** Der Code eines geworfenen Fehlers, wenn er in [POS_ERROR_CODES] steht; sonst `undefined`. */