@kreiseck/kasseneck-api 1.14.0 → 1.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 +21 -0
  2. package/README.md +72 -2
  3. package/dist/cjs/client/api.d.ts +5 -0
  4. package/dist/cjs/client/api.js +3 -0
  5. package/dist/cjs/client/aufrufe.d.ts +2 -2
  6. package/dist/cjs/client/aufrufe.js +4 -0
  7. package/dist/cjs/client/index.d.ts +1 -0
  8. package/dist/cjs/client/index.js +12 -1
  9. package/dist/cjs/client/list-receipts.d.ts +217 -0
  10. package/dist/cjs/client/list-receipts.js +298 -0
  11. package/dist/cjs/index.d.ts +1 -1
  12. package/dist/cjs/index.js +11 -2
  13. package/dist/cjs/invoice/vertrag.d.ts +1 -1
  14. package/dist/cjs/invoice/vertrag.js +2 -0
  15. package/dist/cjs/models/receipt-errors.d.ts +1 -1
  16. package/dist/cjs/models/receipt-errors.js +3 -0
  17. package/dist/cjs/stored/vokabular.d.ts +1 -1
  18. package/dist/cjs/stored/vokabular.js +14 -2
  19. package/dist/cjs/version.d.ts +1 -1
  20. package/dist/cjs/version.js +1 -1
  21. package/dist/esm/client/api.d.ts +5 -0
  22. package/dist/esm/client/api.js +3 -0
  23. package/dist/esm/client/aufrufe.d.ts +2 -2
  24. package/dist/esm/client/aufrufe.js +4 -0
  25. package/dist/esm/client/index.d.ts +1 -0
  26. package/dist/esm/client/index.js +1 -0
  27. package/dist/esm/client/list-receipts.d.ts +217 -0
  28. package/dist/esm/client/list-receipts.js +292 -0
  29. package/dist/esm/index.d.ts +1 -1
  30. package/dist/esm/index.js +1 -1
  31. package/dist/esm/invoice/vertrag.d.ts +1 -1
  32. package/dist/esm/invoice/vertrag.js +2 -0
  33. package/dist/esm/models/receipt-errors.d.ts +1 -1
  34. package/dist/esm/models/receipt-errors.js +3 -0
  35. package/dist/esm/stored/vokabular.d.ts +1 -1
  36. package/dist/esm/stored/vokabular.js +14 -2
  37. package/dist/esm/version.d.ts +1 -1
  38. package/dist/esm/version.js +1 -1
  39. package/fixtures/hobex-hps-codes.json +1 -1
  40. package/fixtures/invoice-api.schema.json +3 -2
  41. package/fixtures/invoice-texts.json +1 -1
  42. package/fixtures/pos-texts.json +1 -1
  43. package/fixtures/receipt-due-voucher-generated.json +1 -1
  44. package/fixtures/surface.json +6 -3
  45. package/fixtures/v3/antworten/belege.json +1 -1
  46. package/fixtures/v3/antworten/belegmail.json +1 -1
  47. package/fixtures/v3/antworten/kasse-belege.json +1 -1
  48. package/fixtures/v3/antworten/kasse.json +75 -10
  49. package/fixtures/v3/antworten/lager.json +1 -1
  50. package/fixtures/v3/antworten/rechnungen.json +1 -1
  51. package/fixtures/v3/antworten/storno.json +1 -1
  52. package/fixtures/v3/stored/belege.json +1 -1
  53. package/fixtures/v3/stored/kasse.json +151 -381
  54. package/fixtures/v3/stored/rechnungen.json +142 -2
  55. package/fixtures/v3/v3-vokabular.json +103 -11
  56. package/fixtures/v3/zahlbetrag-faelle.json +1 -1
  57. package/package.json +1 -1
@@ -0,0 +1,217 @@
1
+ import { KeckPaymentMethod, ReceiptType } from '../enums/index.js';
2
+ import { type CancellationReason, type CancellationStatus, type Receipt, type ReceiptPayment, type ZeroKind } from '../models/index.js';
3
+ import type { ReportV2Metadata } from './reports.js';
4
+ import type { InternerTransport } from './aufrufe.js';
5
+ /**
6
+ * Belege einer Kasse auflisten (`listReceipts`, nur unter `/v3`): ein Tag oder
7
+ * ein Zeitraum von hoechstens 31 Kalendertagen, Seite fuer Seite ueber einen
8
+ * undurchsichtigen Cursor. Nachfolger von `getReportV2` fuer Listen;
9
+ * `getReportV2` bleibt fuer Berichte.
10
+ *
11
+ * **Anmeldung wie `getReportV2`:** API-Schluessel plus `cashregister-token`
12
+ * (`apiKeyAuth`); die Kasse kommt aus dem Token, nie aus einem Parameter.
13
+ * Kassen-Bediener (Geraet + PIN) weist der Server ab; die Kasse hat dafuer
14
+ * `listMyReceipts` am Kassenweg. Dieses Paket bildet das nicht nach, wer darf,
15
+ * entscheidet allein das Backend.
16
+ *
17
+ * Zeiten sind die **Wiener Wanduhr** als Text, wie `timeStamp` am Beleg; der
18
+ * Server vergleicht sie als Text. Ein Tag ist ein Kalendertag, auch an den
19
+ * Tagen der Zeitumstellung, und die Grenze von 31 Tagen zaehlt Kalendertage,
20
+ * nicht 31 x 24 Stunden. Die Pruefung hier rechnet darum ohne Zeitzone, genau
21
+ * wie der Server (`beleg-liste-core.js`).
22
+ */
23
+ /** Ansicht einer Seite: `summary` eine schlanke Zeile je Beleg, `full` das gespeicherte Belegdokument. */
24
+ export declare const LIST_RECEIPTS_VIEWS: readonly ["summary", "full"];
25
+ export type ListReceiptsView = (typeof LIST_RECEIPTS_VIEWS)[number];
26
+ /** Reihenfolge: `desc` neueste zuerst (Vorgabe des Servers), `asc` aelteste zuerst. */
27
+ export declare const LIST_RECEIPTS_ORDERS: readonly ["desc", "asc"];
28
+ export type ListReceiptsOrder = (typeof LIST_RECEIPTS_ORDERS)[number];
29
+ /** Groesste Seite, die der Server liefert (`limit`); ohne Angabe nimmt er 100. */
30
+ export declare const LIST_RECEIPTS_LIMIT_MAX = 500;
31
+ /** Laengster Zeitraum in Kalendertagen (`to` hoechstens `from` + 31 Tage). */
32
+ export declare const LIST_RECEIPTS_DAYS_MAX = 31;
33
+ /**
34
+ * So viele Seiten holt [listAllReceipts] hoechstens, dann bricht er mit
35
+ * Fehler ab. Schutz gegen einen Cursor, der nie endet; mit der Seitengroesse
36
+ * des Helfers (500) sind das 50.000 Belege, mehr als jede Kasse in 31 Tagen
37
+ * ausstellt.
38
+ */
39
+ export declare const LIST_ALL_RECEIPTS_MAX_PAGES = 100;
40
+ /**
41
+ * Fehlercodes von `listReceipts` (`code` des [KasseneckApiError]), dazu die
42
+ * gemeinsamen Codes von Anmeldung und Rand (Kassen-Token, Live-Gate,
43
+ * API-Freigabe). Ein Code ausserhalb bleibt ueber `KasseneckApiError.code`
44
+ * lesbar. Die Regeln der ersten sieben prueft dieses Paket schon vor dem
45
+ * Senden (ausser `invalid_cursor`: ob ein Cursor zur Abfrage passt, weiss nur
46
+ * der Server).
47
+ */
48
+ export declare const LIST_RECEIPTS_ERROR_CODES: readonly ["invalid_date", "invalid_range", "range_too_long", "invalid_limit", "invalid_order", "invalid_view", "invalid_cursor", "server_error"];
49
+ export type ListReceiptsErrorCode = (typeof LIST_RECEIPTS_ERROR_CODES)[number];
50
+ /**
51
+ * Eingabe von [listReceipts]. Genau eine Form des Zeitfensters: `date` ODER
52
+ * `from` + `to`.
53
+ *
54
+ * - `date`: ein Wiener Tag, `YYYY-MM-DD` (00:00:00 bis zum Beginn des
55
+ * Folgetags). Nur mit `date` traegt die erste Seite `daySummary`.
56
+ * - `from` (einschliesslich) und `to` (ausschliesslich): `YYYY-MM-DD` oder
57
+ * `YYYY-MM-DDTHH:mm:ss`, Wiener Wanduhr ohne Zone. Ein reines Datum heisst
58
+ * Beginn dieses Tages; `to` liegt hoechstens 31 Kalendertage nach `from`.
59
+ *
60
+ * Mit `cursor` (dem `nextCursor` der Vorseite) muessen Zeitfenster, `order`
61
+ * und `view` gleich bleiben wie auf Seite 1, sonst antwortet der Server
62
+ * `invalid_cursor`; `limit` darf sich aendern.
63
+ */
64
+ export type ListReceiptsOptions<V extends ListReceiptsView = ListReceiptsView> = ListReceiptsWindow & {
65
+ /** Seitengroesse, ganze Zahl 1-500; ohne Angabe 100. */
66
+ limit?: number;
67
+ /** Ohne Angabe `desc` (neueste zuerst). */
68
+ order?: ListReceiptsOrder;
69
+ /** Ohne Angabe `summary`. */
70
+ view?: V;
71
+ /** `nextCursor` der vorigen Seite. */
72
+ cursor?: string;
73
+ };
74
+ /** Zeitfenster von [ListReceiptsOptions]: ein Tag oder ein Zeitraum. */
75
+ export type ListReceiptsWindow = {
76
+ date: string;
77
+ from?: undefined;
78
+ to?: undefined;
79
+ } | {
80
+ from: string;
81
+ to: string;
82
+ date?: undefined;
83
+ };
84
+ /** Brutto je RKSV-Satzgruppe in Cent (`amountRateStandard` bis `amountRateSpecial` am Beleg). */
85
+ export interface ListReceiptsGrossByRate {
86
+ standard: number;
87
+ reduced1: number;
88
+ reduced2: number;
89
+ zero: number;
90
+ special: number;
91
+ }
92
+ /**
93
+ * Zeile eines Belegs in [listReceipts] mit `view: 'summary'`. Betraege in
94
+ * ganzen Cent. Kein Layout, kein Kopf, keine Positionen und keine
95
+ * Pruefangaben: fuer die Detailansicht `getReceipt`, fuer die PDF
96
+ * `downloadReceipt` mit `fullReceiptId`.
97
+ *
98
+ * Nicht zu verwechseln mit [ReceiptSummary] von `listMyReceipts` (Kassenweg,
99
+ * andere Felder, Betrag dort aus Euro gerechnet).
100
+ *
101
+ * `receiptType` und `paymentMethod` sind wie ueberall beim Lesen der bekannte
102
+ * Enum-Eintrag oder der rohe Schluessel; ein Wert, den dieses Paket nicht
103
+ * kennt, laesst die Liste nicht scheitern.
104
+ */
105
+ export interface ListReceiptsSummary {
106
+ receiptId: string | null;
107
+ /** Fortlaufender Belegzaehler der Kasse; `null` bei Alt-Belegen. */
108
+ counter: number | null;
109
+ receiptType: ReceiptType | string | null;
110
+ /** Nur am Nullbeleg: Anlass (`manual`, wenn der Beleg keinen nennt); sonst `null`. */
111
+ zeroKind: ZeroKind | string | null;
112
+ /** Roher Belegzeitstempel (Wiener Wanduhr); Deutung ueber `parseServerTimeStamp`. */
113
+ timeStamp: string | null;
114
+ /** Summe von `grossByRateCents`; negativ am Storno-Beleg. */
115
+ totalCents: number;
116
+ grossByRateCents: ListReceiptsGrossByRate;
117
+ /** `mixed` bei mehreren Zahlungen (die stehen dann in `payments`). */
118
+ paymentMethod: KeckPaymentMethod | string | null;
119
+ /** Nur wenn der Beleg eine Zahlungsliste traegt; ohne Anbieterdaten. */
120
+ payments?: ReceiptPayment[];
121
+ /** Nur wenn der Beleg Trinkgeld traegt. */
122
+ tipCents?: number;
123
+ /** Bediener (nur der Name), oder `null`. */
124
+ operator: {
125
+ name: string;
126
+ } | null;
127
+ /** Nur am Storno-Beleg: das Original. */
128
+ cancellationOf: {
129
+ receiptId: string | null;
130
+ timeStamp: string | null;
131
+ } | null;
132
+ cancellationReason: CancellationReason | string | null;
133
+ /**
134
+ * Storno-Stand: `none`, `partial` oder `full` (nur an Normalbelegen anders
135
+ * als `none`). Ein Wert, den dieses Paket nicht kennt, kommt als
136
+ * `'unknown'` an, nie still als `none`: dann keinen Storno anbieten, bis
137
+ * der Beleg einzeln gelesen ist.
138
+ */
139
+ cancellationStatus: CancellationStatus | 'unknown';
140
+ /** Mit funktionierender Signatureinheit ausgestellt (`signatureSuccess !== false`). */
141
+ signatureOk: boolean;
142
+ /** Eigene Referenz des Aufrufers am Beleg, oder `null`. */
143
+ customProjectId: string | null;
144
+ /** Schluessel fuer `downloadReceipt` und den Beleg-Link, oder `null`. */
145
+ fullReceiptId: string | null;
146
+ }
147
+ /** Ein Beleg der Liste je Ansicht: `full` das Belegdokument wie bei `getReportV2`, sonst die Zeile. */
148
+ export type ListedReceipt<V extends ListReceiptsView = 'summary'> = V extends 'full' ? Receipt : ListReceiptsSummary;
149
+ /**
150
+ * Tagessumme aus der Tagesstatistik der Kasse, nur bei `date` und nur auf
151
+ * der ersten Seite. **Nicht die Summe der Liste:** `receiptCount` zaehlt jeden
152
+ * Beleg des Tages (auch Null-, Start- und Trainingsbelege), `revenueCents`
153
+ * nur Normal- und Storno-Belege, ohne Mitarbeiter-Trinkgeld und nach
154
+ * Aktionsrabatt. Wer die Liste summieren will, summiert die Liste.
155
+ */
156
+ export interface ListReceiptsDaySummary {
157
+ date: string;
158
+ receiptCount: number;
159
+ revenueCents: number;
160
+ /** Je Steuersatz (Basispunkte, 2000 = 20 %), hoechster zuerst; Saetze ohne Umsatz fehlen. */
161
+ revenueByRate: Array<{
162
+ rateBp: number;
163
+ grossCents: number;
164
+ }>;
165
+ }
166
+ /** Eine Seite von [listReceipts]. */
167
+ export interface ListReceiptsPage<V extends ListReceiptsView = 'summary'> {
168
+ receipts: Array<ListedReceipt<V>>;
169
+ /** Es gibt weitere Belege: mit `cursor: nextCursor` weiterlesen. */
170
+ hasMore: boolean;
171
+ /** `null`, wenn `hasMore` false ist. */
172
+ nextCursor: string | null;
173
+ /**
174
+ * Nur bei `date` auf der ersten Seite (ohne `cursor`); `null`, wenn es fuer
175
+ * den Tag keine Statistik gibt. Auf allen anderen Seiten fehlt das Feld.
176
+ */
177
+ daySummary?: ListReceiptsDaySummary | null;
178
+ /**
179
+ * Nur bei `view: 'full'`: Firmendaten fuer den Belegkopf (Nachdruck), dieselben Felder wie
180
+ * `getReportV2().metadata`. Bei der Kurzansicht fehlt das Feld.
181
+ */
182
+ metadata?: V extends 'full' ? ReportV2Metadata : never;
183
+ }
184
+ /** Zeile `view: summary` vom Draht. */
185
+ export declare function fromListReceiptsSummaryPayload(payload: Record<string, unknown>): ListReceiptsSummary;
186
+ /**
187
+ * Eine Seite Belege der angemeldeten Kasse (`listReceipts`). Die Eingabe wird
188
+ * vor dem Senden nach den Regeln des Servers geprueft (genau eine Form des
189
+ * Zeitfensters, Datumsformat, hoechstens 31 Kalendertage, `limit` 1-500,
190
+ * `order`, `view`); ein Verstoss wirft [KasseneckValidationError] mit
191
+ * `scope: 'request'`, ohne dass etwas hinausgeht.
192
+ *
193
+ * Mit `view: 'full'` sind die Belege das gespeicherte Belegdokument
194
+ * ([Receipt], dieselbe Form wie `getReportV2`), sonst [ListReceiptsSummary].
195
+ * Alle Seiten auf einmal: [listAllReceipts].
196
+ */
197
+ export declare function listReceipts<V extends ListReceiptsView = 'summary'>(transport: InternerTransport, options: ListReceiptsOptions<V>): Promise<ListReceiptsPage<V>>;
198
+ /**
199
+ * Alle Belege eines Tages oder Zeitraums, Seite fuer Seite: holt mit
200
+ * [listReceipts] die erste Seite, dann mit `cursor: nextCursor` und
201
+ * demselben Zeitfenster, `order` und `view` jede weitere, und liefert jeden
202
+ * Beleg einzeln, in der Reihenfolge des Servers. Jeder Beleg des Fensters
203
+ * kommt genau einmal.
204
+ *
205
+ * Ohne `limit` holt der Helfer Seiten zu 500 (weniger Aufrufe als die
206
+ * Vorgabe 100 des Servers). Mit `cursor` setzt er an dieser Stelle fort.
207
+ *
208
+ * Ein Fehler auf irgendeiner Seite bricht ab (der Fehler kommt im
209
+ * `for await` an); die bis dahin gelieferten Belege bleiben gueltig. Nach
210
+ * [LIST_ALL_RECEIPTS_MAX_PAGES] Seiten, oder wenn der Server denselben
211
+ * Cursor zweimal nennt, bricht er mit [KasseneckValidationError]
212
+ * (`scope: 'response'`) ab, statt endlos zu laufen.
213
+ *
214
+ * `daySummary` liefert der Helfer nicht; wer sie braucht, ruft die erste
215
+ * Seite mit [listReceipts].
216
+ */
217
+ export declare function listAllReceipts<V extends ListReceiptsView = 'summary'>(transport: InternerTransport, options: ListReceiptsOptions<V>): AsyncGenerator<ListedReceipt<V>, void, undefined>;
@@ -0,0 +1,292 @@
1
+ import { KeckPaymentMethod, ReceiptType } from '../enums/index.js';
2
+ import { CANCELLATION_STATUSES, fromReceiptCompanyPayload, fromReceiptPayload, fromReceiptPaymentPayload, } from '../models/index.js';
3
+ import { readEnumKey } from '../models/enum-payload.js';
4
+ import { KasseneckValidationError } from './errors.js';
5
+ /**
6
+ * Belege einer Kasse auflisten (`listReceipts`, nur unter `/v3`): ein Tag oder
7
+ * ein Zeitraum von hoechstens 31 Kalendertagen, Seite fuer Seite ueber einen
8
+ * undurchsichtigen Cursor. Nachfolger von `getReportV2` fuer Listen;
9
+ * `getReportV2` bleibt fuer Berichte.
10
+ *
11
+ * **Anmeldung wie `getReportV2`:** API-Schluessel plus `cashregister-token`
12
+ * (`apiKeyAuth`); die Kasse kommt aus dem Token, nie aus einem Parameter.
13
+ * Kassen-Bediener (Geraet + PIN) weist der Server ab; die Kasse hat dafuer
14
+ * `listMyReceipts` am Kassenweg. Dieses Paket bildet das nicht nach, wer darf,
15
+ * entscheidet allein das Backend.
16
+ *
17
+ * Zeiten sind die **Wiener Wanduhr** als Text, wie `timeStamp` am Beleg; der
18
+ * Server vergleicht sie als Text. Ein Tag ist ein Kalendertag, auch an den
19
+ * Tagen der Zeitumstellung, und die Grenze von 31 Tagen zaehlt Kalendertage,
20
+ * nicht 31 x 24 Stunden. Die Pruefung hier rechnet darum ohne Zeitzone, genau
21
+ * wie der Server (`beleg-liste-core.js`).
22
+ */
23
+ /** Ansicht einer Seite: `summary` eine schlanke Zeile je Beleg, `full` das gespeicherte Belegdokument. */
24
+ export const LIST_RECEIPTS_VIEWS = Object.freeze(['summary', 'full']);
25
+ /** Reihenfolge: `desc` neueste zuerst (Vorgabe des Servers), `asc` aelteste zuerst. */
26
+ export const LIST_RECEIPTS_ORDERS = Object.freeze(['desc', 'asc']);
27
+ /** Groesste Seite, die der Server liefert (`limit`); ohne Angabe nimmt er 100. */
28
+ export const LIST_RECEIPTS_LIMIT_MAX = 500;
29
+ /** Laengster Zeitraum in Kalendertagen (`to` hoechstens `from` + 31 Tage). */
30
+ export const LIST_RECEIPTS_DAYS_MAX = 31;
31
+ /**
32
+ * So viele Seiten holt [listAllReceipts] hoechstens, dann bricht er mit
33
+ * Fehler ab. Schutz gegen einen Cursor, der nie endet; mit der Seitengroesse
34
+ * des Helfers (500) sind das 50.000 Belege, mehr als jede Kasse in 31 Tagen
35
+ * ausstellt.
36
+ */
37
+ export const LIST_ALL_RECEIPTS_MAX_PAGES = 100;
38
+ /**
39
+ * Fehlercodes von `listReceipts` (`code` des [KasseneckApiError]), dazu die
40
+ * gemeinsamen Codes von Anmeldung und Rand (Kassen-Token, Live-Gate,
41
+ * API-Freigabe). Ein Code ausserhalb bleibt ueber `KasseneckApiError.code`
42
+ * lesbar. Die Regeln der ersten sieben prueft dieses Paket schon vor dem
43
+ * Senden (ausser `invalid_cursor`: ob ein Cursor zur Abfrage passt, weiss nur
44
+ * der Server).
45
+ */
46
+ export const LIST_RECEIPTS_ERROR_CODES = Object.freeze([
47
+ 'invalid_date', // kein Datum JJJJ-MM-TT bzw. Zeitpunkt JJJJ-MM-TTThh:mm:ss, oder unmoeglich (2026-02-30)
48
+ 'invalid_range', // nicht genau eine Form (date ODER from + to), oder to nicht nach from
49
+ 'range_too_long', // mehr als 31 Kalendertage
50
+ 'invalid_limit', // keine ganze Zahl von 1 bis 500 (der Server kappt nie still)
51
+ 'invalid_order', // weder desc noch asc
52
+ 'invalid_view', // weder summary noch full
53
+ 'invalid_cursor', // veraendert, fremde Kasse, oder Zeitfenster/order/view anders als auf Seite 1
54
+ 'server_error',
55
+ ]);
56
+ const TAG = /^(\d{4})-(\d{2})-(\d{2})$/;
57
+ const ZEIT = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})$/;
58
+ /** Kalendertag als UTC-Mitternacht (nur zum Rechnen mit Tagen; auch fuer Jahre unter 100). */
59
+ function utcTag(jahr, monat, tag) {
60
+ const d = new Date(Date.UTC(2000, 0, 1));
61
+ d.setUTCFullYear(jahr, monat - 1, tag);
62
+ return d;
63
+ }
64
+ /** Ein echtes Kalenderdatum (2026-02-30 nicht)? */
65
+ function kalendertag(jahr, monat, tag) {
66
+ const d = utcTag(jahr, monat, tag);
67
+ return d.getUTCFullYear() === jahr && d.getUTCMonth() === monat - 1 && d.getUTCDate() === tag;
68
+ }
69
+ const zwei = (n) => String(n).padStart(2, '0');
70
+ /** Wanduhr-Text `YYYY-MM-DDTHH:mm:ss` aus einem Tag oder Zeitpunkt; sonst `null`. */
71
+ function wanduhr(wert) {
72
+ if (typeof wert !== 'string')
73
+ return null;
74
+ const t = TAG.exec(wert);
75
+ if (t)
76
+ return kalendertag(+t[1], +t[2], +t[3]) ? `${wert}T00:00:00` : null;
77
+ const z = ZEIT.exec(wert);
78
+ if (z && kalendertag(+z[1], +z[2], +z[3]) && +z[4] <= 23 && +z[5] <= 59 && +z[6] <= 59)
79
+ return wert;
80
+ return null;
81
+ }
82
+ /** Wanduhr-Text plus ganze Kalendertage, Uhrzeit bleibt (ohne Zeitzone gerechnet). */
83
+ function plusTage(zeit, tage) {
84
+ const [datum, uhr] = zeit.split('T');
85
+ const [j, m, t] = datum.split('-').map(Number);
86
+ const d = utcTag(j, m, t + tage);
87
+ return `${String(d.getUTCFullYear()).padStart(4, '0')}-${zwei(d.getUTCMonth() + 1)}-${zwei(d.getUTCDate())}T${uhr}`;
88
+ }
89
+ const gesetzt = (v) => v !== undefined && v !== null;
90
+ /** Fehler in der Eingabe des Aufrufers: es geht keine Anfrage raus. */
91
+ function eingabefehler(grund) {
92
+ return new KasseneckValidationError('listReceipts', grund, 'request');
93
+ }
94
+ /** Antwort meldet Erfolg, traegt aber nicht, was der Aufruf zusagt. */
95
+ function antwortfehler(grund) {
96
+ return new KasseneckValidationError('listReceipts', grund, 'response');
97
+ }
98
+ /**
99
+ * Prueft die Eingabe nach den Regeln des Servers und gibt die Parameter
100
+ * zurueck, die hinausgehen (nur gesetzte Felder, Werte unveraendert, damit
101
+ * Folgeseiten dasselbe Fenster senden).
102
+ */
103
+ function parameter(options) {
104
+ if (options == null || typeof options !== 'object')
105
+ throw eingabefehler('Optionen fehlen (date oder from und to)');
106
+ const o = options;
107
+ const raus = {};
108
+ if (gesetzt(o.date)) {
109
+ if (gesetzt(o.from) || gesetzt(o.to))
110
+ throw eingabefehler('entweder date oder from und to angeben, nicht beides');
111
+ if (typeof o.date !== 'string' || !TAG.test(o.date) || wanduhr(o.date) === null) {
112
+ throw eingabefehler(`date muss ein Datum YYYY-MM-DD sein, war "${String(o.date)}"`);
113
+ }
114
+ raus['date'] = o.date;
115
+ }
116
+ else {
117
+ if (!gesetzt(o.from) || !gesetzt(o.to))
118
+ throw eingabefehler('Zeitraum fehlt: date oder from und to angeben');
119
+ const von = wanduhr(o.from);
120
+ if (von === null)
121
+ throw eingabefehler(`from muss YYYY-MM-DD oder YYYY-MM-DDTHH:mm:ss sein, war "${String(o.from)}"`);
122
+ const bis = wanduhr(o.to);
123
+ if (bis === null)
124
+ throw eingabefehler(`to muss YYYY-MM-DD oder YYYY-MM-DDTHH:mm:ss sein, war "${String(o.to)}"`);
125
+ if (bis <= von)
126
+ throw eingabefehler('to muss nach from liegen (to ist ausschliesslich)');
127
+ if (bis > plusTage(von, LIST_RECEIPTS_DAYS_MAX)) {
128
+ throw eingabefehler(`Zeitraum hoechstens ${LIST_RECEIPTS_DAYS_MAX} Kalendertage (to hoechstens from + ${LIST_RECEIPTS_DAYS_MAX} Tage)`);
129
+ }
130
+ raus['from'] = o.from;
131
+ raus['to'] = o.to;
132
+ }
133
+ if (gesetzt(o.limit)) {
134
+ if (!Number.isInteger(o.limit) || o.limit < 1 || o.limit > LIST_RECEIPTS_LIMIT_MAX) {
135
+ throw eingabefehler(`limit muss eine ganze Zahl von 1 bis ${LIST_RECEIPTS_LIMIT_MAX} sein, war "${String(o.limit)}"`);
136
+ }
137
+ raus['limit'] = o.limit;
138
+ }
139
+ if (gesetzt(o.order)) {
140
+ if (!LIST_RECEIPTS_ORDERS.includes(o.order))
141
+ throw eingabefehler(`order muss desc oder asc sein, war "${String(o.order)}"`);
142
+ raus['order'] = o.order;
143
+ }
144
+ if (gesetzt(o.view)) {
145
+ if (!LIST_RECEIPTS_VIEWS.includes(o.view))
146
+ throw eingabefehler(`view muss summary oder full sein, war "${String(o.view)}"`);
147
+ raus['view'] = o.view;
148
+ }
149
+ if (gesetzt(o.cursor)) {
150
+ if (typeof o.cursor !== 'string' || o.cursor === '')
151
+ throw eingabefehler('cursor muss der nextCursor der vorigen Seite sein (nicht leerer Text)');
152
+ raus['cursor'] = o.cursor;
153
+ }
154
+ return raus;
155
+ }
156
+ const istObjekt = (w) => w != null && typeof w === 'object' && !Array.isArray(w);
157
+ const text = (w) => (typeof w === 'string' ? w : null);
158
+ // Ganze Cent; ein einzelner unbrauchbarer Betrag laesst die Liste nicht scheitern.
159
+ const cent = (w) => (typeof w === 'number' && Number.isInteger(w) ? w : 0);
160
+ function istStornoStand(w) {
161
+ return typeof w === 'string' && CANCELLATION_STATUSES.includes(w);
162
+ }
163
+ /** Zeile `view: summary` vom Draht. */
164
+ export function fromListReceiptsSummaryPayload(payload) {
165
+ const brutto = istObjekt(payload['grossByRateCents']) ? payload['grossByRateCents'] : {};
166
+ const bediener = payload['operator'];
167
+ const bezug = payload['cancellationOf'];
168
+ return {
169
+ receiptId: text(payload['receiptId']),
170
+ counter: typeof payload['counter'] === 'number' ? payload['counter'] : null,
171
+ receiptType: typeof payload['receiptType'] === 'string' ? readEnumKey(ReceiptType, payload['receiptType']) : null,
172
+ zeroKind: text(payload['zeroKind']),
173
+ timeStamp: text(payload['timeStamp']),
174
+ totalCents: cent(payload['totalCents']),
175
+ grossByRateCents: {
176
+ standard: cent(brutto['standard']),
177
+ reduced1: cent(brutto['reduced1']),
178
+ reduced2: cent(brutto['reduced2']),
179
+ zero: cent(brutto['zero']),
180
+ special: cent(brutto['special']),
181
+ },
182
+ paymentMethod: typeof payload['paymentMethod'] === 'string' ? readEnumKey(KeckPaymentMethod, payload['paymentMethod']) : null,
183
+ ...(Array.isArray(payload['payments'])
184
+ ? { payments: payload['payments'].filter(istObjekt).map((z) => fromReceiptPaymentPayload(z)) }
185
+ : {}),
186
+ ...(typeof payload['tipCents'] === 'number' ? { tipCents: payload['tipCents'] } : {}),
187
+ operator: istObjekt(bediener) ? { name: typeof bediener['name'] === 'string' ? bediener['name'] : '' } : null,
188
+ cancellationOf: istObjekt(bezug) ? { receiptId: text(bezug['receiptId']), timeStamp: text(bezug['timeStamp']) } : null,
189
+ cancellationReason: text(payload['cancellationReason']),
190
+ cancellationStatus: istStornoStand(payload['cancellationStatus']) ? payload['cancellationStatus'] : 'unknown',
191
+ signatureOk: payload['signatureOk'] !== false,
192
+ customProjectId: text(payload['customProjectId']),
193
+ fullReceiptId: text(payload['fullReceiptId']),
194
+ };
195
+ }
196
+ function tagessumme(roh) {
197
+ if (roh === null)
198
+ return null;
199
+ if (!istObjekt(roh))
200
+ throw antwortfehler('daySummary ist weder ein Objekt noch null');
201
+ const saetze = Array.isArray(roh['revenueByRate']) ? roh['revenueByRate'] : [];
202
+ return {
203
+ date: typeof roh['date'] === 'string' ? roh['date'] : '',
204
+ receiptCount: cent(roh['receiptCount']),
205
+ revenueCents: cent(roh['revenueCents']),
206
+ revenueByRate: saetze.filter(istObjekt).map((z) => ({ rateBp: cent(z['rateBp']), grossCents: cent(z['grossCents']) })),
207
+ };
208
+ }
209
+ /** `metadata` der vollen Ansicht wie bei getReportV2: Firmendaten plus Bezeichnung der Kasse. */
210
+ function kopfdaten(roh) {
211
+ if (!istObjekt(roh))
212
+ throw antwortfehler('metadata ist kein Objekt');
213
+ const label = roh.label;
214
+ return { ...fromReceiptCompanyPayload(roh), label: typeof label === 'string' ? label : '' };
215
+ }
216
+ /**
217
+ * Eine Seite Belege der angemeldeten Kasse (`listReceipts`). Die Eingabe wird
218
+ * vor dem Senden nach den Regeln des Servers geprueft (genau eine Form des
219
+ * Zeitfensters, Datumsformat, hoechstens 31 Kalendertage, `limit` 1-500,
220
+ * `order`, `view`); ein Verstoss wirft [KasseneckValidationError] mit
221
+ * `scope: 'request'`, ohne dass etwas hinausgeht.
222
+ *
223
+ * Mit `view: 'full'` sind die Belege das gespeicherte Belegdokument
224
+ * ([Receipt], dieselbe Form wie `getReportV2`), sonst [ListReceiptsSummary].
225
+ * Alle Seiten auf einmal: [listAllReceipts].
226
+ */
227
+ export async function listReceipts(transport, options) {
228
+ const params = parameter(options);
229
+ const voll = params['view'] === 'full';
230
+ const daten = await transport('listReceipts', params);
231
+ if (!istObjekt(daten))
232
+ throw antwortfehler('Antwort enthaelt keine Daten (data fehlt)');
233
+ const liste = daten['receipts'];
234
+ if (!Array.isArray(liste) || liste.some((b) => !istObjekt(b))) {
235
+ throw antwortfehler('Antwort enthaelt keine Belegliste (data.receipts fehlt)');
236
+ }
237
+ if (typeof daten['hasMore'] !== 'boolean')
238
+ throw antwortfehler('Antwort ohne hasMore');
239
+ const weiter = daten['nextCursor'];
240
+ // Ein `hasMore` ohne Cursor liesse den Aufrufer ratlos (oder einen Blaetterer im Kreis laufen).
241
+ if (daten['hasMore'] ? typeof weiter !== 'string' || weiter === '' : weiter !== null) {
242
+ throw antwortfehler('nextCursor passt nicht zu hasMore (Text bei hasMore, sonst null)');
243
+ }
244
+ const receipts = (voll
245
+ ? liste.map((b) => fromReceiptPayload(b))
246
+ : liste.map((b) => fromListReceiptsSummaryPayload(b)));
247
+ return {
248
+ receipts,
249
+ hasMore: daten['hasMore'],
250
+ nextCursor: daten['hasMore'] ? weiter : null,
251
+ ...('daySummary' in daten ? { daySummary: tagessumme(daten['daySummary']) } : {}),
252
+ ...(voll && 'metadata' in daten ? { metadata: kopfdaten(daten['metadata']) } : {}),
253
+ };
254
+ }
255
+ /**
256
+ * Alle Belege eines Tages oder Zeitraums, Seite fuer Seite: holt mit
257
+ * [listReceipts] die erste Seite, dann mit `cursor: nextCursor` und
258
+ * demselben Zeitfenster, `order` und `view` jede weitere, und liefert jeden
259
+ * Beleg einzeln, in der Reihenfolge des Servers. Jeder Beleg des Fensters
260
+ * kommt genau einmal.
261
+ *
262
+ * Ohne `limit` holt der Helfer Seiten zu 500 (weniger Aufrufe als die
263
+ * Vorgabe 100 des Servers). Mit `cursor` setzt er an dieser Stelle fort.
264
+ *
265
+ * Ein Fehler auf irgendeiner Seite bricht ab (der Fehler kommt im
266
+ * `for await` an); die bis dahin gelieferten Belege bleiben gueltig. Nach
267
+ * [LIST_ALL_RECEIPTS_MAX_PAGES] Seiten, oder wenn der Server denselben
268
+ * Cursor zweimal nennt, bricht er mit [KasseneckValidationError]
269
+ * (`scope: 'response'`) ab, statt endlos zu laufen.
270
+ *
271
+ * `daySummary` liefert der Helfer nicht; wer sie braucht, ruft die erste
272
+ * Seite mit [listReceipts].
273
+ */
274
+ export async function* listAllReceipts(transport, options) {
275
+ // Frueh pruefen: ein Eingabefehler kommt beim ersten Schritt an, vor jedem Aufruf.
276
+ parameter(options);
277
+ const grund = { ...options, limit: options.limit ?? LIST_RECEIPTS_LIMIT_MAX };
278
+ let cursor = options.cursor;
279
+ const gesehen = new Set();
280
+ for (let seite = 1; seite <= LIST_ALL_RECEIPTS_MAX_PAGES; seite++) {
281
+ const page = await listReceipts(transport, { ...grund, cursor });
282
+ yield* page.receipts;
283
+ if (!page.hasMore)
284
+ return;
285
+ const weiter = page.nextCursor;
286
+ if (gesehen.has(weiter) || weiter === cursor)
287
+ throw antwortfehler('Server nennt denselben Cursor erneut; Abbruch statt Endlosschleife');
288
+ gesehen.add(weiter);
289
+ cursor = weiter;
290
+ }
291
+ throw antwortfehler(`mehr als ${LIST_ALL_RECEIPTS_MAX_PAGES} Seiten; Zeitfenster kleiner waehlen`);
292
+ }
@@ -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, isVoucherItem, isVoucherFloatItem, type Voucher, type VoucherArticle, type IssuedVoucher, type VoucherPayload, toVoucherPayload, fromVoucherPayload, voucherIsValid, type Receipt, type RegistrationInfo, type ReceiptPayload, type ReceiptPayloadRead, toReceiptPayload, fromReceiptPayload, receiptSubSumCents, receiptSumCents, receiptValueVoucherSign, 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, RECEIPT_OUTPUT_KINDS, type ReceiptOutputKind, RECEIPT_OUTPUT_LOG_KINDS, type ReceiptOutputLogKind, RECEIPT_OUTPUT_RESULTS, type ReceiptOutputResult, RECEIPT_OUTPUT_ENTRIES_MAX, type ReceiptOutput, type ReceiptOutputActor, RECEIPT_OUTPUT_ENTRY_ERROR_CODES, type ReceiptOutputEntryErrorCode, RECEIPT_OUTPUT_ERROR_CODES, type ReceiptOutputErrorCode, isReceiptOutputErrorCode, receiptOutputErrorCode, isReceiptOutputError, receiptOutputFieldErrors, type ReceiptOutputFieldError, type ReceiptErrorCode, type ReceiptFieldError, RECEIPT_ERROR_CODES, isReceiptErrorCode, receiptErrorCode, isReceiptError, receiptFieldErrors, remainingQuantities, TIP_REFUND_SOURCES, type TipRefundSource, isTipRefundSource, openStaffTipCents, cancellationItemsForTip, cancellationCashRefundCents, asksTipRefundSource, asksRefundTip, 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, 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, type ReceiptOutputEntry, type LogReceiptOutputsOptions, type LogReceiptOutputsResult, type RejectedReceiptOutput, logReceiptOutputs, downloadDailyReport, downloadMonthlyReport, getCashregisterReport, type CashregisterReportPeriod, 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, type ReceiptOutputEntry, type LogReceiptOutputsOptions, type LogReceiptOutputsResult, type RejectedReceiptOutput, logReceiptOutputs, downloadDailyReport, downloadMonthlyReport, getCashregisterReport, type CashregisterReportPeriod, getReportV2, type ReportV2, type ReportV2Metadata, type ReportV2Options, listReceipts, listAllReceipts, fromListReceiptsSummaryPayload, LIST_RECEIPTS_VIEWS, LIST_RECEIPTS_ORDERS, LIST_RECEIPTS_LIMIT_MAX, LIST_RECEIPTS_DAYS_MAX, LIST_ALL_RECEIPTS_MAX_PAGES, LIST_RECEIPTS_ERROR_CODES, type ListReceiptsErrorCode, type ListReceiptsView, type ListReceiptsOrder, type ListReceiptsOptions, type ListReceiptsWindow, type ListReceiptsGrossByRate, type ListReceiptsSummary, type ListReceiptsDaySummary, type ListReceiptsPage, type ListedReceipt, 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, type VoucherDueInfo, type VoucherDueArticle, type VoucherRedeemContext, voucherRedeemMaxCents, VOUCHER_ZERO_RATE_BUCKET_FROM, } 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, voucherPermsOf, } 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, isVoucherItem, isVoucherFloatItem, toVoucherPayload, fromVoucherPayload, voucherIsValid, toReceiptPayload, fromReceiptPayload, receiptSubSumCents, receiptSumCents, receiptValueVoucherSign, 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_OUTPUT_KINDS, RECEIPT_OUTPUT_LOG_KINDS, RECEIPT_OUTPUT_RESULTS, RECEIPT_OUTPUT_ENTRIES_MAX, RECEIPT_OUTPUT_ENTRY_ERROR_CODES, RECEIPT_OUTPUT_ERROR_CODES, isReceiptOutputErrorCode, receiptOutputErrorCode, isReceiptOutputError, receiptOutputFieldErrors, RECEIPT_ERROR_CODES, isReceiptErrorCode, receiptErrorCode, isReceiptError, receiptFieldErrors, remainingQuantities, TIP_REFUND_SOURCES, isTipRefundSource, openStaffTipCents, cancellationItemsForTip, cancellationCashRefundCents, asksTipRefundSource, asksRefundTip, 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, 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, logReceiptOutputs, downloadDailyReport, downloadMonthlyReport, getCashregisterReport, 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, logReceiptOutputs, downloadDailyReport, downloadMonthlyReport, getCashregisterReport, getReportV2, listReceipts, listAllReceipts, fromListReceiptsSummaryPayload, LIST_RECEIPTS_VIEWS, LIST_RECEIPTS_ORDERS, LIST_RECEIPTS_LIMIT_MAX, LIST_RECEIPTS_DAYS_MAX, LIST_ALL_RECEIPTS_MAX_PAGES, LIST_RECEIPTS_ERROR_CODES, getCashboxStatus, getSignatureStatus, createKasseneckApi, } from './client/index.js';
4
4
  export { receiptDueCents, receiptDueBreakdown, ReceiptDueError, RECEIPT_DUE_ERROR_REASONS, isReceiptDueError, voucherRedeemMaxCents, VOUCHER_ZERO_RATE_BUCKET_FROM, } 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, voucherPermsOf, } from './pos/index.js';
@@ -27,7 +27,7 @@ export type InvoiceEndpoint = (typeof INVOICE_ENDPOINTS)[number];
27
27
  * Stabile Fehlercodes. Das Fremdsystem verzweigt am Code, der Text darf sich
28
28
  * aendern. `validation` traegt zusaetzlich `errors: [{ field, message }]`.
29
29
  */
30
- 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", "language_not_allowed", "brand_not_found", "not_payable", "payment_exceeds_invoice", "tax_scheme_mismatch", "vat_rate_not_in_country", "reverse_charge_reason_required", "reverse_charge_threshold", "mixed_supply_not_allowed", "oss_not_enabled", "einvoice_unavailable", "amount_too_large", "vat_id_invalid", "vat_id_check_pending", "reservation_not_found", "reservation_mismatch", "reservation_not_active"];
30
+ 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", "language_not_allowed", "brand_not_found", "not_payable", "payment_exceeds_invoice", "tax_scheme_mismatch", "vat_rate_not_in_country", "reverse_charge_reason_required", "reverse_charge_threshold", "mixed_supply_not_allowed", "oss_not_enabled", "einvoice_unavailable", "amount_too_large", "vat_id_invalid", "vat_id_check_pending", "reservation_not_found", "reservation_mismatch", "reservation_not_active", "invoice_number_taken"];
31
31
  export type InvoiceErrorCode = (typeof INVOICE_ERROR_CODES)[number];
32
32
  /**
33
33
  * Codes, die Anmeldung und Rand auf jedem Rechnungsaufruf erzeugen koennen,
@@ -77,6 +77,8 @@ export const INVOICE_ERROR_CODES = [
77
77
  'reservation_not_found', // unbekannt oder einem anderen Konto
78
78
  'reservation_mismatch', // keine offene Position mit gleichem Artikel am Lagerstandort der Rechnung
79
79
  'reservation_not_active', // schon eingeloest oder freigegeben
80
+ // Seit 1.15.0 (Vertrag): die Rechnungsnummer ist schon vergeben (§ 11 Abs. 1 Z 3 lit. h UStG), nichts ausgestellt.
81
+ 'invoice_number_taken',
80
82
  ];
81
83
  /**
82
84
  * Codes, die Anmeldung und Rand auf jedem Rechnungsaufruf erzeugen koennen,
@@ -16,7 +16,7 @@ import { KasseneckApiError } from '../client/errors.js';
16
16
  * ...) stehen in [PAYMENT_ERROR_CODES]. Ein Code ausserhalb bleibt ueber
17
17
  * `KasseneckApiError.code` lesbar.
18
18
  */
19
- export declare const RECEIPT_ERROR_CODES: readonly ["cancellation_reference_unavailable", "cashregister_closed", "cashregister_decommissioned", "final_receipt_expired", "final_receipt_not_allowed", "module_inactive", "not_permitted", "receipt_limit_exceeded", "receipt_not_found", "receipt_outcome_unknown", "receipt_type_invalid", "server_error", "signature_incomplete", "signature_missing", "signing_failed", "small_business_vat_not_allowed", "tip_invalid", "tip_not_allowed", "tip_recipient_unknown", "validation", "voucher_balance_changed", "account_not_found", "action_confirmation_required", "admin_required", "api_not_approved", "app_check_invalid", "app_check_missing", "cashregister_not_assigned", "cashregister_not_found", "cashregister_token_invalid", "cashregister_token_missing", "dialect_mismatch", "internal_translation_error", "live_not_enabled", "method_not_allowed", "mfa_required", "not_found", "password_change_required", "register_user_no_business", "register_user_not_allowed", "register_user_not_found", "response_translation_failed", "second_factor_required", "session_expired", "session_other_cashregister", "unauthorized", "user_disabled", "user_verification_failed", "route_missing", "response_unreadable"];
19
+ export declare const RECEIPT_ERROR_CODES: readonly ["cancellation_reference_unavailable", "cashregister_closed", "cashregister_decommissioned", "final_receipt_expired", "final_receipt_not_allowed", "idempotency_conflict", "module_inactive", "not_permitted", "receipt_limit_exceeded", "receipt_not_found", "receipt_outcome_unknown", "receipt_type_invalid", "server_error", "signature_incomplete", "signature_missing", "signing_failed", "small_business_vat_not_allowed", "tip_invalid", "tip_not_allowed", "tip_recipient_unknown", "validation", "voucher_balance_changed", "account_not_found", "action_confirmation_required", "admin_required", "api_not_approved", "app_check_invalid", "app_check_missing", "cashregister_not_assigned", "cashregister_not_found", "cashregister_token_invalid", "cashregister_token_missing", "dialect_mismatch", "internal_translation_error", "live_not_enabled", "method_not_allowed", "mfa_required", "not_found", "password_change_required", "register_user_no_business", "register_user_not_allowed", "register_user_not_found", "response_translation_failed", "second_factor_required", "session_expired", "session_other_cashregister", "unauthorized", "user_disabled", "user_verification_failed", "route_missing", "response_unreadable"];
20
20
  export type ReceiptErrorCode = (typeof RECEIPT_ERROR_CODES)[number];
21
21
  export declare function isReceiptErrorCode(value: unknown): value is ReceiptErrorCode;
22
22
  /** Der Code eines geworfenen Fehlers, wenn er in [RECEIPT_ERROR_CODES] steht; sonst `undefined`. */
@@ -22,6 +22,9 @@ export const RECEIPT_ERROR_CODES = Object.freeze([
22
22
  'cashregister_decommissioned',
23
23
  'final_receipt_expired',
24
24
  'final_receipt_not_allowed',
25
+ // Seit 1.15.0 (Vertrag): derselbe idempotencyKey mit anderem Inhalt, nichts geschrieben. Der Server nimmt den
26
+ // Schluessel optional an; dieses Paket sendet (noch) keinen, der Code bleibt damit nur lesbar.
27
+ 'idempotency_conflict',
25
28
  'module_inactive',
26
29
  'not_permitted',
27
30
  'receipt_limit_exceeded',
@@ -1,5 +1,5 @@
1
1
  /** Fingerabdruck des Vertrags-Exports, aus dem diese Datei stammt (`_quelle.sha256`). */
2
- export declare const VOKABULAR_QUELLE = "328c8d0ff0f496f8f6b7d9ed78673e7666980e38586ec7efacb442e6906d898a";
2
+ export declare const VOKABULAR_QUELLE = "d11de425770bc431be9766199e4c9b3e712eb8e0eea84658f771a0f79d98e90e";
3
3
  /** Schema-Notation des Vertrags: Blatt 'aussen': 'innen', Objekt { __: 'innen', ... }, Liste [ { __: 'innen', ... } ]. */
4
4
  export type SchemaEintrag = string | SchemaObjekt | readonly [SchemaObjekt];
5
5
  export interface SchemaObjekt {
@@ -1,7 +1,7 @@
1
1
  // Erzeugt von scripts/stored-vokabular.mjs aus fixtures/v3/v3-vokabular.json.
2
2
  // Nicht von Hand aendern: test/stored.test.ts vergleicht mit dem Vertrag.
3
3
  /** Fingerabdruck des Vertrags-Exports, aus dem diese Datei stammt (`_quelle.sha256`). */
4
- export const VOKABULAR_QUELLE = "328c8d0ff0f496f8f6b7d9ed78673e7666980e38586ec7efacb442e6906d898a";
4
+ export const VOKABULAR_QUELLE = "d11de425770bc431be9766199e4c9b3e712eb8e0eea84658f771a0f79d98e90e";
5
5
  /** Schema je Endpunkt (aussen -> innen) und Wertverweise auf die Kataloge. */
6
6
  export const SCHEMAS = {
7
7
  "getReceipt": {
@@ -202,7 +202,19 @@ export const SCHEMAS = {
202
202
  "__": "gutscheine",
203
203
  "sale": "verkauf",
204
204
  "valueVoucherType": "wertArt",
205
- "vatRateBp": "satzBp"
205
+ "vatRateBp": "satzBp",
206
+ "label": {
207
+ "__": "etikett",
208
+ "size": "groesse",
209
+ "fields": {
210
+ "__": "felder",
211
+ "business": "betrieb",
212
+ "value": "wert",
213
+ "validity": "gueltigkeit",
214
+ "checkPage": "pruefseite"
215
+ },
216
+ "freeText": "freitext"
217
+ }
206
218
  }
207
219
  },
208
220
  "werte": {
@@ -4,4 +4,4 @@
4
4
  * Client-Version, Nachtrag §6). Ein Test haelt sie gleich mit `package.json`;
5
5
  * beim Anheben der Version beide Stellen aendern.
6
6
  */
7
- export declare const PACKAGE_VERSION = "1.14.0";
7
+ export declare const PACKAGE_VERSION = "1.16.0";