@kreiseck/kasseneck-api 1.11.0 → 1.12.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 (187) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +2 -1
  3. package/dist/cjs/client/aufrufe.d.ts +4 -4
  4. package/dist/cjs/client/aufrufe.js +15 -0
  5. package/dist/cjs/client/receipts.d.ts +5 -0
  6. package/dist/cjs/client/receipts.js +65 -6
  7. package/dist/cjs/enums/voucher-action.d.ts +2 -0
  8. package/dist/cjs/enums/voucher-action.js +2 -0
  9. package/dist/cjs/enums/voucher-type.d.ts +10 -0
  10. package/dist/cjs/enums/voucher-type.js +10 -0
  11. package/dist/cjs/index.d.ts +3 -3
  12. package/dist/cjs/index.js +9 -3
  13. package/dist/cjs/models/index.d.ts +3 -3
  14. package/dist/cjs/models/index.js +7 -2
  15. package/dist/cjs/models/receipt-errors.d.ts +1 -1
  16. package/dist/cjs/models/receipt-errors.js +2 -0
  17. package/dist/cjs/models/receipt-item.d.ts +11 -3
  18. package/dist/cjs/models/receipt-item.js +22 -1
  19. package/dist/cjs/models/receipt.d.ts +31 -1
  20. package/dist/cjs/models/receipt.js +45 -5
  21. package/dist/cjs/models/voucher.d.ts +57 -4
  22. package/dist/cjs/models/voucher.js +111 -3
  23. package/dist/cjs/partner/fehler.d.ts +1 -1
  24. package/dist/cjs/partner/fehler.js +2 -0
  25. package/dist/cjs/partner/index.d.ts +1 -1
  26. package/dist/cjs/partner/typen.d.ts +7 -1
  27. package/dist/cjs/partner/typen.js +3 -0
  28. package/dist/cjs/pos/client.d.ts +2 -1
  29. package/dist/cjs/pos/client.js +3 -1
  30. package/dist/cjs/pos/gutschein.d.ts +90 -0
  31. package/dist/cjs/pos/gutschein.js +164 -0
  32. package/dist/cjs/pos/index.d.ts +3 -2
  33. package/dist/cjs/pos/index.js +13 -2
  34. package/dist/cjs/pos/settings.d.ts +3 -0
  35. package/dist/cjs/pos/settings.js +12 -10
  36. package/dist/cjs/pos/texte.d.ts +156 -0
  37. package/dist/cjs/pos/texte.js +72 -1
  38. package/dist/cjs/react/index.js +8 -2
  39. package/dist/cjs/receipt/due.d.ts +83 -2
  40. package/dist/cjs/receipt/due.js +202 -36
  41. package/dist/cjs/receipt/grid.js +13 -1
  42. package/dist/cjs/receipt/gutschein-plan.d.ts +104 -0
  43. package/dist/cjs/receipt/gutschein-plan.js +360 -0
  44. package/dist/cjs/receipt/index.d.ts +1 -1
  45. package/dist/cjs/receipt/index.js +3 -0
  46. package/dist/cjs/receipt/layout.js +186 -10
  47. package/dist/cjs/register/pairing.d.ts +21 -1
  48. package/dist/cjs/register/pairing.js +17 -0
  49. package/dist/cjs/stored/bon-layout.d.ts +8 -0
  50. package/dist/cjs/stored/bon-layout.js +23 -0
  51. package/dist/cjs/stored/draht.d.ts +3 -1
  52. package/dist/cjs/stored/draht.js +53 -6
  53. package/dist/cjs/stored/einstellungen.js +2 -1
  54. package/dist/cjs/stored/gutscheine.d.ts +3 -0
  55. package/dist/cjs/stored/gutscheine.js +60 -0
  56. package/dist/cjs/stored/index.js +2 -17
  57. package/dist/cjs/stored/vokabular.d.ts +6 -4
  58. package/dist/cjs/stored/vokabular.js +48 -2
  59. package/dist/cjs/version.d.ts +1 -1
  60. package/dist/cjs/version.js +1 -1
  61. package/dist/esm/client/aufrufe.d.ts +4 -4
  62. package/dist/esm/client/aufrufe.js +15 -0
  63. package/dist/esm/client/receipts.d.ts +5 -0
  64. package/dist/esm/client/receipts.js +66 -8
  65. package/dist/esm/enums/voucher-action.d.ts +2 -0
  66. package/dist/esm/enums/voucher-action.js +2 -0
  67. package/dist/esm/enums/voucher-type.d.ts +10 -0
  68. package/dist/esm/enums/voucher-type.js +10 -0
  69. package/dist/esm/index.d.ts +3 -3
  70. package/dist/esm/index.js +3 -3
  71. package/dist/esm/models/index.d.ts +3 -3
  72. package/dist/esm/models/index.js +3 -3
  73. package/dist/esm/models/receipt-errors.d.ts +1 -1
  74. package/dist/esm/models/receipt-errors.js +2 -0
  75. package/dist/esm/models/receipt-item.d.ts +11 -3
  76. package/dist/esm/models/receipt-item.js +20 -1
  77. package/dist/esm/models/receipt.d.ts +31 -1
  78. package/dist/esm/models/receipt.js +44 -5
  79. package/dist/esm/models/voucher.d.ts +57 -4
  80. package/dist/esm/models/voucher.js +108 -3
  81. package/dist/esm/partner/fehler.d.ts +1 -1
  82. package/dist/esm/partner/fehler.js +2 -0
  83. package/dist/esm/partner/index.d.ts +1 -1
  84. package/dist/esm/partner/typen.d.ts +7 -1
  85. package/dist/esm/partner/typen.js +3 -0
  86. package/dist/esm/pos/client.d.ts +2 -1
  87. package/dist/esm/pos/client.js +3 -1
  88. package/dist/esm/pos/gutschein.d.ts +90 -0
  89. package/dist/esm/pos/gutschein.js +158 -0
  90. package/dist/esm/pos/index.d.ts +3 -2
  91. package/dist/esm/pos/index.js +4 -2
  92. package/dist/esm/pos/settings.d.ts +3 -0
  93. package/dist/esm/pos/settings.js +2 -0
  94. package/dist/esm/pos/texte.d.ts +156 -0
  95. package/dist/esm/pos/texte.js +70 -0
  96. package/dist/esm/react/index.js +8 -2
  97. package/dist/esm/receipt/due.d.ts +83 -2
  98. package/dist/esm/receipt/due.js +198 -34
  99. package/dist/esm/receipt/grid.js +13 -1
  100. package/dist/esm/receipt/gutschein-plan.d.ts +104 -0
  101. package/dist/esm/receipt/gutschein-plan.js +352 -0
  102. package/dist/esm/receipt/index.d.ts +1 -1
  103. package/dist/esm/receipt/index.js +1 -1
  104. package/dist/esm/receipt/layout.js +187 -11
  105. package/dist/esm/register/pairing.d.ts +21 -1
  106. package/dist/esm/register/pairing.js +16 -0
  107. package/dist/esm/stored/bon-layout.d.ts +8 -0
  108. package/dist/esm/stored/bon-layout.js +20 -0
  109. package/dist/esm/stored/draht.d.ts +3 -1
  110. package/dist/esm/stored/draht.js +52 -6
  111. package/dist/esm/stored/einstellungen.js +3 -2
  112. package/dist/esm/stored/gutscheine.d.ts +3 -0
  113. package/dist/esm/stored/gutscheine.js +56 -0
  114. package/dist/esm/stored/index.js +2 -17
  115. package/dist/esm/stored/vokabular.d.ts +6 -4
  116. package/dist/esm/stored/vokabular.js +48 -2
  117. package/dist/esm/version.d.ts +1 -1
  118. package/dist/esm/version.js +1 -1
  119. package/fixtures/expected/voucher-cancellation.grid32.txt +30 -0
  120. package/fixtures/expected/voucher-cancellation.grid48.txt +29 -0
  121. package/fixtures/expected/voucher-cancellation.lines.json +252 -0
  122. package/fixtures/expected/voucher-cancellation.sheet32.json +206 -0
  123. package/fixtures/expected/voucher-cancellation.sheet48.json +200 -0
  124. package/fixtures/expected/voucher-multi-purpose-redeem.grid32.txt +25 -0
  125. package/fixtures/expected/voucher-multi-purpose-redeem.grid48.txt +25 -0
  126. package/fixtures/expected/voucher-multi-purpose-redeem.lines.json +259 -0
  127. package/fixtures/expected/voucher-multi-purpose-redeem.sheet32.json +176 -0
  128. package/fixtures/expected/voucher-multi-purpose-redeem.sheet48.json +176 -0
  129. package/fixtures/expected/voucher-multi-purpose-sale.grid32.txt +24 -0
  130. package/fixtures/expected/voucher-multi-purpose-sale.grid48.txt +23 -0
  131. package/fixtures/expected/voucher-multi-purpose-sale.lines.json +216 -0
  132. package/fixtures/expected/voucher-multi-purpose-sale.sheet32.json +170 -0
  133. package/fixtures/expected/voucher-multi-purpose-sale.sheet48.json +164 -0
  134. package/fixtures/expected/voucher-payout.grid32.txt +23 -0
  135. package/fixtures/expected/voucher-payout.grid48.txt +22 -0
  136. package/fixtures/expected/voucher-payout.lines.json +216 -0
  137. package/fixtures/expected/voucher-payout.sheet32.json +164 -0
  138. package/fixtures/expected/voucher-payout.sheet48.json +158 -0
  139. package/fixtures/expected/voucher-service-redeem.grid32.txt +26 -0
  140. package/fixtures/expected/voucher-service-redeem.grid48.txt +25 -0
  141. package/fixtures/expected/voucher-service-redeem.lines.json +261 -0
  142. package/fixtures/expected/voucher-service-redeem.sheet32.json +182 -0
  143. package/fixtures/expected/voucher-service-redeem.sheet48.json +176 -0
  144. package/fixtures/expected/voucher-single-purpose-redeem-exempt.grid32.txt +30 -0
  145. package/fixtures/expected/voucher-single-purpose-redeem-exempt.grid48.txt +29 -0
  146. package/fixtures/expected/voucher-single-purpose-redeem-exempt.lines.json +331 -0
  147. package/fixtures/expected/voucher-single-purpose-redeem-exempt.sheet32.json +206 -0
  148. package/fixtures/expected/voucher-single-purpose-redeem-exempt.sheet48.json +200 -0
  149. package/fixtures/expected/voucher-single-purpose-redeem.grid32.txt +25 -0
  150. package/fixtures/expected/voucher-single-purpose-redeem.grid48.txt +24 -0
  151. package/fixtures/expected/voucher-single-purpose-redeem.lines.json +246 -0
  152. package/fixtures/expected/voucher-single-purpose-redeem.sheet32.json +176 -0
  153. package/fixtures/expected/voucher-single-purpose-redeem.sheet48.json +170 -0
  154. package/fixtures/expected/voucher-single-purpose-sale.grid32.txt +26 -0
  155. package/fixtures/expected/voucher-single-purpose-sale.grid48.txt +24 -0
  156. package/fixtures/expected/voucher-single-purpose-sale.lines.json +225 -0
  157. package/fixtures/expected/voucher-single-purpose-sale.sheet32.json +182 -0
  158. package/fixtures/expected/voucher-single-purpose-sale.sheet48.json +170 -0
  159. package/fixtures/hobex-hps-codes.json +1 -1
  160. package/fixtures/invoice-api.schema.json +1 -1
  161. package/fixtures/invoice-texts.json +1 -1
  162. package/fixtures/manifest.json +64 -0
  163. package/fixtures/pos-texts.json +170 -1
  164. package/fixtures/receipt-due-generated.json +1 -1
  165. package/fixtures/receipt-due-voucher-generated.json +494 -0
  166. package/fixtures/receipts/voucher-cancellation.json +76 -0
  167. package/fixtures/receipts/voucher-multi-purpose-redeem.json +62 -0
  168. package/fixtures/receipts/voucher-multi-purpose-sale.json +63 -0
  169. package/fixtures/receipts/voucher-payout.json +65 -0
  170. package/fixtures/receipts/voucher-service-redeem.json +82 -0
  171. package/fixtures/receipts/voucher-single-purpose-redeem-exempt.json +86 -0
  172. package/fixtures/receipts/voucher-single-purpose-redeem.json +71 -0
  173. package/fixtures/receipts/voucher-single-purpose-sale.json +88 -0
  174. package/fixtures/surface.json +35 -5
  175. package/fixtures/v3/antworten/belege.json +3405 -3
  176. package/fixtures/v3/antworten/belegmail.json +5 -2
  177. package/fixtures/v3/antworten/kasse-belege.json +3423 -3
  178. package/fixtures/v3/antworten/kasse.json +621 -14
  179. package/fixtures/v3/antworten/lager.json +1 -1
  180. package/fixtures/v3/antworten/rechnungen.json +5 -2
  181. package/fixtures/v3/antworten/storno.json +214 -3
  182. package/fixtures/v3/stored/belege.json +5 -2
  183. package/fixtures/v3/stored/kasse.json +225 -4
  184. package/fixtures/v3/stored/rechnungen.json +5 -2
  185. package/fixtures/v3/v3-vokabular.json +1375 -23
  186. package/fixtures/v3/zahlbetrag-faelle.json +293 -3
  187. package/package.json +4 -1
@@ -119,12 +119,18 @@ export const ALL_CALLS = [
119
119
  'closeStocktake',
120
120
  'cancelStocktake',
121
121
  'getStocktakePdf',
122
+ // Signaturkarte bestellen und Bestellung lesen
123
+ 'orderSignatureCard',
124
+ 'getSignatureCardOrder',
122
125
  // Inventur zaehlen an der Kasse (Lager-Kern Stufe 3, ./pos)
123
126
  'listMyStocktakes',
124
127
  'listMyStocktakeItems',
125
128
  'listMyStocktakeCounts',
126
129
  'recordMyStocktakeCount',
127
130
  'voidMyStocktakeCount',
131
+ // Gutschein pruefen und Etikett nachdrucken (./pos)
132
+ 'checkVoucher',
133
+ 'reprintVoucherLabel',
128
134
  // Schicht, Kassenstand und Lade-Protokoll an der Kasse (./pos)
129
135
  'getMyDrawerState',
130
136
  'openMyShift',
@@ -252,6 +258,8 @@ export const PUBLIC_CALLS = [
252
258
  'closeStocktake',
253
259
  'cancelStocktake',
254
260
  'getStocktakePdf',
261
+ 'orderSignatureCard',
262
+ 'getSignatureCardOrder',
255
263
  ];
256
264
  /**
257
265
  * Die Endpunkte des Kassenwegs (`https://kasse.kasseneck.at/api/v3/<name>`,
@@ -295,6 +303,9 @@ export const POS_CALLS = [
295
303
  'listMyStocktakeCounts',
296
304
  'recordMyStocktakeCount',
297
305
  'voidMyStocktakeCount',
306
+ // Gutschein pruefen und Etikett nachdrucken: nur ueber den Kassenweg.
307
+ 'checkVoucher',
308
+ 'reprintVoucherLabel',
298
309
  // Schicht, Kassenstand und Lade-Protokoll: nur ueber den Kassenweg.
299
310
  'getMyDrawerState',
300
311
  'openMyShift',
@@ -353,6 +364,7 @@ export const UNKNOWN_OUTCOME_CALLS = [
353
364
  'issueInvoice',
354
365
  'logMyDrawerOpenings',
355
366
  'openMyShift',
367
+ 'orderSignatureCard',
356
368
  'pairRegisterDevice',
357
369
  'receiveGoods',
358
370
  'recordInvoicePayment',
@@ -417,6 +429,7 @@ export const UNKNOWN_OUTCOME_CALLS = [
417
429
  */
418
430
  export const CALLS_WITHOUT_EFFECT = Object.freeze({
419
431
  checkPartnerCustomerEmail: 'read',
432
+ checkVoucher: 'read',
420
433
  downloadDailyReport: 'read',
421
434
  downloadReceipt: 'read',
422
435
  downloadReport: 'read',
@@ -447,6 +460,7 @@ export const CALLS_WITHOUT_EFFECT = Object.freeze({
447
460
  getReservation: 'read',
448
461
  getStock: 'read',
449
462
  getStocktake: 'read',
463
+ getSignatureCardOrder: 'read',
450
464
  getStocktakePdf: 'read',
451
465
  getVariantGroup: 'read',
452
466
  hobexGetStatus: 'read',
@@ -485,6 +499,7 @@ export const CALLS_WITHOUT_EFFECT = Object.freeze({
485
499
  registerPinLogin: 'repeatable',
486
500
  registerUserLogin: 'repeatable',
487
501
  renewRegisterSession: 'repeatable',
502
+ reprintVoucherLabel: 'repeatable',
488
503
  searchCustomers: 'read',
489
504
  });
490
505
  const MIT_WIRKUNG = new Set(UNKNOWN_OUTCOME_CALLS);
@@ -239,6 +239,11 @@ export declare function receiptLayoutFromResult(result: ReceiptWithCompany, opti
239
239
  * die Hand des Aufrufers, sondern zu einem der benannten Aufrufe darunter.
240
240
  */
241
241
  export declare function createReceipt(rufen: InternerTransport, options: CreateReceiptOptions): Promise<Receipt>;
242
+ /**
243
+ * Baut die Nutzlast von `createReceipt` und prueft die Eingabe. Wirft, bevor
244
+ * irgendetwas rausgeht — ein Beleg ist nicht folgenlos wiederholbar.
245
+ */
246
+ export declare function createReceiptParams(options: CreateReceiptOptions): Record<string, unknown>;
242
247
  /** Normalbeleg (Verkauf) nach RKSV. */
243
248
  export declare function sellReceipt(transport: InternerTransport, options: SellReceiptOptions): Promise<Receipt>;
244
249
  /**
@@ -1,5 +1,5 @@
1
1
  import { ReceiptType, KeckPaymentMethod, CreditCardProvider, VoucherAction, VoucherType, } from '../enums/index.js';
2
- import { fromReceiptCompanyPayload, fromReceiptPayload, toReceiptItemPayload, toVoucherPayload, receiptItemIsValid, voucherIsValid, fromReceiptSummaryPayload, isCancellationReason, isReturnDisposition, RETURN_DISPOSITIONS, isTipRefundSource, TIP_REFUND_SOURCES, RECEIPT_EMAIL_VIAS, readRegistrationInfo, } from '../models/index.js';
2
+ import { fromReceiptCompanyPayload, fromReceiptPayload, toReceiptItemPayload, toVoucherPayload, receiptItemIsValid, voucherIsValid, isNewFormVoucher, voucherServerFields, fromReceiptSummaryPayload, isCancellationReason, isReturnDisposition, RETURN_DISPOSITIONS, isTipRefundSource, TIP_REFUND_SOURCES, RECEIPT_EMAIL_VIAS, readRegistrationInfo, } from '../models/index.js';
3
3
  import { parseServerTimeStamp, toViennaWallClock } from '../vienna-time.js';
4
4
  import { euroToCents } from '../money.js';
5
5
  import { KasseneckValidationError, isKasseneckApiError, signiertGelesen } from './errors.js';
@@ -50,7 +50,7 @@ async function createReceiptWithCompany(rufen, options) {
50
50
  * Baut die Nutzlast von `createReceipt` und prueft die Eingabe. Wirft, bevor
51
51
  * irgendetwas rausgeht — ein Beleg ist nicht folgenlos wiederholbar.
52
52
  */
53
- function createReceiptParams(options) {
53
+ export function createReceiptParams(options) {
54
54
  const typ = belegtyp(options.receiptType);
55
55
  const { items, vouchers } = options;
56
56
  // Unter /v3 weist der Server diese Felder ab (payment_method_not_supported);
@@ -62,10 +62,15 @@ function createReceiptParams(options) {
62
62
  if (typ.value === ReceiptType.cancellation.value) {
63
63
  throw eingabefehler('Ein Storno geht nur ueber cancelReceipt (Bezug, Grund, Restmengen).');
64
64
  }
65
+ // Gutschein-Positionen setzt nur der Server; vor jeder anderen Positionspruefung.
66
+ if (items?.some((item) => item.kind === 'voucher' || item.kind === 'voucher_float') ?? false) {
67
+ throw eingabefehler('voucher_invalid: Gutschein-Positionen (kind voucher, voucher_float) setzt nur der Server.');
68
+ }
65
69
  if (typ.needsItems) {
66
70
  // Ein reiner Gutscheinverkauf ist ein Umsatz ohne Positionen, deshalb
67
71
  // zaehlt er hier wie eine Position (wie im Flutter-Vorbild).
68
- const hatVerkaufsgutschein = vouchers?.some((v) => v.action === VoucherAction.sell) ?? false;
72
+ // (Eine Auszahlung der neuen Form braucht ebenfalls keine Positionen.)
73
+ const hatVerkaufsgutschein = vouchers?.some((v) => v.action === VoucherAction.sell || v.action === VoucherAction.payout) ?? false;
69
74
  if ((items == null || items.length === 0) && !hatVerkaufsgutschein) {
70
75
  throw eingabefehler(`Positionen sind Pflicht bei receiptType "${typ.value}" und duerfen nicht leer sein.`);
71
76
  }
@@ -78,6 +83,13 @@ function createReceiptParams(options) {
78
83
  if (!typ.allowsVouchers) {
79
84
  throw eingabefehler(`Gutscheine sind nicht erlaubt bei receiptType "${typ.value}".`);
80
85
  }
86
+ const serverfeld = vouchers.flatMap(voucherServerFields)[0];
87
+ if (serverfeld != null) {
88
+ throw eingabefehler(`voucher_invalid: Das Feld ${serverfeld} setzt nur der Server.`);
89
+ }
90
+ if (typ.value === ReceiptType.training.value && vouchers.some(isNewFormVoucher)) {
91
+ throw eingabefehler('Gutscheine der neuen Form gibt es nicht auf Schulungsbelegen (receiptType training).');
92
+ }
81
93
  if (vouchers.some((voucher) => !voucherIsValid(voucher))) {
82
94
  throw eingabefehler('Ungueltiger Gutschein uebergeben.');
83
95
  }
@@ -90,6 +102,11 @@ function createReceiptParams(options) {
90
102
  if (items != null && items.length > 0) {
91
103
  params['items'] = alsNutzlast(items, toReceiptItemPayload);
92
104
  }
105
+ else if (items != null && (vouchers?.some(isNewFormVoucher) ?? false)) {
106
+ // Verkauf/Auszahlung der neuen Form ohne Positionen: die leere Liste geht
107
+ // mit, wie der Vertrag es zeigt (Altform ohne Positionen bleibt byte-gleich).
108
+ params['items'] = [];
109
+ }
93
110
  const umsatz = typ.value === ReceiptType.standard.value || typ.value === ReceiptType.training.value;
94
111
  if (umsatz) {
95
112
  // Pflicht unter /v3 (payments_required); eine leere Liste ist erlaubt,
@@ -97,7 +114,12 @@ function createReceiptParams(options) {
97
114
  if (options.payments == null) {
98
115
  throw eingabefehler('payments fehlt: unter /v3 ist die Zahlungsliste Pflicht (Summe = receiptDueCents).');
99
116
  }
100
- params['payments'] = gepruefteZahlungen(options.payments, false, 'createReceipt');
117
+ // Beleg nur aus Gutschein-Auszahlungen (Server gutschein-beleg.istNurAuszahlung):
118
+ // genau eine Barzahlung ueber den negativen Zahlbetrag.
119
+ // Wie der Server erst nach dem Anhaengen des Trinkgelds: eine Trinkgeldzeile ist keine Gutscheinzeile.
120
+ const nurAuszahlung = (vouchers?.length ?? 0) > 0 && vouchers.every((v) => v.action === VoucherAction.payout)
121
+ && (items?.length ?? 0) === 0 && options.tip == null;
122
+ params['payments'] = gepruefteZahlungen(options.payments, false, 'createReceipt', nurAuszahlung);
101
123
  }
102
124
  else if (options.payments != null) {
103
125
  throw eingabefehler(`payments sind bei receiptType "${typ.value}" nicht erlaubt.`);
@@ -453,6 +475,26 @@ export function checkVoucherCombinationError(vouchers, items) {
453
475
  verkaufenPromo++;
454
476
  }
455
477
  }
478
+ // Neue Form, Regeln wie gutschein-beleg.plane des Servers:
479
+ // - Verkauf und Einloesung nie zusammen, sobald einer davon die neue Form
480
+ // hat (auch gegen die Altform); eine Auszahlung zaehlt hier nicht.
481
+ // - der Aktionsgutschein (promotion) steht allein.
482
+ // - eine Auszahlung nie mit einem Altform-Rabatt (promo).
483
+ // Die Altform-Zaehler unten zaehlen die neue Form bewusst nicht mit.
484
+ const neu = vouchers.filter((v) => isNewFormVoucher(v));
485
+ const verkaufEinloesung = vouchers.filter((v) => v.action === VoucherAction.sell || v.action === VoucherAction.redeem);
486
+ if (verkaufEinloesung.some((v) => v.action === VoucherAction.sell)
487
+ && verkaufEinloesung.some((v) => v.action === VoucherAction.redeem)
488
+ && verkaufEinloesung.some((v) => isNewFormVoucher(v))) {
489
+ return 'Ungueltige Daten: Ein Beleg kann Gutscheine der neuen Form nicht zugleich verkaufen und einloesen';
490
+ }
491
+ if (neu.some((v) => v.type === VoucherType.promotion) && vouchers.length > 1) {
492
+ return 'Ungueltige Daten: Ein Aktionsgutschein (type promotion) darf nicht mit anderen Gutscheinen kombiniert werden';
493
+ }
494
+ if (neu.some((v) => v.action === VoucherAction.payout) && vouchers.some((v) => !isNewFormVoucher(v) && v.type === VoucherType.promo)) {
495
+ return 'Ungueltige Daten: Eine Auszahlung (action payout) darf nicht mit einem Gutschein mit type promo kombiniert werden';
496
+ }
497
+ const einloesenNeu = neu.filter((v) => v.action === VoucherAction.redeem).length;
456
498
  const einloesenGesamt = einloesenWert + einloesenPromo;
457
499
  const verkaufenGesamt = verkaufenWert + verkaufenPromo;
458
500
  if (verkaufenPromo > 0) {
@@ -467,7 +509,7 @@ export function checkVoucherCombinationError(vouchers, items) {
467
509
  if (einloesenPromo > 0 && verkaufenGesamt > 0) {
468
510
  return 'Ungueltige Daten: Mit einem Gutschein mit type promo duerfen nicht andere Gutscheine verkauft werden';
469
511
  }
470
- if (einloesenGesamt > 0 && items.length === 0) {
512
+ if ((einloesenGesamt > 0 || einloesenNeu > 0) && items.length === 0) {
471
513
  return 'Ungueltige Daten: Gutscheine mit action redeem benoetigen mindestens ein item';
472
514
  }
473
515
  return null;
@@ -601,12 +643,28 @@ const MAX_ZAHLUNGEN = 20;
601
643
  * (Summe, Anbieter-Pflicht und Trinkgeld prueft der Server). Wirft, bevor
602
644
  * etwas hinausgeht.
603
645
  */
604
- function gepruefteZahlungen(roh, storno, functionName) {
646
+ function gepruefteZahlungen(roh, storno, functionName, auszahlung = false) {
605
647
  const fehler = (grund) => new KasseneckValidationError(functionName, grund, 'request');
606
648
  if (!Array.isArray(roh))
607
649
  throw fehler('payments muss eine Liste sein.');
608
650
  if (roh.length > MAX_ZAHLUNGEN)
609
651
  throw fehler(`payments: es sind hoechstens ${MAX_ZAHLUNGEN} Eintraege erlaubt.`);
652
+ // Auszahlung eines Gutscheins: der Betrag geht bar hinaus, ohne gegeben und ohne Trinkgeld (Server pruefeZahlungen).
653
+ const negativ = storno || auszahlung;
654
+ if (auszahlung) {
655
+ const e = roh[0];
656
+ if (roh.length !== 1)
657
+ throw fehler('Auszahlung: genau eine Barzahlung angeben.');
658
+ if (e != null && typeof e === 'object') {
659
+ const m = e['method'];
660
+ if ((typeof m === 'object' && m !== null ? m.value : m) !== 'cash')
661
+ throw fehler('Auszahlung: nur in bar moeglich.');
662
+ if (e['tenderedCents'] !== undefined)
663
+ throw fehler('Auszahlung: tenderedCents ist nicht moeglich.');
664
+ if (e['tipCents'] !== undefined)
665
+ throw fehler('Auszahlung: tipCents ist nicht moeglich.');
666
+ }
667
+ }
610
668
  return roh.map((eintrag, i) => {
611
669
  const nr = i + 1;
612
670
  if (eintrag == null || typeof eintrag !== 'object' || Array.isArray(eintrag)) {
@@ -615,8 +673,8 @@ function gepruefteZahlungen(roh, storno, functionName) {
615
673
  const z = eintrag;
616
674
  const method = gepruefteZahlungsart(z['method']);
617
675
  const betrag = z['amountCents'];
618
- if (typeof betrag !== 'number' || !Number.isInteger(betrag) || (storno ? betrag >= 0 : betrag <= 0)) {
619
- throw fehler(`Zahlung ${nr}: amountCents muss eine ganze Zahl ${storno ? 'kleiner' : 'groesser'} als 0 sein.`);
676
+ if (typeof betrag !== 'number' || !Number.isInteger(betrag) || (negativ ? betrag >= 0 : betrag <= 0)) {
677
+ throw fehler(`Zahlung ${nr}: amountCents muss eine ganze Zahl ${negativ ? 'kleiner' : 'groesser'} als 0 sein.`);
620
678
  }
621
679
  const aus = { method, amountCents: betrag };
622
680
  if (z['tenderedCents'] !== undefined) {
@@ -5,6 +5,8 @@
5
5
  export declare const VoucherAction: {
6
6
  readonly sell: "sell";
7
7
  readonly redeem: "redeem";
8
+ /** Neue Form: Restwert auszahlen (Mehrzweck/Einzweck). */
9
+ readonly payout: "payout";
8
10
  };
9
11
  export type VoucherActionKey = keyof typeof VoucherAction;
10
12
  export type VoucherAction = (typeof VoucherAction)[VoucherActionKey];
@@ -5,4 +5,6 @@
5
5
  export const VoucherAction = {
6
6
  sell: 'sell',
7
7
  redeem: 'redeem',
8
+ /** Neue Form: Restwert auszahlen (Mehrzweck/Einzweck). */
9
+ payout: 'payout',
8
10
  };
@@ -2,8 +2,18 @@
2
2
  * Gutscheinart — Zwilling von `VoucherType` in kasseneck_api/lib/enums/voucher_type.dart.
3
3
  */
4
4
  export declare const VoucherType: {
5
+ /** Altform: Wertgutschein (Wert im Cent, Code frei). */
5
6
  readonly value: "value";
7
+ /** Altform: Rabatt-/Promotionsgutschein. */
6
8
  readonly promo: "promo";
9
+ /** Neue Form: Mehrzweckgutschein (Zahlungsmittel, Steuer erst bei der Einloesung). */
10
+ readonly multi_purpose: "multi_purpose";
11
+ /** Neue Form: Einzweckgutschein (Steuer schon beim Verkauf, ein Satz). */
12
+ readonly single_purpose: "single_purpose";
13
+ /** Neue Form: Leistungsgutschein (Artikel mal Menge). */
14
+ readonly service: "service";
15
+ /** Neue Form: Aktionsgutschein (Rabatt laut Aktion, nur einloesbar). */
16
+ readonly promotion: "promotion";
7
17
  };
8
18
  export type VoucherTypeKey = keyof typeof VoucherType;
9
19
  export type VoucherType = (typeof VoucherType)[VoucherTypeKey];
@@ -2,6 +2,16 @@
2
2
  * Gutscheinart — Zwilling von `VoucherType` in kasseneck_api/lib/enums/voucher_type.dart.
3
3
  */
4
4
  export const VoucherType = {
5
+ /** Altform: Wertgutschein (Wert im Cent, Code frei). */
5
6
  value: 'value',
7
+ /** Altform: Rabatt-/Promotionsgutschein. */
6
8
  promo: 'promo',
9
+ /** Neue Form: Mehrzweckgutschein (Zahlungsmittel, Steuer erst bei der Einloesung). */
10
+ multi_purpose: 'multi_purpose',
11
+ /** Neue Form: Einzweckgutschein (Steuer schon beim Verkauf, ein Satz). */
12
+ single_purpose: 'single_purpose',
13
+ /** Neue Form: Leistungsgutschein (Artikel mal Menge). */
14
+ service: 'service',
15
+ /** Neue Form: Aktionsgutschein (Rabatt laut Aktion, nur einloesbar). */
16
+ promotion: 'promotion',
7
17
  };
@@ -1,6 +1,6 @@
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, type Voucher, type VoucherPayload, toVoucherPayload, fromVoucherPayload, voucherIsValid, type Receipt, type RegistrationInfo, type ReceiptPayload, type ReceiptPayloadRead, toReceiptPayload, fromReceiptPayload, receiptSubSumCents, receiptSumCents, 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, 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 VoucherPayload, toVoucherPayload, fromVoucherPayload, voucherIsValid, 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, 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, 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, downloadDailyReport, downloadMonthlyReport, getCashregisterReport, type CashregisterReportPeriod, getReportV2, type ReportV2, type ReportV2Metadata, type ReportV2Options, type CashboxStatus, type SignatureStatus, getCashboxStatus, getSignatureStatus, type KasseneckApi, createKasseneckApi, } from './client/index.js';
4
- export { type ReceiptDueTip, type ReceiptDueTipRecipient, type ReceiptDueOptions, type ReceiptDueBuckets, type ReceiptDueBreakdown, type ReceiptDueErrorReason, receiptDueCents, receiptDueBreakdown, ReceiptDueError, RECEIPT_DUE_ERROR_REASONS, isReceiptDueError, } from './receipt/due.js';
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 VoucherRedeemContext, voucherRedeemMaxCents, VOUCHER_ZERO_RATE_BUCKET_FROM, } from './receipt/due.js';
5
5
  export { parseServerTimeStamp, toViennaWallClock, type ViennaWallClock } from './vienna-time.js';
6
- export { type PosBusinessSettings, type PosDeviceSettings, type PosSettings, type ArticleGroup, type PosArticle, POS_BUSINESS_DEFAULTS, POS_DEVICE_DEFAULTS, mergePosSettings, fromArticleGroupPayload, fromPosArticlePayload, listMyArticleGroups, listMyArticles, getPosSettings, setMyPosSettings, setMyRegisterDeviceSettings, distributeDiscount, cancelScopeOf, receiptsScopeOf, stockViewOf, } from './pos/index.js';
6
+ export { type PosBusinessSettings, type PosDeviceSettings, type PosSettings, type ArticleGroup, type PosArticle, POS_BUSINESS_DEFAULTS, POS_DEVICE_DEFAULTS, mergePosSettings, fromArticleGroupPayload, fromPosArticlePayload, listMyArticleGroups, listMyArticles, getPosSettings, setMyPosSettings, setMyRegisterDeviceSettings, distributeDiscount, cancelScopeOf, receiptsScopeOf, stockViewOf, voucherPermsOf, } from './pos/index.js';
package/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export { ReceiptType, VatRate, KeckPaymentMethod, CreditCardProvider, VoucherType, VoucherAction, StripeLinkMode, } from './enums/index.js';
2
- export { toReceiptItemPayload, fromReceiptItemPayload, receiptItemTotalCents, receiptItemIsValid, negateReceiptItem, isTipItem, toVoucherPayload, fromVoucherPayload, voucherIsValid, toReceiptPayload, fromReceiptPayload, receiptSubSumCents, receiptSumCents, 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_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, 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_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, 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, downloadDailyReport, downloadMonthlyReport, getCashregisterReport, getReportV2, getCashboxStatus, getSignatureStatus, createKasseneckApi, } from './client/index.js';
4
- export { receiptDueCents, receiptDueBreakdown, ReceiptDueError, RECEIPT_DUE_ERROR_REASONS, isReceiptDueError, } from './receipt/due.js';
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';
6
- export { POS_BUSINESS_DEFAULTS, POS_DEVICE_DEFAULTS, mergePosSettings, fromArticleGroupPayload, fromPosArticlePayload, listMyArticleGroups, listMyArticles, getPosSettings, setMyPosSettings, setMyRegisterDeviceSettings, distributeDiscount, cancelScopeOf, receiptsScopeOf, stockViewOf, } from './pos/index.js';
6
+ export { POS_BUSINESS_DEFAULTS, POS_DEVICE_DEFAULTS, mergePosSettings, fromArticleGroupPayload, fromPosArticlePayload, listMyArticleGroups, listMyArticles, getPosSettings, setMyPosSettings, setMyRegisterDeviceSettings, distributeDiscount, cancelScopeOf, receiptsScopeOf, stockViewOf, voucherPermsOf, } from './pos/index.js';
@@ -1,6 +1,6 @@
1
- export { type ReceiptItem, type ReceiptItemPayload, type ReceiptItemPayloadRead, toReceiptItemPayload, fromReceiptItemPayload, receiptItemTotalCents, receiptItemIsValid, negateReceiptItem, type TipRecipient, isTipItem, isDiscountItem, } from './receipt-item.js';
2
- export { type Voucher, type VoucherPayload, toVoucherPayload, fromVoucherPayload, voucherIsValid } from './voucher.js';
3
- export { type Receipt, type RegistrationInfo, type ReceiptPayload, type ReceiptPayloadRead, toReceiptPayload, fromReceiptPayload, readRegistrationInfo, receiptSubSumCents, receiptSumCents, } from './receipt.js';
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 VoucherPayload, toVoucherPayload, fromVoucherPayload, voucherIsValid, isNewFormVoucher, voucherServerFields } from './voucher.js';
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';
6
6
  export { type PaymentErrorCode, PAYMENT_ERROR_CODES, isPaymentErrorCode, paymentErrorCode, isPaymentError, paymentFieldErrors, type PaymentFieldError } from './payment-errors.js';
@@ -1,6 +1,6 @@
1
- export { toReceiptItemPayload, fromReceiptItemPayload, receiptItemTotalCents, receiptItemIsValid, negateReceiptItem, isTipItem, isDiscountItem, } from './receipt-item.js';
2
- export { toVoucherPayload, fromVoucherPayload, voucherIsValid } from './voucher.js';
3
- export { toReceiptPayload, fromReceiptPayload, readRegistrationInfo, receiptSubSumCents, receiptSumCents, } from './receipt.js';
1
+ export { toReceiptItemPayload, fromReceiptItemPayload, receiptItemTotalCents, receiptItemIsValid, negateReceiptItem, isTipItem, isDiscountItem, isVoucherItem, isVoucherFloatItem, } from './receipt-item.js';
2
+ export { toVoucherPayload, fromVoucherPayload, voucherIsValid, isNewFormVoucher, voucherServerFields } from './voucher.js';
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';
6
6
  export { PAYMENT_ERROR_CODES, isPaymentErrorCode, paymentErrorCode, isPaymentError, paymentFieldErrors } from './payment-errors.js';
@@ -16,7 +16,7 @@ import { KasseneckApiError } from '../client/errors.js';
16
16
  * ...) stehen in [PAYMENT_ERROR_CODES]. Ein Code ausserhalb bleibt ueber
17
17
  * `KasseneckApiError.code` lesbar.
18
18
  */
19
- export declare const RECEIPT_ERROR_CODES: readonly ["cancellation_reference_unavailable", "cashregister_closed", "cashregister_decommissioned", "final_receipt_expired", "final_receipt_not_allowed", "module_inactive", "not_permitted", "receipt_limit_exceeded", "receipt_not_found", "receipt_outcome_unknown", "receipt_type_invalid", "signature_incomplete", "signature_missing", "signing_failed", "small_business_vat_not_allowed", "tip_invalid", "tip_not_allowed", "tip_recipient_unknown", "validation", "account_not_found", "action_confirmation_required", "admin_required", "api_not_approved", "app_check_invalid", "app_check_missing", "cashregister_not_assigned", "cashregister_not_found", "cashregister_token_invalid", "cashregister_token_missing", "dialect_mismatch", "internal_translation_error", "live_not_enabled", "method_not_allowed", "mfa_required", "not_found", "password_change_required", "register_user_no_business", "register_user_not_allowed", "register_user_not_found", "response_translation_failed", "second_factor_required", "session_expired", "session_other_cashregister", "unauthorized", "user_disabled", "user_verification_failed", "route_missing", "response_unreadable"];
19
+ export declare const RECEIPT_ERROR_CODES: readonly ["cancellation_reference_unavailable", "cashregister_closed", "cashregister_decommissioned", "final_receipt_expired", "final_receipt_not_allowed", "module_inactive", "not_permitted", "receipt_limit_exceeded", "receipt_not_found", "receipt_outcome_unknown", "receipt_type_invalid", "server_error", "signature_incomplete", "signature_missing", "signing_failed", "small_business_vat_not_allowed", "tip_invalid", "tip_not_allowed", "tip_recipient_unknown", "validation", "voucher_balance_changed", "account_not_found", "action_confirmation_required", "admin_required", "api_not_approved", "app_check_invalid", "app_check_missing", "cashregister_not_assigned", "cashregister_not_found", "cashregister_token_invalid", "cashregister_token_missing", "dialect_mismatch", "internal_translation_error", "live_not_enabled", "method_not_allowed", "mfa_required", "not_found", "password_change_required", "register_user_no_business", "register_user_not_allowed", "register_user_not_found", "response_translation_failed", "second_factor_required", "session_expired", "session_other_cashregister", "unauthorized", "user_disabled", "user_verification_failed", "route_missing", "response_unreadable"];
20
20
  export type ReceiptErrorCode = (typeof RECEIPT_ERROR_CODES)[number];
21
21
  export declare function isReceiptErrorCode(value: unknown): value is ReceiptErrorCode;
22
22
  /** Der Code eines geworfenen Fehlers, wenn er in [RECEIPT_ERROR_CODES] steht; sonst `undefined`. */
@@ -28,6 +28,7 @@ export const RECEIPT_ERROR_CODES = Object.freeze([
28
28
  'receipt_not_found',
29
29
  'receipt_outcome_unknown',
30
30
  'receipt_type_invalid',
31
+ 'server_error',
31
32
  'signature_incomplete',
32
33
  'signature_missing',
33
34
  'signing_failed',
@@ -36,6 +37,7 @@ export const RECEIPT_ERROR_CODES = Object.freeze([
36
37
  'tip_not_allowed',
37
38
  'tip_recipient_unknown',
38
39
  'validation',
40
+ 'voucher_balance_changed',
39
41
  // Anmeldung und Rand (errorCodes.auth ohne Partner-Zugang, errorCodes.edge)
40
42
  'account_not_found',
41
43
  'action_confirmation_required',
@@ -36,7 +36,7 @@ export interface ReceiptItem {
36
36
  * negative Entgeltminderungen je Steuersatz; die Kennzeichnung steuert nur
37
37
  * die Bon-Darstellung (Summenzeile mit Aufteilung), nie die Beträge.
38
38
  */
39
- kind?: 'tip' | 'discount';
39
+ kind?: 'tip' | 'discount' | 'voucher' | 'voucher_float';
40
40
  /** Empfaenger der Trinkgeld-Position; `null` = nicht zugeordnet. */
41
41
  recipient?: TipRecipient | null;
42
42
  /** Zahlart der Trinkgeld-Position (kann von der des Belegs abweichen). */
@@ -73,6 +73,14 @@ export interface TipRecipient {
73
73
  export declare function isTipItem(item: ReceiptItem | ReceiptItemPayloadRead): boolean;
74
74
  /** Rabatt-Position? Die eine Erkennungsstelle — niemand prueft `kind` selbst. */
75
75
  export declare function isDiscountItem(item: ReceiptItem | ReceiptItemPayloadRead): boolean;
76
+ /**
77
+ * Gutschein-Position (Server, neue Gutscheinform)? `voucher` ist eine
78
+ * Einloesung oder ein Verkauf mit Umsatzsteuer-Wirkung, siehe
79
+ * [isVoucherFloatItem] fuer den durchlaufenden Posten.
80
+ */
81
+ export declare function isVoucherItem(item: ReceiptItem | ReceiptItemPayloadRead): boolean;
82
+ /** Gutschein-Position als durchlaufender Posten (Mehrzweck: Verkauf, Auszahlung)? */
83
+ export declare function isVoucherFloatItem(item: ReceiptItem | ReceiptItemPayloadRead): boolean;
76
84
  /**
77
85
  * Nutzlast-Form, die dieses Paket **schreibt** (v2):
78
86
  * `{ name, quantity, unitPriceCents, vatRate }`.
@@ -82,8 +90,8 @@ export interface ReceiptItemPayload {
82
90
  quantity: number;
83
91
  unitPriceCents: number;
84
92
  vatRate: number;
85
- /** Trinkgeld-/Rabatt-Kennzeichnung, siehe [ReceiptItem.kind]. */
86
- kind?: 'tip' | 'discount';
93
+ /** Trinkgeld-/Rabatt-/Gutschein-Kennzeichnung, siehe [ReceiptItem.kind]. */
94
+ kind?: 'tip' | 'discount' | 'voucher' | 'voucher_float';
87
95
  recipient?: TipRecipient | null;
88
96
  paymentMethod?: string;
89
97
  receivedImmediately?: boolean;
@@ -9,6 +9,18 @@ export function isTipItem(item) {
9
9
  export function isDiscountItem(item) {
10
10
  return item != null && item.kind === 'discount';
11
11
  }
12
+ /**
13
+ * Gutschein-Position (Server, neue Gutscheinform)? `voucher` ist eine
14
+ * Einloesung oder ein Verkauf mit Umsatzsteuer-Wirkung, siehe
15
+ * [isVoucherFloatItem] fuer den durchlaufenden Posten.
16
+ */
17
+ export function isVoucherItem(item) {
18
+ return item != null && item.kind === 'voucher';
19
+ }
20
+ /** Gutschein-Position als durchlaufender Posten (Mehrzweck: Verkauf, Auszahlung)? */
21
+ export function isVoucherFloatItem(item) {
22
+ return item != null && item.kind === 'voucher_float';
23
+ }
12
24
  export function toReceiptItemPayload(item) {
13
25
  // Schreibpfad bleibt streng: ein unaufgeloester (unbekannter) Steuersatz
14
26
  // darf nicht unbesehen wieder hinausgehen.
@@ -37,6 +49,11 @@ export function toReceiptItemPayload(item) {
37
49
  // am Bon wieder als gewoehnliche Warenzeile mit "1 x" an.
38
50
  if (item.kind === 'discount')
39
51
  nutzlast.kind = 'discount';
52
+ // Gutschein-Positionen (vom Server) reisen mit: der Cache der Kasse schreibt
53
+ // gelesene Belege wieder, und ein Wunsch an den Server traegt sie nie
54
+ // (createReceipt weist sie als voucher_invalid ab).
55
+ if (item.kind === 'voucher' || item.kind === 'voucher_float')
56
+ nutzlast.kind = item.kind;
40
57
  // Artikel-Verweis reist mit (Erloesgruppen im Bericht); leere Werte nicht.
41
58
  if (item.articleId != null && item.articleId !== '')
42
59
  nutzlast.articleId = item.articleId;
@@ -81,7 +98,9 @@ export function fromReceiptItemPayload(payload) {
81
98
  }
82
99
  : payload.kind === 'discount'
83
100
  ? { kind: 'discount' }
84
- : {}),
101
+ : payload.kind === 'voucher' || payload.kind === 'voucher_float'
102
+ ? { kind: payload.kind }
103
+ : {}),
85
104
  // Artikel-Verweis erhalten (Storno-Spiegelung schreibt ihn wieder mit).
86
105
  ...(typeof payload.articleId === 'string' && payload.articleId !== '' ? { articleId: payload.articleId } : {}),
87
106
  // Lager: Bezug und Rueckgabe-Wahl einer Storno-Zeile (nur gelesen; ein
@@ -143,11 +143,41 @@ export declare function readRegistrationInfo(roh: {
143
143
  cardRegisteredAt?: unknown;
144
144
  cashregisterRegisteredAt?: unknown;
145
145
  }): RegistrationInfo;
146
+ /**
147
+ * Vorzeichen der Wertgutscheine am Beleg: am Storno-Beleg -1, sonst 1.
148
+ *
149
+ * Das Backend spiegelt Wertgutscheine beim Vollstorno mit UNVERAENDERTER
150
+ * `action` und positivem Wert (storno-core.stornoVouchers); der Fluss dreht
151
+ * sich am Storno um (zahlungen-core.wertgutscheinFlussCents, hier
152
+ * `receiptDueCents`): ein verkaufter Gutschein wird zurueckgezahlt, ein
153
+ * eingeloester mindert die Rueckzahlung.
154
+ */
155
+ export declare function receiptValueVoucherSign(receipt: Receipt): 1 | -1;
146
156
  /**
147
157
  * Zwischensumme in **Cent** — Positionen plus verkaufte Wertgutscheine minus
148
158
  * eingeloeste Promotionsgutscheine. Wertgutschein-Einloesungen wirken erst auf
149
159
  * [receiptSumCents], nicht hier (siehe Dart-Vorbild `subSumCents`/`sumCents`).
160
+ * Am Storno-Beleg zaehlen Wertgutscheine mit umgekehrtem Vorzeichen
161
+ * ([receiptValueVoucherSign]), und ein gespiegelter Promotionsgutschein
162
+ * mindert nichts: den Rabatt nimmt der Server dort ueber Ausgleichspositionen
163
+ * (`kind: 'discount'`) zurueck, und belegToepfe verteilt einen Promo-Eintrag
164
+ * nur auf eine positive Topfsumme, die ein Storno nie hat.
165
+ *
166
+ * Gutscheine der neuen Form (Spec 2026-10-14): ihr Betrag steht als Position
167
+ * (`kind: 'voucher'` bei Einzweck/Leistung, `'voucher_float'` im 0-%-Topf) und
168
+ * zaehlt hier schon mit den Positionen. Ein Eintrag mit `zeroRateBucket`
169
+ * (Server: `imNullTopf`, Mehrzweck-Verkauf ab dem Stichtag, Auszahlung) zaehlt
170
+ * darum nicht noch einmal -- sonst stuende der Betrag doppelt am Bon
171
+ * (Vorfall 16.10.2026: Verkauf ueber 30 € mit „Gesamt 60,00“). Eintraege der
172
+ * Arten `single_purpose`/`service` tragen keinen Fluss (wie
173
+ * gutschein-beleg.zahlbetrag, das nur `value`/`promo` an den Fluss gibt).
150
174
  */
151
175
  export declare function receiptSubSumCents(receipt: Receipt): number;
152
- /** Gesamtsumme in **Cent** — Zwischensumme minus eingeloeste Wertgutscheine. */
176
+ /**
177
+ * Gesamtsumme in **Cent** — Zwischensumme minus eingeloeste Wertgutscheine
178
+ * (am Storno-Beleg plus, siehe [receiptValueVoucherSign]). Zwilling von
179
+ * zahlungen-core.wertgutscheinFlussCents: eine Auszahlung (`payout`) eines
180
+ * Wertgutscheins ohne `zeroRateBucket` mindert wie eine Einloesung; mit
181
+ * `zeroRateBucket` steht sie als Position und zaehlt nur dort.
182
+ */
153
183
  export declare function receiptSumCents(receipt: Receipt): number;
@@ -127,29 +127,68 @@ function gueltigeRueckzahlungen(rueckzahlungen) {
127
127
  }
128
128
  return raus;
129
129
  }
130
+ /**
131
+ * Vorzeichen der Wertgutscheine am Beleg: am Storno-Beleg -1, sonst 1.
132
+ *
133
+ * Das Backend spiegelt Wertgutscheine beim Vollstorno mit UNVERAENDERTER
134
+ * `action` und positivem Wert (storno-core.stornoVouchers); der Fluss dreht
135
+ * sich am Storno um (zahlungen-core.wertgutscheinFlussCents, hier
136
+ * `receiptDueCents`): ein verkaufter Gutschein wird zurueckgezahlt, ein
137
+ * eingeloester mindert die Rueckzahlung.
138
+ */
139
+ export function receiptValueVoucherSign(receipt) {
140
+ const typ = typeof receipt.receiptType === 'object' ? receipt.receiptType.value : receipt.receiptType;
141
+ return typ === ReceiptType.cancellation.value ? -1 : 1;
142
+ }
130
143
  /**
131
144
  * Zwischensumme in **Cent** — Positionen plus verkaufte Wertgutscheine minus
132
145
  * eingeloeste Promotionsgutscheine. Wertgutschein-Einloesungen wirken erst auf
133
146
  * [receiptSumCents], nicht hier (siehe Dart-Vorbild `subSumCents`/`sumCents`).
147
+ * Am Storno-Beleg zaehlen Wertgutscheine mit umgekehrtem Vorzeichen
148
+ * ([receiptValueVoucherSign]), und ein gespiegelter Promotionsgutschein
149
+ * mindert nichts: den Rabatt nimmt der Server dort ueber Ausgleichspositionen
150
+ * (`kind: 'discount'`) zurueck, und belegToepfe verteilt einen Promo-Eintrag
151
+ * nur auf eine positive Topfsumme, die ein Storno nie hat.
152
+ *
153
+ * Gutscheine der neuen Form (Spec 2026-10-14): ihr Betrag steht als Position
154
+ * (`kind: 'voucher'` bei Einzweck/Leistung, `'voucher_float'` im 0-%-Topf) und
155
+ * zaehlt hier schon mit den Positionen. Ein Eintrag mit `zeroRateBucket`
156
+ * (Server: `imNullTopf`, Mehrzweck-Verkauf ab dem Stichtag, Auszahlung) zaehlt
157
+ * darum nicht noch einmal -- sonst stuende der Betrag doppelt am Bon
158
+ * (Vorfall 16.10.2026: Verkauf ueber 30 € mit „Gesamt 60,00“). Eintraege der
159
+ * Arten `single_purpose`/`service` tragen keinen Fluss (wie
160
+ * gutschein-beleg.zahlbetrag, das nur `value`/`promo` an den Fluss gibt).
134
161
  */
135
162
  export function receiptSubSumCents(receipt) {
163
+ const vz = receiptValueVoucherSign(receipt);
136
164
  let cents = receipt.items.reduce((acc, item) => acc + receiptItemTotalCents(item), 0);
137
165
  for (const voucher of receipt.vouchers) {
138
- if (voucher.action === VoucherAction.redeem && voucher.type === VoucherType.promo) {
166
+ if (voucher.zeroRateBucket === true)
167
+ continue;
168
+ if (vz === 1 && voucher.action === VoucherAction.redeem && voucher.type === VoucherType.promo) {
139
169
  cents -= voucher.valueCents ?? 0;
140
170
  }
141
171
  if (voucher.action === VoucherAction.sell && voucher.type === VoucherType.value) {
142
- cents += voucher.valueCents ?? 0;
172
+ cents += vz * (voucher.valueCents ?? 0);
143
173
  }
144
174
  }
145
175
  return cents;
146
176
  }
147
- /** Gesamtsumme in **Cent** — Zwischensumme minus eingeloeste Wertgutscheine. */
177
+ /**
178
+ * Gesamtsumme in **Cent** — Zwischensumme minus eingeloeste Wertgutscheine
179
+ * (am Storno-Beleg plus, siehe [receiptValueVoucherSign]). Zwilling von
180
+ * zahlungen-core.wertgutscheinFlussCents: eine Auszahlung (`payout`) eines
181
+ * Wertgutscheins ohne `zeroRateBucket` mindert wie eine Einloesung; mit
182
+ * `zeroRateBucket` steht sie als Position und zaehlt nur dort.
183
+ */
148
184
  export function receiptSumCents(receipt) {
185
+ const vz = receiptValueVoucherSign(receipt);
149
186
  let cents = receiptSubSumCents(receipt);
150
187
  for (const voucher of receipt.vouchers) {
151
- if (voucher.action === VoucherAction.redeem && voucher.type === VoucherType.value) {
152
- cents -= voucher.valueCents ?? 0;
188
+ if (voucher.zeroRateBucket === true || voucher.type !== VoucherType.value)
189
+ continue;
190
+ if (voucher.action === VoucherAction.redeem || voucher.action === VoucherAction.payout) {
191
+ cents -= vz * (voucher.valueCents ?? 0);
153
192
  }
154
193
  }
155
194
  return cents;