@kreiseck/kasseneck-api 1.30.0 → 1.31.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.
Files changed (89) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/index.d.ts +1 -1
  3. package/dist/cjs/index.js +7 -5
  4. package/dist/cjs/models/index.d.ts +1 -1
  5. package/dist/cjs/models/index.js +4 -2
  6. package/dist/cjs/models/voucher.d.ts +18 -0
  7. package/dist/cjs/models/voucher.js +32 -1
  8. package/dist/cjs/pos/artikel.d.ts +12 -0
  9. package/dist/cjs/pos/artikel.js +2 -0
  10. package/dist/cjs/pos/client.js +11 -0
  11. package/dist/cjs/pos/errors.d.ts +1 -1
  12. package/dist/cjs/pos/errors.js +1 -0
  13. package/dist/cjs/pos/fremdgutschein-artikel.d.ts +66 -0
  14. package/dist/cjs/pos/fremdgutschein-artikel.js +74 -0
  15. package/dist/cjs/pos/index.d.ts +6 -3
  16. package/dist/cjs/pos/index.js +42 -4
  17. package/dist/cjs/pos/rabatt-vorlagen.d.ts +79 -0
  18. package/dist/cjs/pos/rabatt-vorlagen.js +156 -0
  19. package/dist/cjs/pos/schicht-lesen.js +8 -0
  20. package/dist/cjs/pos/schicht-typen.d.ts +15 -0
  21. package/dist/cjs/pos/settings.d.ts +69 -3
  22. package/dist/cjs/pos/settings.js +72 -5
  23. package/dist/cjs/pos/texte.d.ts +215 -0
  24. package/dist/cjs/pos/texte.js +124 -1
  25. package/dist/cjs/pos/zusaetze.d.ts +3 -3
  26. package/dist/cjs/pos/zusaetze.js +4 -2
  27. package/dist/cjs/receipt/shift-sheet.js +8 -0
  28. package/dist/cjs/stored/draht.js +1 -0
  29. package/dist/cjs/stored/einstellungen.js +50 -2
  30. package/dist/cjs/stored/vokabular.d.ts +1 -1
  31. package/dist/cjs/stored/vokabular.js +38 -4
  32. package/dist/cjs/version.d.ts +1 -1
  33. package/dist/cjs/version.js +1 -1
  34. package/dist/esm/index.d.ts +1 -1
  35. package/dist/esm/index.js +1 -1
  36. package/dist/esm/models/index.d.ts +1 -1
  37. package/dist/esm/models/index.js +1 -1
  38. package/dist/esm/models/voucher.d.ts +18 -0
  39. package/dist/esm/models/voucher.js +30 -0
  40. package/dist/esm/pos/artikel.d.ts +12 -0
  41. package/dist/esm/pos/artikel.js +2 -0
  42. package/dist/esm/pos/client.js +12 -1
  43. package/dist/esm/pos/errors.d.ts +1 -1
  44. package/dist/esm/pos/errors.js +1 -0
  45. package/dist/esm/pos/fremdgutschein-artikel.d.ts +66 -0
  46. package/dist/esm/pos/fremdgutschein-artikel.js +67 -0
  47. package/dist/esm/pos/index.d.ts +6 -3
  48. package/dist/esm/pos/index.js +7 -3
  49. package/dist/esm/pos/rabatt-vorlagen.d.ts +79 -0
  50. package/dist/esm/pos/rabatt-vorlagen.js +148 -0
  51. package/dist/esm/pos/schicht-lesen.js +8 -0
  52. package/dist/esm/pos/schicht-typen.d.ts +15 -0
  53. package/dist/esm/pos/settings.d.ts +69 -3
  54. package/dist/esm/pos/settings.js +67 -4
  55. package/dist/esm/pos/texte.d.ts +215 -0
  56. package/dist/esm/pos/texte.js +122 -0
  57. package/dist/esm/pos/zusaetze.d.ts +3 -3
  58. package/dist/esm/pos/zusaetze.js +4 -2
  59. package/dist/esm/receipt/shift-sheet.js +8 -0
  60. package/dist/esm/stored/draht.js +1 -0
  61. package/dist/esm/stored/einstellungen.js +52 -4
  62. package/dist/esm/stored/vokabular.d.ts +1 -1
  63. package/dist/esm/stored/vokabular.js +38 -4
  64. package/dist/esm/version.d.ts +1 -1
  65. package/dist/esm/version.js +1 -1
  66. package/fixtures/add-on-cases.json +6 -4
  67. package/fixtures/discount-preset-cases.json +1074 -0
  68. package/fixtures/external-voucher-article-cases.json +311 -0
  69. package/fixtures/hobex-hps-codes.json +1 -1
  70. package/fixtures/invoice-api.schema.json +1 -1
  71. package/fixtures/invoice-texts.json +1 -1
  72. package/fixtures/pos-texts.json +205 -1
  73. package/fixtures/receipt-due-voucher-generated.json +1 -1
  74. package/fixtures/renames-1.0.json +18 -0
  75. package/fixtures/surface.json +49 -4
  76. package/fixtures/v3/antworten/belege.json +1 -1
  77. package/fixtures/v3/antworten/belegmail.json +1 -1
  78. package/fixtures/v3/antworten/berichte.json +1 -1
  79. package/fixtures/v3/antworten/kasse-belege.json +1 -1
  80. package/fixtures/v3/antworten/kasse.json +2 -2
  81. package/fixtures/v3/antworten/lager.json +1 -1
  82. package/fixtures/v3/antworten/rechnungen.json +1 -1
  83. package/fixtures/v3/antworten/storno.json +1 -1
  84. package/fixtures/v3/stored/belege.json +1 -1
  85. package/fixtures/v3/stored/kasse.json +2 -2
  86. package/fixtures/v3/stored/rechnungen.json +1 -1
  87. package/fixtures/v3/v3-vokabular.json +95 -9
  88. package/fixtures/v3/zahlbetrag-faelle.json +1 -1
  89. package/package.json +1 -1
@@ -6,6 +6,7 @@ const errors_js_1 = require("../client/errors.js");
6
6
  const texte_js_1 = require("../pos/texte.js");
7
7
  const schicht_lesen_js_1 = require("../pos/schicht-lesen.js");
8
8
  const schicht_js_1 = require("../pos/schicht.js");
9
+ const rabatt_vorlagen_js_1 = require("../pos/rabatt-vorlagen.js");
9
10
  const vienna_time_js_1 = require("../vienna-time.js");
10
11
  const layout_js_1 = require("./layout.js");
11
12
  const PAPIER = ['mm58', 'mm80'];
@@ -191,6 +192,13 @@ function shiftReceiptLayout(receipt, options = {}) {
191
192
  for (const u of bon.nonCashByMethod)
192
193
  zeilen.push(betrag(zahlartText(u.method), u.cents));
193
194
  }
195
+ // Gewaehrte Rabatte je Name: nur wenn es welche gab, sonst bleibt der Bon wie bisher.
196
+ const rabatte = (0, rabatt_vorlagen_js_1.discountBlockLines)(bon.discounts);
197
+ if (rabatte.length > 0) {
198
+ zeilen.push(text((0, texte_js_1.labelText)('shift_receipt.discounts'), 'left', true));
199
+ for (const r of rabatte)
200
+ zeilen.push(betrag(r.label, r.cents));
201
+ }
194
202
  zeilen.push(anzahl((0, texte_js_1.labelText)('shift_receipt.receipts'), bon.receiptCount));
195
203
  zeilen.push(anzahl((0, texte_js_1.labelText)('shift_receipt.cancellations'), bon.cancellationCount));
196
204
  zeilen.push(anzahl((0, texte_js_1.labelText)('shift_receipt.openings_without_sale'), bon.openingsWithoutSale));
@@ -313,6 +313,7 @@ function _storedArticleToWire(id, doc, functionName = 'fromStoredArticle') {
313
313
  const katalog = (pfad) => aeussereWerte(schema.werte[pfad]);
314
314
  const raus = nurBekannte(artikel, new Set(vokabular_js_1.ARTIKEL_FELDER), {
315
315
  quantityRule: katalog('articles[].quantityRule'), e1aGroup: katalog('articles[].e1aGroup'),
316
+ externalVoucher: katalog('articles[].externalVoucher'),
316
317
  });
317
318
  if ((0, exports.istObjekt)(raus.tile)) {
318
319
  const kachel = regel(regel(schema.data.articles).unter.tile).unter;
@@ -5,6 +5,7 @@ exports._storedPosSettingsToWire = _storedPosSettingsToWire;
5
5
  const settings_js_1 = require("../pos/settings.js");
6
6
  const draht_js_1 = require("./draht.js");
7
7
  const draht_js_2 = require("./draht.js");
8
+ const rabatt_vorlagen_js_1 = require("../pos/rabatt-vorlagen.js");
8
9
  const vokabular_js_1 = require("./vokabular.js");
9
10
  const bool = (v) => typeof v === 'boolean';
10
11
  const hex = (v) => typeof v === 'string' && /^#[0-9a-fA-F]{6}$/.test(v);
@@ -138,6 +139,38 @@ function aufzaehlung(liste, katalog, w) {
138
139
  return 'ungueltig';
139
140
  return 'unbekannt';
140
141
  }
142
+ /**
143
+ * Rabatt-Vorlagen (Zwilling von `rabatt-vorlagen-core.liste` und dem Schema `discountPresets`): die gespeicherte Liste
144
+ * `[{ name, art, prozentBp | betragCents }]` geht nur hinaus, wenn die Pruefung sie annimmt (sonst faellt sie ganz);
145
+ * ausgegeben wird sie wie gespeichert (nicht getrimmt), eine ungueltige fehlt still, uebersetzt in `kind`/`percentBp`/`amountCents`. Ein englischer
146
+ * Wert in `art` oder ein englischer Feldname ist innen unbekannt und macht die Liste ungueltig.
147
+ */
148
+ function vorlagenNachAussen(w) {
149
+ const schema = teilSchema('business').discountPresets;
150
+ const aussenName = (0, draht_js_1.innereNamen)((0, draht_js_1.regel)(schema).unter); // innen -> aussen
151
+ const art = vokabular_js_1.KATALOGE['KASSE_BETRIEB_WERTE.discountPresets[].kind'] ?? {};
152
+ if (!Array.isArray(w))
153
+ return undefined;
154
+ const draht = w.map((e) => {
155
+ if (!(0, draht_js_1.istObjekt)(e))
156
+ return e;
157
+ const raus = {};
158
+ for (const [k, v] of Object.entries(e)) {
159
+ if (k === 'art')
160
+ raus[aussenName.get('art') ?? 'kind'] = typeof v === 'string' && (0, draht_js_1.hat)(art, v) ? art[v] : undefined;
161
+ else if (k === 'name')
162
+ raus[k] = v;
163
+ else if (k === 'prozentBp' || k === 'betragCents')
164
+ raus[aussenName.get(k) ?? k] = v;
165
+ // Jeder andere Schluessel (auch ein englischer wie `percentBp`) ist innen unbekannt.
166
+ else
167
+ raus[`innen_${k}`] = v;
168
+ }
169
+ return raus;
170
+ });
171
+ const geprueft = (0, rabatt_vorlagen_js_1.checkDiscountPresets)(draht);
172
+ return geprueft.ok ? draht : undefined;
173
+ }
141
174
  function teilNachAussen(teil, gespeichert, weg) {
142
175
  if (!(0, draht_js_1.istObjekt)(gespeichert))
143
176
  return {};
@@ -150,6 +183,13 @@ function teilNachAussen(teil, gespeichert, weg) {
150
183
  if (aussen === undefined || w === undefined)
151
184
  continue;
152
185
  const pfad = `${teil}.${aussen}`;
186
+ if (teil === 'business' && aussen === 'discountPresets') {
187
+ const liste = vorlagenNachAussen(w);
188
+ // Wie jede optionale Einstellung: ungueltig fehlt still (mischeBetrieb nimmt sie gar nicht erst), ohne Eintrag in `weg`.
189
+ if (liste !== undefined)
190
+ raus[aussen] = liste;
191
+ continue;
192
+ }
153
193
  if ((0, draht_js_1.hat)(WAHLFELDER, teil) && WAHLFELDER[teil].includes(aussen)) {
154
194
  const katalog = katalogFuer(teil, aussen);
155
195
  const einzeln = (e) => (typeof e === 'string' && katalog !== null && (0, draht_js_1.hat)(katalog, e) ? katalog[e] : undefined);
@@ -226,6 +266,14 @@ function teilNachAussen(teil, gespeichert, weg) {
226
266
  else
227
267
  weg.push(pfad);
228
268
  }
269
+ // Mit gueltigen Vorlagen folgen die Chips immer den Vorlagen (mischeBetrieb), auch ein ungueltiges gespeichertes
270
+ // `rabattChips` faellt dann nicht erst am Validator.
271
+ if (teil === 'business' && (0, draht_js_1.hat)(raus, 'discountPresets')) {
272
+ raus.discountChips = (0, rabatt_vorlagen_js_1.discountChipsFromPresets)(raus.discountPresets);
273
+ const i = weg.indexOf('business.discountChips');
274
+ if (i >= 0)
275
+ weg.splice(i, 1);
276
+ }
229
277
  return raus;
230
278
  }
231
279
  /**
@@ -242,10 +290,10 @@ function _storedPosSettingsToWire(stored) {
242
290
  }
243
291
  /** Nur fuer den Test: die Feldliste der Pruefer (muss mit der Vorgabe deckungsgleich sein). */
244
292
  exports._PRUEFER_FELDER = Object.freeze({
245
- business: [...new Set([...Object.keys(PRUEFER.business), ...Object.keys(settings_js_1.POS_BUSINESS_VALUES), ...Object.keys(BETRIEB_OPTIONAL), ...Object.keys(KARTEN)])],
293
+ business: [...new Set([...Object.keys(PRUEFER.business), ...Object.keys(settings_js_1.POS_BUSINESS_VALUES), ...Object.keys(BETRIEB_OPTIONAL), ...Object.keys(KARTEN), ...settings_js_1.POS_BUSINESS_OPTIONAL_LISTS])],
246
294
  device: [...new Set([...Object.keys(PRUEFER.device), ...Object.keys(settings_js_1.POS_DEVICE_VALUES), ...Object.keys(GERAET_OPTIONAL), 'shortcuts'])],
247
295
  standard: {
248
- business: [...Object.keys(settings_js_1.POS_BUSINESS_DEFAULTS), ...settings_js_1.POS_BUSINESS_OPTIONAL_FIELDS, ...settings_js_1.POS_BUSINESS_OPTIONAL_CHOICES],
296
+ business: [...Object.keys(settings_js_1.POS_BUSINESS_DEFAULTS), ...settings_js_1.POS_BUSINESS_OPTIONAL_FIELDS, ...settings_js_1.POS_BUSINESS_OPTIONAL_CHOICES, ...settings_js_1.POS_BUSINESS_OPTIONAL_LISTS],
249
297
  device: [...Object.keys(settings_js_1.POS_DEVICE_DEFAULTS), ...settings_js_1.POS_DEVICE_OPTIONAL_FIELDS, ...settings_js_1.POS_DEVICE_OPTIONAL_CHOICES],
250
298
  },
251
299
  });
@@ -1,5 +1,5 @@
1
1
  /** Fingerabdruck des Vertrags-Exports, aus dem diese Datei stammt (`_quelle.sha256`). */
2
- export declare const VOKABULAR_QUELLE = "3c729299a204cf522158317aa38dcad5bb8ef797c44e9369faecc94be4717d78";
2
+ export declare const VOKABULAR_QUELLE = "04ab5e1d031979a4f0aa31ea000f4cbe1d6e557e2411e439899ac19a1bba0325";
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.ZUSATZ_KATALOGE = 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 = "3c729299a204cf522158317aa38dcad5bb8ef797c44e9369faecc94be4717d78";
7
+ exports.VOKABULAR_QUELLE = "04ab5e1d031979a4f0aa31ea000f4cbe1d6e557e2411e439899ac19a1bba0325";
8
8
  /** Schema je Endpunkt (aussen -> innen) und Wertverweise auf die Kataloge. */
9
9
  exports.SCHEMAS = {
10
10
  "getReceipt": {
@@ -154,6 +154,7 @@ exports.SCHEMAS = {
154
154
  "tipChips": "tgChips",
155
155
  "exactCash": "schnellbar",
156
156
  "tipKeptByDefault": "tgDirekt",
157
+ "tipKeptMode": "tgDirektModus",
157
158
  "tipKinds": "tgArten",
158
159
  "tipStart": "tgStart",
159
160
  "checkoutMode": "kassierenModus",
@@ -168,7 +169,16 @@ exports.SCHEMAS = {
168
169
  "watermarkScale": "wzSkala",
169
170
  "glass": "glas",
170
171
  "hints": "hinweise",
171
- "discountChips": "rabattChips"
172
+ "discountChips": "rabattChips",
173
+ "discountPresets": [
174
+ {
175
+ "__": "rabattVorlagen",
176
+ "kind": "art",
177
+ "percentBp": "prozentBp",
178
+ "amountCents": "betragCents"
179
+ }
180
+ ],
181
+ "customDiscountAllowed": "rabattFrei"
172
182
  },
173
183
  "device": {
174
184
  "__": "geraet",
@@ -333,6 +343,12 @@ exports.SCHEMAS = {
333
343
  "business.tipStart": {
334
344
  "$catalog": "KASSE_BETRIEB_WERTE.tipStart"
335
345
  },
346
+ "business.tipKeptMode": {
347
+ "$catalog": "KASSE_BETRIEB_WERTE.tipKeptMode"
348
+ },
349
+ "business.discountPresets[].kind": {
350
+ "$catalog": "KASSE_BETRIEB_WERTE.discountPresets[].kind"
351
+ },
336
352
  "business.checkoutMode": {
337
353
  "$catalog": "KASSE_BETRIEB_WERTE.checkoutMode"
338
354
  },
@@ -411,7 +427,8 @@ exports.SCHEMAS = {
411
427
  "pattern": "muster",
412
428
  "patternStrict": "musterStreng"
413
429
  },
414
- "addOns": "zusaetze"
430
+ "addOns": "zusaetze",
431
+ "externalVoucher": "fremdgutschein"
415
432
  }
416
433
  ]
417
434
  },
@@ -424,6 +441,9 @@ exports.SCHEMAS = {
424
441
  },
425
442
  "articles[].reference.mode": {
426
443
  "$catalog": "REFERENZ_STUFE"
444
+ },
445
+ "articles[].externalVoucher": {
446
+ "$catalog": "ARTIKEL_FREMDGUTSCHEIN"
427
447
  }
428
448
  }
429
449
  }
@@ -457,10 +477,15 @@ exports.ARTIKEL_FELDER = [
457
477
  "minStockByLocation",
458
478
  "askPrice",
459
479
  "reference",
460
- "addOns"
480
+ "addOns",
481
+ "externalVoucher"
461
482
  ];
462
483
  /** Wertkataloge innen (deutsch) -> aussen (englisch). */
463
484
  exports.KATALOGE = {
485
+ "ARTIKEL_FREMDGUTSCHEIN": {
486
+ "mehrzweck": "multi_purpose",
487
+ "einzweck": "single_purpose"
488
+ },
464
489
  "AUSGABE_ART": {
465
490
  "erstdruck": "print",
466
491
  "duplikat": "reprint",
@@ -654,6 +679,10 @@ exports.KATALOGE = {
654
679
  "aus": "off",
655
680
  "an": "on"
656
681
  },
682
+ "KASSE_BETRIEB_WERTE.discountPresets[].kind": {
683
+ "prozent": "percent",
684
+ "betrag": "amount"
685
+ },
657
686
  "KASSE_BETRIEB_WERTE.quantity": {
658
687
  "aus": "off",
659
688
  "x": "x",
@@ -676,6 +705,11 @@ exports.KATALOGE = {
676
705
  "streifen": "stripe",
677
706
  "voll": "full"
678
707
  },
708
+ "KASSE_BETRIEB_WERTE.tipKeptMode": {
709
+ "fragen": "ask",
710
+ "immer": "always",
711
+ "nie": "never"
712
+ },
679
713
  "KASSE_BETRIEB_WERTE.tipKinds[]": {
680
714
  "prozent": "percent",
681
715
  "aufrunden": "round_up",
@@ -4,4 +4,4 @@
4
4
  * Client-Version, Nachtrag §6). Ein Test haelt sie gleich mit `package.json`;
5
5
  * beim Anheben der Version beide Stellen aendern.
6
6
  */
7
- export declare const PACKAGE_VERSION = "1.30.0";
7
+ export declare const PACKAGE_VERSION = "1.31.0";
@@ -7,4 +7,4 @@ exports.PACKAGE_VERSION = void 0;
7
7
  * Client-Version, Nachtrag §6). Ein Test haelt sie gleich mit `package.json`;
8
8
  * beim Anheben der Version beide Stellen aendern.
9
9
  */
10
- exports.PACKAGE_VERSION = '1.30.0';
10
+ exports.PACKAGE_VERSION = '1.31.0';
@@ -1,5 +1,5 @@
1
1
  export { ReceiptType, type ReceiptTypeKey, VatRate, type VatRateKey, KeckPaymentMethod, type KeckPaymentMethodKey, CreditCardProvider, type CreditCardProviderKey, VoucherType, type VoucherTypeKey, VoucherAction, type VoucherActionKey, StripeLinkMode, type StripeLinkModeKey, } from './enums/index.js';
2
- export { type ReceiptItem, type ReceiptItemPayload, type ReceiptItemPayloadRead, toReceiptItemPayload, fromReceiptItemPayload, receiptItemTotalCents, receiptItemIsValid, negateReceiptItem, type TipRecipient, isTipItem, isVoucherItem, isVoucherFloatItem, type Voucher, type VoucherArticle, type IssuedVoucher, type ReturnIssuedVoucher, type VoucherPayload, toVoucherPayload, fromVoucherPayload, voucherIsValid, type VoucherSource, type LegacyValueVoucherWish, VOUCHER_SOURCES, isExternalVoucher, externalVoucherIsValid, normalizeExternalVoucherNumber, checkExternalVoucherNumber, type ExternalVoucherNumberCheck, EXTERNAL_VOUCHER_NUMBER_MAX, EXTERNAL_VOUCHER_TAXED_WITH_MAX, EXTERNAL_VOUCHER_VAT_RATES_BP, type Receipt, type RegistrationInfo, type ReceiptPayload, type ReceiptPayloadRead, toReceiptPayload, fromReceiptPayload, receiptSubSumCents, receiptSumCents, receiptValueVoucherSign, type CancellationOf, type CancellationItem, type Cancellation, type CancellationReason, type CancellationErrorCode, type CancellationStatus, type ReturnDisposition, RETURN_DISPOSITIONS, CANCELLATION_REASONS, CANCELLATION_STATUSES, CANCELLATION_ERROR_CODES, CANCELLATION_RESERVATION_MS, isCancellationReason, isReturnDisposition, isCancellationErrorCode, cancellationErrorCode, isCancellationError, cancellationFieldErrors, type CancellationFieldError, type ReceiptPayment, type ReceiptPaymentPayload, type ReceiptPaymentInput, fromReceiptPaymentPayload, toReceiptPaymentPayload, type PaymentErrorCode, PAYMENT_ERROR_CODES, isPaymentErrorCode, paymentErrorCode, isPaymentError, paymentFieldErrors, type PaymentFieldError, type ReceiptEmailErrorCode, type ReceiptEmailVia, RECEIPT_EMAIL_ERROR_CODES, RECEIPT_EMAIL_SEND_ERROR_CODES, type ReceiptEmailSendErrorCode, RECEIPT_EMAIL_VIAS, isReceiptEmailErrorCode, receiptEmailErrorCode, isReceiptEmailError, receiptEmailFieldErrors, type ReceiptEmailFieldError, RECEIPT_OUTPUT_KINDS, type ReceiptOutputKind, RECEIPT_OUTPUT_LOG_KINDS, type ReceiptOutputLogKind, RECEIPT_OUTPUT_RESULTS, type ReceiptOutputResult, RECEIPT_OUTPUT_ENTRIES_MAX, type ReceiptOutput, type ReceiptOutputActor, RECEIPT_OUTPUT_ENTRY_ERROR_CODES, type ReceiptOutputEntryErrorCode, RECEIPT_OUTPUT_ERROR_CODES, type ReceiptOutputErrorCode, isReceiptOutputErrorCode, receiptOutputErrorCode, isReceiptOutputError, receiptOutputFieldErrors, type ReceiptOutputFieldError, type ReceiptErrorCode, type ReceiptFieldError, RECEIPT_ERROR_CODES, isReceiptErrorCode, receiptErrorCode, isReceiptError, receiptFieldErrors, remainingQuantities, TIP_REFUND_SOURCES, type TipRefundSource, isTipRefundSource, openStaffTipCents, cancellationItemsForTip, cancellationCashRefundCents, asksTipRefundSource, asksRefundTip, type ReceiptCompany, type ReceiptCompanyPayload, fromReceiptCompanyPayload, receiptCompanyTaxInfo, type Cashregister, type CashregisterOnboarding, type CashregisterPayload, type CashregisterOnboardingPayload, type CashregisterAutoLogout, type CashregisterAutoLogoutPayload, fromCashregisterPayload, type ReceiptSummary, type ReceiptSummaryPayload, fromReceiptSummaryPayload, type ZeroKind, ZERO_KINDS, isZeroKind, type ReportMonth, reportMonthFromDate, previousReportMonth, nextReportMonth, reportMonthKey, reportMonthReadable, type StripeUrlSession, type StripeUrlSessionPayload, toStripeUrlSessionPayload, fromStripeUrlSessionPayload, type HobexReceipt, type HobexReceiptPayload, toHobexReceiptPayload, fromHobexReceiptPayload, hobexReceiptToCardPaymentData, hobexReceiptNeedsSignature, } from './models/index.js';
2
+ export { type ReceiptItem, type ReceiptItemPayload, type ReceiptItemPayloadRead, toReceiptItemPayload, fromReceiptItemPayload, receiptItemTotalCents, receiptItemIsValid, negateReceiptItem, type TipRecipient, isTipItem, isVoucherItem, isVoucherFloatItem, type Voucher, type VoucherArticle, type IssuedVoucher, type ReturnIssuedVoucher, type VoucherPayload, toVoucherPayload, fromVoucherPayload, voucherIsValid, type VoucherSource, type LegacyValueVoucherWish, VOUCHER_SOURCES, isExternalVoucher, externalVoucherIsValid, normalizeExternalVoucherNumber, checkExternalVoucherNumber, ownVoucherCodeShape, OWN_VOUCHER_CODE_SHAPES, type OwnVoucherCodeShape, type ExternalVoucherNumberCheck, EXTERNAL_VOUCHER_NUMBER_MAX, EXTERNAL_VOUCHER_TAXED_WITH_MAX, EXTERNAL_VOUCHER_VAT_RATES_BP, type Receipt, type RegistrationInfo, type ReceiptPayload, type ReceiptPayloadRead, toReceiptPayload, fromReceiptPayload, receiptSubSumCents, receiptSumCents, receiptValueVoucherSign, type CancellationOf, type CancellationItem, type Cancellation, type CancellationReason, type CancellationErrorCode, type CancellationStatus, type ReturnDisposition, RETURN_DISPOSITIONS, CANCELLATION_REASONS, CANCELLATION_STATUSES, CANCELLATION_ERROR_CODES, CANCELLATION_RESERVATION_MS, isCancellationReason, isReturnDisposition, isCancellationErrorCode, cancellationErrorCode, isCancellationError, cancellationFieldErrors, type CancellationFieldError, type ReceiptPayment, type ReceiptPaymentPayload, type ReceiptPaymentInput, fromReceiptPaymentPayload, toReceiptPaymentPayload, type PaymentErrorCode, PAYMENT_ERROR_CODES, isPaymentErrorCode, paymentErrorCode, isPaymentError, paymentFieldErrors, type PaymentFieldError, type ReceiptEmailErrorCode, type ReceiptEmailVia, RECEIPT_EMAIL_ERROR_CODES, RECEIPT_EMAIL_SEND_ERROR_CODES, type ReceiptEmailSendErrorCode, RECEIPT_EMAIL_VIAS, isReceiptEmailErrorCode, receiptEmailErrorCode, isReceiptEmailError, receiptEmailFieldErrors, type ReceiptEmailFieldError, RECEIPT_OUTPUT_KINDS, type ReceiptOutputKind, RECEIPT_OUTPUT_LOG_KINDS, type ReceiptOutputLogKind, RECEIPT_OUTPUT_RESULTS, type ReceiptOutputResult, RECEIPT_OUTPUT_ENTRIES_MAX, type ReceiptOutput, type ReceiptOutputActor, RECEIPT_OUTPUT_ENTRY_ERROR_CODES, type ReceiptOutputEntryErrorCode, RECEIPT_OUTPUT_ERROR_CODES, type ReceiptOutputErrorCode, isReceiptOutputErrorCode, receiptOutputErrorCode, isReceiptOutputError, receiptOutputFieldErrors, type ReceiptOutputFieldError, type ReceiptErrorCode, type ReceiptFieldError, RECEIPT_ERROR_CODES, isReceiptErrorCode, receiptErrorCode, isReceiptError, receiptFieldErrors, remainingQuantities, TIP_REFUND_SOURCES, type TipRefundSource, isTipRefundSource, openStaffTipCents, cancellationItemsForTip, cancellationCashRefundCents, asksTipRefundSource, asksRefundTip, type ReceiptCompany, type ReceiptCompanyPayload, fromReceiptCompanyPayload, receiptCompanyTaxInfo, type Cashregister, type CashregisterOnboarding, type CashregisterPayload, type CashregisterOnboardingPayload, type CashregisterAutoLogout, type CashregisterAutoLogoutPayload, fromCashregisterPayload, type ReceiptSummary, type ReceiptSummaryPayload, fromReceiptSummaryPayload, type ZeroKind, ZERO_KINDS, isZeroKind, type ReportMonth, reportMonthFromDate, previousReportMonth, nextReportMonth, reportMonthKey, reportMonthReadable, type StripeUrlSession, type StripeUrlSessionPayload, toStripeUrlSessionPayload, fromStripeUrlSessionPayload, type HobexReceipt, type HobexReceiptPayload, toHobexReceiptPayload, fromHobexReceiptPayload, hobexReceiptToCardPaymentData, hobexReceiptNeedsSignature, } from './models/index.js';
3
3
  export { type AuthCredentials, type KasseneckAuth, type ApiKeyAuthOptions, type RegisterUserAuthOptions, apiKeyAuth, registerUserAuth, DEFAULT_BASE_URL, POS_BASE_URL, DEFAULT_TIMEOUT_MS, type HttpResponseLike, type HttpRequestInit, type FetchLike, type TransportOptions, type TransportBodyFields, type TransportCallOptions, type KasseneckTransport, type KasseneckBinaryTransport, type KasseneckPdfOrDataTransport, type PdfOrData, ALL_CALLS, type ApiCall, PUBLIC_CALLS, POS_CALLS, UNKNOWN_OUTCOME_CALLS, type PublicCall, type PosCall, createTransport, createBinaryTransport, createPdfOrDataTransport, createFileOrDataTransport, type FileOrData, type FileOrDataCallOptions, type KasseneckFileOrDataTransport, KasseneckApiError, KasseneckAuthError, KasseneckHttpError, KasseneckNetworkError, KasseneckValidationError, type ValidationScope, type KasseneckError, type HttpFailureReason, type CauseDigest, type ErrorOutcome, CLIENT_ERROR_CODES, type ClientErrorCode, isKasseneckApiError, isKasseneckAuthError, isKasseneckHttpError, isKasseneckNetworkError, isKasseneckValidationError, isOutcomeUnknown, type ReceiptCommonOptions, type SellReceiptOptions, type TipOptions, type TipRecipientShare, type CancelReceiptOptions, type CancelReceiptResult, type ReceiptWithCompany, sellReceipt, sellReceiptWithCompany, paymentsExpectedCents, cardRefundReference, receiptLayoutFromResult, cancelReceipt, zeroReceipt, getReceipt, getReceiptWithCompany, generateFullReceiptId, getFirstReceiptDate, listMyReceipts, type ListMyReceiptsOptions, type ReceiptList, type ReceiptListStats, listMyCashregisters, checkVoucherCombinationError, type SendReceiptEmailOptions, type SendReceiptEmailResult, sendReceiptEmail, type ReceiptOutputEntry, type LogReceiptOutputsOptions, type LogReceiptOutputsResult, type RejectedReceiptOutput, logReceiptOutputs, downloadDailyReport, downloadMonthlyReport, getCashregisterReport, type CashregisterReportPeriod, getReportV2, type ReportV2, type ReportV2Metadata, type ReportV2Options, listReceipts, listAllReceipts, fromListReceiptsSummaryPayload, listedReceiptWithCompany, LIST_RECEIPTS_VIEWS, LIST_RECEIPTS_ORDERS, LIST_RECEIPTS_LIMIT_MAX, LIST_RECEIPTS_DAYS_MAX, LIST_ALL_RECEIPTS_MAX_PAGES, LIST_RECEIPTS_ERROR_CODES, type ListReceiptsErrorCode, type ListReceiptsView, type ListReceiptsOrder, type ListReceiptsOptions, type ListReceiptsWindow, type ListReceiptsGrossByRate, type ListReceiptsSummary, type ListReceiptsDaySummary, type ListReceiptsPage, type ListedReceipt, createDepExport, getDepExport, waitForDepExport, getDepExportFile, createDepHandoverLink, revokeDepHandoverLink, DepExportTimeoutError, DepExportChecksumError, DEP_EXPORT_STATUSES, DEP_EXPORT_FILES, DEP_EXPORT_ERROR_CODES, DEP_EXPORT_FAILURES, DEP_EXPORT_POLL_START_MS, DEP_EXPORT_POLL_FACTOR, DEP_EXPORT_POLL_MAX_MS, DEP_EXPORT_WAIT_TIMEOUT_MS, DEP_EXPORT_DOWNLOAD_TIMEOUT_MS, type DepExportStatus, type DepExportFileKind, type DepExportErrorCode, type DepExportFailure, type CreateDepExportOptions, type CreateDepExportResult, type DepExportGap, type DepExportChainBreak, type DepExportFindings, type DepExportItems, type DepHandoverLinkInfo, type DepExport, type WaitForDepExportOptions, type GetDepExportFileOptions, type DepExportFile, type DepHandoverLink, type RevokedDepHandoverLink, registerTerminalDevice, getTerminalAccess, claimTerminal, requestTerminalCode, getTerminalCode, reportTerminalLogin, reportTerminalReady, TERMINAL_PLATFORMS, TERMINAL_SETUP_STATES, TERMINAL_CODE_STATUSES, TERMINAL_CODE_SOURCES, TERMINAL_ERROR_CODES, TERMINAL_LABEL_MAX, TERMINAL_APP_MAX, TERMINAL_REQUESTED_BY_MAX, type TerminalPlatform, type TerminalSetupState, type TerminalCodeStatus, type TerminalCodeSource, type TerminalErrorCode, type TerminalDeviceCredentials, type RegisterTerminalDeviceOptions, type RegisteredTerminalDevice, type GetTerminalAccessOptions, type ClaimTerminalOptions, type RequestTerminalCodeOptions, type ReportTerminalLoginOptions, type TerminalSetup, type TerminalCodeFormat, type TerminalAccess, type TerminalListEntry, type TerminalAccessUnavailable, type TerminalAccessResult, type TerminalCodeRequest, type TerminalCode, type ListedFullReceipt, type ListReceiptsHeader, type CashboxStatus, type SignatureStatus, getCashboxStatus, getSignatureStatus, type KasseneckApi, createKasseneckApi, } from './client/index.js';
4
4
  export { type ReceiptDueTip, type ReceiptDueTipRecipient, type ReceiptDueOptions, type ReceiptDueBuckets, type ReceiptDueBreakdown, type ReceiptDueErrorReason, receiptDueCents, receiptDueBreakdown, ReceiptDueError, RECEIPT_DUE_ERROR_REASONS, isReceiptDueError, type VoucherDueInfo, type VoucherDueArticle, type VoucherDueType, type VoucherRedeemContext, voucherRedeemMaxCents, VOUCHER_ZERO_RATE_BUCKET_FROM, } from './receipt/due.js';
5
5
  export { parseServerTimeStamp, toViennaWallClock, type ViennaWallClock } from './vienna-time.js';
package/dist/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { ReceiptType, VatRate, KeckPaymentMethod, CreditCardProvider, VoucherType, VoucherAction, StripeLinkMode, } from './enums/index.js';
2
- export { toReceiptItemPayload, fromReceiptItemPayload, receiptItemTotalCents, receiptItemIsValid, negateReceiptItem, isTipItem, isVoucherItem, isVoucherFloatItem, toVoucherPayload, fromVoucherPayload, voucherIsValid, VOUCHER_SOURCES, isExternalVoucher, externalVoucherIsValid, normalizeExternalVoucherNumber, checkExternalVoucherNumber, EXTERNAL_VOUCHER_NUMBER_MAX, EXTERNAL_VOUCHER_TAXED_WITH_MAX, EXTERNAL_VOUCHER_VAT_RATES_BP, toReceiptPayload, fromReceiptPayload, receiptSubSumCents, receiptSumCents, receiptValueVoucherSign, RETURN_DISPOSITIONS, CANCELLATION_REASONS, CANCELLATION_STATUSES, CANCELLATION_ERROR_CODES, CANCELLATION_RESERVATION_MS, isCancellationReason, isReturnDisposition, isCancellationErrorCode, cancellationErrorCode, isCancellationError, cancellationFieldErrors, fromReceiptPaymentPayload, toReceiptPaymentPayload, PAYMENT_ERROR_CODES, isPaymentErrorCode, paymentErrorCode, isPaymentError, paymentFieldErrors, RECEIPT_EMAIL_ERROR_CODES, RECEIPT_EMAIL_SEND_ERROR_CODES, RECEIPT_EMAIL_VIAS, isReceiptEmailErrorCode, receiptEmailErrorCode, isReceiptEmailError, receiptEmailFieldErrors, RECEIPT_OUTPUT_KINDS, RECEIPT_OUTPUT_LOG_KINDS, RECEIPT_OUTPUT_RESULTS, RECEIPT_OUTPUT_ENTRIES_MAX, RECEIPT_OUTPUT_ENTRY_ERROR_CODES, RECEIPT_OUTPUT_ERROR_CODES, isReceiptOutputErrorCode, receiptOutputErrorCode, isReceiptOutputError, receiptOutputFieldErrors, RECEIPT_ERROR_CODES, isReceiptErrorCode, receiptErrorCode, isReceiptError, receiptFieldErrors, remainingQuantities, TIP_REFUND_SOURCES, isTipRefundSource, openStaffTipCents, cancellationItemsForTip, cancellationCashRefundCents, asksTipRefundSource, asksRefundTip, fromReceiptCompanyPayload, receiptCompanyTaxInfo, fromCashregisterPayload, fromReceiptSummaryPayload, ZERO_KINDS, isZeroKind, reportMonthFromDate, previousReportMonth, nextReportMonth, reportMonthKey, reportMonthReadable, toStripeUrlSessionPayload, fromStripeUrlSessionPayload, toHobexReceiptPayload, fromHobexReceiptPayload, hobexReceiptToCardPaymentData, hobexReceiptNeedsSignature, } from './models/index.js';
2
+ export { toReceiptItemPayload, fromReceiptItemPayload, receiptItemTotalCents, receiptItemIsValid, negateReceiptItem, isTipItem, isVoucherItem, isVoucherFloatItem, toVoucherPayload, fromVoucherPayload, voucherIsValid, VOUCHER_SOURCES, isExternalVoucher, externalVoucherIsValid, normalizeExternalVoucherNumber, checkExternalVoucherNumber, ownVoucherCodeShape, OWN_VOUCHER_CODE_SHAPES, EXTERNAL_VOUCHER_NUMBER_MAX, EXTERNAL_VOUCHER_TAXED_WITH_MAX, EXTERNAL_VOUCHER_VAT_RATES_BP, toReceiptPayload, fromReceiptPayload, receiptSubSumCents, receiptSumCents, receiptValueVoucherSign, RETURN_DISPOSITIONS, CANCELLATION_REASONS, CANCELLATION_STATUSES, CANCELLATION_ERROR_CODES, CANCELLATION_RESERVATION_MS, isCancellationReason, isReturnDisposition, isCancellationErrorCode, cancellationErrorCode, isCancellationError, cancellationFieldErrors, fromReceiptPaymentPayload, toReceiptPaymentPayload, PAYMENT_ERROR_CODES, isPaymentErrorCode, paymentErrorCode, isPaymentError, paymentFieldErrors, RECEIPT_EMAIL_ERROR_CODES, RECEIPT_EMAIL_SEND_ERROR_CODES, RECEIPT_EMAIL_VIAS, isReceiptEmailErrorCode, receiptEmailErrorCode, isReceiptEmailError, receiptEmailFieldErrors, RECEIPT_OUTPUT_KINDS, RECEIPT_OUTPUT_LOG_KINDS, RECEIPT_OUTPUT_RESULTS, RECEIPT_OUTPUT_ENTRIES_MAX, RECEIPT_OUTPUT_ENTRY_ERROR_CODES, RECEIPT_OUTPUT_ERROR_CODES, isReceiptOutputErrorCode, receiptOutputErrorCode, isReceiptOutputError, receiptOutputFieldErrors, RECEIPT_ERROR_CODES, isReceiptErrorCode, receiptErrorCode, isReceiptError, receiptFieldErrors, remainingQuantities, TIP_REFUND_SOURCES, isTipRefundSource, openStaffTipCents, cancellationItemsForTip, cancellationCashRefundCents, asksTipRefundSource, asksRefundTip, fromReceiptCompanyPayload, receiptCompanyTaxInfo, fromCashregisterPayload, fromReceiptSummaryPayload, ZERO_KINDS, isZeroKind, reportMonthFromDate, previousReportMonth, nextReportMonth, reportMonthKey, reportMonthReadable, toStripeUrlSessionPayload, fromStripeUrlSessionPayload, toHobexReceiptPayload, fromHobexReceiptPayload, hobexReceiptToCardPaymentData, hobexReceiptNeedsSignature, } from './models/index.js';
3
3
  export { apiKeyAuth, registerUserAuth, DEFAULT_BASE_URL, POS_BASE_URL, DEFAULT_TIMEOUT_MS, ALL_CALLS, PUBLIC_CALLS, POS_CALLS, UNKNOWN_OUTCOME_CALLS, createTransport, createBinaryTransport, createPdfOrDataTransport, createFileOrDataTransport, KasseneckApiError, KasseneckAuthError, KasseneckHttpError, KasseneckNetworkError, KasseneckValidationError, CLIENT_ERROR_CODES, isKasseneckApiError, isKasseneckAuthError, isKasseneckHttpError, isKasseneckNetworkError, isKasseneckValidationError, isOutcomeUnknown, sellReceipt, sellReceiptWithCompany, paymentsExpectedCents, cardRefundReference, receiptLayoutFromResult, cancelReceipt, zeroReceipt, getReceipt, getReceiptWithCompany, generateFullReceiptId, getFirstReceiptDate, listMyReceipts, listMyCashregisters, checkVoucherCombinationError, sendReceiptEmail, logReceiptOutputs, downloadDailyReport, downloadMonthlyReport, getCashregisterReport, getReportV2, listReceipts, listAllReceipts, fromListReceiptsSummaryPayload, listedReceiptWithCompany, LIST_RECEIPTS_VIEWS, LIST_RECEIPTS_ORDERS, LIST_RECEIPTS_LIMIT_MAX, LIST_RECEIPTS_DAYS_MAX, LIST_ALL_RECEIPTS_MAX_PAGES, LIST_RECEIPTS_ERROR_CODES, createDepExport, getDepExport, waitForDepExport, getDepExportFile, createDepHandoverLink, revokeDepHandoverLink, DepExportTimeoutError, DepExportChecksumError, DEP_EXPORT_STATUSES, DEP_EXPORT_FILES, DEP_EXPORT_ERROR_CODES, DEP_EXPORT_FAILURES, DEP_EXPORT_POLL_START_MS, DEP_EXPORT_POLL_FACTOR, DEP_EXPORT_POLL_MAX_MS, DEP_EXPORT_WAIT_TIMEOUT_MS, DEP_EXPORT_DOWNLOAD_TIMEOUT_MS, registerTerminalDevice, getTerminalAccess, claimTerminal, requestTerminalCode, getTerminalCode, reportTerminalLogin, reportTerminalReady, TERMINAL_PLATFORMS, TERMINAL_SETUP_STATES, TERMINAL_CODE_STATUSES, TERMINAL_CODE_SOURCES, TERMINAL_ERROR_CODES, TERMINAL_LABEL_MAX, TERMINAL_APP_MAX, TERMINAL_REQUESTED_BY_MAX, getCashboxStatus, getSignatureStatus, createKasseneckApi, } from './client/index.js';
4
4
  export { receiptDueCents, receiptDueBreakdown, ReceiptDueError, RECEIPT_DUE_ERROR_REASONS, isReceiptDueError, voucherRedeemMaxCents, VOUCHER_ZERO_RATE_BUCKET_FROM, } from './receipt/due.js';
5
5
  export { parseServerTimeStamp, toViennaWallClock } from './vienna-time.js';
@@ -1,5 +1,5 @@
1
1
  export { type ReceiptItem, type ReceiptItemPayload, type ReceiptItemPayloadRead, toReceiptItemPayload, fromReceiptItemPayload, receiptItemTotalCents, receiptItemIsValid, negateReceiptItem, type TipRecipient, isTipItem, isDiscountItem, isVoucherItem, isVoucherFloatItem, } from './receipt-item.js';
2
- export { type Voucher, type VoucherArticle, type IssuedVoucher, type ReturnIssuedVoucher, type VoucherPayload, toVoucherPayload, fromVoucherPayload, voucherIsValid, isNewFormVoucher, voucherServerFields, type VoucherSource, type LegacyValueVoucherWish, VOUCHER_SOURCES, isExternalVoucher, externalVoucherIsValid, normalizeExternalVoucherNumber, checkExternalVoucherNumber, type ExternalVoucherNumberCheck, EXTERNAL_VOUCHER_NUMBER_MAX, EXTERNAL_VOUCHER_TAXED_WITH_MAX, EXTERNAL_VOUCHER_VAT_RATES_BP, } from './voucher.js';
2
+ export { type Voucher, type VoucherArticle, type IssuedVoucher, type ReturnIssuedVoucher, type VoucherPayload, toVoucherPayload, fromVoucherPayload, voucherIsValid, isNewFormVoucher, voucherServerFields, type VoucherSource, type LegacyValueVoucherWish, VOUCHER_SOURCES, isExternalVoucher, externalVoucherIsValid, normalizeExternalVoucherNumber, checkExternalVoucherNumber, type ExternalVoucherNumberCheck, ownVoucherCodeShape, OWN_VOUCHER_CODE_SHAPES, type OwnVoucherCodeShape, EXTERNAL_VOUCHER_NUMBER_MAX, EXTERNAL_VOUCHER_TAXED_WITH_MAX, EXTERNAL_VOUCHER_VAT_RATES_BP, } from './voucher.js';
3
3
  export { type Receipt, type RegistrationInfo, type ReceiptPayload, type ReceiptPayloadRead, toReceiptPayload, fromReceiptPayload, readRegistrationInfo, receiptSubSumCents, receiptSumCents, receiptValueVoucherSign, } from './receipt.js';
4
4
  export { type CancellationOf, type CancellationItem, type Cancellation, type CancellationReason, type CancellationErrorCode, type CancellationStatus, type ReturnDisposition, RETURN_DISPOSITIONS, CANCELLATION_REASONS, CANCELLATION_STATUSES, CANCELLATION_ERROR_CODES, CANCELLATION_RESERVATION_MS, isCancellationReason, isReturnDisposition, isCancellationErrorCode, cancellationErrorCode, isCancellationError, cancellationFieldErrors, type CancellationFieldError, remainingQuantities, TIP_REFUND_SOURCES, type TipRefundSource, isTipRefundSource, openStaffTipCents, cancellationItemsForTip, cancellationCashRefundCents, asksTipRefundSource, asksRefundTip, } from './cancellation.js';
5
5
  export { type ReceiptPayment, type ReceiptPaymentPayload, type ReceiptPaymentInput, fromReceiptPaymentPayload, toReceiptPaymentPayload, } from './receipt-payment.js';
@@ -1,5 +1,5 @@
1
1
  export { toReceiptItemPayload, fromReceiptItemPayload, receiptItemTotalCents, receiptItemIsValid, negateReceiptItem, isTipItem, isDiscountItem, isVoucherItem, isVoucherFloatItem, } from './receipt-item.js';
2
- export { toVoucherPayload, fromVoucherPayload, voucherIsValid, isNewFormVoucher, voucherServerFields, VOUCHER_SOURCES, isExternalVoucher, externalVoucherIsValid, normalizeExternalVoucherNumber, checkExternalVoucherNumber, EXTERNAL_VOUCHER_NUMBER_MAX, EXTERNAL_VOUCHER_TAXED_WITH_MAX, EXTERNAL_VOUCHER_VAT_RATES_BP, } from './voucher.js';
2
+ export { toVoucherPayload, fromVoucherPayload, voucherIsValid, isNewFormVoucher, voucherServerFields, VOUCHER_SOURCES, isExternalVoucher, externalVoucherIsValid, normalizeExternalVoucherNumber, checkExternalVoucherNumber, ownVoucherCodeShape, OWN_VOUCHER_CODE_SHAPES, EXTERNAL_VOUCHER_NUMBER_MAX, EXTERNAL_VOUCHER_TAXED_WITH_MAX, EXTERNAL_VOUCHER_VAT_RATES_BP, } from './voucher.js';
3
3
  export { toReceiptPayload, fromReceiptPayload, readRegistrationInfo, receiptSubSumCents, receiptSumCents, receiptValueVoucherSign, } from './receipt.js';
4
4
  export { RETURN_DISPOSITIONS, CANCELLATION_REASONS, CANCELLATION_STATUSES, CANCELLATION_ERROR_CODES, CANCELLATION_RESERVATION_MS, isCancellationReason, isReturnDisposition, isCancellationErrorCode, cancellationErrorCode, isCancellationError, cancellationFieldErrors, remainingQuantities, TIP_REFUND_SOURCES, isTipRefundSource, openStaffTipCents, cancellationItemsForTip, cancellationCashRefundCents, asksTipRefundSource, asksRefundTip, } from './cancellation.js';
5
5
  export { fromReceiptPaymentPayload, toReceiptPaymentPayload, } from './receipt-payment.js';
@@ -242,6 +242,24 @@ export type ExternalVoucherNumberCheck = {
242
242
  * `external_voucher_number_is_own_code`, der Gutschein gehoert als eigener eingeloest –, danach die Form.
243
243
  */
244
244
  export declare function checkExternalVoucherNumber(text: unknown): ExternalVoucherNumberCheck;
245
+ /**
246
+ * Wie sehr eine Eingabe einem eigenen Gutscheincode gleicht ([ownVoucherCodeShape]): `valid` = gueltiger eigener
247
+ * Code; `checksum` = 12 Zeichen des Code-Alphabets mit falschem Pruefzeichen (z. B. eine zwoelfstellige
248
+ * Webshop-Nummer); `length` = Muster `4-4-x` mit echten Bindestrichen `-` (nie `.`, `_`, `/`), aber nicht 12 Zeichen;
249
+ * `none` = keine Aehnlichkeit.
250
+ */
251
+ export type OwnVoucherCodeShape = 'valid' | 'checksum' | 'length' | 'none';
252
+ export declare const OWN_VOUCHER_CODE_SHAPES: readonly OwnVoucherCodeShape[];
253
+ /**
254
+ * Form-Erkennung eigener Codes fuer das Feld „Code eingeben oder scannen“ (Web-Kasse und Kassen-App gleich):
255
+ * `valid` laeuft als eigener Gutschein, `checksum`/`length` fragt die Kasse nach („Sieht aus wie ein
256
+ * Kasseneck-Code, ist aber keiner. Als fremden Gutschein verwenden?“, `external_voucher.looks_like_own_code`),
257
+ * `none` geht bei Freigabe direkt in das Blatt „Fremder Gutschein“. Gelesen wie [checkExternalVoucherNumber]:
258
+ * Rand weg, `.`, `_`, `/` wie `-`, dann die Normalisierung von `VoucherCode` (gross, ohne Leerraum und `-`,
259
+ * O → 0, I/L → 1); `length` nur mit echten Bindestrichen. Eine Nachfrage weist nichts ab: der Server prueft die Fremdnummer selbst
260
+ * (`external_voucher_number_is_own_code` nur bei `valid`).
261
+ */
262
+ export declare function ownVoucherCodeShape(text: unknown): OwnVoucherCodeShape;
245
263
  /**
246
264
  * Ist der Fremdgutschein sendbar? Die Form wie `gutschein-beleg.pruefeFremd` (ohne die Freigabe des Kontos, die
247
265
  * kennt nur der Server bzw. `PosVoucherSettings.externalVouchers`): Aktion `sell`/`redeem`/`payout`, Art
@@ -271,6 +271,36 @@ export function checkExternalVoucherNumber(text) {
271
271
  const number = normalizeExternalVoucherNumber(text);
272
272
  return number === null ? { ok: false, code: 'external_voucher_number_invalid' } : { ok: true, number };
273
273
  }
274
+ export const OWN_VOUCHER_CODE_SHAPES = Object.freeze(['valid', 'checksum', 'length', 'none']);
275
+ /** Alphabet der eigenen Codes (Crockford-Base32 ohne U), nach der Normalisierung von `VoucherCode`. */
276
+ const CODE_ALPHABET = /^[0-9A-HJKMNP-TV-Z]+$/;
277
+ const CODE_GRUPPEN = /^[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]+$/;
278
+ /**
279
+ * Form-Erkennung eigener Codes fuer das Feld „Code eingeben oder scannen“ (Web-Kasse und Kassen-App gleich):
280
+ * `valid` laeuft als eigener Gutschein, `checksum`/`length` fragt die Kasse nach („Sieht aus wie ein
281
+ * Kasseneck-Code, ist aber keiner. Als fremden Gutschein verwenden?“, `external_voucher.looks_like_own_code`),
282
+ * `none` geht bei Freigabe direkt in das Blatt „Fremder Gutschein“. Gelesen wie [checkExternalVoucherNumber]:
283
+ * Rand weg, `.`, `_`, `/` wie `-`, dann die Normalisierung von `VoucherCode` (gross, ohne Leerraum und `-`,
284
+ * O → 0, I/L → 1); `length` nur mit echten Bindestrichen. Eine Nachfrage weist nichts ab: der Server prueft die Fremdnummer selbst
285
+ * (`external_voucher_number_is_own_code` nur bei `valid`).
286
+ */
287
+ export function ownVoucherCodeShape(text) {
288
+ if (typeof text !== 'string')
289
+ return 'none';
290
+ const roh = text.replace(FREMD_RAND_MUSTER, '');
291
+ const t = roh.replace(/[._/]/g, '-');
292
+ if (t === '')
293
+ return 'none';
294
+ if (VoucherCode.validate(t).ok)
295
+ return 'valid';
296
+ const s = t.toUpperCase().replace(/[\s-]/g, '').replace(/O/g, '0').replace(/[IL]/g, '1');
297
+ if (!CODE_ALPHABET.test(s))
298
+ return 'none';
299
+ if (s.length === 12)
300
+ return 'checksum';
301
+ // Falsche Laenge nur mit echten Bindestrichen: eigene Codes stehen immer so da, `WEIN.2026/7` ist keiner.
302
+ return CODE_GRUPPEN.test(roh) ? 'length' : 'none';
303
+ }
274
304
  /** Steuer- und Formatzeichen (`gutschein-core.STEUERZEICHEN`): nie in `taxedWith`. */
275
305
  const STEUERZEICHEN = /[\p{Cc}\p{Cf}]/u;
276
306
  /**
@@ -1,5 +1,6 @@
1
1
  import type { InternerTransport } from '../client/aufrufe.js';
2
2
  import { type PosReference } from './kachel-referenz.js';
3
+ import { type ArticleExternalVoucher } from './fremdgutschein-artikel.js';
3
4
  /**
4
5
  * Artikelgruppen (Kategorien der Kachel-Kasse) und Artikel in der Form, die
5
6
  * die Kacheln brauchen, Backend: `article-endpoints.js`
@@ -121,6 +122,16 @@ export interface PosArticle {
121
122
  * immer; wirksam wird es ueber [addOnsFor].
122
123
  */
123
124
  addOns?: string[] | null;
125
+ /**
126
+ * Kachel verkauft einen fremden Gutschein (1.31.0): `multi_purpose` =
127
+ * Wertgutschein, `single_purpose` = Leistungsgutschein mit dem Satz des
128
+ * Artikels; null = normaler Artikel. Die Kasse fragt die Gutscheinnummer ab
129
+ * und sendet einen `vouchers[]`-Eintrag statt einer Position; sperren ueber
130
+ * [externalVoucherTileBlock]. Vor `stockTracked` werten (ein Fremdgutschein
131
+ * fuehrt nie Bestand). Optional wie `addOns`, der Leser setzt es immer; ein
132
+ * unbekannter Wert wird null.
133
+ */
134
+ externalVoucher?: ArticleExternalVoucher | null;
124
135
  }
125
136
  /**
126
137
  * Kann die Kachel gebucht werden? Mit festem Preis immer, ohne Preis nur mit
@@ -161,6 +172,7 @@ export interface PosArticlePayload {
161
172
  askPrice?: boolean | null;
162
173
  reference?: unknown;
163
174
  addOns?: unknown;
175
+ externalVoucher?: unknown;
164
176
  }
165
177
  export declare function fromPosArticlePayload(p: PosArticlePayload): PosArticle;
166
178
  /**
@@ -1,5 +1,6 @@
1
1
  import { KasseneckValidationError } from '../client/errors.js';
2
2
  import { fromReferencePayload } from './kachel-referenz.js';
3
+ import { isArticleExternalVoucher } from './fremdgutschein-artikel.js';
3
4
  /** Zusatzliste am Draht: nur eine Liste von Texten zaehlt, sonst null. Paketintern. */
4
5
  export function addOnListe(wert) {
5
6
  return Array.isArray(wert) ? wert.filter((s) => typeof s === 'string' && s !== '') : null;
@@ -92,6 +93,7 @@ export function fromPosArticlePayload(p) {
92
93
  askPrice: p.askPrice === true,
93
94
  reference: fromReferencePayload(p.reference),
94
95
  addOns: addOnListe(p.addOns),
96
+ externalVoucher: isArticleExternalVoucher(p.externalVoucher) ? p.externalVoucher : null,
95
97
  };
96
98
  }
97
99
  /**
@@ -1,6 +1,7 @@
1
1
  import { KasseneckValidationError } from '../client/errors.js';
2
2
  import { posVoucherSettingsFromWire } from './gutschein.js';
3
- import { POS_BUSINESS_DEFAULTS, POS_DEVICE_DEFAULTS, POS_BUSINESS_VALUES, POS_DEVICE_VALUES, POS_SHORTCUT_ACTIONS, POS_DEVICE_OPTIONAL_FIELDS, POS_BUSINESS_OPTIONAL_FIELDS, POS_BUSINESS_OPTIONAL_CHOICES, POS_DEVICE_OPTIONAL_CHOICES, mergePosSettings, posShortcutConflict, _istAltwert0x, _optionalerWert, } from './settings.js';
3
+ import { checkDiscountPresets, INVALID_DISCOUNT_PRESET } from './rabatt-vorlagen.js';
4
+ import { POS_BUSINESS_DEFAULTS, POS_DEVICE_DEFAULTS, POS_BUSINESS_VALUES, POS_DEVICE_VALUES, POS_SHORTCUT_ACTIONS, POS_DEVICE_OPTIONAL_FIELDS, POS_BUSINESS_OPTIONAL_FIELDS, POS_BUSINESS_OPTIONAL_CHOICES, POS_BUSINESS_OPTIONAL_LISTS, POS_DEVICE_OPTIONAL_CHOICES, mergePosSettings, posShortcutConflict, _istAltwert0x, _optionalerWert, } from './settings.js';
4
5
  /*
5
6
  * Die Einstellungs-Aufrufe am Draht `/api/v3`: Parameter und Antwort heissen
6
7
  * `business`/`device`, Schluessel und Werte englisch (Nachtrag §11.7.2).
@@ -144,6 +145,16 @@ function pruefeTeil(name, teil, block, standard, werte) {
144
145
  throw new KasseneckValidationError(name, `${teil}.${schluessel}: true oder false erwartet`, 'request');
145
146
  continue;
146
147
  }
148
+ // Rabatt-Vorlagen: dieselbe Pruefung wie am Server, der erste Fehler mit Vorlage, Feld und Satz.
149
+ if (teil === 'business' && POS_BUSINESS_OPTIONAL_LISTS.includes(schluessel)) {
150
+ const geprueft = checkDiscountPresets(wert);
151
+ if (!geprueft.ok) {
152
+ const f = geprueft.errors[0];
153
+ const ort = `${teil}.${schluessel}${f.index === null ? '' : `[${f.index}]`}${f.field === null ? '' : `.${f.field}`}`;
154
+ throw new KasseneckValidationError(name, `${ort}: ${f.message} (${INVALID_DISCOUNT_PRESET})`, 'request');
155
+ }
156
+ continue;
157
+ }
147
158
  const wahl = teil === 'business' ? POS_BUSINESS_OPTIONAL_CHOICES : POS_DEVICE_OPTIONAL_CHOICES;
148
159
  if (!Object.prototype.hasOwnProperty.call(standard, schluessel) && !wahl.includes(schluessel)) {
149
160
  throw new KasseneckValidationError(name, `${teil}.${schluessel}: unbekanntes Feld`, 'request');
@@ -21,7 +21,7 @@ import { KasseneckApiError } from '../client/errors.js';
21
21
  * ueber `KasseneckApiError.code` lesbar; die Kasse braucht dafuer einen
22
22
  * Rueckfallzweig.
23
23
  */
24
- export declare const POS_ERROR_CODES: readonly ["account_not_found", "action_confirmation_required", "admin_required", "after_count_not_permitted", "api_not_approved", "app_check_invalid", "app_check_missing", "article_not_found", "article_not_in_scope", "article_not_tracked", "cash_movement_exceeds_balance", "cashregister_not_assigned", "cashregister_not_found", "cashregister_token_invalid", "cashregister_token_missing", "comment_required", "count_already_voided", "count_not_found", "device_not_found", "dialect_mismatch", "drawer_inactive", "drawer_not_found", "idempotency_conflict", "idempotency_key_required", "internal_translation_error", "invalid_amount", "invalid_cursor", "invalid_denominations", "invalid_movement_type", "invalid_quantity", "invalid_serial", "live_not_enabled", "location_inactive", "location_not_found", "logo_invalid", "logo_invalid_type", "logo_too_large", "method_not_allowed", "mfa_required", "module_inactive", "not_found", "not_permitted", "note_required", "password_change_required", "print_job_not_found", "print_layout_failed", "printer_not_found", "recount_exhausted", "register_user_no_business", "register_user_not_allowed", "register_user_not_found", "response_translation_failed", "second_factor_required", "serial_already_counted", "serial_not_allowed", "serial_required", "server_error", "session_expired", "session_other_cashregister", "shift_already_open", "shift_closed", "shift_mode_off", "shift_not_open", "stocktake_closed", "stocktake_closing", "stocktake_not_found", "stocktake_not_open", "tip_payout_exceeds_claim", "too_many_counts", "transfer_same_drawer", "unauthorized", "user_disabled", "user_verification_failed", "validation", "route_missing"];
24
+ export declare const POS_ERROR_CODES: readonly ["account_not_found", "action_confirmation_required", "admin_required", "after_count_not_permitted", "api_not_approved", "app_check_invalid", "app_check_missing", "article_not_found", "article_not_in_scope", "article_not_tracked", "cash_movement_exceeds_balance", "cashregister_not_assigned", "cashregister_not_found", "cashregister_token_invalid", "cashregister_token_missing", "comment_required", "count_already_voided", "count_not_found", "device_not_found", "dialect_mismatch", "drawer_inactive", "drawer_not_found", "idempotency_conflict", "idempotency_key_required", "internal_translation_error", "invalid_amount", "invalid_cursor", "invalid_denominations", "invalid_discount_preset", "invalid_movement_type", "invalid_quantity", "invalid_serial", "live_not_enabled", "location_inactive", "location_not_found", "logo_invalid", "logo_invalid_type", "logo_too_large", "method_not_allowed", "mfa_required", "module_inactive", "not_found", "not_permitted", "note_required", "password_change_required", "print_job_not_found", "print_layout_failed", "printer_not_found", "recount_exhausted", "register_user_no_business", "register_user_not_allowed", "register_user_not_found", "response_translation_failed", "second_factor_required", "serial_already_counted", "serial_not_allowed", "serial_required", "server_error", "session_expired", "session_other_cashregister", "shift_already_open", "shift_closed", "shift_mode_off", "shift_not_open", "stocktake_closed", "stocktake_closing", "stocktake_not_found", "stocktake_not_open", "tip_payout_exceeds_claim", "too_many_counts", "transfer_same_drawer", "unauthorized", "user_disabled", "user_verification_failed", "validation", "route_missing"];
25
25
  export type PosErrorCode = typeof POS_ERROR_CODES[number];
26
26
  export declare function isPosErrorCode(value: unknown): value is PosErrorCode;
27
27
  /** Der Code eines geworfenen Fehlers, wenn er in [POS_ERROR_CODES] steht; sonst `undefined`. */
@@ -50,6 +50,7 @@ export const POS_ERROR_CODES = Object.freeze([
50
50
  'invalid_amount',
51
51
  'invalid_cursor',
52
52
  'invalid_denominations',
53
+ 'invalid_discount_preset',
53
54
  'invalid_movement_type',
54
55
  'invalid_quantity',
55
56
  'invalid_serial',
@@ -0,0 +1,66 @@
1
+ import type { PosExternalVouchers } from './gutschein.js';
2
+ /**
3
+ * Artikel als fremder Gutschein (Fremdgutscheine an der Kasse, 1.31.0): der
4
+ * Chef legt einen Artikel als Kachel „fremder Gutschein“ an. Die Kasse fragt
5
+ * beim Antippen die Gutscheinnummer (und ohne Preis den Betrag) ab und sendet
6
+ * statt einer Position einen `vouchers[]`-Eintrag
7
+ * `{ source: 'external', action: 'sell', type: externalVoucher, number, amountCents, vatRateBp? }`.
8
+ *
9
+ * Die Regeln am Artikel rechnet das Backend (`functions-kasse/fremdgutschein-artikel-core.js`)
10
+ * beim Speichern (`createMyArticle`/`updateMyArticle`, Code `article_external_voucher_invalid`
11
+ * mit `data.grund`); der Artikel-Editor des Kundenbereichs prueft vorher gleich. Vertrag sind
12
+ * die Pruefaelle `fixtures/external-voucher-article-cases.json` (byte-gleich mit dem Backend).
13
+ */
14
+ /** Art des fremden Gutscheins am Artikel (`/v3` `externalVoucher`, gespeichert `fremdgutschein`). */
15
+ export type ArticleExternalVoucher = 'multi_purpose' | 'single_purpose';
16
+ export declare const ARTICLE_EXTERNAL_VOUCHER_TYPES: readonly ArticleExternalVoucher[];
17
+ /** Fehlercode beim Speichern eines Artikels, intern und unter `/v3` gleich. */
18
+ export declare const ARTICLE_EXTERNAL_VOUCHER_INVALID = "article_external_voucher_invalid";
19
+ /** Welche Regel verletzt ist (Antwortfeld `data.grund`), in der Reihenfolge, in der der Server prueft. */
20
+ export declare const EXTERNAL_VOUCHER_ARTICLE_REASONS: readonly ["invalid_type", "service_voucher", "add_ons", "stock_tracked", "reference", "asks_quantity", "rate_required", "invalid_rate", "price_required"];
21
+ export type ExternalVoucherArticleReason = typeof EXTERNAL_VOUCHER_ARTICLE_REASONS[number];
22
+ /**
23
+ * Ein Artikel im Editor (`/v3`-Form), soweit die Regeln ihn lesen. Bewusst
24
+ * `unknown` beim Wert: der Editor prueft auch, was nicht in den Typ passt.
25
+ */
26
+ export interface ExternalVoucherArticleInput {
27
+ externalVoucher?: unknown;
28
+ unitPriceCents?: number | null;
29
+ vatRate?: number | null;
30
+ askPrice?: boolean | null;
31
+ serviceVoucher?: boolean | null;
32
+ addOns?: readonly unknown[] | null;
33
+ stockTracked?: boolean | null;
34
+ reference?: unknown;
35
+ askQuantity?: boolean | null;
36
+ }
37
+ /**
38
+ * Saetze, mit denen ein Einzweckgutschein verkauft werden kann (Prozent wie
39
+ * `PosArticle.vatRate`; 0 = befreit verkauft): die Saetze der Kasse, Backend
40
+ * `article-groups-core.STEUERSAETZE`, dieselben wie [EXTERNAL_VOUCHER_VAT_RATES_BP] / 100.
41
+ */
42
+ export declare const ARTICLE_EXTERNAL_VOUCHER_VAT_RATES: readonly number[];
43
+ /** Ist der Wert eine Art fremder Gutschein? */
44
+ export declare function isArticleExternalVoucher(value: unknown): value is ArticleExternalVoucher;
45
+ /** Form des Werts beim Speichern: `null` heisst entfernen und ist gueltig. Zwilling von `pruefeWert`. */
46
+ export declare function checkExternalVoucherValue(value: unknown): ExternalVoucherArticleReason | null;
47
+ /**
48
+ * Regeln am wirksamen Artikelstand (Bestand + Aenderung), Zwilling von
49
+ * `pruefeArtikel`: `null` = passt. Ohne `externalVoucher` gilt keine Regel.
50
+ * Einzweck verlangt einen Satz der Kasse (0 = befreit verkauft), Mehrzweck ignoriert ihn;
51
+ * nie zusammen mit Leistungsgutschein, eigener Zusatzliste, Lagerbestand,
52
+ * Referenz oder Mengenabfrage (die Kasse fragt die Nummer selbst und bucht
53
+ * genau einen); ohne `askPrice` braucht er einen Preis ab 1 Cent.
54
+ */
55
+ export declare function checkExternalVoucherArticle(a: ExternalVoucherArticleInput): ExternalVoucherArticleReason | null;
56
+ /** Warum die Kachel eines fremden Gutscheins gesperrt ist. */
57
+ export type ExternalVoucherTileBlock = 'not_enabled' | 'type_not_enabled';
58
+ /**
59
+ * Darf die Kachel verkaufen? `null` = ja (auch fuer jeden Artikel ohne
60
+ * `externalVoucher`). Gesperrt bei Freigabe `off` (oder ohne Angabe) und bei
61
+ * Einzweck ohne `all` -- dieselbe Regel, mit der der Server den Beleg abweist
62
+ * (`external_voucher_not_enabled`, `external_voucher_type_not_enabled`).
63
+ */
64
+ export declare function externalVoucherTileBlock(article: {
65
+ externalVoucher?: ArticleExternalVoucher | null;
66
+ }, externalVouchers: PosExternalVouchers | null | undefined): ExternalVoucherTileBlock | null;
@@ -0,0 +1,67 @@
1
+ export const ARTICLE_EXTERNAL_VOUCHER_TYPES = Object.freeze(['multi_purpose', 'single_purpose']);
2
+ /** Fehlercode beim Speichern eines Artikels, intern und unter `/v3` gleich. */
3
+ export const ARTICLE_EXTERNAL_VOUCHER_INVALID = 'article_external_voucher_invalid';
4
+ /** Welche Regel verletzt ist (Antwortfeld `data.grund`), in der Reihenfolge, in der der Server prueft. */
5
+ export const EXTERNAL_VOUCHER_ARTICLE_REASONS = Object.freeze([
6
+ 'invalid_type', 'service_voucher', 'add_ons', 'stock_tracked', 'reference', 'asks_quantity', 'rate_required', 'invalid_rate', 'price_required',
7
+ ]);
8
+ /**
9
+ * Saetze, mit denen ein Einzweckgutschein verkauft werden kann (Prozent wie
10
+ * `PosArticle.vatRate`; 0 = befreit verkauft): die Saetze der Kasse, Backend
11
+ * `article-groups-core.STEUERSAETZE`, dieselben wie [EXTERNAL_VOUCHER_VAT_RATES_BP] / 100.
12
+ */
13
+ export const ARTICLE_EXTERNAL_VOUCHER_VAT_RATES = Object.freeze([20, 13, 10, 4.9, 0, 19]);
14
+ /** Ist der Wert eine Art fremder Gutschein? */
15
+ export function isArticleExternalVoucher(value) {
16
+ return ARTICLE_EXTERNAL_VOUCHER_TYPES.includes(value);
17
+ }
18
+ /** Form des Werts beim Speichern: `null` heisst entfernen und ist gueltig. Zwilling von `pruefeWert`. */
19
+ export function checkExternalVoucherValue(value) {
20
+ return value === null || isArticleExternalVoucher(value) ? null : 'invalid_type';
21
+ }
22
+ /**
23
+ * Regeln am wirksamen Artikelstand (Bestand + Aenderung), Zwilling von
24
+ * `pruefeArtikel`: `null` = passt. Ohne `externalVoucher` gilt keine Regel.
25
+ * Einzweck verlangt einen Satz der Kasse (0 = befreit verkauft), Mehrzweck ignoriert ihn;
26
+ * nie zusammen mit Leistungsgutschein, eigener Zusatzliste, Lagerbestand,
27
+ * Referenz oder Mengenabfrage (die Kasse fragt die Nummer selbst und bucht
28
+ * genau einen); ohne `askPrice` braucht er einen Preis ab 1 Cent.
29
+ */
30
+ export function checkExternalVoucherArticle(a) {
31
+ if (a.externalVoucher == null)
32
+ return null;
33
+ if (!isArticleExternalVoucher(a.externalVoucher))
34
+ return 'invalid_type';
35
+ if (a.serviceVoucher === true)
36
+ return 'service_voucher';
37
+ if (Array.isArray(a.addOns) && a.addOns.length > 0)
38
+ return 'add_ons';
39
+ if (a.stockTracked === true)
40
+ return 'stock_tracked';
41
+ if (a.reference)
42
+ return 'reference';
43
+ if (a.askQuantity === true)
44
+ return 'asks_quantity';
45
+ if (a.externalVoucher === 'single_purpose' && !(typeof a.vatRate === 'number' && Number.isFinite(a.vatRate)))
46
+ return 'rate_required';
47
+ if (a.externalVoucher === 'single_purpose' && !ARTICLE_EXTERNAL_VOUCHER_VAT_RATES.includes(a.vatRate))
48
+ return 'invalid_rate';
49
+ if (a.askPrice !== true && !(typeof a.unitPriceCents === 'number' && Number.isInteger(a.unitPriceCents) && a.unitPriceCents >= 1))
50
+ return 'price_required';
51
+ return null;
52
+ }
53
+ /**
54
+ * Darf die Kachel verkaufen? `null` = ja (auch fuer jeden Artikel ohne
55
+ * `externalVoucher`). Gesperrt bei Freigabe `off` (oder ohne Angabe) und bei
56
+ * Einzweck ohne `all` -- dieselbe Regel, mit der der Server den Beleg abweist
57
+ * (`external_voucher_not_enabled`, `external_voucher_type_not_enabled`).
58
+ */
59
+ export function externalVoucherTileBlock(article, externalVouchers) {
60
+ if (article.externalVoucher == null)
61
+ return null;
62
+ if (externalVouchers !== 'multi_purpose' && externalVouchers !== 'all')
63
+ return 'not_enabled';
64
+ if (article.externalVoucher === 'single_purpose' && externalVouchers !== 'all')
65
+ return 'type_not_enabled';
66
+ return null;
67
+ }