@kreiseck/kasseneck-api 1.7.0 → 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 (115) hide show
  1. package/CHANGELOG.md +122 -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/react/index.js +6 -0
  44. package/dist/cjs/register/errors.d.ts +1 -1
  45. package/dist/cjs/register/errors.js +2 -0
  46. package/dist/cjs/stored/vokabular.d.ts +1 -1
  47. package/dist/cjs/stored/vokabular.js +1 -1
  48. package/dist/cjs/version.d.ts +1 -1
  49. package/dist/cjs/version.js +1 -1
  50. package/dist/esm/client/aufrufe.d.ts +9 -7
  51. package/dist/esm/client/aufrufe.js +57 -2
  52. package/dist/esm/client/errors.js +2 -0
  53. package/dist/esm/client/index.d.ts +1 -1
  54. package/dist/esm/client/index.js +1 -1
  55. package/dist/esm/client/transport.d.ts +27 -3
  56. package/dist/esm/client/transport.js +28 -3
  57. package/dist/esm/index.d.ts +1 -1
  58. package/dist/esm/index.js +1 -1
  59. package/dist/esm/inventory/api.d.ts +21 -2
  60. package/dist/esm/inventory/api.js +23 -4
  61. package/dist/esm/inventory/fehler.d.ts +6 -0
  62. package/dist/esm/inventory/fehler.js +11 -0
  63. package/dist/esm/inventory/index.d.ts +6 -4
  64. package/dist/esm/inventory/index.js +5 -3
  65. package/dist/esm/inventory/inventur.d.ts +104 -0
  66. package/dist/esm/inventory/inventur.js +226 -0
  67. package/dist/esm/inventory/lesen.d.ts +20 -1
  68. package/dist/esm/inventory/lesen.js +301 -0
  69. package/dist/esm/inventory/typen.d.ts +410 -1
  70. package/dist/esm/inventory/vertrag.d.ts +94 -8
  71. package/dist/esm/inventory/vertrag.js +116 -4
  72. package/dist/esm/invoice/vertrag.d.ts +1 -1
  73. package/dist/esm/invoice/vertrag.js +2 -0
  74. package/dist/esm/models/cancellation.d.ts +1 -1
  75. package/dist/esm/models/cancellation.js +2 -0
  76. package/dist/esm/models/payment-errors.d.ts +1 -1
  77. package/dist/esm/models/payment-errors.js +2 -0
  78. package/dist/esm/models/receipt-email.d.ts +1 -1
  79. package/dist/esm/models/receipt-email.js +2 -0
  80. package/dist/esm/models/receipt-errors.d.ts +1 -1
  81. package/dist/esm/models/receipt-errors.js +2 -0
  82. package/dist/esm/pos/errors.d.ts +4 -3
  83. package/dist/esm/pos/errors.js +23 -2
  84. package/dist/esm/pos/index.d.ts +4 -1
  85. package/dist/esm/pos/index.js +2 -1
  86. package/dist/esm/pos/inventur.d.ts +104 -0
  87. package/dist/esm/pos/inventur.js +109 -0
  88. package/dist/esm/pos/texte.d.ts +82 -0
  89. package/dist/esm/pos/texte.js +35 -0
  90. package/dist/esm/react/index.js +6 -0
  91. package/dist/esm/register/errors.d.ts +1 -1
  92. package/dist/esm/register/errors.js +2 -0
  93. package/dist/esm/stored/vokabular.d.ts +1 -1
  94. package/dist/esm/stored/vokabular.js +1 -1
  95. package/dist/esm/version.d.ts +1 -1
  96. package/dist/esm/version.js +1 -1
  97. package/fixtures/hobex-hps-codes.json +1 -1
  98. package/fixtures/invoice-api.schema.json +1 -1
  99. package/fixtures/invoice-texts.json +1 -1
  100. package/fixtures/pos-texts.json +94 -1
  101. package/fixtures/stocktake-quantity-cases.json +55 -0
  102. package/fixtures/surface.json +151 -8
  103. package/fixtures/v3/antworten/belege.json +1 -1
  104. package/fixtures/v3/antworten/belegmail.json +1 -1
  105. package/fixtures/v3/antworten/kasse-belege.json +1 -1
  106. package/fixtures/v3/antworten/kasse.json +2958 -3
  107. package/fixtures/v3/antworten/lager.json +1727 -3
  108. package/fixtures/v3/antworten/rechnungen.json +1 -1
  109. package/fixtures/v3/antworten/storno.json +1 -1
  110. package/fixtures/v3/stored/belege.json +1 -1
  111. package/fixtures/v3/stored/kasse.json +414 -3
  112. package/fixtures/v3/stored/rechnungen.json +1 -1
  113. package/fixtures/v3/v3-vokabular.json +475 -8
  114. package/fixtures/v3/zahlbetrag-faelle.json +1 -1
  115. package/package.json +1 -1
@@ -91,16 +91,16 @@ export interface TransportOptions {
91
91
  auth: KasseneckAuth;
92
92
  /**
93
93
  * Abweichende Basis der **oeffentlichen** Aufrufe (Vorgabe
94
- * [DEFAULT_BASE_URL]): alles ausser den 28 Aufrufen des Kassenwegs, und die
94
+ * [DEFAULT_BASE_URL]): alles ausser den 33 Aufrufen des Kassenwegs, und die
95
95
  * sechs oeffentlichen davon nur, wenn nicht mit `registerUserAuth`
96
96
  * angemeldet. Muss auf `/v3` enden (eigene Proxys erlaubt), sonst wirft das
97
97
  * Anlegen; `/v1` oder `/api` gibt es in der 1.x-Linie nicht.
98
98
  */
99
99
  baseUrl?: string;
100
100
  /**
101
- * Abweichende Basis des **Kassenwegs** (Vorgabe [POS_BASE_URL]): die 22
101
+ * Abweichende Basis des **Kassenwegs** (Vorgabe [POS_BASE_URL]): die 27
102
102
  * reinen Kassenaufrufe (Kopplung, Anmeldung, Einstellungen, Artikel,
103
- * Drucker, ...) und mit `registerUserAuth` alle 28 Aufrufe des Kassenwegs.
103
+ * Drucker, ...) und mit `registerUserAuth` alle 33 Aufrufe des Kassenwegs.
104
104
  * Die Web-Kasse gibt `'/api/v3'` (gleicher Ursprung). Muss auf `/v3` enden
105
105
  * (in der Regel `/api/v3`), sonst wirft das Anlegen.
106
106
  */
@@ -193,3 +193,27 @@ export declare function createTransport(options: TransportOptions): KasseneckTra
193
193
  * reports.ts.)
194
194
  */
195
195
  export declare function createBinaryTransport(options: TransportOptions): KasseneckBinaryTransport;
196
+ /**
197
+ * Ergebnis eines Aufrufs, der eine Datei **oder** eine Nutzlast liefert: das
198
+ * PDF als Bytes oder die `data` einer Erfolgshuelle (etwa ein Lese-Link, wenn
199
+ * die Datei zu gross fuer die Antwort ist).
200
+ */
201
+ export type PdfOrData = {
202
+ pdf: Uint8Array;
203
+ } | {
204
+ data: unknown;
205
+ };
206
+ /**
207
+ * Ruft eine Backend-Funktion auf, die ein PDF **oder** eine JSON-Nutzlast
208
+ * liefert (Inventurprotokoll: die Datei bis 9 MiB, darueber ein Lese-Link).
209
+ */
210
+ export type KasseneckPdfOrDataTransport = (functionName: string, params?: Record<string, unknown>) => Promise<PdfOrData>;
211
+ /**
212
+ * Dritter Einstiegspunkt, fuer Aufrufe, die eine Datei oder eine Nutzlast
213
+ * liefern (`getStocktakePdf` aus `./inventory`). Wie [createBinaryTransport]
214
+ * wird die Antwort nur als Bytes gelesen; die ersten Bytes entscheiden: `%PDF`
215
+ * ergibt `{ pdf }`, eine Erfolgshuelle `{ data }`, eine Fehlerhuelle denselben
216
+ * fachlichen Fehler wie auf dem JSON-Weg. Leer, kein JSON oder ohne Statusfeld
217
+ * ist unlesbar mit denselben Gruenden wie dort.
218
+ */
219
+ export declare function createPdfOrDataTransport(options: TransportOptions): KasseneckPdfOrDataTransport;
@@ -93,7 +93,19 @@ export function createBinaryTransport(options) {
93
93
  return (functionName, params) => kern(functionName, params, undefined, undefined, undefined, alsBytes, pdfAuswerten);
94
94
  }
95
95
  /**
96
- * Gemeinsamer Kern beider Einstiegspunkte: Anmeldung, Zeitlimit, Anfrage und
96
+ * Dritter Einstiegspunkt, fuer Aufrufe, die eine Datei oder eine Nutzlast
97
+ * liefern (`getStocktakePdf` aus `./inventory`). Wie [createBinaryTransport]
98
+ * wird die Antwort nur als Bytes gelesen; die ersten Bytes entscheiden: `%PDF`
99
+ * ergibt `{ pdf }`, eine Erfolgshuelle `{ data }`, eine Fehlerhuelle denselben
100
+ * fachlichen Fehler wie auf dem JSON-Weg. Leer, kein JSON oder ohne Statusfeld
101
+ * ist unlesbar mit denselben Gruenden wie dort.
102
+ */
103
+ export function createPdfOrDataTransport(options) {
104
+ const kern = createCore(options);
105
+ return (functionName, params) => kern(functionName, params, undefined, undefined, undefined, alsBytes, pdfOderDatenAuswerten);
106
+ }
107
+ /**
108
+ * Gemeinsamer Kern aller Einstiegspunkte: Anmeldung, Zeitlimit, Anfrage und
97
109
  * HTTP-Status. Was danach mit dem Rumpf geschieht, entscheiden `lesen` und
98
110
  * `auswerten`.
99
111
  */
@@ -107,9 +119,9 @@ function createCore(options) {
107
119
  pruefeKennung(kennung);
108
120
  const kopfzeilenSenden = options.omitKasseneckHeaders !== true;
109
121
  /**
110
- * Basis je Aufruf. Die 22 reinen Kassenaufrufe gehen immer an den
122
+ * Basis je Aufruf. Die 27 reinen Kassenaufrufe gehen immer an den
111
123
  * Kassenweg (unter der oeffentlichen Basis gibt es sie nicht), und die
112
- * Kassen-Anmeldung ruft alle 28 Aufrufe des Kassenwegs dort, auch die sechs
124
+ * Kassen-Anmeldung ruft alle 33 Aufrufe des Kassenwegs dort, auch die sechs
113
125
  * oeffentlichen (Kanal `app`). Was der Kassenweg gar nicht fuehrt
114
126
  * (Berichte, Zahlungen, FinanzOnline), geht an die oeffentliche Basis.
115
127
  */
@@ -431,6 +443,19 @@ function pdfAuswerten(bytes, functionName, statusCode, inhaltstyp, geheimnisse,
431
443
  // es keinen Unterschied, ob er ein PDF oder eine Nutzlast erwartet hat.
432
444
  throw fachfehler(functionName, huelle.message, huelle.data, geheimnisse, huelle.code);
433
445
  }
446
+ /**
447
+ * Auswertung von [createPdfOrDataTransport]: ein PDF geht als Bytes zurueck,
448
+ * eine Erfolgshuelle als ihre `data`, eine Fehlerhuelle als derselbe
449
+ * fachliche Fehler wie auf dem JSON-Weg. Alles andere (leer, kein JSON, ohne
450
+ * Statusfeld) ist unlesbar mit denselben Gruenden wie dort.
451
+ */
452
+ function pdfOderDatenAuswerten(bytes, functionName, statusCode, inhaltstyp, geheimnisse, unlesbar) {
453
+ if (istPdf(bytes)) {
454
+ return { pdf: bytes };
455
+ }
456
+ const text = new TextDecoder('utf-8').decode(bytes);
457
+ return { data: jsonAuswerten(text, functionName, statusCode, inhaltstyp, geheimnisse, unlesbar) };
458
+ }
434
459
  /** `%PDF` am Anfang — die Kennung jeder PDF-Datei. */
435
460
  function istPdf(bytes) {
436
461
  return bytes.length >= 4 && bytes[0] === 0x25 && bytes[1] === 0x50 && bytes[2] === 0x44 && bytes[3] === 0x46;
@@ -1,6 +1,6 @@
1
1
  export { ReceiptType, type ReceiptTypeKey, VatRate, type VatRateKey, KeckPaymentMethod, type KeckPaymentMethodKey, CreditCardProvider, type CreditCardProviderKey, VoucherType, type VoucherTypeKey, VoucherAction, type VoucherActionKey, StripeLinkMode, type StripeLinkModeKey, } from './enums/index.js';
2
2
  export { type ReceiptItem, type ReceiptItemPayload, type ReceiptItemPayloadRead, toReceiptItemPayload, fromReceiptItemPayload, receiptItemTotalCents, receiptItemIsValid, negateReceiptItem, type TipRecipient, isTipItem, type Voucher, type VoucherPayload, toVoucherPayload, fromVoucherPayload, voucherIsValid, type Receipt, type RegistrationInfo, type ReceiptPayload, type ReceiptPayloadRead, toReceiptPayload, fromReceiptPayload, receiptSubSumCents, receiptSumCents, type CancellationOf, type CancellationItem, type Cancellation, type CancellationReason, type CancellationErrorCode, type CancellationStatus, type ReturnDisposition, RETURN_DISPOSITIONS, CANCELLATION_REASONS, CANCELLATION_STATUSES, CANCELLATION_ERROR_CODES, CANCELLATION_RESERVATION_MS, isCancellationReason, isReturnDisposition, isCancellationErrorCode, cancellationErrorCode, isCancellationError, cancellationFieldErrors, type CancellationFieldError, type ReceiptPayment, type ReceiptPaymentPayload, type ReceiptPaymentInput, fromReceiptPaymentPayload, toReceiptPaymentPayload, type PaymentErrorCode, PAYMENT_ERROR_CODES, isPaymentErrorCode, paymentErrorCode, isPaymentError, paymentFieldErrors, type PaymentFieldError, type ReceiptEmailErrorCode, type ReceiptEmailVia, RECEIPT_EMAIL_ERROR_CODES, RECEIPT_EMAIL_SEND_ERROR_CODES, type ReceiptEmailSendErrorCode, RECEIPT_EMAIL_VIAS, isReceiptEmailErrorCode, receiptEmailErrorCode, isReceiptEmailError, receiptEmailFieldErrors, type ReceiptEmailFieldError, type ReceiptErrorCode, type ReceiptFieldError, RECEIPT_ERROR_CODES, isReceiptErrorCode, receiptErrorCode, isReceiptError, receiptFieldErrors, remainingQuantities, type ReceiptCompany, type ReceiptCompanyPayload, fromReceiptCompanyPayload, receiptCompanyTaxInfo, type Cashregister, type CashregisterOnboarding, type CashregisterPayload, type CashregisterOnboardingPayload, type CashregisterAutoLogout, type CashregisterAutoLogoutPayload, fromCashregisterPayload, type ReceiptSummary, type ReceiptSummaryPayload, fromReceiptSummaryPayload, type ZeroKind, ZERO_KINDS, isZeroKind, type ReportMonth, reportMonthFromDate, previousReportMonth, nextReportMonth, reportMonthKey, reportMonthReadable, type StripeUrlSession, type StripeUrlSessionPayload, toStripeUrlSessionPayload, fromStripeUrlSessionPayload, type HobexReceipt, type HobexReceiptPayload, toHobexReceiptPayload, fromHobexReceiptPayload, hobexReceiptToCardPaymentData, hobexReceiptNeedsSignature, } from './models/index.js';
3
- export { type AuthCredentials, type KasseneckAuth, type ApiKeyAuthOptions, type RegisterUserAuthOptions, apiKeyAuth, registerUserAuth, DEFAULT_BASE_URL, POS_BASE_URL, DEFAULT_TIMEOUT_MS, type HttpResponseLike, type HttpRequestInit, type FetchLike, type TransportOptions, type TransportBodyFields, type TransportCallOptions, type KasseneckTransport, type KasseneckBinaryTransport, ALL_CALLS, type ApiCall, PUBLIC_CALLS, POS_CALLS, UNKNOWN_OUTCOME_CALLS, type PublicCall, type PosCall, createTransport, createBinaryTransport, KasseneckApiError, KasseneckAuthError, KasseneckHttpError, KasseneckNetworkError, KasseneckValidationError, type ValidationScope, type KasseneckError, type HttpFailureReason, type CauseDigest, type ErrorOutcome, CLIENT_ERROR_CODES, type ClientErrorCode, isKasseneckApiError, isKasseneckAuthError, isKasseneckHttpError, isKasseneckNetworkError, isKasseneckValidationError, isOutcomeUnknown, type ReceiptCommonOptions, type SellReceiptOptions, type TipOptions, type TipRecipientShare, type CancelReceiptOptions, type CancelReceiptResult, type ReceiptWithCompany, sellReceipt, sellReceiptWithCompany, paymentsExpectedCents, cardRefundReference, receiptLayoutFromResult, cancelReceipt, zeroReceipt, getReceipt, getReceiptWithCompany, generateFullReceiptId, getFirstReceiptDate, listMyReceipts, type ListMyReceiptsOptions, type ReceiptList, type ReceiptListStats, listMyCashregisters, checkVoucherCombinationError, type SendReceiptEmailOptions, type SendReceiptEmailResult, sendReceiptEmail, downloadDailyReport, downloadMonthlyReport, getReportV2, type ReportV2, type ReportV2Metadata, type ReportV2Options, type CashboxStatus, type SignatureStatus, getCashboxStatus, getSignatureStatus, type KasseneckApi, createKasseneckApi, } from './client/index.js';
3
+ export { type AuthCredentials, type KasseneckAuth, type ApiKeyAuthOptions, type RegisterUserAuthOptions, apiKeyAuth, registerUserAuth, DEFAULT_BASE_URL, POS_BASE_URL, DEFAULT_TIMEOUT_MS, type HttpResponseLike, type HttpRequestInit, type FetchLike, type TransportOptions, type TransportBodyFields, type TransportCallOptions, type KasseneckTransport, type KasseneckBinaryTransport, type KasseneckPdfOrDataTransport, type PdfOrData, ALL_CALLS, type ApiCall, PUBLIC_CALLS, POS_CALLS, UNKNOWN_OUTCOME_CALLS, type PublicCall, type PosCall, createTransport, createBinaryTransport, createPdfOrDataTransport, KasseneckApiError, KasseneckAuthError, KasseneckHttpError, KasseneckNetworkError, KasseneckValidationError, type ValidationScope, type KasseneckError, type HttpFailureReason, type CauseDigest, type ErrorOutcome, CLIENT_ERROR_CODES, type ClientErrorCode, isKasseneckApiError, isKasseneckAuthError, isKasseneckHttpError, isKasseneckNetworkError, isKasseneckValidationError, isOutcomeUnknown, type ReceiptCommonOptions, type SellReceiptOptions, type TipOptions, type TipRecipientShare, type CancelReceiptOptions, type CancelReceiptResult, type ReceiptWithCompany, sellReceipt, sellReceiptWithCompany, paymentsExpectedCents, cardRefundReference, receiptLayoutFromResult, cancelReceipt, zeroReceipt, getReceipt, getReceiptWithCompany, generateFullReceiptId, getFirstReceiptDate, listMyReceipts, type ListMyReceiptsOptions, type ReceiptList, type ReceiptListStats, listMyCashregisters, checkVoucherCombinationError, type SendReceiptEmailOptions, type SendReceiptEmailResult, sendReceiptEmail, downloadDailyReport, downloadMonthlyReport, getReportV2, type ReportV2, type ReportV2Metadata, type ReportV2Options, type CashboxStatus, type SignatureStatus, getCashboxStatus, getSignatureStatus, type KasseneckApi, createKasseneckApi, } from './client/index.js';
4
4
  export { type ReceiptDueTip, type ReceiptDueTipRecipient, type ReceiptDueOptions, type ReceiptDueBuckets, type ReceiptDueBreakdown, type ReceiptDueErrorReason, receiptDueCents, receiptDueBreakdown, ReceiptDueError, RECEIPT_DUE_ERROR_REASONS, isReceiptDueError, } from './receipt/due.js';
5
5
  export { parseServerTimeStamp, toViennaWallClock, type ViennaWallClock } from './vienna-time.js';
6
6
  export { type PosBusinessSettings, type PosDeviceSettings, type PosSettings, type ArticleGroup, type PosArticle, POS_BUSINESS_DEFAULTS, POS_DEVICE_DEFAULTS, mergePosSettings, fromArticleGroupPayload, fromPosArticlePayload, listMyArticleGroups, listMyArticles, getPosSettings, setMyPosSettings, setMyRegisterDeviceSettings, distributeDiscount, cancelScopeOf, receiptsScopeOf, stockViewOf, } from './pos/index.js';
package/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export { ReceiptType, VatRate, KeckPaymentMethod, CreditCardProvider, VoucherType, VoucherAction, StripeLinkMode, } from './enums/index.js';
2
2
  export { toReceiptItemPayload, fromReceiptItemPayload, receiptItemTotalCents, receiptItemIsValid, negateReceiptItem, isTipItem, toVoucherPayload, fromVoucherPayload, voucherIsValid, toReceiptPayload, fromReceiptPayload, receiptSubSumCents, receiptSumCents, RETURN_DISPOSITIONS, CANCELLATION_REASONS, CANCELLATION_STATUSES, CANCELLATION_ERROR_CODES, CANCELLATION_RESERVATION_MS, isCancellationReason, isReturnDisposition, isCancellationErrorCode, cancellationErrorCode, isCancellationError, cancellationFieldErrors, fromReceiptPaymentPayload, toReceiptPaymentPayload, PAYMENT_ERROR_CODES, isPaymentErrorCode, paymentErrorCode, isPaymentError, paymentFieldErrors, RECEIPT_EMAIL_ERROR_CODES, RECEIPT_EMAIL_SEND_ERROR_CODES, RECEIPT_EMAIL_VIAS, isReceiptEmailErrorCode, receiptEmailErrorCode, isReceiptEmailError, receiptEmailFieldErrors, RECEIPT_ERROR_CODES, isReceiptErrorCode, receiptErrorCode, isReceiptError, receiptFieldErrors, remainingQuantities, fromReceiptCompanyPayload, receiptCompanyTaxInfo, fromCashregisterPayload, fromReceiptSummaryPayload, ZERO_KINDS, isZeroKind, reportMonthFromDate, previousReportMonth, nextReportMonth, reportMonthKey, reportMonthReadable, toStripeUrlSessionPayload, fromStripeUrlSessionPayload, toHobexReceiptPayload, fromHobexReceiptPayload, hobexReceiptToCardPaymentData, hobexReceiptNeedsSignature, } from './models/index.js';
3
- export { apiKeyAuth, registerUserAuth, DEFAULT_BASE_URL, POS_BASE_URL, DEFAULT_TIMEOUT_MS, ALL_CALLS, PUBLIC_CALLS, POS_CALLS, UNKNOWN_OUTCOME_CALLS, createTransport, createBinaryTransport, KasseneckApiError, KasseneckAuthError, KasseneckHttpError, KasseneckNetworkError, KasseneckValidationError, CLIENT_ERROR_CODES, isKasseneckApiError, isKasseneckAuthError, isKasseneckHttpError, isKasseneckNetworkError, isKasseneckValidationError, isOutcomeUnknown, sellReceipt, sellReceiptWithCompany, paymentsExpectedCents, cardRefundReference, receiptLayoutFromResult, cancelReceipt, zeroReceipt, getReceipt, getReceiptWithCompany, generateFullReceiptId, getFirstReceiptDate, listMyReceipts, listMyCashregisters, checkVoucherCombinationError, sendReceiptEmail, downloadDailyReport, downloadMonthlyReport, getReportV2, getCashboxStatus, getSignatureStatus, createKasseneckApi, } from './client/index.js';
3
+ export { apiKeyAuth, registerUserAuth, DEFAULT_BASE_URL, POS_BASE_URL, DEFAULT_TIMEOUT_MS, ALL_CALLS, PUBLIC_CALLS, POS_CALLS, UNKNOWN_OUTCOME_CALLS, createTransport, createBinaryTransport, createPdfOrDataTransport, KasseneckApiError, KasseneckAuthError, KasseneckHttpError, KasseneckNetworkError, KasseneckValidationError, CLIENT_ERROR_CODES, isKasseneckApiError, isKasseneckAuthError, isKasseneckHttpError, isKasseneckNetworkError, isKasseneckValidationError, isOutcomeUnknown, sellReceipt, sellReceiptWithCompany, paymentsExpectedCents, cardRefundReference, receiptLayoutFromResult, cancelReceipt, zeroReceipt, getReceipt, getReceiptWithCompany, generateFullReceiptId, getFirstReceiptDate, listMyReceipts, listMyCashregisters, checkVoucherCombinationError, sendReceiptEmail, downloadDailyReport, downloadMonthlyReport, getReportV2, getCashboxStatus, getSignatureStatus, createKasseneckApi, } from './client/index.js';
4
4
  export { receiptDueCents, receiptDueBreakdown, ReceiptDueError, RECEIPT_DUE_ERROR_REASONS, isReceiptDueError, } from './receipt/due.js';
5
5
  export { parseServerTimeStamp, toViennaWallClock } from './vienna-time.js';
6
6
  export { POS_BUSINESS_DEFAULTS, POS_DEVICE_DEFAULTS, mergePosSettings, fromArticleGroupPayload, fromPosArticlePayload, listMyArticleGroups, listMyArticles, getPosSettings, setMyPosSettings, setMyRegisterDeviceSettings, distributeDiscount, cancelScopeOf, receiptsScopeOf, stockViewOf, } from './pos/index.js';
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * Fassade ueber den Aufrufen der Lager-API (lesen, Webhooks, schreiben,
3
- * reservieren, Varianten): Schluessel einmal binden, dann rufen. Wie [createInvoiceApi] bewusst keine Klasse; die Aufrufe sind freie
3
+ * reservieren, Varianten, Inventur): Schluessel einmal binden, dann rufen. Wie [createInvoiceApi] bewusst keine Klasse; die Aufrufe sind freie
4
4
  * Funktionen (endpunkte.ts) und bleiben einzeln importierbar.
5
5
  */
6
6
  import { type FetchLike } from '../client/transport.js';
7
- import type { AddVariantRequest, CreateVariantGroupRequest, UpdateVariantGroupRequest, VariantGroup, VariantGroupListQuery, VariantGroupPage, Article, ChangeStockConditionRequest, CreateArticleRequest, CreateReservationRequest, DeactivateArticleRequest, ExtendReservationRequest, GoodsReceiptPreview, GoodsReceiptPreviewRequest, ReceiveGoodsRequest, RecordStockLossRequest, ReleaseReservationRequest, Reservation, ReservationListQuery, ReservationPage, ReverseStockMovementRequest, StockOperation, TransferStockRequest, UpdateArticleRequest, ArticleListQuery, ArticleLookup, ArticlePage, CreateInventoryWebhookOptions, InventoryWebhook, InventoryWebhookDelivery, InventoryWebhookList, InventoryWebhookPatch, InventoryWebhookTestResult, InventoryWebhookWithSecret, Location, StockLevel, StockListQuery, StockMovement, StockMovementPage, StockMovementQuery, StockPage, StockResult } from './typen.js';
7
+ import type { CancelStocktakeRequest, CloseStocktakeRequest, CloseStocktakeResult, CreateStocktakeRequest, RecordStocktakeCountRequest, RecountStocktakeRequest, ReviewStocktakeRequest, Stocktake, StocktakeCount, StocktakeCountListQuery, StocktakeCountPage, StocktakeCountResult, StocktakeItem, StocktakeItemListQuery, StocktakeItemPage, StocktakeListQuery, StocktakePage, StocktakePdf, VoidStocktakeCountRequest, AddVariantRequest, CreateVariantGroupRequest, UpdateVariantGroupRequest, VariantGroup, VariantGroupListQuery, VariantGroupPage, Article, ChangeStockConditionRequest, CreateArticleRequest, CreateReservationRequest, DeactivateArticleRequest, ExtendReservationRequest, GoodsReceiptPreview, GoodsReceiptPreviewRequest, ReceiveGoodsRequest, RecordStockLossRequest, ReleaseReservationRequest, Reservation, ReservationListQuery, ReservationPage, ReverseStockMovementRequest, StockOperation, TransferStockRequest, UpdateArticleRequest, ArticleListQuery, ArticleLookup, ArticlePage, CreateInventoryWebhookOptions, InventoryWebhook, InventoryWebhookDelivery, InventoryWebhookList, InventoryWebhookPatch, InventoryWebhookTestResult, InventoryWebhookWithSecret, Location, StockLevel, StockListQuery, StockMovement, StockMovementPage, StockMovementQuery, StockPage, StockResult } from './typen.js';
8
8
  import type { InventoryWebhookEventType } from './vertrag.js';
9
9
  export interface InventoryClientOptions {
10
10
  /** `api_key` des Kontos (`kr_live_…` / `kr_test_…`). Gehoert auf einen Server. */
@@ -65,5 +65,24 @@ export interface InventoryClient {
65
65
  getVariantGroup(variantGroupId: string): Promise<VariantGroup>;
66
66
  listVariantGroups(query?: VariantGroupListQuery): Promise<VariantGroupPage>;
67
67
  iterateVariantGroups(query?: VariantGroupListQuery): AsyncGenerator<VariantGroup, void, undefined>;
68
+ createStocktake(request: CreateStocktakeRequest): Promise<Stocktake>;
69
+ /** Ohne `updatedSince` zuletzt geaenderte zuerst, mit `updatedSince` aufsteigend und inklusive. */
70
+ listStocktakes(query?: StocktakeListQuery): Promise<StocktakePage>;
71
+ iterateStocktakes(query?: StocktakeListQuery): AsyncGenerator<Stocktake, void, undefined>;
72
+ getStocktake(stocktakeId: string): Promise<Stocktake>;
73
+ listStocktakeItems(query: StocktakeItemListQuery): Promise<StocktakeItemPage>;
74
+ iterateStocktakeItems(query: StocktakeItemListQuery): AsyncGenerator<StocktakeItem, void, undefined>;
75
+ recordStocktakeCount(request: RecordStocktakeCountRequest): Promise<StocktakeCountResult>;
76
+ voidStocktakeCount(request: VoidStocktakeCountRequest): Promise<StocktakeCountResult>;
77
+ listStocktakeCounts(query: StocktakeCountListQuery): Promise<StocktakeCountPage>;
78
+ iterateStocktakeCounts(query: StocktakeCountListQuery): AsyncGenerator<StocktakeCount, void, undefined>;
79
+ /** Pruefen; die Antwort kommt mit `review.complete: false`, gerechnet wird im Hintergrund. */
80
+ reviewStocktake(request: ReviewStocktakeRequest): Promise<Stocktake>;
81
+ recountStocktake(request: RecountStocktakeRequest): Promise<Stocktake>;
82
+ /** Abschliessen; der Server bucht in Teilen weiter (`status: 'closing'`). */
83
+ closeStocktake(request: CloseStocktakeRequest): Promise<CloseStocktakeResult>;
84
+ cancelStocktake(request: CancelStocktakeRequest): Promise<Stocktake>;
85
+ /** Das Inventurprotokoll: die Datei (`kind: 'pdf'`) oder, ueber 9 MiB, ein Lese-Link (`kind: 'download'`). */
86
+ getStocktakePdf(stocktakeId: string): Promise<StocktakePdf>;
68
87
  }
69
88
  export declare function createInventoryClient(options: InventoryClientOptions): InventoryClient;
@@ -1,20 +1,24 @@
1
1
  /**
2
2
  * Fassade ueber den Aufrufen der Lager-API (lesen, Webhooks, schreiben,
3
- * reservieren, Varianten): Schluessel einmal binden, dann rufen. Wie [createInvoiceApi] bewusst keine Klasse; die Aufrufe sind freie
3
+ * reservieren, Varianten, Inventur): Schluessel einmal binden, dann rufen. Wie [createInvoiceApi] bewusst keine Klasse; die Aufrufe sind freie
4
4
  * Funktionen (endpunkte.ts) und bleiben einzeln importierbar.
5
5
  */
6
- import { createTransport } from '../client/transport.js';
6
+ import { createPdfOrDataTransport, createTransport } from '../client/transport.js';
7
7
  import { inventoryKeyAuth } from './auth.js';
8
8
  import { createWebhook, deleteWebhook, getArticle, getStock, iterateArticles, iterateStock, iterateStockMovements, listArticles, listLocations, listStock, listStockMovements, listWebhookDeliveries, listWebhooks, lookupArticleByCode, rotateWebhookSecret, sendWebhookTest, updateWebhook, } from './endpunkte.js';
9
9
  import { changeStockCondition, createArticle, createReservation, deactivateArticle, extendReservation, getReservation, iterateReservations, listReservations, previewGoodsReceipt, receiveGoods, recordStockLoss, releaseReservation, reverseStockMovement, transferStock, updateArticle, } from './schreiben.js';
10
+ import { cancelStocktake, closeStocktake, createStocktake, getStocktake, getStocktakePdf, iterateStocktakeCounts, iterateStocktakeItems, iterateStocktakes, listStocktakeCounts, listStocktakeItems, listStocktakes, recordStocktakeCount, recountStocktake, reviewStocktake, voidStocktakeCount, } from './inventur.js';
10
11
  import { addVariant, createVariantGroup, getVariantGroup, iterateVariantGroups, listVariantGroups, updateVariantGroup, } from './varianten.js';
11
12
  export function createInventoryClient(options) {
12
- const rufen = createTransport({
13
+ const transportOptionen = {
13
14
  auth: inventoryKeyAuth({ apiKey: options.apiKey }),
14
15
  baseUrl: options.baseUrl,
15
16
  timeoutMs: options.timeoutMs,
16
17
  fetch: options.fetch,
17
- });
18
+ };
19
+ const rufen = createTransport(transportOptionen);
20
+ // Das Inventurprotokoll kommt als Datei oder als Lese-Link (ueber 9 MiB).
21
+ const rufenDatei = createPdfOrDataTransport(transportOptionen);
18
22
  return {
19
23
  getArticle: (id) => getArticle(rufen, id),
20
24
  listArticles: (q) => listArticles(rufen, q),
@@ -54,5 +58,20 @@ export function createInventoryClient(options) {
54
58
  getVariantGroup: (id) => getVariantGroup(rufen, id),
55
59
  listVariantGroups: (q) => listVariantGroups(rufen, q),
56
60
  iterateVariantGroups: (q) => iterateVariantGroups(rufen, q),
61
+ createStocktake: (r) => createStocktake(rufen, r),
62
+ listStocktakes: (q) => listStocktakes(rufen, q),
63
+ iterateStocktakes: (q) => iterateStocktakes(rufen, q),
64
+ getStocktake: (id) => getStocktake(rufen, id),
65
+ listStocktakeItems: (q) => listStocktakeItems(rufen, q),
66
+ iterateStocktakeItems: (q) => iterateStocktakeItems(rufen, q),
67
+ recordStocktakeCount: (r) => recordStocktakeCount(rufen, r),
68
+ voidStocktakeCount: (r) => voidStocktakeCount(rufen, r),
69
+ listStocktakeCounts: (q) => listStocktakeCounts(rufen, q),
70
+ iterateStocktakeCounts: (q) => iterateStocktakeCounts(rufen, q),
71
+ reviewStocktake: (r) => reviewStocktake(rufen, r),
72
+ recountStocktake: (r) => recountStocktake(rufen, r),
73
+ closeStocktake: (r) => closeStocktake(rufen, r),
74
+ cancelStocktake: (r) => cancelStocktake(rufen, r),
75
+ getStocktakePdf: (id) => getStocktakePdf(rufenDatei, id),
57
76
  };
58
77
  }
@@ -41,3 +41,9 @@ export declare function inventoryRetryAfterSec(error: unknown): number | undefin
41
41
  export declare function inventoryShortfalls(error: unknown): InventoryShortfall[];
42
42
  /** `true` fuer einen Hinweis-Code einer Buchung (`warnings[].code`); Hinweise sind nie Fehler. */
43
43
  export declare function isInventoryWarningCode(value: unknown): value is InventoryWarningCode;
44
+ /**
45
+ * Die Inventur, die einen Standort belegt (`stocktake_location_busy`,
46
+ * `data.stocktakeId`): weiterzaehlen statt neu anlegen. `undefined`, wenn der
47
+ * Fehler ein anderer ist oder der Server keine Kennung nennt.
48
+ */
49
+ export declare function inventoryBusyStocktakeId(error: unknown): string | undefined;
@@ -55,3 +55,14 @@ const HINWEISE = new Set(INVENTORY_WARNING_CODES);
55
55
  export function isInventoryWarningCode(value) {
56
56
  return typeof value === 'string' && HINWEISE.has(value);
57
57
  }
58
+ /**
59
+ * Die Inventur, die einen Standort belegt (`stocktake_location_busy`,
60
+ * `data.stocktakeId`): weiterzaehlen statt neu anlegen. `undefined`, wenn der
61
+ * Fehler ein anderer ist oder der Server keine Kennung nennt.
62
+ */
63
+ export function inventoryBusyStocktakeId(error) {
64
+ if (inventoryErrorCode(error) !== 'stocktake_location_busy')
65
+ return undefined;
66
+ const wert = error.details['stocktakeId'];
67
+ return typeof wert === 'string' && wert !== '' ? wert : undefined;
68
+ }
@@ -3,7 +3,8 @@
3
3
  * Bestand und Lagerprotokoll lesen, Konto-Webhooks verwalten und eingehende
4
4
  * Zustellungen pruefen (Backend Stufe 5a); Artikel anlegen und aendern,
5
5
  * Bestand buchen und Ware reservieren (Stufe 5b, seit 1.5.0);
6
- * Variantengruppen (Stufe 5c, seit 1.6.0).
6
+ * Variantengruppen (Stufe 5c, seit 1.6.0); Inventur (Lager-Kern Stufe 3,
7
+ * seit 1.8.0).
7
8
  *
8
9
  * Ein eigener Unterpfad wie `invoice`: der `api_key` eines Kontos gehoert auf
9
10
  * einen **Server** (etwa das Backend eines Online-Shops) und soll nicht
@@ -14,10 +15,11 @@
14
15
  */
15
16
  export { createInventoryClient, type InventoryClient, type InventoryClientOptions } from './api.js';
16
17
  export { inventoryKeyAuth, type InventoryKeyAuthOptions } from './auth.js';
17
- export { isInventoryError, isInventoryErrorCode, inventoryErrorCode, inventoryFieldErrors, inventoryRetryAfterSec, inventoryShortfalls, isInventoryWarningCode, type InventoryApiErrorCode, type InventoryFieldError, } from './fehler.js';
18
+ export { isInventoryError, isInventoryErrorCode, inventoryErrorCode, inventoryFieldErrors, inventoryRetryAfterSec, inventoryShortfalls, inventoryBusyStocktakeId, isInventoryWarningCode, type InventoryApiErrorCode, type InventoryFieldError, } from './fehler.js';
18
19
  export { createWebhook, deleteWebhook, getArticle, getStock, iterateArticles, iterateStock, iterateStockMovements, listArticles, listLocations, listStock, listStockMovements, listWebhookDeliveries, listWebhooks, lookupArticleByCode, rotateWebhookSecret, sendWebhookTest, updateWebhook, } from './endpunkte.js';
19
20
  export { changeStockCondition, createArticle, createReservation, deactivateArticle, extendReservation, getReservation, iterateReservations, listReservations, previewGoodsReceipt, receiveGoods, recordStockLoss, releaseReservation, reverseStockMovement, transferStock, updateArticle, } from './schreiben.js';
20
21
  export { addVariant, createVariantGroup, getVariantGroup, iterateVariantGroups, listVariantGroups, updateVariantGroup, } from './varianten.js';
22
+ export { cancelStocktake, closeStocktake, createStocktake, getStocktake, getStocktakePdf, iterateStocktakeCounts, iterateStocktakeItems, iterateStocktakes, listStocktakeCounts, listStocktakeItems, listStocktakes, recordStocktakeCount, recountStocktake, reviewStocktake, voidStocktakeCount, } from './inventur.js';
21
23
  export { verifyInventoryWebhookSignature, parseInventoryWebhookEvent, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_EVENT_HEADER, WEBHOOK_DELIVERY_HEADER, WEBHOOK_TOLERANCE_SEC, type VerifyInventoryWebhookOptions, } from './webhook.js';
22
- export type { AddVariantRequest, Article, ArticleInput, ArticleListQuery, ArticleLookup, ArticlePage, ChangeStockConditionRequest, CreateArticleRequest, CreateInventoryWebhookOptions, CreateReservationRequest, CreateVariantGroupRequest, DeactivateArticleRequest, ExtendReservationRequest, GoodsReceiptItem, GoodsReceiptPreview, GoodsReceiptPreviewLine, GoodsReceiptPreviewRequest, InventoryShortfall, InventoryWarning, InventoryWebhook, InventoryWebhookDelivery, InventoryWebhookEnvelope, InventoryWebhookEvent, InventoryWebhookList, InventoryWebhookPatch, InventoryWebhookTestDelivery, InventoryWebhookTestResult, InventoryWebhookWithSecret, LandedCost, Location, LocationAddress, ReceiveGoodsRequest, RecordStockLossRequest, ReleaseReservationItem, ReleaseReservationRequest, Reservation, ReservationItem, ReservationItemInput, ReservationListQuery, ReservationPage, ReverseStockMovementRequest, StockBelowMinimumEventData, StockChangedEventData, StockItem, StockLevel, StockListQuery, StockMovement, StockMovementLot, StockMovementPage, StockMovementQuery, StockMovementSourceRef, StockOperation, StockPage, StockResult, StockValue, TransferStockRequest, UpdateArticleRequest, UpdateVariantGroupRequest, VariantAttribute, VariantGroup, VariantGroupDefaults, VariantGroupDefaultsInput, VariantGroupListQuery, VariantGroupMember, VariantGroupPage, VariantInput, } from './typen.js';
23
- export { INVENTORY_ENDPOINTS, INVENTORY_ERROR_CODES, INVENTORY_REQUEST_ERROR_CODES, INVENTORY_WEBHOOK_EVENTS, INVENTORY_WEBHOOK_ENVELOPE_FIELDS, INVENTORY_WEBHOOK_LIMIT, INVENTORY_LIST_LIMIT_MAX, LOCATION_TYPES, STOCK_MOVEMENT_TYPES, STOCK_MOVEMENT_SOURCES, STOCK_CONDITIONS, STOCK_CHANGE_CAUSES, WEBHOOK_DELIVERY_STATUSES, INVENTORY_WARNING_CODES, STOCK_KINDS, STOCK_LOSS_REASONS, WITHDRAWAL_TYPES, LANDED_COST_TYPES, LANDED_COST_ALLOCATIONS, RESERVATION_STATUSES, INVENTORY_IDEMPOTENCY_KEY_MAX, RESERVATION_MINUTES_MIN, RESERVATION_MINUTES_MAX, VARIANT_ATTRIBUTES_MAX, VARIANT_VALUES_MAX, VARIANT_MATRIX_MAX, VARIANT_GROUP_ACTIVE_MAX, type InventoryEndpoint, type InventoryErrorCode, type InventoryRequestErrorCode, type InventoryWebhookEventType, type LocationType, type StockMovementType, type StockMovementSource, type StockCondition, type StockChangeCause, type WebhookDeliveryStatus, type InventoryWarningCode, type StockKind, type StockLossReason, type WithdrawalType, type LandedCostType, type LandedCostAllocation, type ReservationStatus, } from './vertrag.js';
24
+ export type { AddVariantRequest, Article, CancelStocktakeRequest, CloseStocktakeRequest, CloseStocktakeResult, CreateStocktakeRequest, RecordStocktakeCountRequest, RecountStocktakeRequest, ReviewStocktakeRequest, Stocktake, StocktakeActor, StocktakeCancellation, StocktakeClosing, StocktakeCount, StocktakeCountListQuery, StocktakeCountPage, StocktakeCountResult, StocktakeInventoryLine, StocktakeItem, StocktakeItemListQuery, StocktakeItemPage, StocktakeListQuery, StocktakeNotBooked, StocktakePage, StocktakePdf, StocktakePdfDownload, StocktakePdfInfo, StocktakeProgress, StocktakeRecount, StocktakeReview, StocktakeScope, StocktakeScopeInput, StocktakeSeal, StocktakeTotals, StocktakeWarning, VoidStocktakeCountRequest, ArticleInput, ArticleListQuery, ArticleLookup, ArticlePage, ChangeStockConditionRequest, CreateArticleRequest, CreateInventoryWebhookOptions, CreateReservationRequest, CreateVariantGroupRequest, DeactivateArticleRequest, ExtendReservationRequest, GoodsReceiptItem, GoodsReceiptPreview, GoodsReceiptPreviewLine, GoodsReceiptPreviewRequest, InventoryShortfall, InventoryWarning, InventoryWebhook, InventoryWebhookDelivery, InventoryWebhookEnvelope, InventoryWebhookEvent, InventoryWebhookList, InventoryWebhookPatch, InventoryWebhookTestDelivery, InventoryWebhookTestResult, InventoryWebhookWithSecret, LandedCost, Location, LocationAddress, ReceiveGoodsRequest, RecordStockLossRequest, ReleaseReservationItem, ReleaseReservationRequest, Reservation, ReservationItem, ReservationItemInput, ReservationListQuery, ReservationPage, ReverseStockMovementRequest, StockBelowMinimumEventData, StockChangedEventData, StockItem, StockLevel, StockListQuery, StockMovement, StockMovementLot, StockMovementPage, StockMovementQuery, StockMovementSourceRef, StockOperation, StockPage, StockResult, StockValue, TransferStockRequest, UpdateArticleRequest, UpdateVariantGroupRequest, VariantAttribute, VariantGroup, VariantGroupDefaults, VariantGroupDefaultsInput, VariantGroupListQuery, VariantGroupMember, VariantGroupPage, VariantInput, } from './typen.js';
25
+ export { INVENTORY_ENDPOINTS, INVENTORY_ERROR_CODES, INVENTORY_REQUEST_ERROR_CODES, INVENTORY_WEBHOOK_EVENTS, INVENTORY_WEBHOOK_ENVELOPE_FIELDS, INVENTORY_WEBHOOK_LIMIT, INVENTORY_LIST_LIMIT_MAX, LOCATION_TYPES, STOCK_MOVEMENT_TYPES, STOCK_MOVEMENT_SOURCES, STOCK_CONDITIONS, STOCK_CHANGE_CAUSES, WEBHOOK_DELIVERY_STATUSES, INVENTORY_WARNING_CODES, STOCK_KINDS, STOCK_LOSS_REASONS, WITHDRAWAL_TYPES, LANDED_COST_TYPES, LANDED_COST_ALLOCATIONS, RESERVATION_STATUSES, INVENTORY_IDEMPOTENCY_KEY_MAX, RESERVATION_MINUTES_MIN, RESERVATION_MINUTES_MAX, VARIANT_ATTRIBUTES_MAX, VARIANT_VALUES_MAX, VARIANT_MATRIX_MAX, VARIANT_GROUP_ACTIVE_MAX, STOCKTAKE_STATUSES, STOCKTAKE_TYPES, STOCKTAKE_SCOPE_TYPES, STOCKTAKE_CHECK_REASONS, STOCKTAKE_NOT_BOOKED_REASONS, STOCKTAKE_SOURCES, STOCKTAKE_ACTOR_TYPES, STOCKTAKE_INVENTORY_AS_OF, STOCKTAKE_ITEMS_MAX, STOCKTAKE_RECOUNT_ITEMS_MAX, STOCKTAKE_COUNTS_PER_ITEM_MAX, type StocktakeStatus, type StocktakeType, type StocktakeScopeType, type StocktakeCheckReason, type StocktakeNotBookedReason, type StocktakeSource, type StocktakeActorType, type StocktakeInventoryAsOf, type InventoryEndpoint, type InventoryErrorCode, type InventoryRequestErrorCode, type InventoryWebhookEventType, type LocationType, type StockMovementType, type StockMovementSource, type StockCondition, type StockChangeCause, type WebhookDeliveryStatus, type InventoryWarningCode, type StockKind, type StockLossReason, type WithdrawalType, type LandedCostType, type LandedCostAllocation, type ReservationStatus, } from './vertrag.js';
@@ -3,7 +3,8 @@
3
3
  * Bestand und Lagerprotokoll lesen, Konto-Webhooks verwalten und eingehende
4
4
  * Zustellungen pruefen (Backend Stufe 5a); Artikel anlegen und aendern,
5
5
  * Bestand buchen und Ware reservieren (Stufe 5b, seit 1.5.0);
6
- * Variantengruppen (Stufe 5c, seit 1.6.0).
6
+ * Variantengruppen (Stufe 5c, seit 1.6.0); Inventur (Lager-Kern Stufe 3,
7
+ * seit 1.8.0).
7
8
  *
8
9
  * Ein eigener Unterpfad wie `invoice`: der `api_key` eines Kontos gehoert auf
9
10
  * einen **Server** (etwa das Backend eines Online-Shops) und soll nicht
@@ -14,9 +15,10 @@
14
15
  */
15
16
  export { createInventoryClient } from './api.js';
16
17
  export { inventoryKeyAuth } from './auth.js';
17
- export { isInventoryError, isInventoryErrorCode, inventoryErrorCode, inventoryFieldErrors, inventoryRetryAfterSec, inventoryShortfalls, isInventoryWarningCode, } from './fehler.js';
18
+ export { isInventoryError, isInventoryErrorCode, inventoryErrorCode, inventoryFieldErrors, inventoryRetryAfterSec, inventoryShortfalls, inventoryBusyStocktakeId, isInventoryWarningCode, } from './fehler.js';
18
19
  export { createWebhook, deleteWebhook, getArticle, getStock, iterateArticles, iterateStock, iterateStockMovements, listArticles, listLocations, listStock, listStockMovements, listWebhookDeliveries, listWebhooks, lookupArticleByCode, rotateWebhookSecret, sendWebhookTest, updateWebhook, } from './endpunkte.js';
19
20
  export { changeStockCondition, createArticle, createReservation, deactivateArticle, extendReservation, getReservation, iterateReservations, listReservations, previewGoodsReceipt, receiveGoods, recordStockLoss, releaseReservation, reverseStockMovement, transferStock, updateArticle, } from './schreiben.js';
20
21
  export { addVariant, createVariantGroup, getVariantGroup, iterateVariantGroups, listVariantGroups, updateVariantGroup, } from './varianten.js';
22
+ export { cancelStocktake, closeStocktake, createStocktake, getStocktake, getStocktakePdf, iterateStocktakeCounts, iterateStocktakeItems, iterateStocktakes, listStocktakeCounts, listStocktakeItems, listStocktakes, recordStocktakeCount, recountStocktake, reviewStocktake, voidStocktakeCount, } from './inventur.js';
21
23
  export { verifyInventoryWebhookSignature, parseInventoryWebhookEvent, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_EVENT_HEADER, WEBHOOK_DELIVERY_HEADER, WEBHOOK_TOLERANCE_SEC, } from './webhook.js';
22
- export { INVENTORY_ENDPOINTS, INVENTORY_ERROR_CODES, INVENTORY_REQUEST_ERROR_CODES, INVENTORY_WEBHOOK_EVENTS, INVENTORY_WEBHOOK_ENVELOPE_FIELDS, INVENTORY_WEBHOOK_LIMIT, INVENTORY_LIST_LIMIT_MAX, LOCATION_TYPES, STOCK_MOVEMENT_TYPES, STOCK_MOVEMENT_SOURCES, STOCK_CONDITIONS, STOCK_CHANGE_CAUSES, WEBHOOK_DELIVERY_STATUSES, INVENTORY_WARNING_CODES, STOCK_KINDS, STOCK_LOSS_REASONS, WITHDRAWAL_TYPES, LANDED_COST_TYPES, LANDED_COST_ALLOCATIONS, RESERVATION_STATUSES, INVENTORY_IDEMPOTENCY_KEY_MAX, RESERVATION_MINUTES_MIN, RESERVATION_MINUTES_MAX, VARIANT_ATTRIBUTES_MAX, VARIANT_VALUES_MAX, VARIANT_MATRIX_MAX, VARIANT_GROUP_ACTIVE_MAX, } from './vertrag.js';
24
+ export { INVENTORY_ENDPOINTS, INVENTORY_ERROR_CODES, INVENTORY_REQUEST_ERROR_CODES, INVENTORY_WEBHOOK_EVENTS, INVENTORY_WEBHOOK_ENVELOPE_FIELDS, INVENTORY_WEBHOOK_LIMIT, INVENTORY_LIST_LIMIT_MAX, LOCATION_TYPES, STOCK_MOVEMENT_TYPES, STOCK_MOVEMENT_SOURCES, STOCK_CONDITIONS, STOCK_CHANGE_CAUSES, WEBHOOK_DELIVERY_STATUSES, INVENTORY_WARNING_CODES, STOCK_KINDS, STOCK_LOSS_REASONS, WITHDRAWAL_TYPES, LANDED_COST_TYPES, LANDED_COST_ALLOCATIONS, RESERVATION_STATUSES, INVENTORY_IDEMPOTENCY_KEY_MAX, RESERVATION_MINUTES_MIN, RESERVATION_MINUTES_MAX, VARIANT_ATTRIBUTES_MAX, VARIANT_VALUES_MAX, VARIANT_MATRIX_MAX, VARIANT_GROUP_ACTIVE_MAX, STOCKTAKE_STATUSES, STOCKTAKE_TYPES, STOCKTAKE_SCOPE_TYPES, STOCKTAKE_CHECK_REASONS, STOCKTAKE_NOT_BOOKED_REASONS, STOCKTAKE_SOURCES, STOCKTAKE_ACTOR_TYPES, STOCKTAKE_INVENTORY_AS_OF, STOCKTAKE_ITEMS_MAX, STOCKTAKE_RECOUNT_ITEMS_MAX, STOCKTAKE_COUNTS_PER_ITEM_MAX, } from './vertrag.js';
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Inventur der Lager-API (Lager-Kern Stufe 3): anlegen, zaehlen, Zaehlungen
3
+ * stornieren, pruefen, nachzaehlen, abschliessen, abbrechen, Inventurprotokoll
4
+ * holen; dazu die Listen der Inventuren, Positionen und Zaehlungen.
5
+ *
6
+ * Ablauf: `createStocktake` → `recordStocktakeCount` (beliebig oft, auch von
7
+ * mehreren Geraeten; je Position addiert) → `reviewStocktake` (erst jetzt Soll
8
+ * und Differenz) → bei Bedarf `recountStocktake` und erneut `reviewStocktake`
9
+ * → `closeStocktake` → `getStocktakePdf`. Pruefen und Abschliessen rechnet der
10
+ * Server im Hintergrund: die Antwort traegt den Zwischenstand
11
+ * (`review.complete: false` bzw. `status: 'closing'`), `getStocktake` den
12
+ * Fortgang.
13
+ *
14
+ * **Blind:** vor `review` traegt keine Antwort ein Soll; `blind: false` zeigt
15
+ * beim Zaehlen nur den heutigen Buchbestand (`bookStockNow`), nie das Soll
16
+ * zur Referenzzeit.
17
+ *
18
+ * Rechte wie in Stufe 5b: Lesen mit jedem Schluessel, alles Schreibende (auch
19
+ * Zaehlen) mit dem Konto-Schalter „Lager-API schreiben“ (Test-Schluessel
20
+ * immer), sonst `inventory_api_not_enabled`; Werte und das Protokoll mit
21
+ * Werten nur mit `lagerApi.kosten`.
22
+ *
23
+ * **Vor dem Senden geprueft wird nur, was ohne Netz sicher falsch ist:**
24
+ * `idempotencyKey` (Pflicht bei jedem Schreiben, 1–120 Zeichen), fehlende
25
+ * Kennungen (`stocktakeId`, `articleId`, `countId`, `locationId`), `scope`
26
+ * kein Objekt, eine Menge, die keine Ganzzahl ist (Tausendstel), ein leerer
27
+ * Grund, `items` beim Nachzaehlen leer oder ohne `articleId`,
28
+ * `serialNumbers` keine Liste, `uncountedAsZero` kein Wahrheitswert. Alles
29
+ * Fachliche (Umfang, Stichtag, Seriennummern, Zustand) prueft der Server.
30
+ *
31
+ * **Wiederholen** wie bei jedem Schreiben: nach `outcome: 'unknown'` denselben
32
+ * Aufruf mit **demselben** `idempotencyKey`. Eine Zaehlung wirkt dann genau
33
+ * einmal (das Zaehldokument ist selbst der Nachweis); ein neuer Schluessel
34
+ * zaehlte die Ware ein zweites Mal.
35
+ */
36
+ import type { ApiCall, InternerPdfOderDatenTransport, InternerTransport } from '../client/aufrufe.js';
37
+ import type { CancelStocktakeRequest, CloseStocktakeRequest, CloseStocktakeResult, CreateStocktakeRequest, RecordStocktakeCountRequest, RecountStocktakeRequest, ReviewStocktakeRequest, Stocktake, StocktakeCount, StocktakeCountListQuery, StocktakeCountPage, StocktakeCountResult, StocktakeItem, StocktakeItemListQuery, StocktakeItemPage, StocktakeListQuery, StocktakePage, StocktakePdf, VoidStocktakeCountRequest } from './typen.js';
38
+ type Params = Record<string, unknown>;
39
+ /**
40
+ * Legt eine Inventur an. Je Standort hoechstens eine offene
41
+ * (`stocktake_location_busy`, `data.stocktakeId` nennt sie); Umfang `groups`
42
+ * bzw. `articles` nur mit bestandsgefuehrten Artikeln (`article_not_tracked`).
43
+ * Jede Inventur beginnt in `counting`.
44
+ */
45
+ export declare function createStocktake(transport: InternerTransport, request: CreateStocktakeRequest): Promise<Stocktake>;
46
+ /**
47
+ * Inventuren des Kontos. Ohne `updatedSince` zuletzt geaenderte zuerst; mit
48
+ * `updatedSince` aufsteigend nach `updatedAt` und inklusive (Abgleich: das
49
+ * groesste gesehene `updatedAt` als naechstes `updatedSince`). Filter
50
+ * `status` und `locationId`.
51
+ */
52
+ export declare function listStocktakes(transport: InternerTransport, query?: StocktakeListQuery): Promise<StocktakePage>;
53
+ /** Alle Inventuren der Abfrage, Seite fuer Seite, in der Reihenfolge von [listStocktakes]. */
54
+ export declare function iterateStocktakes(transport: InternerTransport, query?: StocktakeListQuery): AsyncGenerator<Stocktake, void, undefined>;
55
+ /** Eine Inventur samt `progress.counted` (gezaehlte Positionen). */
56
+ export declare function getStocktake(transport: InternerTransport, stocktakeId: string): Promise<Stocktake>;
57
+ /** Positionen einer Inventur nach Kennung; `openOnly` = ungezaehlt bzw. in `review` zum Nachzaehlen offen. */
58
+ export declare function listStocktakeItems(transport: InternerTransport, query: StocktakeItemListQuery): Promise<StocktakeItemPage>;
59
+ export declare function iterateStocktakeItems(transport: InternerTransport, query: StocktakeItemListQuery): AsyncGenerator<StocktakeItem, void, undefined>;
60
+ /** Zaehlungen einer Inventur, neueste zuerst, auch stornierte; mit `articleId` nur die des Artikels. */
61
+ export declare function listStocktakeCounts(transport: InternerTransport, query: StocktakeCountListQuery): Promise<StocktakeCountPage>;
62
+ export declare function iterateStocktakeCounts(transport: InternerTransport, query: StocktakeCountListQuery): AsyncGenerator<StocktakeCount, void, undefined>;
63
+ /** Pruefung einer Zaehlung vor dem Senden, geteilt mit dem Kassenweg. Paketintern. */
64
+ export declare function zaehlungPruefen(name: ApiCall, p: Params): void;
65
+ /** Pruefung eines Stornos vor dem Senden, geteilt mit dem Kassenweg. Paketintern. */
66
+ export declare function stornoPruefen(name: ApiCall, p: Params): void;
67
+ /**
68
+ * Eine Zaehlung. Antwort: die Zaehlung und ihre Position danach (Summe der
69
+ * Runde in `item.quantity`). Gezaehlt wird in `counting`, in `review` nur an
70
+ * Positionen, die zum Nachzaehlen frei sind (sonst `stocktake_not_open`).
71
+ */
72
+ export declare function recordStocktakeCount(transport: InternerTransport, request: RecordStocktakeCountRequest): Promise<StocktakeCountResult>;
73
+ /** Storniert eine Zaehlung mit Grund; die Position wird aus den uebrigen Zaehlungen neu summiert. */
74
+ export declare function voidStocktakeCount(transport: InternerTransport, request: VoidStocktakeCountRequest): Promise<StocktakeCountResult>;
75
+ /**
76
+ * Pruefen: `counting` → `review`, in `review` neu rechnen (nach dem
77
+ * Nachzaehlen). Die Antwort kommt sofort mit `review.complete: false`; Soll
78
+ * und Differenz stehen an den Positionen, sobald `complete` `true` ist.
79
+ */
80
+ export declare function reviewStocktake(transport: InternerTransport, request: ReviewStocktakeRequest): Promise<Stocktake>;
81
+ /** Nachzaehlen: je genannter Position eine neue Runde; danach zaehlen und erneut [reviewStocktake]. */
82
+ export declare function recountStocktake(transport: InternerTransport, request: RecountStocktakeRequest): Promise<Stocktake>;
83
+ /**
84
+ * Abschliessen (nur aus `review`, sonst `stocktake_not_in_review`; offene
85
+ * Nachzaehlungen ergeben `stocktake_recount_open`). Der Server bucht in
86
+ * Teilen weiter; die Antwort traegt meist `status: 'closing'`. Ein erneuter
87
+ * Aufruf waehrend `closing` stoesst den Abschluss wieder an.
88
+ */
89
+ export declare function closeStocktake(transport: InternerTransport, request: CloseStocktakeRequest): Promise<CloseStocktakeResult>;
90
+ /** Abbrechen mit Grund (aus `counting` oder `review`); der Standort ist danach frei. */
91
+ export declare function cancelStocktake(transport: InternerTransport, request: CancelStocktakeRequest): Promise<Stocktake>;
92
+ /**
93
+ * Das Inventurprotokoll (PDF), erst nach dem Abschluss (`stocktake_not_closed`,
94
+ * auch fuer eine abgebrochene Inventur). Mit `lagerApi.kosten` die Fassung mit
95
+ * Werten, sonst die nur mit Mengen. Bis 9 MiB kommt die Datei selbst
96
+ * (`kind: 'pdf'`), darueber ein signierter Lese-Link fuer 15 Minuten
97
+ * (`kind: 'download'`); die geladene Datei an `download.sha256` pruefen.
98
+ *
99
+ * Als freie Funktion braucht sie den Transport aus `createPdfOrDataTransport`
100
+ * (Paketwurzel): ein JSON-Transport laese die Datei als Text, ein reiner
101
+ * Binaer-Transport kennt den Link nicht. [createInventoryClient] bindet ihn selbst.
102
+ */
103
+ export declare function getStocktakePdf(transport: InternerPdfOderDatenTransport, stocktakeId: string): Promise<StocktakePdf>;
104
+ export {};