@kreiseck/kasseneck-api 0.15.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,25 @@ Was vor 0.7.0 geschah, steht in der Commit-Historie (`git log`); ab hier wird
4
4
  es hier geführt. Ein Eintrag nennt die Änderung **und ihren Grund** —
5
5
  nur der Grund überlebt den nächsten Umbau.
6
6
 
7
+ ## 0.16.0
8
+
9
+ ### Rechnungs-API: Freigabe und Einrichtung vor dem ersten Ausstellen
10
+
11
+ **Anlass:** Mit 0.15.0 konnte jedes Konto mit aktivem Modul Rechnung sofort
12
+ automatisiert Rechnungen mit fortlaufender Nummer ausstellen — auch mit einem
13
+ Probezeitraum, ohne Bankverbindung und mit dem ungewollten Standard-Nummernformat,
14
+ das sich mit der ersten Rechnung sperrt. Ein Fremdsystem erfuhr erst beim
15
+ Festschreiben, dass etwas fehlt.
16
+
17
+ - Neuer Aufruf `getInvoiceSetupStatus()` → `{ ready, environment, missing }`.
18
+ Er läuft auch ohne Freigabe und vor der Live-Freischaltung, also genau dann,
19
+ wenn man die Antwort braucht.
20
+ - `INVOICE_SETUP_REQUIREMENTS`: `module_active`, `api_enabled`, `live_enabled`,
21
+ `business_name`, `address`, `vat_id`, `bank_account`, `number_format`.
22
+ - Neue Fehlercodes: `invoice_api_not_enabled` (Kasseneck hat die Rechnungs-API
23
+ für das Konto nicht freigegeben; nur live) und `invoice_setup_incomplete`
24
+ (`details.missing` wie im Status).
25
+
7
26
  ## 0.15.0
8
27
 
9
28
  ### Rechnungs-API: Rechnungen statt Belege, per `api_key`
package/README.md CHANGED
@@ -479,6 +479,16 @@ await rechnungen.createCreditNote({
479
479
  });
480
480
  ```
481
481
 
482
+ **Vor dem ersten Ausstellen die Einrichtung abfragen.** Die Rechnungs-API muss
483
+ für das Konto von Kasseneck freigegeben sein (live), und Firmenname, Anschrift,
484
+ UID, Bankverbindung und Nummernformat müssen stehen — sonst antwortet
485
+ `issueInvoice` mit `invoice_api_not_enabled` bzw. `invoice_setup_incomplete`:
486
+
487
+ ```ts
488
+ const status = await rechnungen.getInvoiceSetupStatus();
489
+ if (!status.ready) console.warn(status.missing.map((m) => m.message).join('\n'));
490
+ ```
491
+
482
492
  **Nach einem Zeitlimit mit demselben `idempotencyKey` wiederholen**, nie mit
483
493
  einem neuen: dann kommt die schon ausgestellte Rechnung zurück
484
494
  (`replayed: true`). Derselbe Schlüssel mit anderen Daten ergibt
@@ -13,7 +13,7 @@
13
13
  * umhuellt, muss ihn weiterhin absetzen koennen.
14
14
  */
15
15
  import type { TransportBodyFields } from './transport.js';
16
- export declare const AUFRUFE: readonly ["activateCashregister", "cancelInvoice", "cancelReceipt", "createCreditNote", "createCustomer", "createCustomerCashregister", "createPartnerCustomer", "checkPartnerCustomerEmail", "createPartnerWebhook", "createPaymentLinkStripe", "createPrintJob", "createReceipt", "deletePartnerWebhook", "downloadDailyReport", "downloadReport", "endRegisterSession", "financeWebService", "generateFullReceiptId", "getCustomer", "getCustomerCredentials", "getCustomerSignatureStatus", "getFirstReceiptDate", "getInvoice", "getInvoicePdf", "getInvoiceXml", "getKasseSettings", "getPartnerCustomer", "getPartnerInfo", "getPrintJob", "getReceipt", "hobexPayApi", "hobexRefundApi", "issueInvoice", "listCustomerCashregisters", "listInvoices", "listMyArticleGroups", "listMyArticles", "listMyCashregisters", "listMyPrinters", "listMyReceipts", "listMyTipRecipients", "listPartnerCustomers", "listPartnerWebhookDeliveries", "listPartnerWebhooks", "listRegisterUsersForDevice", "listRegisterSessionsForDevice", "pairRegisterDevice", "registerPinLogin", "registerUserLogin", "renewRegisterSession", "requestCustomerSignature", "searchCustomers", "sendPartnerCustomerFonLink", "sendPartnerWebhookTest", "sendReceiptEmail", "setMyKasseSettings", "setMyRegisterDeviceSettings", "stripeCaptureIntent", "unpairRegisterDevice", "rotatePartnerWebhookSecret", "updateCustomer", "updatePartnerWebhook"];
16
+ export declare const AUFRUFE: readonly ["activateCashregister", "cancelInvoice", "cancelReceipt", "createCreditNote", "createCustomer", "createCustomerCashregister", "createPartnerCustomer", "checkPartnerCustomerEmail", "createPartnerWebhook", "createPaymentLinkStripe", "createPrintJob", "createReceipt", "deletePartnerWebhook", "downloadDailyReport", "downloadReport", "endRegisterSession", "financeWebService", "generateFullReceiptId", "getCustomer", "getCustomerCredentials", "getCustomerSignatureStatus", "getFirstReceiptDate", "getInvoice", "getInvoicePdf", "getInvoiceSetupStatus", "getInvoiceXml", "getKasseSettings", "getPartnerCustomer", "getPartnerInfo", "getPrintJob", "getReceipt", "hobexPayApi", "hobexRefundApi", "issueInvoice", "listCustomerCashregisters", "listInvoices", "listMyArticleGroups", "listMyArticles", "listMyCashregisters", "listMyPrinters", "listMyReceipts", "listMyTipRecipients", "listPartnerCustomers", "listPartnerWebhookDeliveries", "listPartnerWebhooks", "listRegisterUsersForDevice", "listRegisterSessionsForDevice", "pairRegisterDevice", "registerPinLogin", "registerUserLogin", "renewRegisterSession", "requestCustomerSignature", "searchCustomers", "sendPartnerCustomerFonLink", "sendPartnerWebhookTest", "sendReceiptEmail", "setMyKasseSettings", "setMyRegisterDeviceSettings", "stripeCaptureIntent", "unpairRegisterDevice", "rotatePartnerWebhookSecret", "updateCustomer", "updatePartnerWebhook"];
17
17
  export type Aufruf = typeof AUFRUFE[number];
18
18
  /** Wie [KasseneckTransport], nur mit bekanntem Aufrufnamen. Nicht exportiert nach aussen. */
19
19
  export type InternerTransport = <T = unknown>(functionName: Aufruf, params?: Record<string, unknown>, extraBodyFields?: TransportBodyFields, secretParams?: readonly string[]) => Promise<T>;
@@ -26,6 +26,7 @@ exports.AUFRUFE = [
26
26
  'getFirstReceiptDate',
27
27
  'getInvoice',
28
28
  'getInvoicePdf',
29
+ 'getInvoiceSetupStatus',
29
30
  'getInvoiceXml',
30
31
  'getKasseSettings',
31
32
  'getPartnerCustomer',
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import { type FetchLike } from '../client/transport.js';
8
8
  import type { EInvoiceFormat } from './vertrag.js';
9
- import type { CancelInvoiceRequest, CancelResult, CreditNoteRequest, CreditNoteResult, Customer, CustomerInput, CustomerPage, CustomerSearch, InvoiceDetail, InvoiceListQuery, InvoicePage, IssueInvoiceRequest, IssueResult } from './typen.js';
9
+ import type { CancelInvoiceRequest, CancelResult, CreditNoteRequest, CreditNoteResult, Customer, CustomerInput, CustomerPage, CustomerSearch, InvoiceDetail, InvoiceListQuery, InvoicePage, InvoiceSetupStatus, IssueInvoiceRequest, IssueResult } from './typen.js';
10
10
  export interface RechnungApiOptions {
11
11
  /** `api_key` des Kontos (`kr_live_…` / `kr_test_…`). Gehoert auf einen Server. */
12
12
  apiKey: string;
@@ -39,5 +39,7 @@ export interface RechnungApi {
39
39
  listInvoices(abfrage?: InvoiceListQuery): Promise<InvoicePage>;
40
40
  getInvoicePdf(invoiceId: string): Promise<Uint8Array>;
41
41
  getInvoiceXml(invoiceId: string, format?: EInvoiceFormat): Promise<string>;
42
+ /** Darf dieses Konto ausstellen, und was fehlt noch? Laeuft auch ohne Freigabe. */
43
+ getInvoiceSetupStatus(): Promise<InvoiceSetupStatus>;
42
44
  }
43
45
  export declare function createRechnungApi(optionen: RechnungApiOptions): RechnungApi;
@@ -31,5 +31,6 @@ function createRechnungApi(optionen) {
31
31
  listInvoices: (abfrage) => (0, endpunkte_js_1.listInvoices)(rufen, abfrage),
32
32
  getInvoicePdf: (id) => (0, endpunkte_js_1.getInvoicePdf)(rufenBinaer, id),
33
33
  getInvoiceXml: (id, format) => (0, endpunkte_js_1.getInvoiceXml)(rufen, id, format),
34
+ getInvoiceSetupStatus: () => (0, endpunkte_js_1.getInvoiceSetupStatus)(rufen),
34
35
  };
35
36
  }
@@ -18,7 +18,7 @@
18
18
  */
19
19
  import type { InternerBinaerTransport, InternerTransport } from '../client/aufrufe.js';
20
20
  import type { EInvoiceFormat } from './vertrag.js';
21
- import type { CancelInvoiceRequest, CancelResult, CreditNoteRequest, CreditNoteResult, Customer, CustomerInput, CustomerPage, CustomerSearch, InvoiceDetail, InvoiceListQuery, InvoicePage, IssueInvoiceRequest, IssueResult } from './typen.js';
21
+ import type { CancelInvoiceRequest, CancelResult, CreditNoteRequest, CreditNoteResult, Customer, CustomerInput, CustomerPage, CustomerSearch, InvoiceDetail, InvoiceListQuery, InvoicePage, InvoiceSetupStatus, IssueInvoiceRequest, IssueResult } from './typen.js';
22
22
  export declare function createCustomer(rufen: InternerTransport, customer: CustomerInput, optionen?: {
23
23
  idempotencyKey?: string;
24
24
  }): Promise<Customer>;
@@ -38,6 +38,12 @@ export declare function getInvoice(rufen: InternerTransport, kennung: {
38
38
  number: string;
39
39
  }): Promise<InvoiceDetail>;
40
40
  export declare function listInvoices(rufen: InternerTransport, abfrage?: InvoiceListQuery): Promise<InvoicePage>;
41
+ /**
42
+ * Darf dieses Konto ueber die API ausstellen, und was fehlt noch? Laeuft auch
43
+ * ohne Freigabe und vor der Live-Freischaltung — genau dann braucht man die
44
+ * Antwort. Vor dem ersten `issueInvoice` aufrufen und `missing` anzeigen.
45
+ */
46
+ export declare function getInvoiceSetupStatus(rufen: InternerTransport): Promise<InvoiceSetupStatus>;
41
47
  /** Das PDF der Rechnung (bei Gutschriften: der Gutschrift), mit eingebetteter Factur-X-Datei. */
42
48
  export declare function getInvoicePdf(rufenBinaer: InternerBinaerTransport, invoiceId: string): Promise<Uint8Array>;
43
49
  /**
@@ -27,6 +27,7 @@ exports.cancelInvoice = cancelInvoice;
27
27
  exports.createCreditNote = createCreditNote;
28
28
  exports.getInvoice = getInvoice;
29
29
  exports.listInvoices = listInvoices;
30
+ exports.getInvoiceSetupStatus = getInvoiceSetupStatus;
30
31
  exports.getInvoicePdf = getInvoicePdf;
31
32
  exports.getInvoiceXml = getInvoiceXml;
32
33
  const errors_js_1 = require("../client/errors.js");
@@ -109,6 +110,23 @@ async function listInvoices(rufen, abfrage = {}) {
109
110
  const { eintraege, nextCursor } = seite('listInvoices', daten, 'invoices');
110
111
  return { invoices: eintraege, nextCursor };
111
112
  }
113
+ // ---- Freigabe und Einrichtung ---------------------------------------------------
114
+ /**
115
+ * Darf dieses Konto ueber die API ausstellen, und was fehlt noch? Laeuft auch
116
+ * ohne Freigabe und vor der Live-Freischaltung — genau dann braucht man die
117
+ * Antwort. Vor dem ersten `issueInvoice` aufrufen und `missing` anzeigen.
118
+ */
119
+ async function getInvoiceSetupStatus(rufen) {
120
+ const daten = objekt(await rufen('getInvoiceSetupStatus', {}));
121
+ if (typeof daten['ready'] !== 'boolean' || !Array.isArray(daten['missing'])) {
122
+ throw new errors_js_1.KasseneckValidationError('getInvoiceSetupStatus', 'Antwort ohne ready/missing', 'response');
123
+ }
124
+ return {
125
+ ready: daten['ready'],
126
+ environment: daten['environment'] === 'test' ? 'test' : 'live',
127
+ missing: daten['missing'],
128
+ };
129
+ }
112
130
  // ---- Dateien ----------------------------------------------------------------
113
131
  /** Das PDF der Rechnung (bei Gutschriften: der Gutschrift), mit eingebetteter Factur-X-Datei. */
114
132
  function getInvoicePdf(rufenBinaer, invoiceId) {
@@ -13,6 +13,6 @@
13
13
  export { createRechnungApi, type RechnungApi, type RechnungApiOptions } from './api.js';
14
14
  export { rechnungKeyAuth, type RechnungKeyAuthOptions } from './auth.js';
15
15
  export { istRechnungFehler, rechnungFehlerCode, rechnungFeldFehler, type RechnungFeldFehler, } from './fehler.js';
16
- export { cancelInvoice, createCreditNote, createCustomer, getCustomer, getInvoice, getInvoicePdf, getInvoiceXml, issueInvoice, listInvoices, searchCustomers, updateCustomer, } from './endpunkte.js';
17
- export type { CancelInvoiceRequest, CancelResult, CreditNoteRequest, CreditNoteResult, Customer, CustomerInput, CustomerPage, CustomerSearch, EInvoiceStatus, Invoice, InvoiceDetail, InvoiceItem, InvoiceItemInput, InvoiceListQuery, InvoicePage, InvoiceRecipient, InvoiceTotals, IssueInvoiceRequest, IssueResult, } from './typen.js';
18
- export { RECHNUNG_VERTRAG_VERSION, RECHNUNG_AUFRUFE, INVOICE_ERROR_CODES, CREDIT_NOTE_REASONS, TAX_SCHEMES, PRICE_MODES, VAT_RATES, CUSTOMER_TYPES, INVOICE_LIST_STATUS, DOC_TYPES, EINVOICE_FORMATS, KUNDE_FELDER, POSITION_FELDER, RECHNUNG_ANFRAGEN, RECHNUNG_GENAU_EINS, RECHNUNG_MINDESTENS_EINS, type RechnungAufruf, type InvoiceErrorCode, type CreditNoteReason, type TaxScheme, type PriceMode, type VatRatePercent, type CustomerType, type InvoiceListStatus, type DocType, type EInvoiceFormat, type Format, type Feld, } from './vertrag.js';
16
+ export { cancelInvoice, createCreditNote, createCustomer, getCustomer, getInvoice, getInvoicePdf, getInvoiceSetupStatus, getInvoiceXml, issueInvoice, listInvoices, searchCustomers, updateCustomer, } from './endpunkte.js';
17
+ export type { CancelInvoiceRequest, CancelResult, CreditNoteRequest, CreditNoteResult, Customer, CustomerInput, CustomerPage, CustomerSearch, EInvoiceStatus, Invoice, InvoiceDetail, InvoiceItem, InvoiceItemInput, InvoiceListQuery, InvoicePage, InvoiceRecipient, InvoiceSetupGap, InvoiceSetupStatus, InvoiceTotals, IssueInvoiceRequest, IssueResult, } from './typen.js';
18
+ export { RECHNUNG_VERTRAG_VERSION, RECHNUNG_AUFRUFE, INVOICE_ERROR_CODES, CREDIT_NOTE_REASONS, TAX_SCHEMES, PRICE_MODES, VAT_RATES, CUSTOMER_TYPES, INVOICE_LIST_STATUS, DOC_TYPES, EINVOICE_FORMATS, INVOICE_SETUP_REQUIREMENTS, KUNDE_FELDER, POSITION_FELDER, RECHNUNG_ANFRAGEN, RECHNUNG_GENAU_EINS, RECHNUNG_MINDESTENS_EINS, type RechnungAufruf, type InvoiceErrorCode, type CreditNoteReason, type TaxScheme, type PriceMode, type VatRatePercent, type CustomerType, type InvoiceListStatus, type DocType, type EInvoiceFormat, type InvoiceSetupRequirement, type Format, type Feld, } from './vertrag.js';
@@ -12,7 +12,7 @@
12
12
  * Benutzung des Clients.
13
13
  */
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.RECHNUNG_MINDESTENS_EINS = exports.RECHNUNG_GENAU_EINS = exports.RECHNUNG_ANFRAGEN = exports.POSITION_FELDER = exports.KUNDE_FELDER = exports.EINVOICE_FORMATS = exports.DOC_TYPES = exports.INVOICE_LIST_STATUS = exports.CUSTOMER_TYPES = exports.VAT_RATES = exports.PRICE_MODES = exports.TAX_SCHEMES = exports.CREDIT_NOTE_REASONS = exports.INVOICE_ERROR_CODES = exports.RECHNUNG_AUFRUFE = exports.RECHNUNG_VERTRAG_VERSION = exports.updateCustomer = exports.searchCustomers = exports.listInvoices = exports.issueInvoice = exports.getInvoiceXml = exports.getInvoicePdf = exports.getInvoice = exports.getCustomer = exports.createCustomer = exports.createCreditNote = exports.cancelInvoice = exports.rechnungFeldFehler = exports.rechnungFehlerCode = exports.istRechnungFehler = exports.rechnungKeyAuth = exports.createRechnungApi = void 0;
15
+ exports.RECHNUNG_MINDESTENS_EINS = exports.RECHNUNG_GENAU_EINS = exports.RECHNUNG_ANFRAGEN = exports.POSITION_FELDER = exports.KUNDE_FELDER = exports.INVOICE_SETUP_REQUIREMENTS = exports.EINVOICE_FORMATS = exports.DOC_TYPES = exports.INVOICE_LIST_STATUS = exports.CUSTOMER_TYPES = exports.VAT_RATES = exports.PRICE_MODES = exports.TAX_SCHEMES = exports.CREDIT_NOTE_REASONS = exports.INVOICE_ERROR_CODES = exports.RECHNUNG_AUFRUFE = exports.RECHNUNG_VERTRAG_VERSION = exports.updateCustomer = exports.searchCustomers = exports.listInvoices = exports.issueInvoice = exports.getInvoiceXml = exports.getInvoiceSetupStatus = exports.getInvoicePdf = exports.getInvoice = exports.getCustomer = exports.createCustomer = exports.createCreditNote = exports.cancelInvoice = exports.rechnungFeldFehler = exports.rechnungFehlerCode = exports.istRechnungFehler = exports.rechnungKeyAuth = exports.createRechnungApi = void 0;
16
16
  var api_js_1 = require("./api.js");
17
17
  Object.defineProperty(exports, "createRechnungApi", { enumerable: true, get: function () { return api_js_1.createRechnungApi; } });
18
18
  var auth_js_1 = require("./auth.js");
@@ -28,6 +28,7 @@ Object.defineProperty(exports, "createCustomer", { enumerable: true, get: functi
28
28
  Object.defineProperty(exports, "getCustomer", { enumerable: true, get: function () { return endpunkte_js_1.getCustomer; } });
29
29
  Object.defineProperty(exports, "getInvoice", { enumerable: true, get: function () { return endpunkte_js_1.getInvoice; } });
30
30
  Object.defineProperty(exports, "getInvoicePdf", { enumerable: true, get: function () { return endpunkte_js_1.getInvoicePdf; } });
31
+ Object.defineProperty(exports, "getInvoiceSetupStatus", { enumerable: true, get: function () { return endpunkte_js_1.getInvoiceSetupStatus; } });
31
32
  Object.defineProperty(exports, "getInvoiceXml", { enumerable: true, get: function () { return endpunkte_js_1.getInvoiceXml; } });
32
33
  Object.defineProperty(exports, "issueInvoice", { enumerable: true, get: function () { return endpunkte_js_1.issueInvoice; } });
33
34
  Object.defineProperty(exports, "listInvoices", { enumerable: true, get: function () { return endpunkte_js_1.listInvoices; } });
@@ -45,6 +46,7 @@ Object.defineProperty(exports, "CUSTOMER_TYPES", { enumerable: true, get: functi
45
46
  Object.defineProperty(exports, "INVOICE_LIST_STATUS", { enumerable: true, get: function () { return vertrag_js_1.INVOICE_LIST_STATUS; } });
46
47
  Object.defineProperty(exports, "DOC_TYPES", { enumerable: true, get: function () { return vertrag_js_1.DOC_TYPES; } });
47
48
  Object.defineProperty(exports, "EINVOICE_FORMATS", { enumerable: true, get: function () { return vertrag_js_1.EINVOICE_FORMATS; } });
49
+ Object.defineProperty(exports, "INVOICE_SETUP_REQUIREMENTS", { enumerable: true, get: function () { return vertrag_js_1.INVOICE_SETUP_REQUIREMENTS; } });
48
50
  Object.defineProperty(exports, "KUNDE_FELDER", { enumerable: true, get: function () { return vertrag_js_1.KUNDE_FELDER; } });
49
51
  Object.defineProperty(exports, "POSITION_FELDER", { enumerable: true, get: function () { return vertrag_js_1.POSITION_FELDER; } });
50
52
  Object.defineProperty(exports, "RECHNUNG_ANFRAGEN", { enumerable: true, get: function () { return vertrag_js_1.RECHNUNG_ANFRAGEN; } });
@@ -5,7 +5,7 @@
5
5
  * Betraege sind ueberall ganze Cent. Datumsangaben sind `YYYY-MM-DD` nach
6
6
  * Wiener Kalender.
7
7
  */
8
- import type { CreditNoteReason, CustomerType, DocType, InvoiceListStatus, PriceMode, TaxScheme, VatRatePercent } from './vertrag.js';
8
+ import type { CreditNoteReason, CustomerType, DocType, InvoiceSetupRequirement, InvoiceListStatus, PriceMode, TaxScheme, VatRatePercent } from './vertrag.js';
9
9
  export interface CustomerInput {
10
10
  type: CustomerType;
11
11
  name: string;
@@ -222,3 +222,17 @@ export interface CreditNoteResult {
222
222
  remainingCents: number;
223
223
  replayed: boolean;
224
224
  }
225
+ /** Ein Punkt, der vor dem Ausstellen noch fehlt. */
226
+ export interface InvoiceSetupGap {
227
+ requirement: InvoiceSetupRequirement;
228
+ /** Was fehlt und wo es nachzutragen ist — fuer einen Menschen formuliert. */
229
+ message: string;
230
+ }
231
+ export interface InvoiceSetupStatus {
232
+ /** `true`: Rechnungen koennen ueber die API ausgestellt werden. */
233
+ ready: boolean;
234
+ /** Umgebung des Schluessels (`kr_live_…` bzw. `kr_test_…`). */
235
+ environment: 'live' | 'test';
236
+ /** Was fehlt, in der Reihenfolge von `INVOICE_SETUP_REQUIREMENTS` — leer, wenn `ready`. */
237
+ missing: InvoiceSetupGap[];
238
+ }
@@ -18,13 +18,13 @@
18
18
  * Nummer, Summen — ist bewusst **nicht** setzbar.
19
19
  */
20
20
  export declare const RECHNUNG_VERTRAG_VERSION = 1;
21
- export declare const RECHNUNG_AUFRUFE: readonly ["createCustomer", "getCustomer", "updateCustomer", "searchCustomers", "issueInvoice", "cancelInvoice", "createCreditNote", "getInvoice", "listInvoices", "getInvoicePdf", "getInvoiceXml"];
21
+ export declare const RECHNUNG_AUFRUFE: readonly ["createCustomer", "getCustomer", "updateCustomer", "searchCustomers", "issueInvoice", "cancelInvoice", "createCreditNote", "getInvoice", "listInvoices", "getInvoicePdf", "getInvoiceXml", "getInvoiceSetupStatus"];
22
22
  export type RechnungAufruf = (typeof RECHNUNG_AUFRUFE)[number];
23
23
  /**
24
24
  * Stabile Fehlercodes. Das Fremdsystem verzweigt am Code, der Text darf sich
25
25
  * aendern. `validation` traegt zusaetzlich `errors: [{ field, message }]`.
26
26
  */
27
- export declare const INVOICE_ERROR_CODES: readonly ["validation", "idempotency_conflict", "module_inactive", "customer_not_found", "customer_exists", "short_code_taken", "short_code_immutable", "recipient_required", "invoice_requirements_missing", "invoice_not_found", "invoice_ambiguous", "not_cancellable", "partial_credit_exists", "credit_exceeds_invoice", "einvoice_incomplete"];
27
+ export declare const INVOICE_ERROR_CODES: readonly ["validation", "idempotency_conflict", "module_inactive", "customer_not_found", "customer_exists", "short_code_taken", "short_code_immutable", "recipient_required", "invoice_requirements_missing", "invoice_not_found", "invoice_ambiguous", "not_cancellable", "partial_credit_exists", "credit_exceeds_invoice", "einvoice_incomplete", "invoice_api_not_enabled", "invoice_setup_incomplete"];
28
28
  export type InvoiceErrorCode = (typeof INVOICE_ERROR_CODES)[number];
29
29
  /** Gruende einer Gutschrift. Der Server druckt den deutschen Anzeigetext. */
30
30
  export declare const CREDIT_NOTE_REASONS: readonly ["cancellation", "price_reduction", "return", "incorrect_invoice", "other"];
@@ -43,6 +43,21 @@ export declare const DOC_TYPES: readonly ["RE", "GU"];
43
43
  export type DocType = (typeof DOC_TYPES)[number];
44
44
  export declare const EINVOICE_FORMATS: readonly ["ubl", "cii"];
45
45
  export type EInvoiceFormat = (typeof EINVOICE_FORMATS)[number];
46
+ /**
47
+ * Was erfuellt sein muss, bevor ueber die API ausgestellt werden darf — in
48
+ * dieser Reihenfolge meldet `getInvoiceSetupStatus`, was fehlt, und dieselben
49
+ * Schluessel stehen in `invoice_setup_incomplete`.
50
+ *
51
+ * - `module_active` Modul Rechnung aktiv
52
+ * - `api_enabled` Rechnungs-API fuer das Konto von Kasseneck freigegeben (nur live)
53
+ * - `live_enabled` Konto live freigeschaltet (nur live)
54
+ * - `business_name`, `address`, `vat_id` Pflichtangaben des Ausstellers (§ 11 UStG;
55
+ * `vat_id` entfaellt bei Kleinunternehmern)
56
+ * - `bank_account` IBAN und Kontoinhaber
57
+ * - `number_format` Rechnungsnummern-Format bewusst gespeichert
58
+ */
59
+ export declare const INVOICE_SETUP_REQUIREMENTS: readonly ["module_active", "api_enabled", "live_enabled", "business_name", "address", "vat_id", "bank_account", "number_format"];
60
+ export type InvoiceSetupRequirement = (typeof INVOICE_SETUP_REQUIREMENTS)[number];
46
61
  /** Formate, die der Server mit `@kreiseck/validator` bzw. einem Muster prueft. */
47
62
  export type Format = 'email' | 'phone' | 'vatId' | 'country' | 'date' | 'shortCode';
48
63
  export type Feld = {
@@ -19,7 +19,7 @@
19
19
  * Nummer, Summen — ist bewusst **nicht** setzbar.
20
20
  */
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.RECHNUNG_MINDESTENS_EINS = exports.RECHNUNG_GENAU_EINS = exports.RECHNUNG_ANFRAGEN = exports.POSITION_FELDER = exports.KUNDE_FELDER = exports.EINVOICE_FORMATS = exports.DOC_TYPES = exports.INVOICE_LIST_STATUS = exports.CUSTOMER_TYPES = exports.VAT_RATES = exports.PRICE_MODES = exports.TAX_SCHEMES = exports.CREDIT_NOTE_REASONS = exports.INVOICE_ERROR_CODES = exports.RECHNUNG_AUFRUFE = exports.RECHNUNG_VERTRAG_VERSION = void 0;
22
+ exports.RECHNUNG_MINDESTENS_EINS = exports.RECHNUNG_GENAU_EINS = exports.RECHNUNG_ANFRAGEN = exports.POSITION_FELDER = exports.KUNDE_FELDER = exports.INVOICE_SETUP_REQUIREMENTS = exports.EINVOICE_FORMATS = exports.DOC_TYPES = exports.INVOICE_LIST_STATUS = exports.CUSTOMER_TYPES = exports.VAT_RATES = exports.PRICE_MODES = exports.TAX_SCHEMES = exports.CREDIT_NOTE_REASONS = exports.INVOICE_ERROR_CODES = exports.RECHNUNG_AUFRUFE = exports.RECHNUNG_VERTRAG_VERSION = void 0;
23
23
  exports.RECHNUNG_VERTRAG_VERSION = 1;
24
24
  exports.RECHNUNG_AUFRUFE = [
25
25
  'createCustomer',
@@ -33,6 +33,7 @@ exports.RECHNUNG_AUFRUFE = [
33
33
  'listInvoices',
34
34
  'getInvoicePdf',
35
35
  'getInvoiceXml',
36
+ 'getInvoiceSetupStatus',
36
37
  ];
37
38
  /**
38
39
  * Stabile Fehlercodes. Das Fremdsystem verzweigt am Code, der Text darf sich
@@ -54,6 +55,8 @@ exports.INVOICE_ERROR_CODES = [
54
55
  'partial_credit_exists',
55
56
  'credit_exceeds_invoice',
56
57
  'einvoice_incomplete',
58
+ 'invoice_api_not_enabled',
59
+ 'invoice_setup_incomplete',
57
60
  ];
58
61
  /** Gruende einer Gutschrift. Der Server druckt den deutschen Anzeigetext. */
59
62
  exports.CREDIT_NOTE_REASONS = [
@@ -70,6 +73,29 @@ exports.CUSTOMER_TYPES = ['private', 'company'];
70
73
  exports.INVOICE_LIST_STATUS = ['final', 'paid', 'cancelled', 'open', 'overdue'];
71
74
  exports.DOC_TYPES = ['RE', 'GU'];
72
75
  exports.EINVOICE_FORMATS = ['ubl', 'cii'];
76
+ /**
77
+ * Was erfuellt sein muss, bevor ueber die API ausgestellt werden darf — in
78
+ * dieser Reihenfolge meldet `getInvoiceSetupStatus`, was fehlt, und dieselben
79
+ * Schluessel stehen in `invoice_setup_incomplete`.
80
+ *
81
+ * - `module_active` Modul Rechnung aktiv
82
+ * - `api_enabled` Rechnungs-API fuer das Konto von Kasseneck freigegeben (nur live)
83
+ * - `live_enabled` Konto live freigeschaltet (nur live)
84
+ * - `business_name`, `address`, `vat_id` Pflichtangaben des Ausstellers (§ 11 UStG;
85
+ * `vat_id` entfaellt bei Kleinunternehmern)
86
+ * - `bank_account` IBAN und Kontoinhaber
87
+ * - `number_format` Rechnungsnummern-Format bewusst gespeichert
88
+ */
89
+ exports.INVOICE_SETUP_REQUIREMENTS = [
90
+ 'module_active',
91
+ 'api_enabled',
92
+ 'live_enabled',
93
+ 'business_name',
94
+ 'address',
95
+ 'vat_id',
96
+ 'bank_account',
97
+ 'number_format',
98
+ ];
73
99
  const text = (max, pflicht = false, extra = {}) => ({ typ: 'string', pflicht, max, ...(pflicht && extra.min === undefined ? { min: 1 } : {}), ...extra });
74
100
  const idempotencyKey = (pflicht) => ({ typ: 'string', pflicht, min: 1, max: 120 });
75
101
  const id = { typ: 'string', pflicht: false, min: 1, max: 128 };
@@ -179,6 +205,7 @@ exports.RECHNUNG_ANFRAGEN = Object.freeze({
179
205
  invoiceId: idPflicht,
180
206
  format: { typ: 'enum', pflicht: false, werte: exports.EINVOICE_FORMATS },
181
207
  },
208
+ getInvoiceSetupStatus: {},
182
209
  });
183
210
  /** Genau eines dieser Felder muss gesetzt sein (je Aufruf, je Gruppe). */
184
211
  exports.RECHNUNG_GENAU_EINS = Object.freeze({
@@ -13,7 +13,7 @@
13
13
  * umhuellt, muss ihn weiterhin absetzen koennen.
14
14
  */
15
15
  import type { TransportBodyFields } from './transport.js';
16
- export declare const AUFRUFE: readonly ["activateCashregister", "cancelInvoice", "cancelReceipt", "createCreditNote", "createCustomer", "createCustomerCashregister", "createPartnerCustomer", "checkPartnerCustomerEmail", "createPartnerWebhook", "createPaymentLinkStripe", "createPrintJob", "createReceipt", "deletePartnerWebhook", "downloadDailyReport", "downloadReport", "endRegisterSession", "financeWebService", "generateFullReceiptId", "getCustomer", "getCustomerCredentials", "getCustomerSignatureStatus", "getFirstReceiptDate", "getInvoice", "getInvoicePdf", "getInvoiceXml", "getKasseSettings", "getPartnerCustomer", "getPartnerInfo", "getPrintJob", "getReceipt", "hobexPayApi", "hobexRefundApi", "issueInvoice", "listCustomerCashregisters", "listInvoices", "listMyArticleGroups", "listMyArticles", "listMyCashregisters", "listMyPrinters", "listMyReceipts", "listMyTipRecipients", "listPartnerCustomers", "listPartnerWebhookDeliveries", "listPartnerWebhooks", "listRegisterUsersForDevice", "listRegisterSessionsForDevice", "pairRegisterDevice", "registerPinLogin", "registerUserLogin", "renewRegisterSession", "requestCustomerSignature", "searchCustomers", "sendPartnerCustomerFonLink", "sendPartnerWebhookTest", "sendReceiptEmail", "setMyKasseSettings", "setMyRegisterDeviceSettings", "stripeCaptureIntent", "unpairRegisterDevice", "rotatePartnerWebhookSecret", "updateCustomer", "updatePartnerWebhook"];
16
+ export declare const AUFRUFE: readonly ["activateCashregister", "cancelInvoice", "cancelReceipt", "createCreditNote", "createCustomer", "createCustomerCashregister", "createPartnerCustomer", "checkPartnerCustomerEmail", "createPartnerWebhook", "createPaymentLinkStripe", "createPrintJob", "createReceipt", "deletePartnerWebhook", "downloadDailyReport", "downloadReport", "endRegisterSession", "financeWebService", "generateFullReceiptId", "getCustomer", "getCustomerCredentials", "getCustomerSignatureStatus", "getFirstReceiptDate", "getInvoice", "getInvoicePdf", "getInvoiceSetupStatus", "getInvoiceXml", "getKasseSettings", "getPartnerCustomer", "getPartnerInfo", "getPrintJob", "getReceipt", "hobexPayApi", "hobexRefundApi", "issueInvoice", "listCustomerCashregisters", "listInvoices", "listMyArticleGroups", "listMyArticles", "listMyCashregisters", "listMyPrinters", "listMyReceipts", "listMyTipRecipients", "listPartnerCustomers", "listPartnerWebhookDeliveries", "listPartnerWebhooks", "listRegisterUsersForDevice", "listRegisterSessionsForDevice", "pairRegisterDevice", "registerPinLogin", "registerUserLogin", "renewRegisterSession", "requestCustomerSignature", "searchCustomers", "sendPartnerCustomerFonLink", "sendPartnerWebhookTest", "sendReceiptEmail", "setMyKasseSettings", "setMyRegisterDeviceSettings", "stripeCaptureIntent", "unpairRegisterDevice", "rotatePartnerWebhookSecret", "updateCustomer", "updatePartnerWebhook"];
17
17
  export type Aufruf = typeof AUFRUFE[number];
18
18
  /** Wie [KasseneckTransport], nur mit bekanntem Aufrufnamen. Nicht exportiert nach aussen. */
19
19
  export type InternerTransport = <T = unknown>(functionName: Aufruf, params?: Record<string, unknown>, extraBodyFields?: TransportBodyFields, secretParams?: readonly string[]) => Promise<T>;
@@ -23,6 +23,7 @@ export const AUFRUFE = [
23
23
  'getFirstReceiptDate',
24
24
  'getInvoice',
25
25
  'getInvoicePdf',
26
+ 'getInvoiceSetupStatus',
26
27
  'getInvoiceXml',
27
28
  'getKasseSettings',
28
29
  'getPartnerCustomer',
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import { type FetchLike } from '../client/transport.js';
8
8
  import type { EInvoiceFormat } from './vertrag.js';
9
- import type { CancelInvoiceRequest, CancelResult, CreditNoteRequest, CreditNoteResult, Customer, CustomerInput, CustomerPage, CustomerSearch, InvoiceDetail, InvoiceListQuery, InvoicePage, IssueInvoiceRequest, IssueResult } from './typen.js';
9
+ import type { CancelInvoiceRequest, CancelResult, CreditNoteRequest, CreditNoteResult, Customer, CustomerInput, CustomerPage, CustomerSearch, InvoiceDetail, InvoiceListQuery, InvoicePage, InvoiceSetupStatus, IssueInvoiceRequest, IssueResult } from './typen.js';
10
10
  export interface RechnungApiOptions {
11
11
  /** `api_key` des Kontos (`kr_live_…` / `kr_test_…`). Gehoert auf einen Server. */
12
12
  apiKey: string;
@@ -39,5 +39,7 @@ export interface RechnungApi {
39
39
  listInvoices(abfrage?: InvoiceListQuery): Promise<InvoicePage>;
40
40
  getInvoicePdf(invoiceId: string): Promise<Uint8Array>;
41
41
  getInvoiceXml(invoiceId: string, format?: EInvoiceFormat): Promise<string>;
42
+ /** Darf dieses Konto ausstellen, und was fehlt noch? Laeuft auch ohne Freigabe. */
43
+ getInvoiceSetupStatus(): Promise<InvoiceSetupStatus>;
42
44
  }
43
45
  export declare function createRechnungApi(optionen: RechnungApiOptions): RechnungApi;
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import { createBinaryTransport, createTransport } from '../client/transport.js';
8
8
  import { rechnungKeyAuth } from './auth.js';
9
- import { cancelInvoice, createCreditNote, createCustomer, getCustomer, getInvoice, getInvoicePdf, getInvoiceXml, issueInvoice, listInvoices, searchCustomers, updateCustomer, } from './endpunkte.js';
9
+ import { cancelInvoice, createCreditNote, createCustomer, getCustomer, getInvoice, getInvoicePdf, getInvoiceSetupStatus, getInvoiceXml, issueInvoice, listInvoices, searchCustomers, updateCustomer, } from './endpunkte.js';
10
10
  export function createRechnungApi(optionen) {
11
11
  const transportOptionen = {
12
12
  auth: rechnungKeyAuth({ apiKey: optionen.apiKey }),
@@ -28,5 +28,6 @@ export function createRechnungApi(optionen) {
28
28
  listInvoices: (abfrage) => listInvoices(rufen, abfrage),
29
29
  getInvoicePdf: (id) => getInvoicePdf(rufenBinaer, id),
30
30
  getInvoiceXml: (id, format) => getInvoiceXml(rufen, id, format),
31
+ getInvoiceSetupStatus: () => getInvoiceSetupStatus(rufen),
31
32
  };
32
33
  }
@@ -18,7 +18,7 @@
18
18
  */
19
19
  import type { InternerBinaerTransport, InternerTransport } from '../client/aufrufe.js';
20
20
  import type { EInvoiceFormat } from './vertrag.js';
21
- import type { CancelInvoiceRequest, CancelResult, CreditNoteRequest, CreditNoteResult, Customer, CustomerInput, CustomerPage, CustomerSearch, InvoiceDetail, InvoiceListQuery, InvoicePage, IssueInvoiceRequest, IssueResult } from './typen.js';
21
+ import type { CancelInvoiceRequest, CancelResult, CreditNoteRequest, CreditNoteResult, Customer, CustomerInput, CustomerPage, CustomerSearch, InvoiceDetail, InvoiceListQuery, InvoicePage, InvoiceSetupStatus, IssueInvoiceRequest, IssueResult } from './typen.js';
22
22
  export declare function createCustomer(rufen: InternerTransport, customer: CustomerInput, optionen?: {
23
23
  idempotencyKey?: string;
24
24
  }): Promise<Customer>;
@@ -38,6 +38,12 @@ export declare function getInvoice(rufen: InternerTransport, kennung: {
38
38
  number: string;
39
39
  }): Promise<InvoiceDetail>;
40
40
  export declare function listInvoices(rufen: InternerTransport, abfrage?: InvoiceListQuery): Promise<InvoicePage>;
41
+ /**
42
+ * Darf dieses Konto ueber die API ausstellen, und was fehlt noch? Laeuft auch
43
+ * ohne Freigabe und vor der Live-Freischaltung — genau dann braucht man die
44
+ * Antwort. Vor dem ersten `issueInvoice` aufrufen und `missing` anzeigen.
45
+ */
46
+ export declare function getInvoiceSetupStatus(rufen: InternerTransport): Promise<InvoiceSetupStatus>;
41
47
  /** Das PDF der Rechnung (bei Gutschriften: der Gutschrift), mit eingebetteter Factur-X-Datei. */
42
48
  export declare function getInvoicePdf(rufenBinaer: InternerBinaerTransport, invoiceId: string): Promise<Uint8Array>;
43
49
  /**
@@ -96,6 +96,23 @@ export async function listInvoices(rufen, abfrage = {}) {
96
96
  const { eintraege, nextCursor } = seite('listInvoices', daten, 'invoices');
97
97
  return { invoices: eintraege, nextCursor };
98
98
  }
99
+ // ---- Freigabe und Einrichtung ---------------------------------------------------
100
+ /**
101
+ * Darf dieses Konto ueber die API ausstellen, und was fehlt noch? Laeuft auch
102
+ * ohne Freigabe und vor der Live-Freischaltung — genau dann braucht man die
103
+ * Antwort. Vor dem ersten `issueInvoice` aufrufen und `missing` anzeigen.
104
+ */
105
+ export async function getInvoiceSetupStatus(rufen) {
106
+ const daten = objekt(await rufen('getInvoiceSetupStatus', {}));
107
+ if (typeof daten['ready'] !== 'boolean' || !Array.isArray(daten['missing'])) {
108
+ throw new KasseneckValidationError('getInvoiceSetupStatus', 'Antwort ohne ready/missing', 'response');
109
+ }
110
+ return {
111
+ ready: daten['ready'],
112
+ environment: daten['environment'] === 'test' ? 'test' : 'live',
113
+ missing: daten['missing'],
114
+ };
115
+ }
99
116
  // ---- Dateien ----------------------------------------------------------------
100
117
  /** Das PDF der Rechnung (bei Gutschriften: der Gutschrift), mit eingebetteter Factur-X-Datei. */
101
118
  export function getInvoicePdf(rufenBinaer, invoiceId) {
@@ -13,6 +13,6 @@
13
13
  export { createRechnungApi, type RechnungApi, type RechnungApiOptions } from './api.js';
14
14
  export { rechnungKeyAuth, type RechnungKeyAuthOptions } from './auth.js';
15
15
  export { istRechnungFehler, rechnungFehlerCode, rechnungFeldFehler, type RechnungFeldFehler, } from './fehler.js';
16
- export { cancelInvoice, createCreditNote, createCustomer, getCustomer, getInvoice, getInvoicePdf, getInvoiceXml, issueInvoice, listInvoices, searchCustomers, updateCustomer, } from './endpunkte.js';
17
- export type { CancelInvoiceRequest, CancelResult, CreditNoteRequest, CreditNoteResult, Customer, CustomerInput, CustomerPage, CustomerSearch, EInvoiceStatus, Invoice, InvoiceDetail, InvoiceItem, InvoiceItemInput, InvoiceListQuery, InvoicePage, InvoiceRecipient, InvoiceTotals, IssueInvoiceRequest, IssueResult, } from './typen.js';
18
- export { RECHNUNG_VERTRAG_VERSION, RECHNUNG_AUFRUFE, INVOICE_ERROR_CODES, CREDIT_NOTE_REASONS, TAX_SCHEMES, PRICE_MODES, VAT_RATES, CUSTOMER_TYPES, INVOICE_LIST_STATUS, DOC_TYPES, EINVOICE_FORMATS, KUNDE_FELDER, POSITION_FELDER, RECHNUNG_ANFRAGEN, RECHNUNG_GENAU_EINS, RECHNUNG_MINDESTENS_EINS, type RechnungAufruf, type InvoiceErrorCode, type CreditNoteReason, type TaxScheme, type PriceMode, type VatRatePercent, type CustomerType, type InvoiceListStatus, type DocType, type EInvoiceFormat, type Format, type Feld, } from './vertrag.js';
16
+ export { cancelInvoice, createCreditNote, createCustomer, getCustomer, getInvoice, getInvoicePdf, getInvoiceSetupStatus, getInvoiceXml, issueInvoice, listInvoices, searchCustomers, updateCustomer, } from './endpunkte.js';
17
+ export type { CancelInvoiceRequest, CancelResult, CreditNoteRequest, CreditNoteResult, Customer, CustomerInput, CustomerPage, CustomerSearch, EInvoiceStatus, Invoice, InvoiceDetail, InvoiceItem, InvoiceItemInput, InvoiceListQuery, InvoicePage, InvoiceRecipient, InvoiceSetupGap, InvoiceSetupStatus, InvoiceTotals, IssueInvoiceRequest, IssueResult, } from './typen.js';
18
+ export { RECHNUNG_VERTRAG_VERSION, RECHNUNG_AUFRUFE, INVOICE_ERROR_CODES, CREDIT_NOTE_REASONS, TAX_SCHEMES, PRICE_MODES, VAT_RATES, CUSTOMER_TYPES, INVOICE_LIST_STATUS, DOC_TYPES, EINVOICE_FORMATS, INVOICE_SETUP_REQUIREMENTS, KUNDE_FELDER, POSITION_FELDER, RECHNUNG_ANFRAGEN, RECHNUNG_GENAU_EINS, RECHNUNG_MINDESTENS_EINS, type RechnungAufruf, type InvoiceErrorCode, type CreditNoteReason, type TaxScheme, type PriceMode, type VatRatePercent, type CustomerType, type InvoiceListStatus, type DocType, type EInvoiceFormat, type InvoiceSetupRequirement, type Format, type Feld, } from './vertrag.js';
@@ -13,5 +13,5 @@
13
13
  export { createRechnungApi } from './api.js';
14
14
  export { rechnungKeyAuth } from './auth.js';
15
15
  export { istRechnungFehler, rechnungFehlerCode, rechnungFeldFehler, } from './fehler.js';
16
- export { cancelInvoice, createCreditNote, createCustomer, getCustomer, getInvoice, getInvoicePdf, getInvoiceXml, issueInvoice, listInvoices, searchCustomers, updateCustomer, } from './endpunkte.js';
17
- export { RECHNUNG_VERTRAG_VERSION, RECHNUNG_AUFRUFE, INVOICE_ERROR_CODES, CREDIT_NOTE_REASONS, TAX_SCHEMES, PRICE_MODES, VAT_RATES, CUSTOMER_TYPES, INVOICE_LIST_STATUS, DOC_TYPES, EINVOICE_FORMATS, KUNDE_FELDER, POSITION_FELDER, RECHNUNG_ANFRAGEN, RECHNUNG_GENAU_EINS, RECHNUNG_MINDESTENS_EINS, } from './vertrag.js';
16
+ export { cancelInvoice, createCreditNote, createCustomer, getCustomer, getInvoice, getInvoicePdf, getInvoiceSetupStatus, getInvoiceXml, issueInvoice, listInvoices, searchCustomers, updateCustomer, } from './endpunkte.js';
17
+ export { RECHNUNG_VERTRAG_VERSION, RECHNUNG_AUFRUFE, INVOICE_ERROR_CODES, CREDIT_NOTE_REASONS, TAX_SCHEMES, PRICE_MODES, VAT_RATES, CUSTOMER_TYPES, INVOICE_LIST_STATUS, DOC_TYPES, EINVOICE_FORMATS, INVOICE_SETUP_REQUIREMENTS, KUNDE_FELDER, POSITION_FELDER, RECHNUNG_ANFRAGEN, RECHNUNG_GENAU_EINS, RECHNUNG_MINDESTENS_EINS, } from './vertrag.js';
@@ -5,7 +5,7 @@
5
5
  * Betraege sind ueberall ganze Cent. Datumsangaben sind `YYYY-MM-DD` nach
6
6
  * Wiener Kalender.
7
7
  */
8
- import type { CreditNoteReason, CustomerType, DocType, InvoiceListStatus, PriceMode, TaxScheme, VatRatePercent } from './vertrag.js';
8
+ import type { CreditNoteReason, CustomerType, DocType, InvoiceSetupRequirement, InvoiceListStatus, PriceMode, TaxScheme, VatRatePercent } from './vertrag.js';
9
9
  export interface CustomerInput {
10
10
  type: CustomerType;
11
11
  name: string;
@@ -222,3 +222,17 @@ export interface CreditNoteResult {
222
222
  remainingCents: number;
223
223
  replayed: boolean;
224
224
  }
225
+ /** Ein Punkt, der vor dem Ausstellen noch fehlt. */
226
+ export interface InvoiceSetupGap {
227
+ requirement: InvoiceSetupRequirement;
228
+ /** Was fehlt und wo es nachzutragen ist — fuer einen Menschen formuliert. */
229
+ message: string;
230
+ }
231
+ export interface InvoiceSetupStatus {
232
+ /** `true`: Rechnungen koennen ueber die API ausgestellt werden. */
233
+ ready: boolean;
234
+ /** Umgebung des Schluessels (`kr_live_…` bzw. `kr_test_…`). */
235
+ environment: 'live' | 'test';
236
+ /** Was fehlt, in der Reihenfolge von `INVOICE_SETUP_REQUIREMENTS` — leer, wenn `ready`. */
237
+ missing: InvoiceSetupGap[];
238
+ }
@@ -18,13 +18,13 @@
18
18
  * Nummer, Summen — ist bewusst **nicht** setzbar.
19
19
  */
20
20
  export declare const RECHNUNG_VERTRAG_VERSION = 1;
21
- export declare const RECHNUNG_AUFRUFE: readonly ["createCustomer", "getCustomer", "updateCustomer", "searchCustomers", "issueInvoice", "cancelInvoice", "createCreditNote", "getInvoice", "listInvoices", "getInvoicePdf", "getInvoiceXml"];
21
+ export declare const RECHNUNG_AUFRUFE: readonly ["createCustomer", "getCustomer", "updateCustomer", "searchCustomers", "issueInvoice", "cancelInvoice", "createCreditNote", "getInvoice", "listInvoices", "getInvoicePdf", "getInvoiceXml", "getInvoiceSetupStatus"];
22
22
  export type RechnungAufruf = (typeof RECHNUNG_AUFRUFE)[number];
23
23
  /**
24
24
  * Stabile Fehlercodes. Das Fremdsystem verzweigt am Code, der Text darf sich
25
25
  * aendern. `validation` traegt zusaetzlich `errors: [{ field, message }]`.
26
26
  */
27
- export declare const INVOICE_ERROR_CODES: readonly ["validation", "idempotency_conflict", "module_inactive", "customer_not_found", "customer_exists", "short_code_taken", "short_code_immutable", "recipient_required", "invoice_requirements_missing", "invoice_not_found", "invoice_ambiguous", "not_cancellable", "partial_credit_exists", "credit_exceeds_invoice", "einvoice_incomplete"];
27
+ export declare const INVOICE_ERROR_CODES: readonly ["validation", "idempotency_conflict", "module_inactive", "customer_not_found", "customer_exists", "short_code_taken", "short_code_immutable", "recipient_required", "invoice_requirements_missing", "invoice_not_found", "invoice_ambiguous", "not_cancellable", "partial_credit_exists", "credit_exceeds_invoice", "einvoice_incomplete", "invoice_api_not_enabled", "invoice_setup_incomplete"];
28
28
  export type InvoiceErrorCode = (typeof INVOICE_ERROR_CODES)[number];
29
29
  /** Gruende einer Gutschrift. Der Server druckt den deutschen Anzeigetext. */
30
30
  export declare const CREDIT_NOTE_REASONS: readonly ["cancellation", "price_reduction", "return", "incorrect_invoice", "other"];
@@ -43,6 +43,21 @@ export declare const DOC_TYPES: readonly ["RE", "GU"];
43
43
  export type DocType = (typeof DOC_TYPES)[number];
44
44
  export declare const EINVOICE_FORMATS: readonly ["ubl", "cii"];
45
45
  export type EInvoiceFormat = (typeof EINVOICE_FORMATS)[number];
46
+ /**
47
+ * Was erfuellt sein muss, bevor ueber die API ausgestellt werden darf — in
48
+ * dieser Reihenfolge meldet `getInvoiceSetupStatus`, was fehlt, und dieselben
49
+ * Schluessel stehen in `invoice_setup_incomplete`.
50
+ *
51
+ * - `module_active` Modul Rechnung aktiv
52
+ * - `api_enabled` Rechnungs-API fuer das Konto von Kasseneck freigegeben (nur live)
53
+ * - `live_enabled` Konto live freigeschaltet (nur live)
54
+ * - `business_name`, `address`, `vat_id` Pflichtangaben des Ausstellers (§ 11 UStG;
55
+ * `vat_id` entfaellt bei Kleinunternehmern)
56
+ * - `bank_account` IBAN und Kontoinhaber
57
+ * - `number_format` Rechnungsnummern-Format bewusst gespeichert
58
+ */
59
+ export declare const INVOICE_SETUP_REQUIREMENTS: readonly ["module_active", "api_enabled", "live_enabled", "business_name", "address", "vat_id", "bank_account", "number_format"];
60
+ export type InvoiceSetupRequirement = (typeof INVOICE_SETUP_REQUIREMENTS)[number];
46
61
  /** Formate, die der Server mit `@kreiseck/validator` bzw. einem Muster prueft. */
47
62
  export type Format = 'email' | 'phone' | 'vatId' | 'country' | 'date' | 'shortCode';
48
63
  export type Feld = {
@@ -30,6 +30,7 @@ export const RECHNUNG_AUFRUFE = [
30
30
  'listInvoices',
31
31
  'getInvoicePdf',
32
32
  'getInvoiceXml',
33
+ 'getInvoiceSetupStatus',
33
34
  ];
34
35
  /**
35
36
  * Stabile Fehlercodes. Das Fremdsystem verzweigt am Code, der Text darf sich
@@ -51,6 +52,8 @@ export const INVOICE_ERROR_CODES = [
51
52
  'partial_credit_exists',
52
53
  'credit_exceeds_invoice',
53
54
  'einvoice_incomplete',
55
+ 'invoice_api_not_enabled',
56
+ 'invoice_setup_incomplete',
54
57
  ];
55
58
  /** Gruende einer Gutschrift. Der Server druckt den deutschen Anzeigetext. */
56
59
  export const CREDIT_NOTE_REASONS = [
@@ -67,6 +70,29 @@ export const CUSTOMER_TYPES = ['private', 'company'];
67
70
  export const INVOICE_LIST_STATUS = ['final', 'paid', 'cancelled', 'open', 'overdue'];
68
71
  export const DOC_TYPES = ['RE', 'GU'];
69
72
  export const EINVOICE_FORMATS = ['ubl', 'cii'];
73
+ /**
74
+ * Was erfuellt sein muss, bevor ueber die API ausgestellt werden darf — in
75
+ * dieser Reihenfolge meldet `getInvoiceSetupStatus`, was fehlt, und dieselben
76
+ * Schluessel stehen in `invoice_setup_incomplete`.
77
+ *
78
+ * - `module_active` Modul Rechnung aktiv
79
+ * - `api_enabled` Rechnungs-API fuer das Konto von Kasseneck freigegeben (nur live)
80
+ * - `live_enabled` Konto live freigeschaltet (nur live)
81
+ * - `business_name`, `address`, `vat_id` Pflichtangaben des Ausstellers (§ 11 UStG;
82
+ * `vat_id` entfaellt bei Kleinunternehmern)
83
+ * - `bank_account` IBAN und Kontoinhaber
84
+ * - `number_format` Rechnungsnummern-Format bewusst gespeichert
85
+ */
86
+ export const INVOICE_SETUP_REQUIREMENTS = [
87
+ 'module_active',
88
+ 'api_enabled',
89
+ 'live_enabled',
90
+ 'business_name',
91
+ 'address',
92
+ 'vat_id',
93
+ 'bank_account',
94
+ 'number_format',
95
+ ];
70
96
  const text = (max, pflicht = false, extra = {}) => ({ typ: 'string', pflicht, max, ...(pflicht && extra.min === undefined ? { min: 1 } : {}), ...extra });
71
97
  const idempotencyKey = (pflicht) => ({ typ: 'string', pflicht, min: 1, max: 120 });
72
98
  const id = { typ: 'string', pflicht: false, min: 1, max: 128 };
@@ -176,6 +202,7 @@ export const RECHNUNG_ANFRAGEN = Object.freeze({
176
202
  invoiceId: idPflicht,
177
203
  format: { typ: 'enum', pflicht: false, werte: EINVOICE_FORMATS },
178
204
  },
205
+ getInvoiceSetupStatus: {},
179
206
  });
180
207
  /** Genau eines dieser Felder muss gesetzt sein (je Aufruf, je Gruppe). */
181
208
  export const RECHNUNG_GENAU_EINS = Object.freeze({
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.15.0",
2
+ "version": "0.16.0",
3
3
  "gemessenAn": {
4
4
  "tid": "3600335",
5
5
  "hpsVersion": "1.10.0",
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.15.0",
2
+ "version": "0.16.0",
3
3
  "meldungen": {
4
4
  "netz.keine_verbindung": {
5
5
  "text": "Keine Verbindung zum Server. Bitte die Internetverbindung prüfen und erneut versuchen."
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.15.0",
2
+ "version": "0.16.0",
3
3
  "aufrufe": [
4
4
  "activateCashregister",
5
5
  "cancelInvoice",
@@ -25,6 +25,7 @@
25
25
  "getFirstReceiptDate",
26
26
  "getInvoice",
27
27
  "getInvoicePdf",
28
+ "getInvoiceSetupStatus",
28
29
  "getInvoiceXml",
29
30
  "getKasseSettings",
30
31
  "getPartnerCustomer",
@@ -395,7 +396,9 @@
395
396
  "not_cancellable",
396
397
  "partial_credit_exists",
397
398
  "credit_exceeds_invoice",
398
- "einvoice_incomplete"
399
+ "einvoice_incomplete",
400
+ "invoice_api_not_enabled",
401
+ "invoice_setup_incomplete"
399
402
  ],
400
403
  "invoiceListStatus": [
401
404
  "final",
@@ -404,6 +407,16 @@
404
407
  "open",
405
408
  "overdue"
406
409
  ],
410
+ "invoiceSetupRequirements": [
411
+ "module_active",
412
+ "api_enabled",
413
+ "live_enabled",
414
+ "business_name",
415
+ "address",
416
+ "vat_id",
417
+ "bank_account",
418
+ "number_format"
419
+ ],
407
420
  "priceModes": [
408
421
  "net",
409
422
  "gross"
@@ -419,7 +432,8 @@
419
432
  "getInvoice",
420
433
  "listInvoices",
421
434
  "getInvoicePdf",
422
- "getInvoiceXml"
435
+ "getInvoiceXml",
436
+ "getInvoiceSetupStatus"
423
437
  ],
424
438
  "taxSchemes": [
425
439
  "normal",
@@ -0,0 +1,14 @@
1
+ {
2
+ "aufruf": "getInvoiceSetupStatus",
3
+ "beschreibung": "Der Status kennt keine Parameter",
4
+ "anfrage": {
5
+ "environment": "live"
6
+ },
7
+ "erwartet": {
8
+ "ok": false,
9
+ "code": "validation",
10
+ "fields": [
11
+ "environment"
12
+ ]
13
+ }
14
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "aufruf": "getInvoiceSetupStatus",
3
+ "beschreibung": "Einrichtung abfragen, ohne Parameter",
4
+ "anfrage": {},
5
+ "erwartet": {
6
+ "ok": true
7
+ }
8
+ }
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "title": "Kasseneck Rechnungs-API",
4
4
  "version": 1,
5
- "paket": "0.15.0",
5
+ "paket": "0.16.0",
6
6
  "aufrufe": {
7
7
  "createCustomer": {
8
8
  "anfrage": {
@@ -643,6 +643,13 @@
643
643
  ],
644
644
  "additionalProperties": false
645
645
  }
646
+ },
647
+ "getInvoiceSetupStatus": {
648
+ "anfrage": {
649
+ "type": "object",
650
+ "properties": {},
651
+ "additionalProperties": false
652
+ }
646
653
  }
647
654
  },
648
655
  "codes": [
@@ -660,7 +667,9 @@
660
667
  "not_cancellable",
661
668
  "partial_credit_exists",
662
669
  "credit_exceeds_invoice",
663
- "einvoice_incomplete"
670
+ "einvoice_incomplete",
671
+ "invoice_api_not_enabled",
672
+ "invoice_setup_incomplete"
664
673
  ],
665
674
  "gruende": [
666
675
  "cancellation",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kreiseck/kasseneck-api",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "RKSV-Registrierkasse fuer JavaScript und TypeScript: signierte Belege, Storno, Kartenzahlung, Bondruck. Austrian fiscal cash register (RKSV) API client.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Kreiseck",