@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.
- package/CHANGELOG.md +245 -0
- package/dist/cjs/client/aufrufe.d.ts +5 -5
- package/dist/cjs/client/aufrufe.js +22 -2
- package/dist/cjs/client/errors.js +2 -0
- package/dist/cjs/client/receipts.d.ts +34 -1
- package/dist/cjs/client/receipts.js +34 -1
- package/dist/cjs/client/reports.d.ts +4 -4
- package/dist/cjs/client/reports.js +4 -4
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +9 -2
- package/dist/cjs/inventory/vertrag.d.ts +1 -1
- package/dist/cjs/inventory/vertrag.js +2 -0
- package/dist/cjs/invoice/vertrag.d.ts +1 -1
- package/dist/cjs/invoice/vertrag.js +2 -0
- package/dist/cjs/models/cancellation.d.ts +49 -1
- package/dist/cjs/models/cancellation.js +139 -1
- package/dist/cjs/models/index.d.ts +1 -1
- package/dist/cjs/models/index.js +9 -2
- package/dist/cjs/models/payment-errors.d.ts +1 -1
- package/dist/cjs/models/payment-errors.js +2 -0
- package/dist/cjs/models/receipt-email.d.ts +1 -1
- package/dist/cjs/models/receipt-email.js +2 -0
- package/dist/cjs/models/receipt-errors.d.ts +1 -1
- package/dist/cjs/models/receipt-errors.js +2 -0
- package/dist/cjs/models/receipt-item.d.ts +10 -0
- package/dist/cjs/models/receipt-item.js +3 -0
- package/dist/cjs/pos/client.js +10 -0
- package/dist/cjs/pos/errors.d.ts +4 -3
- package/dist/cjs/pos/errors.js +21 -2
- package/dist/cjs/pos/index.d.ts +6 -2
- package/dist/cjs/pos/index.js +33 -3
- package/dist/cjs/pos/schicht-lesen.d.ts +39 -0
- package/dist/cjs/pos/schicht-lesen.js +405 -0
- package/dist/cjs/pos/schicht-typen.d.ts +380 -0
- package/dist/cjs/pos/schicht-typen.js +59 -0
- package/dist/cjs/pos/schicht.d.ts +208 -0
- package/dist/cjs/pos/schicht.js +235 -0
- package/dist/cjs/pos/settings.d.ts +37 -1
- package/dist/cjs/pos/settings.js +43 -3
- package/dist/cjs/pos/texte.d.ts +627 -0
- package/dist/cjs/pos/texte.js +236 -0
- package/dist/cjs/react/index.js +1 -1
- package/dist/cjs/receipt/grid.js +2 -2
- package/dist/cjs/receipt/layout.d.ts +5 -0
- package/dist/cjs/receipt/shift-sheet.d.ts +33 -0
- package/dist/cjs/receipt/shift-sheet.js +207 -0
- package/dist/cjs/register/errors.d.ts +1 -1
- package/dist/cjs/register/errors.js +2 -0
- package/dist/cjs/stored/draht.d.ts +1 -1
- package/dist/cjs/stored/draht.js +4 -3
- package/dist/cjs/stored/einstellungen.js +26 -3
- package/dist/cjs/stored/vokabular.d.ts +1 -1
- package/dist/cjs/stored/vokabular.js +118 -12
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/client/aufrufe.d.ts +5 -5
- package/dist/esm/client/aufrufe.js +22 -2
- package/dist/esm/client/errors.js +2 -0
- package/dist/esm/client/receipts.d.ts +34 -1
- package/dist/esm/client/receipts.js +35 -2
- package/dist/esm/client/reports.d.ts +4 -4
- package/dist/esm/client/reports.js +4 -4
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/inventory/vertrag.d.ts +1 -1
- package/dist/esm/inventory/vertrag.js +2 -0
- package/dist/esm/invoice/vertrag.d.ts +1 -1
- package/dist/esm/invoice/vertrag.js +2 -0
- package/dist/esm/models/cancellation.d.ts +49 -1
- package/dist/esm/models/cancellation.js +132 -0
- package/dist/esm/models/index.d.ts +1 -1
- package/dist/esm/models/index.js +1 -1
- package/dist/esm/models/payment-errors.d.ts +1 -1
- package/dist/esm/models/payment-errors.js +2 -0
- package/dist/esm/models/receipt-email.d.ts +1 -1
- package/dist/esm/models/receipt-email.js +2 -0
- package/dist/esm/models/receipt-errors.d.ts +1 -1
- package/dist/esm/models/receipt-errors.js +2 -0
- package/dist/esm/models/receipt-item.d.ts +10 -0
- package/dist/esm/models/receipt-item.js +3 -0
- package/dist/esm/pos/client.js +11 -1
- package/dist/esm/pos/errors.d.ts +4 -3
- package/dist/esm/pos/errors.js +21 -2
- package/dist/esm/pos/index.d.ts +6 -2
- package/dist/esm/pos/index.js +7 -2
- package/dist/esm/pos/schicht-lesen.d.ts +39 -0
- package/dist/esm/pos/schicht-lesen.js +392 -0
- package/dist/esm/pos/schicht-typen.d.ts +380 -0
- package/dist/esm/pos/schicht-typen.js +56 -0
- package/dist/esm/pos/schicht.d.ts +208 -0
- package/dist/esm/pos/schicht.js +222 -0
- package/dist/esm/pos/settings.d.ts +37 -1
- package/dist/esm/pos/settings.js +40 -2
- package/dist/esm/pos/texte.d.ts +627 -0
- package/dist/esm/pos/texte.js +236 -0
- package/dist/esm/react/index.js +1 -1
- package/dist/esm/receipt/grid.js +2 -2
- package/dist/esm/receipt/layout.d.ts +5 -0
- package/dist/esm/receipt/shift-sheet.d.ts +33 -0
- package/dist/esm/receipt/shift-sheet.js +203 -0
- package/dist/esm/register/errors.d.ts +1 -1
- package/dist/esm/register/errors.js +2 -0
- package/dist/esm/stored/draht.d.ts +1 -1
- package/dist/esm/stored/draht.js +4 -3
- package/dist/esm/stored/einstellungen.js +27 -4
- package/dist/esm/stored/vokabular.d.ts +1 -1
- package/dist/esm/stored/vokabular.js +118 -12
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/fixtures/cancellation-tip-cases.json +679 -0
- package/fixtures/expected/cash-movement.grid32.txt +15 -0
- package/fixtures/expected/cash-movement.grid48.txt +15 -0
- package/fixtures/expected/cash-movement.lines.json +171 -0
- package/fixtures/expected/shift-close-blind.grid32.txt +28 -0
- package/fixtures/expected/shift-close-blind.grid48.txt +27 -0
- package/fixtures/expected/shift-close-blind.lines.json +275 -0
- package/fixtures/expected/shift-close-put-in.grid32.txt +38 -0
- package/fixtures/expected/shift-close-put-in.grid48.txt +35 -0
- package/fixtures/expected/shift-close-put-in.lines.json +403 -0
- package/fixtures/expected/shift-close-take-out.grid32.txt +38 -0
- package/fixtures/expected/shift-close-take-out.grid48.txt +35 -0
- package/fixtures/expected/shift-close-take-out.lines.json +403 -0
- package/fixtures/expected/shift-close.grid32.txt +37 -0
- package/fixtures/expected/shift-close.grid48.txt +35 -0
- package/fixtures/expected/shift-close.lines.json +413 -0
- package/fixtures/expected/shift-interim.grid32.txt +28 -0
- package/fixtures/expected/shift-interim.grid48.txt +27 -0
- package/fixtures/expected/shift-interim.lines.json +293 -0
- package/fixtures/hobex-hps-codes.json +1 -1
- package/fixtures/invoice-api.schema.json +1 -1
- package/fixtures/invoice-texts.json +1 -1
- package/fixtures/pos-message-cases.json +45 -0
- package/fixtures/pos-texts.json +723 -1
- package/fixtures/receipt-due-generated.json +1 -1
- package/fixtures/shift-cases.json +87 -0
- package/fixtures/shift-receipts.json +41 -0
- package/fixtures/surface.json +119 -3
- package/fixtures/v3/antworten/belege.json +1 -1
- package/fixtures/v3/antworten/belegmail.json +1 -1
- package/fixtures/v3/antworten/kasse-belege.json +1 -1
- package/fixtures/v3/antworten/kasse.json +10874 -4865
- package/fixtures/v3/antworten/lager.json +1 -1
- package/fixtures/v3/antworten/rechnungen.json +1 -1
- package/fixtures/v3/antworten/storno.json +1 -1
- package/fixtures/v3/stored/belege.json +18 -6
- package/fixtures/v3/stored/kasse.json +4667 -183
- package/fixtures/v3/stored/rechnungen.json +1 -1
- package/fixtures/v3/v3-vokabular.json +739 -32
- package/fixtures/v3/zahlbetrag-faelle.json +1 -1
- 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
|
|
@@ -297,6 +297,7 @@ export const INVENTORY_ERROR_CODES = [
|
|
|
297
297
|
*/
|
|
298
298
|
export const INVENTORY_REQUEST_ERROR_CODES = [
|
|
299
299
|
'account_not_found',
|
|
300
|
+
'action_confirmation_required',
|
|
300
301
|
'admin_required',
|
|
301
302
|
'api_not_approved',
|
|
302
303
|
'app_check_invalid',
|
|
@@ -316,6 +317,7 @@ export const INVENTORY_REQUEST_ERROR_CODES = [
|
|
|
316
317
|
'register_user_not_allowed',
|
|
317
318
|
'register_user_not_found',
|
|
318
319
|
'response_translation_failed',
|
|
320
|
+
'second_factor_required',
|
|
319
321
|
'session_expired',
|
|
320
322
|
'session_other_cashregister',
|
|
321
323
|
'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"];
|
|
@@ -88,6 +88,7 @@ export const INVOICE_ERROR_CODES = [
|
|
|
88
88
|
*/
|
|
89
89
|
export const INVOICE_REQUEST_ERROR_CODES = [
|
|
90
90
|
'account_not_found',
|
|
91
|
+
'action_confirmation_required',
|
|
91
92
|
'admin_required',
|
|
92
93
|
'api_not_approved',
|
|
93
94
|
'app_check_invalid',
|
|
@@ -107,6 +108,7 @@ export const INVOICE_REQUEST_ERROR_CODES = [
|
|
|
107
108
|
'register_user_not_allowed',
|
|
108
109
|
'register_user_not_found',
|
|
109
110
|
'response_translation_failed',
|
|
111
|
+
'second_factor_required',
|
|
110
112
|
'session_expired',
|
|
111
113
|
'session_other_cashregister',
|
|
112
114
|
'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,4 +1,5 @@
|
|
|
1
1
|
import { bekannterCode, feldfehlerVon } from '../client/fehlercodes.js';
|
|
2
|
+
import { isTipItem } from './receipt-item.js';
|
|
2
3
|
/**
|
|
3
4
|
* Storno-Metadaten — Zwilling von `functions/storno-core.js`.
|
|
4
5
|
*
|
|
@@ -75,8 +76,14 @@ export const CANCELLATION_ERROR_CODES = Object.freeze([
|
|
|
75
76
|
'cancellation_refund_reference_unknown', // refundOf nennt keine Zahlung des Originals
|
|
76
77
|
'cancellation_outcome_unknown', // Ausgang unklar: nachlesen, nie wiederholen
|
|
77
78
|
'invalid_return_disposition', // Rueckgabe-Wahl nicht restock, defective oder disposed (Lager)
|
|
79
|
+
// Trinkgeld beim Storno (refundTip/tipRefundSource, Schichten-Spec Nachtrag 5)
|
|
80
|
+
'tip_refund_conflict', // Wahl passt nicht zum Storno (Trinkgeld trotz Nein, Quelle ohne Trinkgeld)
|
|
81
|
+
'invalid_tip_refund_source', // tipRefundSource nicht drawer oder employee
|
|
82
|
+
'tip_refund_source_requires_cash', // eine Quelle nur, wenn das Bargeld des Stornos das Trinkgeld deckt
|
|
83
|
+
'tip_keep_not_possible_with_voucher', // refundTip false an einem Beleg mit Wertgutschein (das Trinkgeld geht mit)
|
|
78
84
|
// Anmeldung und Rand (errorCodes.auth ohne Partner-Zugang, errorCodes.edge)
|
|
79
85
|
'account_not_found',
|
|
86
|
+
'action_confirmation_required',
|
|
80
87
|
'admin_required',
|
|
81
88
|
'api_not_approved',
|
|
82
89
|
'app_check_invalid',
|
|
@@ -95,6 +102,7 @@ export const CANCELLATION_ERROR_CODES = Object.freeze([
|
|
|
95
102
|
'register_user_not_allowed',
|
|
96
103
|
'register_user_not_found',
|
|
97
104
|
'response_translation_failed',
|
|
105
|
+
'second_factor_required',
|
|
98
106
|
'session_expired',
|
|
99
107
|
'session_other_cashregister',
|
|
100
108
|
'unauthorized',
|
|
@@ -147,3 +155,127 @@ export function remainingQuantities(receipt, nowMs = Date.now()) {
|
|
|
147
155
|
export function cancellationFieldErrors(error) {
|
|
148
156
|
return feldfehlerVon(error);
|
|
149
157
|
}
|
|
158
|
+
// --- Trinkgeld beim Storno (Schichten-Spec, Nachtrag 5, R56–R58) --------------------------------
|
|
159
|
+
//
|
|
160
|
+
// Enthaelt ein Beleg noch nicht storniertes Mitarbeiter-Trinkgeld, fragt die Kasse „Trinkgeld auch
|
|
161
|
+
// zurueckgeben?“ (`refundTip`) und bei Barrueckgabe „Woher kommt das Trinkgeld zurueck?“
|
|
162
|
+
// (`tipRefundSource`). Die Regeln stehen hier, damit Web-Kasse und Kassen-App dasselbe fragen;
|
|
163
|
+
// Zwilling von functions/gemeinsam/storno-core.js (wunschMitTrinkgeld, trinkgeldQuelleAnwenden).
|
|
164
|
+
// Faelle mit dem Dart-Zwilling: fixtures/cancellation-tip-cases.json.
|
|
165
|
+
/**
|
|
166
|
+
* Woher das Trinkgeld beim Storno zurueckkommt: `drawer` – die Lade zahlt es aus („offen“ sinkt,
|
|
167
|
+
* kann negativ werden); `employee` – die Mitarbeiterin gibt es selbst („verdient“ und „schon
|
|
168
|
+
* genommen“ sinken, die Lade bleibt unberuehrt). Nur bei Barrueckgabe.
|
|
169
|
+
*/
|
|
170
|
+
export const TIP_REFUND_SOURCES = Object.freeze(['drawer', 'employee']);
|
|
171
|
+
export function isTipRefundSource(value) {
|
|
172
|
+
return typeof value === 'string' && TIP_REFUND_SOURCES.includes(value);
|
|
173
|
+
}
|
|
174
|
+
/** Barzahlarten -- Zwilling von `BAR_ZAHLARTEN` (functions/gemeinsam/tip-core.js). */
|
|
175
|
+
const BAR_ZAHLARTEN = ['cash', 'uberCash', 'boltCash'];
|
|
176
|
+
/** Zahlart als Nutzlast-Schluessel (Enum-Objekt oder Text). */
|
|
177
|
+
function zahlartWert(m) {
|
|
178
|
+
if (m !== null && typeof m === 'object' && typeof m.value === 'string')
|
|
179
|
+
return m.value;
|
|
180
|
+
return typeof m === 'string' ? m : '';
|
|
181
|
+
}
|
|
182
|
+
const istMitarbeiterTrinkgeld = (item) => isTipItem(item) && item.recipient?.owner !== true;
|
|
183
|
+
/**
|
|
184
|
+
* Hatte die Mitarbeiterin dieses Trinkgeld schon in der Hand (sofort erhalten, mit Empfaenger)?
|
|
185
|
+
* Ohne Merkmal (Altbestand) gilt wie im Backend: bar = erhalten, sonst nicht.
|
|
186
|
+
*/
|
|
187
|
+
function hatteSie(item, receipt) {
|
|
188
|
+
if (!item.recipient?.registerUserId)
|
|
189
|
+
return false;
|
|
190
|
+
if (typeof item.receivedImmediately === 'boolean')
|
|
191
|
+
return item.receivedImmediately;
|
|
192
|
+
return BAR_ZAHLARTEN.includes(zahlartWert(item.paymentMethod ?? receipt.paymentMethod));
|
|
193
|
+
}
|
|
194
|
+
/** Indizes des noch nicht stornierten Mitarbeiter-Trinkgelds mit ihrem Rest. */
|
|
195
|
+
function offenesTrinkgeld(receipt, nowMs) {
|
|
196
|
+
const rest = remainingQuantities(receipt, nowMs);
|
|
197
|
+
return receipt.items
|
|
198
|
+
.map((item, index) => ({ item, index, quantity: rest[index] ?? 0 }))
|
|
199
|
+
.filter(({ item, quantity }) => quantity > 0 && istMitarbeiterTrinkgeld(item))
|
|
200
|
+
.map(({ index, quantity }) => ({ index, quantity }));
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Noch nicht storniertes Mitarbeiter-Trinkgeld in Cent. Groesser 0 heisst: das Storno fragt
|
|
204
|
+
* „Trinkgeld auch zurueckgeben?“ (auch beim Teilstorno). Inhaber-Trinkgeld ist Umsatz und folgt
|
|
205
|
+
* der Ware -- dafuer gibt es keine Frage.
|
|
206
|
+
*/
|
|
207
|
+
export function openStaffTipCents(receipt, nowMs = Date.now()) {
|
|
208
|
+
return offenesTrinkgeld(receipt, nowMs).reduce((s, { index, quantity }) => s + quantity * (receipt.items[index]?.priceCents ?? 0), 0);
|
|
209
|
+
}
|
|
210
|
+
/** Traegt der Beleg einen Wertgutschein (verkauft oder eingeloest)? Zwilling von storno-core.hatWertgutschein. */
|
|
211
|
+
function hatWertgutschein(receipt) {
|
|
212
|
+
return (receipt.vouchers ?? []).some((v) => v != null && zahlartWert(v.type) === 'value');
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Fragt das Storno „Trinkgeld auch zurueckgeben?“ – nur bei noch offenem Mitarbeiter-Trinkgeld und
|
|
216
|
+
* ohne Wertgutschein am Beleg. Einen Wertgutschein spiegelt nur ein Storno, der alles nimmt; darum
|
|
217
|
+
* geht das Trinkgeld dort immer mit (der Server weist `refundTip: false` mit
|
|
218
|
+
* `tip_keep_not_possible_with_voucher` ab), die Kasse zeigt stattdessen
|
|
219
|
+
* `cancellation.tip_refunded_with_voucher` und sendet `refundTip: true`. Die Frage nach der Quelle
|
|
220
|
+
* bleibt ([asksTipRefundSource]).
|
|
221
|
+
*/
|
|
222
|
+
export function asksRefundTip(receipt, nowMs = Date.now()) {
|
|
223
|
+
return openStaffTipCents(receipt, nowMs) > 0 && !hatWertgutschein(receipt);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Die Positionen, die nach der Antwort auf „Trinkgeld auch zurueckgeben?“ hinausgehen -- dieselbe
|
|
227
|
+
* Regel wie im Backend. `items` fehlt = ganzer Beleg.
|
|
228
|
+
* - Ja: zum Teilstorno kommt das offene Trinkgeld dazu; der ganze Beleg bleibt `undefined`.
|
|
229
|
+
* - Nein: ohne das Mitarbeiter-Trinkgeld; der ganze Beleg wird zur Liste aller Restmengen ausser dem
|
|
230
|
+
* Trinkgeld (leer = nichts mehr zu stornieren). Ist kein Mitarbeiter-Trinkgeld mehr offen (keines
|
|
231
|
+
* oder schon storniert), bleibt der Wunsch, wie er ist – „Nein“ wirkt dann wie keine Wahl.
|
|
232
|
+
*/
|
|
233
|
+
export function cancellationItemsForTip(receipt, items, refundTip, nowMs = Date.now()) {
|
|
234
|
+
const trinkgeld = new Set(receipt.items.map((item, i) => (istMitarbeiterTrinkgeld(item) ? i : -1)).filter((i) => i >= 0));
|
|
235
|
+
if (trinkgeld.size === 0)
|
|
236
|
+
return items === undefined ? undefined : [...items];
|
|
237
|
+
if (refundTip) {
|
|
238
|
+
if (items === undefined)
|
|
239
|
+
return undefined;
|
|
240
|
+
const genannt = new Set(items.map((x) => x.index));
|
|
241
|
+
return [...items, ...offenesTrinkgeld(receipt, nowMs).filter((x) => !genannt.has(x.index))];
|
|
242
|
+
}
|
|
243
|
+
if (items !== undefined)
|
|
244
|
+
return items.filter((x) => !trinkgeld.has(x.index));
|
|
245
|
+
if (offenesTrinkgeld(receipt, nowMs).length === 0)
|
|
246
|
+
return undefined;
|
|
247
|
+
const rest = remainingQuantities(receipt, nowMs);
|
|
248
|
+
return rest.map((quantity, index) => ({ index, quantity })).filter((x) => x.quantity > 0 && !trinkgeld.has(x.index));
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Was dieses Storno bar zurueckgibt (positiv, Cent): mit Rueckzahlungen deren Barteil; ohne
|
|
252
|
+
* (der Server spiegelt die eine Zahlung des Originals) alles, wenn das Original bar bezahlt war.
|
|
253
|
+
* Bei mehr als einer Zahlung ohne Angabe 0: welcher Teil bar zurueckgeht, ist dann offen (ein
|
|
254
|
+
* Teilstorno verlangt ohnehin `payments`). Beide Kassen schicken bei mehr als einer Zahlung darum
|
|
255
|
+
* immer die Rueckzahlungen mit und rechnen hier mit ihnen.
|
|
256
|
+
*/
|
|
257
|
+
export function cancellationCashRefundCents(receipt, payments, dueCents) {
|
|
258
|
+
if (payments !== undefined) {
|
|
259
|
+
return payments.reduce((s, z) => (zahlartWert(z.method) === 'cash' ? s - z.amountCents : s), 0);
|
|
260
|
+
}
|
|
261
|
+
const zahlungen = receipt.payments ?? [];
|
|
262
|
+
if (zahlungen.length > 1)
|
|
263
|
+
return 0;
|
|
264
|
+
const methode = zahlungen.length === 1 ? zahlartWert(zahlungen[0].method) : zahlartWert(receipt.paymentMethod);
|
|
265
|
+
return methode === 'cash' ? dueCents : 0;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Fragt das Storno nach „Ja“ auch „Woher kommt das Trinkgeld zurueck?“ – nur, wenn das Bargeld des
|
|
269
|
+
* Stornos (`cashRefundCents`, siehe [cancellationCashRefundCents]) das offene Mitarbeiter-Trinkgeld
|
|
270
|
+
* deckt und die Mitarbeiterin wenigstens eines davon schon hatte. Bei Kartenrueckgabe geht es auf
|
|
271
|
+
* die Karte zurueck; ueber Lohn behaltenes Trinkgeld kommt immer aus der Lade.
|
|
272
|
+
*/
|
|
273
|
+
export function asksTipRefundSource(receipt, cashRefundCents, nowMs = Date.now()) {
|
|
274
|
+
// Ohne diese Frage (Karte) und mit `refundTip: true` gilt beim Server: aus der Lade, kein `direkt`.
|
|
275
|
+
const offen = offenesTrinkgeld(receipt, nowMs);
|
|
276
|
+
if (offen.length === 0)
|
|
277
|
+
return false;
|
|
278
|
+
if (!offen.some(({ index }) => hatteSie(receipt.items[index], receipt)))
|
|
279
|
+
return false;
|
|
280
|
+
return cashRefundCents >= openStaffTipCents(receipt, nowMs);
|
|
281
|
+
}
|
|
@@ -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';
|
package/dist/esm/models/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { toReceiptItemPayload, fromReceiptItemPayload, receiptItemTotalCents, receiptItemIsValid, negateReceiptItem, isTipItem, isDiscountItem, } from './receipt-item.js';
|
|
2
2
|
export { toVoucherPayload, fromVoucherPayload, voucherIsValid } from './voucher.js';
|
|
3
3
|
export { toReceiptPayload, fromReceiptPayload, readRegistrationInfo, receiptSubSumCents, receiptSumCents, } from './receipt.js';
|
|
4
|
-
export { RETURN_DISPOSITIONS, CANCELLATION_REASONS, CANCELLATION_STATUSES, CANCELLATION_ERROR_CODES, CANCELLATION_RESERVATION_MS, isCancellationReason, isReturnDisposition, isCancellationErrorCode, cancellationErrorCode, isCancellationError, cancellationFieldErrors, remainingQuantities, } from './cancellation.js';
|
|
4
|
+
export { RETURN_DISPOSITIONS, CANCELLATION_REASONS, CANCELLATION_STATUSES, CANCELLATION_ERROR_CODES, CANCELLATION_RESERVATION_MS, isCancellationReason, isReturnDisposition, isCancellationErrorCode, cancellationErrorCode, isCancellationError, cancellationFieldErrors, remainingQuantities, TIP_REFUND_SOURCES, isTipRefundSource, openStaffTipCents, cancellationItemsForTip, cancellationCashRefundCents, asksTipRefundSource, asksRefundTip, } from './cancellation.js';
|
|
5
5
|
export { fromReceiptPaymentPayload, toReceiptPaymentPayload, } from './receipt-payment.js';
|
|
6
6
|
export { PAYMENT_ERROR_CODES, isPaymentErrorCode, paymentErrorCode, isPaymentError, paymentFieldErrors } from './payment-errors.js';
|
|
7
7
|
export { RECEIPT_EMAIL_ERROR_CODES, RECEIPT_EMAIL_SEND_ERROR_CODES, RECEIPT_EMAIL_VIAS, isReceiptEmailErrorCode, receiptEmailErrorCode, isReceiptEmailError, receiptEmailFieldErrors, } from './receipt-email.js';
|
|
@@ -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;
|
|
@@ -40,6 +40,7 @@ export const PAYMENT_ERROR_CODES = Object.freeze([
|
|
|
40
40
|
'tip_conflict', // tip und payments[].tipCents zugleich
|
|
41
41
|
// Anmeldung und Rand (errorCodes.auth ohne Partner-Zugang, errorCodes.edge)
|
|
42
42
|
'account_not_found',
|
|
43
|
+
'action_confirmation_required',
|
|
43
44
|
'admin_required',
|
|
44
45
|
'api_not_approved',
|
|
45
46
|
'app_check_invalid',
|
|
@@ -59,6 +60,7 @@ export const PAYMENT_ERROR_CODES = Object.freeze([
|
|
|
59
60
|
'register_user_not_allowed',
|
|
60
61
|
'register_user_not_found',
|
|
61
62
|
'response_translation_failed',
|
|
63
|
+
'second_factor_required',
|
|
62
64
|
'session_expired',
|
|
63
65
|
'session_other_cashregister',
|
|
64
66
|
'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`. */
|
|
@@ -19,6 +19,7 @@ export const RECEIPT_EMAIL_ERROR_CODES = Object.freeze([
|
|
|
19
19
|
...RECEIPT_EMAIL_SEND_ERROR_CODES,
|
|
20
20
|
// Anmeldung und Rand (errorCodes.auth ohne Partner-Zugang, errorCodes.edge)
|
|
21
21
|
'account_not_found',
|
|
22
|
+
'action_confirmation_required',
|
|
22
23
|
'admin_required',
|
|
23
24
|
'api_not_approved',
|
|
24
25
|
'app_check_invalid',
|
|
@@ -38,6 +39,7 @@ export const RECEIPT_EMAIL_ERROR_CODES = Object.freeze([
|
|
|
38
39
|
'register_user_not_allowed',
|
|
39
40
|
'register_user_not_found',
|
|
40
41
|
'response_translation_failed',
|
|
42
|
+
'second_factor_required',
|
|
41
43
|
'session_expired',
|
|
42
44
|
'session_other_cashregister',
|
|
43
45
|
'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`. */
|
|
@@ -38,6 +38,7 @@ export const RECEIPT_ERROR_CODES = Object.freeze([
|
|
|
38
38
|
'validation',
|
|
39
39
|
// Anmeldung und Rand (errorCodes.auth ohne Partner-Zugang, errorCodes.edge)
|
|
40
40
|
'account_not_found',
|
|
41
|
+
'action_confirmation_required',
|
|
41
42
|
'admin_required',
|
|
42
43
|
'api_not_approved',
|
|
43
44
|
'app_check_invalid',
|
|
@@ -57,6 +58,7 @@ export const RECEIPT_ERROR_CODES = Object.freeze([
|
|
|
57
58
|
'register_user_not_allowed',
|
|
58
59
|
'register_user_not_found',
|
|
59
60
|
'response_translation_failed',
|
|
61
|
+
'second_factor_required',
|
|
60
62
|
'session_expired',
|
|
61
63
|
'session_other_cashregister',
|
|
62
64
|
'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 */
|
|
@@ -30,6 +30,8 @@ export function toReceiptItemPayload(item) {
|
|
|
30
30
|
nutzlast.paymentMethod = item.paymentMethod;
|
|
31
31
|
if (typeof item.receivedImmediately === 'boolean')
|
|
32
32
|
nutzlast.receivedImmediately = item.receivedImmediately;
|
|
33
|
+
if (item.keptByEmployee === true)
|
|
34
|
+
nutzlast.keptByEmployee = true;
|
|
33
35
|
}
|
|
34
36
|
// Rabatt-Kennzeichnung reist mit — sonst kaeme ein Storno dieser Position
|
|
35
37
|
// am Bon wieder als gewoehnliche Warenzeile mit "1 x" an.
|
|
@@ -75,6 +77,7 @@ export function fromReceiptItemPayload(payload) {
|
|
|
75
77
|
recipient: payload.recipient ?? null,
|
|
76
78
|
...(payload.paymentMethod != null ? { paymentMethod: payload.paymentMethod } : {}),
|
|
77
79
|
...(typeof payload.receivedImmediately === 'boolean' ? { receivedImmediately: payload.receivedImmediately } : {}),
|
|
80
|
+
...(payload.keptByEmployee === true ? { keptByEmployee: true } : {}),
|
|
78
81
|
}
|
|
79
82
|
: payload.kind === 'discount'
|
|
80
83
|
? { kind: 'discount' }
|
package/dist/esm/pos/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { KasseneckValidationError } from '../client/errors.js';
|
|
2
|
-
import { POS_BUSINESS_DEFAULTS, POS_DEVICE_DEFAULTS, POS_BUSINESS_VALUES, POS_DEVICE_VALUES, POS_SHORTCUT_ACTIONS, mergePosSettings, posShortcutConflict, _istAltwert0x, } from './settings.js';
|
|
2
|
+
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
3
|
/*
|
|
4
4
|
* Die Einstellungs-Aufrufe am Draht `/api/v3`: Parameter und Antwort heissen
|
|
5
5
|
* `business`/`device`, Schluessel und Werte englisch (Nachtrag §11.7.2).
|
|
@@ -132,6 +132,16 @@ function pruefeTeil(name, teil, block, standard, werte) {
|
|
|
132
132
|
throw new KasseneckValidationError(name, `${teil}: keine Einstellungen uebergeben`, 'request');
|
|
133
133
|
}
|
|
134
134
|
for (const [schluessel, wert] of gesendet) {
|
|
135
|
+
if (teil === 'device' && POS_DEVICE_OPTIONAL_FIELDS.includes(schluessel)) {
|
|
136
|
+
if (!_optionalerWert(wert, true))
|
|
137
|
+
throw new KasseneckValidationError(name, `${teil}.${schluessel}: Kennung oder null erwartet`, 'request');
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if (teil === 'business' && POS_BUSINESS_OPTIONAL_FIELDS.includes(schluessel)) {
|
|
141
|
+
if (typeof wert !== 'boolean')
|
|
142
|
+
throw new KasseneckValidationError(name, `${teil}.${schluessel}: true oder false erwartet`, 'request');
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
135
145
|
if (!Object.prototype.hasOwnProperty.call(standard, schluessel)) {
|
|
136
146
|
throw new KasseneckValidationError(name, `${teil}.${schluessel}: unbekanntes Feld`, 'request');
|
|
137
147
|
}
|
package/dist/esm/pos/errors.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
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`. */
|
package/dist/esm/pos/errors.js
CHANGED
|
@@ -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
|
|
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
|
|
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`).
|
|
@@ -22,25 +23,34 @@ import { KasseneckApiError } from '../client/errors.js';
|
|
|
22
23
|
*/
|
|
23
24
|
export const POS_ERROR_CODES = Object.freeze([
|
|
24
25
|
'account_not_found',
|
|
26
|
+
'action_confirmation_required',
|
|
25
27
|
'admin_required',
|
|
28
|
+
'after_count_not_permitted',
|
|
26
29
|
'api_not_approved',
|
|
27
30
|
'app_check_invalid',
|
|
28
31
|
'app_check_missing',
|
|
29
32
|
'article_not_found',
|
|
30
33
|
'article_not_in_scope',
|
|
31
34
|
'article_not_tracked',
|
|
35
|
+
'cash_movement_exceeds_balance',
|
|
32
36
|
'cashregister_not_assigned',
|
|
33
37
|
'cashregister_not_found',
|
|
34
38
|
'cashregister_token_invalid',
|
|
35
39
|
'cashregister_token_missing',
|
|
40
|
+
'comment_required',
|
|
36
41
|
'count_already_voided',
|
|
37
42
|
'count_not_found',
|
|
38
43
|
'device_not_found',
|
|
39
44
|
'dialect_mismatch',
|
|
45
|
+
'drawer_inactive',
|
|
46
|
+
'drawer_not_found',
|
|
40
47
|
'idempotency_conflict',
|
|
41
48
|
'idempotency_key_required',
|
|
42
49
|
'internal_translation_error',
|
|
50
|
+
'invalid_amount',
|
|
43
51
|
'invalid_cursor',
|
|
52
|
+
'invalid_denominations',
|
|
53
|
+
'invalid_movement_type',
|
|
44
54
|
'invalid_quantity',
|
|
45
55
|
'invalid_serial',
|
|
46
56
|
'live_not_enabled',
|
|
@@ -54,25 +64,34 @@ export const POS_ERROR_CODES = Object.freeze([
|
|
|
54
64
|
'module_inactive',
|
|
55
65
|
'not_found',
|
|
56
66
|
'not_permitted',
|
|
67
|
+
'note_required',
|
|
57
68
|
'password_change_required',
|
|
58
69
|
'print_job_not_found',
|
|
59
70
|
'print_layout_failed',
|
|
60
71
|
'printer_not_found',
|
|
72
|
+
'recount_exhausted',
|
|
61
73
|
'register_user_no_business',
|
|
62
74
|
'register_user_not_allowed',
|
|
63
75
|
'register_user_not_found',
|
|
64
76
|
'response_translation_failed',
|
|
77
|
+
'second_factor_required',
|
|
65
78
|
'serial_already_counted',
|
|
66
79
|
'serial_not_allowed',
|
|
67
80
|
'serial_required',
|
|
68
81
|
'server_error',
|
|
69
82
|
'session_expired',
|
|
70
83
|
'session_other_cashregister',
|
|
84
|
+
'shift_already_open',
|
|
85
|
+
'shift_closed',
|
|
86
|
+
'shift_mode_off',
|
|
87
|
+
'shift_not_open',
|
|
71
88
|
'stocktake_closed',
|
|
72
89
|
'stocktake_closing',
|
|
73
90
|
'stocktake_not_found',
|
|
74
91
|
'stocktake_not_open',
|
|
92
|
+
'tip_payout_exceeds_claim',
|
|
75
93
|
'too_many_counts',
|
|
94
|
+
'transfer_same_drawer',
|
|
76
95
|
'unauthorized',
|
|
77
96
|
'user_disabled',
|
|
78
97
|
'user_verification_failed',
|