@kreiseck/kasseneck-api 0.14.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.
Files changed (57) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +75 -0
  3. package/dist/cjs/client/aufrufe.d.ts +1 -1
  4. package/dist/cjs/client/aufrufe.js +12 -0
  5. package/dist/cjs/rechnung/api.d.ts +45 -0
  6. package/dist/cjs/rechnung/api.js +36 -0
  7. package/dist/cjs/rechnung/auth.d.ts +21 -0
  8. package/dist/cjs/rechnung/auth.js +36 -0
  9. package/dist/cjs/rechnung/endpunkte.d.ts +54 -0
  10. package/dist/cjs/rechnung/endpunkte.js +147 -0
  11. package/dist/cjs/rechnung/fehler.d.ts +21 -0
  12. package/dist/cjs/rechnung/fehler.js +44 -0
  13. package/dist/cjs/rechnung/index.d.ts +18 -0
  14. package/dist/cjs/rechnung/index.js +54 -0
  15. package/dist/cjs/rechnung/typen.d.ts +238 -0
  16. package/dist/cjs/rechnung/typen.js +9 -0
  17. package/dist/cjs/rechnung/vertrag.d.ts +113 -0
  18. package/dist/cjs/rechnung/vertrag.js +218 -0
  19. package/dist/esm/client/aufrufe.d.ts +1 -1
  20. package/dist/esm/client/aufrufe.js +12 -0
  21. package/dist/esm/rechnung/api.d.ts +45 -0
  22. package/dist/esm/rechnung/api.js +33 -0
  23. package/dist/esm/rechnung/auth.d.ts +21 -0
  24. package/dist/esm/rechnung/auth.js +33 -0
  25. package/dist/esm/rechnung/endpunkte.d.ts +54 -0
  26. package/dist/esm/rechnung/endpunkte.js +133 -0
  27. package/dist/esm/rechnung/fehler.d.ts +21 -0
  28. package/dist/esm/rechnung/fehler.js +39 -0
  29. package/dist/esm/rechnung/index.d.ts +18 -0
  30. package/dist/esm/rechnung/index.js +17 -0
  31. package/dist/esm/rechnung/typen.d.ts +238 -0
  32. package/dist/esm/rechnung/typen.js +8 -0
  33. package/dist/esm/rechnung/vertrag.d.ts +113 -0
  34. package/dist/esm/rechnung/vertrag.js +215 -0
  35. package/fixtures/hobex-hps-codes.json +1 -1
  36. package/fixtures/kasse-texte.json +1 -1
  37. package/fixtures/oberflaeche.json +101 -1
  38. package/fixtures/rechnung-api-beispiele/credit-fehler-grund.json +24 -0
  39. package/fixtures/rechnung-api-beispiele/credit-ok.json +20 -0
  40. package/fixtures/rechnung-api-beispiele/customer-fehler-uid.json +25 -0
  41. package/fixtures/rechnung-api-beispiele/customer-get-fehler-beide.json +15 -0
  42. package/fixtures/rechnung-api-beispiele/customer-ok.json +20 -0
  43. package/fixtures/rechnung-api-beispiele/customer-search-fehler-leer.json +14 -0
  44. package/fixtures/rechnung-api-beispiele/issue-brutto-20.json +27 -0
  45. package/fixtures/rechnung-api-beispiele/issue-fehler-cent.json +26 -0
  46. package/fixtures/rechnung-api-beispiele/issue-fehler-menge.json +26 -0
  47. package/fixtures/rechnung-api-beispiele/issue-fehler-negativ.json +26 -0
  48. package/fixtures/rechnung-api-beispiele/issue-fehler-satz.json +26 -0
  49. package/fixtures/rechnung-api-beispiele/issue-fehler-unbekannt.json +27 -0
  50. package/fixtures/rechnung-api-beispiele/issue-gemischt.json +33 -0
  51. package/fixtures/rechnung-api-beispiele/issue-kleinunternehmer.json +27 -0
  52. package/fixtures/rechnung-api-beispiele/issue-netto-20.json +28 -0
  53. package/fixtures/rechnung-api-beispiele/issue-rabatt.json +28 -0
  54. package/fixtures/rechnung-api-beispiele/setup-status-fehler-feld.json +14 -0
  55. package/fixtures/rechnung-api-beispiele/setup-status-ok.json +8 -0
  56. package/fixtures/rechnung-api.schema.json +681 -0
  57. package/package.json +12 -1
@@ -0,0 +1,238 @@
1
+ /**
2
+ * Typen der Rechnungs-API. Die Anfragen folgen `vertrag.ts` Feld fuer Feld;
3
+ * `test/rechnung-client.test.ts` schickt die Beispiele des Vertrags durch.
4
+ *
5
+ * Betraege sind ueberall ganze Cent. Datumsangaben sind `YYYY-MM-DD` nach
6
+ * Wiener Kalender.
7
+ */
8
+ import type { CreditNoteReason, CustomerType, DocType, InvoiceSetupRequirement, InvoiceListStatus, PriceMode, TaxScheme, VatRatePercent } from './vertrag.js';
9
+ export interface CustomerInput {
10
+ type: CustomerType;
11
+ name: string;
12
+ legalForm?: string;
13
+ email?: string;
14
+ phone?: string;
15
+ street?: string;
16
+ houseNumber?: string;
17
+ zip?: string;
18
+ city?: string;
19
+ /** ISO-3166-Alpha-2, z. B. `AT`. */
20
+ country: string;
21
+ /** UID-Nummer, z. B. `ATU12345678`. */
22
+ vatId?: string;
23
+ /** Kuerzel fuer die Rechnungsnummer; einmal gesetzt unveraenderlich. */
24
+ shortCode?: string;
25
+ /** Behoerde (B2G) — die E-Rechnung verlangt dann Adresse und `orderReference`. */
26
+ isAuthority?: boolean;
27
+ note?: string;
28
+ /** Kennung im eigenen System; je Konto eindeutig. */
29
+ externalId?: string;
30
+ }
31
+ export interface Customer {
32
+ id: string;
33
+ type: CustomerType;
34
+ name: string;
35
+ legalForm: string | null;
36
+ email: string | null;
37
+ phone: string | null;
38
+ street: string | null;
39
+ houseNumber: string | null;
40
+ zip: string | null;
41
+ city: string | null;
42
+ country: string;
43
+ vatId: string | null;
44
+ shortCode: string | null;
45
+ isAuthority: boolean;
46
+ note: string | null;
47
+ externalId: string | null;
48
+ createdAt: string | null;
49
+ updatedAt: string | null;
50
+ }
51
+ export interface CustomerSearch {
52
+ externalId?: string;
53
+ vatId?: string;
54
+ email?: string;
55
+ /** Namensanfang, Gross-/Kleinschreibung und Akzente egal. */
56
+ name?: string;
57
+ limit?: number;
58
+ cursor?: string;
59
+ }
60
+ export interface CustomerPage {
61
+ customers: Customer[];
62
+ nextCursor: string | null;
63
+ }
64
+ export interface InvoiceItemInput {
65
+ description: string;
66
+ subtitle?: string;
67
+ /** Hoechstens drei Nachkommastellen. */
68
+ quantity: number;
69
+ unit?: string;
70
+ /** Einzelpreis in ganzen Cent, im `priceMode` der Rechnung (netto oder brutto). */
71
+ unitPriceCents: number;
72
+ vatRate: VatRatePercent;
73
+ /** Zeilenrabatt in Prozent, hoechstens zwei Nachkommastellen. */
74
+ discountPct?: number;
75
+ }
76
+ export interface IssueInvoiceRequest {
77
+ /** Pflicht: dieselbe Anfrage mit demselben Schluessel erzeugt nie eine zweite Rechnung. */
78
+ idempotencyKey: string;
79
+ /** Pflicht ueber 400 € brutto sowie bei Reverse Charge und ig. Lieferung. */
80
+ customerId?: string;
81
+ taxScheme: TaxScheme;
82
+ priceMode: PriceMode;
83
+ /** Leistungsdatum bzw. Beginn des Leistungszeitraums. */
84
+ serviceStart: string;
85
+ serviceEnd?: string;
86
+ paymentTermDays?: number;
87
+ orderReference?: string;
88
+ intro?: string;
89
+ note?: string;
90
+ /** Verwendungszweck fuer die Ueberweisung; leer = Rechnungsnummer. */
91
+ paymentReference?: string;
92
+ girocode?: boolean;
93
+ tracking?: boolean;
94
+ items: InvoiceItemInput[];
95
+ /** Eigene Merkmale (hoechstens 20), nie gedruckt. */
96
+ metadata?: Record<string, string>;
97
+ }
98
+ export interface CancelInvoiceRequest {
99
+ idempotencyKey: string;
100
+ invoiceId: string;
101
+ reason: CreditNoteReason;
102
+ note?: string;
103
+ }
104
+ export interface CreditNoteRequest extends CancelInvoiceRequest {
105
+ items: InvoiceItemInput[];
106
+ }
107
+ export interface InvoiceTotals {
108
+ netCents: number;
109
+ vatCents: number;
110
+ grossCents: number;
111
+ byRate: {
112
+ rate: number;
113
+ netCents: number;
114
+ vatCents: number;
115
+ }[];
116
+ }
117
+ export interface EInvoiceStatus {
118
+ level: string;
119
+ formats: string[];
120
+ missing: string[];
121
+ }
122
+ export interface Invoice {
123
+ id: string;
124
+ number: string;
125
+ docType: DocType;
126
+ status: string;
127
+ invoiceDate: string;
128
+ dueDate: string | null;
129
+ customerId: string | null;
130
+ totals: InvoiceTotals;
131
+ einvoice: EInvoiceStatus | null;
132
+ statusUrl: string | null;
133
+ statusPassword: string | null;
134
+ metadata: Record<string, string>;
135
+ }
136
+ export interface InvoiceRecipient {
137
+ name: string;
138
+ type: CustomerType;
139
+ street: string | null;
140
+ houseNumber: string | null;
141
+ zip: string | null;
142
+ city: string | null;
143
+ country: string;
144
+ vatId: string | null;
145
+ shortCode: string | null;
146
+ email: string | null;
147
+ isAuthority: boolean;
148
+ }
149
+ /** Eine gespeicherte Position — wie gesendet, fehlende Angaben mit ihrem Standardwert. */
150
+ export interface InvoiceItem {
151
+ description: string;
152
+ subtitle: string;
153
+ quantity: number;
154
+ unit: string;
155
+ unitPriceCents: number;
156
+ vatRate: number;
157
+ discountPct: number;
158
+ }
159
+ export interface InvoiceDetail extends Invoice {
160
+ items: InvoiceItem[];
161
+ customer: InvoiceRecipient | null;
162
+ taxScheme: TaxScheme;
163
+ priceMode: PriceMode;
164
+ serviceStart: string | null;
165
+ serviceEnd: string | null;
166
+ paymentTermDays: number | null;
167
+ orderReference: string | null;
168
+ payments: {
169
+ amountCents: number;
170
+ date: string;
171
+ method: string;
172
+ }[];
173
+ paidCents: number;
174
+ openCents: number;
175
+ overdue: boolean;
176
+ writtenOff: boolean;
177
+ writeOffReasonCode: string | null;
178
+ related: {
179
+ invoiceId: string;
180
+ number: string | null;
181
+ } | null;
182
+ creditNotes: {
183
+ id: string;
184
+ number: string;
185
+ grossCents: number;
186
+ }[];
187
+ source: string | null;
188
+ createdAt: string | null;
189
+ finalizedAt: string | null;
190
+ }
191
+ export interface InvoiceListQuery {
192
+ from?: string;
193
+ to?: string;
194
+ status?: InvoiceListStatus;
195
+ docType?: DocType;
196
+ customerId?: string;
197
+ limit?: number;
198
+ cursor?: string;
199
+ }
200
+ export interface InvoicePage {
201
+ invoices: Invoice[];
202
+ nextCursor: string | null;
203
+ }
204
+ export interface IssueResult {
205
+ invoice: Invoice;
206
+ /** `true`, wenn die Anfrage schon einmal ausgefuehrt wurde und die bestehende Rechnung zurueckkommt. */
207
+ replayed: boolean;
208
+ }
209
+ export interface CancelResult {
210
+ creditNote: Invoice;
211
+ original: {
212
+ id: string;
213
+ status: string;
214
+ };
215
+ /** Bereits auf das Original bezahlt — die Rueckerstattung ist Sache des Betriebs. */
216
+ originalPaidCents: number;
217
+ replayed: boolean;
218
+ }
219
+ export interface CreditNoteResult {
220
+ creditNote: Invoice;
221
+ /** Brutto, das nach dieser Gutschrift noch gutgeschrieben werden kann. */
222
+ remainingCents: number;
223
+ replayed: boolean;
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
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Typen der Rechnungs-API. Die Anfragen folgen `vertrag.ts` Feld fuer Feld;
3
+ * `test/rechnung-client.test.ts` schickt die Beispiele des Vertrags durch.
4
+ *
5
+ * Betraege sind ueberall ganze Cent. Datumsangaben sind `YYYY-MM-DD` nach
6
+ * Wiener Kalender.
7
+ */
8
+ export {};
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Der Vertrag der Rechnungs-API — als Daten, nicht als Prosa.
3
+ *
4
+ * Aus dieser Datei entstehen drei Dinge, damit sie nicht auseinanderlaufen
5
+ * koennen:
6
+ *
7
+ * 1. `fixtures/rechnung-api.schema.json` (`npm run fixtures:rechnung`) — das
8
+ * Backend liest es aus dem vendorierten Paket und vergleicht es in beide
9
+ * Richtungen mit seiner eigenen Pruefung; der Dart-Zwilling zieht es byteweise.
10
+ * 2. Die Listen unter `rechnung` in `fixtures/oberflaeche.json` (Codes, Gruende,
11
+ * Enums) — ueber denselben Namensraum-Scan wie der Partner-Teil.
12
+ * 3. Die TypeScript-Typen in `typen.ts`.
13
+ *
14
+ * Nach aussen spricht die Schnittstelle Englisch: Feldnamen, Codes, Gruende.
15
+ * Deutsch bleibt, was ein Mensch liest (`message`, der Aufdruck eines Grundes).
16
+ *
17
+ * Beschrieben wird die Anfrage. Was der Server daraus macht — Rechnungsdatum,
18
+ * Nummer, Summen — ist bewusst **nicht** setzbar.
19
+ */
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", "getInvoiceSetupStatus"];
22
+ export type RechnungAufruf = (typeof RECHNUNG_AUFRUFE)[number];
23
+ /**
24
+ * Stabile Fehlercodes. Das Fremdsystem verzweigt am Code, der Text darf sich
25
+ * aendern. `validation` traegt zusaetzlich `errors: [{ field, message }]`.
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", "invoice_api_not_enabled", "invoice_setup_incomplete"];
28
+ export type InvoiceErrorCode = (typeof INVOICE_ERROR_CODES)[number];
29
+ /** Gruende einer Gutschrift. Der Server druckt den deutschen Anzeigetext. */
30
+ export declare const CREDIT_NOTE_REASONS: readonly ["cancellation", "price_reduction", "return", "incorrect_invoice", "other"];
31
+ export type CreditNoteReason = (typeof CREDIT_NOTE_REASONS)[number];
32
+ export declare const TAX_SCHEMES: readonly ["normal", "smallBusiness", "reverseCharge", "igLieferung", "exportThirdCountry"];
33
+ export type TaxScheme = (typeof TAX_SCHEMES)[number];
34
+ export declare const PRICE_MODES: readonly ["net", "gross"];
35
+ export type PriceMode = (typeof PRICE_MODES)[number];
36
+ export declare const VAT_RATES: readonly [0, 10, 13, 20];
37
+ export type VatRatePercent = (typeof VAT_RATES)[number];
38
+ export declare const CUSTOMER_TYPES: readonly ["private", "company"];
39
+ export type CustomerType = (typeof CUSTOMER_TYPES)[number];
40
+ export declare const INVOICE_LIST_STATUS: readonly ["final", "paid", "cancelled", "open", "overdue"];
41
+ export type InvoiceListStatus = (typeof INVOICE_LIST_STATUS)[number];
42
+ export declare const DOC_TYPES: readonly ["RE", "GU"];
43
+ export type DocType = (typeof DOC_TYPES)[number];
44
+ export declare const EINVOICE_FORMATS: readonly ["ubl", "cii"];
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];
61
+ /** Formate, die der Server mit `@kreiseck/validator` bzw. einem Muster prueft. */
62
+ export type Format = 'email' | 'phone' | 'vatId' | 'country' | 'date' | 'shortCode';
63
+ export type Feld = {
64
+ typ: 'string';
65
+ pflicht: boolean;
66
+ min?: number;
67
+ max: number;
68
+ format?: Format;
69
+ } | {
70
+ typ: 'integer';
71
+ pflicht: boolean;
72
+ min: number;
73
+ max: number;
74
+ } | {
75
+ typ: 'number';
76
+ pflicht: boolean;
77
+ min: number;
78
+ max: number;
79
+ nachkomma: number;
80
+ exklusivMin?: boolean;
81
+ } | {
82
+ typ: 'boolean';
83
+ pflicht: boolean;
84
+ } | {
85
+ typ: 'enum';
86
+ pflicht: boolean;
87
+ werte: readonly (string | number)[];
88
+ } | {
89
+ typ: 'object';
90
+ pflicht: boolean;
91
+ felder: Readonly<Record<string, Feld>>;
92
+ } | {
93
+ typ: 'list';
94
+ pflicht: boolean;
95
+ min: number;
96
+ max: number;
97
+ eintrag: Feld;
98
+ } | {
99
+ typ: 'map';
100
+ pflicht: boolean;
101
+ maxSchluessel: number;
102
+ schluesselMuster: string;
103
+ wertMax: number;
104
+ };
105
+ /** Kunde, wie das Fremdsystem ihn schickt. `vatId` ist die UID-Nummer. */
106
+ export declare const KUNDE_FELDER: Readonly<Record<string, Feld>>;
107
+ /** Eine Rechnungs- oder Gutschriftsposition. Preise in ganzen Cent. */
108
+ export declare const POSITION_FELDER: Readonly<Record<string, Feld>>;
109
+ export declare const RECHNUNG_ANFRAGEN: Readonly<Record<RechnungAufruf, Readonly<Record<string, Feld>>>>;
110
+ /** Genau eines dieser Felder muss gesetzt sein (je Aufruf, je Gruppe). */
111
+ export declare const RECHNUNG_GENAU_EINS: Readonly<Partial<Record<RechnungAufruf, readonly (readonly string[])[]>>>;
112
+ /** Mindestens eines dieser Felder muss gesetzt sein (je Aufruf, je Gruppe). */
113
+ export declare const RECHNUNG_MINDESTENS_EINS: Readonly<Partial<Record<RechnungAufruf, readonly (readonly string[])[]>>>;
@@ -0,0 +1,215 @@
1
+ /**
2
+ * Der Vertrag der Rechnungs-API — als Daten, nicht als Prosa.
3
+ *
4
+ * Aus dieser Datei entstehen drei Dinge, damit sie nicht auseinanderlaufen
5
+ * koennen:
6
+ *
7
+ * 1. `fixtures/rechnung-api.schema.json` (`npm run fixtures:rechnung`) — das
8
+ * Backend liest es aus dem vendorierten Paket und vergleicht es in beide
9
+ * Richtungen mit seiner eigenen Pruefung; der Dart-Zwilling zieht es byteweise.
10
+ * 2. Die Listen unter `rechnung` in `fixtures/oberflaeche.json` (Codes, Gruende,
11
+ * Enums) — ueber denselben Namensraum-Scan wie der Partner-Teil.
12
+ * 3. Die TypeScript-Typen in `typen.ts`.
13
+ *
14
+ * Nach aussen spricht die Schnittstelle Englisch: Feldnamen, Codes, Gruende.
15
+ * Deutsch bleibt, was ein Mensch liest (`message`, der Aufdruck eines Grundes).
16
+ *
17
+ * Beschrieben wird die Anfrage. Was der Server daraus macht — Rechnungsdatum,
18
+ * Nummer, Summen — ist bewusst **nicht** setzbar.
19
+ */
20
+ export const RECHNUNG_VERTRAG_VERSION = 1;
21
+ export const RECHNUNG_AUFRUFE = [
22
+ 'createCustomer',
23
+ 'getCustomer',
24
+ 'updateCustomer',
25
+ 'searchCustomers',
26
+ 'issueInvoice',
27
+ 'cancelInvoice',
28
+ 'createCreditNote',
29
+ 'getInvoice',
30
+ 'listInvoices',
31
+ 'getInvoicePdf',
32
+ 'getInvoiceXml',
33
+ 'getInvoiceSetupStatus',
34
+ ];
35
+ /**
36
+ * Stabile Fehlercodes. Das Fremdsystem verzweigt am Code, der Text darf sich
37
+ * aendern. `validation` traegt zusaetzlich `errors: [{ field, message }]`.
38
+ */
39
+ export const INVOICE_ERROR_CODES = [
40
+ 'validation',
41
+ 'idempotency_conflict',
42
+ 'module_inactive',
43
+ 'customer_not_found',
44
+ 'customer_exists',
45
+ 'short_code_taken',
46
+ 'short_code_immutable',
47
+ 'recipient_required',
48
+ 'invoice_requirements_missing',
49
+ 'invoice_not_found',
50
+ 'invoice_ambiguous',
51
+ 'not_cancellable',
52
+ 'partial_credit_exists',
53
+ 'credit_exceeds_invoice',
54
+ 'einvoice_incomplete',
55
+ 'invoice_api_not_enabled',
56
+ 'invoice_setup_incomplete',
57
+ ];
58
+ /** Gruende einer Gutschrift. Der Server druckt den deutschen Anzeigetext. */
59
+ export const CREDIT_NOTE_REASONS = [
60
+ 'cancellation',
61
+ 'price_reduction',
62
+ 'return',
63
+ 'incorrect_invoice',
64
+ 'other',
65
+ ];
66
+ export const TAX_SCHEMES = ['normal', 'smallBusiness', 'reverseCharge', 'igLieferung', 'exportThirdCountry'];
67
+ export const PRICE_MODES = ['net', 'gross'];
68
+ export const VAT_RATES = [0, 10, 13, 20];
69
+ export const CUSTOMER_TYPES = ['private', 'company'];
70
+ export const INVOICE_LIST_STATUS = ['final', 'paid', 'cancelled', 'open', 'overdue'];
71
+ export const DOC_TYPES = ['RE', 'GU'];
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
+ ];
96
+ const text = (max, pflicht = false, extra = {}) => ({ typ: 'string', pflicht, max, ...(pflicht && extra.min === undefined ? { min: 1 } : {}), ...extra });
97
+ const idempotencyKey = (pflicht) => ({ typ: 'string', pflicht, min: 1, max: 120 });
98
+ const id = { typ: 'string', pflicht: false, min: 1, max: 128 };
99
+ const idPflicht = { typ: 'string', pflicht: true, min: 1, max: 128 };
100
+ const datum = (pflicht = false) => ({ typ: 'string', pflicht, min: 10, max: 10, format: 'date' });
101
+ const limit = { typ: 'integer', pflicht: false, min: 1, max: 100 };
102
+ const cursor = { typ: 'string', pflicht: false, min: 1, max: 500 };
103
+ /** Kunde, wie das Fremdsystem ihn schickt. `vatId` ist die UID-Nummer. */
104
+ export const KUNDE_FELDER = Object.freeze({
105
+ type: { typ: 'enum', pflicht: true, werte: CUSTOMER_TYPES },
106
+ name: text(200, true),
107
+ legalForm: text(40),
108
+ email: text(254, false, { format: 'email' }),
109
+ phone: text(40, false, { format: 'phone' }),
110
+ street: text(200),
111
+ houseNumber: text(20),
112
+ zip: text(10),
113
+ city: text(100),
114
+ country: text(2, true, { min: 2, format: 'country' }),
115
+ vatId: text(20, false, { format: 'vatId' }),
116
+ shortCode: text(8, false, { format: 'shortCode' }),
117
+ isAuthority: { typ: 'boolean', pflicht: false },
118
+ note: text(1000),
119
+ externalId: { typ: 'string', pflicht: false, min: 1, max: 120 },
120
+ });
121
+ /** Beim Aendern ist jedes Kundenfeld optional. */
122
+ const KUNDE_PATCH = Object.freeze(Object.fromEntries(Object.entries(KUNDE_FELDER).map(([name, feld]) => [name, { ...feld, pflicht: false }])));
123
+ /** Eine Rechnungs- oder Gutschriftsposition. Preise in ganzen Cent. */
124
+ export const POSITION_FELDER = Object.freeze({
125
+ description: text(300, true),
126
+ subtitle: text(1000),
127
+ quantity: { typ: 'number', pflicht: true, min: 0, exklusivMin: true, max: 1_000_000, nachkomma: 3 },
128
+ unit: text(20),
129
+ unitPriceCents: { typ: 'integer', pflicht: true, min: 0, max: 100_000_000 },
130
+ vatRate: { typ: 'enum', pflicht: true, werte: VAT_RATES },
131
+ discountPct: { typ: 'number', pflicht: false, min: 0, max: 100, nachkomma: 2 },
132
+ });
133
+ const positionen = { typ: 'list', pflicht: true, min: 1, max: 500, eintrag: { typ: 'object', pflicht: true, felder: POSITION_FELDER } };
134
+ export const RECHNUNG_ANFRAGEN = Object.freeze({
135
+ createCustomer: {
136
+ customer: { typ: 'object', pflicht: true, felder: KUNDE_FELDER },
137
+ idempotencyKey: idempotencyKey(false),
138
+ },
139
+ getCustomer: {
140
+ customerId: id,
141
+ externalId: { typ: 'string', pflicht: false, min: 1, max: 120 },
142
+ },
143
+ updateCustomer: {
144
+ customerId: idPflicht,
145
+ customer: { typ: 'object', pflicht: true, felder: KUNDE_PATCH },
146
+ },
147
+ searchCustomers: {
148
+ externalId: { typ: 'string', pflicht: false, min: 1, max: 120 },
149
+ vatId: text(20),
150
+ email: text(254),
151
+ name: text(200),
152
+ limit,
153
+ cursor,
154
+ },
155
+ issueInvoice: {
156
+ idempotencyKey: idempotencyKey(true),
157
+ customerId: id,
158
+ taxScheme: { typ: 'enum', pflicht: true, werte: TAX_SCHEMES },
159
+ priceMode: { typ: 'enum', pflicht: true, werte: PRICE_MODES },
160
+ serviceStart: datum(true),
161
+ serviceEnd: datum(),
162
+ paymentTermDays: { typ: 'integer', pflicht: false, min: 0, max: 365 },
163
+ orderReference: text(200),
164
+ intro: text(2000),
165
+ note: text(2000),
166
+ paymentReference: text(140),
167
+ girocode: { typ: 'boolean', pflicht: false },
168
+ tracking: { typ: 'boolean', pflicht: false },
169
+ items: positionen,
170
+ metadata: { typ: 'map', pflicht: false, maxSchluessel: 20, schluesselMuster: '^[a-zA-Z0-9_]{1,40}$', wertMax: 500 },
171
+ },
172
+ cancelInvoice: {
173
+ idempotencyKey: idempotencyKey(true),
174
+ invoiceId: idPflicht,
175
+ reason: { typ: 'enum', pflicht: true, werte: CREDIT_NOTE_REASONS },
176
+ note: text(2000),
177
+ },
178
+ createCreditNote: {
179
+ idempotencyKey: idempotencyKey(true),
180
+ invoiceId: idPflicht,
181
+ reason: { typ: 'enum', pflicht: true, werte: CREDIT_NOTE_REASONS },
182
+ note: text(2000),
183
+ items: positionen,
184
+ },
185
+ getInvoice: {
186
+ invoiceId: id,
187
+ number: { typ: 'string', pflicht: false, min: 1, max: 100 },
188
+ },
189
+ listInvoices: {
190
+ from: datum(),
191
+ to: datum(),
192
+ status: { typ: 'enum', pflicht: false, werte: INVOICE_LIST_STATUS },
193
+ docType: { typ: 'enum', pflicht: false, werte: DOC_TYPES },
194
+ customerId: id,
195
+ limit,
196
+ cursor,
197
+ },
198
+ getInvoicePdf: {
199
+ invoiceId: idPflicht,
200
+ },
201
+ getInvoiceXml: {
202
+ invoiceId: idPflicht,
203
+ format: { typ: 'enum', pflicht: false, werte: EINVOICE_FORMATS },
204
+ },
205
+ getInvoiceSetupStatus: {},
206
+ });
207
+ /** Genau eines dieser Felder muss gesetzt sein (je Aufruf, je Gruppe). */
208
+ export const RECHNUNG_GENAU_EINS = Object.freeze({
209
+ getCustomer: [['customerId', 'externalId']],
210
+ getInvoice: [['invoiceId', 'number']],
211
+ });
212
+ /** Mindestens eines dieser Felder muss gesetzt sein (je Aufruf, je Gruppe). */
213
+ export const RECHNUNG_MINDESTENS_EINS = Object.freeze({
214
+ searchCustomers: [['externalId', 'vatId', 'email', 'name']],
215
+ });
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.14.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.14.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."