@kreiseck/kasseneck-api 1.27.0 → 1.28.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 +16 -0
- package/dist/cjs/client/aufrufe.d.ts +3 -3
- package/dist/cjs/client/aufrufe.js +3 -0
- package/dist/cjs/pos/aufrunden.d.ts +6 -0
- package/dist/cjs/pos/aufrunden.js +59 -0
- package/dist/cjs/pos/client.js +12 -1
- package/dist/cjs/pos/index.d.ts +4 -3
- package/dist/cjs/pos/index.js +17 -4
- package/dist/cjs/pos/schicht-lesen.d.ts +2 -1
- package/dist/cjs/pos/schicht-lesen.js +48 -1
- package/dist/cjs/pos/schicht-typen.d.ts +106 -3
- package/dist/cjs/pos/schicht-typen.js +14 -4
- package/dist/cjs/pos/schicht.d.ts +28 -2
- package/dist/cjs/pos/schicht.js +19 -0
- package/dist/cjs/pos/settings.d.ts +39 -0
- package/dist/cjs/pos/settings.js +65 -4
- package/dist/cjs/pos/texte.d.ts +292 -0
- package/dist/cjs/pos/texte.js +108 -0
- package/dist/cjs/receipt/shift-sheet.js +29 -0
- package/dist/cjs/stored/einstellungen.js +31 -4
- package/dist/cjs/stored/vokabular.d.ts +1 -1
- package/dist/cjs/stored/vokabular.js +29 -2
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/client/aufrufe.d.ts +3 -3
- package/dist/esm/client/aufrufe.js +3 -0
- package/dist/esm/pos/aufrunden.d.ts +6 -0
- package/dist/esm/pos/aufrunden.js +56 -0
- package/dist/esm/pos/client.js +13 -2
- package/dist/esm/pos/index.d.ts +4 -3
- package/dist/esm/pos/index.js +5 -4
- package/dist/esm/pos/schicht-lesen.d.ts +2 -1
- package/dist/esm/pos/schicht-lesen.js +47 -1
- package/dist/esm/pos/schicht-typen.d.ts +106 -3
- package/dist/esm/pos/schicht-typen.js +13 -3
- package/dist/esm/pos/schicht.d.ts +28 -2
- package/dist/esm/pos/schicht.js +19 -1
- package/dist/esm/pos/settings.d.ts +39 -0
- package/dist/esm/pos/settings.js +60 -3
- package/dist/esm/pos/texte.d.ts +292 -0
- package/dist/esm/pos/texte.js +108 -0
- package/dist/esm/receipt/shift-sheet.js +29 -0
- package/dist/esm/stored/einstellungen.js +32 -5
- package/dist/esm/stored/vokabular.d.ts +1 -1
- package/dist/esm/stored/vokabular.js +29 -2
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/fixtures/duplicate-cases.json +6 -0
- package/fixtures/expected/duplicate.shift-close.hex +28 -27
- package/fixtures/expected/shift-close-blind.grid32.txt +1 -0
- package/fixtures/expected/shift-close-blind.grid48.txt +1 -0
- package/fixtures/expected/shift-close-blind.lines.json +6 -0
- package/fixtures/expected/shift-close-put-in.grid32.txt +1 -0
- package/fixtures/expected/shift-close-put-in.grid48.txt +1 -0
- package/fixtures/expected/shift-close-put-in.lines.json +6 -0
- package/fixtures/expected/shift-close-take-out.grid32.txt +1 -0
- package/fixtures/expected/shift-close-take-out.grid48.txt +1 -0
- package/fixtures/expected/shift-close-take-out.lines.json +6 -0
- package/fixtures/expected/shift-close.grid32.txt +1 -0
- package/fixtures/expected/shift-close.grid48.txt +1 -0
- package/fixtures/expected/shift-close.lines.json +6 -0
- package/fixtures/expected/shift-interim.grid32.txt +1 -0
- package/fixtures/expected/shift-interim.grid48.txt +1 -0
- package/fixtures/expected/shift-interim.lines.json +6 -0
- package/fixtures/hobex-hps-codes.json +1 -1
- package/fixtures/invoice-api.schema.json +1 -1
- package/fixtures/invoice-texts.json +1 -1
- package/fixtures/pos-texts.json +337 -1
- package/fixtures/renames-1.0.json +30 -0
- package/fixtures/shift-ablauf-cases.json +182 -0
- package/fixtures/shift-receipts.json +15 -15
- package/fixtures/surface.json +41 -2
- package/fixtures/tip-round-up-cases.json +27 -0
- package/fixtures/v3/antworten/belege.json +2 -2
- package/fixtures/v3/antworten/belegmail.json +2 -2
- package/fixtures/v3/antworten/berichte.json +2 -2
- package/fixtures/v3/antworten/kasse-belege.json +2 -2
- package/fixtures/v3/antworten/kasse.json +504 -4
- package/fixtures/v3/antworten/lager.json +1 -1
- package/fixtures/v3/antworten/rechnungen.json +2 -2
- package/fixtures/v3/antworten/storno.json +2 -2
- package/fixtures/v3/stored/belege.json +2 -2
- package/fixtures/v3/stored/kasse.json +520 -12
- package/fixtures/v3/stored/rechnungen.json +2 -2
- package/fixtures/v3/v3-vokabular.json +131 -9
- package/fixtures/v3/zahlbetrag-faelle.json +2 -2
- package/package.json +1 -1
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* stehen im Modell genau dann, wenn der Server sie sendet.
|
|
13
13
|
*/
|
|
14
14
|
import { type ValidationScope } from '../client/errors.js';
|
|
15
|
-
import type { CashMovement, CashMovementReceipt, CashMovementResult, DrawerOpeningsResult, OpenShiftResult, ShiftReport, CloseShiftResult, DrawerState, Shift, ShiftSummaryReceipt } from './schicht-typen.js';
|
|
15
|
+
import type { CashMovement, CashMovementReceipt, CashMovementResult, DrawerOpeningsResult, OpenShiftResult, ShiftReport, CloseShiftResult, ShiftCountResult, DrawerState, Shift, ShiftSummaryReceipt } from './schicht-typen.js';
|
|
16
16
|
type Roh = Record<string, unknown>;
|
|
17
17
|
/** Wer liest (fuer die Meldung) und wo im Rumpf. */
|
|
18
18
|
export interface Ort {
|
|
@@ -33,6 +33,7 @@ export declare function schichtBon(ort: Ort, w: unknown): ShiftSummaryReceipt;
|
|
|
33
33
|
export declare function bewegungsBon(ort: Ort, w: unknown): CashMovementReceipt;
|
|
34
34
|
export declare function abschluss(ort: Ort, w: unknown): CloseShiftResult;
|
|
35
35
|
export declare function geoeffnet(ort: Ort, w: unknown): OpenShiftResult;
|
|
36
|
+
export declare function gezaehlt(ort: Ort, w: unknown): ShiftCountResult;
|
|
36
37
|
export declare function gebucht(ort: Ort, w: unknown): CashMovementResult;
|
|
37
38
|
export declare function gemeldet(ort: Ort, w: unknown): DrawerOpeningsResult;
|
|
38
39
|
export declare function bericht(ort: Ort, w: unknown): ShiftReport;
|
|
@@ -117,7 +117,7 @@ function trinkgeldMitOffen(ort, w) {
|
|
|
117
117
|
}
|
|
118
118
|
function laufstand(ort, w) {
|
|
119
119
|
const o = pflichtObjekt(ort, w);
|
|
120
|
-
|
|
120
|
+
const raus = {
|
|
121
121
|
cashSalesCents: ganzzahl(ort, o, 'cashSalesCents'),
|
|
122
122
|
cashCancellationsCents: ganzzahl(ort, o, 'cashCancellationsCents'),
|
|
123
123
|
nonCashByMethod: liste(ort, o, 'nonCashByMethod', unbar),
|
|
@@ -130,6 +130,16 @@ function laufstand(ort, w) {
|
|
|
130
130
|
tips: liste(ort, o, 'tips', trinkgeld),
|
|
131
131
|
openingsWithoutSale: ganzzahl(ort, o, 'openingsWithoutSale'),
|
|
132
132
|
};
|
|
133
|
+
// Nur Anzeige (1.28.0); der Server sendet beides nur, wenn es etwas gibt -- gelesen wie gesendet.
|
|
134
|
+
if (o.ownerTips !== undefined && o.ownerTips !== null)
|
|
135
|
+
raus.ownerTips = liste(ort, o, 'ownerTips', inhaberTrinkgeld);
|
|
136
|
+
if (o.unassignedTipCents !== undefined && o.unassignedTipCents !== null)
|
|
137
|
+
raus.unassignedTipCents = ganzzahl(ort, o, 'unassignedTipCents');
|
|
138
|
+
return raus;
|
|
139
|
+
}
|
|
140
|
+
function inhaberTrinkgeld(ort, w) {
|
|
141
|
+
const o = pflichtObjekt(ort, w);
|
|
142
|
+
return { registerUserId: kennung(ort, o, 'registerUserId'), name: text(o.name), cents: ganzzahl(ort, o, 'cents') };
|
|
133
143
|
}
|
|
134
144
|
/** Entnehmen oder Einlegen nach dem Zaehlen; die Art bleibt offen fuer kuenftige Werte (Text). */
|
|
135
145
|
function nachZaehlung(ort, w) {
|
|
@@ -152,6 +162,14 @@ function abgleich(ort, w) {
|
|
|
152
162
|
}
|
|
153
163
|
return { matches: wahr(ort, o, 'matches'), deviations };
|
|
154
164
|
}
|
|
165
|
+
function sollTeil(ort, w) {
|
|
166
|
+
const o = pflichtObjekt(ort, w);
|
|
167
|
+
return { key: kennung(ort, o, 'key'), cents: ganzzahl(ort, o, 'cents') };
|
|
168
|
+
}
|
|
169
|
+
function differenzTeil(ort, w) {
|
|
170
|
+
const o = pflichtObjekt(ort, w);
|
|
171
|
+
return { type: kennung(ort, o, 'type'), cents: ganzzahl(ort, o, 'cents'), at: text(o.at) };
|
|
172
|
+
}
|
|
155
173
|
/** Eine Schicht; was nur mit `cashView` kommt, steht nur, wenn gesendet. */
|
|
156
174
|
export function schicht(ort, w) {
|
|
157
175
|
const o = pflichtObjekt(ort, w);
|
|
@@ -187,6 +205,14 @@ export function schicht(ort, w) {
|
|
|
187
205
|
// Nur wenn beim Abschluss Geld entnommen oder eingelegt wurde.
|
|
188
206
|
wennWert(r, o, 'afterCount', () => nachZaehlung(unter(ort, 'afterCount'), o.afterCount));
|
|
189
207
|
wennWert(r, o, 'leftInDrawerCents', () => ganzzahl(ort, o, 'leftInDrawerCents'));
|
|
208
|
+
// Ablauf der Kasse: nur, wenn der Server sie sendet.
|
|
209
|
+
wennWert(r, o, 'openingCounted', () => wahr(ort, o, 'openingCounted'));
|
|
210
|
+
wennWert(r, o, 'expectedParts', () => liste(ort, o, 'expectedParts', sollTeil));
|
|
211
|
+
wennWert(r, o, 'cashTipsInDrawerCents', () => ganzzahl(ort, o, 'cashTipsInDrawerCents'));
|
|
212
|
+
wennWert(r, o, 'interimCounts', () => ganzzahl(ort, o, 'interimCounts'));
|
|
213
|
+
wennWert(r, o, 'interimDifferenceCents', () => ganzzahl(ort, o, 'interimDifferenceCents'));
|
|
214
|
+
wennWert(r, o, 'differenceParts', () => liste(ort, o, 'differenceParts', differenzTeil));
|
|
215
|
+
wennWert(r, o, 'countedBeforePayoutCents', () => ganzzahl(ort, o, 'countedBeforePayoutCents'));
|
|
190
216
|
return raus;
|
|
191
217
|
}
|
|
192
218
|
function schichtOderNull(ort, w) {
|
|
@@ -207,6 +233,12 @@ function oeffnung(ort, w) {
|
|
|
207
233
|
ok: wahr(ort, o, 'ok'),
|
|
208
234
|
};
|
|
209
235
|
}
|
|
236
|
+
function letzteSchicht(ort, w) {
|
|
237
|
+
if (w === null)
|
|
238
|
+
return null;
|
|
239
|
+
const o = pflichtObjekt(ort, w);
|
|
240
|
+
return { number: ganzzahl(ort, o, 'number'), closedAt: kennung(ort, o, 'closedAt'), closedByName: text(o.closedByName) };
|
|
241
|
+
}
|
|
210
242
|
export function ladeStand(ort, w) {
|
|
211
243
|
const o = pflichtObjekt(ort, w);
|
|
212
244
|
const lade = pflichtObjekt(unter(ort, 'drawer'), o.drawer);
|
|
@@ -236,6 +268,8 @@ export function ladeStand(ort, w) {
|
|
|
236
268
|
wennDa(r, o, 'expectedCents', () => ganzzahlOderNull(ort, o, 'expectedCents'));
|
|
237
269
|
wennDa(r, o, 'recentOpenings', () => liste(ort, o, 'recentOpenings', oeffnung));
|
|
238
270
|
wennWert(r, o, 'suggestedFromShiftNumber', () => ganzzahl(ort, o, 'suggestedFromShiftNumber'));
|
|
271
|
+
// Letzte Schicht der Lade: `null` ist eine Aussage („keine“), darum bleibt es stehen.
|
|
272
|
+
wennDa(r, o, 'lastShift', () => (o.lastShift === undefined ? null : letzteSchicht(unter(ort, 'lastShift'), o.lastShift)));
|
|
239
273
|
// Wechselgeld der Lade: nur wenn eingestellt.
|
|
240
274
|
wennWert(raus.drawer, lade, 'changeFloatCents', () => ganzzahl(ladeOrt, lade, 'changeFloatCents'));
|
|
241
275
|
return raus;
|
|
@@ -322,6 +356,12 @@ export function schichtBon(ort, w) {
|
|
|
322
356
|
const r = raus;
|
|
323
357
|
wennWert(r, o, 'afterCount', () => nachZaehlung(unter(ort, 'afterCount'), o.afterCount));
|
|
324
358
|
wennDa(r, o, 'leftInDrawerCents', () => ganzzahlOderNull(ort, o, 'leftInDrawerCents'));
|
|
359
|
+
// Ablauf der Kasse: nur, wenn der Server sie sendet (die Bons davor tragen sie nicht).
|
|
360
|
+
wennWert(r, o, 'openingCounted', () => wahr(ort, o, 'openingCounted'));
|
|
361
|
+
wennWert(r, o, 'interimDifferenceCents', () => ganzzahl(ort, o, 'interimDifferenceCents'));
|
|
362
|
+
wennWert(r, o, 'differenceParts', () => liste(ort, o, 'differenceParts', differenzTeil));
|
|
363
|
+
wennDa(r, o, 'countedBeforePayoutCents', () => ganzzahlOderNull(ort, o, 'countedBeforePayoutCents'));
|
|
364
|
+
wennDa(r, o, 'countedBeforePayoutDenominations', () => stueckelung(ort, o, 'countedBeforePayoutDenominations'));
|
|
325
365
|
return raus;
|
|
326
366
|
}
|
|
327
367
|
/** Bon-Daten einer Kassenbewegung; eine andere Art ist ein Fehler. */
|
|
@@ -374,6 +414,12 @@ export function geoeffnet(ort, w) {
|
|
|
374
414
|
wennDa(raus, o, 'handoverDifferenceCents', () => ganzzahlOderNull(ort, o, 'handoverDifferenceCents'));
|
|
375
415
|
return raus;
|
|
376
416
|
}
|
|
417
|
+
export function gezaehlt(ort, w) {
|
|
418
|
+
const o = pflichtObjekt(ort, w);
|
|
419
|
+
const z = pflichtObjekt(unter(ort, 'count'), o.count);
|
|
420
|
+
const zOrt = unter(ort, 'count');
|
|
421
|
+
return { count: { expectedCents: ganzzahl(zOrt, z, 'expectedCents'), countedCents: ganzzahl(zOrt, z, 'countedCents'), differenceCents: ganzzahl(zOrt, z, 'differenceCents') } };
|
|
422
|
+
}
|
|
377
423
|
export function gebucht(ort, w) {
|
|
378
424
|
const o = pflichtObjekt(ort, w);
|
|
379
425
|
return { movement: bewegung(unter(ort, 'movement'), o.movement), receipt: bewegungsBon(unter(ort, 'receipt'), o.receipt) };
|
|
@@ -19,10 +19,10 @@ export type EurDenomination = (typeof EUR_DENOMINATIONS)[number];
|
|
|
19
19
|
/**
|
|
20
20
|
* Alle Arten einer Kassenbewegung (Katalog `KASSEN_BEWEGUNG_ART`). Die ersten
|
|
21
21
|
* acht sendet die Kasse ([MANUAL_MOVEMENT_TYPES]); `transfer_in` (Gegenseite
|
|
22
|
-
* einer Umbuchung), `expense`, `count_difference
|
|
23
|
-
* vergibt nur der Server.
|
|
22
|
+
* einer Umbuchung), `expense`, `count_difference`, `handover_difference` und
|
|
23
|
+
* `interim_difference` (Differenz einer Zwischenzaehlung) vergibt nur der Server.
|
|
24
24
|
*/
|
|
25
|
-
export declare const MOVEMENT_TYPES: readonly ["change_in", "cash_drop", "owner_deposit", "owner_withdrawal", "tip_payout", "other_in", "other_out", "transfer_out", "transfer_in", "expense", "count_difference", "handover_difference"];
|
|
25
|
+
export declare const MOVEMENT_TYPES: readonly ["change_in", "cash_drop", "owner_deposit", "owner_withdrawal", "tip_payout", "other_in", "other_out", "transfer_out", "transfer_in", "expense", "count_difference", "handover_difference", "interim_difference"];
|
|
26
26
|
export type MovementType = (typeof MOVEMENT_TYPES)[number];
|
|
27
27
|
/**
|
|
28
28
|
* Was die Kasse von Hand buchen darf. Pflichtangaben je Art (sonst lehnt der
|
|
@@ -150,6 +150,20 @@ export interface ShiftRunningTotals {
|
|
|
150
150
|
/** Nach Name sortiert. */
|
|
151
151
|
tips: ShiftTipTotals[];
|
|
152
152
|
openingsWithoutSale: number;
|
|
153
|
+
/**
|
|
154
|
+
* Trinkgeld an Kassen-Benutzer mit „Trinkgeld steuerpflichtig“ (Inhaber): zählt als Umsatz des Betriebs,
|
|
155
|
+
* nie als Anspruch, nie in „offen“ (nur Anzeige, 1.28.0). Nach Name sortiert; der Server sendet es nur,
|
|
156
|
+
* wenn es etwas gibt (fehlt = keines).
|
|
157
|
+
*/
|
|
158
|
+
ownerTips?: ShiftOwnerTip[];
|
|
159
|
+
/** Trinkgeld ohne angemeldeten Empfänger in Cent (nur Anzeige, 1.28.0); fehlt = 0. */
|
|
160
|
+
unassignedTipCents?: number;
|
|
161
|
+
}
|
|
162
|
+
/** Ein Eintrag von [ShiftRunningTotals.ownerTips]: Trinkgeld, das als Umsatz erfasst ist. */
|
|
163
|
+
export interface ShiftOwnerTip {
|
|
164
|
+
registerUserId: string;
|
|
165
|
+
name: string | null;
|
|
166
|
+
cents: number;
|
|
153
167
|
}
|
|
154
168
|
/** Nachrechnung des Laufstands beim Abschluss: stimmt er, oder welche Felder weichen ab. */
|
|
155
169
|
export interface ShiftReconciliation {
|
|
@@ -160,6 +174,29 @@ export interface ShiftReconciliation {
|
|
|
160
174
|
recomputed: unknown;
|
|
161
175
|
}> | null;
|
|
162
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* Wie sich das Soll in der Lade zusammensetzt (`Shift.expectedParts`, Karte „So setzt sich das zusammen“):
|
|
179
|
+
* Anfang, Barverkaeufe, Trinkgeld bar, Storno bar, Einzahlungen, Ausgaben aus der Lade und die
|
|
180
|
+
* Summe der Zwischenzaehlungs-Differenzen. Die Summe der Teile ist das Soll.
|
|
181
|
+
*/
|
|
182
|
+
export declare const EXPECTED_PART_KEYS: readonly ["opening", "cash_sales", "cash_tips", "cancellations", "cash_in", "cash_out", "interim_difference"];
|
|
183
|
+
export type ExpectedPartKey = (typeof EXPECTED_PART_KEYS)[number];
|
|
184
|
+
/** Ein Teil des Solls in Cent (Vorzeichen wie gebucht, Ausgaben negativ). */
|
|
185
|
+
export interface ShiftExpectedPart {
|
|
186
|
+
/** Offen fuer einen kuenftigen Teil des Servers; bekannt sind [EXPECTED_PART_KEYS]. */
|
|
187
|
+
key: ExpectedPartKey | (string & {});
|
|
188
|
+
cents: number;
|
|
189
|
+
}
|
|
190
|
+
/** Teile der Gesamtdifferenz einer geschlossenen Schicht mit Zwischenzaehlung: `interim` je Zaehlung, `closing` der Abschluss. */
|
|
191
|
+
export declare const DIFFERENCE_PART_TYPES: readonly ["interim", "closing"];
|
|
192
|
+
export type DifferencePartType = (typeof DIFFERENCE_PART_TYPES)[number];
|
|
193
|
+
export interface ShiftDifferencePart {
|
|
194
|
+
/** Offen fuer einen kuenftigen Wert; bekannt sind [DIFFERENCE_PART_TYPES]. */
|
|
195
|
+
type: DifferencePartType | (string & {});
|
|
196
|
+
cents: number;
|
|
197
|
+
/** Zeitpunkt der Zaehlung (ISO 8601, UTC); beim Abschluss kann er fehlen. */
|
|
198
|
+
at: string | null;
|
|
199
|
+
}
|
|
163
200
|
export interface Shift {
|
|
164
201
|
id: string;
|
|
165
202
|
drawerId: string;
|
|
@@ -183,12 +220,38 @@ export interface Shift {
|
|
|
183
220
|
suggestedFloatCents?: number | null;
|
|
184
221
|
runningTotals?: ShiftRunningTotals;
|
|
185
222
|
expectedCents?: number | null;
|
|
223
|
+
/**
|
|
224
|
+
* Gesamtdifferenz der Schicht. Mit Zwischenzaehlungen ist sie NICHT `countedCents − expectedCents`:
|
|
225
|
+
* jede Zwischenzaehlung verschiebt das Soll um ihre Differenz, gespeichert wird die Summe aus den
|
|
226
|
+
* Zwischen-Teilen und dem Abschluss-Teil (`differenceParts`). Ohne Zwischenzaehlung gilt Ist − Soll.
|
|
227
|
+
*/
|
|
186
228
|
differenceCents?: number | null;
|
|
187
229
|
reconciliation?: ShiftReconciliation | null;
|
|
188
230
|
/** Entnommen bzw. eingelegt nach dem Zaehlen. */
|
|
189
231
|
afterCount?: AfterCount;
|
|
190
232
|
/** Was danach in der Lade bleibt (Ist ∓ Betrag); fehlt blind (ohne `cashView`). */
|
|
191
233
|
leftInDrawerCents?: number;
|
|
234
|
+
/**
|
|
235
|
+
* Wurde der Anfang gezaehlt? `false` heisst: der Bestand wurde ohne Zaehlen uebernommen.
|
|
236
|
+
* Steht an offenen und geschlossenen Schichten und auf den Z-Bon-Daten (`ShiftSummaryReceipt.openingCounted`);
|
|
237
|
+
* fehlt das Feld (aeltere Server), gilt es als unbekannt, nicht als gezaehlt.
|
|
238
|
+
*/
|
|
239
|
+
openingCounted?: boolean;
|
|
240
|
+
/** Das Soll in Teilen (Summe = `expectedCents`); nur an der offenen Schicht mit `cashView`. */
|
|
241
|
+
expectedParts?: ShiftExpectedPart[];
|
|
242
|
+
/** Bar-Trinkgeld, das in der Lade liegt (Teil des Solls); nur an der offenen Schicht mit `cashView`. */
|
|
243
|
+
cashTipsInDrawerCents?: number;
|
|
244
|
+
/** Zahl der Zwischenzaehlungen dieser Schicht; nur an der offenen Schicht mit `cashView`. */
|
|
245
|
+
interimCounts?: number;
|
|
246
|
+
/** Summe der Differenzen der Zwischenzaehlungen in Cent; fehlt, wenn der Server sie nicht sendet. */
|
|
247
|
+
interimDifferenceCents?: number;
|
|
248
|
+
/** Teile der Gesamtdifferenz; nur an geschlossenen Schichten mit Zwischenzaehlung. */
|
|
249
|
+
differenceParts?: ShiftDifferencePart[];
|
|
250
|
+
/**
|
|
251
|
+
* Rohwert der Zaehlung vor der Trinkgeld-Auszahlung; nur wenn mit `countedBeforePayout`
|
|
252
|
+
* geschlossen wurde. `countedCents` bleibt dann der Stand nach der Auszahlung.
|
|
253
|
+
*/
|
|
254
|
+
countedBeforePayoutCents?: number;
|
|
192
255
|
}
|
|
193
256
|
/** Offener Trinkgeld-Anspruch eines Mitarbeiters (auszahlbar beim Abschluss oder per `tip_payout`). */
|
|
194
257
|
export interface TipClaim {
|
|
@@ -236,6 +299,18 @@ export interface DrawerState {
|
|
|
236
299
|
* mit einem Betrag „Bleibt in der Kassenlade“ schloss.
|
|
237
300
|
*/
|
|
238
301
|
suggestedFromShiftNumber?: number;
|
|
302
|
+
/**
|
|
303
|
+
* Die zuletzt geschlossene Schicht dieser Lade (Karte „Letzte Schicht“ am Schichtbeginn);
|
|
304
|
+
* `null`, wenn es keine gibt, fehlt ohne Recht `shift`.
|
|
305
|
+
*/
|
|
306
|
+
lastShift?: LastShift | null;
|
|
307
|
+
}
|
|
308
|
+
/** Die zuletzt geschlossene Schicht einer Lade. */
|
|
309
|
+
export interface LastShift {
|
|
310
|
+
number: number;
|
|
311
|
+
closedAt: string;
|
|
312
|
+
/** Wer sie schloss; `null`, wenn kein Name bekannt ist. */
|
|
313
|
+
closedByName: string | null;
|
|
239
314
|
}
|
|
240
315
|
export interface CashMovement {
|
|
241
316
|
id: string;
|
|
@@ -308,6 +383,10 @@ export interface ShiftSummaryReceipt extends ShiftReceiptHeader {
|
|
|
308
383
|
/** Beim X-Bon immer `null`. */
|
|
309
384
|
countedCents: number | null;
|
|
310
385
|
countedDenominations: Denominations | null;
|
|
386
|
+
/**
|
|
387
|
+
* Gesamtdifferenz; mit Zwischenzaehlungen nicht `countedCents − expectedCents`, sondern die Summe der
|
|
388
|
+
* Zwischen-Teile und des Abschluss-Teils (`differenceParts`), wie an `Shift.differenceCents`.
|
|
389
|
+
*/
|
|
311
390
|
differenceCents: number | null;
|
|
312
391
|
comment: string | null;
|
|
313
392
|
openingsWithoutSale: number;
|
|
@@ -318,6 +397,22 @@ export interface ShiftSummaryReceipt extends ShiftReceiptHeader {
|
|
|
318
397
|
* (mit „Entnommen“ ergaebe es sonst das Ist).
|
|
319
398
|
*/
|
|
320
399
|
leftInDrawerCents?: number | null;
|
|
400
|
+
/**
|
|
401
|
+
* Wurde der Anfang gezaehlt? Nur mit `false` druckt der Bon „Anfang uebernommen, nicht
|
|
402
|
+
* gezaehlt“; fehlt das Feld (der Server sendet es auf dem Bon nicht), bleibt die Zeile weg.
|
|
403
|
+
*/
|
|
404
|
+
openingCounted?: boolean;
|
|
405
|
+
/** Summe der Zwischenzaehlungs-Differenzen; fehlt, wenn sie 0 ist oder blind. */
|
|
406
|
+
interimDifferenceCents?: number;
|
|
407
|
+
/** Teile der Gesamtdifferenz (Zwischenzaehlungen und Abschluss); fehlt ohne Zwischenzaehlung und blind. */
|
|
408
|
+
differenceParts?: ShiftDifferencePart[];
|
|
409
|
+
/**
|
|
410
|
+
* Die Zaehlung vor der Trinkgeld-Auszahlung (Rohwert); nur wenn so geschlossen wurde, blind `null`.
|
|
411
|
+
* `countedCents` ist dann der Stand nach der Auszahlung.
|
|
412
|
+
*/
|
|
413
|
+
countedBeforePayoutCents?: number | null;
|
|
414
|
+
/** Stueckelung zu `countedBeforePayoutCents`; blind `null`. */
|
|
415
|
+
countedBeforePayoutDenominations?: Denominations | null;
|
|
321
416
|
}
|
|
322
417
|
/** Bon-Daten einer Kassenbewegung. */
|
|
323
418
|
export interface CashMovementReceipt extends ShiftReceiptHeader {
|
|
@@ -343,6 +438,14 @@ export interface OpenShiftResult {
|
|
|
343
438
|
/** Unterschied zum uebergebenen Bestand beim Zaehlen; nur mit `cashView`. */
|
|
344
439
|
handoverDifferenceCents?: number | null;
|
|
345
440
|
}
|
|
441
|
+
/** Antwort von `recordMyShiftCount`: Soll, Zaehlung und Differenz dieser Zwischenzaehlung (Cent). */
|
|
442
|
+
export interface ShiftCountResult {
|
|
443
|
+
count: {
|
|
444
|
+
expectedCents: number;
|
|
445
|
+
countedCents: number;
|
|
446
|
+
differenceCents: number;
|
|
447
|
+
};
|
|
448
|
+
}
|
|
346
449
|
export interface CashMovementResult {
|
|
347
450
|
movement: CashMovement;
|
|
348
451
|
receipt: CashMovementReceipt;
|
|
@@ -18,12 +18,12 @@ export const EUR_DENOMINATIONS = Object.freeze([50000, 20000, 10000, 5000, 2000,
|
|
|
18
18
|
/**
|
|
19
19
|
* Alle Arten einer Kassenbewegung (Katalog `KASSEN_BEWEGUNG_ART`). Die ersten
|
|
20
20
|
* acht sendet die Kasse ([MANUAL_MOVEMENT_TYPES]); `transfer_in` (Gegenseite
|
|
21
|
-
* einer Umbuchung), `expense`, `count_difference
|
|
22
|
-
* vergibt nur der Server.
|
|
21
|
+
* einer Umbuchung), `expense`, `count_difference`, `handover_difference` und
|
|
22
|
+
* `interim_difference` (Differenz einer Zwischenzaehlung) vergibt nur der Server.
|
|
23
23
|
*/
|
|
24
24
|
export const MOVEMENT_TYPES = Object.freeze([
|
|
25
25
|
'change_in', 'cash_drop', 'owner_deposit', 'owner_withdrawal', 'tip_payout', 'other_in', 'other_out', 'transfer_out',
|
|
26
|
-
'transfer_in', 'expense', 'count_difference', 'handover_difference',
|
|
26
|
+
'transfer_in', 'expense', 'count_difference', 'handover_difference', 'interim_difference',
|
|
27
27
|
]);
|
|
28
28
|
/**
|
|
29
29
|
* Was die Kasse von Hand buchen darf. Pflichtangaben je Art (sonst lehnt der
|
|
@@ -54,3 +54,13 @@ export const MANUAL_OPENING_REASONS = Object.freeze(['change', 'check', 'misoper
|
|
|
54
54
|
export const AFTER_COUNT_TYPES = Object.freeze(['cash_drop', 'change_in']);
|
|
55
55
|
/** Arten der Bon-Daten (Katalog `SCHICHT_BON_ART`): Z-Bon, X-Bon, Kassenbewegung. */
|
|
56
56
|
export const SHIFT_RECEIPT_KINDS = Object.freeze(['shift_close', 'shift_interim', 'cash_movement']);
|
|
57
|
+
/**
|
|
58
|
+
* Wie sich das Soll in der Lade zusammensetzt (`Shift.expectedParts`, Karte „So setzt sich das zusammen“):
|
|
59
|
+
* Anfang, Barverkaeufe, Trinkgeld bar, Storno bar, Einzahlungen, Ausgaben aus der Lade und die
|
|
60
|
+
* Summe der Zwischenzaehlungs-Differenzen. Die Summe der Teile ist das Soll.
|
|
61
|
+
*/
|
|
62
|
+
export const EXPECTED_PART_KEYS = Object.freeze([
|
|
63
|
+
'opening', 'cash_sales', 'cash_tips', 'cancellations', 'cash_in', 'cash_out', 'interim_difference',
|
|
64
|
+
]);
|
|
65
|
+
/** Teile der Gesamtdifferenz einer geschlossenen Schicht mit Zwischenzaehlung: `interim` je Zaehlung, `closing` der Abschluss. */
|
|
66
|
+
export const DIFFERENCE_PART_TYPES = Object.freeze(['interim', 'closing']);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { InternerTransport } from '../client/aufrufe.js';
|
|
2
|
-
import { type AfterCountType, type CashLocation, type CashMovementResult, type CloseShiftResult, type Denominations, type DrawerOpeningsResult, type DrawerState, type ManualMovementType, type OpeningReason, type OpenShiftResult, type ShiftReport, type ShiftTipTotals } from './schicht-typen.js';
|
|
2
|
+
import { type AfterCountType, type CashLocation, type CashMovementResult, type CloseShiftResult, type Denominations, type DrawerOpeningsResult, type DrawerState, type ManualMovementType, type OpeningReason, type OpenShiftResult, type ShiftCountResult, type ShiftReport, type ShiftTipTotals } from './schicht-typen.js';
|
|
3
3
|
/**
|
|
4
4
|
* Schicht, Kassenstand und Lade-Protokoll an der Kasse (Backend
|
|
5
|
-
* schicht-endpoints.js). Alle
|
|
5
|
+
* schicht-endpoints.js). Alle sieben Aufrufe gibt es nur ueber den Kassenweg
|
|
6
6
|
* `/api/v3`; sie laufen mit dem Kassen-Benutzer-Weg (`registerUserAuth`).
|
|
7
7
|
*
|
|
8
8
|
* Rechte am Server: `shift` (Schicht oeffnen und schliessen, Bericht),
|
|
@@ -125,6 +125,26 @@ export interface CloseMyShiftOptions {
|
|
|
125
125
|
* danach derselbe Betrag, gilt er als dieselbe Zaehlung.
|
|
126
126
|
*/
|
|
127
127
|
checkOnly?: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* `countedCents` ist der Stand **vor** den Trinkgeld-Auszahlungen derselben Anfrage: die
|
|
130
|
+
* Kasse zaehlt zuerst, zahlt dann aus. Der Server speichert den Rohwert (Antwort:
|
|
131
|
+
* `shift.countedBeforePayoutCents`, auf dem Bon „Gezaehlt“) und rechnet Ist und Differenz
|
|
132
|
+
* mit dem Stand nach der Auszahlung. Ohne die Angabe zaehlt der Betrag wie bisher als Ist.
|
|
133
|
+
*/
|
|
134
|
+
countedBeforePayout?: boolean;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Zwischenzaehlung waehrend der Schicht ([recordMyShiftCount], Recht `cashView`): der Kassenstand
|
|
138
|
+
* wird gezaehlt, ohne die Schicht zu schliessen.
|
|
139
|
+
*/
|
|
140
|
+
export interface RecordMyShiftCountOptions {
|
|
141
|
+
idempotencyKey: string;
|
|
142
|
+
shiftId: string;
|
|
143
|
+
/** Gezaehltes Bargeld in Cent (`0` erlaubt). */
|
|
144
|
+
countedCents: number;
|
|
145
|
+
denominations?: Denominations | null;
|
|
146
|
+
/** Freitext zur Zaehlung (z. B. Grund einer Abweichung). */
|
|
147
|
+
comment?: string;
|
|
128
148
|
}
|
|
129
149
|
/** Entnehmen oder Einlegen beim Abschluss (siehe [CloseMyShiftOptions.afterCount]). */
|
|
130
150
|
export interface AfterCountOption {
|
|
@@ -148,6 +168,12 @@ export declare function getMyShiftReport(transport: InternerTransport, options:
|
|
|
148
168
|
* `checkOnly` nur pruefen: `status: 'ready'` statt Schliessen.
|
|
149
169
|
*/
|
|
150
170
|
export declare function closeMyShift(transport: InternerTransport, options: CloseMyShiftOptions): Promise<CloseShiftResult>;
|
|
171
|
+
/**
|
|
172
|
+
* Zwischenzaehlung festhalten (Recht `cashView`, ohne es `not_permitted`): der Server vergleicht die Zaehlung mit dem Soll
|
|
173
|
+
* und haelt die Differenz fest, die Schicht bleibt offen. Antwort: Soll, Zaehlung und Differenz
|
|
174
|
+
* dieser Zaehlung. Derselbe `idempotencyKey` ergibt dieselbe Antwort und keinen zweiten Eintrag.
|
|
175
|
+
*/
|
|
176
|
+
export declare function recordMyShiftCount(transport: InternerTransport, options: RecordMyShiftCountOptions): Promise<ShiftCountResult>;
|
|
151
177
|
/**
|
|
152
178
|
* Summe einer Stueckelung in Cent, oder `null`, wenn sie keine ist: ein
|
|
153
179
|
* Schluessel, der kein Euro-Wert ist ([EUR_DENOMINATIONS], genau so
|
package/dist/esm/pos/schicht.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { KasseneckValidationError } from '../client/errors.js';
|
|
2
2
|
import { anfrage, schluessel } from '../inventory/schreiben.js';
|
|
3
|
-
import { abschluss, bericht, gebucht, geoeffnet, gemeldet, ladeStand } from './schicht-lesen.js';
|
|
3
|
+
import { abschluss, bericht, gebucht, geoeffnet, gemeldet, gezaehlt, ladeStand } from './schicht-lesen.js';
|
|
4
4
|
import { labelText } from './texte.js';
|
|
5
5
|
import { CASH_LOCATIONS, EUR_DENOMINATIONS, } from './schicht-typen.js';
|
|
6
6
|
const antwort = (name) => ({ name, pfad: '', scope: 'response' });
|
|
@@ -104,6 +104,8 @@ export async function closeMyShift(transport, options) {
|
|
|
104
104
|
}
|
|
105
105
|
if (p.checkOnly !== undefined && typeof p.checkOnly !== 'boolean')
|
|
106
106
|
throw anfragefehler(name, 'checkOnly muss true oder false sein');
|
|
107
|
+
if (p.countedBeforePayout !== undefined && typeof p.countedBeforePayout !== 'boolean')
|
|
108
|
+
throw anfragefehler(name, 'countedBeforePayout muss true oder false sein');
|
|
107
109
|
// Nur die Form: die Art (Katalog) und die Grenzen prueft der Server.
|
|
108
110
|
if (p.afterCount !== undefined && p.afterCount !== null) {
|
|
109
111
|
if (typeof p.afterCount !== 'object' || Array.isArray(p.afterCount))
|
|
@@ -112,6 +114,22 @@ export async function closeMyShift(transport, options) {
|
|
|
112
114
|
}
|
|
113
115
|
return rufe(transport, name, p, abschluss);
|
|
114
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Zwischenzaehlung festhalten (Recht `cashView`, ohne es `not_permitted`): der Server vergleicht die Zaehlung mit dem Soll
|
|
119
|
+
* und haelt die Differenz fest, die Schicht bleibt offen. Antwort: Soll, Zaehlung und Differenz
|
|
120
|
+
* dieser Zaehlung. Derselbe `idempotencyKey` ergibt dieselbe Antwort und keinen zweiten Eintrag.
|
|
121
|
+
*/
|
|
122
|
+
export async function recordMyShiftCount(transport, options) {
|
|
123
|
+
const name = 'recordMyShiftCount';
|
|
124
|
+
const p = anfrage(name, options);
|
|
125
|
+
kennung(name, p, 'shiftId');
|
|
126
|
+
schluessel(name, p, { pflicht: true });
|
|
127
|
+
cent(name, 'countedCents', p.countedCents);
|
|
128
|
+
stueckelungPruefen(name, p);
|
|
129
|
+
if (p.comment !== undefined && typeof p.comment !== 'string')
|
|
130
|
+
throw anfragefehler(name, 'comment muss ein Text sein');
|
|
131
|
+
return rufe(transport, name, p, gezaehlt);
|
|
132
|
+
}
|
|
115
133
|
// ---- Helfer der Kasse ---------------------------------------------------------
|
|
116
134
|
const ANZAHL_MAX = 100000;
|
|
117
135
|
const WERTE = new Set(EUR_DENOMINATIONS.map(String));
|
|
@@ -22,6 +22,18 @@ export declare const QUANTITY: readonly ["off", "x", "kg"];
|
|
|
22
22
|
export type PosQuantity = typeof QUANTITY[number];
|
|
23
23
|
export declare const TIP_MODE: readonly ["amount", "total", "both"];
|
|
24
24
|
export type PosTipMode = typeof TIP_MODE[number];
|
|
25
|
+
/**
|
|
26
|
+
* Trinkgeld-Arten, die die Kasse anbietet (`business.tipKinds`): Prozent, Aufrunden
|
|
27
|
+
* (der Gast zahlt auf einen runden Betrag) und Gesamt (der Gast nennt den Betrag, den er insgesamt zahlt).
|
|
28
|
+
* `business.tipStart` ist die zuerst offene Art und liegt immer unter den angebotenen.
|
|
29
|
+
*/
|
|
30
|
+
export declare const TIP_KINDS: readonly ["percent", "round_up", "total"];
|
|
31
|
+
export type PosTipKind = typeof TIP_KINDS[number];
|
|
32
|
+
/** Die zuerst offene Trinkgeld-Art (`business.tipStart`): dieselben Werte wie [TIP_KINDS]. */
|
|
33
|
+
export declare const TIP_START: readonly ["percent", "round_up", "total"];
|
|
34
|
+
/** Breite der rechten Spalte (Korb) an diesem Geraet (`device.cartWidth`); in der schmalen Ansicht ohne Wirkung. */
|
|
35
|
+
export declare const CART_WIDTH: readonly ["narrow", "medium", "wide"];
|
|
36
|
+
export type PosCartWidth = typeof CART_WIDTH[number];
|
|
25
37
|
export declare const CHECKOUT_MODE: readonly ["page", "panel"];
|
|
26
38
|
export type PosCheckoutMode = typeof CHECKOUT_MODE[number];
|
|
27
39
|
/** Kartenanbieter: Karte gibt es erst mit eingerichtetem Anbieter; 'external' = eigenes Terminal ohne Anbindung. */
|
|
@@ -197,6 +209,14 @@ export interface PosBusinessSettings {
|
|
|
197
209
|
* Lesen ueber [posTipKeptByDefault]. Siehe [POS_BUSINESS_OPTIONAL_FIELDS].
|
|
198
210
|
*/
|
|
199
211
|
tipKeptByDefault?: boolean;
|
|
212
|
+
/**
|
|
213
|
+
* Angebotene Trinkgeld-Arten (nichtleere Teilmenge von [TIP_KINDS], Reihenfolge wie
|
|
214
|
+
* gespeichert). Optional: der Server sendet das Feld nur, wenn es gespeichert ist; fehlt es,
|
|
215
|
+
* gelten alle drei. Lesen ueber [posTipKinds]. `tipMode` folgt den Arten (der Server leitet ihn ab).
|
|
216
|
+
*/
|
|
217
|
+
tipKinds?: PosOpen<PosTipKind>[];
|
|
218
|
+
/** Zuerst offene Trinkgeld-Art; optional, fehlt sie, gilt Prozent (sonst die erste Art). Lesen ueber [posTipStart]. */
|
|
219
|
+
tipStart?: PosOpen<PosTipKind>;
|
|
200
220
|
}
|
|
201
221
|
/** Aktionen der Kasse, die eine Taste bekommen koennen (Schluessel von `device.shortcuts`). */
|
|
202
222
|
export declare const POS_SHORTCUT_ACTIONS: readonly ["checkout", "complete", "cancel", "customAmount", "cash", "card", "exactAmount", "receipts", "undoLast", "settings", "logout", "tip", "fullscreen", "clearTendered", "clearCart", "splitPayment", "shiftStatus", "openDrawer", "voucherPayout"];
|
|
@@ -256,6 +276,8 @@ export interface PosDeviceSettings {
|
|
|
256
276
|
* [POS_DEVICE_OPTIONAL_FIELDS].
|
|
257
277
|
*/
|
|
258
278
|
drawerId?: string | null;
|
|
279
|
+
/** Breite der rechten Spalte; optional, fehlt sie, gilt `narrow`. Lesen ueber [posCartWidth]. */
|
|
280
|
+
cartWidth?: PosOpen<PosCartWidth>;
|
|
259
281
|
terminalIp: string;
|
|
260
282
|
terminalPort: number;
|
|
261
283
|
terminalVia: PosOpen<PosTerminalVia>;
|
|
@@ -291,6 +313,23 @@ export declare function _optionalerWert(wert: unknown, schreiben: boolean): bool
|
|
|
291
313
|
* nimmt nur `true`/`false`.
|
|
292
314
|
*/
|
|
293
315
|
export declare const POS_BUSINESS_OPTIONAL_FIELDS: readonly ["tipKeptByDefault"];
|
|
316
|
+
/**
|
|
317
|
+
* Optionale Betriebs-Einstellungen mit Wertemenge (Backend `BETRIEB_OPTIONAL`, Katalog
|
|
318
|
+
* `KASSE_BETRIEB_WERTE.tipKinds[]` und `.tipStart`): ohne Standardwert, der Server sendet sie nur,
|
|
319
|
+
* wenn sie gespeichert sind. [mergePosSettings] uebernimmt sie, wenn sie die Form haben
|
|
320
|
+
* (`tipKinds` eine nichtleere Liste von Texten, `tipStart` ein Text); den Wert prueft der Schreibweg.
|
|
321
|
+
*/
|
|
322
|
+
export declare const POS_BUSINESS_OPTIONAL_CHOICES: readonly ["tipKinds", "tipStart"];
|
|
323
|
+
/** Optionale Geraete-Einstellungen mit Wertemenge (Backend `GERAET_OPTIONAL`, Katalog `KASSE_GERAET_WERTE.cartWidth`). */
|
|
324
|
+
export declare const POS_DEVICE_OPTIONAL_CHOICES: readonly ["cartWidth"];
|
|
325
|
+
/** Hat der Wert die Form eines optionalen Wahlfeldes? Texte, die der Server neu einfuehren koennte, bleiben (kein Altwert 0.x). */
|
|
326
|
+
export declare function _optionalerWahlwert(feld: string, wert: unknown): boolean;
|
|
327
|
+
/** Wirksame Trinkgeld-Arten: die gespeicherten, sonst alle drei. */
|
|
328
|
+
export declare function posTipKinds(business: Readonly<Partial<PosBusinessSettings>> | null | undefined): PosOpen<PosTipKind>[];
|
|
329
|
+
/** Wirksame Start-Art: die gespeicherte, wenn sie angeboten wird, sonst Prozent (oder die erste angebotene Art). */
|
|
330
|
+
export declare function posTipStart(business: Readonly<Partial<PosBusinessSettings>> | null | undefined): PosOpen<PosTipKind>;
|
|
331
|
+
/** Wirksame Breite der rechten Spalte; ohne Angabe `narrow`. */
|
|
332
|
+
export declare function posCartWidth(device: Readonly<Partial<PosDeviceSettings>> | null | undefined): PosOpen<PosCartWidth>;
|
|
294
333
|
/** Bar-Trinkgeld „gleich behalten“ vorbelegt? Fehlt die Einstellung, gilt aus. */
|
|
295
334
|
export declare function posTipKeptByDefault(business: Readonly<Partial<PosBusinessSettings>> | null | undefined): boolean;
|
|
296
335
|
/**
|
package/dist/esm/pos/settings.js
CHANGED
|
@@ -25,6 +25,16 @@ export const FONT_SIZE = ['S', 'M', 'L', 'XL'];
|
|
|
25
25
|
export const WATERMARK = ['off', 'login', 'everywhere'];
|
|
26
26
|
export const QUANTITY = ['off', 'x', 'kg'];
|
|
27
27
|
export const TIP_MODE = ['amount', 'total', 'both'];
|
|
28
|
+
/**
|
|
29
|
+
* Trinkgeld-Arten, die die Kasse anbietet (`business.tipKinds`): Prozent, Aufrunden
|
|
30
|
+
* (der Gast zahlt auf einen runden Betrag) und Gesamt (der Gast nennt den Betrag, den er insgesamt zahlt).
|
|
31
|
+
* `business.tipStart` ist die zuerst offene Art und liegt immer unter den angebotenen.
|
|
32
|
+
*/
|
|
33
|
+
export const TIP_KINDS = ['percent', 'round_up', 'total'];
|
|
34
|
+
/** Die zuerst offene Trinkgeld-Art (`business.tipStart`): dieselben Werte wie [TIP_KINDS]. */
|
|
35
|
+
export const TIP_START = TIP_KINDS;
|
|
36
|
+
/** Breite der rechten Spalte (Korb) an diesem Geraet (`device.cartWidth`); in der schmalen Ansicht ohne Wirkung. */
|
|
37
|
+
export const CART_WIDTH = ['narrow', 'medium', 'wide'];
|
|
28
38
|
export const CHECKOUT_MODE = ['page', 'panel'];
|
|
29
39
|
/** Kartenanbieter: Karte gibt es erst mit eingerichtetem Anbieter; 'external' = eigenes Terminal ohne Anbindung. */
|
|
30
40
|
export const CARD_PROVIDER = ['none', 'external', 'gptom', 'hobex', 'mypos', 'stripe'];
|
|
@@ -202,6 +212,41 @@ const OPTIONALE = new Set(POS_DEVICE_OPTIONAL_FIELDS);
|
|
|
202
212
|
*/
|
|
203
213
|
export const POS_BUSINESS_OPTIONAL_FIELDS = Object.freeze(['tipKeptByDefault']);
|
|
204
214
|
const OPTIONALE_SCHALTER = new Set(POS_BUSINESS_OPTIONAL_FIELDS);
|
|
215
|
+
/**
|
|
216
|
+
* Optionale Betriebs-Einstellungen mit Wertemenge (Backend `BETRIEB_OPTIONAL`, Katalog
|
|
217
|
+
* `KASSE_BETRIEB_WERTE.tipKinds[]` und `.tipStart`): ohne Standardwert, der Server sendet sie nur,
|
|
218
|
+
* wenn sie gespeichert sind. [mergePosSettings] uebernimmt sie, wenn sie die Form haben
|
|
219
|
+
* (`tipKinds` eine nichtleere Liste von Texten, `tipStart` ein Text); den Wert prueft der Schreibweg.
|
|
220
|
+
*/
|
|
221
|
+
export const POS_BUSINESS_OPTIONAL_CHOICES = Object.freeze(['tipKinds', 'tipStart']);
|
|
222
|
+
/** Optionale Geraete-Einstellungen mit Wertemenge (Backend `GERAET_OPTIONAL`, Katalog `KASSE_GERAET_WERTE.cartWidth`). */
|
|
223
|
+
export const POS_DEVICE_OPTIONAL_CHOICES = Object.freeze(['cartWidth']);
|
|
224
|
+
/** Hat der Wert die Form eines optionalen Wahlfeldes? Texte, die der Server neu einfuehren koennte, bleiben (kein Altwert 0.x). */
|
|
225
|
+
export function _optionalerWahlwert(feld, wert) {
|
|
226
|
+
if (feld === 'tipKinds') {
|
|
227
|
+
return Array.isArray(wert) && wert.length > 0 && wert.every((x) => typeof x === 'string' && !_istAltwert0x('tipKinds', x));
|
|
228
|
+
}
|
|
229
|
+
return typeof wert === 'string' && wert !== '' && !_istAltwert0x(feld, wert);
|
|
230
|
+
}
|
|
231
|
+
const OPTIONALE_WAHL = new Set([...POS_BUSINESS_OPTIONAL_CHOICES, ...POS_DEVICE_OPTIONAL_CHOICES]);
|
|
232
|
+
/** Wirksame Trinkgeld-Arten: die gespeicherten, sonst alle drei. */
|
|
233
|
+
export function posTipKinds(business) {
|
|
234
|
+
const k = business?.tipKinds;
|
|
235
|
+
return Array.isArray(k) && k.length > 0 ? [...k] : [...TIP_KINDS];
|
|
236
|
+
}
|
|
237
|
+
/** Wirksame Start-Art: die gespeicherte, wenn sie angeboten wird, sonst Prozent (oder die erste angebotene Art). */
|
|
238
|
+
export function posTipStart(business) {
|
|
239
|
+
const arten = posTipKinds(business);
|
|
240
|
+
const start = business?.tipStart;
|
|
241
|
+
if (typeof start === 'string' && arten.includes(start))
|
|
242
|
+
return start;
|
|
243
|
+
return arten.includes('percent') ? 'percent' : arten[0];
|
|
244
|
+
}
|
|
245
|
+
/** Wirksame Breite der rechten Spalte; ohne Angabe `narrow`. */
|
|
246
|
+
export function posCartWidth(device) {
|
|
247
|
+
const w = device?.cartWidth;
|
|
248
|
+
return typeof w === 'string' && w !== '' ? w : 'narrow';
|
|
249
|
+
}
|
|
205
250
|
/** Bar-Trinkgeld „gleich behalten“ vorbelegt? Fehlt die Einstellung, gilt aus. */
|
|
206
251
|
export function posTipKeptByDefault(business) {
|
|
207
252
|
return !!business && business.tipKeptByDefault === true;
|
|
@@ -216,13 +261,13 @@ export const POS_BUSINESS_VALUES = Object.freeze({
|
|
|
216
261
|
tileStyle: TILE_STYLE, autoLogoutMinutes: AUTO_LOGOUT_MINUTES, quantity: QUANTITY, discount: DISCOUNT,
|
|
217
262
|
cardProvider: CARD_PROVIDER, tipMode: TIP_MODE, checkoutMode: CHECKOUT_MODE, receiptOutput: RECEIPT_OUTPUT,
|
|
218
263
|
doneScreenSeconds: DONE_SCREEN_SECONDS, watermarkSide: WATERMARK_SIDE, watermarkStrength: WATERMARK_STRENGTH,
|
|
219
|
-
logoScale: LOGO_SCALE, watermarkScale: WATERMARK_SCALE,
|
|
264
|
+
logoScale: LOGO_SCALE, watermarkScale: WATERMARK_SCALE, tipKinds: TIP_KINDS, tipStart: TIP_START,
|
|
220
265
|
});
|
|
221
266
|
/** Wie [POS_BUSINESS_VALUES] fuer die Geraete-Einstellungen. */
|
|
222
267
|
export const POS_DEVICE_VALUES = Object.freeze({
|
|
223
268
|
layout: LAYOUT, categoryPosition: CATEGORY_POSITION, tileHeight: TILE_HEIGHT, printerType: PRINTER_TYPE,
|
|
224
269
|
paperSize: PAPER_SIZE, codePage: CODE_PAGE, cut: CUT, qrMode: QR_MODE, drawerAutoOpen: DRAWER_AUTO_OPEN,
|
|
225
|
-
terminalVia: TERMINAL_VIA, terminalType: TERMINAL_TYPE,
|
|
270
|
+
terminalVia: TERMINAL_VIA, terminalType: TERMINAL_TYPE, cartWidth: CART_WIDTH,
|
|
226
271
|
});
|
|
227
272
|
/** Eigene Eigenschaft, nie eine geerbte (`toString`, `constructor`, `__proto__`). */
|
|
228
273
|
const eigen = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
|
|
@@ -251,6 +296,9 @@ const ALTWERTE_0X = Object.freeze({
|
|
|
251
296
|
drawerAutoOpen: ['bar', 'immer', 'nie'],
|
|
252
297
|
terminalVia: ['direkt'],
|
|
253
298
|
terminalType: ['keins'],
|
|
299
|
+
tipKinds: ['prozent', 'aufrunden', 'gesamt'],
|
|
300
|
+
tipStart: ['prozent', 'aufrunden', 'gesamt'],
|
|
301
|
+
cartWidth: ['schmal', 'mittel', 'breit'],
|
|
254
302
|
});
|
|
255
303
|
/** Tasten-Aktionen der inneren Form (0.x). */
|
|
256
304
|
const ALTAKTIONEN_0X = new Set([
|
|
@@ -291,6 +339,8 @@ export function mergePosSettings(standard, stored) {
|
|
|
291
339
|
out[key] = wert;
|
|
292
340
|
if (OPTIONALE_SCHALTER.has(key) && typeof wert === 'boolean')
|
|
293
341
|
out[key] = wert;
|
|
342
|
+
if (OPTIONALE_WAHL.has(key) && _optionalerWahlwert(key, wert))
|
|
343
|
+
out[key] = Array.isArray(wert) ? [...wert] : wert;
|
|
294
344
|
continue;
|
|
295
345
|
}
|
|
296
346
|
const wert = stored[key];
|
|
@@ -348,7 +398,14 @@ export function unknownPosSettingValues(settings) {
|
|
|
348
398
|
const erlaubt = mengen[k];
|
|
349
399
|
if (!erlaubt || !eigen(block, k))
|
|
350
400
|
continue;
|
|
351
|
-
|
|
401
|
+
const wert = block[k];
|
|
402
|
+
// Eine Liste (tipKinds): unbekannt, sobald ein Eintrag fremd ist.
|
|
403
|
+
if (Array.isArray(wert)) {
|
|
404
|
+
if (wert.some((e) => !erlaubt.includes(e)))
|
|
405
|
+
raus.push(`${teil}.${k}`);
|
|
406
|
+
continue;
|
|
407
|
+
}
|
|
408
|
+
if (!erlaubt.includes(wert))
|
|
352
409
|
raus.push(`${teil}.${k}`);
|
|
353
410
|
}
|
|
354
411
|
};
|