@kreiseck/kasseneck-api 1.7.1 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/CHANGELOG.md +106 -0
  2. package/README.md +170 -1
  3. package/dist/cjs/client/aufrufe.d.ts +9 -7
  4. package/dist/cjs/client/aufrufe.js +57 -2
  5. package/dist/cjs/client/errors.js +2 -0
  6. package/dist/cjs/client/index.d.ts +1 -1
  7. package/dist/cjs/client/index.js +2 -1
  8. package/dist/cjs/client/transport.d.ts +27 -3
  9. package/dist/cjs/client/transport.js +29 -3
  10. package/dist/cjs/index.d.ts +1 -1
  11. package/dist/cjs/index.js +3 -2
  12. package/dist/cjs/inventory/api.d.ts +21 -2
  13. package/dist/cjs/inventory/api.js +22 -3
  14. package/dist/cjs/inventory/fehler.d.ts +6 -0
  15. package/dist/cjs/inventory/fehler.js +12 -0
  16. package/dist/cjs/inventory/index.d.ts +6 -4
  17. package/dist/cjs/inventory/index.js +33 -3
  18. package/dist/cjs/inventory/inventur.d.ts +104 -0
  19. package/dist/cjs/inventory/inventur.js +245 -0
  20. package/dist/cjs/inventory/lesen.d.ts +20 -1
  21. package/dist/cjs/inventory/lesen.js +307 -0
  22. package/dist/cjs/inventory/typen.d.ts +410 -1
  23. package/dist/cjs/inventory/vertrag.d.ts +94 -8
  24. package/dist/cjs/inventory/vertrag.js +117 -5
  25. package/dist/cjs/invoice/vertrag.d.ts +1 -1
  26. package/dist/cjs/invoice/vertrag.js +2 -0
  27. package/dist/cjs/models/cancellation.d.ts +1 -1
  28. package/dist/cjs/models/cancellation.js +2 -0
  29. package/dist/cjs/models/payment-errors.d.ts +1 -1
  30. package/dist/cjs/models/payment-errors.js +2 -0
  31. package/dist/cjs/models/receipt-email.d.ts +1 -1
  32. package/dist/cjs/models/receipt-email.js +2 -0
  33. package/dist/cjs/models/receipt-errors.d.ts +1 -1
  34. package/dist/cjs/models/receipt-errors.js +2 -0
  35. package/dist/cjs/pos/errors.d.ts +4 -3
  36. package/dist/cjs/pos/errors.js +23 -2
  37. package/dist/cjs/pos/index.d.ts +4 -1
  38. package/dist/cjs/pos/index.js +9 -2
  39. package/dist/cjs/pos/inventur.d.ts +104 -0
  40. package/dist/cjs/pos/inventur.js +117 -0
  41. package/dist/cjs/pos/texte.d.ts +82 -0
  42. package/dist/cjs/pos/texte.js +35 -0
  43. package/dist/cjs/register/errors.d.ts +1 -1
  44. package/dist/cjs/register/errors.js +2 -0
  45. package/dist/cjs/stored/vokabular.d.ts +1 -1
  46. package/dist/cjs/stored/vokabular.js +1 -1
  47. package/dist/cjs/version.d.ts +1 -1
  48. package/dist/cjs/version.js +1 -1
  49. package/dist/esm/client/aufrufe.d.ts +9 -7
  50. package/dist/esm/client/aufrufe.js +57 -2
  51. package/dist/esm/client/errors.js +2 -0
  52. package/dist/esm/client/index.d.ts +1 -1
  53. package/dist/esm/client/index.js +1 -1
  54. package/dist/esm/client/transport.d.ts +27 -3
  55. package/dist/esm/client/transport.js +28 -3
  56. package/dist/esm/index.d.ts +1 -1
  57. package/dist/esm/index.js +1 -1
  58. package/dist/esm/inventory/api.d.ts +21 -2
  59. package/dist/esm/inventory/api.js +23 -4
  60. package/dist/esm/inventory/fehler.d.ts +6 -0
  61. package/dist/esm/inventory/fehler.js +11 -0
  62. package/dist/esm/inventory/index.d.ts +6 -4
  63. package/dist/esm/inventory/index.js +5 -3
  64. package/dist/esm/inventory/inventur.d.ts +104 -0
  65. package/dist/esm/inventory/inventur.js +226 -0
  66. package/dist/esm/inventory/lesen.d.ts +20 -1
  67. package/dist/esm/inventory/lesen.js +301 -0
  68. package/dist/esm/inventory/typen.d.ts +410 -1
  69. package/dist/esm/inventory/vertrag.d.ts +94 -8
  70. package/dist/esm/inventory/vertrag.js +116 -4
  71. package/dist/esm/invoice/vertrag.d.ts +1 -1
  72. package/dist/esm/invoice/vertrag.js +2 -0
  73. package/dist/esm/models/cancellation.d.ts +1 -1
  74. package/dist/esm/models/cancellation.js +2 -0
  75. package/dist/esm/models/payment-errors.d.ts +1 -1
  76. package/dist/esm/models/payment-errors.js +2 -0
  77. package/dist/esm/models/receipt-email.d.ts +1 -1
  78. package/dist/esm/models/receipt-email.js +2 -0
  79. package/dist/esm/models/receipt-errors.d.ts +1 -1
  80. package/dist/esm/models/receipt-errors.js +2 -0
  81. package/dist/esm/pos/errors.d.ts +4 -3
  82. package/dist/esm/pos/errors.js +23 -2
  83. package/dist/esm/pos/index.d.ts +4 -1
  84. package/dist/esm/pos/index.js +2 -1
  85. package/dist/esm/pos/inventur.d.ts +104 -0
  86. package/dist/esm/pos/inventur.js +109 -0
  87. package/dist/esm/pos/texte.d.ts +82 -0
  88. package/dist/esm/pos/texte.js +35 -0
  89. package/dist/esm/register/errors.d.ts +1 -1
  90. package/dist/esm/register/errors.js +2 -0
  91. package/dist/esm/stored/vokabular.d.ts +1 -1
  92. package/dist/esm/stored/vokabular.js +1 -1
  93. package/dist/esm/version.d.ts +1 -1
  94. package/dist/esm/version.js +1 -1
  95. package/fixtures/hobex-hps-codes.json +1 -1
  96. package/fixtures/invoice-api.schema.json +1 -1
  97. package/fixtures/invoice-texts.json +1 -1
  98. package/fixtures/pos-texts.json +94 -1
  99. package/fixtures/stocktake-quantity-cases.json +55 -0
  100. package/fixtures/surface.json +151 -8
  101. package/fixtures/v3/antworten/belege.json +1 -1
  102. package/fixtures/v3/antworten/belegmail.json +1 -1
  103. package/fixtures/v3/antworten/kasse-belege.json +1 -1
  104. package/fixtures/v3/antworten/kasse.json +2958 -3
  105. package/fixtures/v3/antworten/lager.json +1727 -3
  106. package/fixtures/v3/antworten/rechnungen.json +1 -1
  107. package/fixtures/v3/antworten/storno.json +1 -1
  108. package/fixtures/v3/stored/belege.json +1 -1
  109. package/fixtures/v3/stored/kasse.json +414 -3
  110. package/fixtures/v3/stored/rechnungen.json +1 -1
  111. package/fixtures/v3/v3-vokabular.json +475 -8
  112. package/fixtures/v3/zahlbetrag-faelle.json +1 -1
  113. package/package.json +1 -1
@@ -1,17 +1,19 @@
1
1
  /**
2
2
  * Der Vertrag der Lager-API (Backend Stufe 5a lesen, 5b schreiben und
3
- * reservieren, 5c Varianten) als Daten: Endpunkte, Wertkataloge, Ereignisse, Fehler- und
4
- * Hinweiscodes, englisch wie am Draht `/v3`.
3
+ * reservieren, 5c Varianten, Lager-Kern Stufe 3 Inventur) als Daten:
4
+ * Endpunkte, Wertkataloge, Ereignisse, Fehler- und Hinweiscodes, englisch wie
5
+ * am Draht `/v3`.
5
6
  *
6
7
  * Quelle ist der Vertrags-Export des Backends (`fixtures/v3/v3-vokabular.json`):
7
8
  * `endpoints.public`, die Kataloge `STANDORT_TYP`, `BEWEGUNG_ART`,
8
9
  * `BEWEGUNG_QUELLE`, `LAGER_ZUSTAND`, `LAGER_URSACHE`, `ZUSTELLUNG`,
9
10
  * `LAGER_ABGANG_GRUND`, `LAGER_ENTNAHME_ART`, `LAGER_NEBENKOSTEN_ART`,
10
- * `LAGER_VERTEILUNG`, `RESERVIERUNG_STATUS`, dazu `events`, `errorCodes.inventory`
11
+ * `LAGER_VERTEILUNG`, `RESERVIERUNG_STATUS`, die Inventur-Kataloge `INVENTUR_*`,
12
+ * dazu `events`, `errorCodes.inventory`
11
13
  * und `warningCodes.inventory`. `test/inventory.test.ts` haelt jede Liste
12
14
  * deckungsgleich mit dieser Datei; nichts hier wird geraten.
13
15
  */
14
- /** Die 32 Endpunkte (14 aus 5a, 13 aus 5b, 5 aus 5c), in der Reihenfolge von `endpoints.public`. */
16
+ /** Die 44 Endpunkte (14 aus 5a, 13 aus 5b, 5 aus 5c, 12 der Inventur), in der Reihenfolge von `endpoints.public`. */
15
17
  export const INVENTORY_ENDPOINTS = [
16
18
  'getArticle',
17
19
  'listArticles',
@@ -45,6 +47,18 @@ export const INVENTORY_ENDPOINTS = [
45
47
  'getVariantGroup',
46
48
  'listVariantGroups',
47
49
  'addVariant',
50
+ 'createStocktake',
51
+ 'listStocktakes',
52
+ 'getStocktake',
53
+ 'listStocktakeItems',
54
+ 'recordStocktakeCount',
55
+ 'voidStocktakeCount',
56
+ 'listStocktakeCounts',
57
+ 'reviewStocktake',
58
+ 'recountStocktake',
59
+ 'closeStocktake',
60
+ 'cancelStocktake',
61
+ 'getStocktakePdf',
48
62
  ];
49
63
  /** Art eines Standorts (Katalog `STANDORT_TYP`). */
50
64
  export const LOCATION_TYPES = ['warehouse', 'store', 'vehicle', 'other'];
@@ -174,6 +188,22 @@ export const INVENTORY_LIST_LIMIT_MAX = 200;
174
188
  * `too_many_positions` traegt bei Varianten `field` (`variants`,
175
189
  * `createMatrix` bzw. `externalIds` bei `addVariant`): die Anfrage braeuchte
176
190
  * mehr Schreibvorgaenge, als in einen Vorgang passen; geschrieben wurde nichts.
191
+ *
192
+ * Seit 1.8.0 dahinter die Codes der Inventur: `stocktake_not_found`,
193
+ * `stocktake_not_open` (Zaehlen oder Stornieren ausserhalb der Zaehlung bzw.
194
+ * an einer Position, die nicht zum Nachzaehlen frei ist), `stocktake_closed`
195
+ * (abgeschlossen oder abgebrochen: nichts mehr schreibbar),
196
+ * `stocktake_not_in_review` (Nachzaehlen und Abschluss nur in `review`),
197
+ * `stocktake_closing` (der Abschluss bucht gerade), `stocktake_location_busy`
198
+ * (am Standort laeuft schon eine Inventur; `data.stocktakeId` nennt sie),
199
+ * `stocktake_review_running` (die Pruefung rechnet noch), `stocktake_recount_open`
200
+ * (Abschluss, solange Positionen zum Nachzaehlen offen sind: erst nachzaehlen,
201
+ * dann erneut pruefen), `article_not_in_scope`, `article_not_tracked`,
202
+ * `count_not_found`, `count_already_voided`, `serial_already_counted` (dieselbe
203
+ * Seriennummer zweimal in einer Runde), `too_many_counts` (mehr als
204
+ * [STOCKTAKE_COUNTS_PER_ITEM_MAX] Zaehlungen je Position und Runde) und
205
+ * `stocktake_not_closed` (das Protokoll gibt es erst nach dem Abschluss, auch
206
+ * nicht fuer eine abgebrochene Inventur).
177
207
  */
178
208
  export const INVENTORY_ERROR_CODES = [
179
209
  'validation',
@@ -242,6 +272,21 @@ export const INVENTORY_ERROR_CODES = [
242
272
  'invalid_variant_attributes',
243
273
  'variant_group_inactive',
244
274
  'variant_limit',
275
+ 'stocktake_not_found',
276
+ 'stocktake_not_open',
277
+ 'stocktake_closed',
278
+ 'stocktake_not_in_review',
279
+ 'stocktake_closing',
280
+ 'stocktake_location_busy',
281
+ 'stocktake_review_running',
282
+ 'stocktake_recount_open',
283
+ 'article_not_in_scope',
284
+ 'article_not_tracked',
285
+ 'count_not_found',
286
+ 'count_already_voided',
287
+ 'serial_already_counted',
288
+ 'too_many_counts',
289
+ 'stocktake_not_closed',
245
290
  ];
246
291
  /**
247
292
  * Codes, die Anmeldung und Rand auf jedem Lager-Aufruf erzeugen koennen,
@@ -254,6 +299,8 @@ export const INVENTORY_REQUEST_ERROR_CODES = [
254
299
  'account_not_found',
255
300
  'admin_required',
256
301
  'api_not_approved',
302
+ 'app_check_invalid',
303
+ 'app_check_missing',
257
304
  'cashregister_not_assigned',
258
305
  'cashregister_not_found',
259
306
  'cashregister_token_invalid',
@@ -283,12 +330,24 @@ export const INVENTORY_REQUEST_ERROR_CODES = [
283
330
  * `below_minimum` misst am verfuegbaren Bestand (`onHand − reserved`) gegen den
284
331
  * Mindestbestand des Standorts, `reservation_exceeded` meldet eine Rechnung, die
285
332
  * mehr verkauft als reserviert war.
333
+ *
334
+ * Seit 1.8.0 die Hinweise der Inventur, je mit der Zahl der Positionen
335
+ * (`items`): `defect_capped` (eine Fehlmenge im Zustand `defective` reichte
336
+ * ueber den Defektbestand, der Rest blieb ungebucht), `uncounted_items` (nicht
337
+ * gezaehlt und darum nicht gebucht), `not_booked` (nicht oder nicht ganz
338
+ * gebucht, Grund an der Position, `notBooked`) und `recount_uncounted`
339
+ * (Positionen zum Nachzaehlen blieben ungezaehlt; die Antwort von
340
+ * `closeStocktake` traegt ihn).
286
341
  */
287
342
  export const INVENTORY_WARNING_CODES = [
288
343
  'insufficient_stock',
289
344
  'below_minimum',
290
345
  'return_exceeds_sale',
291
346
  'reservation_exceeded',
347
+ 'defect_capped',
348
+ 'uncounted_items',
349
+ 'not_booked',
350
+ 'recount_uncounted',
292
351
  ];
293
352
  /**
294
353
  * Bestandsart eines Artikels (`stockKind`): `quantity` = Menge, `serial` =
@@ -334,3 +393,56 @@ export const VARIANT_ATTRIBUTES_MAX = 3;
334
393
  export const VARIANT_VALUES_MAX = 30;
335
394
  export const VARIANT_MATRIX_MAX = 100;
336
395
  export const VARIANT_GROUP_ACTIVE_MAX = 250;
396
+ // ---- Inventur (Lager-Kern Stufe 3, seit 1.8.0) ----------------------------------
397
+ /**
398
+ * Stand einer Inventur (Katalog `INVENTUR_STATUS`). Gezaehlt wird in
399
+ * `counting`; `review` rechnet Soll und Differenz (erst ab hier sichtbar,
400
+ * blind); `closing` bucht den Abschluss in Teilen; `closed` und `cancelled`
401
+ * sind endgueltig. `creating` steht nur, solange eine grosse Anlage ihre
402
+ * Positionen schreibt.
403
+ */
404
+ export const STOCKTAKE_STATUSES = ['creating', 'counting', 'review', 'closing', 'closed', 'cancelled'];
405
+ /**
406
+ * Art einer Inventur (Katalog `INVENTUR_ART`): `key_date` zu einem Stichtag
407
+ * (`keyDate`), `perpetual` (permanente Inventur, ohne Stichtag).
408
+ */
409
+ export const STOCKTAKE_TYPES = ['key_date', 'perpetual'];
410
+ /** Umfang einer Inventur (Katalog `INVENTUR_UMFANG`): alle bestandsgefuehrten Artikel des Standorts, Artikelgruppen oder genannte Artikel. */
411
+ export const STOCKTAKE_SCOPE_TYPES = ['all', 'groups', 'articles'];
412
+ /**
413
+ * Warum eine Position in der Pruefung „pruefen“ traegt (Katalog
414
+ * `INVENTUR_PRUEFGRUND`): Bewegung zwischen der ersten und letzten Zaehlung,
415
+ * Zaehlung mehr als 10 Tage vom Stichtag, Seriennummern weichen ab, nicht gezaehlt.
416
+ */
417
+ export const STOCKTAKE_CHECK_REASONS = ['movements_between_counts', 'far_from_key_date', 'serial_mismatch', 'not_counted'];
418
+ /**
419
+ * Warum eine Position nicht oder nicht ganz gebucht wurde (`notBooked.code`,
420
+ * Katalog `INVENTUR_NICHT_GEBUCHT`). Dazu kommen Codes, die schon englisch
421
+ * sind (`serial_not_in_stock`, `serial_already_exists`, `article_not_found`);
422
+ * das Modell laesst darum jeden Text stehen.
423
+ */
424
+ export const STOCKTAKE_NOT_BOOKED_REASONS = ['serial_mismatch', 'recount_open', 'defect_capped'];
425
+ /** Woher eine Zaehlung bzw. Inventur kam (Katalog `INVENTUR_QUELLE`). */
426
+ export const STOCKTAKE_SOURCES = ['register', 'panel', 'api'];
427
+ /** Wer handelte (Katalog `INVENTUR_AKTEUR`): Inhaber, Kasseneck-Admin, Kassen-Benutzer, API-Schluessel. */
428
+ export const STOCKTAKE_ACTOR_TYPES = ['owner', 'admin', 'register_user', 'api'];
429
+ /**
430
+ * Zu welchem Zeitpunkt das Inventar im Protokoll steht (Katalog
431
+ * `INVENTUR_INVENTAR_ZUM`): `key_date` (auf das Ende des Stichtags
432
+ * fortgeschrieben, Abschluss nach dem Stichtag) oder `count_date` (Menge zur
433
+ * Aufnahme: permanente Inventur oder Abschluss vor dem Stichtag).
434
+ */
435
+ export const STOCKTAKE_INVENTORY_AS_OF = ['key_date', 'count_date'];
436
+ /**
437
+ * Grenzen einer Inventur, wie das Backend sie prueft. Wie bei den Varianten
438
+ * prueft das Paket sie **nicht** vor dem Senden:
439
+ *
440
+ * - [STOCKTAKE_ITEMS_MAX] Positionen je Inventur (`too_many_positions`;
441
+ * groessere Bestaende in mehreren Inventuren nacheinander),
442
+ * - [STOCKTAKE_RECOUNT_ITEMS_MAX] Positionen je `recountStocktake`,
443
+ * - [STOCKTAKE_COUNTS_PER_ITEM_MAX] Zaehlungen je Position und Runde
444
+ * (`too_many_counts`), hoechstens so viele Seriennummern je Zaehlung.
445
+ */
446
+ export const STOCKTAKE_ITEMS_MAX = 5000;
447
+ export const STOCKTAKE_RECOUNT_ITEMS_MAX = 200;
448
+ export const STOCKTAKE_COUNTS_PER_ITEM_MAX = 200;
@@ -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", "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"];
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", "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"];
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"];
@@ -90,6 +90,8 @@ export const INVOICE_REQUEST_ERROR_CODES = [
90
90
  'account_not_found',
91
91
  'admin_required',
92
92
  'api_not_approved',
93
+ 'app_check_invalid',
94
+ 'app_check_missing',
93
95
  'cashregister_not_assigned',
94
96
  'cashregister_not_found',
95
97
  'cashregister_token_invalid',
@@ -53,7 +53,7 @@ export declare function isReturnDisposition(value: unknown): value is ReturnDisp
53
53
  * [PAYMENT_ERROR_CODES]. Ein Code ausserhalb bleibt ueber
54
54
  * `KasseneckApiError.code` lesbar.
55
55
  */
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"];
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", "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
57
  export type CancellationErrorCode = (typeof CANCELLATION_ERROR_CODES)[number];
58
58
  export declare function isCancellationErrorCode(value: unknown): value is CancellationErrorCode;
59
59
  /** Der Code eines geworfenen Fehlers, wenn er in [CANCELLATION_ERROR_CODES] steht; sonst `undefined`. */
@@ -79,6 +79,8 @@ export const CANCELLATION_ERROR_CODES = Object.freeze([
79
79
  'account_not_found',
80
80
  'admin_required',
81
81
  'api_not_approved',
82
+ 'app_check_invalid',
83
+ 'app_check_missing',
82
84
  'cashregister_not_found',
83
85
  'cashregister_token_invalid',
84
86
  'cashregister_token_missing',
@@ -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", "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", "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", "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;
@@ -42,6 +42,8 @@ export const PAYMENT_ERROR_CODES = Object.freeze([
42
42
  'account_not_found',
43
43
  'admin_required',
44
44
  'api_not_approved',
45
+ 'app_check_invalid',
46
+ 'app_check_missing',
45
47
  'cashregister_not_assigned',
46
48
  'cashregister_not_found',
47
49
  '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", "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"];
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", "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`. */
@@ -21,6 +21,8 @@ export const RECEIPT_EMAIL_ERROR_CODES = Object.freeze([
21
21
  'account_not_found',
22
22
  'admin_required',
23
23
  'api_not_approved',
24
+ 'app_check_invalid',
25
+ 'app_check_missing',
24
26
  'cashregister_not_assigned',
25
27
  'cashregister_not_found',
26
28
  '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", "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"];
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", "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`. */
@@ -40,6 +40,8 @@ export const RECEIPT_ERROR_CODES = Object.freeze([
40
40
  'account_not_found',
41
41
  'admin_required',
42
42
  'api_not_approved',
43
+ 'app_check_invalid',
44
+ 'app_check_missing',
43
45
  'cashregister_not_assigned',
44
46
  'cashregister_not_found',
45
47
  'cashregister_token_invalid',
@@ -1,12 +1,13 @@
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) auswerten: am `code`, nie am Text.
4
+ * Artikel, Drucker, Trinkgeld-Empfaenger, Lager, Inventur zaehlen) auswerten:
5
+ * am `code`, nie am Text.
5
6
  * Belege, Storno und Belegmail haben eigene Listen (`RECEIPT_ERROR_CODES`,
6
7
  * `CANCELLATION_ERROR_CODES`, `RECEIPT_EMAIL_ERROR_CODES`), die Anmeldung
7
8
  * `REGISTER_ERROR_CODES` im Unterpfad `./register`.
8
9
  *
9
- * Abgeleitet aus dem Vertrags-Export (Fehlerfaelle dieser dreizehn Endpunkte in
10
+ * Abgeleitet aus dem Vertrags-Export (Fehlerfaelle dieser achtzehn Endpunkte in
10
11
  * `fixtures/v3/antworten/kasse.json` und ihre Handler-Codes); ein Test haelt
11
12
  * die Liste deckungsgleich. `validation` traegt `data.errors[]` mit dem
12
13
  * aeusseren Feldpfad (`business.theme`, `device.shortcuts.splitPayment`).
@@ -19,7 +20,7 @@ import { KasseneckApiError } from '../client/errors.js';
19
20
  * ueber `KasseneckApiError.code` lesbar; die Kasse braucht dafuer einen
20
21
  * Rueckfallzweig.
21
22
  */
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
+ 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", "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"];
23
24
  export type PosErrorCode = typeof POS_ERROR_CODES[number];
24
25
  export declare function isPosErrorCode(value: unknown): value is PosErrorCode;
25
26
  /** Der Code eines geworfenen Fehlers, wenn er in [POS_ERROR_CODES] steht; sonst `undefined`. */
@@ -1,12 +1,13 @@
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) auswerten: am `code`, nie am Text.
4
+ * Artikel, Drucker, Trinkgeld-Empfaenger, Lager, Inventur zaehlen) auswerten:
5
+ * am `code`, nie am Text.
5
6
  * Belege, Storno und Belegmail haben eigene Listen (`RECEIPT_ERROR_CODES`,
6
7
  * `CANCELLATION_ERROR_CODES`, `RECEIPT_EMAIL_ERROR_CODES`), die Anmeldung
7
8
  * `REGISTER_ERROR_CODES` im Unterpfad `./register`.
8
9
  *
9
- * Abgeleitet aus dem Vertrags-Export (Fehlerfaelle dieser dreizehn Endpunkte in
10
+ * Abgeleitet aus dem Vertrags-Export (Fehlerfaelle dieser achtzehn Endpunkte in
10
11
  * `fixtures/v3/antworten/kasse.json` und ihre Handler-Codes); ein Test haelt
11
12
  * die Liste deckungsgleich. `validation` traegt `data.errors[]` mit dem
12
13
  * aeusseren Feldpfad (`business.theme`, `device.shortcuts.splitPayment`).
@@ -23,13 +24,25 @@ export const POS_ERROR_CODES = Object.freeze([
23
24
  'account_not_found',
24
25
  'admin_required',
25
26
  'api_not_approved',
27
+ 'app_check_invalid',
28
+ 'app_check_missing',
29
+ 'article_not_found',
30
+ 'article_not_in_scope',
31
+ 'article_not_tracked',
26
32
  'cashregister_not_assigned',
27
33
  'cashregister_not_found',
28
34
  'cashregister_token_invalid',
29
35
  'cashregister_token_missing',
36
+ 'count_already_voided',
37
+ 'count_not_found',
30
38
  'device_not_found',
31
39
  'dialect_mismatch',
40
+ 'idempotency_conflict',
41
+ 'idempotency_key_required',
32
42
  'internal_translation_error',
43
+ 'invalid_cursor',
44
+ 'invalid_quantity',
45
+ 'invalid_serial',
33
46
  'live_not_enabled',
34
47
  'location_inactive',
35
48
  'location_not_found',
@@ -48,9 +61,17 @@ export const POS_ERROR_CODES = Object.freeze([
48
61
  'register_user_not_allowed',
49
62
  'register_user_not_found',
50
63
  'response_translation_failed',
64
+ 'serial_already_counted',
65
+ 'serial_not_allowed',
66
+ 'serial_required',
51
67
  'server_error',
52
68
  'session_expired',
53
69
  'session_other_cashregister',
70
+ 'stocktake_closed',
71
+ 'stocktake_closing',
72
+ 'stocktake_not_found',
73
+ 'stocktake_not_open',
74
+ 'too_many_counts',
54
75
  'unauthorized',
55
76
  'user_disabled',
56
77
  'user_verification_failed',
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Kachel-Kasse: Einstellungen, Artikelgruppen/Artikel fuer Kacheln,
3
3
  * Rabattverteilung, Drucker, Trinkgeld-Empfaenger, Lager (Standorte, Bestand,
4
- * Standort der Kasse). Die Aufrufe heissen 1:1 wie
4
+ * Standort der Kasse), Inventur zaehlen. Die Aufrufe heissen 1:1 wie
5
5
  * die Backend-Functions (die Rewrites-Waechter der Web-App leiten daraus ab)
6
6
  * und sprechen den Kassenweg `/api/v3` (Schluessel und Werte englisch).
7
7
  */
@@ -14,5 +14,8 @@ export { cancelScopeOf, receiptsScopeOf, stockViewOf, type RegisterScope, type R
14
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';
15
15
  export { listMyTipRecipients } from './trinkgeld.js';
16
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 { type ListMyStocktakesOptions, type ListMyStocktakeItemsOptions, type ListMyStocktakeCountsOptions, type RecordMyStocktakeCountOptions, type VoidMyStocktakeCountOptions, listMyStocktakes, listMyStocktakeItems, listMyStocktakeCounts, recordMyStocktakeCount, voidMyStocktakeCount, parseQuantityMilli, } from './inventur.js';
18
+ export type { Stocktake, StocktakeItem, StocktakeCount, StocktakeCountResult, StocktakeItemPage, StocktakeCountPage, StocktakeActor, StocktakeProgress, StocktakeReview, StocktakeRecount, StocktakeScope, } from '../inventory/typen.js';
19
+ export type { StocktakeStatus } from '../inventory/vertrag.js';
17
20
  export { RETURN_DISPOSITIONS, isReturnDisposition, type ReturnDisposition } from '../models/cancellation.js';
18
21
  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, RETURN_DISPOSITION_LABELS, type TextEntry, type MessageKey, type ErrorKind, type ErrorRule, type ErrorRuleDetail, type Surface, type ReceiptEmailMessageCode, type CancellationPaymentMessageCode, type LabelKey, } from './texte.js';
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Kachel-Kasse: Einstellungen, Artikelgruppen/Artikel fuer Kacheln,
3
3
  * Rabattverteilung, Drucker, Trinkgeld-Empfaenger, Lager (Standorte, Bestand,
4
- * Standort der Kasse). Die Aufrufe heissen 1:1 wie
4
+ * Standort der Kasse), Inventur zaehlen. Die Aufrufe heissen 1:1 wie
5
5
  * die Backend-Functions (die Rewrites-Waechter der Web-App leiten daraus ab)
6
6
  * und sprechen den Kassenweg `/api/v3` (Schluessel und Werte englisch).
7
7
  */
@@ -18,6 +18,7 @@ export { cancelScopeOf, receiptsScopeOf, stockViewOf } from '../register/pairing
18
18
  export { PRINT_JOB_STATUSES, PRINT_JOB_SOURCES, isPrintJobFinished, listMyPrinters, createPrintJob, getPrintJob, } from './drucker.js';
19
19
  export { listMyTipRecipients } from './trinkgeld.js';
20
20
  export { STOCK_LOCATION_TYPES, listMyStockLocations, listMyStock, setMyCashregisterStockLocation, } from './lager.js';
21
+ export { listMyStocktakes, listMyStocktakeItems, listMyStocktakeCounts, recordMyStocktakeCount, voidMyStocktakeCount, parseQuantityMilli, } from './inventur.js';
21
22
  // Rueckgabe-Wahl beim Storno (Kassen-Dialog); dieselbe Liste wie an der Wurzel.
22
23
  export { RETURN_DISPOSITIONS, isReturnDisposition } from '../models/cancellation.js';
23
24
  // Was die Kasse selbst sagt: ein Katalog fuer Browser-Kasse und App.
@@ -0,0 +1,104 @@
1
+ import type { InternerTransport } from '../client/aufrufe.js';
2
+ import type { Stocktake, StocktakeCountPage, StocktakeCountResult, StocktakeItemPage } from '../inventory/typen.js';
3
+ import type { StockCondition, StocktakeStatus } from '../inventory/vertrag.js';
4
+ import { type QuantityRule } from './artikel.js';
5
+ /**
6
+ * Inventur zaehlen an der Kasse (Lager-Kern Stufe 3, Backend
7
+ * inventur-endpoints.js): offene Inventuren des Standorts, ihre Positionen und
8
+ * Zaehlungen lesen, zaehlen und eine Zaehlung stornieren. Alle fuenf Aufrufe
9
+ * gibt es nur ueber den Kassenweg `/api/v3`.
10
+ *
11
+ * Rechte am Server: `stocktakeCount` (zaehlen, eigene Zaehlungen stornieren,
12
+ * lesen) bzw. `stocktakeClose` (auch fremde Zaehlungen stornieren und ab der
13
+ * Pruefung das Soll sehen). Kassen-Benutzer sehen in [listMyStocktakes] nur
14
+ * Inventuren in `counting` und solche in `review` mit offenem Nachzaehlen.
15
+ * Anlegen, Pruefen und Abschliessen gibt es an der Kasse nicht.
16
+ *
17
+ * Gezaehlt wird nur online: die Serverzeit ist die Referenzzeit. Bei unklarem
18
+ * Ausgang (`outcome: 'unknown'`) dieselbe Zaehlung mit **demselben**
19
+ * `idempotencyKey` erneut senden; sie wirkt genau einmal.
20
+ *
21
+ * Die Modelle sind dieselben wie in `./inventory` (`Stocktake`,
22
+ * `StocktakeItem`, `StocktakeCount`); Mengen in Tausendstel.
23
+ */
24
+ export interface ListMyStocktakesOptions {
25
+ /** Nur dieser Standort; `''` gilt wie nicht angegeben. */
26
+ locationId?: string;
27
+ /** Nur dieser Stand. */
28
+ status?: StocktakeStatus;
29
+ }
30
+ export interface ListMyStocktakeItemsOptions {
31
+ stocktakeId: string;
32
+ /** Nur ungezaehlte Positionen (in der Pruefung: die zum Nachzaehlen). */
33
+ openOnly?: boolean;
34
+ limit?: number;
35
+ cursor?: string;
36
+ }
37
+ export interface ListMyStocktakeCountsOptions {
38
+ stocktakeId: string;
39
+ articleId?: string;
40
+ /** Nur die eigenen Zaehlungen. */
41
+ ownOnly?: boolean;
42
+ limit?: number;
43
+ cursor?: string;
44
+ }
45
+ export interface RecordMyStocktakeCountOptions {
46
+ /** Bei „Erneut senden“ derselbe Schluessel wie beim ersten Versuch. */
47
+ idempotencyKey: string;
48
+ stocktakeId: string;
49
+ articleId: string;
50
+ /** Vorgabe `sellable`. */
51
+ condition?: StockCondition;
52
+ /** Tausendstel, aus der Eingabe mit [parseQuantityMilli]; `0` = leer gezaehlt. */
53
+ quantity: number;
54
+ /** Einzelstueck: je Stueck genau eine Seriennummer. */
55
+ serialNumbers?: string[];
56
+ /** Hoechstens 200 Zeichen. */
57
+ note?: string | null;
58
+ /** Ohne Angabe gilt die Kasse der Anmeldung (`registerUserAuth`). */
59
+ cashregisterId?: string;
60
+ }
61
+ export interface VoidMyStocktakeCountOptions {
62
+ idempotencyKey: string;
63
+ stocktakeId: string;
64
+ countId: string;
65
+ /** 1–500 Zeichen. */
66
+ reason: string;
67
+ }
68
+ /** Offene Inventuren (fuer Kassen-Benutzer nur `counting` und `review` mit offenem Nachzaehlen). */
69
+ export declare function listMyStocktakes(transport: InternerTransport, options?: ListMyStocktakesOptions): Promise<Stocktake[]>;
70
+ /** Positionen einer Inventur; ab der Pruefung mit Soll nur mit dem Recht `stocktakeClose`. */
71
+ export declare function listMyStocktakeItems(transport: InternerTransport, options: ListMyStocktakeItemsOptions): Promise<StocktakeItemPage>;
72
+ /** Zaehlungen einer Inventur, neueste zuerst; `ownOnly` nur die eigenen. */
73
+ export declare function listMyStocktakeCounts(transport: InternerTransport, options: ListMyStocktakeCountsOptions): Promise<StocktakeCountPage>;
74
+ /** Eine Zaehlung; Antwort: die Zaehlung und die Position danach (Ist-Summe, kein Soll). */
75
+ export declare function recordMyStocktakeCount(transport: InternerTransport, options: RecordMyStocktakeCountOptions): Promise<StocktakeCountResult>;
76
+ /** Storniert eine Zaehlung mit Grund (fremde nur mit dem Recht `stocktakeClose`). */
77
+ export declare function voidMyStocktakeCount(transport: InternerTransport, options: VoidMyStocktakeCountOptions): Promise<StocktakeCountResult>;
78
+ /**
79
+ * Eine eingetippte Menge in Tausendstel der Basiseinheit, **ohne Gleitkomma**:
80
+ * `'12'` → `12000`, `'0,25'` → `250`, `'1.5'` → `1500`.
81
+ *
82
+ * - Dezimaltrenner Komma oder Punkt, hoechstens drei Nachkommastellen; weitere
83
+ * Nullen am Ende zaehlen nicht (`'1,2340'` → `1234`). `'0'` ist eine gueltige
84
+ * Menge (leer gezaehlt).
85
+ * - **Punkt mit genau drei Ziffern danach und einem Ganzteil ungleich 0**
86
+ * (`'1.000'`, `'12.500'`) ist bei jeder Einheit `null`: in oesterreichischer
87
+ * Schreibweise ist das ein Tausenderpunkt („tausend“), am Ziffernblock ein
88
+ * Dezimalpunkt („eins“); ein Faktor 1000 buchte der Abschluss als Differenz.
89
+ * Mit Komma ist es eindeutig (`'1,000'` → `1000`), ebenso `'0.500'`,
90
+ * `'1.5'`, `'1.25'`.
91
+ * - **Stueckware** nur als ganze Zahl ohne Trenner. Stueckware ist, was
92
+ * `rule` sagt (die gespeicherte Mengenregel des Artikels,
93
+ * `PosArticle.quantityRule`, `'piece'` | `'decimal'`), ohne `rule` die
94
+ * Vorgabe der Einheit (`quantityRuleForUnit`: Stk, g, ml …, auch ohne
95
+ * Einheit). Einzelstuecke (Seriennummer) sind immer Stueckware: dann
96
+ * `'piece'` uebergeben.
97
+ *
98
+ * `null` auch fuer: leer, Vorzeichen, Tausenderleerzeichen, Exponent, mehr als
99
+ * drei Nachkommastellen, groesser als eine sichere Ganzzahl. Die Kasse zeigt
100
+ * dann ihren Satz (`stocktake.quantity_invalid`), statt still zu runden.
101
+ * Gemeinsame Prueffaelle mit dem Dart-Zwilling:
102
+ * `fixtures/stocktake-quantity-cases.json`.
103
+ */
104
+ export declare function parseQuantityMilli(text: string, unit?: string | null, rule?: QuantityRule | null): number | null;
@@ -0,0 +1,109 @@
1
+ import { KasseneckValidationError } from '../client/errors.js';
2
+ import { stornoPruefen, zaehlungPruefen } from '../inventory/inventur.js';
3
+ import { inventur, inventurPosition, inventurZaehlung, liste, naechsterCursor, zaehlungMitPosition } from '../inventory/lesen.js';
4
+ import { anfrage, schluessel } from '../inventory/schreiben.js';
5
+ import { quantityRuleForUnit } from './artikel.js';
6
+ function anfragefehler(name, grund) {
7
+ return new KasseneckValidationError(name, grund, 'request');
8
+ }
9
+ /** Eine Kennung, die gesendet werden muss. */
10
+ function kennung(name, feld, w) {
11
+ if (typeof w !== 'string' || w.trim() === '')
12
+ throw anfragefehler(name, `${feld} fehlt`);
13
+ return w;
14
+ }
15
+ /** Die Optionen flach, ohne `undefined`; Pflichtkennung `stocktakeId`. */
16
+ function mitInventur(name, options) {
17
+ const p = anfrage(name, options);
18
+ kennung(name, 'stocktakeId', p.stocktakeId);
19
+ return p;
20
+ }
21
+ /** Offene Inventuren (fuer Kassen-Benutzer nur `counting` und `review` mit offenem Nachzaehlen). */
22
+ export async function listMyStocktakes(transport, options = {}) {
23
+ const name = 'listMyStocktakes';
24
+ const p = anfrage(name, options);
25
+ if (p.locationId === '')
26
+ delete p.locationId;
27
+ const daten = await transport(name, p);
28
+ return liste(name, daten, 'stocktakes', inventur);
29
+ }
30
+ /** Positionen einer Inventur; ab der Pruefung mit Soll nur mit dem Recht `stocktakeClose`. */
31
+ export async function listMyStocktakeItems(transport, options) {
32
+ const name = 'listMyStocktakeItems';
33
+ const daten = await transport(name, mitInventur(name, options));
34
+ return { items: liste(name, daten, 'items', inventurPosition), nextCursor: naechsterCursor(name, daten) };
35
+ }
36
+ /** Zaehlungen einer Inventur, neueste zuerst; `ownOnly` nur die eigenen. */
37
+ export async function listMyStocktakeCounts(transport, options) {
38
+ const name = 'listMyStocktakeCounts';
39
+ const daten = await transport(name, mitInventur(name, options));
40
+ return { counts: liste(name, daten, 'counts', inventurZaehlung), nextCursor: naechsterCursor(name, daten) };
41
+ }
42
+ /** Eine Zaehlung; Antwort: die Zaehlung und die Position danach (Ist-Summe, kein Soll). */
43
+ export async function recordMyStocktakeCount(transport, options) {
44
+ const name = 'recordMyStocktakeCount';
45
+ const p = mitInventur(name, options);
46
+ schluessel(name, p, { pflicht: true });
47
+ zaehlungPruefen(name, p);
48
+ if (p.cashregisterId !== undefined)
49
+ kennung(name, 'cashregisterId', p.cashregisterId);
50
+ return zaehlungMitPosition(name, await transport(name, p));
51
+ }
52
+ /** Storniert eine Zaehlung mit Grund (fremde nur mit dem Recht `stocktakeClose`). */
53
+ export async function voidMyStocktakeCount(transport, options) {
54
+ const name = 'voidMyStocktakeCount';
55
+ const p = mitInventur(name, options);
56
+ schluessel(name, p, { pflicht: true });
57
+ stornoPruefen(name, p);
58
+ return zaehlungMitPosition(name, await transport(name, p));
59
+ }
60
+ /** Tausendstel je Einheit: drei Nachkommastellen, wie die Mengen am Draht. */
61
+ const STELLEN = 3;
62
+ /**
63
+ * Eine eingetippte Menge in Tausendstel der Basiseinheit, **ohne Gleitkomma**:
64
+ * `'12'` → `12000`, `'0,25'` → `250`, `'1.5'` → `1500`.
65
+ *
66
+ * - Dezimaltrenner Komma oder Punkt, hoechstens drei Nachkommastellen; weitere
67
+ * Nullen am Ende zaehlen nicht (`'1,2340'` → `1234`). `'0'` ist eine gueltige
68
+ * Menge (leer gezaehlt).
69
+ * - **Punkt mit genau drei Ziffern danach und einem Ganzteil ungleich 0**
70
+ * (`'1.000'`, `'12.500'`) ist bei jeder Einheit `null`: in oesterreichischer
71
+ * Schreibweise ist das ein Tausenderpunkt („tausend“), am Ziffernblock ein
72
+ * Dezimalpunkt („eins“); ein Faktor 1000 buchte der Abschluss als Differenz.
73
+ * Mit Komma ist es eindeutig (`'1,000'` → `1000`), ebenso `'0.500'`,
74
+ * `'1.5'`, `'1.25'`.
75
+ * - **Stueckware** nur als ganze Zahl ohne Trenner. Stueckware ist, was
76
+ * `rule` sagt (die gespeicherte Mengenregel des Artikels,
77
+ * `PosArticle.quantityRule`, `'piece'` | `'decimal'`), ohne `rule` die
78
+ * Vorgabe der Einheit (`quantityRuleForUnit`: Stk, g, ml …, auch ohne
79
+ * Einheit). Einzelstuecke (Seriennummer) sind immer Stueckware: dann
80
+ * `'piece'` uebergeben.
81
+ *
82
+ * `null` auch fuer: leer, Vorzeichen, Tausenderleerzeichen, Exponent, mehr als
83
+ * drei Nachkommastellen, groesser als eine sichere Ganzzahl. Die Kasse zeigt
84
+ * dann ihren Satz (`stocktake.quantity_invalid`), statt still zu runden.
85
+ * Gemeinsame Prueffaelle mit dem Dart-Zwilling:
86
+ * `fixtures/stocktake-quantity-cases.json`.
87
+ */
88
+ export function parseQuantityMilli(text, unit, rule) {
89
+ if (typeof text !== 'string')
90
+ return null;
91
+ const m = /^(\d*)(?:([.,])(\d*))?$/.exec(text.trim());
92
+ if (!m)
93
+ return null;
94
+ const ganz = m[1] ?? '';
95
+ const trenner = m[2];
96
+ const roh = m[3] ?? '';
97
+ if (ganz === '' && roh === '')
98
+ return null;
99
+ const stueck = (rule === 'piece' || rule === 'decimal' ? rule : quantityRuleForUnit(unit).rule) === 'piece';
100
+ if (trenner !== undefined && stueck)
101
+ return null;
102
+ if (trenner === '.' && roh.length === 3 && /[1-9]/.test(ganz))
103
+ return null;
104
+ const nachkomma = roh.replace(/0+$/, '');
105
+ if (nachkomma.length > STELLEN)
106
+ return null;
107
+ const milli = BigInt(ganz === '' ? '0' : ganz) * 1000n + BigInt(nachkomma.padEnd(STELLEN, '0'));
108
+ return milli <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(milli) : null;
109
+ }