@kreiseck/kasseneck-api 1.14.0 → 1.15.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 +13 -0
- package/README.md +70 -2
- package/dist/cjs/client/api.d.ts +5 -0
- package/dist/cjs/client/api.js +3 -0
- package/dist/cjs/client/aufrufe.d.ts +2 -2
- package/dist/cjs/client/aufrufe.js +4 -0
- package/dist/cjs/client/index.d.ts +1 -0
- package/dist/cjs/client/index.js +12 -1
- package/dist/cjs/client/list-receipts.d.ts +211 -0
- package/dist/cjs/client/list-receipts.js +290 -0
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +11 -2
- package/dist/cjs/invoice/vertrag.d.ts +1 -1
- package/dist/cjs/invoice/vertrag.js +2 -0
- package/dist/cjs/models/receipt-errors.d.ts +1 -1
- package/dist/cjs/models/receipt-errors.js +3 -0
- package/dist/cjs/stored/vokabular.d.ts +1 -1
- package/dist/cjs/stored/vokabular.js +14 -2
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/client/api.d.ts +5 -0
- package/dist/esm/client/api.js +3 -0
- package/dist/esm/client/aufrufe.d.ts +2 -2
- package/dist/esm/client/aufrufe.js +4 -0
- package/dist/esm/client/index.d.ts +1 -0
- package/dist/esm/client/index.js +1 -0
- package/dist/esm/client/list-receipts.d.ts +211 -0
- package/dist/esm/client/list-receipts.js +284 -0
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/invoice/vertrag.d.ts +1 -1
- package/dist/esm/invoice/vertrag.js +2 -0
- package/dist/esm/models/receipt-errors.d.ts +1 -1
- package/dist/esm/models/receipt-errors.js +3 -0
- package/dist/esm/stored/vokabular.d.ts +1 -1
- package/dist/esm/stored/vokabular.js +14 -2
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/fixtures/hobex-hps-codes.json +1 -1
- package/fixtures/invoice-api.schema.json +3 -2
- package/fixtures/invoice-texts.json +1 -1
- package/fixtures/pos-texts.json +1 -1
- package/fixtures/receipt-due-voucher-generated.json +1 -1
- package/fixtures/surface.json +6 -3
- package/fixtures/v3/antworten/belege.json +1 -1
- package/fixtures/v3/antworten/belegmail.json +1 -1
- package/fixtures/v3/antworten/kasse-belege.json +1 -1
- package/fixtures/v3/antworten/kasse.json +75 -10
- package/fixtures/v3/antworten/lager.json +1 -1
- package/fixtures/v3/antworten/rechnungen.json +1 -1
- package/fixtures/v3/antworten/storno.json +1 -1
- package/fixtures/v3/stored/belege.json +1 -1
- package/fixtures/v3/stored/kasse.json +151 -381
- package/fixtures/v3/stored/rechnungen.json +142 -2
- package/fixtures/v3/v3-vokabular.json +89 -11
- package/fixtures/v3/zahlbetrag-faelle.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,211 @@
|
|
|
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 { InternerTransport } from './aufrufe.js';
|
|
4
|
+
/**
|
|
5
|
+
* Belege einer Kasse auflisten (`listReceipts`, nur unter `/v3`): ein Tag oder
|
|
6
|
+
* ein Zeitraum von hoechstens 31 Kalendertagen, Seite fuer Seite ueber einen
|
|
7
|
+
* undurchsichtigen Cursor. Nachfolger von `getReportV2` fuer Listen;
|
|
8
|
+
* `getReportV2` bleibt fuer Berichte.
|
|
9
|
+
*
|
|
10
|
+
* **Anmeldung wie `getReportV2`:** API-Schluessel plus `cashregister-token`
|
|
11
|
+
* (`apiKeyAuth`); die Kasse kommt aus dem Token, nie aus einem Parameter.
|
|
12
|
+
* Kassen-Bediener (Geraet + PIN) weist der Server ab; die Kasse hat dafuer
|
|
13
|
+
* `listMyReceipts` am Kassenweg. Dieses Paket bildet das nicht nach, wer darf,
|
|
14
|
+
* entscheidet allein das Backend.
|
|
15
|
+
*
|
|
16
|
+
* Zeiten sind die **Wiener Wanduhr** als Text, wie `timeStamp` am Beleg; der
|
|
17
|
+
* Server vergleicht sie als Text. Ein Tag ist ein Kalendertag, auch an den
|
|
18
|
+
* Tagen der Zeitumstellung, und die Grenze von 31 Tagen zaehlt Kalendertage,
|
|
19
|
+
* nicht 31 x 24 Stunden. Die Pruefung hier rechnet darum ohne Zeitzone, genau
|
|
20
|
+
* wie der Server (`beleg-liste-core.js`).
|
|
21
|
+
*/
|
|
22
|
+
/** Ansicht einer Seite: `summary` eine schlanke Zeile je Beleg, `full` das gespeicherte Belegdokument. */
|
|
23
|
+
export declare const LIST_RECEIPTS_VIEWS: readonly ["summary", "full"];
|
|
24
|
+
export type ListReceiptsView = (typeof LIST_RECEIPTS_VIEWS)[number];
|
|
25
|
+
/** Reihenfolge: `desc` neueste zuerst (Vorgabe des Servers), `asc` aelteste zuerst. */
|
|
26
|
+
export declare const LIST_RECEIPTS_ORDERS: readonly ["desc", "asc"];
|
|
27
|
+
export type ListReceiptsOrder = (typeof LIST_RECEIPTS_ORDERS)[number];
|
|
28
|
+
/** Groesste Seite, die der Server liefert (`limit`); ohne Angabe nimmt er 100. */
|
|
29
|
+
export declare const LIST_RECEIPTS_LIMIT_MAX = 500;
|
|
30
|
+
/** Laengster Zeitraum in Kalendertagen (`to` hoechstens `from` + 31 Tage). */
|
|
31
|
+
export declare const LIST_RECEIPTS_DAYS_MAX = 31;
|
|
32
|
+
/**
|
|
33
|
+
* So viele Seiten holt [listAllReceipts] hoechstens, dann bricht er mit
|
|
34
|
+
* Fehler ab. Schutz gegen einen Cursor, der nie endet; mit der Seitengroesse
|
|
35
|
+
* des Helfers (500) sind das 50.000 Belege, mehr als jede Kasse in 31 Tagen
|
|
36
|
+
* ausstellt.
|
|
37
|
+
*/
|
|
38
|
+
export declare const LIST_ALL_RECEIPTS_MAX_PAGES = 100;
|
|
39
|
+
/**
|
|
40
|
+
* Fehlercodes von `listReceipts` (`code` des [KasseneckApiError]), dazu die
|
|
41
|
+
* gemeinsamen Codes von Anmeldung und Rand (Kassen-Token, Live-Gate,
|
|
42
|
+
* API-Freigabe). Ein Code ausserhalb bleibt ueber `KasseneckApiError.code`
|
|
43
|
+
* lesbar. Die Regeln der ersten sieben prueft dieses Paket schon vor dem
|
|
44
|
+
* Senden (ausser `invalid_cursor`: ob ein Cursor zur Abfrage passt, weiss nur
|
|
45
|
+
* der Server).
|
|
46
|
+
*/
|
|
47
|
+
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"];
|
|
48
|
+
export type ListReceiptsErrorCode = (typeof LIST_RECEIPTS_ERROR_CODES)[number];
|
|
49
|
+
/**
|
|
50
|
+
* Eingabe von [listReceipts]. Genau eine Form des Zeitfensters: `date` ODER
|
|
51
|
+
* `from` + `to`.
|
|
52
|
+
*
|
|
53
|
+
* - `date`: ein Wiener Tag, `YYYY-MM-DD` (00:00:00 bis zum Beginn des
|
|
54
|
+
* Folgetags). Nur mit `date` traegt die erste Seite `daySummary`.
|
|
55
|
+
* - `from` (einschliesslich) und `to` (ausschliesslich): `YYYY-MM-DD` oder
|
|
56
|
+
* `YYYY-MM-DDTHH:mm:ss`, Wiener Wanduhr ohne Zone. Ein reines Datum heisst
|
|
57
|
+
* Beginn dieses Tages; `to` liegt hoechstens 31 Kalendertage nach `from`.
|
|
58
|
+
*
|
|
59
|
+
* Mit `cursor` (dem `nextCursor` der Vorseite) muessen Zeitfenster, `order`
|
|
60
|
+
* und `view` gleich bleiben wie auf Seite 1, sonst antwortet der Server
|
|
61
|
+
* `invalid_cursor`; `limit` darf sich aendern.
|
|
62
|
+
*/
|
|
63
|
+
export type ListReceiptsOptions<V extends ListReceiptsView = ListReceiptsView> = ListReceiptsWindow & {
|
|
64
|
+
/** Seitengroesse, ganze Zahl 1-500; ohne Angabe 100. */
|
|
65
|
+
limit?: number;
|
|
66
|
+
/** Ohne Angabe `desc` (neueste zuerst). */
|
|
67
|
+
order?: ListReceiptsOrder;
|
|
68
|
+
/** Ohne Angabe `summary`. */
|
|
69
|
+
view?: V;
|
|
70
|
+
/** `nextCursor` der vorigen Seite. */
|
|
71
|
+
cursor?: string;
|
|
72
|
+
};
|
|
73
|
+
/** Zeitfenster von [ListReceiptsOptions]: ein Tag oder ein Zeitraum. */
|
|
74
|
+
export type ListReceiptsWindow = {
|
|
75
|
+
date: string;
|
|
76
|
+
from?: undefined;
|
|
77
|
+
to?: undefined;
|
|
78
|
+
} | {
|
|
79
|
+
from: string;
|
|
80
|
+
to: string;
|
|
81
|
+
date?: undefined;
|
|
82
|
+
};
|
|
83
|
+
/** Brutto je RKSV-Satzgruppe in Cent (`amountRateStandard` bis `amountRateSpecial` am Beleg). */
|
|
84
|
+
export interface ListReceiptsGrossByRate {
|
|
85
|
+
standard: number;
|
|
86
|
+
reduced1: number;
|
|
87
|
+
reduced2: number;
|
|
88
|
+
zero: number;
|
|
89
|
+
special: number;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Zeile eines Belegs in [listReceipts] mit `view: 'summary'`. Betraege in
|
|
93
|
+
* ganzen Cent. Kein Layout, kein Kopf, keine Positionen und keine
|
|
94
|
+
* Pruefangaben: fuer die Detailansicht `getReceipt`, fuer die PDF
|
|
95
|
+
* `downloadReceipt` mit `fullReceiptId`.
|
|
96
|
+
*
|
|
97
|
+
* Nicht zu verwechseln mit [ReceiptSummary] von `listMyReceipts` (Kassenweg,
|
|
98
|
+
* andere Felder, Betrag dort aus Euro gerechnet).
|
|
99
|
+
*
|
|
100
|
+
* `receiptType` und `paymentMethod` sind wie ueberall beim Lesen der bekannte
|
|
101
|
+
* Enum-Eintrag oder der rohe Schluessel; ein Wert, den dieses Paket nicht
|
|
102
|
+
* kennt, laesst die Liste nicht scheitern.
|
|
103
|
+
*/
|
|
104
|
+
export interface ListReceiptsSummary {
|
|
105
|
+
receiptId: string | null;
|
|
106
|
+
/** Fortlaufender Belegzaehler der Kasse; `null` bei Alt-Belegen. */
|
|
107
|
+
counter: number | null;
|
|
108
|
+
receiptType: ReceiptType | string | null;
|
|
109
|
+
/** Nur am Nullbeleg: Anlass (`manual`, wenn der Beleg keinen nennt); sonst `null`. */
|
|
110
|
+
zeroKind: ZeroKind | string | null;
|
|
111
|
+
/** Roher Belegzeitstempel (Wiener Wanduhr); Deutung ueber `parseServerTimeStamp`. */
|
|
112
|
+
timeStamp: string | null;
|
|
113
|
+
/** Summe von `grossByRateCents`; negativ am Storno-Beleg. */
|
|
114
|
+
totalCents: number;
|
|
115
|
+
grossByRateCents: ListReceiptsGrossByRate;
|
|
116
|
+
/** `mixed` bei mehreren Zahlungen (die stehen dann in `payments`). */
|
|
117
|
+
paymentMethod: KeckPaymentMethod | string | null;
|
|
118
|
+
/** Nur wenn der Beleg eine Zahlungsliste traegt; ohne Anbieterdaten. */
|
|
119
|
+
payments?: ReceiptPayment[];
|
|
120
|
+
/** Nur wenn der Beleg Trinkgeld traegt. */
|
|
121
|
+
tipCents?: number;
|
|
122
|
+
/** Bediener (nur der Name), oder `null`. */
|
|
123
|
+
operator: {
|
|
124
|
+
name: string;
|
|
125
|
+
} | null;
|
|
126
|
+
/** Nur am Storno-Beleg: das Original. */
|
|
127
|
+
cancellationOf: {
|
|
128
|
+
receiptId: string | null;
|
|
129
|
+
timeStamp: string | null;
|
|
130
|
+
} | null;
|
|
131
|
+
cancellationReason: CancellationReason | string | null;
|
|
132
|
+
/**
|
|
133
|
+
* Storno-Stand: `none`, `partial` oder `full` (nur an Normalbelegen anders
|
|
134
|
+
* als `none`). Ein Wert, den dieses Paket nicht kennt, kommt als
|
|
135
|
+
* `'unknown'` an, nie still als `none`: dann keinen Storno anbieten, bis
|
|
136
|
+
* der Beleg einzeln gelesen ist.
|
|
137
|
+
*/
|
|
138
|
+
cancellationStatus: CancellationStatus | 'unknown';
|
|
139
|
+
/** Mit funktionierender Signatureinheit ausgestellt (`signatureSuccess !== false`). */
|
|
140
|
+
signatureOk: boolean;
|
|
141
|
+
/** Eigene Referenz des Aufrufers am Beleg, oder `null`. */
|
|
142
|
+
customProjectId: string | null;
|
|
143
|
+
/** Schluessel fuer `downloadReceipt` und den Beleg-Link, oder `null`. */
|
|
144
|
+
fullReceiptId: string | null;
|
|
145
|
+
}
|
|
146
|
+
/** Ein Beleg der Liste je Ansicht: `full` das Belegdokument wie bei `getReportV2`, sonst die Zeile. */
|
|
147
|
+
export type ListedReceipt<V extends ListReceiptsView = 'summary'> = V extends 'full' ? Receipt : ListReceiptsSummary;
|
|
148
|
+
/**
|
|
149
|
+
* Tagessumme aus der Tagesstatistik der Kasse, nur bei `date` und nur auf
|
|
150
|
+
* der ersten Seite. **Nicht die Summe der Liste:** `receiptCount` zaehlt jeden
|
|
151
|
+
* Beleg des Tages (auch Null-, Start- und Trainingsbelege), `revenueCents`
|
|
152
|
+
* nur Normal- und Storno-Belege, ohne Mitarbeiter-Trinkgeld und nach
|
|
153
|
+
* Aktionsrabatt. Wer die Liste summieren will, summiert die Liste.
|
|
154
|
+
*/
|
|
155
|
+
export interface ListReceiptsDaySummary {
|
|
156
|
+
date: string;
|
|
157
|
+
receiptCount: number;
|
|
158
|
+
revenueCents: number;
|
|
159
|
+
/** Je Steuersatz (Basispunkte, 2000 = 20 %), hoechster zuerst; Saetze ohne Umsatz fehlen. */
|
|
160
|
+
revenueByRate: Array<{
|
|
161
|
+
rateBp: number;
|
|
162
|
+
grossCents: number;
|
|
163
|
+
}>;
|
|
164
|
+
}
|
|
165
|
+
/** Eine Seite von [listReceipts]. */
|
|
166
|
+
export interface ListReceiptsPage<V extends ListReceiptsView = 'summary'> {
|
|
167
|
+
receipts: Array<ListedReceipt<V>>;
|
|
168
|
+
/** Es gibt weitere Belege: mit `cursor: nextCursor` weiterlesen. */
|
|
169
|
+
hasMore: boolean;
|
|
170
|
+
/** `null`, wenn `hasMore` false ist. */
|
|
171
|
+
nextCursor: string | null;
|
|
172
|
+
/**
|
|
173
|
+
* Nur bei `date` auf der ersten Seite (ohne `cursor`); `null`, wenn es fuer
|
|
174
|
+
* den Tag keine Statistik gibt. Auf allen anderen Seiten fehlt das Feld.
|
|
175
|
+
*/
|
|
176
|
+
daySummary?: ListReceiptsDaySummary | null;
|
|
177
|
+
}
|
|
178
|
+
/** Zeile `view: summary` vom Draht. */
|
|
179
|
+
export declare function fromListReceiptsSummaryPayload(payload: Record<string, unknown>): ListReceiptsSummary;
|
|
180
|
+
/**
|
|
181
|
+
* Eine Seite Belege der angemeldeten Kasse (`listReceipts`). Die Eingabe wird
|
|
182
|
+
* vor dem Senden nach den Regeln des Servers geprueft (genau eine Form des
|
|
183
|
+
* Zeitfensters, Datumsformat, hoechstens 31 Kalendertage, `limit` 1-500,
|
|
184
|
+
* `order`, `view`); ein Verstoss wirft [KasseneckValidationError] mit
|
|
185
|
+
* `scope: 'request'`, ohne dass etwas hinausgeht.
|
|
186
|
+
*
|
|
187
|
+
* Mit `view: 'full'` sind die Belege das gespeicherte Belegdokument
|
|
188
|
+
* ([Receipt], dieselbe Form wie `getReportV2`), sonst [ListReceiptsSummary].
|
|
189
|
+
* Alle Seiten auf einmal: [listAllReceipts].
|
|
190
|
+
*/
|
|
191
|
+
export declare function listReceipts<V extends ListReceiptsView = 'summary'>(transport: InternerTransport, options: ListReceiptsOptions<V>): Promise<ListReceiptsPage<V>>;
|
|
192
|
+
/**
|
|
193
|
+
* Alle Belege eines Tages oder Zeitraums, Seite fuer Seite: holt mit
|
|
194
|
+
* [listReceipts] die erste Seite, dann mit `cursor: nextCursor` und
|
|
195
|
+
* demselben Zeitfenster, `order` und `view` jede weitere, und liefert jeden
|
|
196
|
+
* Beleg einzeln, in der Reihenfolge des Servers. Jeder Beleg des Fensters
|
|
197
|
+
* kommt genau einmal.
|
|
198
|
+
*
|
|
199
|
+
* Ohne `limit` holt der Helfer Seiten zu 500 (weniger Aufrufe als die
|
|
200
|
+
* Vorgabe 100 des Servers). Mit `cursor` setzt er an dieser Stelle fort.
|
|
201
|
+
*
|
|
202
|
+
* Ein Fehler auf irgendeiner Seite bricht ab (der Fehler kommt im
|
|
203
|
+
* `for await` an); die bis dahin gelieferten Belege bleiben gueltig. Nach
|
|
204
|
+
* [LIST_ALL_RECEIPTS_MAX_PAGES] Seiten, oder wenn der Server denselben
|
|
205
|
+
* Cursor zweimal nennt, bricht er mit [KasseneckValidationError]
|
|
206
|
+
* (`scope: 'response'`) ab, statt endlos zu laufen.
|
|
207
|
+
*
|
|
208
|
+
* `daySummary` liefert der Helfer nicht; wer sie braucht, ruft die erste
|
|
209
|
+
* Seite mit [listReceipts].
|
|
210
|
+
*/
|
|
211
|
+
export declare function listAllReceipts<V extends ListReceiptsView = 'summary'>(transport: InternerTransport, options: ListReceiptsOptions<V>): AsyncGenerator<ListedReceipt<V>, void, undefined>;
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { KeckPaymentMethod, ReceiptType } from '../enums/index.js';
|
|
2
|
+
import { CANCELLATION_STATUSES, 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
|
+
/**
|
|
210
|
+
* Eine Seite Belege der angemeldeten Kasse (`listReceipts`). Die Eingabe wird
|
|
211
|
+
* vor dem Senden nach den Regeln des Servers geprueft (genau eine Form des
|
|
212
|
+
* Zeitfensters, Datumsformat, hoechstens 31 Kalendertage, `limit` 1-500,
|
|
213
|
+
* `order`, `view`); ein Verstoss wirft [KasseneckValidationError] mit
|
|
214
|
+
* `scope: 'request'`, ohne dass etwas hinausgeht.
|
|
215
|
+
*
|
|
216
|
+
* Mit `view: 'full'` sind die Belege das gespeicherte Belegdokument
|
|
217
|
+
* ([Receipt], dieselbe Form wie `getReportV2`), sonst [ListReceiptsSummary].
|
|
218
|
+
* Alle Seiten auf einmal: [listAllReceipts].
|
|
219
|
+
*/
|
|
220
|
+
export async function listReceipts(transport, options) {
|
|
221
|
+
const params = parameter(options);
|
|
222
|
+
const voll = params['view'] === 'full';
|
|
223
|
+
const daten = await transport('listReceipts', params);
|
|
224
|
+
if (!istObjekt(daten))
|
|
225
|
+
throw antwortfehler('Antwort enthaelt keine Daten (data fehlt)');
|
|
226
|
+
const liste = daten['receipts'];
|
|
227
|
+
if (!Array.isArray(liste) || liste.some((b) => !istObjekt(b))) {
|
|
228
|
+
throw antwortfehler('Antwort enthaelt keine Belegliste (data.receipts fehlt)');
|
|
229
|
+
}
|
|
230
|
+
if (typeof daten['hasMore'] !== 'boolean')
|
|
231
|
+
throw antwortfehler('Antwort ohne hasMore');
|
|
232
|
+
const weiter = daten['nextCursor'];
|
|
233
|
+
// Ein `hasMore` ohne Cursor liesse den Aufrufer ratlos (oder einen Blaetterer im Kreis laufen).
|
|
234
|
+
if (daten['hasMore'] ? typeof weiter !== 'string' || weiter === '' : weiter !== null) {
|
|
235
|
+
throw antwortfehler('nextCursor passt nicht zu hasMore (Text bei hasMore, sonst null)');
|
|
236
|
+
}
|
|
237
|
+
const receipts = (voll
|
|
238
|
+
? liste.map((b) => fromReceiptPayload(b))
|
|
239
|
+
: liste.map((b) => fromListReceiptsSummaryPayload(b)));
|
|
240
|
+
return {
|
|
241
|
+
receipts,
|
|
242
|
+
hasMore: daten['hasMore'],
|
|
243
|
+
nextCursor: daten['hasMore'] ? weiter : null,
|
|
244
|
+
...('daySummary' in daten ? { daySummary: tagessumme(daten['daySummary']) } : {}),
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Alle Belege eines Tages oder Zeitraums, Seite fuer Seite: holt mit
|
|
249
|
+
* [listReceipts] die erste Seite, dann mit `cursor: nextCursor` und
|
|
250
|
+
* demselben Zeitfenster, `order` und `view` jede weitere, und liefert jeden
|
|
251
|
+
* Beleg einzeln, in der Reihenfolge des Servers. Jeder Beleg des Fensters
|
|
252
|
+
* kommt genau einmal.
|
|
253
|
+
*
|
|
254
|
+
* Ohne `limit` holt der Helfer Seiten zu 500 (weniger Aufrufe als die
|
|
255
|
+
* Vorgabe 100 des Servers). Mit `cursor` setzt er an dieser Stelle fort.
|
|
256
|
+
*
|
|
257
|
+
* Ein Fehler auf irgendeiner Seite bricht ab (der Fehler kommt im
|
|
258
|
+
* `for await` an); die bis dahin gelieferten Belege bleiben gueltig. Nach
|
|
259
|
+
* [LIST_ALL_RECEIPTS_MAX_PAGES] Seiten, oder wenn der Server denselben
|
|
260
|
+
* Cursor zweimal nennt, bricht er mit [KasseneckValidationError]
|
|
261
|
+
* (`scope: 'response'`) ab, statt endlos zu laufen.
|
|
262
|
+
*
|
|
263
|
+
* `daySummary` liefert der Helfer nicht; wer sie braucht, ruft die erste
|
|
264
|
+
* Seite mit [listReceipts].
|
|
265
|
+
*/
|
|
266
|
+
export async function* listAllReceipts(transport, options) {
|
|
267
|
+
// Frueh pruefen: ein Eingabefehler kommt beim ersten Schritt an, vor jedem Aufruf.
|
|
268
|
+
parameter(options);
|
|
269
|
+
const grund = { ...options, limit: options.limit ?? LIST_RECEIPTS_LIMIT_MAX };
|
|
270
|
+
let cursor = options.cursor;
|
|
271
|
+
const gesehen = new Set();
|
|
272
|
+
for (let seite = 1; seite <= LIST_ALL_RECEIPTS_MAX_PAGES; seite++) {
|
|
273
|
+
const page = await listReceipts(transport, { ...grund, cursor });
|
|
274
|
+
yield* page.receipts;
|
|
275
|
+
if (!page.hasMore)
|
|
276
|
+
return;
|
|
277
|
+
const weiter = page.nextCursor;
|
|
278
|
+
if (gesehen.has(weiter) || weiter === cursor)
|
|
279
|
+
throw antwortfehler('Server nennt denselben Cursor erneut; Abbruch statt Endlosschleife');
|
|
280
|
+
gesehen.add(weiter);
|
|
281
|
+
cursor = weiter;
|
|
282
|
+
}
|
|
283
|
+
throw antwortfehler(`mehr als ${LIST_ALL_RECEIPTS_MAX_PAGES} Seiten; Zeitfenster kleiner waehlen`);
|
|
284
|
+
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -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 = "
|
|
2
|
+
export declare const VOKABULAR_QUELLE = "c64430e6ec3c3dad8674ad684b353bf52c57df54da8afbaa6ba7d8f717511eb7";
|
|
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 = "
|
|
4
|
+
export const VOKABULAR_QUELLE = "c64430e6ec3c3dad8674ad684b353bf52c57df54da8afbaa6ba7d8f717511eb7";
|
|
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": {
|
package/dist/esm/version.d.ts
CHANGED
package/dist/esm/version.js
CHANGED