@kreiseck/kasseneck-api 0.29.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/dist/cjs/client/api.d.ts +3 -3
  3. package/dist/cjs/client/index.d.ts +1 -1
  4. package/dist/cjs/client/receipts.d.ts +32 -3
  5. package/dist/cjs/client/receipts.js +121 -6
  6. package/dist/cjs/enums/keck-payment-method.d.ts +10 -0
  7. package/dist/cjs/enums/keck-payment-method.js +6 -0
  8. package/dist/cjs/index.d.ts +2 -2
  9. package/dist/cjs/index.js +6 -2
  10. package/dist/cjs/models/cancellation.d.ts +11 -1
  11. package/dist/cjs/models/cancellation.js +15 -0
  12. package/dist/cjs/models/index.d.ts +2 -0
  13. package/dist/cjs/models/index.js +7 -1
  14. package/dist/cjs/models/payment-errors.d.ts +22 -0
  15. package/dist/cjs/models/payment-errors.js +46 -0
  16. package/dist/cjs/models/receipt-payment.d.ts +85 -0
  17. package/dist/cjs/models/receipt-payment.js +40 -0
  18. package/dist/cjs/models/receipt-summary.d.ts +9 -0
  19. package/dist/cjs/models/receipt-summary.js +2 -0
  20. package/dist/cjs/models/receipt.d.ts +9 -0
  21. package/dist/cjs/models/receipt.js +3 -0
  22. package/dist/cjs/receipt/layout.js +112 -10
  23. package/dist/esm/client/api.d.ts +3 -3
  24. package/dist/esm/client/index.d.ts +1 -1
  25. package/dist/esm/client/receipts.d.ts +32 -3
  26. package/dist/esm/client/receipts.js +121 -6
  27. package/dist/esm/enums/keck-payment-method.d.ts +10 -0
  28. package/dist/esm/enums/keck-payment-method.js +6 -0
  29. package/dist/esm/index.d.ts +2 -2
  30. package/dist/esm/index.js +1 -1
  31. package/dist/esm/models/cancellation.d.ts +11 -1
  32. package/dist/esm/models/cancellation.js +15 -0
  33. package/dist/esm/models/index.d.ts +2 -0
  34. package/dist/esm/models/index.js +2 -0
  35. package/dist/esm/models/payment-errors.d.ts +22 -0
  36. package/dist/esm/models/payment-errors.js +42 -0
  37. package/dist/esm/models/receipt-payment.d.ts +85 -0
  38. package/dist/esm/models/receipt-payment.js +36 -0
  39. package/dist/esm/models/receipt-summary.d.ts +9 -0
  40. package/dist/esm/models/receipt-summary.js +2 -0
  41. package/dist/esm/models/receipt.d.ts +9 -0
  42. package/dist/esm/models/receipt.js +3 -0
  43. package/dist/esm/receipt/layout.js +112 -10
  44. package/fixtures/belege/split-bar-rueckgeld.json +58 -0
  45. package/fixtures/belege/split-eine-karte-trinkgeld.json +75 -0
  46. package/fixtures/belege/split-karte-karte-bar.json +102 -0
  47. package/fixtures/belege/split-langer-betrag.json +74 -0
  48. package/fixtures/belege/split-tischrunde-trinkgeld.json +152 -0
  49. package/fixtures/belege/split-trinkgeld-karte.json +82 -0
  50. package/fixtures/belege/split-zwei-karten-gleicher-anbieter.json +89 -0
  51. package/fixtures/belege/storno-split-teil.json +71 -0
  52. package/fixtures/belege/storno-split-voll.json +100 -0
  53. package/fixtures/erwartet/split-bar-rueckgeld.blatt32.json +194 -0
  54. package/fixtures/erwartet/split-bar-rueckgeld.blatt48.json +182 -0
  55. package/fixtures/erwartet/split-bar-rueckgeld.grid32.txt +28 -0
  56. package/fixtures/erwartet/split-bar-rueckgeld.grid48.txt +26 -0
  57. package/fixtures/erwartet/split-bar-rueckgeld.lines.json +286 -0
  58. package/fixtures/erwartet/split-eine-karte-trinkgeld.blatt32.json +242 -0
  59. package/fixtures/erwartet/split-eine-karte-trinkgeld.blatt48.json +224 -0
  60. package/fixtures/erwartet/split-eine-karte-trinkgeld.grid32.txt +36 -0
  61. package/fixtures/erwartet/split-eine-karte-trinkgeld.grid48.txt +33 -0
  62. package/fixtures/erwartet/split-eine-karte-trinkgeld.lines.json +371 -0
  63. package/fixtures/erwartet/split-karte-karte-bar.blatt32.json +356 -0
  64. package/fixtures/erwartet/split-karte-karte-bar.blatt48.json +338 -0
  65. package/fixtures/erwartet/split-karte-karte-bar.grid32.txt +55 -0
  66. package/fixtures/erwartet/split-karte-karte-bar.grid48.txt +52 -0
  67. package/fixtures/erwartet/split-karte-karte-bar.lines.json +519 -0
  68. package/fixtures/erwartet/split-langer-betrag.blatt32.json +266 -0
  69. package/fixtures/erwartet/split-langer-betrag.blatt48.json +260 -0
  70. package/fixtures/erwartet/split-langer-betrag.grid32.txt +40 -0
  71. package/fixtures/erwartet/split-langer-betrag.grid48.txt +39 -0
  72. package/fixtures/erwartet/split-langer-betrag.lines.json +343 -0
  73. package/fixtures/erwartet/split-tischrunde-trinkgeld.blatt32.json +470 -0
  74. package/fixtures/erwartet/split-tischrunde-trinkgeld.blatt48.json +434 -0
  75. package/fixtures/erwartet/split-tischrunde-trinkgeld.grid32.txt +74 -0
  76. package/fixtures/erwartet/split-tischrunde-trinkgeld.grid48.txt +68 -0
  77. package/fixtures/erwartet/split-tischrunde-trinkgeld.lines.json +740 -0
  78. package/fixtures/erwartet/split-trinkgeld-karte.blatt32.json +272 -0
  79. package/fixtures/erwartet/split-trinkgeld-karte.blatt48.json +254 -0
  80. package/fixtures/erwartet/split-trinkgeld-karte.grid32.txt +41 -0
  81. package/fixtures/erwartet/split-trinkgeld-karte.grid48.txt +38 -0
  82. package/fixtures/erwartet/split-trinkgeld-karte.lines.json +428 -0
  83. package/fixtures/erwartet/split-zwei-karten-gleicher-anbieter.blatt32.json +326 -0
  84. package/fixtures/erwartet/split-zwei-karten-gleicher-anbieter.blatt48.json +296 -0
  85. package/fixtures/erwartet/split-zwei-karten-gleicher-anbieter.grid32.txt +50 -0
  86. package/fixtures/erwartet/split-zwei-karten-gleicher-anbieter.grid48.txt +45 -0
  87. package/fixtures/erwartet/split-zwei-karten-gleicher-anbieter.lines.json +504 -0
  88. package/fixtures/erwartet/storno-split-teil.blatt32.json +230 -0
  89. package/fixtures/erwartet/storno-split-teil.blatt48.json +224 -0
  90. package/fixtures/erwartet/storno-split-teil.grid32.txt +34 -0
  91. package/fixtures/erwartet/storno-split-teil.grid48.txt +33 -0
  92. package/fixtures/erwartet/storno-split-teil.lines.json +304 -0
  93. package/fixtures/erwartet/storno-split-voll.blatt32.json +320 -0
  94. package/fixtures/erwartet/storno-split-voll.blatt48.json +314 -0
  95. package/fixtures/erwartet/storno-split-voll.grid32.txt +49 -0
  96. package/fixtures/erwartet/storno-split-voll.grid48.txt +48 -0
  97. package/fixtures/erwartet/storno-split-voll.lines.json +410 -0
  98. package/fixtures/hobex-hps-codes.json +1 -1
  99. package/fixtures/kasse-texte.json +1 -1
  100. package/fixtures/manifest.json +72 -0
  101. package/fixtures/oberflaeche.json +1 -1
  102. package/fixtures/rechnung-api.schema.json +1 -1
  103. package/fixtures/rechnung-texte.json +1 -1
  104. package/package.json +1 -1
@@ -5,6 +5,11 @@
5
5
  * `label` ist das deutsche Anzeige-Label fuer die Zahlungsart-Zeile auf dem Beleg.
6
6
  * Muss 1:1 mit dem Backend-Mapping `paymentMethodToString` (functions/helper.js)
7
7
  * uebereinstimmen.
8
+ *
9
+ * `mixed` vergibt nur der Server: ein Beleg mit mehreren Zahlungen
10
+ * verschiedener Zahlart (`payments`) traegt ihn als Einzelfeld
11
+ * `paymentMethod`. Lesen ist erlaubt, Senden nicht — wer mehrere Zahlarten
12
+ * kassiert, schickt die Zahlungsliste, nie `mixed`.
8
13
  */
9
14
  export declare const KeckPaymentMethod: {
10
15
  readonly cash: {
@@ -52,6 +57,11 @@ export declare const KeckPaymentMethod: {
52
57
  readonly needsCreditCard: true;
53
58
  readonly label: "Bolt Card";
54
59
  };
60
+ readonly mixed: {
61
+ readonly value: "mixed";
62
+ readonly needsCreditCard: false;
63
+ readonly label: "Mehrere Zahlungsarten";
64
+ };
55
65
  };
56
66
  export type KeckPaymentMethodKey = keyof typeof KeckPaymentMethod;
57
67
  export type KeckPaymentMethod = (typeof KeckPaymentMethod)[KeckPaymentMethodKey];
@@ -6,6 +6,11 @@ import { defineEnum } from './define-enum.js';
6
6
  * `label` ist das deutsche Anzeige-Label fuer die Zahlungsart-Zeile auf dem Beleg.
7
7
  * Muss 1:1 mit dem Backend-Mapping `paymentMethodToString` (functions/helper.js)
8
8
  * uebereinstimmen.
9
+ *
10
+ * `mixed` vergibt nur der Server: ein Beleg mit mehreren Zahlungen
11
+ * verschiedener Zahlart (`payments`) traegt ihn als Einzelfeld
12
+ * `paymentMethod`. Lesen ist erlaubt, Senden nicht — wer mehrere Zahlarten
13
+ * kassiert, schickt die Zahlungsliste, nie `mixed`.
9
14
  */
10
15
  export const KeckPaymentMethod = defineEnum({
11
16
  cash: { value: 'cash', needsCreditCard: false, label: 'Barzahlung' },
@@ -17,4 +22,5 @@ export const KeckPaymentMethod = defineEnum({
17
22
  boltApp: { value: 'boltApp', needsCreditCard: false, label: 'Bolt App' },
18
23
  boltCash: { value: 'boltCash', needsCreditCard: false, label: 'Bolt Cash' },
19
24
  boltCard: { value: 'boltCard', needsCreditCard: true, label: 'Bolt Card' },
25
+ mixed: { value: 'mixed', needsCreditCard: false, label: 'Mehrere Zahlungsarten' },
20
26
  });
@@ -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, type Voucher, type VoucherPayload, toVoucherPayload, fromVoucherPayload, voucherIsValid, type Receipt, type ReceiptPayload, type ReceiptPayloadRead, toReceiptPayload, fromReceiptPayload, receiptSubSumCents, receiptSumCents, type CancellationOf, type CancellationItem, type Cancellation, type CancellationReason, type CancellationErrorCode, CANCELLATION_REASONS, CANCELLATION_ERROR_CODES, CANCELLATION_RESERVATION_MS, isCancellationReason, isCancellationErrorCode, type ReceiptEmailErrorCode, RECEIPT_EMAIL_ERROR_CODES, isReceiptEmailErrorCode, remainingQuantities, type ReceiptCompany, type ReceiptCompanyPayload, fromReceiptCompanyPayload, receiptCompanyTaxInfo, type Cashregister, type CashregisterOnboarding, type CashregisterPayload, type CashregisterOnboardingPayload, fromCashregisterPayload, type ReceiptSummary, type ReceiptSummaryPayload, fromReceiptSummaryPayload, type ZeroKind, ZERO_KINDS, istZeroKind, 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
- export { type AuthCredentials, type KasseneckAuth, type ApiKeyAuthOptions, type RegisterUserAuthOptions, apiKeyAuth, registerUserAuth, DEFAULT_BASE_URL, DEFAULT_TIMEOUT_MS, type HttpResponseLike, type HttpRequestInit, type FetchLike, type TransportOptions, type TransportBodyFields, type KasseneckTransport, type KasseneckBinaryTransport, AUFRUFE, type Aufruf, createTransport, createBinaryTransport, KasseneckApiError, KasseneckAuthError, KasseneckHttpError, KasseneckNetworkError, KasseneckValidationError, type ValidationScope, type KasseneckError, type HttpFailureReason, type CauseDigest, isKasseneckApiError, isKasseneckAuthError, isKasseneckHttpError, isKasseneckNetworkError, isKasseneckValidationError, type ReceiptCommonOptions, type SellReceiptOptions, type TipOptions, type TipRecipientShare, type CancelReceiptOptions, type CancelReceiptResult, type CreateCancelReceiptOptions, type ReceiptWithCompany, sellReceipt, sellReceiptWithCompany, cancelReceipt, createCancelReceipt, zeroReceipt, getReceipt, getReceiptWithCompany, generateFullReceiptId, getFirstReceiptDate, listMyReceipts, type ListMyReceiptsOptions, type ReceiptList, type ReceiptListStats, listMyCashregisters, checkVoucherCombinationError, type SendReceiptEmailOptions, type SendReceiptEmailResult, sendReceiptEmail, downloadDailyReport, downloadMonthlyReport, type CashboxStatus, type SignatureStatus, getCashboxStatus, getSignatureStatus, type KasseneckApi, createKasseneckApi, } from './client/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 ReceiptPayload, type ReceiptPayloadRead, toReceiptPayload, fromReceiptPayload, receiptSubSumCents, receiptSumCents, type CancellationOf, type CancellationItem, type Cancellation, type CancellationReason, type CancellationErrorCode, CANCELLATION_REASONS, CANCELLATION_ERROR_CODES, CANCELLATION_RESERVATION_MS, isCancellationReason, isCancellationErrorCode, type ReceiptPayment, type ReceiptPaymentPayload, type ReceiptPaymentInput, fromReceiptPaymentPayload, toReceiptPaymentPayload, type PaymentErrorCode, PAYMENT_ERROR_CODES, isPaymentErrorCode, type ReceiptEmailErrorCode, RECEIPT_EMAIL_ERROR_CODES, isReceiptEmailErrorCode, remainingQuantities, type ReceiptCompany, type ReceiptCompanyPayload, fromReceiptCompanyPayload, receiptCompanyTaxInfo, type Cashregister, type CashregisterOnboarding, type CashregisterPayload, type CashregisterOnboardingPayload, fromCashregisterPayload, type ReceiptSummary, type ReceiptSummaryPayload, fromReceiptSummaryPayload, type ZeroKind, ZERO_KINDS, istZeroKind, 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
+ export { type AuthCredentials, type KasseneckAuth, type ApiKeyAuthOptions, type RegisterUserAuthOptions, apiKeyAuth, registerUserAuth, DEFAULT_BASE_URL, DEFAULT_TIMEOUT_MS, type HttpResponseLike, type HttpRequestInit, type FetchLike, type TransportOptions, type TransportBodyFields, type KasseneckTransport, type KasseneckBinaryTransport, AUFRUFE, type Aufruf, createTransport, createBinaryTransport, KasseneckApiError, KasseneckAuthError, KasseneckHttpError, KasseneckNetworkError, KasseneckValidationError, type ValidationScope, type KasseneckError, type HttpFailureReason, type CauseDigest, isKasseneckApiError, isKasseneckAuthError, isKasseneckHttpError, isKasseneckNetworkError, isKasseneckValidationError, type ReceiptCommonOptions, type SellReceiptOptions, type SellReceiptWithPaymentsOptions, type TipOptions, type TipRecipientShare, type CancelReceiptOptions, type CancelReceiptResult, type CreateCancelReceiptOptions, type ReceiptWithCompany, sellReceipt, sellReceiptWithCompany, cancelReceipt, createCancelReceipt, zeroReceipt, getReceipt, getReceiptWithCompany, generateFullReceiptId, getFirstReceiptDate, listMyReceipts, type ListMyReceiptsOptions, type ReceiptList, type ReceiptListStats, listMyCashregisters, checkVoucherCombinationError, type SendReceiptEmailOptions, type SendReceiptEmailResult, sendReceiptEmail, downloadDailyReport, downloadMonthlyReport, type CashboxStatus, type SignatureStatus, getCashboxStatus, getSignatureStatus, type KasseneckApi, createKasseneckApi, } from './client/index.js';
4
4
  export { parseServerTimeStamp, toViennaWallClock, type ViennaWallClock } from './vienna-time.js';
5
5
  export { type KasseSettingsBetrieb, type KasseSettingsGeraet, type KasseSettings, type ArticleGroup, type KasseArtikel, KASSE_BETRIEB_STANDARD, KASSE_GERAET_STANDARD, mergeKasseSettings, fromArticleGroupPayload, fromKasseArtikelPayload, listMyArticleGroups, listMyArticles, getKasseSettings, setMyKasseSettings, setMyRegisterDeviceSettings, verteileRabatt, cancelScopeOf, receiptsScopeOf, } from './kasse/index.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, toVoucherPayload, fromVoucherPayload, voucherIsValid, toReceiptPayload, fromReceiptPayload, receiptSubSumCents, receiptSumCents, CANCELLATION_REASONS, CANCELLATION_ERROR_CODES, CANCELLATION_RESERVATION_MS, isCancellationReason, isCancellationErrorCode, RECEIPT_EMAIL_ERROR_CODES, isReceiptEmailErrorCode, remainingQuantities, fromReceiptCompanyPayload, receiptCompanyTaxInfo, fromCashregisterPayload, fromReceiptSummaryPayload, ZERO_KINDS, istZeroKind, reportMonthFromDate, previousReportMonth, nextReportMonth, reportMonthKey, reportMonthReadable, toStripeUrlSessionPayload, fromStripeUrlSessionPayload, toHobexReceiptPayload, fromHobexReceiptPayload, hobexReceiptToCardPaymentData, hobexReceiptNeedsSignature, } from './models/index.js';
2
+ export { toReceiptItemPayload, fromReceiptItemPayload, receiptItemTotalCents, receiptItemIsValid, negateReceiptItem, isTipItem, toVoucherPayload, fromVoucherPayload, voucherIsValid, toReceiptPayload, fromReceiptPayload, receiptSubSumCents, receiptSumCents, CANCELLATION_REASONS, CANCELLATION_ERROR_CODES, CANCELLATION_RESERVATION_MS, isCancellationReason, isCancellationErrorCode, fromReceiptPaymentPayload, toReceiptPaymentPayload, PAYMENT_ERROR_CODES, isPaymentErrorCode, RECEIPT_EMAIL_ERROR_CODES, isReceiptEmailErrorCode, remainingQuantities, fromReceiptCompanyPayload, receiptCompanyTaxInfo, fromCashregisterPayload, fromReceiptSummaryPayload, ZERO_KINDS, istZeroKind, reportMonthFromDate, previousReportMonth, nextReportMonth, reportMonthKey, reportMonthReadable, toStripeUrlSessionPayload, fromStripeUrlSessionPayload, toHobexReceiptPayload, fromHobexReceiptPayload, hobexReceiptToCardPaymentData, hobexReceiptNeedsSignature, } from './models/index.js';
3
3
  export { apiKeyAuth, registerUserAuth, DEFAULT_BASE_URL, DEFAULT_TIMEOUT_MS, AUFRUFE, createTransport, createBinaryTransport, KasseneckApiError, KasseneckAuthError, KasseneckHttpError, KasseneckNetworkError, KasseneckValidationError, isKasseneckApiError, isKasseneckAuthError, isKasseneckHttpError, isKasseneckNetworkError, isKasseneckValidationError, sellReceipt, sellReceiptWithCompany, cancelReceipt, createCancelReceipt, zeroReceipt, getReceipt, getReceiptWithCompany, generateFullReceiptId, getFirstReceiptDate, listMyReceipts, listMyCashregisters, checkVoucherCombinationError, sendReceiptEmail, downloadDailyReport, downloadMonthlyReport, getCashboxStatus, getSignatureStatus, createKasseneckApi, } from './client/index.js';
4
4
  export { parseServerTimeStamp, toViennaWallClock } from './vienna-time.js';
5
5
  export { KASSE_BETRIEB_STANDARD, KASSE_GERAET_STANDARD, mergeKasseSettings, fromArticleGroupPayload, fromKasseArtikelPayload, listMyArticleGroups, listMyArticles, getKasseSettings, setMyKasseSettings, setMyRegisterDeviceSettings, verteileRabatt, cancelScopeOf, receiptsScopeOf, } from './kasse/index.js';
@@ -27,8 +27,18 @@ export declare function isCancellationReason(value: unknown): value is Cancellat
27
27
  *
28
28
  * Nur Auth-/Parameterfehler (Sitzung abgelaufen, Pflichtfeld fehlt) kommen
29
29
  * ohne Code; dort bleibt `code` undefined.
30
+ *
31
+ * Die vier `STORNO_…`-Codes am Ende gehoeren zur Rueckzahlung je Zahlung
32
+ * (mehrere Zahlungen je Beleg); Formfehler an `payments` selbst melden die
33
+ * Codes aus [PAYMENT_ERROR_CODES].
34
+ *
35
+ * Die Werte hier sind die von `/v1` und intern. Unter `/v3` heissen die
36
+ * Storno-Codes nach dem /v3-Vokabular anders (`already_cancelled`,
37
+ * `cancellation_payments_required`, functions/gemeinsam/api-vokabular-v3.js);
38
+ * diese Namen kommen mit der Umstellung des Pakets auf `/v3`.
39
+ * [isCancellationErrorCode] prueft darum exakt.
30
40
  */
31
- export declare const CANCELLATION_ERROR_CODES: readonly ["beleg_nicht_gefunden", "belegart_nicht_stornierbar", "trainingsbeleg", "bereits_storniert", "position_ungueltig", "menge_ueber_rest", "grund_unbekannt", "anmerkung_zu_lang", "items_ungueltig", "kasse_nicht_zugewiesen", "keine_berechtigung", "nur_eigene_belege", "kasse_unvollstaendig", "storno_fehlgeschlagen"];
41
+ export declare const CANCELLATION_ERROR_CODES: readonly ["beleg_nicht_gefunden", "belegart_nicht_stornierbar", "trainingsbeleg", "bereits_storniert", "position_ungueltig", "menge_ueber_rest", "grund_unbekannt", "anmerkung_zu_lang", "items_ungueltig", "kasse_nicht_zugewiesen", "keine_berechtigung", "nur_eigene_belege", "kasse_unvollstaendig", "storno_fehlgeschlagen", "STORNO_PAYMENTS_REQUIRED", "STORNO_REFUND_EXCEEDS_PAYMENT", "STORNO_REFUND_REFERENCE_REQUIRED", "STORNO_REFUND_REFERENCE_UNKNOWN"];
32
42
  export type CancellationErrorCode = (typeof CANCELLATION_ERROR_CODES)[number];
33
43
  export declare function isCancellationErrorCode(value: unknown): value is CancellationErrorCode;
34
44
  /** Bezug eines Storno-Belegs auf sein Original. */
@@ -27,6 +27,16 @@ export function isCancellationReason(value) {
27
27
  *
28
28
  * Nur Auth-/Parameterfehler (Sitzung abgelaufen, Pflichtfeld fehlt) kommen
29
29
  * ohne Code; dort bleibt `code` undefined.
30
+ *
31
+ * Die vier `STORNO_…`-Codes am Ende gehoeren zur Rueckzahlung je Zahlung
32
+ * (mehrere Zahlungen je Beleg); Formfehler an `payments` selbst melden die
33
+ * Codes aus [PAYMENT_ERROR_CODES].
34
+ *
35
+ * Die Werte hier sind die von `/v1` und intern. Unter `/v3` heissen die
36
+ * Storno-Codes nach dem /v3-Vokabular anders (`already_cancelled`,
37
+ * `cancellation_payments_required`, functions/gemeinsam/api-vokabular-v3.js);
38
+ * diese Namen kommen mit der Umstellung des Pakets auf `/v3`.
39
+ * [isCancellationErrorCode] prueft darum exakt.
30
40
  */
31
41
  export const CANCELLATION_ERROR_CODES = [
32
42
  'beleg_nicht_gefunden', // Original fehlt oder gehoert nicht zu dieser Kasse
@@ -43,6 +53,11 @@ export const CANCELLATION_ERROR_CODES = [
43
53
  'nur_eigene_belege', // Recht "eigene", fremder Beleg
44
54
  'kasse_unvollstaendig', // api_key/token fehlen am Konto bzw. an der Kasse
45
55
  'storno_fehlgeschlagen', // der Storno-Beleg selbst wurde abgelehnt (z. B. Signatur)
56
+ // Mehrere Zahlungen je Beleg (Rueckzahlung je Zahlung):
57
+ 'STORNO_PAYMENTS_REQUIRED', // Teilstorno eines Belegs mit mehreren Zahlungen ohne payments
58
+ 'STORNO_REFUND_EXCEEDS_PAYMENT', // Rueckzahlungen auf eine Zahlung uebersteigen deren Rest
59
+ 'STORNO_REFUND_REFERENCE_REQUIRED', // Karten-Rueckzahlung ohne refundOf einer Kartenzahlung
60
+ 'STORNO_REFUND_REFERENCE_UNKNOWN', // refundOf nennt keine Zahlung des Originals
46
61
  ];
47
62
  export function isCancellationErrorCode(value) {
48
63
  return typeof value === 'string' && CANCELLATION_ERROR_CODES.includes(value);
@@ -2,6 +2,8 @@ export { type ReceiptItem, type ReceiptItemPayload, type ReceiptItemPayloadRead,
2
2
  export { type Voucher, type VoucherPayload, toVoucherPayload, fromVoucherPayload, voucherIsValid } from './voucher.js';
3
3
  export { type Receipt, type ReceiptPayload, type ReceiptPayloadRead, toReceiptPayload, fromReceiptPayload, receiptSubSumCents, receiptSumCents, } from './receipt.js';
4
4
  export { type CancellationOf, type CancellationItem, type Cancellation, type CancellationReason, type CancellationErrorCode, CANCELLATION_REASONS, CANCELLATION_ERROR_CODES, CANCELLATION_RESERVATION_MS, isCancellationReason, isCancellationErrorCode, remainingQuantities, } from './cancellation.js';
5
+ export { type ReceiptPayment, type ReceiptPaymentPayload, type ReceiptPaymentInput, fromReceiptPaymentPayload, toReceiptPaymentPayload, } from './receipt-payment.js';
6
+ export { type PaymentErrorCode, PAYMENT_ERROR_CODES, isPaymentErrorCode } from './payment-errors.js';
5
7
  export { type ReceiptEmailErrorCode, RECEIPT_EMAIL_ERROR_CODES, isReceiptEmailErrorCode, } from './receipt-email.js';
6
8
  export { type ReceiptCompany, type ReceiptCompanyPayload, fromReceiptCompanyPayload, receiptCompanyTaxInfo, } from './receipt-company.js';
7
9
  export { type Cashregister, type CashregisterOnboarding, type CashregisterPayload, type CashregisterOnboardingPayload, fromCashregisterPayload, } from './cashregister.js';
@@ -2,6 +2,8 @@ export { toReceiptItemPayload, fromReceiptItemPayload, receiptItemTotalCents, re
2
2
  export { toVoucherPayload, fromVoucherPayload, voucherIsValid } from './voucher.js';
3
3
  export { toReceiptPayload, fromReceiptPayload, receiptSubSumCents, receiptSumCents, } from './receipt.js';
4
4
  export { CANCELLATION_REASONS, CANCELLATION_ERROR_CODES, CANCELLATION_RESERVATION_MS, isCancellationReason, isCancellationErrorCode, remainingQuantities, } from './cancellation.js';
5
+ export { fromReceiptPaymentPayload, toReceiptPaymentPayload, } from './receipt-payment.js';
6
+ export { PAYMENT_ERROR_CODES, isPaymentErrorCode } from './payment-errors.js';
5
7
  export { RECEIPT_EMAIL_ERROR_CODES, isReceiptEmailErrorCode, } from './receipt-email.js';
6
8
  export { fromReceiptCompanyPayload, receiptCompanyTaxInfo, } from './receipt-company.js';
7
9
  export { fromCashregisterPayload, } from './cashregister.js';
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Mehrere Zahlungen je Beleg — Fehlercode-Katalog, Zwilling von
3
+ * `functions/gemeinsam/zahlungen-core.js` ZAHLUNGS_FEHLERCODES (gleiche
4
+ * Codes, gleiche Reihenfolge).
5
+ *
6
+ * `createReceipt` und `cancelReceipt` legen sie bei jedem Fehler rund um
7
+ * `payments` (und bei den Aufrufer-Vorbedingungen wie `PAYMENTS_CONFLICT`)
8
+ * als `code` neben die Meldung; das Paket reicht sie als
9
+ * [KasseneckApiError.code] durch. **Entscheide am Code, nie am Text** — die
10
+ * deutsche Meldung darf sich aendern, der Code nicht.
11
+ *
12
+ * Schreibweise: auf `/v1`, `/v2` und intern kommen die Codes gross
13
+ * (`PAYMENTS_SUM_MISMATCH`), unter `/v3` schreibt der Rand des Backends sie
14
+ * klein (`payments_sum_mismatch`, functions/gemeinsam/api-vokabular-v3.js:
15
+ * jeder dieser Codes 1:1 in Kleinschreibung, anders als die Storno-Codes).
16
+ * [isPaymentErrorCode] erkennt beide; wer selbst vergleicht, vergleicht
17
+ * `code.toUpperCase()`.
18
+ */
19
+ export declare const PAYMENT_ERROR_CODES: readonly ["PAYMENTS_INVALID", "PAYMENT_METHOD_INVALID", "PAYMENT_AMOUNT_INVALID", "PAYMENT_TENDERED_INVALID", "PAYMENT_PROVIDER_INVALID", "PAYMENT_PROVIDER_NOT_ALLOWED", "PAYMENTS_SUM_MISMATCH", "PAYMENTS_DUE_NEGATIVE", "PAYMENTS_NOT_ALLOWED", "PAYMENTS_CONFLICT", "PAYMENTS_REQUIRED", "PAYMENT_METHOD_NOT_SUPPORTED", "TIP_PAYMENT_METHOD_INVALID", "TIP_PAYMENT_METHOD_REQUIRED", "TIP_EXCEEDS_PAYMENT", "PAYMENT_REFUND_NOT_ALLOWED", "PAYMENT_TIP_INVALID", "TIP_CONFLICT"];
20
+ export type PaymentErrorCode = (typeof PAYMENT_ERROR_CODES)[number];
21
+ /** Erkennt einen Code aus [PAYMENT_ERROR_CODES] — gross (`/v1`) wie klein (`/v3`). */
22
+ export declare function isPaymentErrorCode(value: unknown): value is PaymentErrorCode | Lowercase<PaymentErrorCode>;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Mehrere Zahlungen je Beleg — Fehlercode-Katalog, Zwilling von
3
+ * `functions/gemeinsam/zahlungen-core.js` ZAHLUNGS_FEHLERCODES (gleiche
4
+ * Codes, gleiche Reihenfolge).
5
+ *
6
+ * `createReceipt` und `cancelReceipt` legen sie bei jedem Fehler rund um
7
+ * `payments` (und bei den Aufrufer-Vorbedingungen wie `PAYMENTS_CONFLICT`)
8
+ * als `code` neben die Meldung; das Paket reicht sie als
9
+ * [KasseneckApiError.code] durch. **Entscheide am Code, nie am Text** — die
10
+ * deutsche Meldung darf sich aendern, der Code nicht.
11
+ *
12
+ * Schreibweise: auf `/v1`, `/v2` und intern kommen die Codes gross
13
+ * (`PAYMENTS_SUM_MISMATCH`), unter `/v3` schreibt der Rand des Backends sie
14
+ * klein (`payments_sum_mismatch`, functions/gemeinsam/api-vokabular-v3.js:
15
+ * jeder dieser Codes 1:1 in Kleinschreibung, anders als die Storno-Codes).
16
+ * [isPaymentErrorCode] erkennt beide; wer selbst vergleicht, vergleicht
17
+ * `code.toUpperCase()`.
18
+ */
19
+ export const PAYMENT_ERROR_CODES = Object.freeze([
20
+ 'PAYMENTS_INVALID', // payments ist keine Liste oder hat mehr als 20 Eintraege
21
+ 'PAYMENT_METHOD_INVALID', // Zahlart unbekannt oder mixed
22
+ 'PAYMENT_AMOUNT_INVALID', // amountCents keine Ganzzahl, 0 oder falsches Vorzeichen
23
+ 'PAYMENT_TENDERED_INVALID', // tenderedCents an Nicht-Bar-Zahlung, zu klein oder doppelt
24
+ 'PAYMENT_PROVIDER_INVALID', // Karte ohne/mit unbekanntem provider, providerPaymentId fehlt
25
+ 'PAYMENT_PROVIDER_NOT_ALLOWED', // Anbieterfelder an einer Zahlung, die weder Karte noch online ist
26
+ 'PAYMENTS_SUM_MISMATCH', // Summe != Zahlbetrag (Antwort nennt data.expectedCents)
27
+ 'PAYMENTS_DUE_NEGATIVE', // Zahlbetrag < 0 (Wertgutschein groesser als der Beleg)
28
+ 'PAYMENTS_NOT_ALLOWED', // Null-/Startbeleg mit Zahlungen, alter Storno-Weg
29
+ 'PAYMENTS_CONFLICT', // payments zusammen mit paymentMethod oder Kartenfeldern
30
+ 'PAYMENTS_REQUIRED', // /v3 ohne payments
31
+ 'PAYMENT_METHOD_NOT_SUPPORTED', // paymentMethod/Kartenfelder unter /v3
32
+ 'TIP_PAYMENT_METHOD_INVALID', // Trinkgeld-Zahlart kommt in payments nicht vor
33
+ 'TIP_PAYMENT_METHOD_REQUIRED', // mehrere Zahlarten, tip.paymentMethod fehlt
34
+ 'TIP_EXCEEDS_PAYMENT', // Trinkgeld uebersteigt die Zahlungen seiner Zahlart
35
+ 'PAYMENT_REFUND_NOT_ALLOWED', // refundOf ausserhalb eines Stornos oder kein String
36
+ 'PAYMENT_TIP_INVALID', // tipCents keine Ganzzahl, <= 0, > amountCents oder nicht am Verkauf
37
+ 'TIP_CONFLICT', // tip und payments[].tipCents zugleich
38
+ ]);
39
+ /** Erkennt einen Code aus [PAYMENT_ERROR_CODES] — gross (`/v1`) wie klein (`/v3`). */
40
+ export function isPaymentErrorCode(value) {
41
+ return typeof value === 'string' && PAYMENT_ERROR_CODES.includes(value.toUpperCase());
42
+ }
@@ -0,0 +1,85 @@
1
+ import { KeckPaymentMethod, type KeckPaymentMethodKey, CreditCardProvider } from '../enums/index.js';
2
+ /**
3
+ * Eine Zahlung am Beleg — Zwilling der Eintraege in `payments`, wie
4
+ * `functions/gemeinsam/zahlungen-core.js` (`pruefeZahlungen`) sie normalisiert
5
+ * und ablegt.
6
+ *
7
+ * Ein Beleg kann ueber mehrere Zahlungen bezahlt sein (zwei Karten, Rest bar).
8
+ * Dann steht die Liste unter `payments`, und das Einzelfeld `paymentMethod`
9
+ * ist `mixed`, sobald verschiedene Zahlarten vorkommen (zwei Karten ergeben
10
+ * `creditCard`). Altbelege haben keine Liste; dort gilt weiter
11
+ * `paymentMethod` samt Kartenfeldern.
12
+ *
13
+ * Betraege in ganzen Cent: am Verkauf positiv, am Storno negativ (Rueckzahlung).
14
+ * `method`/`provider` sind beim Lesen wie ueberall entweder der bekannte
15
+ * Enum-Eintrag oder der rohe Schluessel (siehe `enum-payload.ts`).
16
+ */
17
+ export interface ReceiptPayment {
18
+ /** Vom Server vergeben (`p1`, `p2`, …); Bezugspunkt fuer `refundOf`. */
19
+ id?: string;
20
+ method: KeckPaymentMethod | string;
21
+ amountCents: number;
22
+ /** Nur bei Barzahlung: gegebener Betrag. */
23
+ tenderedCents?: number;
24
+ /** Nur neben `tenderedCents`: Rueckgeld (vom Server gerechnet). */
25
+ changeCents?: number;
26
+ /** Kartenanbieter bzw. Terminal. */
27
+ provider?: CreditCardProvider | string;
28
+ /** Kennung der Zahlung am Terminal/Anbieter. */
29
+ providerPaymentId?: string;
30
+ /** Terminaldaten fuer den Kartenblock (frueher `cardPaymentData`). */
31
+ providerData?: Record<string, unknown>;
32
+ /** Nur am Storno: `id` der Originalzahlung, die erstattet wird. */
33
+ refundOf?: string;
34
+ /**
35
+ * Trinkgeld, das mit dieser Zahlung gegeben wurde, in ganzen Cent — TEIL
36
+ * von `amountCents` (das Terminal bucht Betrag + Trinkgeld zusammen). Nur
37
+ * an Verkaufs-/Trainingsbelegen.
38
+ */
39
+ tipCents?: number;
40
+ }
41
+ /** Nutzlast-Form einer Zahlung (Backend-Dokument bzw. Antwort). */
42
+ export interface ReceiptPaymentPayload {
43
+ id?: string;
44
+ method: string;
45
+ amountCents: number;
46
+ tenderedCents?: number;
47
+ changeCents?: number;
48
+ provider?: string;
49
+ providerPaymentId?: string;
50
+ providerData?: Record<string, unknown>;
51
+ refundOf?: string;
52
+ tipCents?: number;
53
+ }
54
+ /**
55
+ * Eine Zahlung, wie der Aufrufer sie an `createReceipt`/`sellReceipt`/
56
+ * `cancelReceipt` schickt. `id` und `changeCents` vergibt der Server.
57
+ *
58
+ * - `method`: jede Zahlungsart ausser `mixed`.
59
+ * - `amountCents`: ganze Cent, am Verkauf > 0, am Storno < 0.
60
+ * - `tenderedCents`: nur bei Barzahlung am Verkauf, hoechstens an einer Zahlung.
61
+ * - `provider`/`providerPaymentId`/`providerData`: bei Karten Pflicht
62
+ * (`providerPaymentId` ausser bei `custom`), bei `online` optional, sonst
63
+ * nicht erlaubt; am Storno beschreiben sie die Erstattung und sind optional.
64
+ * - `refundOf`: nur am Storno.
65
+ * - `tipCents`: Trinkgeld dieser Zahlung, ganze Cent > 0, Teil von
66
+ * `amountCents`; nur am Verkauf, nie neben `tip` (den Rest prueft der Server).
67
+ */
68
+ export interface ReceiptPaymentInput {
69
+ method: KeckPaymentMethod | KeckPaymentMethodKey;
70
+ amountCents: number;
71
+ tenderedCents?: number;
72
+ provider?: CreditCardProvider;
73
+ providerPaymentId?: string;
74
+ providerData?: Record<string, unknown>;
75
+ refundOf?: string;
76
+ tipCents?: number;
77
+ }
78
+ /** Lesepfad: nur vorhandene Felder uebernehmen, nichts ergaenzen. */
79
+ export declare function fromReceiptPaymentPayload(payload: ReceiptPaymentPayload): ReceiptPayment;
80
+ /**
81
+ * Schreibpfad: Zahlungen zurueck in die Nutzlast — streng wie
82
+ * `toReceiptPayload`: ein roher, unbekannter Schluessel bei `method` oder
83
+ * `provider` wirft.
84
+ */
85
+ export declare function toReceiptPaymentPayload(payment: ReceiptPayment): ReceiptPaymentPayload;
@@ -0,0 +1,36 @@
1
+ import { KeckPaymentMethod, CreditCardProvider } from '../enums/index.js';
2
+ import { readEnumKey, requireEnumKey } from './enum-payload.js';
3
+ /** Lesepfad: nur vorhandene Felder uebernehmen, nichts ergaenzen. */
4
+ export function fromReceiptPaymentPayload(payload) {
5
+ return {
6
+ ...(typeof payload.id === 'string' ? { id: payload.id } : {}),
7
+ method: readEnumKey(KeckPaymentMethod, payload.method),
8
+ amountCents: payload.amountCents,
9
+ ...(typeof payload.tenderedCents === 'number' ? { tenderedCents: payload.tenderedCents } : {}),
10
+ ...(typeof payload.changeCents === 'number' ? { changeCents: payload.changeCents } : {}),
11
+ ...(typeof payload.provider === 'string' ? { provider: readEnumKey(CreditCardProvider, payload.provider) } : {}),
12
+ ...(typeof payload.providerPaymentId === 'string' ? { providerPaymentId: payload.providerPaymentId } : {}),
13
+ ...(payload.providerData != null && typeof payload.providerData === 'object' ? { providerData: payload.providerData } : {}),
14
+ ...(typeof payload.refundOf === 'string' ? { refundOf: payload.refundOf } : {}),
15
+ ...(typeof payload.tipCents === 'number' ? { tipCents: payload.tipCents } : {}),
16
+ };
17
+ }
18
+ /**
19
+ * Schreibpfad: Zahlungen zurueck in die Nutzlast — streng wie
20
+ * `toReceiptPayload`: ein roher, unbekannter Schluessel bei `method` oder
21
+ * `provider` wirft.
22
+ */
23
+ export function toReceiptPaymentPayload(payment) {
24
+ return {
25
+ ...(payment.id !== undefined ? { id: payment.id } : {}),
26
+ method: typeof payment.method === 'object' ? payment.method.value : requireEnumKey(KeckPaymentMethod, payment.method, 'Zahlungsart').value,
27
+ amountCents: payment.amountCents,
28
+ ...(payment.tenderedCents !== undefined ? { tenderedCents: payment.tenderedCents } : {}),
29
+ ...(payment.changeCents !== undefined ? { changeCents: payment.changeCents } : {}),
30
+ ...(payment.provider !== undefined ? { provider: requireEnumKey(CreditCardProvider, payment.provider, 'Kartenanbieter') } : {}),
31
+ ...(payment.providerPaymentId !== undefined ? { providerPaymentId: payment.providerPaymentId } : {}),
32
+ ...(payment.providerData !== undefined ? { providerData: payment.providerData } : {}),
33
+ ...(payment.refundOf !== undefined ? { refundOf: payment.refundOf } : {}),
34
+ ...(payment.tipCents !== undefined ? { tipCents: payment.tipCents } : {}),
35
+ };
36
+ }
@@ -1,4 +1,5 @@
1
1
  import { KeckPaymentMethod, ReceiptType } from '../enums/index.js';
2
+ import { type ReceiptPayment, type ReceiptPaymentPayload } from './receipt-payment.js';
2
3
  /**
3
4
  * Belegzeile einer Liste — die Form, die `listMyReceipts` liefert
4
5
  * (`projectReceiptForCustomer` in functions/index.js).
@@ -63,6 +64,13 @@ export interface ReceiptSummary {
63
64
  stornoStand: 'offen' | 'teil' | 'voll';
64
65
  /** Nur am Nullbeleg, nur fuer Kassen-Benutzer: Anlass (monthly, annual, annual_replacement, outage_end, final, manual). */
65
66
  zeroKind?: ZeroKind;
67
+ /**
68
+ * Zahlungsliste, nur bei Belegen, die eine tragen. Die Liste liefert nur
69
+ * die oeffentlichen Felder (id, method, amountCents, provider,
70
+ * tenderedCents, changeCents, refundOf, tipCents) — Anbieter-Interna
71
+ * (`providerPaymentId`, `providerData`) bleiben im Backend.
72
+ */
73
+ payments?: ReceiptPayment[];
66
74
  }
67
75
  export interface ReceiptSummaryPayload {
68
76
  receiptId?: string | null;
@@ -90,5 +98,6 @@ export interface ReceiptSummaryPayload {
90
98
  cancellationReason?: string | null;
91
99
  stornoStand?: string | null;
92
100
  zeroKind?: string | null;
101
+ payments?: ReceiptPaymentPayload[] | null;
93
102
  }
94
103
  export declare function fromReceiptSummaryPayload(payload: ReceiptSummaryPayload): ReceiptSummary;
@@ -1,6 +1,7 @@
1
1
  import { KeckPaymentMethod, ReceiptType } from '../enums/index.js';
2
2
  import { euroToCents } from '../money.js';
3
3
  import { readEnumKey } from './enum-payload.js';
4
+ import { fromReceiptPaymentPayload } from './receipt-payment.js';
4
5
  /**
5
6
  * Belegzeile einer Liste — die Form, die `listMyReceipts` liefert
6
7
  * (`projectReceiptForCustomer` in functions/index.js).
@@ -48,5 +49,6 @@ export function fromReceiptSummaryPayload(payload) {
48
49
  ...(payload.cancellationReason ? { cancellationReason: payload.cancellationReason } : {}),
49
50
  stornoStand: payload.stornoStand === 'teil' || payload.stornoStand === 'voll' ? payload.stornoStand : 'offen',
50
51
  ...(istZeroKind(payload.zeroKind) ? { zeroKind: payload.zeroKind } : {}),
52
+ ...(Array.isArray(payload.payments) ? { payments: payload.payments.map(fromReceiptPaymentPayload) } : {}),
51
53
  };
52
54
  }
@@ -3,6 +3,7 @@ import { type ReceiptItem, type ReceiptItemPayload, type ReceiptItemPayloadRead
3
3
  import { type Voucher, type VoucherPayload } from './voucher.js';
4
4
  import type { Cancellation, CancellationOf, CancellationReason } from './cancellation.js';
5
5
  import { type ZeroKind } from './receipt-summary.js';
6
+ import { type ReceiptPayment, type ReceiptPaymentPayload } from './receipt-payment.js';
6
7
  /**
7
8
  * Beleg — Zwilling der Beleg-Nutzlast von `KasseneckReceipt` in
8
9
  * kasseneck_api/lib/models/kasseneck_receipt.dart (nur der signatur-/
@@ -54,6 +55,12 @@ export interface Receipt {
54
55
  cancellations?: Cancellation[];
55
56
  /** Nur an Nullbelegen: Anlass (monthly, annual, annual_replacement, outage_end, final, manual). */
56
57
  zeroKind?: ZeroKind;
58
+ /**
59
+ * Zahlungsliste (mehrere Zahlungen je Beleg), nur vorhanden, wenn der Beleg
60
+ * sie traegt. Altbelege haben keine; dort gelten `paymentMethod` und die
61
+ * Kartenfelder. Siehe [ReceiptPayment].
62
+ */
63
+ payments?: ReceiptPayment[];
57
64
  }
58
65
  export interface ReceiptPayload {
59
66
  qr: string;
@@ -78,6 +85,8 @@ export interface ReceiptPayload {
78
85
  customProjectId: string | null;
79
86
  /** Nur bei Belegen mit Trinkgeld (siehe [Receipt.tipCents]). */
80
87
  tipCents?: number | null;
88
+ /** Nur bei Belegen mit Zahlungsliste (siehe [Receipt.payments]). */
89
+ payments?: ReceiptPaymentPayload[] | null;
81
90
  }
82
91
  /**
83
92
  * Nutzlast-Form, die dieses Paket **liest**. Unterscheidet sich von
@@ -3,6 +3,7 @@ import { readEnumKey, requireEnumKey } from './enum-payload.js';
3
3
  import { toReceiptItemPayload, fromReceiptItemPayload, receiptItemTotalCents, } from './receipt-item.js';
4
4
  import { toVoucherPayload, fromVoucherPayload } from './voucher.js';
5
5
  import { istZeroKind } from './receipt-summary.js';
6
+ import { fromReceiptPaymentPayload, toReceiptPaymentPayload } from './receipt-payment.js';
6
7
  /**
7
8
  * Schreibt die Nutzlast in der **neuen** Form — sie **normalisiert, statt zu
8
9
  * spiegeln**: ein Beleg, der in der v1-Positionsform gelesen wurde, geht hier
@@ -43,6 +44,7 @@ export function toReceiptPayload(receipt) {
43
44
  signatureSuccess: receipt.signatureSuccess ?? null,
44
45
  customProjectId: receipt.customProjectId ?? null,
45
46
  ...(receipt.tipCents != null ? { tipCents: receipt.tipCents } : {}),
47
+ ...(receipt.payments != null ? { payments: receipt.payments.map(toReceiptPaymentPayload) } : {}),
46
48
  };
47
49
  }
48
50
  // Nullbelege haben keine Positionen -> items kann fehlen/null sein (siehe Dart-Vorbild).
@@ -78,6 +80,7 @@ export function fromReceiptPayload(payload) {
78
80
  ...(payload.cancellationReason ? { cancellationReason: payload.cancellationReason } : {}),
79
81
  ...(istZeroKind(payload.zeroKind) ? { zeroKind: payload.zeroKind } : {}),
80
82
  ...(payload.cancellations ? { cancellations: payload.cancellations.map(leseStorno) } : {}),
83
+ ...(Array.isArray(payload.payments) ? { payments: payload.payments.map(fromReceiptPaymentPayload) } : {}),
81
84
  };
82
85
  }
83
86
  function leseStorno(eintrag) {
@@ -291,16 +291,13 @@ function stripeBlock(daten, cardPaymentId) {
291
291
  return zeilen;
292
292
  }
293
293
  /**
294
- * Der Kartenzahlungsblock des Belegs -- fuer JEDEN Anbieter, den das Backend
295
- * kennt. Ohne `cardPaymentData` bleibt der Block weg; ein unbekannter Anbieter
296
- * ebenfalls, still und ohne Fehler: ein Beleg muss sich immer zeigen lassen.
294
+ * Der Kartenzahlungsblock eines Anbieters -- fuer JEDEN Anbieter, den das
295
+ * Backend kennt. Ein unbekannter Anbieter bekommt keinen Block, still und
296
+ * ohne Fehler: ein Beleg muss sich immer zeigen lassen.
297
297
  */
298
- function kartenblock(receipt) {
299
- const daten = receipt.cardPaymentData;
300
- if (daten == null)
301
- return [];
298
+ function anbieterBlock(provider, daten, id) {
302
299
  const zeilen = (() => {
303
- switch (receipt.creditCardProvider) {
300
+ switch (provider) {
304
301
  case 'hobexHps':
305
302
  case 'hobexCloudApi':
306
303
  return hobexBlock(daten);
@@ -312,7 +309,7 @@ function kartenblock(receipt) {
312
309
  case 'myposPro':
313
310
  return myposBlock(daten);
314
311
  case 'stripe':
315
- return stripeBlock(daten, receipt.cardPaymentId ?? null);
312
+ return stripeBlock(daten, id);
316
313
  default:
317
314
  return [];
318
315
  }
@@ -325,12 +322,117 @@ function kartenblock(receipt) {
325
322
  // gehoert aber zum Blatt, nicht zum Terminal.
326
323
  return [...zeilen, { kind: 'space', lines: 1 }];
327
324
  }
325
+ /**
326
+ * Die Kartenzahlungsbloecke des Belegs. Mit Zahlungsliste (`payments`) je
327
+ * Zahlung mit Anbieter und Terminaldaten ein Block, in Zahlungsreihenfolge --
328
+ * zwei Karten desselben Anbieters ergeben zwei Bloecke; die alten
329
+ * Einzelfelder zaehlen dann nicht. Bei mehreren Zahlungen steht vor jedem
330
+ * Block, nicht fett und zentriert, die Nummer der Zahlung aus der
331
+ * Aufschluesselung („2. Kartenzahlung") -- so ist jeder Block seiner Zeile
332
+ * zuzuordnen. Ohne (oder mit leerer) Liste der bisherige Weg ueber
333
+ * `creditCardProvider`/`cardPaymentData`/`cardPaymentId` -- ebenso bei
334
+ * hoechstens einer Zahlung ohne `providerData`, wenn die Altfelder gesetzt sind.
335
+ */
336
+ function kartenblock(receipt) {
337
+ const zahlungen = receipt.payments;
338
+ // Eine einzelne Zahlung ohne Terminaldaten neben gesetzten Altfeldern
339
+ // (creditCardProvider + cardPaymentData): der bisherige Block, wie ohne Liste.
340
+ const altfelderTragen = zahlungen != null && zahlungen.length <= 1
341
+ && zahlungen.every((z) => z.providerData == null)
342
+ && receipt.creditCardProvider != null && receipt.cardPaymentData != null;
343
+ if (zahlungen != null && zahlungen.length > 0 && !altfelderTragen) {
344
+ const zeilen = [];
345
+ zahlungen.forEach((zahlung, i) => {
346
+ if (zahlung.provider == null || zahlung.providerData == null)
347
+ return;
348
+ const block = anbieterBlock(zahlung.provider, zahlung.providerData, zahlung.providerPaymentId ?? null);
349
+ if (block.length === 0)
350
+ return;
351
+ if (zahlungen.length > 1)
352
+ zeilen.push(textZeile(zahlungNummerText(zahlung, i), 'center'));
353
+ zeilen.push(...block);
354
+ });
355
+ return zeilen;
356
+ }
357
+ const daten = receipt.cardPaymentData;
358
+ if (daten == null)
359
+ return [];
360
+ return anbieterBlock(receipt.creditCardProvider, daten, receipt.cardPaymentId ?? null);
361
+ }
328
362
  function zahlungsartText(wert) {
329
363
  if (wert != null && typeof wert === 'object') {
330
364
  return wert.label;
331
365
  }
332
366
  return typeof wert === 'string' ? wert : '';
333
367
  }
368
+ /** Barzahlarten -- Zwilling von `BAR_ZAHLARTEN` (functions/gemeinsam/tip-core.js). */
369
+ const BAR_ZAHLARTEN = ['cash', 'uberCash', 'boltCash'];
370
+ function zahlartSchluessel(wert) {
371
+ if (wert != null && typeof wert === 'object')
372
+ return wert.value;
373
+ return typeof wert === 'string' ? wert : '';
374
+ }
375
+ /**
376
+ * Nummerierter Text einer Zahlung („1. Kartenzahlung", „3. Barzahlung") --
377
+ * in der Aufschluesselung und ueber ihrem Kartenblock dieselbe Nummer, in
378
+ * Zahlungsreihenfolge ab 1.
379
+ */
380
+ function zahlungNummerText(zahlung, index) {
381
+ return `${index + 1}. ${zahlungsartText(zahlung.method)}`;
382
+ }
383
+ /** „davon Trinkgeld" eingerueckt unter einer Zahlung, die Trinkgeld traegt. */
384
+ function zahlungTrinkgeldZeilen(zahlung) {
385
+ if (typeof zahlung.tipCents !== 'number' || zahlung.tipCents <= 0)
386
+ return [];
387
+ return [paarZeile(' davon Trinkgeld', `${formatCents(zahlung.tipCents)} €`, 8, 4)];
388
+ }
389
+ /**
390
+ * Gegeben/Rueckgeld unter einer Barzahlung mit `tenderedCents`. Fehlt
391
+ * `changeCents` (der Server rechnet es sonst selbst), ergibt es sich aus
392
+ * gegeben minus Betrag.
393
+ */
394
+ function barZeilen(zahlung) {
395
+ if (!BAR_ZAHLARTEN.includes(zahlartSchluessel(zahlung.method)) || typeof zahlung.tenderedCents !== 'number')
396
+ return [];
397
+ const rueckgeld = typeof zahlung.changeCents === 'number' ? zahlung.changeCents : zahlung.tenderedCents - zahlung.amountCents;
398
+ return [
399
+ paarZeile(' Gegeben:', `${formatCents(zahlung.tenderedCents)} €`, 8, 4),
400
+ paarZeile(' Rückgeld:', `${formatCents(rueckgeld)} €`, 8, 4),
401
+ ];
402
+ }
403
+ /**
404
+ * Die Zahlungszeilen unter „Gesamt:".
405
+ *
406
+ * - Ohne Zahlungsliste: „Zahlungsart: <Label>" aus `paymentMethod`, wie immer.
407
+ * - Genau eine Zahlung: dieselbe Zeile, Label aus der Zahlung.
408
+ * - Mehrere Zahlungen (auch zwei Karten, die `paymentMethod: creditCard`
409
+ * ergeben -- entschieden wird an der Laenge, nie an `mixed`): „Zahlungsarten:"
410
+ * und je Zahlung eine nummerierte Zeile mit Betrag, ohne Anbieter (der
411
+ * steht im Kartenblock mit derselben Nummer). Breite 8:4 -- auf 58 mm
412
+ * bleiben der Betragsspalte elf Zeichen, genug fuer „-9999,99 €".
413
+ *
414
+ * Unter jeder Zahlung in dieser Reihenfolge: „davon Trinkgeld" (bei
415
+ * `tipCents`), dann bei einer Barzahlung mit gegebenem Betrag „Gegeben:" und
416
+ * „Rückgeld:" -- alles, was zu einer Zahlung gehoert, zwei Zeichen eingerueckt,
417
+ * die Zahlung selbst buendig.
418
+ */
419
+ function zahlungsZeilen(receipt) {
420
+ const zahlungen = receipt.payments;
421
+ if (zahlungen == null || zahlungen.length === 0) {
422
+ return [paarZeile('Zahlungsart:', zahlungsartText(receipt.paymentMethod))];
423
+ }
424
+ if (zahlungen.length === 1) {
425
+ const zahlung = zahlungen[0];
426
+ return [paarZeile('Zahlungsart:', zahlungsartText(zahlung.method)), ...zahlungTrinkgeldZeilen(zahlung), ...barZeilen(zahlung)];
427
+ }
428
+ const zeilen = [textZeile('Zahlungsarten:')];
429
+ zahlungen.forEach((zahlung, i) => {
430
+ zeilen.push(paarZeile(zahlungNummerText(zahlung, i), `${formatCents(zahlung.amountCents)} €`, 8, 4));
431
+ zeilen.push(...zahlungTrinkgeldZeilen(zahlung));
432
+ zeilen.push(...barZeilen(zahlung));
433
+ });
434
+ return zeilen;
435
+ }
334
436
  // -------------------------------------------------------- Kleinunternehmer
335
437
  /**
336
438
  * Hinweis auf die Steuerbefreiung, den ein Kleinunternehmerbeleg tragen muss —
@@ -898,7 +1000,7 @@ export function buildReceiptLayout(receipt, company, options = {}) {
898
1000
  lines.push({ kind: 'rule', char: '-' });
899
1001
  }
900
1002
  lines.push(paarZeile('Gesamt:', `${formatCents(summeCents)} €`));
901
- lines.push(paarZeile('Zahlungsart:', zahlungsartText(receipt.paymentMethod)));
1003
+ lines.push(...zahlungsZeilen(receipt));
902
1004
  lines.push({ kind: 'space', lines: 1 });
903
1005
  // --- Rechtshinweise und Ausfallhinweis
904
1006
  const hinweise = company.isSmallBusiness