@kreiseck/kasseneck-api 1.25.1 → 1.27.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 +20 -0
- package/dist/cjs/models/receipt-errors.d.ts +1 -1
- package/dist/cjs/models/receipt-errors.js +2 -0
- package/dist/cjs/models/receipt-item.d.ts +10 -0
- package/dist/cjs/models/receipt-item.js +8 -0
- package/dist/cjs/pos/artikel.d.ts +39 -0
- package/dist/cjs/pos/artikel.js +23 -0
- package/dist/cjs/pos/index.d.ts +3 -1
- package/dist/cjs/pos/index.js +28 -2
- package/dist/cjs/pos/kachel-referenz.d.ts +55 -0
- package/dist/cjs/pos/kachel-referenz.js +107 -0
- package/dist/cjs/pos/texte.d.ts +35 -0
- package/dist/cjs/pos/texte.js +14 -0
- package/dist/cjs/pos/zusaetze.d.ts +70 -0
- package/dist/cjs/pos/zusaetze.js +159 -0
- package/dist/cjs/receipt/grid.js +16 -3
- package/dist/cjs/receipt/layout.js +16 -9
- package/dist/cjs/stored/draht.js +4 -0
- package/dist/cjs/stored/vokabular.d.ts +1 -1
- package/dist/cjs/stored/vokabular.js +25 -4
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/models/receipt-errors.d.ts +1 -1
- package/dist/esm/models/receipt-errors.js +2 -0
- package/dist/esm/models/receipt-item.d.ts +10 -0
- package/dist/esm/models/receipt-item.js +8 -0
- package/dist/esm/pos/artikel.d.ts +39 -0
- package/dist/esm/pos/artikel.js +20 -0
- package/dist/esm/pos/index.d.ts +3 -1
- package/dist/esm/pos/index.js +3 -1
- package/dist/esm/pos/kachel-referenz.d.ts +55 -0
- package/dist/esm/pos/kachel-referenz.js +98 -0
- package/dist/esm/pos/texte.d.ts +35 -0
- package/dist/esm/pos/texte.js +14 -0
- package/dist/esm/pos/zusaetze.d.ts +70 -0
- package/dist/esm/pos/zusaetze.js +148 -0
- package/dist/esm/receipt/grid.js +16 -3
- package/dist/esm/receipt/layout.js +16 -9
- package/dist/esm/stored/draht.js +4 -0
- package/dist/esm/stored/vokabular.d.ts +1 -1
- package/dist/esm/stored/vokabular.js +25 -4
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/fixtures/add-on-cases.json +103 -0
- package/fixtures/expected/add-ons.grid32.txt +31 -0
- package/fixtures/expected/add-ons.grid48.txt +27 -0
- package/fixtures/expected/add-ons.lines.json +270 -0
- package/fixtures/expected/add-ons.sheet32.json +212 -0
- package/fixtures/expected/add-ons.sheet48.json +188 -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/manifest.json +8 -0
- package/fixtures/pos-texts.json +40 -1
- package/fixtures/receipts/add-ons.json +70 -0
- package/fixtures/reference-cases.json +238 -0
- package/fixtures/surface.json +14 -1
- package/fixtures/v3/antworten/belege.json +1 -1
- package/fixtures/v3/antworten/belegmail.json +1 -1
- package/fixtures/v3/antworten/berichte.json +1 -1
- package/fixtures/v3/antworten/kasse-belege.json +1 -1
- package/fixtures/v3/antworten/kasse.json +2 -2
- 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 +2 -2
- package/fixtures/v3/stored/rechnungen.json +1 -1
- package/fixtures/v3/v3-vokabular.json +51 -12
- package/fixtures/v3/zahlbetrag-faelle.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ADD_ON_BLOCK_REASONS = exports.ADD_ONS_MAX = void 0;
|
|
4
|
+
exports.isSelectableAddOn = isSelectableAddOn;
|
|
5
|
+
exports.addOnsFor = addOnsFor;
|
|
6
|
+
exports.addOnReferencesValid = addOnReferencesValid;
|
|
7
|
+
exports.addOnsOfItem = addOnsOfItem;
|
|
8
|
+
exports.addOnRemap = addOnRemap;
|
|
9
|
+
exports.istGueltigerZusatz = istGueltigerZusatz;
|
|
10
|
+
exports.addOnDisplayOrder = addOnDisplayOrder;
|
|
11
|
+
exports.orderAddOnLines = orderAddOnLines;
|
|
12
|
+
/**
|
|
13
|
+
* Zusatz-Kacheln (1.27.0): Tippt man eine Hauptleistung an, oeffnet die Kasse
|
|
14
|
+
* ein Fenster mit ihren Zusaetzen. Die Liste steht an der Gruppe, je Artikel
|
|
15
|
+
* abweichend (`addOns`: null = wie die Gruppe, [] = keine, sonst eigene Liste).
|
|
16
|
+
* Jeder Zusatz wird eine eigene Belegposition mit `addOnOf` = Index der
|
|
17
|
+
* Hauptposition. Die Regeln rechnen Backend (`gemeinsam/zusatz-core.js`), npm
|
|
18
|
+
* und Dart gleich; der Vertrag sind die Pruefaelle `fixtures/add-on-cases.json`.
|
|
19
|
+
*/
|
|
20
|
+
/** Hoechstens so viele Zusaetze je Liste (der Server weist mehr ab). */
|
|
21
|
+
exports.ADD_ONS_MAX = 30;
|
|
22
|
+
/** Warum ein Artikel kein Zusatz sein kann (Panel zeigt den Grund an). */
|
|
23
|
+
exports.ADD_ON_BLOCK_REASONS = ['inactive', 'own_list', 'asks_price', 'reference', 'asks_quantity', 'no_price', 'service_voucher'];
|
|
24
|
+
const eigeneListe = (a) => Array.isArray(a.addOns) && a.addOns.length > 0;
|
|
25
|
+
/**
|
|
26
|
+
* Taugt der Artikel als Zusatz? `null` = ja. Im Fenster wird ohne Abfrage
|
|
27
|
+
* gebucht: Betrag, Referenz oder Menge fragen geht nicht, ein Preis muss
|
|
28
|
+
* feststehen (0 erlaubt), ein Leistungsgutschein liefe am Gutschein-Weg vorbei,
|
|
29
|
+
* und ein Artikel mit eigener Liste oeffnete selbst ein Fenster (eine Ebene).
|
|
30
|
+
*/
|
|
31
|
+
function isSelectableAddOn(a) {
|
|
32
|
+
if (a.active === false)
|
|
33
|
+
return 'inactive';
|
|
34
|
+
if (eigeneListe(a))
|
|
35
|
+
return 'own_list';
|
|
36
|
+
if (a.askPrice === true)
|
|
37
|
+
return 'asks_price';
|
|
38
|
+
if (a.reference != null)
|
|
39
|
+
return 'reference';
|
|
40
|
+
if (a.askQuantity === true)
|
|
41
|
+
return 'asks_quantity';
|
|
42
|
+
if (typeof a.unitPriceCents !== 'number' || !Number.isInteger(a.unitPriceCents) || a.unitPriceCents < 0)
|
|
43
|
+
return 'no_price';
|
|
44
|
+
if (a.serviceVoucher === true)
|
|
45
|
+
return 'service_voucher';
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
function nachId(karte, id) {
|
|
49
|
+
if (karte instanceof Map)
|
|
50
|
+
return karte.get(id);
|
|
51
|
+
return Object.prototype.hasOwnProperty.call(karte, id) ? karte[id] : undefined;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Wirksame Zusatzliste eines Artikels: eigene Liste (auch leer) vor der der
|
|
55
|
+
* Gruppe; still heraus fallen der Artikel selbst, Unbekanntes, Dubletten und
|
|
56
|
+
* alles, was nicht als Zusatz taugt. Leer = kein Fenster.
|
|
57
|
+
*/
|
|
58
|
+
function addOnsFor(article, group, articleById) {
|
|
59
|
+
const liste = Array.isArray(article.addOns) ? article.addOns : (group && Array.isArray(group.addOns) ? group.addOns : []);
|
|
60
|
+
const raus = [];
|
|
61
|
+
for (const id of liste) {
|
|
62
|
+
if (typeof id !== 'string' || id === article.id || raus.includes(id))
|
|
63
|
+
continue;
|
|
64
|
+
const z = nachId(articleById, id);
|
|
65
|
+
if (!z || isSelectableAddOn(z) !== null)
|
|
66
|
+
continue;
|
|
67
|
+
raus.push(id);
|
|
68
|
+
}
|
|
69
|
+
return raus;
|
|
70
|
+
}
|
|
71
|
+
const hatVerweis = (it) => it != null && typeof it === 'object' && Object.prototype.hasOwnProperty.call(it, 'addOnOf') && it.addOnOf !== undefined;
|
|
72
|
+
// Positionsarten, die nie Zusatz oder Hauptposition sind (Trinkgeld, Rabatt, Gutschein).
|
|
73
|
+
const OHNE_ZUSATZ = new Set(['tip', 'discount', 'voucher', 'voucher_float']);
|
|
74
|
+
/**
|
|
75
|
+
* Halten die Verweise den Server-Regeln stand? Ganze Zahl, zeigt nach vorne
|
|
76
|
+
* auf eine Warenposition, die selbst kein Zusatz ist (sonst antwortet
|
|
77
|
+
* createReceipt mit `invalid_add_on_reference`).
|
|
78
|
+
*/
|
|
79
|
+
function addOnReferencesValid(items) {
|
|
80
|
+
return items.every((it, i) => {
|
|
81
|
+
if (!hatVerweis(it))
|
|
82
|
+
return true;
|
|
83
|
+
const z = it.addOnOf;
|
|
84
|
+
if (typeof z !== 'number' || !Number.isInteger(z) || z < 0 || z >= i)
|
|
85
|
+
return false;
|
|
86
|
+
const ziel = items[z];
|
|
87
|
+
if (OHNE_ZUSATZ.has(it.kind ?? '') || OHNE_ZUSATZ.has(ziel?.kind ?? ''))
|
|
88
|
+
return false;
|
|
89
|
+
return !hatVerweis(ziel);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/** Indizes der Zusaetze einer Hauptposition (Storno: mit vormerken, abwaehlbar). */
|
|
93
|
+
function addOnsOfItem(items, index) {
|
|
94
|
+
const raus = [];
|
|
95
|
+
items.forEach((it, i) => { if (hatVerweis(it) && it.addOnOf === index)
|
|
96
|
+
raus.push(i); });
|
|
97
|
+
return raus;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Storno: Verweis je Storno-Position (in der Reihenfolge der stornierten
|
|
101
|
+
* Positionen, Menge > 0). Ein Zusatz behaelt ihn nur, wenn seine Hauptposition
|
|
102
|
+
* mit storniert wird, umgerechnet auf den neuen Index; sonst `null`.
|
|
103
|
+
*/
|
|
104
|
+
function addOnRemap(items, quantities) {
|
|
105
|
+
const neu = new Map();
|
|
106
|
+
const raus = [];
|
|
107
|
+
items.forEach((it, i) => {
|
|
108
|
+
if (!((quantities[i] ?? 0) > 0))
|
|
109
|
+
return;
|
|
110
|
+
neu.set(i, raus.length);
|
|
111
|
+
raus.push(hatVerweis(it) && neu.has(it.addOnOf) ? neu.get(it.addOnOf) : null);
|
|
112
|
+
});
|
|
113
|
+
return raus;
|
|
114
|
+
}
|
|
115
|
+
/** Ist Position `i` ein gueltiger Zusatz (Verweis nach vorne auf eine Hauptposition)? Paketintern (Layout). */
|
|
116
|
+
function istGueltigerZusatz(items, i) {
|
|
117
|
+
const it = items[i];
|
|
118
|
+
return it != null && hatVerweis(it) && Number.isInteger(it.addOnOf)
|
|
119
|
+
&& it.addOnOf >= 0 && it.addOnOf < i && !hatVerweis(items[it.addOnOf]);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Bon-Reihenfolge: jede Hauptposition, direkt gefolgt von ihren Zusaetzen
|
|
123
|
+
* (stabil). Positionen mit ungueltigem Verweis bleiben an ihrem Platz.
|
|
124
|
+
*/
|
|
125
|
+
function addOnDisplayOrder(items) {
|
|
126
|
+
const gueltig = (_it, i) => istGueltigerZusatz(items, i);
|
|
127
|
+
const raus = [];
|
|
128
|
+
items.forEach((it, i) => {
|
|
129
|
+
if (gueltig(it, i))
|
|
130
|
+
return;
|
|
131
|
+
raus.push(i);
|
|
132
|
+
items.forEach((z, j) => { if (j > i && gueltig(z, j) && z.addOnOf === i)
|
|
133
|
+
raus.push(j); });
|
|
134
|
+
});
|
|
135
|
+
return raus;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Warenkorb -> Belegpositionen: Zeilen tragen die Zeilen-Id ihrer Hauptzeile
|
|
139
|
+
* (`addOnOf`). Sortiert jeden Zusatz hinter seine Hauptzeile (stabil) und
|
|
140
|
+
* rechnet den Verweis in den Index um. Fehlt die Hauptzeile (geloescht oder
|
|
141
|
+
* vorher herausgefiltert, etwa ein Gutschein-Verkauf), bleibt die Zeile ohne
|
|
142
|
+
* Verweis an ihrem Platz.
|
|
143
|
+
*/
|
|
144
|
+
function orderAddOnLines(lines) {
|
|
145
|
+
const ids = new Set(lines.map((l) => l.id));
|
|
146
|
+
const istZusatz = (l) => typeof l.addOnOf === 'string' && l.addOnOf !== l.id && ids.has(l.addOnOf)
|
|
147
|
+
&& !lines.some((h) => h.id === l.addOnOf && typeof h.addOnOf === 'string' && ids.has(h.addOnOf));
|
|
148
|
+
const raus = [];
|
|
149
|
+
for (const l of lines) {
|
|
150
|
+
if (istZusatz(l))
|
|
151
|
+
continue;
|
|
152
|
+
const index = raus.length;
|
|
153
|
+
raus.push({ line: l, addOnOf: null });
|
|
154
|
+
for (const z of lines)
|
|
155
|
+
if (istZusatz(z) && z.addOnOf === l.id)
|
|
156
|
+
raus.push({ line: z, addOnOf: index });
|
|
157
|
+
}
|
|
158
|
+
return raus;
|
|
159
|
+
}
|
package/dist/cjs/receipt/grid.js
CHANGED
|
@@ -105,7 +105,19 @@ function renderReceiptGrid(layout, options = {}) {
|
|
|
105
105
|
const breiten = gridColumnWidths(z.columns.map((c) => c.width), zeichen);
|
|
106
106
|
// Inhalt jeder nicht-letzten Spalte um 1 Zeichen schmaler: garantierter Abstand.
|
|
107
107
|
const inhalt = breiten.map((b, i) => (i < breiten.length - 1 ? Math.max(1, b - 1) : b));
|
|
108
|
-
|
|
108
|
+
// Haengender Einzug wie bei Textzeilen: eine linksbuendige Spalte mit
|
|
109
|
+
// fuehrenden Leerzeichen bricht mit demselben Einzug um; ein Spiegelstrich
|
|
110
|
+
// „+ “ danach zaehlt mit (Zusatzzeile „ + 1 x …“: Fortsetzung unter der
|
|
111
|
+
// Menge). Ohne fuehrende Leerzeichen dieselben Zeichen wie bisher.
|
|
112
|
+
const einzugVon = (c, i) => {
|
|
113
|
+
const e = c.align === 'left' ? (/^ +(?:\+ )?/.exec(c.text)?.[0].length ?? 0) : 0;
|
|
114
|
+
return e > 0 && e < inhalt[i] && c.text.slice(e).trim() !== '' ? e : 0;
|
|
115
|
+
};
|
|
116
|
+
const einzuege = z.columns.map(einzugVon);
|
|
117
|
+
const umbrechen = (text, breite, e) => (e > 0
|
|
118
|
+
? (0, escpos_js_1.wrapText)(text.slice(e), breite - e).map((t, k) => (k === 0 ? text.slice(0, e) : ' '.repeat(e)) + t)
|
|
119
|
+
: (0, escpos_js_1.wrapText)(text, breite));
|
|
120
|
+
const teile = z.columns.map((c, i) => umbrechen(c.text, inhalt[i], einzuege[i]));
|
|
109
121
|
// Fliessregel: laeuft nach der ersten Zeile nur noch EINE Spalte weiter (die anderen sind
|
|
110
122
|
// fertig), bekommt ihr Rest die volle Breite -- auf 58 mm sonst 18-Zeichen-Schnipsel.
|
|
111
123
|
// Laufen mehrere weiter, bleibt das Raster (sonst verschoeben sich die Nachbarn).
|
|
@@ -124,8 +136,9 @@ function renderReceiptGrid(layout, options = {}) {
|
|
|
124
136
|
const i = weiterlaufend[0];
|
|
125
137
|
// Rest aus dem Originaltext (nicht aus den schmal umbrochenen Stuecken), damit
|
|
126
138
|
// Bindestrich-/Hartbrueche der schmalen Spalte nicht als Leerzeichen zurueckbleiben.
|
|
127
|
-
const
|
|
128
|
-
|
|
139
|
+
const e = einzuege[i];
|
|
140
|
+
const rest = e > 0 ? restNach(z.columns[i].text.slice(e), teile[i][0].slice(e)) : restNach(z.columns[i].text, teile[i][0]);
|
|
141
|
+
for (const t of (e > 0 ? (0, escpos_js_1.wrapText)(rest, zeichen - e).map((x) => ' '.repeat(e) + x) : (0, escpos_js_1.wrapText)(rest, zeichen)))
|
|
129
142
|
lines.push({ text: ausrichten(t, zeichen, z.columns[i].align), kind: 'columns', bold: z.bold === true });
|
|
130
143
|
}
|
|
131
144
|
break;
|
|
@@ -14,6 +14,7 @@ const index_js_1 = require("../enums/index.js");
|
|
|
14
14
|
const index_js_2 = require("../models/index.js");
|
|
15
15
|
const vienna_time_js_1 = require("../vienna-time.js");
|
|
16
16
|
const errors_js_1 = require("../client/errors.js");
|
|
17
|
+
const zusaetze_js_1 = require("../pos/zusaetze.js");
|
|
17
18
|
exports.CURRENT_LAYOUT_RULESET = 2;
|
|
18
19
|
/** Die Optionen von [buildReceiptLayout]; jede andere wird abgewiesen. */
|
|
19
20
|
const LAYOUT_OPTIONEN = new Set(['paperSize', 'ruleset', 'testCashregister', 'testSignature', 'registrationInfo']);
|
|
@@ -830,8 +831,10 @@ function trinkgeldZeilen(name, teile) {
|
|
|
830
831
|
* Aufteilung als Fussnote darunter (siehe trinkgeldZeilen).
|
|
831
832
|
*/
|
|
832
833
|
const rabattZeilen = trinkgeldZeilen;
|
|
833
|
-
/**
|
|
834
|
-
|
|
834
|
+
/** Vorsatz einer Zusatzzeile (Zusatz-Kacheln, 1.27.0): eingerueckt unter der Hauptposition. */
|
|
835
|
+
const ZUSATZ_VORSATZ = ' + ';
|
|
836
|
+
/** Positionszeile: Menge, Bezeichnung, ab Menge 2 der Einzelpreis; ein Zusatz eingerueckt mit „+ “. */
|
|
837
|
+
function positionsZeile(item, satz, zusatz = false) {
|
|
835
838
|
const menge = String(item.quantity);
|
|
836
839
|
// Vorbild: Menge auf zwei Zeichen auffuellen, danach ' x ' — bei drei- und
|
|
837
840
|
// mehrstelligen Mengen faellt das Leerzeichen dahinter weg.
|
|
@@ -841,7 +844,7 @@ function positionsZeile(item, satz) {
|
|
|
841
844
|
return {
|
|
842
845
|
kind: 'columns',
|
|
843
846
|
columns: [
|
|
844
|
-
{ text: `${kopf}${item.name}${einzelpreis}`, width: 7, align: 'left' },
|
|
847
|
+
{ text: `${zusatz ? ZUSATZ_VORSATZ : ''}${kopf}${item.name}${einzelpreis}`, width: 7, align: 'left' },
|
|
845
848
|
{ text: `${formatCents((0, index_js_2.receiptItemTotalCents)(item))} ${satz.category}`, width: 5, align: 'right' },
|
|
846
849
|
],
|
|
847
850
|
};
|
|
@@ -1165,22 +1168,26 @@ function buildReceiptLayout(receipt, company, options = {}) {
|
|
|
1165
1168
|
.reduce((summe, it) => summe + (0, index_js_2.receiptItemTotalCents)(it), 0);
|
|
1166
1169
|
let zwischensummeGezeigt = false;
|
|
1167
1170
|
const gutscheinZuordnung = gutscheinPositionen(receipt);
|
|
1171
|
+
// Zusatz-Kacheln: Zusaetze direkt unter ihrer Hauptposition (stabil); ohne
|
|
1172
|
+
// Verweise ist die Reihenfolge die des Belegs (byte-gleich).
|
|
1173
|
+
const reihe = (0, zusaetze_js_1.addOnDisplayOrder)(receipt.items);
|
|
1174
|
+
const an = (k) => receipt.items[reihe[k]];
|
|
1168
1175
|
let i = 0;
|
|
1169
|
-
while (i <
|
|
1170
|
-
const item =
|
|
1176
|
+
while (i < reihe.length) {
|
|
1177
|
+
const item = an(i);
|
|
1171
1178
|
if (!(0, index_js_2.isTipItem)(item) && !(0, index_js_2.isDiscountItem)(item)) {
|
|
1172
1179
|
const satz = steuersatz(item.vat);
|
|
1173
1180
|
gruppeVon(satz).bruttoCents += (0, index_js_2.receiptItemTotalCents)(item);
|
|
1174
|
-
const gutschein = gutscheinZuordnung.get(i);
|
|
1175
|
-
lines.push(...(gutschein ? gutscheinPositionsZeilen(item, satz, gutschein) : [positionsZeile(item, satz)]));
|
|
1181
|
+
const gutschein = gutscheinZuordnung.get(reihe[i]);
|
|
1182
|
+
lines.push(...(gutschein ? gutscheinPositionsZeilen(item, satz, gutschein) : [positionsZeile(item, satz, (0, zusaetze_js_1.istGueltigerZusatz)(receipt.items, reihe[i]))]));
|
|
1176
1183
|
i += 1;
|
|
1177
1184
|
continue;
|
|
1178
1185
|
}
|
|
1179
1186
|
const artVon = (it) => ((0, index_js_2.isTipItem)(it) ? 'tip' : 'discount');
|
|
1180
1187
|
const art = artVon(item);
|
|
1181
1188
|
const gruppe = [];
|
|
1182
|
-
while (i <
|
|
1183
|
-
gruppe.push(
|
|
1189
|
+
while (i < reihe.length && artVon(an(i)) === art && !(!(0, index_js_2.isTipItem)(an(i)) && !(0, index_js_2.isDiscountItem)(an(i))) && an(i).name === item.name) {
|
|
1190
|
+
gruppe.push(an(i));
|
|
1184
1191
|
i += 1;
|
|
1185
1192
|
}
|
|
1186
1193
|
const teile = [];
|
package/dist/cjs/stored/draht.js
CHANGED
|
@@ -313,5 +313,9 @@ function _storedArticleToWire(id, doc, functionName = 'fromStoredArticle') {
|
|
|
313
313
|
const kachel = regel(regel(schema.data.articles).unter.tile).unter;
|
|
314
314
|
raus.tile = nurBekannte(raus.tile, new Set(Object.keys(kachel)));
|
|
315
315
|
}
|
|
316
|
+
if ((0, exports.istObjekt)(raus.reference)) {
|
|
317
|
+
const referenz = regel(regel(schema.data.articles).unter.reference).unter;
|
|
318
|
+
raus.reference = nurBekannte(raus.reference, new Set(Object.keys(referenz)), { mode: katalog('articles[].reference.mode') });
|
|
319
|
+
}
|
|
316
320
|
return raus;
|
|
317
321
|
}
|
|
@@ -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 = "842340e1f94c14fab01ffe96277d76dff4482b97df2e355daa583ff49c2db634";
|
|
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 {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.KATALOGE = exports.ARTIKEL_FELDER = exports.SCHEMAS = exports.VOKABULAR_QUELLE = void 0;
|
|
6
6
|
/** Fingerabdruck des Vertrags-Exports, aus dem diese Datei stammt (`_quelle.sha256`). */
|
|
7
|
-
exports.VOKABULAR_QUELLE = "
|
|
7
|
+
exports.VOKABULAR_QUELLE = "842340e1f94c14fab01ffe96277d76dff4482b97df2e355daa583ff49c2db634";
|
|
8
8
|
/** Schema je Endpunkt (aussen -> innen) und Wertverweise auf die Kataloge. */
|
|
9
9
|
exports.SCHEMAS = {
|
|
10
10
|
"getReceipt": {
|
|
@@ -22,7 +22,8 @@ exports.SCHEMAS = {
|
|
|
22
22
|
{
|
|
23
23
|
"__": "items",
|
|
24
24
|
"receivedImmediately": "sofortErhalten",
|
|
25
|
-
"keptByEmployee": "direkt"
|
|
25
|
+
"keptByEmployee": "direkt",
|
|
26
|
+
"addOnOf": "zusatzZu"
|
|
26
27
|
}
|
|
27
28
|
],
|
|
28
29
|
"manualReceipt": {
|
|
@@ -381,7 +382,17 @@ exports.SCHEMAS = {
|
|
|
381
382
|
"sort": "sort"
|
|
382
383
|
},
|
|
383
384
|
"stockLocationIds": "standorte",
|
|
384
|
-
"minStockByLocation": "mindestJeStandort"
|
|
385
|
+
"minStockByLocation": "mindestJeStandort",
|
|
386
|
+
"askPrice": "preisFragen",
|
|
387
|
+
"reference": {
|
|
388
|
+
"__": "referenz",
|
|
389
|
+
"mode": "stufe",
|
|
390
|
+
"label": "bezeichnung",
|
|
391
|
+
"hint": "hinweis",
|
|
392
|
+
"pattern": "muster",
|
|
393
|
+
"patternStrict": "musterStreng"
|
|
394
|
+
},
|
|
395
|
+
"addOns": "zusaetze"
|
|
385
396
|
}
|
|
386
397
|
]
|
|
387
398
|
},
|
|
@@ -391,6 +402,9 @@ exports.SCHEMAS = {
|
|
|
391
402
|
},
|
|
392
403
|
"articles[].e1aGroup": {
|
|
393
404
|
"$catalog": "E1A_GRUPPE"
|
|
405
|
+
},
|
|
406
|
+
"articles[].reference.mode": {
|
|
407
|
+
"$catalog": "REFERENZ_STUFE"
|
|
394
408
|
}
|
|
395
409
|
}
|
|
396
410
|
}
|
|
@@ -421,7 +435,10 @@ exports.ARTIKEL_FELDER = [
|
|
|
421
435
|
"groupId",
|
|
422
436
|
"tile",
|
|
423
437
|
"stockLocationIds",
|
|
424
|
-
"minStockByLocation"
|
|
438
|
+
"minStockByLocation",
|
|
439
|
+
"askPrice",
|
|
440
|
+
"reference",
|
|
441
|
+
"addOns"
|
|
425
442
|
];
|
|
426
443
|
/** Wertkataloge innen (deutsch) -> aussen (englisch). */
|
|
427
444
|
exports.KATALOGE = {
|
|
@@ -692,6 +709,10 @@ exports.KATALOGE = {
|
|
|
692
709
|
"stueck": "piece",
|
|
693
710
|
"dezimal": "decimal"
|
|
694
711
|
},
|
|
712
|
+
"REFERENZ_STUFE": {
|
|
713
|
+
"fragen": "optional",
|
|
714
|
+
"pflicht": "required"
|
|
715
|
+
},
|
|
695
716
|
"STORNO_GRUND": {
|
|
696
717
|
"fehleingabe": "input_error",
|
|
697
718
|
"kunde_storniert": "customer_cancelled",
|
package/dist/cjs/version.d.ts
CHANGED
package/dist/cjs/version.js
CHANGED
|
@@ -18,7 +18,7 @@ import { KasseneckApiError } from '../client/errors.js';
|
|
|
18
18
|
* ...) stehen in [PAYMENT_ERROR_CODES]. Ein Code ausserhalb bleibt ueber
|
|
19
19
|
* `KasseneckApiError.code` lesbar.
|
|
20
20
|
*/
|
|
21
|
-
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"];
|
|
21
|
+
export declare const RECEIPT_ERROR_CODES: readonly ["cancellation_reference_unavailable", "cashregister_closed", "cashregister_decommissioned", "final_receipt_expired", "final_receipt_not_allowed", "idempotency_conflict", "invalid_add_on_reference", "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"];
|
|
22
22
|
export type ReceiptErrorCode = (typeof RECEIPT_ERROR_CODES)[number];
|
|
23
23
|
export declare function isReceiptErrorCode(value: unknown): value is ReceiptErrorCode;
|
|
24
24
|
/** Der Code eines geworfenen Fehlers, wenn er in [RECEIPT_ERROR_CODES] steht; sonst `undefined`. */
|
|
@@ -27,6 +27,8 @@ export const RECEIPT_ERROR_CODES = Object.freeze([
|
|
|
27
27
|
// Seit 1.15.0 (Vertrag): derselbe idempotencyKey mit anderem Inhalt, nichts geschrieben. Seit 1.22.0 sendet
|
|
28
28
|
// dieses Paket den Schluessel, wenn der Aufrufer ihn angibt (`idempotencyKey` an sellReceipt/createReceipt).
|
|
29
29
|
'idempotency_conflict',
|
|
30
|
+
// Seit 1.27.0 (Zusatz-Kacheln): addOnOf zeigt nicht nach vorne auf eine Warenposition, die selbst kein Zusatz ist.
|
|
31
|
+
'invalid_add_on_reference',
|
|
30
32
|
'module_inactive',
|
|
31
33
|
'not_permitted',
|
|
32
34
|
'receipt_limit_exceeded',
|
|
@@ -61,6 +61,12 @@ export interface ReceiptItem {
|
|
|
61
61
|
originalIndex?: number;
|
|
62
62
|
/** Nur an Storno-Zeilen mit `articleId`: wohin die Ware ging (Lager-Kern Stufe 2). */
|
|
63
63
|
returnDisposition?: ReturnDisposition;
|
|
64
|
+
/**
|
|
65
|
+
* Zusatz-Kacheln (1.27.0): Index der Hauptposition im selben Beleg; nur an
|
|
66
|
+
* Zusatzpositionen. Der Server prueft: ganze Zahl, zeigt nach vorne auf eine
|
|
67
|
+
* Warenposition, die selbst kein Zusatz ist (`invalid_add_on_reference`).
|
|
68
|
+
*/
|
|
69
|
+
addOnOf?: number;
|
|
64
70
|
}
|
|
65
71
|
/** Empfaenger einer Trinkgeld-Position (Kassen-Benutzer, Snapshot des Namens). */
|
|
66
72
|
export interface TipRecipient {
|
|
@@ -99,6 +105,8 @@ export interface ReceiptItemPayload {
|
|
|
99
105
|
keptByEmployee?: boolean;
|
|
100
106
|
/** Artikel-Verweis, siehe [ReceiptItem.articleId]. */
|
|
101
107
|
articleId?: string;
|
|
108
|
+
/** Hauptposition eines Zusatzes, siehe [ReceiptItem.addOnOf]. */
|
|
109
|
+
addOnOf?: number;
|
|
102
110
|
}
|
|
103
111
|
/**
|
|
104
112
|
* Nutzlast-Form, die dieses Paket **liest** — v2 und v1 nebeneinander, alles
|
|
@@ -144,6 +152,8 @@ export interface ReceiptItemPayloadRead {
|
|
|
144
152
|
originalIndex?: number | null;
|
|
145
153
|
/** Storno-Zeile mit `articleId`: Rueckgabe-Wahl, siehe [ReceiptItem.returnDisposition]. */
|
|
146
154
|
returnDisposition?: string | null;
|
|
155
|
+
/** Hauptposition eines Zusatzes, siehe [ReceiptItem.addOnOf]. */
|
|
156
|
+
addOnOf?: number | null;
|
|
147
157
|
}
|
|
148
158
|
export declare function toReceiptItemPayload(item: ReceiptItem): ReceiptItemPayload;
|
|
149
159
|
/**
|
|
@@ -57,6 +57,9 @@ export function toReceiptItemPayload(item) {
|
|
|
57
57
|
// Artikel-Verweis reist mit (Erloesgruppen im Bericht); leere Werte nicht.
|
|
58
58
|
if (item.articleId != null && item.articleId !== '')
|
|
59
59
|
nutzlast.articleId = item.articleId;
|
|
60
|
+
// Zusatz-Kacheln: Verweis auf die Hauptposition nur, wenn gesetzt.
|
|
61
|
+
if (istIndex(item.addOnOf))
|
|
62
|
+
nutzlast.addOnOf = item.addOnOf;
|
|
60
63
|
return nutzlast;
|
|
61
64
|
}
|
|
62
65
|
/**
|
|
@@ -107,8 +110,13 @@ export function fromReceiptItemPayload(payload) {
|
|
|
107
110
|
// unbekannter Wert faellt weg wie am Rand des Servers).
|
|
108
111
|
...(Number.isInteger(payload.originalIndex) && payload.originalIndex >= 0 ? { originalIndex: payload.originalIndex } : {}),
|
|
109
112
|
...(isReturnDisposition(payload.returnDisposition) ? { returnDisposition: payload.returnDisposition } : {}),
|
|
113
|
+
// Zusatz-Kacheln: Verweis auf die Hauptposition (nur eine ganze Zahl >= 0).
|
|
114
|
+
...(istIndex(payload.addOnOf) ? { addOnOf: payload.addOnOf } : {}),
|
|
110
115
|
};
|
|
111
116
|
}
|
|
117
|
+
function istIndex(wert) {
|
|
118
|
+
return Number.isInteger(wert) && wert >= 0;
|
|
119
|
+
}
|
|
112
120
|
/** Erster brauchbarer Zahlenwert der Reihe; `null`/`undefined`/NaN zaehlen nicht. */
|
|
113
121
|
function ersteZahl(...werte) {
|
|
114
122
|
for (const wert of werte) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { InternerTransport } from '../client/aufrufe.js';
|
|
2
|
+
import { type PosReference } from './kachel-referenz.js';
|
|
2
3
|
/**
|
|
3
4
|
* Artikelgruppen (Kategorien der Kachel-Kasse) und Artikel in der Form, die
|
|
4
5
|
* die Kacheln brauchen, Backend: `article-endpoints.js`
|
|
@@ -13,6 +14,13 @@ export interface ArticleGroup {
|
|
|
13
14
|
symbol: string | null;
|
|
14
15
|
sort: number;
|
|
15
16
|
vatRate: number | null;
|
|
17
|
+
/**
|
|
18
|
+
* Zusaetze der Gruppe (Zusatz-Kacheln, 1.27.0): Artikel-Kennungen in der
|
|
19
|
+
* Reihenfolge des Fensters; null = keine. Optional, damit bestehende Literale
|
|
20
|
+
* weiter uebersetzen; der Leser setzt das Feld immer. Wirksam wird die Liste
|
|
21
|
+
* erst ueber [addOnsFor].
|
|
22
|
+
*/
|
|
23
|
+
addOns?: string[] | null;
|
|
16
24
|
}
|
|
17
25
|
export interface ArticleGroupPayload {
|
|
18
26
|
id?: string | null;
|
|
@@ -21,7 +29,10 @@ export interface ArticleGroupPayload {
|
|
|
21
29
|
symbol?: string | null;
|
|
22
30
|
sort?: number | null;
|
|
23
31
|
vatRate?: number | null;
|
|
32
|
+
addOns?: unknown;
|
|
24
33
|
}
|
|
34
|
+
/** Zusatzliste am Draht: nur eine Liste von Texten zaehlt, sonst null. Paketintern. */
|
|
35
|
+
export declare function addOnListe(wert: unknown): string[] | null;
|
|
25
36
|
export declare function fromArticleGroupPayload(p: ArticleGroupPayload): ArticleGroup;
|
|
26
37
|
/**
|
|
27
38
|
* Mengenregel eines Artikels (Draht `quantityRule`): `piece` = ganze Stueck
|
|
@@ -96,7 +107,32 @@ export interface PosArticle {
|
|
|
96
107
|
* ausdrueckliches `true` gilt.
|
|
97
108
|
*/
|
|
98
109
|
serviceVoucher?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Kasse fragt beim Antippen den Betrag (Kachel mit Betrag und Referenz,
|
|
112
|
+
* 1.26.0); ein vorhandener Preis ist Vorschlag. Optional wie
|
|
113
|
+
* `serviceVoucher`, der Leser setzt es immer: nur ein ausdrueckliches `true` gilt.
|
|
114
|
+
*/
|
|
115
|
+
askPrice?: boolean;
|
|
116
|
+
/** Kasse fragt beim Antippen eine Referenz ab; null = aus. Der Leser setzt es immer. */
|
|
117
|
+
reference?: PosReference | null;
|
|
118
|
+
/**
|
|
119
|
+
* Eigene Zusatzliste (Zusatz-Kacheln, 1.27.0): null = wie die Gruppe, [] =
|
|
120
|
+
* keine, sonst die Liste in der Reihenfolge des Fensters. Der Leser setzt es
|
|
121
|
+
* immer; wirksam wird es ueber [addOnsFor].
|
|
122
|
+
*/
|
|
123
|
+
addOns?: string[] | null;
|
|
99
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* Kann die Kachel gebucht werden? Mit festem Preis immer, ohne Preis nur mit
|
|
127
|
+
* `askPrice` (der Betrag kommt aus dem Eingabeblatt).
|
|
128
|
+
*/
|
|
129
|
+
export declare function isBookableArticle(a: Pick<PosArticle, 'unitPriceCents' | 'askPrice'>): boolean;
|
|
130
|
+
/** Fragt die Kachel beim Antippen etwas ab (Betrag, Referenz oder Menge)? */
|
|
131
|
+
export declare function tilePrompts(a: Pick<PosArticle, 'askPrice' | 'reference' | 'unit' | 'quantityRule' | 'askQuantity'>): {
|
|
132
|
+
amount: boolean;
|
|
133
|
+
reference: boolean;
|
|
134
|
+
quantity: boolean;
|
|
135
|
+
};
|
|
100
136
|
/** Deckelt eine gewuenschte Menge an der Hoechstmenge des Artikels (null = keine Grenze). */
|
|
101
137
|
export declare function allowedQuantity(a: Pick<PosArticle, 'maxQuantity'>, wanted: number): number;
|
|
102
138
|
/** Ein Artikel am Draht `/api/v3` (`listMyArticles`), soweit dieses Paket ihn liest. */
|
|
@@ -122,6 +158,9 @@ export interface PosArticlePayload {
|
|
|
122
158
|
internalCode?: string | null;
|
|
123
159
|
stockTracked?: boolean | null;
|
|
124
160
|
serviceVoucher?: boolean | null;
|
|
161
|
+
askPrice?: boolean | null;
|
|
162
|
+
reference?: unknown;
|
|
163
|
+
addOns?: unknown;
|
|
125
164
|
}
|
|
126
165
|
export declare function fromPosArticlePayload(p: PosArticlePayload): PosArticle;
|
|
127
166
|
/**
|
package/dist/esm/pos/artikel.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { KasseneckValidationError } from '../client/errors.js';
|
|
2
|
+
import { fromReferencePayload } from './kachel-referenz.js';
|
|
3
|
+
/** Zusatzliste am Draht: nur eine Liste von Texten zaehlt, sonst null. Paketintern. */
|
|
4
|
+
export function addOnListe(wert) {
|
|
5
|
+
return Array.isArray(wert) ? wert.filter((s) => typeof s === 'string' && s !== '') : null;
|
|
6
|
+
}
|
|
2
7
|
export function fromArticleGroupPayload(p) {
|
|
3
8
|
return {
|
|
4
9
|
id: p.id ?? '',
|
|
@@ -7,6 +12,7 @@ export function fromArticleGroupPayload(p) {
|
|
|
7
12
|
symbol: p.symbol ?? null,
|
|
8
13
|
sort: typeof p.sort === 'number' ? p.sort : 0,
|
|
9
14
|
vatRate: typeof p.vatRate === 'number' ? p.vatRate : null,
|
|
15
|
+
addOns: addOnListe(p.addOns),
|
|
10
16
|
};
|
|
11
17
|
}
|
|
12
18
|
/**
|
|
@@ -41,6 +47,17 @@ export function quantityDefaults(a) {
|
|
|
41
47
|
decimals: (a.quantityRule ?? v.rule) === 'decimal' ? Math.max(1, v.decimals || 2) : 0,
|
|
42
48
|
};
|
|
43
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Kann die Kachel gebucht werden? Mit festem Preis immer, ohne Preis nur mit
|
|
52
|
+
* `askPrice` (der Betrag kommt aus dem Eingabeblatt).
|
|
53
|
+
*/
|
|
54
|
+
export function isBookableArticle(a) {
|
|
55
|
+
return a.askPrice === true || (typeof a.unitPriceCents === 'number' && Number.isInteger(a.unitPriceCents) && a.unitPriceCents >= 0);
|
|
56
|
+
}
|
|
57
|
+
/** Fragt die Kachel beim Antippen etwas ab (Betrag, Referenz oder Menge)? */
|
|
58
|
+
export function tilePrompts(a) {
|
|
59
|
+
return { amount: a.askPrice === true, reference: a.reference != null, quantity: quantityDefaults(a).ask };
|
|
60
|
+
}
|
|
44
61
|
/** Deckelt eine gewuenschte Menge an der Hoechstmenge des Artikels (null = keine Grenze). */
|
|
45
62
|
export function allowedQuantity(a, wanted) {
|
|
46
63
|
return a.maxQuantity != null && a.maxQuantity > 0 ? Math.min(wanted, a.maxQuantity) : wanted;
|
|
@@ -72,6 +89,9 @@ export function fromPosArticlePayload(p) {
|
|
|
72
89
|
internalCode: textOderNull(p.internalCode),
|
|
73
90
|
stockTracked: typeof p.stockTracked === 'boolean' ? p.stockTracked : null,
|
|
74
91
|
serviceVoucher: p.serviceVoucher === true,
|
|
92
|
+
askPrice: p.askPrice === true,
|
|
93
|
+
reference: fromReferencePayload(p.reference),
|
|
94
|
+
addOns: addOnListe(p.addOns),
|
|
75
95
|
};
|
|
76
96
|
}
|
|
77
97
|
/**
|
package/dist/esm/pos/index.d.ts
CHANGED
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
* und sprechen den Kassenweg `/api/v3` (Schluessel und Werte englisch).
|
|
8
8
|
*/
|
|
9
9
|
export { type PosTheme, type PosFontSize, type PosWatermark, type PosQuantity, type PosTipMode, type PosCheckoutMode, type PosCardProvider, type PosReceiptOutput, type PosShortcutAction, type PosShortcutMap, POS_SHORTCUT_ACTIONS, POS_SHORTCUT_DEFAULTS, type PosLayout, type PosCategoryPosition, type PosTileHeight, type PosPrinterType, type PosTerminalVia, type PosTerminalType, type PosPaperSize, type PosCodePage, type PosCut, type PosDrawerAutoOpen, type PosQrMode, type PosLogoSize, type PosSettingsFontSize, type PosTileStyle, type PosAutoLogoutMinutes, type PosDiscount, type PosWatermarkSide, type PosWatermarkStrength, type PosLogoScale, type PosWatermarkScale, type PosDoneScreenSeconds, type PosToggleMap, type PosBusinessSettings, type PosDeviceSettings, type PosSettings, POS_BUSINESS_DEFAULTS, POS_DEVICE_DEFAULTS, POS_DEVICE_OPTIONAL_FIELDS, POS_BUSINESS_OPTIONAL_FIELDS, posTipKeptByDefault, POS_BUSINESS_VALUES, POS_DEVICE_VALUES, mergePosSettings, sanitizePosSettings, unknownPosSettingValues, posSettingsChanges, type PosOpen, POS_SHORTCUT_SHARED_PAIRS, posShortcutConflict, THEME, FONT_SIZE, WATERMARK, QUANTITY, TIP_MODE, CHECKOUT_MODE, CARD_PROVIDER, RECEIPT_OUTPUT, LAYOUT, CATEGORY_POSITION, TILE_HEIGHT, PRINTER_TYPE, TERMINAL_VIA, TERMINAL_TYPE, PAPER_SIZE, CODE_PAGE, CUT, DRAWER_AUTO_OPEN, QR_MODE, LOGO_SIZE, SETTINGS_FONT_SIZE, TILE_STYLE, AUTO_LOGOUT_MINUTES, DISCOUNT, WATERMARK_SIDE, WATERMARK_STRENGTH, LOGO_SCALE, WATERMARK_SCALE, DONE_SCREEN_SECONDS, } from './settings.js';
|
|
10
|
-
export { type ArticleGroup, type ArticleGroupPayload, fromArticleGroupPayload, type PosArticle, type PosArticlePayload, fromPosArticlePayload, listMyArticleGroups, listMyArticles, QUANTITY_RULES, type QuantityRule, type QuantityDefaults, quantityRuleForUnit, quantityDefaults, allowedQuantity, } from './artikel.js';
|
|
10
|
+
export { type ArticleGroup, type ArticleGroupPayload, fromArticleGroupPayload, type PosArticle, type PosArticlePayload, fromPosArticlePayload, listMyArticleGroups, listMyArticles, QUANTITY_RULES, type QuantityRule, type QuantityDefaults, quantityRuleForUnit, quantityDefaults, allowedQuantity, isBookableArticle, tilePrompts, } from './artikel.js';
|
|
11
|
+
export { REFERENCE_MODES, type ReferenceMode, type PosReference, REFERENCE_INPUT_MAX, REFERENCE_LABEL_MAX, REFERENCE_HINT_MAX, REFERENCE_PATTERN_MAX, REFERENCE_PATTERN_TEMPLATES, cleanReferenceText, isValidReferencePattern, isDigitsOnlyPattern, type ReferenceCheckResult, checkReference, referenceLineName, fromReferencePayload, } from './kachel-referenz.js';
|
|
12
|
+
export { ADD_ONS_MAX, ADD_ON_BLOCK_REASONS, type AddOnBlockReason, isSelectableAddOn, addOnsFor, addOnReferencesValid, addOnsOfItem, addOnRemap, addOnDisplayOrder, orderAddOnLines, } from './zusaetze.js';
|
|
11
13
|
export { getPosSettings, setMyPosSettings, setMyRegisterDeviceSettings, setMyPosLogo, posSettingsFromWire, type SetMyPosLogoOptions, } from './client.js';
|
|
12
14
|
export { POS_ERROR_CODES, type PosErrorCode, isPosErrorCode, posErrorCode, isPosError, type PosFieldError, posFieldErrors, } from './errors.js';
|
|
13
15
|
export { distributeDiscount } from '../receipt/discount.js';
|
package/dist/esm/pos/index.js
CHANGED
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
export { POS_SHORTCUT_ACTIONS, POS_SHORTCUT_DEFAULTS, POS_BUSINESS_DEFAULTS, POS_DEVICE_DEFAULTS, POS_DEVICE_OPTIONAL_FIELDS, POS_BUSINESS_OPTIONAL_FIELDS, posTipKeptByDefault, POS_BUSINESS_VALUES, POS_DEVICE_VALUES, mergePosSettings, sanitizePosSettings, unknownPosSettingValues, posSettingsChanges, POS_SHORTCUT_SHARED_PAIRS, posShortcutConflict,
|
|
10
10
|
// Die Enums als Laufzeitlisten, benannt nach ihrem Feld.
|
|
11
11
|
THEME, FONT_SIZE, WATERMARK, QUANTITY, TIP_MODE, CHECKOUT_MODE, CARD_PROVIDER, RECEIPT_OUTPUT, LAYOUT, CATEGORY_POSITION, TILE_HEIGHT, PRINTER_TYPE, TERMINAL_VIA, TERMINAL_TYPE, PAPER_SIZE, CODE_PAGE, CUT, DRAWER_AUTO_OPEN, QR_MODE, LOGO_SIZE, SETTINGS_FONT_SIZE, TILE_STYLE, AUTO_LOGOUT_MINUTES, DISCOUNT, WATERMARK_SIDE, WATERMARK_STRENGTH, LOGO_SCALE, WATERMARK_SCALE, DONE_SCREEN_SECONDS, } from './settings.js';
|
|
12
|
-
export { fromArticleGroupPayload, fromPosArticlePayload, listMyArticleGroups, listMyArticles, QUANTITY_RULES, quantityRuleForUnit, quantityDefaults, allowedQuantity, } from './artikel.js';
|
|
12
|
+
export { fromArticleGroupPayload, fromPosArticlePayload, listMyArticleGroups, listMyArticles, QUANTITY_RULES, quantityRuleForUnit, quantityDefaults, allowedQuantity, isBookableArticle, tilePrompts, } from './artikel.js';
|
|
13
|
+
export { REFERENCE_MODES, REFERENCE_INPUT_MAX, REFERENCE_LABEL_MAX, REFERENCE_HINT_MAX, REFERENCE_PATTERN_MAX, REFERENCE_PATTERN_TEMPLATES, cleanReferenceText, isValidReferencePattern, isDigitsOnlyPattern, checkReference, referenceLineName, fromReferencePayload, } from './kachel-referenz.js';
|
|
14
|
+
export { ADD_ONS_MAX, ADD_ON_BLOCK_REASONS, isSelectableAddOn, addOnsFor, addOnReferencesValid, addOnsOfItem, addOnRemap, addOnDisplayOrder, orderAddOnLines, } from './zusaetze.js';
|
|
13
15
|
export { getPosSettings, setMyPosSettings, setMyRegisterDeviceSettings, setMyPosLogo, posSettingsFromWire, } from './client.js';
|
|
14
16
|
export { POS_ERROR_CODES, isPosErrorCode, posErrorCode, isPosError, posFieldErrors, } from './errors.js';
|
|
15
17
|
export { distributeDiscount } from '../receipt/discount.js';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kachel mit Betrag und Referenz: eine Kachel fragt beim Antippen den Betrag
|
|
3
|
+
* (`askPrice`) und/oder eine Referenz (Honorarnote, Auftragsnummer) ab.
|
|
4
|
+
* Dieselben Regeln rechnen das Backend (`kachel-referenz-core.js`) und das
|
|
5
|
+
* Dart-Paket; der Vertrag sind die Pruefaelle `fixtures/reference-cases.json`.
|
|
6
|
+
*/
|
|
7
|
+
/** `optional` = darf leer bleiben, `required` = Pflicht. */
|
|
8
|
+
export declare const REFERENCE_MODES: readonly ["optional", "required"];
|
|
9
|
+
export type ReferenceMode = typeof REFERENCE_MODES[number];
|
|
10
|
+
/** Einstellung am Artikel (Draht `reference`). */
|
|
11
|
+
export interface PosReference {
|
|
12
|
+
mode: ReferenceMode;
|
|
13
|
+
/** Titel des Eingabefelds („Honorarnote Nr.“); steht nie am Beleg. */
|
|
14
|
+
label: string;
|
|
15
|
+
/** Platzhalter/Hilfetext („z. B. 2026/0123“); null = keiner. */
|
|
16
|
+
hint: string | null;
|
|
17
|
+
/** Regulaerer Ausdruck fuer die ganze Eingabe (ohne ^/$); null = keiner. */
|
|
18
|
+
pattern: string | null;
|
|
19
|
+
/** true = falsches Format sperrt, false = nur Warnung. */
|
|
20
|
+
patternStrict: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** Hoechstlaenge der Eingabe an der Kasse. */
|
|
23
|
+
export declare const REFERENCE_INPUT_MAX = 40;
|
|
24
|
+
export declare const REFERENCE_LABEL_MAX = 30;
|
|
25
|
+
export declare const REFERENCE_HINT_MAX = 60;
|
|
26
|
+
export declare const REFERENCE_PATTERN_MAX = 200;
|
|
27
|
+
/** Vorlagen fuer das Musterfeld im Panel. */
|
|
28
|
+
export declare const REFERENCE_PATTERN_TEMPLATES: readonly {
|
|
29
|
+
key: 'digits' | 'year_number' | 'letters_digits';
|
|
30
|
+
pattern: string;
|
|
31
|
+
}[];
|
|
32
|
+
/**
|
|
33
|
+
* Eingabe an der Kasse: ohne Steuer- und Formatzeichen, Leerraum
|
|
34
|
+
* zusammengezogen und getrimmt. Bewusst ohne NFC, damit Web und Dart gleich
|
|
35
|
+
* rechnen (Dart kennt keine Unicode-Normalisierung).
|
|
36
|
+
*/
|
|
37
|
+
export declare function cleanReferenceText(text: string): string;
|
|
38
|
+
/** Ist das Muster erlaubt (kompilierbar, ohne gesperrte Konstrukte)? */
|
|
39
|
+
export declare function isValidReferencePattern(pattern: string | null | undefined): boolean;
|
|
40
|
+
/** Reines Ziffernmuster -> die Kasse zeigt die Zifferntastatur. */
|
|
41
|
+
export declare function isDigitsOnlyPattern(pattern: string | null | undefined): boolean;
|
|
42
|
+
export type ReferenceCheckResult = 'ok' | 'empty' | 'warning' | 'error';
|
|
43
|
+
/**
|
|
44
|
+
* Prueft die Eingabe an der Kasse. `empty` und `error` sperren das Uebernehmen,
|
|
45
|
+
* `warning` zeigt den Hinweis und laesst uebernehmen. Ein ungueltiges Muster
|
|
46
|
+
* (Altbestand, fremder Client) gilt wie keines.
|
|
47
|
+
*/
|
|
48
|
+
export declare function checkReference(input: string | null | undefined, reference: Pick<PosReference, 'mode' | 'pattern' | 'patternStrict'> | null | undefined): {
|
|
49
|
+
result: ReferenceCheckResult;
|
|
50
|
+
value: string;
|
|
51
|
+
};
|
|
52
|
+
/** Positionsname am Beleg: Artikelname + Leerzeichen + Referenz (leer = nur der Name). */
|
|
53
|
+
export declare function referenceLineName(articleName: string, value: string | null | undefined): string;
|
|
54
|
+
/** Liest `reference` vom Draht; alles Unbrauchbare -> null. */
|
|
55
|
+
export declare function fromReferencePayload(p: unknown): PosReference | null;
|