@kreiseck/kasseneck-api 1.1.1 → 1.2.1
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 +67 -0
- package/README.md +70 -0
- package/dist/cjs/client/aufrufe.d.ts +5 -5
- package/dist/cjs/client/aufrufe.js +21 -2
- package/dist/cjs/client/errors.d.ts +1 -1
- package/dist/cjs/client/errors.js +2 -1
- package/dist/cjs/client/receipts.d.ts +9 -1
- package/dist/cjs/client/receipts.js +18 -3
- package/dist/cjs/client/transport.d.ts +3 -3
- package/dist/cjs/client/transport.js +2 -2
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +6 -3
- package/dist/cjs/invoice/index.d.ts +2 -2
- package/dist/cjs/invoice/index.js +3 -1
- package/dist/cjs/invoice/texte.d.ts +5 -5
- package/dist/cjs/invoice/texte.js +10 -10
- package/dist/cjs/invoice/typen.d.ts +13 -2
- package/dist/cjs/invoice/vertrag.d.ts +10 -1
- package/dist/cjs/invoice/vertrag.js +39 -2
- package/dist/cjs/models/cancellation.d.ts +14 -2
- package/dist/cjs/models/cancellation.js +15 -1
- package/dist/cjs/models/cashregister.d.ts +3 -0
- package/dist/cjs/models/cashregister.js +1 -0
- package/dist/cjs/models/index.d.ts +1 -1
- package/dist/cjs/models/index.js +4 -2
- package/dist/cjs/models/payment-errors.d.ts +1 -1
- package/dist/cjs/models/payment-errors.js +1 -0
- package/dist/cjs/models/receipt-email.d.ts +1 -1
- package/dist/cjs/models/receipt-email.js +1 -0
- package/dist/cjs/models/receipt-errors.d.ts +1 -1
- package/dist/cjs/models/receipt-errors.js +1 -0
- package/dist/cjs/models/receipt-item.d.ts +9 -0
- package/dist/cjs/models/receipt-item.js +5 -0
- package/dist/cjs/models/receipt.d.ts +1 -1
- package/dist/cjs/models/receipt.js +6 -1
- package/dist/cjs/pos/artikel.d.ts +14 -0
- package/dist/cjs/pos/artikel.js +13 -2
- package/dist/cjs/pos/errors.d.ts +3 -3
- package/dist/cjs/pos/errors.js +6 -2
- package/dist/cjs/pos/index.d.ts +5 -2
- package/dist/cjs/pos/index.js +13 -2
- package/dist/cjs/pos/lager.d.ts +95 -0
- package/dist/cjs/pos/lager.js +160 -0
- package/dist/cjs/register/errors.d.ts +1 -1
- package/dist/cjs/register/errors.js +1 -0
- package/dist/cjs/register/pairing.d.ts +27 -1
- package/dist/cjs/register/pairing.js +18 -1
- package/dist/cjs/stored/draht.d.ts +4 -2
- package/dist/cjs/stored/draht.js +46 -5
- package/dist/cjs/stored/vokabular.d.ts +1 -1
- package/dist/cjs/stored/vokabular.js +5 -3
- 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 +21 -2
- package/dist/esm/client/errors.d.ts +1 -1
- package/dist/esm/client/errors.js +2 -1
- package/dist/esm/client/receipts.d.ts +9 -1
- package/dist/esm/client/receipts.js +19 -4
- package/dist/esm/client/transport.d.ts +3 -3
- package/dist/esm/client/transport.js +2 -2
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/invoice/index.d.ts +2 -2
- package/dist/esm/invoice/index.js +1 -1
- package/dist/esm/invoice/texte.d.ts +5 -5
- package/dist/esm/invoice/texte.js +10 -10
- package/dist/esm/invoice/typen.d.ts +13 -2
- package/dist/esm/invoice/vertrag.d.ts +10 -1
- package/dist/esm/invoice/vertrag.js +38 -1
- package/dist/esm/models/cancellation.d.ts +14 -2
- package/dist/esm/models/cancellation.js +13 -0
- package/dist/esm/models/cashregister.d.ts +3 -0
- package/dist/esm/models/cashregister.js +1 -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 +1 -0
- package/dist/esm/models/receipt-email.d.ts +1 -1
- package/dist/esm/models/receipt-email.js +1 -0
- package/dist/esm/models/receipt-errors.d.ts +1 -1
- package/dist/esm/models/receipt-errors.js +1 -0
- package/dist/esm/models/receipt-item.d.ts +9 -0
- package/dist/esm/models/receipt-item.js +5 -0
- package/dist/esm/models/receipt.d.ts +1 -1
- package/dist/esm/models/receipt.js +6 -1
- package/dist/esm/pos/artikel.d.ts +14 -0
- package/dist/esm/pos/artikel.js +13 -3
- package/dist/esm/pos/errors.d.ts +3 -3
- package/dist/esm/pos/errors.js +6 -2
- package/dist/esm/pos/index.d.ts +5 -2
- package/dist/esm/pos/index.js +6 -2
- package/dist/esm/pos/lager.d.ts +95 -0
- package/dist/esm/pos/lager.js +154 -0
- package/dist/esm/register/errors.d.ts +1 -1
- package/dist/esm/register/errors.js +1 -0
- package/dist/esm/register/pairing.d.ts +27 -1
- package/dist/esm/register/pairing.js +17 -1
- package/dist/esm/stored/draht.d.ts +4 -2
- package/dist/esm/stored/draht.js +45 -4
- package/dist/esm/stored/vokabular.d.ts +1 -1
- package/dist/esm/stored/vokabular.js +5 -3
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/fixtures/hobex-hps-codes.json +1 -1
- package/fixtures/invoice-api-examples/cancel-error-return-disposition.json +17 -0
- package/fixtures/invoice-api-examples/credit-error-return-disposition.json +26 -0
- package/fixtures/invoice-api-examples/credit-return-disposition.json +23 -0
- package/fixtures/invoice-api-examples/issue-error-return-disposition.json +25 -0
- package/fixtures/invoice-api-examples/issue-error-stock-id.json +27 -0
- package/fixtures/invoice-api-examples/issue-stock.json +22 -0
- package/fixtures/invoice-api.schema.json +37 -1
- package/fixtures/invoice-texts.json +11 -11
- package/fixtures/pos-texts.json +1 -1
- package/fixtures/surface.json +48 -4
- 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 +662 -3
- package/fixtures/v3/antworten/rechnungen.json +1 -1
- package/fixtures/v3/antworten/storno.json +1 -1
- package/fixtures/v3/stored/belege.json +1 -1
- package/fixtures/v3/stored/kasse.json +58 -3
- package/fixtures/v3/stored/rechnungen.json +1 -1
- package/fixtures/v3/v3-vokabular.json +249 -16
- package/fixtures/v3/zahlbetrag-faelle.json +1 -1
- package/package.json +1 -1
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
* Beschrieben wird die Anfrage. Was der Server daraus macht — Rechnungsdatum,
|
|
18
18
|
* Nummer, Summen — ist bewusst **nicht** setzbar.
|
|
19
19
|
*/
|
|
20
|
+
import { RETURN_DISPOSITIONS } from '../models/cancellation.js';
|
|
21
|
+
export { RETURN_DISPOSITIONS };
|
|
20
22
|
export const INVOICE_CONTRACT_VERSION = 2;
|
|
21
23
|
export const INVOICE_ENDPOINTS = [
|
|
22
24
|
'createCustomer',
|
|
@@ -80,6 +82,7 @@ export const INVOICE_ERROR_CODES = [
|
|
|
80
82
|
export const INVOICE_REQUEST_ERROR_CODES = [
|
|
81
83
|
'account_not_found',
|
|
82
84
|
'admin_required',
|
|
85
|
+
'api_not_approved',
|
|
83
86
|
'cashregister_not_assigned',
|
|
84
87
|
'cashregister_not_found',
|
|
85
88
|
'cashregister_token_invalid',
|
|
@@ -418,6 +421,13 @@ export const ITEM_FIELDS = Object.freeze({
|
|
|
418
421
|
unitPriceMicros: { type: 'integer', required: false, min: 0, max: 1_000_000_000_000 },
|
|
419
422
|
vatRate: { type: 'enum', required: true, values: VAT_RATES },
|
|
420
423
|
discountPct: { type: 'number', required: false, min: 0, max: 100, decimals: 2 },
|
|
424
|
+
/**
|
|
425
|
+
* Artikel aus dem Artikelstamm (Lager-Kern Stufe 2): ist er bestandsgefuehrt
|
|
426
|
+
* und das Modul Lager aktiv, bucht das Ausstellen ihn ab -- danach, die
|
|
427
|
+
* Rechnung scheitert nie am Lager. Kein „/“, nicht „.“, „..“ oder „__…__“
|
|
428
|
+
* (prueft der Server, `validation`).
|
|
429
|
+
*/
|
|
430
|
+
articleId: id,
|
|
421
431
|
});
|
|
422
432
|
/** Genau einer der beiden Preise je Position (§ 9.1). */
|
|
423
433
|
export const ITEM_PRICE_EXACTLY_ONE = Object.freeze([
|
|
@@ -433,6 +443,23 @@ const positionen = {
|
|
|
433
443
|
type: 'object', required: true, fields: ITEM_FIELDS, exactlyOne: ITEM_PRICE_EXACTLY_ONE,
|
|
434
444
|
},
|
|
435
445
|
};
|
|
446
|
+
/** Rueckgabe-Wahl einer Gutschrift: Vorgabe des Aufrufs oder je Position. */
|
|
447
|
+
const returnDisposition = { type: 'enum', required: false, values: RETURN_DISPOSITIONS };
|
|
448
|
+
/**
|
|
449
|
+
* Eine Gutschriftsposition: die Rechnungsposition plus `returnDisposition`
|
|
450
|
+
* (wohin die zurueckgenommene Ware geht). An einer Rechnungsposition weist der
|
|
451
|
+
* Server das Feld als unbekannt ab.
|
|
452
|
+
*/
|
|
453
|
+
export const CREDIT_NOTE_ITEM_FIELDS = Object.freeze({ ...ITEM_FIELDS, returnDisposition });
|
|
454
|
+
const gutschriftPositionen = {
|
|
455
|
+
type: 'list',
|
|
456
|
+
required: true,
|
|
457
|
+
min: 1,
|
|
458
|
+
max: 500,
|
|
459
|
+
item: {
|
|
460
|
+
type: 'object', required: true, fields: CREDIT_NOTE_ITEM_FIELDS, exactlyOne: ITEM_PRICE_EXACTLY_ONE,
|
|
461
|
+
},
|
|
462
|
+
};
|
|
436
463
|
/**
|
|
437
464
|
* Eine Zahlung zu einer Rechnung. Ohne `amountCents` gilt der volle
|
|
438
465
|
* Bruttobetrag, ohne `paidAt` der heutige Wiener Tag. `reference` ist die
|
|
@@ -500,6 +527,12 @@ export const INVOICE_REQUESTS = Object.freeze({
|
|
|
500
527
|
language: { type: 'enum', required: false, values: INVOICE_LANGUAGES },
|
|
501
528
|
/** Marke (Kennung aus `listBrands`); sonst die Standardmarke. */
|
|
502
529
|
brandId: id,
|
|
530
|
+
/**
|
|
531
|
+
* Lager-Standort, von dem bestandsgefuehrte Positionen abgebucht werden;
|
|
532
|
+
* sonst der Standard-Standort. Ein unbekannter oder aufgeloester Standort
|
|
533
|
+
* bucht am Standard-Standort und meldet ein Ereignis im Lager.
|
|
534
|
+
*/
|
|
535
|
+
stockLocationId: id,
|
|
503
536
|
/**
|
|
504
537
|
* Schon bezahlt: die Zahlung entsteht in **derselben** Transaktion wie das
|
|
505
538
|
* Festschreiben. Sonst gaebe es einen Moment, in dem die Rechnung offen ist
|
|
@@ -518,13 +551,17 @@ export const INVOICE_REQUESTS = Object.freeze({
|
|
|
518
551
|
invoiceId: idPflicht,
|
|
519
552
|
reason: { type: 'enum', required: true, values: CREDIT_NOTE_REASONS },
|
|
520
553
|
note: text(2000),
|
|
554
|
+
/** Fuer alle bestandsgefuehrten Positionen; fehlt = `restock`. */
|
|
555
|
+
returnDisposition,
|
|
521
556
|
},
|
|
522
557
|
createCreditNote: {
|
|
523
558
|
idempotencyKey: idempotencyKey(true),
|
|
524
559
|
invoiceId: idPflicht,
|
|
525
560
|
reason: { type: 'enum', required: true, values: CREDIT_NOTE_REASONS },
|
|
526
561
|
note: text(2000),
|
|
527
|
-
items:
|
|
562
|
+
items: gutschriftPositionen,
|
|
563
|
+
/** Vorgabe fuer alle Positionen; je Position abweichend ueber `items[].returnDisposition`. */
|
|
564
|
+
returnDisposition,
|
|
528
565
|
},
|
|
529
566
|
getInvoice: {
|
|
530
567
|
invoiceId: id,
|
|
@@ -23,6 +23,16 @@ export declare const CANCELLATION_REASONS: Readonly<{
|
|
|
23
23
|
}>;
|
|
24
24
|
export type CancellationReason = keyof typeof CANCELLATION_REASONS;
|
|
25
25
|
export declare function isCancellationReason(value: unknown): value is CancellationReason;
|
|
26
|
+
/**
|
|
27
|
+
* Rueckgabe-Wahl beim Storno und bei der Gutschrift (Lager-Kern Stufe 2,
|
|
28
|
+
* Katalog `RUECKGABE` des Backends): `restock` zurueck ins Lager (Vorgabe des
|
|
29
|
+
* Servers), `defective` als defekt ins Lager, `disposed` entsorgt. Wirkt nur
|
|
30
|
+
* an Positionen mit `articleId`; alle anderen bucht der Server nie und meldet
|
|
31
|
+
* dafuer auch keinen Fehler.
|
|
32
|
+
*/
|
|
33
|
+
export declare const RETURN_DISPOSITIONS: readonly ["restock", "defective", "disposed"];
|
|
34
|
+
export type ReturnDisposition = (typeof RETURN_DISPOSITIONS)[number];
|
|
35
|
+
export declare function isReturnDisposition(value: unknown): value is ReturnDisposition;
|
|
26
36
|
/**
|
|
27
37
|
* Stabile Fehlercodes von `cancelReceipt` unter `/v3` (Vokabular
|
|
28
38
|
* `errorCodes.cancellation`, gleiche Reihenfolge). Das Backend legt sie bei
|
|
@@ -43,7 +53,7 @@ export declare function isCancellationReason(value: unknown): value is Cancellat
|
|
|
43
53
|
* [PAYMENT_ERROR_CODES]. Ein Code ausserhalb bleibt ueber
|
|
44
54
|
* `KasseneckApiError.code` lesbar.
|
|
45
55
|
*/
|
|
46
|
-
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", "account_not_found", "admin_required", "cashregister_not_found", "cashregister_token_invalid", "cashregister_token_missing", "dialect_mismatch", "internal_translation_error", "live_not_enabled", "method_not_allowed", "mfa_required", "not_found", "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"];
|
|
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", "cashregister_not_found", "cashregister_token_invalid", "cashregister_token_missing", "dialect_mismatch", "internal_translation_error", "live_not_enabled", "method_not_allowed", "mfa_required", "not_found", "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"];
|
|
47
57
|
export type CancellationErrorCode = (typeof CANCELLATION_ERROR_CODES)[number];
|
|
48
58
|
export declare function isCancellationErrorCode(value: unknown): value is CancellationErrorCode;
|
|
49
59
|
/** Der Code eines geworfenen Fehlers, wenn er in [CANCELLATION_ERROR_CODES] steht; sonst `undefined`. */
|
|
@@ -67,10 +77,12 @@ export interface CancellationOf {
|
|
|
67
77
|
*/
|
|
68
78
|
timeStamp?: string;
|
|
69
79
|
}
|
|
70
|
-
/** Eine stornierte Position: Index im Original und Menge. */
|
|
80
|
+
/** Eine stornierte Position: Index im Original und Menge, an Artikelzeilen die Rueckgabe-Wahl. */
|
|
71
81
|
export interface CancellationItem {
|
|
72
82
|
index: number;
|
|
73
83
|
quantity: number;
|
|
84
|
+
/** Wohin die Ware dieser Position geht; fehlt = Vorgabe des Aufrufs bzw. `restock`. */
|
|
85
|
+
returnDisposition?: ReturnDisposition;
|
|
74
86
|
}
|
|
75
87
|
/**
|
|
76
88
|
* Eintrag in `cancellations[]` am Original. `pending` = Reservierung, die
|
|
@@ -23,6 +23,17 @@ export const CANCELLATION_REASONS = Object.freeze({
|
|
|
23
23
|
export function isCancellationReason(value) {
|
|
24
24
|
return typeof value === 'string' && Object.prototype.hasOwnProperty.call(CANCELLATION_REASONS, value);
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Rueckgabe-Wahl beim Storno und bei der Gutschrift (Lager-Kern Stufe 2,
|
|
28
|
+
* Katalog `RUECKGABE` des Backends): `restock` zurueck ins Lager (Vorgabe des
|
|
29
|
+
* Servers), `defective` als defekt ins Lager, `disposed` entsorgt. Wirkt nur
|
|
30
|
+
* an Positionen mit `articleId`; alle anderen bucht der Server nie und meldet
|
|
31
|
+
* dafuer auch keinen Fehler.
|
|
32
|
+
*/
|
|
33
|
+
export const RETURN_DISPOSITIONS = Object.freeze(['restock', 'defective', 'disposed']);
|
|
34
|
+
export function isReturnDisposition(value) {
|
|
35
|
+
return typeof value === 'string' && RETURN_DISPOSITIONS.includes(value);
|
|
36
|
+
}
|
|
26
37
|
/**
|
|
27
38
|
* Stabile Fehlercodes von `cancelReceipt` unter `/v3` (Vokabular
|
|
28
39
|
* `errorCodes.cancellation`, gleiche Reihenfolge). Das Backend legt sie bei
|
|
@@ -63,9 +74,11 @@ export const CANCELLATION_ERROR_CODES = Object.freeze([
|
|
|
63
74
|
'cancellation_refund_reference_required', // Karten-Rueckzahlung ohne refundOf einer Kartenzahlung
|
|
64
75
|
'cancellation_refund_reference_unknown', // refundOf nennt keine Zahlung des Originals
|
|
65
76
|
'cancellation_outcome_unknown', // Ausgang unklar: nachlesen, nie wiederholen
|
|
77
|
+
'invalid_return_disposition', // Rueckgabe-Wahl nicht restock, defective oder disposed (Lager)
|
|
66
78
|
// Anmeldung und Rand (errorCodes.auth ohne Partner-Zugang, errorCodes.edge)
|
|
67
79
|
'account_not_found',
|
|
68
80
|
'admin_required',
|
|
81
|
+
'api_not_approved',
|
|
69
82
|
'cashregister_not_found',
|
|
70
83
|
'cashregister_token_invalid',
|
|
71
84
|
'cashregister_token_missing',
|
|
@@ -36,6 +36,8 @@ export interface Cashregister {
|
|
|
36
36
|
token?: string;
|
|
37
37
|
/** Zugeordnete Signatureinheit. */
|
|
38
38
|
signatureId?: string;
|
|
39
|
+
/** Lager-Standort der Kasse (Lager-Kern Stufe 2); fehlt = Standard-Standort des Betriebs. */
|
|
40
|
+
stockLocationId?: string;
|
|
39
41
|
onboarding: CashregisterOnboarding;
|
|
40
42
|
}
|
|
41
43
|
/**
|
|
@@ -58,6 +60,7 @@ export interface CashregisterPayload {
|
|
|
58
60
|
description?: string | null;
|
|
59
61
|
create_time?: string | null;
|
|
60
62
|
signature_id?: string | null;
|
|
63
|
+
stockLocationId?: string | null;
|
|
61
64
|
token?: string | null;
|
|
62
65
|
onboarding?: CashregisterOnboardingPayload | null;
|
|
63
66
|
}
|
|
@@ -13,6 +13,7 @@ export function fromCashregisterPayload(payload, id) {
|
|
|
13
13
|
...zeitfeld('createTime', payload.create_time),
|
|
14
14
|
...(payload.token ? { token: payload.token } : {}),
|
|
15
15
|
...(payload.signature_id ? { signatureId: payload.signature_id } : {}),
|
|
16
|
+
...(payload.stockLocationId ? { stockLocationId: payload.stockLocationId } : {}),
|
|
16
17
|
onboarding: {
|
|
17
18
|
cashboxRegistered: ob.cashbox_registered === true,
|
|
18
19
|
startReceiptCreated: ob.start_receipt_created === true,
|
|
@@ -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, CANCELLATION_REASONS, CANCELLATION_STATUSES, CANCELLATION_ERROR_CODES, CANCELLATION_RESERVATION_MS, isCancellationReason, 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, } 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 { CANCELLATION_REASONS, CANCELLATION_STATUSES, CANCELLATION_ERROR_CODES, CANCELLATION_RESERVATION_MS, isCancellationReason, 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, } 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", "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", "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", "admin_required", "api_not_approved", "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", "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"];
|
|
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;
|
|
@@ -41,6 +41,7 @@ export const PAYMENT_ERROR_CODES = Object.freeze([
|
|
|
41
41
|
// Anmeldung und Rand (errorCodes.auth ohne Partner-Zugang, errorCodes.edge)
|
|
42
42
|
'account_not_found',
|
|
43
43
|
'admin_required',
|
|
44
|
+
'api_not_approved',
|
|
44
45
|
'cashregister_not_assigned',
|
|
45
46
|
'cashregister_not_found',
|
|
46
47
|
'cashregister_token_invalid',
|
|
@@ -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", "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", "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", "admin_required", "api_not_approved", "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", "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"];
|
|
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`. */
|
|
@@ -20,6 +20,7 @@ export const RECEIPT_EMAIL_ERROR_CODES = Object.freeze([
|
|
|
20
20
|
// Anmeldung und Rand (errorCodes.auth ohne Partner-Zugang, errorCodes.edge)
|
|
21
21
|
'account_not_found',
|
|
22
22
|
'admin_required',
|
|
23
|
+
'api_not_approved',
|
|
23
24
|
'cashregister_not_assigned',
|
|
24
25
|
'cashregister_not_found',
|
|
25
26
|
'cashregister_token_invalid',
|
|
@@ -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", "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", "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", "admin_required", "api_not_approved", "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", "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"];
|
|
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`. */
|
|
@@ -39,6 +39,7 @@ export const RECEIPT_ERROR_CODES = Object.freeze([
|
|
|
39
39
|
// Anmeldung und Rand (errorCodes.auth ohne Partner-Zugang, errorCodes.edge)
|
|
40
40
|
'account_not_found',
|
|
41
41
|
'admin_required',
|
|
42
|
+
'api_not_approved',
|
|
42
43
|
'cashregister_not_assigned',
|
|
43
44
|
'cashregister_not_found',
|
|
44
45
|
'cashregister_token_invalid',
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { VatRate } from '../enums/index.js';
|
|
2
|
+
import { type ReturnDisposition } from './cancellation.js';
|
|
2
3
|
/**
|
|
3
4
|
* Belegposition — Zwilling von `KasseneckItem` in
|
|
4
5
|
* kasseneck_api/lib/models/kasseneck_item.dart.
|
|
@@ -50,6 +51,10 @@ export interface ReceiptItem {
|
|
|
50
51
|
* im Bericht. Optional; Handeingaben haben keinen.
|
|
51
52
|
*/
|
|
52
53
|
articleId?: string;
|
|
54
|
+
/** Nur an Storno-Zeilen mit `articleId`: Index der Position im Original. */
|
|
55
|
+
originalIndex?: number;
|
|
56
|
+
/** Nur an Storno-Zeilen mit `articleId`: wohin die Ware ging (Lager-Kern Stufe 2). */
|
|
57
|
+
returnDisposition?: ReturnDisposition;
|
|
53
58
|
}
|
|
54
59
|
/** Empfaenger einer Trinkgeld-Position (Kassen-Benutzer, Snapshot des Namens). */
|
|
55
60
|
export interface TipRecipient {
|
|
@@ -117,6 +122,10 @@ export interface ReceiptItemPayloadRead {
|
|
|
117
122
|
vat?: number | null;
|
|
118
123
|
/** Artikel-Verweis, siehe [ReceiptItem.articleId]. */
|
|
119
124
|
articleId?: string | null;
|
|
125
|
+
/** Storno-Zeile mit `articleId`: Index im Original, siehe [ReceiptItem.originalIndex]. */
|
|
126
|
+
originalIndex?: number | null;
|
|
127
|
+
/** Storno-Zeile mit `articleId`: Rueckgabe-Wahl, siehe [ReceiptItem.returnDisposition]. */
|
|
128
|
+
returnDisposition?: string | null;
|
|
120
129
|
}
|
|
121
130
|
export declare function toReceiptItemPayload(item: ReceiptItem): ReceiptItemPayload;
|
|
122
131
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { VatRate } from '../enums/index.js';
|
|
2
2
|
import { readVatRateByRate, requireVatRateByRate } from './enum-payload.js';
|
|
3
|
+
import { isReturnDisposition } from './cancellation.js';
|
|
3
4
|
/** Trinkgeld-Position? Die eine Erkennungsstelle — niemand prueft `kind` selbst. */
|
|
4
5
|
export function isTipItem(item) {
|
|
5
6
|
return item != null && item.kind === 'tip';
|
|
@@ -80,6 +81,10 @@ export function fromReceiptItemPayload(payload) {
|
|
|
80
81
|
: {}),
|
|
81
82
|
// Artikel-Verweis erhalten (Storno-Spiegelung schreibt ihn wieder mit).
|
|
82
83
|
...(typeof payload.articleId === 'string' && payload.articleId !== '' ? { articleId: payload.articleId } : {}),
|
|
84
|
+
// Lager: Bezug und Rueckgabe-Wahl einer Storno-Zeile (nur gelesen; ein
|
|
85
|
+
// unbekannter Wert faellt weg wie am Rand des Servers).
|
|
86
|
+
...(Number.isInteger(payload.originalIndex) && payload.originalIndex >= 0 ? { originalIndex: payload.originalIndex } : {}),
|
|
87
|
+
...(isReturnDisposition(payload.returnDisposition) ? { returnDisposition: payload.returnDisposition } : {}),
|
|
83
88
|
};
|
|
84
89
|
}
|
|
85
90
|
/** Erster brauchbarer Zahlenwert der Reihe; `null`/`undefined`/NaN zaehlen nicht. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReceiptType, KeckPaymentMethod, CreditCardProvider } from '../enums/index.js';
|
|
2
2
|
import { type ReceiptItem, type ReceiptItemPayload, type ReceiptItemPayloadRead } from './receipt-item.js';
|
|
3
3
|
import { type Voucher, type VoucherPayload } from './voucher.js';
|
|
4
|
-
import type
|
|
4
|
+
import { type Cancellation, type CancellationOf, type CancellationReason } from './cancellation.js';
|
|
5
5
|
import { type ZeroKind } from './receipt-summary.js';
|
|
6
6
|
import { type ReceiptPayment, type ReceiptPaymentPayload } from './receipt-payment.js';
|
|
7
7
|
/**
|
|
@@ -2,6 +2,7 @@ import { ReceiptType, KeckPaymentMethod, CreditCardProvider, VoucherAction, Vouc
|
|
|
2
2
|
import { readEnumKey, requireEnumKey } from './enum-payload.js';
|
|
3
3
|
import { toReceiptItemPayload, fromReceiptItemPayload, receiptItemTotalCents, } from './receipt-item.js';
|
|
4
4
|
import { toVoucherPayload, fromVoucherPayload } from './voucher.js';
|
|
5
|
+
import { isReturnDisposition } from './cancellation.js';
|
|
5
6
|
import { isZeroKind } from './receipt-summary.js';
|
|
6
7
|
import { fromReceiptPaymentPayload, toReceiptPaymentPayload } from './receipt-payment.js';
|
|
7
8
|
/**
|
|
@@ -100,7 +101,11 @@ function leseStorno(eintrag) {
|
|
|
100
101
|
at: Number(eintrag.at ?? 0),
|
|
101
102
|
by: eintrag.by ?? null,
|
|
102
103
|
note: eintrag.note ?? null,
|
|
103
|
-
items: (eintrag.items ?? []).map((p) => ({
|
|
104
|
+
items: (eintrag.items ?? []).map((p) => ({
|
|
105
|
+
index: Number(p.index),
|
|
106
|
+
quantity: Number(p.quantity),
|
|
107
|
+
...(isReturnDisposition(p.returnDisposition) ? { returnDisposition: p.returnDisposition } : {}),
|
|
108
|
+
})),
|
|
104
109
|
...(eintrag.promoAdjustmentCents && typeof eintrag.promoAdjustmentCents === 'object'
|
|
105
110
|
? { promoAdjustmentCents: Object.fromEntries(Object.entries(eintrag.promoAdjustmentCents).map(([k, v]) => [k, Number(v)])) }
|
|
106
111
|
: {}),
|
|
@@ -64,6 +64,14 @@ export interface PosArticle {
|
|
|
64
64
|
askQuantity: boolean | null;
|
|
65
65
|
/** Hoechstmenge je Beleg (bei kg/l/m auch Kommazahl); null = keine Grenze. */
|
|
66
66
|
maxQuantity: number | null;
|
|
67
|
+
/**
|
|
68
|
+
* Standorte, an denen der Artikel gefuehrt wird (Lager-Kern Stufe 2, innen
|
|
69
|
+
* `standorte`); `null`, wenn der Artikel keine Angabe traegt. Wie die Kasse
|
|
70
|
+
* daraus Kacheln filtert, entscheidet die Oberflaeche. Optional, damit
|
|
71
|
+
* bestehende Literale von Verbrauchern weiter uebersetzen; der Leser
|
|
72
|
+
* (`fromPosArticlePayload`) setzt das Feld immer (`null` oder Liste).
|
|
73
|
+
*/
|
|
74
|
+
stockLocationIds?: string[] | null;
|
|
67
75
|
}
|
|
68
76
|
/** Deckelt eine gewuenschte Menge an der Hoechstmenge des Artikels (null = keine Grenze). */
|
|
69
77
|
export declare function allowedQuantity(a: Pick<PosArticle, 'maxQuantity'>, wanted: number): number;
|
|
@@ -84,7 +92,13 @@ export interface PosArticlePayload {
|
|
|
84
92
|
quantityRule?: string | null;
|
|
85
93
|
askQuantity?: boolean | null;
|
|
86
94
|
maxQuantity?: number | null;
|
|
95
|
+
stockLocationIds?: string[] | null;
|
|
87
96
|
}
|
|
88
97
|
export declare function fromPosArticlePayload(p: PosArticlePayload): PosArticle;
|
|
98
|
+
/**
|
|
99
|
+
* Die Liste `data.<feld>` einer Antwort, jedes Element durch `lesen` (mit
|
|
100
|
+
* seinem Index fuer Fehlermeldungen). Paketintern: auch `lager.ts` liest so.
|
|
101
|
+
*/
|
|
102
|
+
export declare function liste<T>(daten: unknown, feld: string, name: string, lesen: (e: unknown, index: number) => T): T[];
|
|
89
103
|
export declare function listMyArticleGroups(transport: InternerTransport): Promise<ArticleGroup[]>;
|
|
90
104
|
export declare function listMyArticles(transport: InternerTransport): Promise<PosArticle[]>;
|
package/dist/esm/pos/artikel.js
CHANGED
|
@@ -60,14 +60,24 @@ export function fromPosArticlePayload(p) {
|
|
|
60
60
|
quantityRule: p.quantityRule === 'piece' || p.quantityRule === 'decimal' ? p.quantityRule : null,
|
|
61
61
|
askQuantity: typeof p.askQuantity === 'boolean' ? p.askQuantity : null,
|
|
62
62
|
maxQuantity: typeof p.maxQuantity === 'number' && Number.isFinite(p.maxQuantity) && p.maxQuantity > 0 ? p.maxQuantity : null,
|
|
63
|
+
stockLocationIds: Array.isArray(p.stockLocationIds)
|
|
64
|
+
? p.stockLocationIds.filter((s) => typeof s === 'string' && s !== '')
|
|
65
|
+
: null,
|
|
63
66
|
};
|
|
64
67
|
}
|
|
65
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Die Liste `data.<feld>` einer Antwort, jedes Element durch `lesen` (mit
|
|
70
|
+
* seinem Index fuer Fehlermeldungen). Paketintern: auch `lager.ts` liest so.
|
|
71
|
+
*/
|
|
72
|
+
export function liste(daten, feld, name, lesen) {
|
|
66
73
|
const roh = daten?.[feld];
|
|
67
74
|
if (!Array.isArray(roh)) {
|
|
68
|
-
|
|
75
|
+
const grund = roh === undefined || roh === null
|
|
76
|
+
? `Antwort enthaelt keine Liste (data.${feld} fehlt)`
|
|
77
|
+
: `Antwort ist unbrauchbar (data.${feld} ist keine Liste)`;
|
|
78
|
+
throw new KasseneckValidationError(name, grund, 'response');
|
|
69
79
|
}
|
|
70
|
-
return roh.map((e) => lesen(typeof e === 'object' && e !== null ? e : {}));
|
|
80
|
+
return roh.map((e, i) => lesen(typeof e === 'object' && e !== null ? e : {}, i));
|
|
71
81
|
}
|
|
72
82
|
export async function listMyArticleGroups(transport) {
|
|
73
83
|
const daten = await transport('listMyArticleGroups');
|
package/dist/esm/pos/errors.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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) auswerten: am `code`, nie am Text.
|
|
4
|
+
* Artikel, Drucker, Trinkgeld-Empfaenger, Lager) auswerten: am `code`, nie am Text.
|
|
5
5
|
* Belege, Storno und Belegmail haben eigene Listen (`RECEIPT_ERROR_CODES`,
|
|
6
6
|
* `CANCELLATION_ERROR_CODES`, `RECEIPT_EMAIL_ERROR_CODES`), die Anmeldung
|
|
7
7
|
* `REGISTER_ERROR_CODES` im Unterpfad `./register`.
|
|
8
8
|
*
|
|
9
|
-
* Abgeleitet aus dem Vertrags-Export (Fehlerfaelle dieser
|
|
9
|
+
* Abgeleitet aus dem Vertrags-Export (Fehlerfaelle dieser dreizehn Endpunkte in
|
|
10
10
|
* `fixtures/v3/antworten/kasse.json` und ihre Handler-Codes); ein Test haelt
|
|
11
11
|
* die Liste deckungsgleich. `validation` traegt `data.errors[]` mit dem
|
|
12
12
|
* aeusseren Feldpfad (`business.theme`, `device.shortcuts.splitPayment`).
|
|
@@ -19,7 +19,7 @@ import { KasseneckApiError } from '../client/errors.js';
|
|
|
19
19
|
* ueber `KasseneckApiError.code` lesbar; die Kasse braucht dafuer einen
|
|
20
20
|
* Rueckfallzweig.
|
|
21
21
|
*/
|
|
22
|
-
export declare const POS_ERROR_CODES: readonly ["account_not_found", "admin_required", "cashregister_not_assigned", "cashregister_not_found", "cashregister_token_invalid", "cashregister_token_missing", "device_not_found", "dialect_mismatch", "internal_translation_error", "live_not_enabled", "logo_invalid", "logo_invalid_type", "logo_too_large", "method_not_allowed", "mfa_required", "module_inactive", "not_found", "not_permitted", "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", "session_expired", "session_other_cashregister", "unauthorized", "user_disabled", "user_verification_failed", "validation", "route_missing"];
|
|
22
|
+
export declare const POS_ERROR_CODES: readonly ["account_not_found", "admin_required", "api_not_approved", "cashregister_not_assigned", "cashregister_not_found", "cashregister_token_invalid", "cashregister_token_missing", "device_not_found", "dialect_mismatch", "internal_translation_error", "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", "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", "server_error", "session_expired", "session_other_cashregister", "unauthorized", "user_disabled", "user_verification_failed", "validation", "route_missing"];
|
|
23
23
|
export type PosErrorCode = typeof POS_ERROR_CODES[number];
|
|
24
24
|
export declare function isPosErrorCode(value: unknown): value is PosErrorCode;
|
|
25
25
|
/** Der Code eines geworfenen Fehlers, wenn er in [POS_ERROR_CODES] steht; sonst `undefined`. */
|
package/dist/esm/pos/errors.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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) auswerten: am `code`, nie am Text.
|
|
4
|
+
* Artikel, Drucker, Trinkgeld-Empfaenger, Lager) auswerten: am `code`, nie am Text.
|
|
5
5
|
* Belege, Storno und Belegmail haben eigene Listen (`RECEIPT_ERROR_CODES`,
|
|
6
6
|
* `CANCELLATION_ERROR_CODES`, `RECEIPT_EMAIL_ERROR_CODES`), die Anmeldung
|
|
7
7
|
* `REGISTER_ERROR_CODES` im Unterpfad `./register`.
|
|
8
8
|
*
|
|
9
|
-
* Abgeleitet aus dem Vertrags-Export (Fehlerfaelle dieser
|
|
9
|
+
* Abgeleitet aus dem Vertrags-Export (Fehlerfaelle dieser dreizehn Endpunkte in
|
|
10
10
|
* `fixtures/v3/antworten/kasse.json` und ihre Handler-Codes); ein Test haelt
|
|
11
11
|
* die Liste deckungsgleich. `validation` traegt `data.errors[]` mit dem
|
|
12
12
|
* aeusseren Feldpfad (`business.theme`, `device.shortcuts.splitPayment`).
|
|
@@ -22,6 +22,7 @@ import { KasseneckApiError } from '../client/errors.js';
|
|
|
22
22
|
export const POS_ERROR_CODES = Object.freeze([
|
|
23
23
|
'account_not_found',
|
|
24
24
|
'admin_required',
|
|
25
|
+
'api_not_approved',
|
|
25
26
|
'cashregister_not_assigned',
|
|
26
27
|
'cashregister_not_found',
|
|
27
28
|
'cashregister_token_invalid',
|
|
@@ -30,6 +31,8 @@ export const POS_ERROR_CODES = Object.freeze([
|
|
|
30
31
|
'dialect_mismatch',
|
|
31
32
|
'internal_translation_error',
|
|
32
33
|
'live_not_enabled',
|
|
34
|
+
'location_inactive',
|
|
35
|
+
'location_not_found',
|
|
33
36
|
'logo_invalid',
|
|
34
37
|
'logo_invalid_type',
|
|
35
38
|
'logo_too_large',
|
|
@@ -45,6 +48,7 @@ export const POS_ERROR_CODES = Object.freeze([
|
|
|
45
48
|
'register_user_not_allowed',
|
|
46
49
|
'register_user_not_found',
|
|
47
50
|
'response_translation_failed',
|
|
51
|
+
'server_error',
|
|
48
52
|
'session_expired',
|
|
49
53
|
'session_other_cashregister',
|
|
50
54
|
'unauthorized',
|
package/dist/esm/pos/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Kachel-Kasse: Einstellungen, Artikelgruppen/Artikel fuer Kacheln,
|
|
3
|
-
* Rabattverteilung, Drucker, Trinkgeld-Empfaenger
|
|
3
|
+
* Rabattverteilung, Drucker, Trinkgeld-Empfaenger, Lager (Standorte, Bestand,
|
|
4
|
+
* Standort der Kasse). Die Aufrufe heissen 1:1 wie
|
|
4
5
|
* die Backend-Functions (die Rewrites-Waechter der Web-App leiten daraus ab)
|
|
5
6
|
* und sprechen den Kassenweg `/api/v3` (Schluessel und Werte englisch).
|
|
6
7
|
*/
|
|
@@ -9,7 +10,9 @@ export { type ArticleGroup, type ArticleGroupPayload, fromArticleGroupPayload, t
|
|
|
9
10
|
export { getPosSettings, setMyPosSettings, setMyRegisterDeviceSettings, setMyPosLogo, posSettingsFromWire, type SetMyPosLogoOptions, } from './client.js';
|
|
10
11
|
export { POS_ERROR_CODES, type PosErrorCode, isPosErrorCode, posErrorCode, isPosError, type PosFieldError, posFieldErrors, } from './errors.js';
|
|
11
12
|
export { distributeDiscount } from '../receipt/discount.js';
|
|
12
|
-
export { cancelScopeOf, receiptsScopeOf, type RegisterScope, type RegisterUserPerms } from '../register/pairing.js';
|
|
13
|
+
export { cancelScopeOf, receiptsScopeOf, stockViewOf, type RegisterScope, type RegisterUserPerms } from '../register/pairing.js';
|
|
13
14
|
export { type NetworkPrinter, type PrintJob, type PrintJobStatus, PRINT_JOB_STATUSES, type PrintJobSource, PRINT_JOB_SOURCES, isPrintJobFinished, type CreatePrintJobOptions, listMyPrinters, createPrintJob, getPrintJob, } from './drucker.js';
|
|
14
15
|
export { listMyTipRecipients } from './trinkgeld.js';
|
|
16
|
+
export { STOCK_LOCATION_TYPES, type StockLocationType, type StockLocation, type StockLocationAddress, type StockLevel, type StockValue, type StockList, type ListMyStockOptions, type SetMyCashregisterStockLocationOptions, type CashregisterStockLocation, listMyStockLocations, listMyStock, setMyCashregisterStockLocation, } from './lager.js';
|
|
17
|
+
export { RETURN_DISPOSITIONS, isReturnDisposition, type ReturnDisposition } from '../models/cancellation.js';
|
|
15
18
|
export { MESSAGES, ERROR_RULES, ERROR_CODE_RULES, ERROR_OUTCOME_RULES, CALLS_WITH_EFFECT, findErrorRule, messageOutcome, messageText, messageAppliesTo, RECEIPT_EMAIL_ERROR_MESSAGES, receiptEmailErrorMessage, CANCELLATION_PAYMENT_ERROR_MESSAGES, cancellationPaymentErrorMessage, LABELS, labelText, type TextEntry, type MessageKey, type ErrorKind, type ErrorRule, type ErrorRuleDetail, type Surface, type ReceiptEmailMessageCode, type CancellationPaymentMessageCode, type LabelKey, } from './texte.js';
|
package/dist/esm/pos/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Kachel-Kasse: Einstellungen, Artikelgruppen/Artikel fuer Kacheln,
|
|
3
|
-
* Rabattverteilung, Drucker, Trinkgeld-Empfaenger
|
|
3
|
+
* Rabattverteilung, Drucker, Trinkgeld-Empfaenger, Lager (Standorte, Bestand,
|
|
4
|
+
* Standort der Kasse). Die Aufrufe heissen 1:1 wie
|
|
4
5
|
* die Backend-Functions (die Rewrites-Waechter der Web-App leiten daraus ab)
|
|
5
6
|
* und sprechen den Kassenweg `/api/v3` (Schluessel und Werte englisch).
|
|
6
7
|
*/
|
|
@@ -13,8 +14,11 @@ export { POS_ERROR_CODES, isPosErrorCode, posErrorCode, isPosError, posFieldErro
|
|
|
13
14
|
export { distributeDiscount } from '../receipt/discount.js';
|
|
14
15
|
// Reichweiten der Kassen-Rechte (Migration wie im Backend) -- bewusst NICHT im
|
|
15
16
|
// Register-Unterpfad: dessen Exportnamen sind 1:1 Function-Namen (Rewrites).
|
|
16
|
-
export { cancelScopeOf, receiptsScopeOf } from '../register/pairing.js';
|
|
17
|
+
export { cancelScopeOf, receiptsScopeOf, stockViewOf } from '../register/pairing.js';
|
|
17
18
|
export { PRINT_JOB_STATUSES, PRINT_JOB_SOURCES, isPrintJobFinished, listMyPrinters, createPrintJob, getPrintJob, } from './drucker.js';
|
|
18
19
|
export { listMyTipRecipients } from './trinkgeld.js';
|
|
20
|
+
export { STOCK_LOCATION_TYPES, listMyStockLocations, listMyStock, setMyCashregisterStockLocation, } from './lager.js';
|
|
21
|
+
// Rueckgabe-Wahl beim Storno (Kassen-Dialog); dieselbe Liste wie an der Wurzel.
|
|
22
|
+
export { RETURN_DISPOSITIONS, isReturnDisposition } from '../models/cancellation.js';
|
|
19
23
|
// Was die Kasse selbst sagt: ein Katalog fuer Browser-Kasse und App.
|
|
20
24
|
export { MESSAGES, ERROR_RULES, ERROR_CODE_RULES, ERROR_OUTCOME_RULES, CALLS_WITH_EFFECT, findErrorRule, messageOutcome, messageText, messageAppliesTo, RECEIPT_EMAIL_ERROR_MESSAGES, receiptEmailErrorMessage, CANCELLATION_PAYMENT_ERROR_MESSAGES, cancellationPaymentErrorMessage, LABELS, labelText, } from './texte.js';
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { InternerTransport } from '../client/aufrufe.js';
|
|
2
|
+
/**
|
|
3
|
+
* Lager an der Kasse (Lager-Kern Stufe 2, Backend lager-endpoints.js):
|
|
4
|
+
* Standorte, Bestand und der Standort der Kasse. Alle drei Aufrufe gibt es
|
|
5
|
+
* nur ueber den Kassenweg `/api/v3` (registerInternal); Rechte am Server:
|
|
6
|
+
* `stockView` (lesen), `stockCosts` (Werte), `stockLocation` (Standort setzen).
|
|
7
|
+
*
|
|
8
|
+
* **Ganzzahlen:** Mengen sind Tausendstel der Basiseinheit (`1000` = 1 Stueck,
|
|
9
|
+
* `250` = 0,250 kg), Werte ganze Cent bzw. Mikro-Euro. Nichts wird geteilt,
|
|
10
|
+
* gerundet oder geklemmt -- ein negativer Bestand (mehr verkauft als gebucht)
|
|
11
|
+
* ist eine Aussage des Servers und bleibt negativ. Eine Zahl, die keine
|
|
12
|
+
* Ganzzahl ist, oder eine fehlende Menge wird **nie** zu `0`: der Aufruf
|
|
13
|
+
* endet mit `KasseneckValidationError` (`scope: 'response'`), denn „kein
|
|
14
|
+
* Bestand“ und „Antwort kaputt“ sind verschiedene Aussagen.
|
|
15
|
+
*/
|
|
16
|
+
/** Standort-Typen (Katalog `STANDORT_TYP`), englisch wie am Draht. */
|
|
17
|
+
export declare const STOCK_LOCATION_TYPES: readonly ["warehouse", "store", "vehicle", "other"];
|
|
18
|
+
export type StockLocationType = (typeof STOCK_LOCATION_TYPES)[number];
|
|
19
|
+
export interface StockLocationAddress {
|
|
20
|
+
street: string | null;
|
|
21
|
+
zip: string | null;
|
|
22
|
+
city: string | null;
|
|
23
|
+
country: string | null;
|
|
24
|
+
}
|
|
25
|
+
export interface StockLocation {
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
/** `null`: ein Typ, den dieses Paket nicht kennt. */
|
|
29
|
+
type: StockLocationType | null;
|
|
30
|
+
/** Fahrzeuge haben keine Adresse. */
|
|
31
|
+
address: StockLocationAddress | null;
|
|
32
|
+
/** Kennzeichen, nur bei `vehicle`. */
|
|
33
|
+
licensePlate: string | null;
|
|
34
|
+
/** `false` = aufgeloest; als Standort der Kasse abgewiesen (`location_inactive`). */
|
|
35
|
+
active: boolean;
|
|
36
|
+
/** `true` = Hauptstandort, den der Server ohne eigenes Dokument ergaenzt. */
|
|
37
|
+
virtual: boolean;
|
|
38
|
+
}
|
|
39
|
+
/** Bestand eines Artikels an einem Standort, in Tausendstel der Basiseinheit. */
|
|
40
|
+
export interface StockLevel {
|
|
41
|
+
articleId: string;
|
|
42
|
+
locationId: string;
|
|
43
|
+
sellable: number;
|
|
44
|
+
defective: number;
|
|
45
|
+
reserved: number;
|
|
46
|
+
/** `sellable - reserved`, vom Server gerechnet. */
|
|
47
|
+
available: number;
|
|
48
|
+
}
|
|
49
|
+
/** Lagerwert eines Artikels -- nur mit dem Recht `stockCosts`. */
|
|
50
|
+
export interface StockValue {
|
|
51
|
+
articleId: string;
|
|
52
|
+
stockValueCents: number;
|
|
53
|
+
/** Durchschnittlicher Einstandspreis je Basiseinheit in Mikro-Euro; `null` bei Menge 0. */
|
|
54
|
+
averageCostMicros: number | null;
|
|
55
|
+
}
|
|
56
|
+
export interface StockList {
|
|
57
|
+
stock: StockLevel[];
|
|
58
|
+
/**
|
|
59
|
+
* `null`, wenn der Aufrufer das Recht `stockCosts` nicht hat (der Server
|
|
60
|
+
* laesst das Feld weg); `[]`, wenn er es hat und nichts bewertet ist. Eine
|
|
61
|
+
* Oberflaeche zeigt bei `null` keinen Wert, nie „0,00 €“.
|
|
62
|
+
*/
|
|
63
|
+
values: StockValue[] | null;
|
|
64
|
+
}
|
|
65
|
+
export interface ListMyStockOptions {
|
|
66
|
+
/** Nur dieser Standort; `''` gilt wie nicht angegeben. */
|
|
67
|
+
locationId?: string;
|
|
68
|
+
/** Nur dieser Artikel; `''` gilt wie nicht angegeben. */
|
|
69
|
+
articleId?: string;
|
|
70
|
+
/** Nur Zeilen unter dem Mindestbestand. */
|
|
71
|
+
belowMinimum?: boolean;
|
|
72
|
+
}
|
|
73
|
+
export interface SetMyCashregisterStockLocationOptions {
|
|
74
|
+
/** Standort-Kennung; `null` setzt auf den Standard-Standort des Betriebs zurueck. */
|
|
75
|
+
stockLocationId: string | null;
|
|
76
|
+
/** Ohne Angabe gilt die Kasse der Anmeldung (`registerUserAuth`). */
|
|
77
|
+
cashregisterId?: string;
|
|
78
|
+
}
|
|
79
|
+
export interface CashregisterStockLocation {
|
|
80
|
+
cashregisterId: string;
|
|
81
|
+
/** `null` = Standard-Standort des Betriebs. */
|
|
82
|
+
stockLocationId: string | null;
|
|
83
|
+
}
|
|
84
|
+
/** Standorte des Betriebs, samt aufgeloesten (`active: false`) und dem Hauptstandort. */
|
|
85
|
+
export declare function listMyStockLocations(transport: InternerTransport): Promise<StockLocation[]>;
|
|
86
|
+
/** Bestand je Artikel und Standort; Werte nur mit dem Recht `stockCosts`. */
|
|
87
|
+
export declare function listMyStock(transport: InternerTransport, options?: ListMyStockOptions): Promise<StockList>;
|
|
88
|
+
/**
|
|
89
|
+
* Standort der Kasse setzen -- von dort bucht der Server Verkauf und Storno
|
|
90
|
+
* ab. `stockLocationId: null` setzt zurueck (am Draht der leere Text).
|
|
91
|
+
* Fehler am Code: `location_not_found`, `location_inactive`,
|
|
92
|
+
* `cashregister_not_found`, `cashregister_not_assigned`, `not_permitted`,
|
|
93
|
+
* `module_inactive`.
|
|
94
|
+
*/
|
|
95
|
+
export declare function setMyCashregisterStockLocation(transport: InternerTransport, options: SetMyCashregisterStockLocationOptions): Promise<CashregisterStockLocation>;
|