@kreiseck/kasseneck-api 1.31.0 → 1.32.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 +8 -0
- package/dist/cjs/client/receipts.d.ts +11 -0
- package/dist/cjs/client/receipts.js +14 -0
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +8 -5
- package/dist/cjs/models/index.d.ts +1 -1
- package/dist/cjs/models/index.js +5 -2
- package/dist/cjs/models/receipt-errors.d.ts +1 -1
- package/dist/cjs/models/receipt-errors.js +9 -0
- package/dist/cjs/models/receipt-item.d.ts +44 -2
- package/dist/cjs/models/receipt-item.js +56 -1
- package/dist/cjs/models/receipt.d.ts +17 -0
- package/dist/cjs/models/receipt.js +9 -0
- package/dist/cjs/pos/artikel.d.ts +14 -0
- package/dist/cjs/pos/artikel.js +3 -0
- package/dist/cjs/pos/client.d.ts +1 -0
- package/dist/cjs/pos/client.js +3 -0
- package/dist/cjs/pos/errors.d.ts +1 -1
- package/dist/cjs/pos/errors.js +12 -0
- package/dist/cjs/pos/index.d.ts +4 -2
- package/dist/cjs/pos/index.js +24 -4
- package/dist/cjs/pos/leergut.d.ts +60 -0
- package/dist/cjs/pos/leergut.js +82 -0
- package/dist/cjs/pos/pfand.d.ts +144 -0
- package/dist/cjs/pos/pfand.js +382 -0
- package/dist/cjs/pos/settings.d.ts +3 -7
- package/dist/cjs/pos/settings.js +7 -0
- package/dist/cjs/pos/texte.d.ts +68 -0
- package/dist/cjs/pos/texte.js +40 -1
- package/dist/cjs/receipt/discount.js +3 -0
- package/dist/cjs/receipt/due.d.ts +6 -0
- package/dist/cjs/receipt/due.js +16 -5
- package/dist/cjs/receipt/gutschein-plan.d.ts +7 -1
- package/dist/cjs/receipt/gutschein-plan.js +16 -2
- package/dist/cjs/receipt/layout.js +108 -2
- package/dist/cjs/register/pairing.d.ts +15 -1
- package/dist/cjs/register/pairing.js +14 -1
- package/dist/cjs/stored/vokabular.d.ts +1 -1
- package/dist/cjs/stored/vokabular.js +72 -4
- 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 +8 -0
- package/dist/esm/client/receipts.d.ts +11 -0
- package/dist/esm/client/receipts.js +14 -0
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/models/index.d.ts +1 -1
- package/dist/esm/models/index.js +1 -1
- package/dist/esm/models/receipt-errors.d.ts +1 -1
- package/dist/esm/models/receipt-errors.js +9 -0
- package/dist/esm/models/receipt-item.d.ts +44 -2
- package/dist/esm/models/receipt-item.js +54 -1
- package/dist/esm/models/receipt.d.ts +17 -0
- package/dist/esm/models/receipt.js +9 -0
- package/dist/esm/pos/artikel.d.ts +14 -0
- package/dist/esm/pos/artikel.js +3 -0
- package/dist/esm/pos/client.d.ts +1 -0
- package/dist/esm/pos/client.js +3 -0
- package/dist/esm/pos/errors.d.ts +1 -1
- package/dist/esm/pos/errors.js +12 -0
- package/dist/esm/pos/index.d.ts +4 -2
- package/dist/esm/pos/index.js +4 -2
- package/dist/esm/pos/leergut.d.ts +60 -0
- package/dist/esm/pos/leergut.js +77 -0
- package/dist/esm/pos/pfand.d.ts +144 -0
- package/dist/esm/pos/pfand.js +371 -0
- package/dist/esm/pos/settings.d.ts +3 -7
- package/dist/esm/pos/settings.js +7 -0
- package/dist/esm/pos/texte.d.ts +68 -0
- package/dist/esm/pos/texte.js +38 -0
- package/dist/esm/receipt/discount.js +4 -1
- package/dist/esm/receipt/due.d.ts +6 -0
- package/dist/esm/receipt/due.js +17 -6
- package/dist/esm/receipt/gutschein-plan.d.ts +7 -1
- package/dist/esm/receipt/gutschein-plan.js +14 -2
- package/dist/esm/receipt/layout.js +109 -3
- package/dist/esm/register/pairing.d.ts +15 -1
- package/dist/esm/register/pairing.js +13 -1
- package/dist/esm/stored/vokabular.d.ts +1 -1
- package/dist/esm/stored/vokabular.js +72 -4
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/fixtures/deposit-cases.json +4758 -0
- package/fixtures/expected/deposit-return.grid32.txt +28 -0
- package/fixtures/expected/deposit-return.grid48.txt +28 -0
- package/fixtures/expected/deposit-return.lines.json +275 -0
- package/fixtures/expected/deposit-return.sheet32.json +194 -0
- package/fixtures/expected/deposit-return.sheet48.json +194 -0
- package/fixtures/expected/deposit.grid32.txt +34 -0
- package/fixtures/expected/deposit.grid48.txt +32 -0
- package/fixtures/expected/deposit.lines.json +316 -0
- package/fixtures/expected/deposit.sheet32.json +230 -0
- package/fixtures/expected/deposit.sheet48.json +218 -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 +16 -0
- package/fixtures/pos-texts.json +62 -1
- package/fixtures/receipts/deposit-return.json +63 -0
- package/fixtures/receipts/deposit.json +83 -0
- package/fixtures/return-code-cases.json +1338 -0
- package/fixtures/surface.json +44 -4
- 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 +428 -13
- 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 +42 -4
- package/fixtures/v3/stored/rechnungen.json +2 -2
- package/fixtures/v3/v3-vokabular.json +808 -27
- package/fixtures/v3/zahlbetrag-faelle.json +187 -3
- package/package.json +1 -1
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Pfand & Leergut an der Kasse: Pfandarten und Einstellungen aus
|
|
4
|
+
* `getKasseSettings` (Block `deposit`), Pfandliste am Artikel und an der
|
|
5
|
+
* Gruppe (`deposits`) und die Pfand-Angaben des Kassenobjekts aus
|
|
6
|
+
* `listRegisterUsersForDevice`. Alles nur Lesen und Schreiben der Formen; die
|
|
7
|
+
* Rechnung (Betrag, Staffel nach Tag) kommt in einem eigenen Modul.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.DEPOSIT_ON_PREMISES_DEFAULTS = exports.DEPOSIT_RETURN_MODES = exports.DEPOSIT_TYPES = exports.DEPOSIT_KINDS = void 0;
|
|
11
|
+
exports.posDepositSettingsFromWire = posDepositSettingsFromWire;
|
|
12
|
+
exports.depositEntriesFromWire = depositEntriesFromWire;
|
|
13
|
+
exports.cashRegisterDepositFromWire = cashRegisterDepositFromWire;
|
|
14
|
+
exports.depositsFor = depositsFor;
|
|
15
|
+
exports.depositAmountOn = depositAmountOn;
|
|
16
|
+
exports.viennaDay = viennaDay;
|
|
17
|
+
exports.withDepositLines = withDepositLines;
|
|
18
|
+
exports.depositReturnLine = depositReturnLine;
|
|
19
|
+
const validator_1 = require("@kreiseck/validator");
|
|
20
|
+
const enum_payload_js_1 = require("../models/enum-payload.js");
|
|
21
|
+
/** Art einer Pfandart: Einweg oder Mehrweg. */
|
|
22
|
+
exports.DEPOSIT_KINDS = ['single_use', 'reusable'];
|
|
23
|
+
/** Gebindetyp einer Pfandart (frei, nur zur Anzeige). */
|
|
24
|
+
exports.DEPOSIT_TYPES = ['bottle', 'crate', 'keg', 'cup', 'glass', 'other'];
|
|
25
|
+
/** Wer nimmt Leergut an der Kasse zurueck: diese Kasse, eine gemeinsame Stelle oder niemand. */
|
|
26
|
+
exports.DEPOSIT_RETURN_MODES = ['here', 'shared', 'none'];
|
|
27
|
+
/** Vorbelegung, ob Getraenke vor Ort getrunken oder mitgenommen werden. */
|
|
28
|
+
exports.DEPOSIT_ON_PREMISES_DEFAULTS = ['on_premises', 'takeaway', 'ask'];
|
|
29
|
+
const istObjekt = (w) => w !== null && typeof w === 'object' && !Array.isArray(w);
|
|
30
|
+
const istGanz = (w, min) => Number.isInteger(w) && w >= min;
|
|
31
|
+
function aus(liste, value) {
|
|
32
|
+
return typeof value === 'string' && liste.includes(value) ? value : null;
|
|
33
|
+
}
|
|
34
|
+
function betrag(value) {
|
|
35
|
+
if (!istObjekt(value) || typeof value['from'] !== 'string' || !istGanz(value['cents'], 0))
|
|
36
|
+
return null;
|
|
37
|
+
return { from: value['from'], cents: value['cents'] };
|
|
38
|
+
}
|
|
39
|
+
function pfandart(value) {
|
|
40
|
+
if (!istObjekt(value) || typeof value['id'] !== 'string' || value['id'] === '')
|
|
41
|
+
return null;
|
|
42
|
+
const kind = aus(exports.DEPOSIT_KINDS, value['kind']);
|
|
43
|
+
if (kind == null)
|
|
44
|
+
return null;
|
|
45
|
+
const rate = value['returnRate'];
|
|
46
|
+
return {
|
|
47
|
+
id: value['id'],
|
|
48
|
+
kind,
|
|
49
|
+
name: typeof value['name'] === 'string' ? value['name'] : '',
|
|
50
|
+
type: aus(exports.DEPOSIT_TYPES, value['type']),
|
|
51
|
+
amounts: Array.isArray(value['amounts']) ? value['amounts'].map(betrag).filter((b) => b != null) : [],
|
|
52
|
+
returnRate: typeof rate === 'number' && Number.isFinite(rate) ? rate : null,
|
|
53
|
+
used: value['used'] === true,
|
|
54
|
+
active: value['active'] !== false,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Den Block `deposit` einer Antwort lesen. Kein Objekt (Pfand aus, alter
|
|
59
|
+
* Server) -> `undefined`: das Feld fehlt dann am Modell, es wird nichts erfunden.
|
|
60
|
+
* Eine Pfandart in unbekannter Form faellt weg.
|
|
61
|
+
*/
|
|
62
|
+
function posDepositSettingsFromWire(value) {
|
|
63
|
+
if (!istObjekt(value))
|
|
64
|
+
return undefined;
|
|
65
|
+
return {
|
|
66
|
+
singleUse: value['singleUse'] === true,
|
|
67
|
+
reusable: value['reusable'] === true,
|
|
68
|
+
depositTypes: Array.isArray(value['depositTypes']) ? value['depositTypes'].map(pfandart).filter((a) => a != null) : [],
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/** Die Pfandliste eines Artikels oder einer Gruppe; keine Liste -> `null`, unlesbare Eintraege fallen weg. */
|
|
72
|
+
function depositEntriesFromWire(value) {
|
|
73
|
+
if (!Array.isArray(value))
|
|
74
|
+
return null;
|
|
75
|
+
const raus = [];
|
|
76
|
+
for (const e of value) {
|
|
77
|
+
if (!istObjekt(e) || typeof e['depositTypeId'] !== 'string' || e['depositTypeId'] === '' || !istGanz(e['quantity'], 1))
|
|
78
|
+
continue;
|
|
79
|
+
raus.push({
|
|
80
|
+
depositTypeId: e['depositTypeId'],
|
|
81
|
+
quantity: e['quantity'],
|
|
82
|
+
...(typeof e['gtin'] === 'string' && e['gtin'] !== '' ? { gtin: e['gtin'] } : {}),
|
|
83
|
+
...(typeof e['ownFilling'] === 'boolean' ? { ownFilling: e['ownFilling'] } : {}),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return raus;
|
|
87
|
+
}
|
|
88
|
+
/** Die Pfand-Angaben eines Kassenobjekts; fehlt der Block oder ist er unbrauchbar -> `undefined`. */
|
|
89
|
+
function cashRegisterDepositFromWire(value) {
|
|
90
|
+
if (!istObjekt(value))
|
|
91
|
+
return undefined;
|
|
92
|
+
const returns = aus(exports.DEPOSIT_RETURN_MODES, value['returns']);
|
|
93
|
+
const onPremisesDefault = aus(exports.DEPOSIT_ON_PREMISES_DEFAULTS, value['onPremisesDefault']);
|
|
94
|
+
if (returns == null || onPremisesDefault == null)
|
|
95
|
+
return undefined;
|
|
96
|
+
const stelle = value['sharedReturnPoint'];
|
|
97
|
+
return {
|
|
98
|
+
returns,
|
|
99
|
+
onPremisesDefault,
|
|
100
|
+
usualQuantity: istGanz(value['usualQuantity'], 1) ? value['usualQuantity'] : 1,
|
|
101
|
+
sharedReturnPoint: istObjekt(stelle) && typeof stelle['name'] === 'string'
|
|
102
|
+
? { name: stelle['name'], address: typeof stelle['address'] === 'string' ? stelle['address'] : '' }
|
|
103
|
+
: null,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
// ---------------------------------------------------------------------------------------------------------------
|
|
107
|
+
// Vorschau-Rechnung: dieselben Pfand- und Leergutzeilen wie der Server (`createReceipt`), damit der Korb sie vor
|
|
108
|
+
// dem Buchen zeigt. Vertrag sind die Pruefaelle `fixtures/deposit-cases.json` (Backend `pfand-faelle.json`).
|
|
109
|
+
// ---------------------------------------------------------------------------------------------------------------
|
|
110
|
+
/** EWP-GTIN der Einweg-Pfandzeile (gesetzlich festgelegt). */
|
|
111
|
+
const EWP_GTIN = '9010945000011';
|
|
112
|
+
/** Pfandangaben, wirksam fuer einen Artikel: Artikel vor Gruppe, `[]` = kein Pfand, `null`/fehlend = wie die Gruppe. */
|
|
113
|
+
function depositsFor(article, group) {
|
|
114
|
+
if (article == null)
|
|
115
|
+
return [];
|
|
116
|
+
if (article.externalVoucher != null)
|
|
117
|
+
return []; // fremde Gutscheine tragen nie Pfand, auch nicht von der Gruppe
|
|
118
|
+
if (Array.isArray(article.deposits))
|
|
119
|
+
return article.deposits;
|
|
120
|
+
if (group != null && Array.isArray(group.deposits))
|
|
121
|
+
return group.deposits;
|
|
122
|
+
return [];
|
|
123
|
+
}
|
|
124
|
+
/** Pfandbetrag in Cent am Wiener Tag `day` (`YYYY-MM-DD`): letzter Eintrag mit `from <= day`, sonst `null`. */
|
|
125
|
+
function depositAmountOn(type, day) {
|
|
126
|
+
let cents = null;
|
|
127
|
+
for (const e of type.amounts) {
|
|
128
|
+
if (e.from <= day)
|
|
129
|
+
cents = e.cents;
|
|
130
|
+
else
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
return cents;
|
|
134
|
+
}
|
|
135
|
+
const tagFormat = new Intl.DateTimeFormat('en-CA', { timeZone: 'Europe/Vienna', year: 'numeric', month: '2-digit', day: '2-digit' });
|
|
136
|
+
/** Wiener Kalendertag `YYYY-MM-DD` zum Zeitpunkt `nowMs` (nie der UTC-Tag). */
|
|
137
|
+
function viennaDay(nowMs) {
|
|
138
|
+
const teile = {};
|
|
139
|
+
for (const t of tagFormat.formatToParts(new Date(nowMs)))
|
|
140
|
+
teile[t.type] = t.value;
|
|
141
|
+
return `${teile['year']}-${teile['month']}-${teile['day']}`;
|
|
142
|
+
}
|
|
143
|
+
const istObj = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
144
|
+
const ganz = (v, min, max) => Number.isInteger(v) && v >= min && v <= max;
|
|
145
|
+
const nachId = (karte, id) => {
|
|
146
|
+
if (karte instanceof Map)
|
|
147
|
+
return karte.get(id);
|
|
148
|
+
return Object.prototype.hasOwnProperty.call(karte, id) ? karte[id] : undefined;
|
|
149
|
+
};
|
|
150
|
+
const fehler = (code) => ({ ok: false, code });
|
|
151
|
+
const OHNE_PFAND = ['tip', 'discount', 'voucher', 'voucher_float', 'deposit', 'deposit_return'];
|
|
152
|
+
const istHaupt = (it) => istObj(it) && !OHNE_PFAND.includes(it['kind']);
|
|
153
|
+
const mengeVon = (it) => (it['amount'] !== undefined && it['amount'] !== null ? it['amount'] : it['quantity']);
|
|
154
|
+
const satzVon = (it) => (it['vat'] !== undefined && it['vat'] !== null ? it['vat'] : it['vatRate']);
|
|
155
|
+
const hatVerweis = (it) => it['addOnOf'] !== undefined && it['addOnOf'] !== null;
|
|
156
|
+
const aktiv = (arten, id) => {
|
|
157
|
+
const a = typeof id === 'string' ? nachId(arten, id) : undefined;
|
|
158
|
+
return a && a.active !== false ? a : null;
|
|
159
|
+
};
|
|
160
|
+
function zeile(kind, art, name, quantity, cents, vatRate) {
|
|
161
|
+
return {
|
|
162
|
+
kind, name, quantity, amount: quantity,
|
|
163
|
+
unitPriceCents: cents, priceOneCents: cents, priceOne: cents / 100, vatRate, vat: vatRate,
|
|
164
|
+
depositTypeId: art.id, depositKind: art.kind,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function pfandPreis(art, haupt, day, smallBusiness) {
|
|
168
|
+
const cents = depositAmountOn(art, day);
|
|
169
|
+
if (cents === null)
|
|
170
|
+
return null;
|
|
171
|
+
if (art.kind === 'single_use')
|
|
172
|
+
return { cents, vatRate: 0 };
|
|
173
|
+
if (smallBusiness)
|
|
174
|
+
return { cents, vatRate: 0 };
|
|
175
|
+
const satz = satzVon(haupt);
|
|
176
|
+
return typeof satz === 'number' && Number.isFinite(satz) ? { cents, vatRate: satz } : null;
|
|
177
|
+
}
|
|
178
|
+
function abgeleitet(it, input) {
|
|
179
|
+
if (!input.auto || !istHaupt(it) || typeof it['articleId'] !== 'string' || it['articleId'] === '')
|
|
180
|
+
return [];
|
|
181
|
+
const a = nachId(input.articles, it['articleId']);
|
|
182
|
+
if (!a)
|
|
183
|
+
return [];
|
|
184
|
+
const g = a.groupId ? nachId(input.groups, a.groupId) : null;
|
|
185
|
+
return depositsFor(a, g);
|
|
186
|
+
}
|
|
187
|
+
function gtinOk(v) {
|
|
188
|
+
return typeof v === 'string' && validator_1.Gtin.isValid(v);
|
|
189
|
+
}
|
|
190
|
+
function leergut(it, input) {
|
|
191
|
+
if (!input.cashRegister || input.cashRegister.returns !== 'here')
|
|
192
|
+
return fehler('deposit_return_not_offered');
|
|
193
|
+
if (input.mayReturn === false)
|
|
194
|
+
return fehler('not_permitted');
|
|
195
|
+
const art = aktiv(input.depositTypes, it['depositTypeId']);
|
|
196
|
+
if (!art)
|
|
197
|
+
return fehler('deposit_type_not_found');
|
|
198
|
+
if (art.kind === 'reusable' && art.used !== true)
|
|
199
|
+
return fehler('deposit_type_not_issued');
|
|
200
|
+
const quantity = it['quantity'];
|
|
201
|
+
if (!ganz(quantity, 1, 1000))
|
|
202
|
+
return fehler('invalid_deposit');
|
|
203
|
+
let codes;
|
|
204
|
+
if (it['codes'] !== undefined && it['codes'] !== null) {
|
|
205
|
+
if (!istObj(it['codes']))
|
|
206
|
+
return fehler('invalid_deposit');
|
|
207
|
+
const schluessel = Object.keys(it['codes']);
|
|
208
|
+
if (schluessel.length > 50)
|
|
209
|
+
return fehler('invalid_deposit');
|
|
210
|
+
let summe = 0;
|
|
211
|
+
for (const k of schluessel) {
|
|
212
|
+
const n = it['codes'][k];
|
|
213
|
+
if (!gtinOk(k) || !ganz(n, 1, 1000))
|
|
214
|
+
return fehler('invalid_deposit');
|
|
215
|
+
summe += n;
|
|
216
|
+
}
|
|
217
|
+
if (summe !== quantity)
|
|
218
|
+
return fehler('invalid_deposit');
|
|
219
|
+
codes = { ...it['codes'] };
|
|
220
|
+
}
|
|
221
|
+
const cents = depositAmountOn(art, input.day);
|
|
222
|
+
if (cents === null)
|
|
223
|
+
return fehler('invalid_deposit');
|
|
224
|
+
// Mehrweg-Leergut rechnet mit dem Rueckgabesatz der Pfandart (`returnRate` = Steuersatz), bei Kleinunternehmern 0.
|
|
225
|
+
let vatRate = 0;
|
|
226
|
+
if (art.kind === 'reusable' && !input.smallBusiness) {
|
|
227
|
+
if (art.returnRate === null || !Number.isFinite(art.returnRate))
|
|
228
|
+
return fehler('invalid_deposit');
|
|
229
|
+
vatRate = art.returnRate;
|
|
230
|
+
}
|
|
231
|
+
const z = zeile('deposit_return', art, 'Leergut ' + art.name.replace(/^Pfand /, ''), quantity, -cents, vatRate);
|
|
232
|
+
if (art.kind === 'single_use')
|
|
233
|
+
z['ean'] = EWP_GTIN;
|
|
234
|
+
if (codes)
|
|
235
|
+
z['codes'] = codes;
|
|
236
|
+
return { ok: true, line: z };
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Pfand- und Leergutzeilen eines Belegs wie der Server: leitet Pfand zu Artikeln ab (`auto`), prueft ausdrueckliche
|
|
240
|
+
* `deposit`-Zeilen und `deposit_return`-Zeilen und rechnet `addOnOf` und `depositFor` auf die neuen Positionen um.
|
|
241
|
+
* Ohne Pfand-/Leergutzeile und ohne Ableitung kommen die Positionen unveraendert zurueck. Die Fehlercodes sind die
|
|
242
|
+
* von `createReceipt`.
|
|
243
|
+
*/
|
|
244
|
+
function withDepositLines(items, input) {
|
|
245
|
+
const liste = Array.isArray(items) ? items : [];
|
|
246
|
+
const dahinter = new Map();
|
|
247
|
+
const ersetzt = new Map();
|
|
248
|
+
const hinzu = (i, z) => { dahinter.set(i, [...(dahinter.get(i) ?? []), z]); };
|
|
249
|
+
for (let i = 0; i < liste.length; i += 1) {
|
|
250
|
+
const it = liste[i];
|
|
251
|
+
if (!istObj(it))
|
|
252
|
+
continue;
|
|
253
|
+
if (it['kind'] === 'deposit_return') {
|
|
254
|
+
const r = leergut(it, input);
|
|
255
|
+
if (!r.ok)
|
|
256
|
+
return r;
|
|
257
|
+
ersetzt.set(i, r.line);
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
if (it['kind'] === 'deposit') {
|
|
261
|
+
const verweis = it['depositFor'];
|
|
262
|
+
const haupt = Number.isInteger(verweis) ? liste[verweis] : null;
|
|
263
|
+
if (!istHaupt(haupt))
|
|
264
|
+
return fehler('invalid_deposit');
|
|
265
|
+
if (abgeleitet(haupt, input).length > 0)
|
|
266
|
+
return fehler('deposit_set_by_server');
|
|
267
|
+
const art = aktiv(input.depositTypes, it['depositTypeId']);
|
|
268
|
+
if (!art)
|
|
269
|
+
return fehler('deposit_type_not_found');
|
|
270
|
+
const menge = mengeVon(haupt);
|
|
271
|
+
if (!Number.isInteger(menge) || menge === 0)
|
|
272
|
+
return fehler('invalid_deposit_quantity');
|
|
273
|
+
const quantity = it['quantity'] === undefined || it['quantity'] === null ? menge : it['quantity'];
|
|
274
|
+
if (!Number.isInteger(quantity) || quantity % menge !== 0 || quantity / menge < 1)
|
|
275
|
+
return fehler('invalid_deposit_quantity');
|
|
276
|
+
const preis = pfandPreis(art, haupt, input.day, input.smallBusiness);
|
|
277
|
+
if (!preis)
|
|
278
|
+
return fehler('invalid_deposit');
|
|
279
|
+
const hatGtin = it['gtin'] !== undefined && it['gtin'] !== null;
|
|
280
|
+
if (hatGtin && !gtinOk(it['gtin']))
|
|
281
|
+
return fehler('invalid_deposit');
|
|
282
|
+
if (it['ownFilling'] !== undefined && it['ownFilling'] !== null && typeof it['ownFilling'] !== 'boolean')
|
|
283
|
+
return fehler('invalid_deposit');
|
|
284
|
+
if (it['ownFilling'] === true && !hatGtin)
|
|
285
|
+
return fehler('invalid_deposit');
|
|
286
|
+
const q = quantity;
|
|
287
|
+
const z = zeile('deposit', art, art.name, q, preis.cents, preis.vatRate);
|
|
288
|
+
z['depositFor'] = verweis;
|
|
289
|
+
z['perUnit'] = q / menge;
|
|
290
|
+
if (art.kind === 'single_use')
|
|
291
|
+
z['ean'] = EWP_GTIN;
|
|
292
|
+
if (hatGtin)
|
|
293
|
+
z['gtin'] = it['gtin'];
|
|
294
|
+
if (it['ownFilling'] === true)
|
|
295
|
+
z['ownFilling'] = true;
|
|
296
|
+
ersetzt.set(i, z);
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
const eintraege = abgeleitet(it, input);
|
|
300
|
+
if (!eintraege.length)
|
|
301
|
+
continue;
|
|
302
|
+
const menge = mengeVon(it);
|
|
303
|
+
const gelten = [];
|
|
304
|
+
for (const e of eintraege) {
|
|
305
|
+
const art = aktiv(input.depositTypes, e.depositTypeId);
|
|
306
|
+
if (!art)
|
|
307
|
+
return fehler('deposit_type_not_found');
|
|
308
|
+
if (art.kind === 'single_use' && input.onPremises === true)
|
|
309
|
+
continue;
|
|
310
|
+
gelten.push({ e, art });
|
|
311
|
+
}
|
|
312
|
+
if (!gelten.length)
|
|
313
|
+
continue;
|
|
314
|
+
if (!Number.isInteger(menge))
|
|
315
|
+
return fehler('invalid_deposit_quantity');
|
|
316
|
+
if (menge === 0)
|
|
317
|
+
continue;
|
|
318
|
+
for (const { e, art } of gelten) {
|
|
319
|
+
const preis = pfandPreis(art, it, input.day, input.smallBusiness);
|
|
320
|
+
if (!preis)
|
|
321
|
+
return fehler('invalid_deposit');
|
|
322
|
+
const z = zeile('deposit', art, art.name, e.quantity * menge, preis.cents, preis.vatRate);
|
|
323
|
+
z['depositFor'] = i;
|
|
324
|
+
z['perUnit'] = e.quantity;
|
|
325
|
+
if (art.kind === 'single_use')
|
|
326
|
+
z['ean'] = EWP_GTIN;
|
|
327
|
+
if (e.gtin)
|
|
328
|
+
z['gtin'] = e.gtin;
|
|
329
|
+
if (e.ownFilling === true)
|
|
330
|
+
z['ownFilling'] = true;
|
|
331
|
+
hinzu(i, z);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
if (!ersetzt.size && !dahinter.size)
|
|
335
|
+
return { ok: true, items: [...liste] };
|
|
336
|
+
const neu = [];
|
|
337
|
+
let verschiebung = 0;
|
|
338
|
+
liste.forEach((_, i) => { neu.push(i + verschiebung); verschiebung += dahinter.get(i)?.length ?? 0; });
|
|
339
|
+
const umgerechnet = (v) => (typeof v === 'number' && Number.isInteger(v) ? neu[v] : undefined);
|
|
340
|
+
const raus = [];
|
|
341
|
+
liste.forEach((it, i) => {
|
|
342
|
+
if (!istObj(it)) {
|
|
343
|
+
raus.push(it);
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
let z = ersetzt.get(i) ?? it;
|
|
347
|
+
if (z['kind'] === 'deposit' && umgerechnet(z['depositFor']) !== undefined)
|
|
348
|
+
z = { ...z, depositFor: umgerechnet(z['depositFor']) };
|
|
349
|
+
else if (hatVerweis(z) && umgerechnet(z['addOnOf']) !== undefined)
|
|
350
|
+
z = { ...z, addOnOf: umgerechnet(z['addOnOf']) };
|
|
351
|
+
raus.push(z);
|
|
352
|
+
for (const d of dahinter.get(i) ?? [])
|
|
353
|
+
raus.push({ ...d, depositFor: neu[i] });
|
|
354
|
+
});
|
|
355
|
+
return { ok: true, items: raus };
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Die Leergutzeile zu `quantity` Stueck einer Pfandart, wie `withDepositLines` sie fuer eine
|
|
359
|
+
* `deposit_return`-Eingabe baut (fuer die Korb-Vorschau). Wirft, wenn sich keine Zeile ergibt
|
|
360
|
+
* (unbekannte Pfandart, Menge ausserhalb 1 bis 1000, Mehrweg ohne Rueckgabesatz, ungueltige Codes);
|
|
361
|
+
* ob die Kasse Leergut annimmt, prueft der Aufrufer.
|
|
362
|
+
*/
|
|
363
|
+
function depositReturnLine(type, quantity, options) {
|
|
364
|
+
const r = leergut({ kind: 'deposit_return', depositTypeId: type.id, quantity, ...(options.codes ? { codes: options.codes } : {}) }, { depositTypes: { [type.id]: type }, day: options.day, smallBusiness: options.smallBusiness, cashRegister: { returns: 'here' }, mayReturn: true });
|
|
365
|
+
if (!r.ok)
|
|
366
|
+
throw new Error(`Leergutzeile nicht moeglich: ${r.code}`);
|
|
367
|
+
const l = r.line;
|
|
368
|
+
const item = {
|
|
369
|
+
name: l['name'],
|
|
370
|
+
quantity: l['quantity'],
|
|
371
|
+
vat: (0, enum_payload_js_1.readVatRateByRate)(l['vatRate']),
|
|
372
|
+
priceCents: l['unitPriceCents'],
|
|
373
|
+
kind: 'deposit_return',
|
|
374
|
+
depositTypeId: l['depositTypeId'],
|
|
375
|
+
depositKind: type.kind,
|
|
376
|
+
};
|
|
377
|
+
if (typeof l['ean'] === 'string')
|
|
378
|
+
item.ean = l['ean'];
|
|
379
|
+
if (l['codes'] !== undefined)
|
|
380
|
+
item.codes = l['codes'];
|
|
381
|
+
return item;
|
|
382
|
+
}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* bis die Buchung geklaert ist (Spec kachel-kasse § 9).
|
|
13
13
|
*/
|
|
14
14
|
import { type PosVoucherSettings } from './gutschein.js';
|
|
15
|
+
import { type DepositSettings } from './pfand.js';
|
|
15
16
|
export declare const THEME: readonly ["clear", "warm", "night", "contrast"];
|
|
16
17
|
export type PosTheme = typeof THEME[number];
|
|
17
18
|
export declare const FONT_SIZE: readonly ["S", "M", "L", "XL"];
|
|
@@ -335,6 +336,8 @@ export interface PosSettings {
|
|
|
335
336
|
device: PosDeviceSettings;
|
|
336
337
|
/** Gutschein-Verkauf der Kasse (Block `vouchers`); ohne Block ist Verkaufen aus. */
|
|
337
338
|
vouchers: PosVoucherSettings;
|
|
339
|
+
/** Pfand & Leergut (Block `deposit`); fehlt, solange der Betrieb kein Pfand eingeschaltet hat. */
|
|
340
|
+
deposit?: DepositSettings;
|
|
338
341
|
}
|
|
339
342
|
export declare const POS_BUSINESS_DEFAULTS: Readonly<PosBusinessSettings>;
|
|
340
343
|
export declare const POS_DEVICE_DEFAULTS: Readonly<PosDeviceSettings>;
|
|
@@ -429,13 +432,6 @@ export declare const _ALTFORM_0X: Readonly<{
|
|
|
429
432
|
* dagegen stehen: er kann ein neuer Wert des Servers sein.
|
|
430
433
|
*/
|
|
431
434
|
export declare function mergePosSettings<T extends object>(standard: Readonly<T>, stored: Partial<T> | null | undefined): T;
|
|
432
|
-
/**
|
|
433
|
-
* Einen gespeicherten oder zwischengespeicherten Stand `{business, device}`
|
|
434
|
-
* lesen: gemischt mit den Standardwerten, ohne Werte und Tasten-Aktionen der
|
|
435
|
-
* inneren Form 0.x (siehe [mergePosSettings]). Der Weg fuer jeden Stand, den
|
|
436
|
-
* ein Verbraucher selbst abgelegt hat; ein Stand in der inneren Form ergibt
|
|
437
|
-
* die Standardwerte, nie einen deutschen Wert und nie einen Absturz.
|
|
438
|
-
*/
|
|
439
435
|
export declare function sanitizePosSettings(stored: unknown): PosSettings;
|
|
440
436
|
/**
|
|
441
437
|
* Die Felder, deren Wert dieses Paket nicht kennt (neuer Wert des Servers),
|
package/dist/cjs/pos/settings.js
CHANGED
|
@@ -31,6 +31,7 @@ exports.posSettingsChanges = posSettingsChanges;
|
|
|
31
31
|
* bis die Buchung geklaert ist (Spec kachel-kasse § 9).
|
|
32
32
|
*/
|
|
33
33
|
const gutschein_js_1 = require("./gutschein.js");
|
|
34
|
+
const pfand_js_1 = require("./pfand.js");
|
|
34
35
|
/*
|
|
35
36
|
* Jedes Enum steht als Liste zur Laufzeit da, der Typ leitet sich daraus ab
|
|
36
37
|
* (`typeof LISTE[number]`). So gibt es die Werte nur einmal, und die Zwillinge
|
|
@@ -455,6 +456,11 @@ function mergePosSettings(standard, stored) {
|
|
|
455
456
|
* ein Verbraucher selbst abgelegt hat; ein Stand in der inneren Form ergibt
|
|
456
457
|
* die Standardwerte, nie einen deutschen Wert und nie einen Absturz.
|
|
457
458
|
*/
|
|
459
|
+
/** `{ deposit }`, wenn der Block lesbar ist, sonst nichts: ohne Block fehlt das Feld am Modell. */
|
|
460
|
+
function pfandBlock(wert) {
|
|
461
|
+
const deposit = (0, pfand_js_1.posDepositSettingsFromWire)(wert);
|
|
462
|
+
return deposit ? { deposit } : {};
|
|
463
|
+
}
|
|
458
464
|
function sanitizePosSettings(stored) {
|
|
459
465
|
const roh = stored !== null && typeof stored === 'object' ? stored : {};
|
|
460
466
|
const teil = (k) => {
|
|
@@ -465,6 +471,7 @@ function sanitizePosSettings(stored) {
|
|
|
465
471
|
business: mergePosSettings(exports.POS_BUSINESS_DEFAULTS, teil('business')),
|
|
466
472
|
device: mergePosSettings(exports.POS_DEVICE_DEFAULTS, teil('device')),
|
|
467
473
|
vouchers: (0, gutschein_js_1.posVoucherSettingsFromWire)(eigen(roh, 'vouchers') ? roh['vouchers'] : undefined),
|
|
474
|
+
...pfandBlock(eigen(roh, 'deposit') ? roh['deposit'] : undefined),
|
|
468
475
|
};
|
|
469
476
|
}
|
|
470
477
|
/**
|
package/dist/cjs/pos/texte.d.ts
CHANGED
|
@@ -1005,6 +1005,33 @@ declare const MELDUNGEN_ROH: {
|
|
|
1005
1005
|
readonly 'tip.unassigned_hint': {
|
|
1006
1006
|
readonly text: "Trinkgeld ohne angemeldeten Benutzer.";
|
|
1007
1007
|
};
|
|
1008
|
+
readonly 'deposit.changed': {
|
|
1009
|
+
readonly text: "Pfand wurde geändert. Bitte Summe prüfen.";
|
|
1010
|
+
};
|
|
1011
|
+
readonly 'deposit_error.not_enabled': {
|
|
1012
|
+
readonly text: "Pfand ist für diesen Betrieb nicht eingeschaltet.";
|
|
1013
|
+
};
|
|
1014
|
+
readonly 'deposit_error.type_not_found': {
|
|
1015
|
+
readonly text: "Diese Pfandart gibt es nicht mehr.";
|
|
1016
|
+
};
|
|
1017
|
+
readonly 'deposit_error.set_by_server': {
|
|
1018
|
+
readonly text: "Das Pfand bucht die Kasse selbst.";
|
|
1019
|
+
};
|
|
1020
|
+
readonly 'deposit_error.invalid_quantity': {
|
|
1021
|
+
readonly text: "Pfand gibt es nur für ganze Stück.";
|
|
1022
|
+
};
|
|
1023
|
+
readonly 'deposit_error.return_not_offered': {
|
|
1024
|
+
readonly text: "Diese Kasse nimmt kein Leergut zurück.";
|
|
1025
|
+
};
|
|
1026
|
+
readonly 'deposit_error.type_not_issued': {
|
|
1027
|
+
readonly text: "Dieses Leergut wurde hier nie verkauft.";
|
|
1028
|
+
};
|
|
1029
|
+
readonly 'deposit_error.follows_item': {
|
|
1030
|
+
readonly text: "Pfand wird mit seinem Artikel storniert.";
|
|
1031
|
+
};
|
|
1032
|
+
readonly 'deposit_error.invalid': {
|
|
1033
|
+
readonly text: "Die Pfand-Angaben stimmen nicht.";
|
|
1034
|
+
};
|
|
1008
1035
|
};
|
|
1009
1036
|
export type MessageKey = keyof typeof MELDUNGEN_ROH;
|
|
1010
1037
|
export declare const MESSAGES: Record<MessageKey, TextEntry>;
|
|
@@ -1337,6 +1364,23 @@ export declare const VOUCHER_ERROR_MESSAGES: {
|
|
|
1337
1364
|
export type VoucherMessageCode = keyof typeof VOUCHER_ERROR_MESSAGES;
|
|
1338
1365
|
/** Der Satz zu einem Gutschein-`code`; `undefined` für jeden anderen Code. */
|
|
1339
1366
|
export declare function voucherErrorMessage(code: string | undefined | null): MessageKey | undefined;
|
|
1367
|
+
/**
|
|
1368
|
+
* Pfand-Fehler (`/v3`, createReceipt und cancelReceipt): welcher `code` des
|
|
1369
|
+
* Backends welchen Satz bekommt. Kassensprache, keine Rechtssprache.
|
|
1370
|
+
*/
|
|
1371
|
+
export declare const DEPOSIT_ERROR_MESSAGES: {
|
|
1372
|
+
readonly deposit_not_enabled: "deposit_error.not_enabled";
|
|
1373
|
+
readonly deposit_type_not_found: "deposit_error.type_not_found";
|
|
1374
|
+
readonly deposit_set_by_server: "deposit_error.set_by_server";
|
|
1375
|
+
readonly invalid_deposit_quantity: "deposit_error.invalid_quantity";
|
|
1376
|
+
readonly deposit_return_not_offered: "deposit_error.return_not_offered";
|
|
1377
|
+
readonly deposit_type_not_issued: "deposit_error.type_not_issued";
|
|
1378
|
+
readonly deposit_follows_item: "deposit_error.follows_item";
|
|
1379
|
+
readonly invalid_deposit: "deposit_error.invalid";
|
|
1380
|
+
};
|
|
1381
|
+
export type DepositMessageCode = keyof typeof DEPOSIT_ERROR_MESSAGES;
|
|
1382
|
+
/** Der Satz zu einem Pfand-`code`; `undefined` für jeden anderen Code. */
|
|
1383
|
+
export declare function depositErrorMessage(code: string | undefined | null): MessageKey | undefined;
|
|
1340
1384
|
/**
|
|
1341
1385
|
* Beschriftungen: Knoepfe, Ueberschriften, Zeilennamen – was kein Satz ist.
|
|
1342
1386
|
*
|
|
@@ -3019,6 +3063,30 @@ declare const BESCHRIFTUNGEN_ROH: {
|
|
|
3019
3063
|
readonly 'settings.tip_start': {
|
|
3020
3064
|
readonly text: "Zuerst offen";
|
|
3021
3065
|
};
|
|
3066
|
+
readonly 'deposit.return': {
|
|
3067
|
+
readonly text: "Leergut";
|
|
3068
|
+
};
|
|
3069
|
+
readonly 'deposit.payout': {
|
|
3070
|
+
readonly text: "Bar auszahlen";
|
|
3071
|
+
};
|
|
3072
|
+
readonly 'deposit.offset': {
|
|
3073
|
+
readonly text: "Mit Einkauf verrechnen";
|
|
3074
|
+
};
|
|
3075
|
+
readonly 'deposit.unknown_code': {
|
|
3076
|
+
readonly text: "Welches Leergut ist das?";
|
|
3077
|
+
};
|
|
3078
|
+
readonly 'deposit.over_usual': {
|
|
3079
|
+
readonly text: "Mehr als üblich – trotzdem annehmen?";
|
|
3080
|
+
};
|
|
3081
|
+
readonly 'deposit.on_premises': {
|
|
3082
|
+
readonly text: "Vor Ort";
|
|
3083
|
+
};
|
|
3084
|
+
readonly 'deposit.takeaway': {
|
|
3085
|
+
readonly text: "Mitnahme";
|
|
3086
|
+
};
|
|
3087
|
+
readonly 'deposit.sum': {
|
|
3088
|
+
readonly text: "Summe Leergut";
|
|
3089
|
+
};
|
|
3022
3090
|
};
|
|
3023
3091
|
export type LabelKey = keyof typeof BESCHRIFTUNGEN_ROH;
|
|
3024
3092
|
export declare const LABELS: Record<LabelKey, TextEntry>;
|
package/dist/cjs/pos/texte.js
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* `placeholders` und `structure`).
|
|
23
23
|
*/
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.EXTERNAL_VOUCHER_KIND_LABELS = exports.EXTERNAL_VOUCHERS_LABELS = exports.TIP_KEPT_MODE_LABELS = exports.RETURN_DISPOSITION_LABELS = exports.LABELS = exports.VOUCHER_ERROR_MESSAGES = exports.EXTERNAL_VOUCHER_ARTICLE_MESSAGES = exports.EXTERNAL_VOUCHER_TILE_MESSAGES = exports.CANCELLATION_VOUCHER_ERROR_MESSAGES = exports.CANCELLATION_PAYMENT_ERROR_MESSAGES = exports.RECEIPT_EMAIL_ERROR_MESSAGES = exports.CALLS_WITH_EFFECT = exports.ERROR_OUTCOME_RULES = exports.ERROR_CODE_RULES = exports.ERROR_RULES = exports.MESSAGES = void 0;
|
|
25
|
+
exports.EXTERNAL_VOUCHER_KIND_LABELS = exports.EXTERNAL_VOUCHERS_LABELS = exports.TIP_KEPT_MODE_LABELS = exports.RETURN_DISPOSITION_LABELS = exports.LABELS = exports.DEPOSIT_ERROR_MESSAGES = exports.VOUCHER_ERROR_MESSAGES = exports.EXTERNAL_VOUCHER_ARTICLE_MESSAGES = exports.EXTERNAL_VOUCHER_TILE_MESSAGES = exports.CANCELLATION_VOUCHER_ERROR_MESSAGES = exports.CANCELLATION_PAYMENT_ERROR_MESSAGES = exports.RECEIPT_EMAIL_ERROR_MESSAGES = exports.CALLS_WITH_EFFECT = exports.ERROR_OUTCOME_RULES = exports.ERROR_CODE_RULES = exports.ERROR_RULES = exports.MESSAGES = void 0;
|
|
26
26
|
exports.findErrorRule = findErrorRule;
|
|
27
27
|
exports.messageOutcome = messageOutcome;
|
|
28
28
|
exports.receiptEmailErrorMessage = receiptEmailErrorMessage;
|
|
@@ -30,6 +30,7 @@ exports.cancellationPaymentErrorMessage = cancellationPaymentErrorMessage;
|
|
|
30
30
|
exports.cancellationErrorMessage = cancellationErrorMessage;
|
|
31
31
|
exports.externalVoucherArticleErrorMessage = externalVoucherArticleErrorMessage;
|
|
32
32
|
exports.voucherErrorMessage = voucherErrorMessage;
|
|
33
|
+
exports.depositErrorMessage = depositErrorMessage;
|
|
33
34
|
exports.receiptOutputLabel = receiptOutputLabel;
|
|
34
35
|
exports.labelText = labelText;
|
|
35
36
|
exports.messageText = messageText;
|
|
@@ -491,6 +492,16 @@ const MELDUNGEN_ROH = {
|
|
|
491
492
|
'shift.finish_step_first': { text: 'Erst den Schritt rechts abschließen oder abbrechen.' },
|
|
492
493
|
'tip.revenue_hint': { text: 'Steuerpflichtiges Trinkgeld zählt als Umsatz des Betriebs und wird nicht ausgezahlt.' },
|
|
493
494
|
'tip.unassigned_hint': { text: 'Trinkgeld ohne angemeldeten Benutzer.' },
|
|
495
|
+
// --- Pfand und Leergut (1.32.0): Fehlersätze (Zuordnung in DEPOSIT_ERROR_MESSAGES) ---
|
|
496
|
+
'deposit.changed': { text: 'Pfand wurde geändert. Bitte Summe prüfen.' },
|
|
497
|
+
'deposit_error.not_enabled': { text: 'Pfand ist für diesen Betrieb nicht eingeschaltet.' },
|
|
498
|
+
'deposit_error.type_not_found': { text: 'Diese Pfandart gibt es nicht mehr.' },
|
|
499
|
+
'deposit_error.set_by_server': { text: 'Das Pfand bucht die Kasse selbst.' },
|
|
500
|
+
'deposit_error.invalid_quantity': { text: 'Pfand gibt es nur für ganze Stück.' },
|
|
501
|
+
'deposit_error.return_not_offered': { text: 'Diese Kasse nimmt kein Leergut zurück.' },
|
|
502
|
+
'deposit_error.type_not_issued': { text: 'Dieses Leergut wurde hier nie verkauft.' },
|
|
503
|
+
'deposit_error.follows_item': { text: 'Pfand wird mit seinem Artikel storniert.' },
|
|
504
|
+
'deposit_error.invalid': { text: 'Die Pfand-Angaben stimmen nicht.' },
|
|
494
505
|
};
|
|
495
506
|
// Auf den gemeinsamen Typ gebracht: `Object.entries(MESSAGES)` liefert sonst
|
|
496
507
|
// pro Schluessel den engsten Literaltyp, und `placeholders`/`only` waeren nur
|
|
@@ -794,6 +805,25 @@ function voucherErrorMessage(code) {
|
|
|
794
805
|
const fehler = exports.VOUCHER_ERROR_MESSAGES;
|
|
795
806
|
return code !== undefined && code !== null ? fehler[code] : undefined;
|
|
796
807
|
}
|
|
808
|
+
/**
|
|
809
|
+
* Pfand-Fehler (`/v3`, createReceipt und cancelReceipt): welcher `code` des
|
|
810
|
+
* Backends welchen Satz bekommt. Kassensprache, keine Rechtssprache.
|
|
811
|
+
*/
|
|
812
|
+
exports.DEPOSIT_ERROR_MESSAGES = {
|
|
813
|
+
deposit_not_enabled: 'deposit_error.not_enabled',
|
|
814
|
+
deposit_type_not_found: 'deposit_error.type_not_found',
|
|
815
|
+
deposit_set_by_server: 'deposit_error.set_by_server',
|
|
816
|
+
invalid_deposit_quantity: 'deposit_error.invalid_quantity',
|
|
817
|
+
deposit_return_not_offered: 'deposit_error.return_not_offered',
|
|
818
|
+
deposit_type_not_issued: 'deposit_error.type_not_issued',
|
|
819
|
+
deposit_follows_item: 'deposit_error.follows_item',
|
|
820
|
+
invalid_deposit: 'deposit_error.invalid',
|
|
821
|
+
};
|
|
822
|
+
/** Der Satz zu einem Pfand-`code`; `undefined` für jeden anderen Code. */
|
|
823
|
+
function depositErrorMessage(code) {
|
|
824
|
+
const fehler = exports.DEPOSIT_ERROR_MESSAGES;
|
|
825
|
+
return code !== undefined && code !== null && Object.prototype.hasOwnProperty.call(fehler, code) ? fehler[code] : undefined;
|
|
826
|
+
}
|
|
797
827
|
/**
|
|
798
828
|
* Beschriftungen: Knoepfe, Ueberschriften, Zeilennamen – was kein Satz ist.
|
|
799
829
|
*
|
|
@@ -1438,6 +1468,15 @@ const BESCHRIFTUNGEN_ROH = {
|
|
|
1438
1468
|
'tip.summary_percent': { text: 'Trinkgeld {tip} ({percent} %)', placeholders: ['tip', 'percent'] },
|
|
1439
1469
|
'settings.tip_kinds': { text: 'Trinkgeld-Arten' },
|
|
1440
1470
|
'settings.tip_start': { text: 'Zuerst offen' },
|
|
1471
|
+
// --- Pfand und Leergut (1.32.0) ---
|
|
1472
|
+
'deposit.return': { text: 'Leergut' },
|
|
1473
|
+
'deposit.payout': { text: 'Bar auszahlen' },
|
|
1474
|
+
'deposit.offset': { text: 'Mit Einkauf verrechnen' },
|
|
1475
|
+
'deposit.unknown_code': { text: 'Welches Leergut ist das?' },
|
|
1476
|
+
'deposit.over_usual': { text: 'Mehr als üblich – trotzdem annehmen?' },
|
|
1477
|
+
'deposit.on_premises': { text: 'Vor Ort' },
|
|
1478
|
+
'deposit.takeaway': { text: 'Mitnahme' },
|
|
1479
|
+
'deposit.sum': { text: 'Summe Leergut' },
|
|
1441
1480
|
};
|
|
1442
1481
|
exports.LABELS = BESCHRIFTUNGEN_ROH;
|
|
1443
1482
|
/**
|
|
@@ -21,6 +21,9 @@ function distributeDiscount(items, discountCents, name = 'Rabatt') {
|
|
|
21
21
|
// Umsatz je Steuersatz (nur positive Positionen -- Rabatte/Stornos zaehlen nicht mit)
|
|
22
22
|
const gruppen = new Map();
|
|
23
23
|
for (const p of items) {
|
|
24
|
+
// Pfand und Leergut werden nie rabattiert (durchlaufend, Spec E17).
|
|
25
|
+
if ((0, receipt_item_js_1.isDepositItem)(p) || (0, receipt_item_js_1.isDepositReturnItem)(p))
|
|
26
|
+
continue;
|
|
24
27
|
const betrag = (0, receipt_item_js_1.receiptItemTotalCents)(p);
|
|
25
28
|
if (betrag <= 0)
|
|
26
29
|
continue;
|
|
@@ -151,6 +151,12 @@ export interface ReceiptDueBreakdown {
|
|
|
151
151
|
valueVoucherFlowCents: number;
|
|
152
152
|
/** Toepfe je auf Cent gerundet; `null` bei Start- und Nullbeleg. */
|
|
153
153
|
bucketsCents: ReceiptDueBuckets | null;
|
|
154
|
+
/**
|
|
155
|
+
* `'deposit'`: der negative Zahlbetrag ist eine Leergut-Auszahlung (Beleg mit Leergut, Betrag hoechstens die
|
|
156
|
+
* Leergutsumme): genau eine Barzahlung ueber den Betrag, ohne Trinkgeld und ohne `tendered`. Ware fuehrt nie zu
|
|
157
|
+
* einer Auszahlung. Fehlt sonst.
|
|
158
|
+
*/
|
|
159
|
+
payout?: 'deposit';
|
|
154
160
|
}
|
|
155
161
|
/**
|
|
156
162
|
* Warum sich der Zahlbetrag nicht rechnen laesst. Fest wie ein Backend-Code;
|