@kreiseck/kasseneck-api 1.29.0 → 1.30.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/README.md +27 -0
- package/dist/cjs/client/list-receipts.d.ts +5 -0
- package/dist/cjs/client/list-receipts.js +5 -1
- package/dist/cjs/client/receipts.d.ts +6 -0
- package/dist/cjs/client/receipts.js +1 -0
- package/dist/cjs/enums/voucher-type.d.ts +5 -1
- package/dist/cjs/enums/voucher-type.js +5 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +13 -5
- package/dist/cjs/inventory/index.d.ts +2 -2
- package/dist/cjs/inventory/index.js +3 -2
- package/dist/cjs/inventory/typen.d.ts +39 -1
- package/dist/cjs/inventory/vertrag.d.ts +13 -2
- package/dist/cjs/inventory/vertrag.js +16 -1
- package/dist/cjs/inventory/webhook.d.ts +3 -0
- package/dist/cjs/inventory/webhook.js +39 -0
- package/dist/cjs/models/index.d.ts +1 -1
- package/dist/cjs/models/index.js +10 -2
- package/dist/cjs/models/voucher.d.ts +78 -2
- package/dist/cjs/models/voucher.js +127 -5
- package/dist/cjs/pos/gutschein.d.ts +13 -0
- package/dist/cjs/pos/gutschein.js +5 -1
- package/dist/cjs/pos/index.d.ts +1 -1
- package/dist/cjs/pos/index.js +3 -2
- package/dist/cjs/pos/texte.d.ts +20 -0
- package/dist/cjs/pos/texte.js +11 -0
- package/dist/cjs/receipt/due.d.ts +8 -1
- package/dist/cjs/receipt/due.js +1 -0
- package/dist/cjs/receipt/gutschein-plan.d.ts +11 -1
- package/dist/cjs/receipt/gutschein-plan.js +116 -1
- package/dist/cjs/receipt/layout.js +39 -6
- package/dist/cjs/stored/draht.js +5 -0
- package/dist/cjs/stored/vokabular.d.ts +3 -1
- package/dist/cjs/stored/vokabular.js +15 -2
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/client/list-receipts.d.ts +5 -0
- package/dist/esm/client/list-receipts.js +5 -2
- package/dist/esm/client/receipts.d.ts +6 -0
- package/dist/esm/client/receipts.js +1 -0
- package/dist/esm/enums/voucher-type.d.ts +5 -1
- package/dist/esm/enums/voucher-type.js +5 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/inventory/index.d.ts +2 -2
- package/dist/esm/inventory/index.js +1 -1
- package/dist/esm/inventory/typen.d.ts +39 -1
- package/dist/esm/inventory/vertrag.d.ts +13 -2
- package/dist/esm/inventory/vertrag.js +15 -0
- package/dist/esm/inventory/webhook.d.ts +3 -0
- package/dist/esm/inventory/webhook.js +39 -0
- package/dist/esm/models/index.d.ts +1 -1
- package/dist/esm/models/index.js +1 -1
- package/dist/esm/models/voucher.d.ts +78 -2
- package/dist/esm/models/voucher.js +122 -4
- package/dist/esm/pos/gutschein.d.ts +13 -0
- package/dist/esm/pos/gutschein.js +4 -0
- package/dist/esm/pos/index.d.ts +1 -1
- package/dist/esm/pos/index.js +1 -1
- package/dist/esm/pos/texte.d.ts +20 -0
- package/dist/esm/pos/texte.js +11 -0
- package/dist/esm/receipt/due.d.ts +8 -1
- package/dist/esm/receipt/due.js +1 -0
- package/dist/esm/receipt/gutschein-plan.d.ts +11 -1
- package/dist/esm/receipt/gutschein-plan.js +117 -2
- package/dist/esm/receipt/layout.js +40 -7
- package/dist/esm/stored/draht.js +6 -1
- package/dist/esm/stored/vokabular.d.ts +3 -1
- package/dist/esm/stored/vokabular.js +14 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/fixtures/expected/voucher-external-redeem.grid32.txt +30 -0
- package/fixtures/expected/voucher-external-redeem.grid48.txt +27 -0
- package/fixtures/expected/voucher-external-redeem.lines.json +280 -0
- package/fixtures/expected/voucher-external-redeem.sheet32.json +206 -0
- package/fixtures/expected/voucher-external-redeem.sheet48.json +188 -0
- package/fixtures/expected/voucher-external-sale.grid32.txt +27 -0
- package/fixtures/expected/voucher-external-sale.grid48.txt +26 -0
- package/fixtures/expected/voucher-external-sale.lines.json +256 -0
- package/fixtures/expected/voucher-external-sale.sheet32.json +188 -0
- package/fixtures/expected/voucher-external-sale.sheet48.json +182 -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 +22 -2
- package/fixtures/receipt-due-voucher-generated.json +2 -2
- package/fixtures/receipts/voucher-external-redeem.json +85 -0
- package/fixtures/receipts/voucher-external-sale.json +80 -0
- package/fixtures/stored/voucher-cases.json +2800 -0
- package/fixtures/surface.json +14 -2
- package/fixtures/v3/antworten/belege.json +4 -3
- package/fixtures/v3/antworten/belegmail.json +2 -2
- package/fixtures/v3/antworten/berichte.json +2 -2
- package/fixtures/v3/antworten/kasse-belege.json +4 -3
- package/fixtures/v3/antworten/kasse.json +16 -10
- package/fixtures/v3/antworten/lager.json +6 -3
- 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 +3 -3
- package/fixtures/v3/stored/rechnungen.json +2 -2
- package/fixtures/v3/v3-vokabular.json +169 -8
- package/fixtures/v3/zahlbetrag-faelle.json +2 -2
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Voucher } from '../models/voucher.js';
|
|
2
|
-
import type { PosVoucherSettings, PosVoucherType, VoucherArticle, VoucherCheck } from '../pos/gutschein.js';
|
|
2
|
+
import type { PosExternalVouchers, PosVoucherSettings, PosVoucherType, VoucherArticle, VoucherCheck } from '../pos/gutschein.js';
|
|
3
3
|
/**
|
|
4
4
|
* Gutscheine der neuen Form im Zahlbetrag: Zwilling von
|
|
5
5
|
* `gutschein-beleg.plane` im Backend, soweit er den Zahlbetrag bestimmt.
|
|
@@ -27,6 +27,11 @@ import type { PosVoucherSettings, PosVoucherType, VoucherArticle, VoucherCheck }
|
|
|
27
27
|
* - Leistung verkaufen: Stueck mal Artikelpreis im Artikelsatz; einloesen: je
|
|
28
28
|
* Satz eine Minuszeile ueber die gewaehlten Positionen.
|
|
29
29
|
* - Aktion: Rabatt wie `promo`, Betrag aus der Pruefung, hoechstens die Summe.
|
|
30
|
+
* - Fremdgutschein (`source: 'external'`, Server 2026-11): dieselbe Strecke
|
|
31
|
+
* wie ein eigener Mehrzweck- bzw. Einzweckgutschein, nur ohne Pruefung und
|
|
32
|
+
* Saldo (verfuegbar ist genau der Betrag des Wunschs); Satz und Vermerk
|
|
33
|
+
* sagt der Wunsch, Satz 0 heisst befreit verkauft. Freigabe aus
|
|
34
|
+
* `externalVouchers` (sonst `voucherSettings.externalVouchers`).
|
|
30
35
|
*
|
|
31
36
|
* Kein Fehler wird still geschluckt: was der Server mit einem Gutschein-Code
|
|
32
37
|
* abwiese, liefert `fehler` mit genau diesem Code (`voucher_*`). Der
|
|
@@ -77,6 +82,11 @@ export declare const VOUCHER_ZERO_RATE_BUCKET_FROM = "2099-12-31";
|
|
|
77
82
|
export interface PlanOptionen {
|
|
78
83
|
voucherInfo?: readonly VoucherDueInfo[];
|
|
79
84
|
voucherSettings?: PosVoucherSettings;
|
|
85
|
+
/**
|
|
86
|
+
* Freigabe fuer Fremdgutscheine des Kontos; ohne Angabe die aus `voucherSettings`. Fehlen beide, prueft nur
|
|
87
|
+
* der Server die Freigabe.
|
|
88
|
+
*/
|
|
89
|
+
externalVouchers?: PosExternalVouchers;
|
|
80
90
|
voucherTypes?: readonly VoucherDueType[];
|
|
81
91
|
voucherArticles?: readonly VoucherDueArticle[];
|
|
82
92
|
smallBusiness?: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VoucherCode } from '@kreiseck/validator';
|
|
2
|
-
import { isNewFormVoucher, istWertVerkauf, voucherIsValid, voucherServerFields, wunschFormGueltig } from '../models/voucher.js';
|
|
2
|
+
import { EXTERNAL_VOUCHER_TAXED_WITH_MAX, EXTERNAL_VOUCHER_VAT_RATES_BP, checkExternalVoucherNumber, isExternalVoucher, isNewFormVoucher, istWertVerkauf, voucherIsValid, voucherServerFields, wunschFormGueltig, } from '../models/voucher.js';
|
|
3
3
|
/**
|
|
4
4
|
* Stichtag des 0-%-Topfs fuer Mehrzweck-Verkaeufe (Backend
|
|
5
5
|
* `gutschein-core.NULLTOPF_AB`). Solange er in der Zukunft liegt, zaehlt ein
|
|
@@ -121,6 +121,63 @@ function kuTeile(kunde, betragCents) {
|
|
|
121
121
|
nachRest[k].s.cents += 1;
|
|
122
122
|
return saetze.filter((s) => s.cents > 0).map((s) => ({ satzBp: s.satzBp, cents: s.cents }));
|
|
123
123
|
}
|
|
124
|
+
/** Steuer- und Formatzeichen (`gutschein-core.STEUERZEICHEN`). */
|
|
125
|
+
const STEUERZEICHEN = /[\p{Cc}\p{Cf}]/u;
|
|
126
|
+
/**
|
|
127
|
+
* Form eines Fremdgutschein-Wunschs in der Reihenfolge von `gutschein-beleg.pruefeFremd`: Freigabe, Aktion, Art,
|
|
128
|
+
* Freigabe der Art, Felder eigener Gutscheine, eigener Code, Nummer, Dublette, Betrag, Satz, Vermerk, Grund.
|
|
129
|
+
* `freigabe` undefined: die Freigabe prueft nur der Server.
|
|
130
|
+
*/
|
|
131
|
+
function pruefeFremd(v, i, freigabe, gesehen) {
|
|
132
|
+
const nein = (fehler, text) => ({ fehler, text });
|
|
133
|
+
const falsch = (feld) => nein('voucher_invalid', `Gutschein ${i + 1}: ${feld} passt nicht zum Fremdgutschein.`);
|
|
134
|
+
if (freigabe === 'off')
|
|
135
|
+
return nein('external_voucher_not_enabled', `Gutschein ${i + 1}: Fremdgutscheine sind nicht freigegeben.`);
|
|
136
|
+
if (v.action !== 'sell' && v.action !== 'redeem' && v.action !== 'payout')
|
|
137
|
+
return falsch('action');
|
|
138
|
+
if (v.type !== 'multi_purpose' && v.type !== 'single_purpose')
|
|
139
|
+
return falsch('type');
|
|
140
|
+
if (v.type === 'single_purpose' && freigabe !== undefined && freigabe !== 'all') {
|
|
141
|
+
return nein('external_voucher_type_not_enabled', `Gutschein ${i + 1}: fremde Einzweckgutscheine sind nicht freigegeben.`);
|
|
142
|
+
}
|
|
143
|
+
const r = v;
|
|
144
|
+
for (const feld of ['code', 'typeId', 'articleId', 'article', 'quantity', 'positions']) {
|
|
145
|
+
if (r[feld] !== undefined)
|
|
146
|
+
return falsch(feld);
|
|
147
|
+
}
|
|
148
|
+
if (v.valueCents != null)
|
|
149
|
+
return falsch('valueCents');
|
|
150
|
+
const nummer = checkExternalVoucherNumber(v.number);
|
|
151
|
+
if (!nummer.ok)
|
|
152
|
+
return nein(nummer.code, `Gutschein ${i + 1}: die Nummer ist ${nummer.code === 'external_voucher_number_is_own_code' ? 'ein eigener Gutscheincode' : 'ungueltig'}.`);
|
|
153
|
+
if (gesehen.has(nummer.number))
|
|
154
|
+
return nein('external_voucher_duplicate', `Gutschein ${i + 1}: dieselbe Nummer steht zweimal am Beleg.`);
|
|
155
|
+
gesehen.add(nummer.number);
|
|
156
|
+
const c = v.amountCents;
|
|
157
|
+
if (!(typeof c === 'number' && Number.isInteger(c) && c >= 1 && c <= 1_000_000))
|
|
158
|
+
return falsch('amountCents');
|
|
159
|
+
if (v.type === 'single_purpose') {
|
|
160
|
+
if (!(typeof v.vatRateBp === 'number' && EXTERNAL_VOUCHER_VAT_RATES_BP.includes(v.vatRateBp)))
|
|
161
|
+
return falsch('vatRateBp');
|
|
162
|
+
}
|
|
163
|
+
else if (v.vatRateBp != null) {
|
|
164
|
+
return falsch('vatRateBp');
|
|
165
|
+
}
|
|
166
|
+
if (v.taxedWith != null) {
|
|
167
|
+
if (v.type !== 'single_purpose' || v.action === 'sell')
|
|
168
|
+
return falsch('taxedWith');
|
|
169
|
+
const t = typeof v.taxedWith === 'string' ? v.taxedWith.trim() : '';
|
|
170
|
+
if (t.length < 1 || t.length > EXTERNAL_VOUCHER_TAXED_WITH_MAX || STEUERZEICHEN.test(t))
|
|
171
|
+
return falsch('taxedWith');
|
|
172
|
+
}
|
|
173
|
+
if (v.action === 'payout') {
|
|
174
|
+
const g = typeof v.reason === 'string' ? v.reason.trim() : '';
|
|
175
|
+
if (g.length < 1 || g.length > 200)
|
|
176
|
+
return falsch('reason');
|
|
177
|
+
}
|
|
178
|
+
// Uebrige Serverfelder am Wunsch: wie bei eigenen Gutscheinen nie sendbar.
|
|
179
|
+
return voucherIsValid(v) ? null : falsch('Angaben');
|
|
180
|
+
}
|
|
124
181
|
/**
|
|
125
182
|
* Wuensche und gelesene Eintraege in Positionen und Belegeintraege, wie
|
|
126
183
|
* `plane` sie baut. `kunde` sind Ware und Trinkgeld in innerer Form.
|
|
@@ -166,11 +223,19 @@ export function planeGutscheine(kunde, vouchers, art, o) {
|
|
|
166
223
|
return nein('voucher_invalid', 'Gutscheine der neuen Form gibt es nicht auf Schulungsbelegen.');
|
|
167
224
|
if (kunde.some(istGutscheinZeile))
|
|
168
225
|
return nein('voucher_invalid', 'Gutschein-Positionen setzt nur der Server.');
|
|
226
|
+
const freigabe = o.externalVouchers ?? o.voucherSettings?.externalVouchers;
|
|
227
|
+
const nummern = new Set();
|
|
169
228
|
for (const [i, v] of vouchers.entries()) {
|
|
170
229
|
if (istGelesen(v))
|
|
171
230
|
return nein('voucher_invalid', `Gutschein ${i + 1}: Serverfelder an einem Wunsch.`);
|
|
172
231
|
if (!isNewFormVoucher(v))
|
|
173
232
|
continue;
|
|
233
|
+
if (isExternalVoucher(v)) {
|
|
234
|
+
const f = pruefeFremd(v, i, freigabe, nummern);
|
|
235
|
+
if (f)
|
|
236
|
+
return f;
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
174
239
|
if (istWertVerkauf(v) && v.typeId == null) {
|
|
175
240
|
// Wie gutschein-beleg.pruefeWuensche: ein Wert-Verkauf ohne Sorte ist voucher_type_required.
|
|
176
241
|
// Nur eine alte Gutschein-Einstellung MIT Art (Aufrufer bis 1.16) rechnet wie bisher; ein Server ab
|
|
@@ -197,7 +262,8 @@ export function planeGutscheine(kunde, vouchers, art, o) {
|
|
|
197
262
|
if (wuensche.some((v) => v.action === 'payout') && vouchers.some((v) => !isNewFormVoucher(v) && v.type === 'promo')) {
|
|
198
263
|
return nein('voucher_invalid', 'Rabatt und Auszahlung gehen nicht am selben Beleg.');
|
|
199
264
|
}
|
|
200
|
-
|
|
265
|
+
// Die Nummer eines Fremdgutscheins prueft pruefeFremd (external_voucher_duplicate).
|
|
266
|
+
const codes = wuensche.filter((v) => v.action !== 'sell' && !isExternalVoucher(v)).map((v) => normalerCode(v.code));
|
|
201
267
|
if (codes.some((c) => c == null))
|
|
202
268
|
return nein('voucher_invalid', 'Ein Gutscheincode ist ungueltig.');
|
|
203
269
|
if (new Set(codes).size !== codes.length)
|
|
@@ -243,6 +309,55 @@ export function planeGutscheine(kunde, vouchers, art, o) {
|
|
|
243
309
|
gutscheine.push(g);
|
|
244
310
|
continue;
|
|
245
311
|
}
|
|
312
|
+
if (isExternalVoucher(v)) {
|
|
313
|
+
// gutschein-beleg.plane mit sichtExtern: kein Dokument, kein Saldo, keine Statuspruefung.
|
|
314
|
+
const c = v.amountCents;
|
|
315
|
+
const satz = v.type === 'single_purpose' ? v.vatRateBp : 0;
|
|
316
|
+
if (v.action === 'sell') {
|
|
317
|
+
if (v.type === 'multi_purpose') {
|
|
318
|
+
if (nulltopf) {
|
|
319
|
+
zusatz.push(position(0, c, 'voucher_float'));
|
|
320
|
+
gutscheine.push({ action: 'sell', type: 'value', value: c / 100, imNullTopf: true });
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
gutscheine.push({ action: 'sell', type: 'value', value: c / 100 });
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
// Kleinunternehmer verkauft befreit: Satz 0, egal was gesendet wird.
|
|
328
|
+
zusatz.push(position(ku ? 0 : satz, c, 'voucher'));
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
else if (v.action === 'payout') {
|
|
332
|
+
if (v.type === 'multi_purpose') {
|
|
333
|
+
zusatz.push(position(0, -c, 'voucher_float'));
|
|
334
|
+
gutscheine.push({ action: 'payout', type: 'value', value: c / 100, imNullTopf: true });
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
// Ohne Dokument berichtigt ein Kleinunternehmer-Konto im 0-%-Topf (nie USt, die es nie geschuldet hat).
|
|
338
|
+
zusatz.push(position(ku ? 0 : satz, -c, 'voucher'));
|
|
339
|
+
}
|
|
340
|
+
auszahlungCents += c;
|
|
341
|
+
}
|
|
342
|
+
else if (v.type === 'multi_purpose') {
|
|
343
|
+
gutscheine.push({ action: 'redeem', type: 'value', value: c / 100 });
|
|
344
|
+
}
|
|
345
|
+
else if (satz === 0 || ku) {
|
|
346
|
+
// Befreit verkauft (Satz 0) oder Kleinunternehmer-Konto: anteilig auf alle Toepfe des Korbs.
|
|
347
|
+
const teile = kuTeile(kunde, c);
|
|
348
|
+
if (!teile)
|
|
349
|
+
return nein('voucher_rate_mismatch', `Gutschein ${i + 1}: der Korb deckt den Betrag nicht.`);
|
|
350
|
+
for (const t of teile) {
|
|
351
|
+
zusatz.push(position(t.satzBp, -t.cents, 'voucher'));
|
|
352
|
+
minus(t.satzBp, t.cents);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
zusatz.push(position(satz, -c, 'voucher'));
|
|
357
|
+
minus(satz, c);
|
|
358
|
+
}
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
246
361
|
if (istWertVerkauf(v) && v.typeId != null) {
|
|
247
362
|
// Verkauf ueber eine Sorte (gutschein-beleg.plane): unbekannt, andere Art, falscher Fixbetrag. Eine andere Art
|
|
248
363
|
// heisst: die Kasse hat eine alte Sicht (Sorte umgestellt) – wie ein anderer Fixbetrag voucher_amount_mismatch,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VatRate, VoucherAction, VoucherType } from '../enums/index.js';
|
|
2
|
-
import { CANCELLATION_REASONS, isCancellationReason, receiptCompanyTaxInfo, receiptItemTotalCents, isDiscountItem, isTipItem, receiptSubSumCents, receiptSumCents, receiptValueVoucherSign, voucherIsValid, } from '../models/index.js';
|
|
2
|
+
import { CANCELLATION_REASONS, isCancellationReason, receiptCompanyTaxInfo, receiptItemTotalCents, isDiscountItem, isTipItem, receiptSubSumCents, receiptSumCents, receiptValueVoucherSign, voucherIsValid, isExternalVoucher, } from '../models/index.js';
|
|
3
3
|
import { parseServerTimeStamp, toViennaWallClock } from '../vienna-time.js';
|
|
4
4
|
import { KasseneckValidationError } from '../client/errors.js';
|
|
5
5
|
import { addOnDisplayOrder, istGueltigerZusatz } from '../pos/zusaetze.js';
|
|
@@ -571,6 +571,10 @@ function nettoAusBrutto(bruttoCents, rate) {
|
|
|
571
571
|
* nennt, allein stehen bleibt.
|
|
572
572
|
*/
|
|
573
573
|
function gutscheinText(voucher) {
|
|
574
|
+
// Fremdgutschein: die Nummer des fremden Systems voll, ohne Gutscheinart (die steht beim Verkauf in der Position).
|
|
575
|
+
const fremd = fremdZeile(voucher);
|
|
576
|
+
if (fremd != null)
|
|
577
|
+
return fremd;
|
|
574
578
|
let text = '';
|
|
575
579
|
if (voucher.type === VoucherType.value) {
|
|
576
580
|
text += 'Wertgutschein';
|
|
@@ -616,6 +620,15 @@ function gutscheinText(voucher) {
|
|
|
616
620
|
* Text „ Grund: <Grund>“
|
|
617
621
|
* Aktion Rabattzeile wie bisher (Aktionsgutschein)
|
|
618
622
|
*
|
|
623
|
+
* Fremdgutschein wie der eigene, nur mit „Gutschein Nr. <Nummer>“ statt der
|
|
624
|
+
* (`source: 'external'`) Maske: Verkauf „Gutschein Nr. W-77 (Mehrzweckgutschein)“ bzw.
|
|
625
|
+
* „(Einzweckgutschein 20 %)“ (Name der Position vom Server),
|
|
626
|
+
* Einloesung Einzweck 8:4 „Gutschein Nr. FG-1234“ | „-20,00 A“ und
|
|
627
|
+
* Text „ Einzweck, versteuert mit FG-1234-V“ (nur mit
|
|
628
|
+
* `taxedWith`), Mehrzweck nach „Zwischensumme“ „Gutschein Nr.
|
|
629
|
+
* W-77“ | „-3,00 €“, Auszahlung „Auszahlung Gutschein Nr. …“;
|
|
630
|
+
* nie „Rest am Gutschein“ (den Saldo kennt nur das fremde System)
|
|
631
|
+
*
|
|
619
632
|
* Vermerke sind Textzeilen mit zwei fuehrenden Leerzeichen; das Raster bricht
|
|
620
633
|
* sie mit demselben Einzug um (grid.ts, haengender Einzug), auf 58 mm etwa
|
|
621
634
|
* „ Einzweck, versteuert mit“ / „ Beleg K1-ID-4711“.
|
|
@@ -658,6 +671,16 @@ function gutscheinEndung(voucher) {
|
|
|
658
671
|
return typeof voucher.code === 'string' && voucher.code.length >= 4 && voucher.code !== 'no-code' ? voucher.code.slice(-4) : null;
|
|
659
672
|
}
|
|
660
673
|
const MEHRZWECK_UST_TEXT = ' USt bei Einlösung';
|
|
674
|
+
/** Zeile eines Fremdgutscheins `Gutschein Nr. <Nummer>`; null bei einem eigenen Gutschein oder ohne Nummer. */
|
|
675
|
+
function fremdZeile(voucher) {
|
|
676
|
+
return isExternalVoucher(voucher) && typeof voucher.number === 'string' && voucher.number !== '' ? `Gutschein Nr. ${voucher.number}` : null;
|
|
677
|
+
}
|
|
678
|
+
/** Ein gelesener Eintrag mit Wert: beim Fremdgutschein ganze positive Cent, sonst wie [voucherIsValid]. */
|
|
679
|
+
function eintragGueltig(voucher) {
|
|
680
|
+
if (!isExternalVoucher(voucher))
|
|
681
|
+
return voucherIsValid(voucher);
|
|
682
|
+
return Number.isSafeInteger(voucher.valueCents) && voucher.valueCents > 0;
|
|
683
|
+
}
|
|
661
684
|
/**
|
|
662
685
|
* Welche Gutscheinposition (`voucher`/`voucher_float`) gehoert zu welchem
|
|
663
686
|
* Eintrag? Jede Position hoechstens einem Eintrag, Eintraege in ihrer
|
|
@@ -686,10 +709,11 @@ function gutscheinPositionen(receipt) {
|
|
|
686
709
|
zuordnung.set(i, { voucher, letzte: true });
|
|
687
710
|
continue;
|
|
688
711
|
}
|
|
712
|
+
const fremd = fremdZeile(voucher);
|
|
689
713
|
const endung = gutscheinEndung(voucher);
|
|
690
|
-
if (endung == null || (voucher.action !== VoucherAction.redeem && voucher.action !== VoucherAction.payout))
|
|
714
|
+
if ((fremd == null && endung == null) || (voucher.action !== VoucherAction.redeem && voucher.action !== VoucherAction.payout))
|
|
691
715
|
continue;
|
|
692
|
-
const name = `${voucher.action === VoucherAction.payout ? 'Auszahlung ' : ''}Gutschein ····-${endung}`;
|
|
716
|
+
const name = `${voucher.action === VoucherAction.payout ? 'Auszahlung ' : ''}${fremd ?? `Gutschein ····-${endung}`}`;
|
|
693
717
|
const ziel = Number.isInteger(voucher.amountCents) ? Math.abs(voucher.amountCents) : Math.abs(voucher.valueCents ?? 0);
|
|
694
718
|
const genommen = [];
|
|
695
719
|
let summe = 0;
|
|
@@ -735,6 +759,12 @@ function gutscheinPositionsZeilen(item, satz, zu) {
|
|
|
735
759
|
return zeilen;
|
|
736
760
|
}
|
|
737
761
|
const art = v.type === VoucherType.service ? 'Leistung' : 'Einzweck';
|
|
762
|
+
if (isExternalVoucher(v)) {
|
|
763
|
+
// Fremdgutschein: Vermerk nur mit `taxedWith` (Beleg im fremden System, wie gesendet), kein Rest.
|
|
764
|
+
if (typeof v.taxedWith === 'string' && v.taxedWith !== '')
|
|
765
|
+
zeilen.push(textZeile(` ${art}, versteuert mit ${v.taxedWith}`));
|
|
766
|
+
return zeilen;
|
|
767
|
+
}
|
|
738
768
|
if (typeof v.taxedWith === 'string' && v.taxedWith !== '') {
|
|
739
769
|
zeilen.push(textZeile(` ${art}, versteuert mit Beleg ${v.taxedWith}`));
|
|
740
770
|
}
|
|
@@ -1213,17 +1243,18 @@ export function buildReceiptLayout(receipt, company, options = {}) {
|
|
|
1213
1243
|
continue;
|
|
1214
1244
|
const wert = voucher.valueCents ?? 0;
|
|
1215
1245
|
const vz = voucher.type === VoucherType.value ? wgVz : 1;
|
|
1216
|
-
if (
|
|
1246
|
+
if (eintragGueltig(voucher) && voucher.action === VoucherAction.sell) {
|
|
1217
1247
|
gruppeVon(steuersatz(VatRate.vat0)).bruttoCents += vz * wert;
|
|
1218
1248
|
}
|
|
1219
1249
|
if (voucher.action === VoucherAction.sell && voucher.type === VoucherType.value) {
|
|
1220
1250
|
// Mehrzweck mit Code (vor dem Stichtag nur als Eintrag): wie die Position im 0-%-Topf.
|
|
1221
1251
|
const mehrzweck = istMehrzweckMitCode(voucher);
|
|
1222
1252
|
const code = gutscheinCodeZusatz(voucher);
|
|
1253
|
+
const fremd = fremdZeile(voucher);
|
|
1223
1254
|
lines.push({
|
|
1224
1255
|
kind: 'columns',
|
|
1225
1256
|
columns: [
|
|
1226
|
-
{ text: `1 x ${mehrzweck ? `Mehrzweckgutschein${code}` : gutscheinText(voucher)}`, width: 7, align: 'left' },
|
|
1257
|
+
{ text: `1 x ${fremd != null ? `${fremd} (Mehrzweckgutschein)` : mehrzweck ? `Mehrzweckgutschein${code}` : gutscheinText(voucher)}`, width: 7, align: 'left' },
|
|
1227
1258
|
{ text: `${formatCents(vz * wert)} ${VatRate.vat0.category}`, width: 5, align: 'right' },
|
|
1228
1259
|
],
|
|
1229
1260
|
});
|
|
@@ -1303,8 +1334,10 @@ export function buildReceiptLayout(receipt, company, options = {}) {
|
|
|
1303
1334
|
// (Zahlungszeile laut Spec); eine Auszahlung ohne `zeroRateBucket`
|
|
1304
1335
|
// (schreibt der Server nicht) zaehlt wie in receiptSumCents.
|
|
1305
1336
|
const wert = voucher.valueCents ?? 0;
|
|
1306
|
-
|
|
1307
|
-
const
|
|
1337
|
+
// Fremdgutschein: „Gutschein Nr. <Nummer>“, nie ein Rest (den Saldo kennt nur das fremde System).
|
|
1338
|
+
const fremd = fremdZeile(voucher);
|
|
1339
|
+
const endung = fremd == null && istMehrzweckMitCode(voucher) ? gutscheinEndung(voucher) : null;
|
|
1340
|
+
const text = fremd ?? (endung != null ? `Gutschein ····-${endung}` : gutscheinText(voucher));
|
|
1308
1341
|
lines.push(paarZeile(voucher.action === VoucherAction.payout ? `Auszahlung ${text}` : text, wgVz === 1 ? `-${formatCents(wert)} €` : `${formatCents(wert)} €`, 8, 4));
|
|
1309
1342
|
if (endung != null && wgVz === 1 && Number.isInteger(voucher.balanceAfterCents)) {
|
|
1310
1343
|
lines.push(paarZeile(' Rest am Gutschein', `${formatCents(voucher.balanceAfterCents)} €`, 8, 4));
|
package/dist/esm/stored/draht.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { KasseneckValidationError } from '../client/errors.js';
|
|
2
|
-
import { ARTIKEL_FELDER, KATALOGE, SCHEMAS } from './vokabular.js';
|
|
2
|
+
import { ARTIKEL_FELDER, KATALOGE, SCHEMAS, ZUSATZ_KATALOGE } from './vokabular.js';
|
|
3
3
|
export const hat = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
|
|
4
4
|
export const istObjekt = (w) => w !== null && typeof w === 'object' && !Array.isArray(w);
|
|
5
5
|
/** Schema-Eintrag zerlegt: innerer Name, Unterschema (ohne `__`) und ob es eine Liste ist. */
|
|
@@ -148,6 +148,8 @@ const BELEG_GUTSCHEIN = {
|
|
|
148
148
|
article: 'artikel', articleId: 'artikelId', quantity: 'stueck', positions: 'positionen',
|
|
149
149
|
balanceAfterCents: 'saldoNachCents', remainingQuantityAfter: 'stueckOffenNach', taxedWith: 'versteuertMit', exempt: 'befreit',
|
|
150
150
|
reason: 'grund', zeroRateBucket: 'imNullTopf', typeId: 'sorteId', typeName: 'sorteName', payout: 'auszahlung',
|
|
151
|
+
// Fremdgutschein: source external (GUTSCHEIN_QUELLE) und die Nummer des fremden Systems.
|
|
152
|
+
source: 'quelle', number: 'nummer',
|
|
151
153
|
};
|
|
152
154
|
const BELEG_GUTSCHEIN_AUSSEN = Object.fromEntries(Object.entries(BELEG_GUTSCHEIN).map(([aussen, innen]) => [innen, aussen]));
|
|
153
155
|
const GUTSCHEIN_ARTIKEL_AUSSEN = { satzBp: 'vatRateBp', preisCents: 'priceCents' };
|
|
@@ -160,6 +162,7 @@ function gutscheinEintragNachAussen(v) {
|
|
|
160
162
|
return v;
|
|
161
163
|
const art = KATALOGE.GUTSCHEIN_ART ?? {};
|
|
162
164
|
const auszahlung = KATALOGE.GUTSCHEIN_AUSZAHLUNG ?? {};
|
|
165
|
+
const quelle = ZUSATZ_KATALOGE.GUTSCHEIN_QUELLE ?? {};
|
|
163
166
|
const typNeu = typeof v.type === 'string' && hat(art, v.type);
|
|
164
167
|
if (!typNeu && !Object.keys(v).some((k) => hat(BELEG_GUTSCHEIN_AUSSEN, k)))
|
|
165
168
|
return v;
|
|
@@ -171,6 +174,8 @@ function gutscheinEintragNachAussen(v) {
|
|
|
171
174
|
raus.voucherType = typeof w === 'string' && hat(art, w) ? art[w] : w;
|
|
172
175
|
else if (k === 'artikel')
|
|
173
176
|
raus.article = istObjekt(w) ? umbenannt(w, GUTSCHEIN_ARTIKEL_AUSSEN) : w;
|
|
177
|
+
else if (k === 'quelle')
|
|
178
|
+
raus.source = typeof w === 'string' && hat(quelle, w) ? quelle[w] : w;
|
|
174
179
|
else if (k === 'auszahlung')
|
|
175
180
|
raus.payout = typeof w === 'string' && hat(auszahlung, w) ? auszahlung[w] : w;
|
|
176
181
|
else
|
|
@@ -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 = "3c729299a204cf522158317aa38dcad5bb8ef797c44e9369faecc94be4717d78";
|
|
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 {
|
|
@@ -18,3 +18,5 @@ export declare const SCHEMAS: Readonly<Record<'getReceipt' | 'getKasseSettings'
|
|
|
18
18
|
export declare const ARTIKEL_FELDER: readonly string[];
|
|
19
19
|
/** Wertkataloge innen (deutsch) -> aussen (englisch). */
|
|
20
20
|
export declare const KATALOGE: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
21
|
+
/** Kataloge der Gutschein-Eintraege am Beleg ohne Schemaverweis (`quelle` eines Fremdgutscheins), innen -> aussen. */
|
|
22
|
+
export declare const ZUSATZ_KATALOGE: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Erzeugt von scripts/stored-vokabular.mjs aus fixtures/v3/v3-vokabular.json.
|
|
2
2
|
// Nicht von Hand aendern: test/stored.test.ts vergleicht mit dem Vertrag.
|
|
3
3
|
/** Fingerabdruck des Vertrags-Exports, aus dem diese Datei stammt (`_quelle.sha256`). */
|
|
4
|
-
export const VOKABULAR_QUELLE = "
|
|
4
|
+
export const VOKABULAR_QUELLE = "3c729299a204cf522158317aa38dcad5bb8ef797c44e9369faecc94be4717d78";
|
|
5
5
|
/** Schema je Endpunkt (aussen -> innen) und Wertverweise auf die Kataloge. */
|
|
6
6
|
export const SCHEMAS = {
|
|
7
7
|
"getReceipt": {
|
|
@@ -44,6 +44,7 @@ export const SCHEMAS = {
|
|
|
44
44
|
},
|
|
45
45
|
"testCashregister": "testKasse",
|
|
46
46
|
"testSignature": "testSignatur",
|
|
47
|
+
"deprecation": "deprecation",
|
|
47
48
|
"logo_scale": "logo_skala",
|
|
48
49
|
"layout": {
|
|
49
50
|
"__": "layout",
|
|
@@ -288,6 +289,7 @@ export const SCHEMAS = {
|
|
|
288
289
|
}
|
|
289
290
|
],
|
|
290
291
|
"serviceArticles": "leistungsArtikel",
|
|
292
|
+
"externalVouchers": "fremd",
|
|
291
293
|
"returnType": {
|
|
292
294
|
"__": "rueckgabe",
|
|
293
295
|
"typeId": "sorteId",
|
|
@@ -373,6 +375,11 @@ export const SCHEMAS = {
|
|
|
373
375
|
},
|
|
374
376
|
"vouchers.types[].payout": {
|
|
375
377
|
"$catalog": "GUTSCHEIN_AUSZAHLUNG"
|
|
378
|
+
},
|
|
379
|
+
"vouchers.externalVouchers": {
|
|
380
|
+
"aus": "off",
|
|
381
|
+
"wert": "multi_purpose",
|
|
382
|
+
"beide": "all"
|
|
376
383
|
}
|
|
377
384
|
}
|
|
378
385
|
},
|
|
@@ -745,3 +752,9 @@ export const KATALOGE = {
|
|
|
745
752
|
"sonstiges": "other"
|
|
746
753
|
}
|
|
747
754
|
};
|
|
755
|
+
/** Kataloge der Gutschein-Eintraege am Beleg ohne Schemaverweis (`quelle` eines Fremdgutscheins), innen -> aussen. */
|
|
756
|
+
export const ZUSATZ_KATALOGE = {
|
|
757
|
+
"GUTSCHEIN_QUELLE": {
|
|
758
|
+
"extern": "external"
|
|
759
|
+
}
|
|
760
|
+
};
|
package/dist/esm/version.d.ts
CHANGED
package/dist/esm/version.js
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Bäckerei Kornblum
|
|
2
|
+
Neubaugasse 12
|
|
3
|
+
1070 Wien
|
|
4
|
+
ATU12345675
|
|
5
|
+
+43 1 2345678
|
|
6
|
+
|
|
7
|
+
Datum: 05.11.2026 10:15:30
|
|
8
|
+
Kassen-ID: KASSE1
|
|
9
|
+
Beleg-ID: AT0-KASSE1-90
|
|
10
|
+
|
|
11
|
+
1 x 20,00 A
|
|
12
|
+
Brauereiführung
|
|
13
|
+
1 x Bier 0,5 4,50 A
|
|
14
|
+
Gutschein Nr. -20,00 A
|
|
15
|
+
FG-1234
|
|
16
|
+
Einzweck, versteuert mit
|
|
17
|
+
FG-1234-V
|
|
18
|
+
|
|
19
|
+
MwSt% MwSt Netto Brutto
|
|
20
|
+
A 20% 0,75 3,75 4,50
|
|
21
|
+
--------------------------------
|
|
22
|
+
Zwischensumme 4,50 €
|
|
23
|
+
Gutschein Nr. W-77 -3,00 €
|
|
24
|
+
--------------------------------
|
|
25
|
+
Gesamt: 1,50 €
|
|
26
|
+
Zahlungsart: Barzahlung
|
|
27
|
+
|
|
28
|
+
[QR-Code]
|
|
29
|
+
|
|
30
|
+
Danke für Ihren Besuch
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Bäckerei Kornblum
|
|
2
|
+
Neubaugasse 12
|
|
3
|
+
1070 Wien
|
|
4
|
+
ATU12345675
|
|
5
|
+
+43 1 2345678
|
|
6
|
+
|
|
7
|
+
Datum: 05.11.2026 10:15:30
|
|
8
|
+
Kassen-ID: KASSE1
|
|
9
|
+
Beleg-ID: AT0-KASSE1-90
|
|
10
|
+
|
|
11
|
+
1 x Brauereiführung 20,00 A
|
|
12
|
+
1 x Bier 0,5 4,50 A
|
|
13
|
+
Gutschein Nr. FG-1234 -20,00 A
|
|
14
|
+
Einzweck, versteuert mit FG-1234-V
|
|
15
|
+
|
|
16
|
+
MwSt% MwSt Netto Brutto
|
|
17
|
+
A 20% 0,75 3,75 4,50
|
|
18
|
+
------------------------------------------------
|
|
19
|
+
Zwischensumme 4,50 €
|
|
20
|
+
Gutschein Nr. W-77 -3,00 €
|
|
21
|
+
------------------------------------------------
|
|
22
|
+
Gesamt: 1,50 €
|
|
23
|
+
Zahlungsart: Barzahlung
|
|
24
|
+
|
|
25
|
+
[QR-Code]
|
|
26
|
+
|
|
27
|
+
Danke für Ihren Besuch
|