@kreiseck/kasseneck-api 1.30.0 → 1.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/cjs/client/aufrufe.d.ts +3 -3
  3. package/dist/cjs/client/aufrufe.js +8 -0
  4. package/dist/cjs/client/receipts.d.ts +11 -0
  5. package/dist/cjs/client/receipts.js +14 -0
  6. package/dist/cjs/index.d.ts +2 -2
  7. package/dist/cjs/index.js +10 -5
  8. package/dist/cjs/models/index.d.ts +2 -2
  9. package/dist/cjs/models/index.js +7 -2
  10. package/dist/cjs/models/receipt-errors.d.ts +1 -1
  11. package/dist/cjs/models/receipt-errors.js +9 -0
  12. package/dist/cjs/models/receipt-item.d.ts +44 -2
  13. package/dist/cjs/models/receipt-item.js +56 -1
  14. package/dist/cjs/models/receipt.d.ts +17 -0
  15. package/dist/cjs/models/receipt.js +9 -0
  16. package/dist/cjs/models/voucher.d.ts +18 -0
  17. package/dist/cjs/models/voucher.js +32 -1
  18. package/dist/cjs/pos/artikel.d.ts +26 -0
  19. package/dist/cjs/pos/artikel.js +5 -0
  20. package/dist/cjs/pos/client.d.ts +1 -0
  21. package/dist/cjs/pos/client.js +14 -0
  22. package/dist/cjs/pos/errors.d.ts +1 -1
  23. package/dist/cjs/pos/errors.js +13 -0
  24. package/dist/cjs/pos/fremdgutschein-artikel.d.ts +66 -0
  25. package/dist/cjs/pos/fremdgutschein-artikel.js +74 -0
  26. package/dist/cjs/pos/index.d.ts +9 -4
  27. package/dist/cjs/pos/index.js +62 -4
  28. package/dist/cjs/pos/leergut.d.ts +60 -0
  29. package/dist/cjs/pos/leergut.js +82 -0
  30. package/dist/cjs/pos/pfand.d.ts +144 -0
  31. package/dist/cjs/pos/pfand.js +382 -0
  32. package/dist/cjs/pos/rabatt-vorlagen.d.ts +79 -0
  33. package/dist/cjs/pos/rabatt-vorlagen.js +156 -0
  34. package/dist/cjs/pos/schicht-lesen.js +8 -0
  35. package/dist/cjs/pos/schicht-typen.d.ts +15 -0
  36. package/dist/cjs/pos/settings.d.ts +72 -10
  37. package/dist/cjs/pos/settings.js +79 -5
  38. package/dist/cjs/pos/texte.d.ts +283 -0
  39. package/dist/cjs/pos/texte.js +163 -1
  40. package/dist/cjs/pos/zusaetze.d.ts +3 -3
  41. package/dist/cjs/pos/zusaetze.js +4 -2
  42. package/dist/cjs/receipt/discount.js +3 -0
  43. package/dist/cjs/receipt/due.d.ts +6 -0
  44. package/dist/cjs/receipt/due.js +16 -5
  45. package/dist/cjs/receipt/gutschein-plan.d.ts +7 -1
  46. package/dist/cjs/receipt/gutschein-plan.js +16 -2
  47. package/dist/cjs/receipt/layout.js +108 -2
  48. package/dist/cjs/receipt/shift-sheet.js +8 -0
  49. package/dist/cjs/register/pairing.d.ts +15 -1
  50. package/dist/cjs/register/pairing.js +14 -1
  51. package/dist/cjs/stored/draht.js +1 -0
  52. package/dist/cjs/stored/einstellungen.js +50 -2
  53. package/dist/cjs/stored/vokabular.d.ts +1 -1
  54. package/dist/cjs/stored/vokabular.js +107 -5
  55. package/dist/cjs/version.d.ts +1 -1
  56. package/dist/cjs/version.js +1 -1
  57. package/dist/esm/client/aufrufe.d.ts +3 -3
  58. package/dist/esm/client/aufrufe.js +8 -0
  59. package/dist/esm/client/receipts.d.ts +11 -0
  60. package/dist/esm/client/receipts.js +14 -0
  61. package/dist/esm/index.d.ts +2 -2
  62. package/dist/esm/index.js +2 -2
  63. package/dist/esm/models/index.d.ts +2 -2
  64. package/dist/esm/models/index.js +2 -2
  65. package/dist/esm/models/receipt-errors.d.ts +1 -1
  66. package/dist/esm/models/receipt-errors.js +9 -0
  67. package/dist/esm/models/receipt-item.d.ts +44 -2
  68. package/dist/esm/models/receipt-item.js +54 -1
  69. package/dist/esm/models/receipt.d.ts +17 -0
  70. package/dist/esm/models/receipt.js +9 -0
  71. package/dist/esm/models/voucher.d.ts +18 -0
  72. package/dist/esm/models/voucher.js +30 -0
  73. package/dist/esm/pos/artikel.d.ts +26 -0
  74. package/dist/esm/pos/artikel.js +5 -0
  75. package/dist/esm/pos/client.d.ts +1 -0
  76. package/dist/esm/pos/client.js +15 -1
  77. package/dist/esm/pos/errors.d.ts +1 -1
  78. package/dist/esm/pos/errors.js +13 -0
  79. package/dist/esm/pos/fremdgutschein-artikel.d.ts +66 -0
  80. package/dist/esm/pos/fremdgutschein-artikel.js +67 -0
  81. package/dist/esm/pos/index.d.ts +9 -4
  82. package/dist/esm/pos/index.js +10 -4
  83. package/dist/esm/pos/leergut.d.ts +60 -0
  84. package/dist/esm/pos/leergut.js +77 -0
  85. package/dist/esm/pos/pfand.d.ts +144 -0
  86. package/dist/esm/pos/pfand.js +371 -0
  87. package/dist/esm/pos/rabatt-vorlagen.d.ts +79 -0
  88. package/dist/esm/pos/rabatt-vorlagen.js +148 -0
  89. package/dist/esm/pos/schicht-lesen.js +8 -0
  90. package/dist/esm/pos/schicht-typen.d.ts +15 -0
  91. package/dist/esm/pos/settings.d.ts +72 -10
  92. package/dist/esm/pos/settings.js +74 -4
  93. package/dist/esm/pos/texte.d.ts +283 -0
  94. package/dist/esm/pos/texte.js +160 -0
  95. package/dist/esm/pos/zusaetze.d.ts +3 -3
  96. package/dist/esm/pos/zusaetze.js +4 -2
  97. package/dist/esm/receipt/discount.js +4 -1
  98. package/dist/esm/receipt/due.d.ts +6 -0
  99. package/dist/esm/receipt/due.js +17 -6
  100. package/dist/esm/receipt/gutschein-plan.d.ts +7 -1
  101. package/dist/esm/receipt/gutschein-plan.js +14 -2
  102. package/dist/esm/receipt/layout.js +109 -3
  103. package/dist/esm/receipt/shift-sheet.js +8 -0
  104. package/dist/esm/register/pairing.d.ts +15 -1
  105. package/dist/esm/register/pairing.js +13 -1
  106. package/dist/esm/stored/draht.js +1 -0
  107. package/dist/esm/stored/einstellungen.js +52 -4
  108. package/dist/esm/stored/vokabular.d.ts +1 -1
  109. package/dist/esm/stored/vokabular.js +107 -5
  110. package/dist/esm/version.d.ts +1 -1
  111. package/dist/esm/version.js +1 -1
  112. package/fixtures/add-on-cases.json +6 -4
  113. package/fixtures/deposit-cases.json +4758 -0
  114. package/fixtures/discount-preset-cases.json +1074 -0
  115. package/fixtures/expected/deposit-return.grid32.txt +28 -0
  116. package/fixtures/expected/deposit-return.grid48.txt +28 -0
  117. package/fixtures/expected/deposit-return.lines.json +275 -0
  118. package/fixtures/expected/deposit-return.sheet32.json +194 -0
  119. package/fixtures/expected/deposit-return.sheet48.json +194 -0
  120. package/fixtures/expected/deposit.grid32.txt +34 -0
  121. package/fixtures/expected/deposit.grid48.txt +32 -0
  122. package/fixtures/expected/deposit.lines.json +316 -0
  123. package/fixtures/expected/deposit.sheet32.json +230 -0
  124. package/fixtures/expected/deposit.sheet48.json +218 -0
  125. package/fixtures/external-voucher-article-cases.json +311 -0
  126. package/fixtures/hobex-hps-codes.json +1 -1
  127. package/fixtures/invoice-api.schema.json +1 -1
  128. package/fixtures/invoice-texts.json +1 -1
  129. package/fixtures/manifest.json +16 -0
  130. package/fixtures/pos-texts.json +266 -1
  131. package/fixtures/receipt-due-voucher-generated.json +1 -1
  132. package/fixtures/receipts/deposit-return.json +63 -0
  133. package/fixtures/receipts/deposit.json +83 -0
  134. package/fixtures/renames-1.0.json +18 -0
  135. package/fixtures/return-code-cases.json +1338 -0
  136. package/fixtures/surface.json +92 -7
  137. package/fixtures/v3/antworten/belege.json +2 -2
  138. package/fixtures/v3/antworten/belegmail.json +2 -2
  139. package/fixtures/v3/antworten/berichte.json +2 -2
  140. package/fixtures/v3/antworten/kasse-belege.json +2 -2
  141. package/fixtures/v3/antworten/kasse.json +428 -13
  142. package/fixtures/v3/antworten/lager.json +1 -1
  143. package/fixtures/v3/antworten/rechnungen.json +2 -2
  144. package/fixtures/v3/antworten/storno.json +2 -2
  145. package/fixtures/v3/stored/belege.json +2 -2
  146. package/fixtures/v3/stored/kasse.json +42 -4
  147. package/fixtures/v3/stored/rechnungen.json +2 -2
  148. package/fixtures/v3/v3-vokabular.json +898 -31
  149. package/fixtures/v3/zahlbetrag-faelle.json +187 -3
  150. package/package.json +1 -1
@@ -0,0 +1,67 @@
1
+ export const ARTICLE_EXTERNAL_VOUCHER_TYPES = Object.freeze(['multi_purpose', 'single_purpose']);
2
+ /** Fehlercode beim Speichern eines Artikels, intern und unter `/v3` gleich. */
3
+ export const ARTICLE_EXTERNAL_VOUCHER_INVALID = 'article_external_voucher_invalid';
4
+ /** Welche Regel verletzt ist (Antwortfeld `data.grund`), in der Reihenfolge, in der der Server prueft. */
5
+ export const EXTERNAL_VOUCHER_ARTICLE_REASONS = Object.freeze([
6
+ 'invalid_type', 'service_voucher', 'add_ons', 'stock_tracked', 'reference', 'asks_quantity', 'rate_required', 'invalid_rate', 'price_required',
7
+ ]);
8
+ /**
9
+ * Saetze, mit denen ein Einzweckgutschein verkauft werden kann (Prozent wie
10
+ * `PosArticle.vatRate`; 0 = befreit verkauft): die Saetze der Kasse, Backend
11
+ * `article-groups-core.STEUERSAETZE`, dieselben wie [EXTERNAL_VOUCHER_VAT_RATES_BP] / 100.
12
+ */
13
+ export const ARTICLE_EXTERNAL_VOUCHER_VAT_RATES = Object.freeze([20, 13, 10, 4.9, 0, 19]);
14
+ /** Ist der Wert eine Art fremder Gutschein? */
15
+ export function isArticleExternalVoucher(value) {
16
+ return ARTICLE_EXTERNAL_VOUCHER_TYPES.includes(value);
17
+ }
18
+ /** Form des Werts beim Speichern: `null` heisst entfernen und ist gueltig. Zwilling von `pruefeWert`. */
19
+ export function checkExternalVoucherValue(value) {
20
+ return value === null || isArticleExternalVoucher(value) ? null : 'invalid_type';
21
+ }
22
+ /**
23
+ * Regeln am wirksamen Artikelstand (Bestand + Aenderung), Zwilling von
24
+ * `pruefeArtikel`: `null` = passt. Ohne `externalVoucher` gilt keine Regel.
25
+ * Einzweck verlangt einen Satz der Kasse (0 = befreit verkauft), Mehrzweck ignoriert ihn;
26
+ * nie zusammen mit Leistungsgutschein, eigener Zusatzliste, Lagerbestand,
27
+ * Referenz oder Mengenabfrage (die Kasse fragt die Nummer selbst und bucht
28
+ * genau einen); ohne `askPrice` braucht er einen Preis ab 1 Cent.
29
+ */
30
+ export function checkExternalVoucherArticle(a) {
31
+ if (a.externalVoucher == null)
32
+ return null;
33
+ if (!isArticleExternalVoucher(a.externalVoucher))
34
+ return 'invalid_type';
35
+ if (a.serviceVoucher === true)
36
+ return 'service_voucher';
37
+ if (Array.isArray(a.addOns) && a.addOns.length > 0)
38
+ return 'add_ons';
39
+ if (a.stockTracked === true)
40
+ return 'stock_tracked';
41
+ if (a.reference)
42
+ return 'reference';
43
+ if (a.askQuantity === true)
44
+ return 'asks_quantity';
45
+ if (a.externalVoucher === 'single_purpose' && !(typeof a.vatRate === 'number' && Number.isFinite(a.vatRate)))
46
+ return 'rate_required';
47
+ if (a.externalVoucher === 'single_purpose' && !ARTICLE_EXTERNAL_VOUCHER_VAT_RATES.includes(a.vatRate))
48
+ return 'invalid_rate';
49
+ if (a.askPrice !== true && !(typeof a.unitPriceCents === 'number' && Number.isInteger(a.unitPriceCents) && a.unitPriceCents >= 1))
50
+ return 'price_required';
51
+ return null;
52
+ }
53
+ /**
54
+ * Darf die Kachel verkaufen? `null` = ja (auch fuer jeden Artikel ohne
55
+ * `externalVoucher`). Gesperrt bei Freigabe `off` (oder ohne Angabe) und bei
56
+ * Einzweck ohne `all` -- dieselbe Regel, mit der der Server den Beleg abweist
57
+ * (`external_voucher_not_enabled`, `external_voucher_type_not_enabled`).
58
+ */
59
+ export function externalVoucherTileBlock(article, externalVouchers) {
60
+ if (article.externalVoucher == null)
61
+ return null;
62
+ if (externalVouchers !== 'multi_purpose' && externalVouchers !== 'all')
63
+ return 'not_enabled';
64
+ if (article.externalVoucher === 'single_purpose' && externalVouchers !== 'all')
65
+ return 'type_not_enabled';
66
+ return null;
67
+ }
@@ -6,28 +6,33 @@
6
6
  * die Backend-Functions (die Rewrites-Waechter der Web-App leiten daraus ab)
7
7
  * und sprechen den Kassenweg `/api/v3` (Schluessel und Werte englisch).
8
8
  */
9
- export { type PosTheme, type PosFontSize, type PosWatermark, type PosQuantity, type PosTipMode, type PosCheckoutMode, type PosCardProvider, type PosReceiptOutput, type PosShortcutAction, type PosShortcutMap, POS_SHORTCUT_ACTIONS, POS_SHORTCUT_DEFAULTS, type PosLayout, type PosCategoryPosition, type PosTileHeight, type PosPrinterType, type PosTerminalVia, type PosTerminalType, type PosPaperSize, type PosCodePage, type PosCut, type PosDrawerAutoOpen, type PosQrMode, type PosLogoSize, type PosSettingsFontSize, type PosTileStyle, type PosAutoLogoutMinutes, type PosDiscount, type PosWatermarkSide, type PosWatermarkStrength, type PosLogoScale, type PosWatermarkScale, type PosDoneScreenSeconds, type PosToggleMap, type PosBusinessSettings, type PosDeviceSettings, type PosSettings, POS_BUSINESS_DEFAULTS, POS_DEVICE_DEFAULTS, POS_DEVICE_OPTIONAL_FIELDS, POS_BUSINESS_OPTIONAL_FIELDS, POS_BUSINESS_OPTIONAL_CHOICES, POS_DEVICE_OPTIONAL_CHOICES, posTipKeptByDefault, posTipKinds, posTipStart, posCartWidth, POS_BUSINESS_VALUES, POS_DEVICE_VALUES, mergePosSettings, sanitizePosSettings, unknownPosSettingValues, posSettingsChanges, type PosOpen, POS_SHORTCUT_SHARED_PAIRS, posShortcutConflict, THEME, FONT_SIZE, WATERMARK, QUANTITY, TIP_MODE, TIP_KINDS, TIP_START, CART_WIDTH, type PosTipKind, type PosCartWidth, CHECKOUT_MODE, CARD_PROVIDER, RECEIPT_OUTPUT, LAYOUT, CATEGORY_POSITION, TILE_HEIGHT, PRINTER_TYPE, TERMINAL_VIA, TERMINAL_TYPE, PAPER_SIZE, CODE_PAGE, CUT, DRAWER_AUTO_OPEN, QR_MODE, LOGO_SIZE, SETTINGS_FONT_SIZE, TILE_STYLE, AUTO_LOGOUT_MINUTES, DISCOUNT, WATERMARK_SIDE, WATERMARK_STRENGTH, LOGO_SCALE, WATERMARK_SCALE, DONE_SCREEN_SECONDS, } from './settings.js';
9
+ export { type PosTheme, type PosFontSize, type PosWatermark, type PosQuantity, type PosTipMode, type PosCheckoutMode, type PosCardProvider, type PosReceiptOutput, type PosShortcutAction, type PosShortcutMap, POS_SHORTCUT_ACTIONS, POS_SHORTCUT_DEFAULTS, type PosLayout, type PosCategoryPosition, type PosTileHeight, type PosPrinterType, type PosTerminalVia, type PosTerminalType, type PosPaperSize, type PosCodePage, type PosCut, type PosDrawerAutoOpen, type PosQrMode, type PosLogoSize, type PosSettingsFontSize, type PosTileStyle, type PosAutoLogoutMinutes, type PosDiscount, type PosWatermarkSide, type PosWatermarkStrength, type PosLogoScale, type PosWatermarkScale, type PosDoneScreenSeconds, type PosToggleMap, type PosBusinessSettings, type PosDeviceSettings, type PosSettings, POS_BUSINESS_DEFAULTS, POS_DEVICE_DEFAULTS, POS_DEVICE_OPTIONAL_FIELDS, POS_BUSINESS_OPTIONAL_FIELDS, POS_BUSINESS_OPTIONAL_CHOICES, POS_DEVICE_OPTIONAL_CHOICES, posTipKeptByDefault, posCustomDiscountAllowed, posTipKeptMode, tipKeptFor, type TipKeptDecision, DISCOUNT_PRESET_KIND, type PosDiscountPreset, type PosDiscountPresetKind, POS_BUSINESS_OPTIONAL_LISTS, posTipKinds, posTipStart, posCartWidth, POS_BUSINESS_VALUES, POS_DEVICE_VALUES, mergePosSettings, sanitizePosSettings, unknownPosSettingValues, posSettingsChanges, type PosOpen, POS_SHORTCUT_SHARED_PAIRS, posShortcutConflict, THEME, FONT_SIZE, WATERMARK, QUANTITY, TIP_MODE, TIP_KINDS, TIP_START, TIP_KEPT_MODE, type PosTipKeptMode, CART_WIDTH, type PosTipKind, type PosCartWidth, CHECKOUT_MODE, CARD_PROVIDER, RECEIPT_OUTPUT, LAYOUT, CATEGORY_POSITION, TILE_HEIGHT, PRINTER_TYPE, TERMINAL_VIA, TERMINAL_TYPE, PAPER_SIZE, CODE_PAGE, CUT, DRAWER_AUTO_OPEN, QR_MODE, LOGO_SIZE, SETTINGS_FONT_SIZE, TILE_STYLE, AUTO_LOGOUT_MINUTES, DISCOUNT, WATERMARK_SIDE, WATERMARK_STRENGTH, LOGO_SCALE, WATERMARK_SCALE, DONE_SCREEN_SECONDS, } from './settings.js';
10
10
  export { type ArticleGroup, type ArticleGroupPayload, fromArticleGroupPayload, type PosArticle, type PosArticlePayload, fromPosArticlePayload, listMyArticleGroups, listMyArticles, QUANTITY_RULES, type QuantityRule, type QuantityDefaults, quantityRuleForUnit, quantityDefaults, allowedQuantity, isBookableArticle, tilePrompts, } from './artikel.js';
11
11
  export { REFERENCE_MODES, type ReferenceMode, type PosReference, REFERENCE_INPUT_MAX, REFERENCE_LABEL_MAX, REFERENCE_HINT_MAX, REFERENCE_PATTERN_MAX, REFERENCE_PATTERN_TEMPLATES, cleanReferenceText, isValidReferencePattern, isDigitsOnlyPattern, type ReferenceCheckResult, checkReference, referenceLineName, fromReferencePayload, } from './kachel-referenz.js';
12
12
  export { ADD_ONS_MAX, ADD_ON_BLOCK_REASONS, type AddOnBlockReason, isSelectableAddOn, addOnsFor, addOnReferencesValid, addOnsOfItem, addOnRemap, addOnDisplayOrder, orderAddOnLines, } from './zusaetze.js';
13
+ export { DEPOSIT_KINDS, type DepositKind, DEPOSIT_TYPES, type DepositContainerType, DEPOSIT_RETURN_MODES, type DepositReturnMode, DEPOSIT_ON_PREMISES_DEFAULTS, type DepositOnPremisesDefault, type DepositAmount, type DepositType, type DepositSettings, type DepositEntry, type DepositSharedReturnPoint, type CashRegisterDeposit, posDepositSettingsFromWire, depositEntriesFromWire, cashRegisterDepositFromWire, depositsFor, depositAmountOn, viennaDay, withDepositLines, depositReturnLine, type DepositPreviewItem, type DepositPreviewLine, type DepositPreviewInput, type DepositPreviewArticle, type DepositPreviewResult, type DepositPreviewErrorCode, } from './pfand.js';
14
+ export { ARTICLE_EXTERNAL_VOUCHER_TYPES, type ArticleExternalVoucher, ARTICLE_EXTERNAL_VOUCHER_INVALID, ARTICLE_EXTERNAL_VOUCHER_VAT_RATES, EXTERNAL_VOUCHER_ARTICLE_REASONS, type ExternalVoucherArticleReason, type ExternalVoucherArticleInput, isArticleExternalVoucher, checkExternalVoucherValue, checkExternalVoucherArticle, type ExternalVoucherTileBlock, externalVoucherTileBlock, } from './fremdgutschein-artikel.js';
15
+ export { ownVoucherCodeShape, OWN_VOUCHER_CODE_SHAPES, type OwnVoucherCodeShape } from '../models/voucher.js';
13
16
  export { getPosSettings, setMyPosSettings, setMyRegisterDeviceSettings, setMyPosLogo, posSettingsFromWire, type SetMyPosLogoOptions, } from './client.js';
14
17
  export { POS_ERROR_CODES, type PosErrorCode, isPosErrorCode, posErrorCode, isPosError, type PosFieldError, posFieldErrors, } from './errors.js';
15
18
  export { distributeDiscount } from '../receipt/discount.js';
16
- export { cancelScopeOf, receiptsScopeOf, stockViewOf, voucherPermsOf, type VoucherPerms, type RegisterScope, type RegisterUserPerms } from '../register/pairing.js';
19
+ export { cancelScopeOf, receiptsScopeOf, stockViewOf, voucherPermsOf, depositReturnOf, type VoucherPerms, type RegisterScope, type RegisterUserPerms } from '../register/pairing.js';
17
20
  export { type NetworkPrinter, type PrintJob, type PrintJobStatus, PRINT_JOB_STATUSES, type PrintJobSource, PRINT_JOB_SOURCES, isPrintJobFinished, type CreatePrintJobOptions, listMyPrinters, createPrintJob, getPrintJob, } from './drucker.js';
18
21
  export { listMyTipRecipients } from './trinkgeld.js';
22
+ export { posDiscountPresets, discountPresetChipText, discountChipsFromPresets, checkDiscountPresets, discountBlockLines, INVALID_DISCOUNT_PRESET, DISCOUNT_PRESETS_MAX, DISCOUNT_PRESET_NAME_MAX, DISCOUNT_PRESET_PERCENT_BP, DISCOUNT_PRESET_AMOUNT_CENTS, DISCOUNT_PRESET_MESSAGES, type DiscountPresetReason, type DiscountPresetError, type DiscountPresetsCheck, type DiscountBlockLine, type DiscountTotal, } from './rabatt-vorlagen.js';
19
23
  export { depFolderName } from './dep.js';
20
24
  export { type RegisterInspectionInfo, type RegisterInspectionSignature, type InspectionSignatureStatus, type InspectionInfoRow, type InspectionInfoRowKey, type InspectionInfoSection, type InspectionInfoLinesOptions, getRegisterInspectionInfo, inspectionInfoRows, inspectionInfoLines, } from './kasseninfo.js';
21
25
  export { type ConnectStateReport, reportConnectState } from './connect-bestand.js';
26
+ export { type ReturnCode, type ReturnCodeEntry, type ReturnCodeMatch, type ReturnCodeArticle, type ReturnCodeGroup, type ReturnCodeInput, learnReturnCode, listReturnCodes, matchReturnCode, } from './leergut.js';
22
27
  export { STOCK_LOCATION_TYPES, type StockLocationType, type StockLocation, type StockLocationAddress, type StockLevel, type StockValue, type StockList, type ListMyStockOptions, type SetMyCashregisterStockLocationOptions, type CashregisterStockLocation, listMyStockLocations, listMyStock, setMyCashregisterStockLocation, } from './lager.js';
23
28
  export { type ListMyStocktakesOptions, type ListMyStocktakeItemsOptions, type ListMyStocktakeCountsOptions, type RecordMyStocktakeCountOptions, type VoidMyStocktakeCountOptions, listMyStocktakes, listMyStocktakeItems, listMyStocktakeCounts, recordMyStocktakeCount, voidMyStocktakeCount, parseQuantityMilli, } from './inventur.js';
24
29
  export type { Stocktake, StocktakeItem, StocktakeCount, StocktakeCountResult, StocktakeItemPage, StocktakeCountPage, StocktakeActor, StocktakeProgress, StocktakeReview, StocktakeRecount, StocktakeScope, } from '../inventory/typen.js';
25
30
  export type { StocktakeStatus } from '../inventory/vertrag.js';
26
31
  export { VOUCHER_KINDS, VOUCHER_STATUSES, checkVoucher, reprintVoucherLabel, VOUCHER_SETTINGS_DEFAULTS, posVoucherSettingsFromWire, VOUCHER_PAYOUTS, VOUCHER_TYPE_KINDS, VOUCHER_AMOUNT_MODES, VOUCHER_TYPE_VALIDITY_PATTERNS, EXTERNAL_VOUCHERS, type PosExternalVouchers, type VoucherKind, type VoucherStatus, type VoucherValidity, type VoucherArticle, type VoucherCheck, type PosVoucherSettings, type PosVoucherReturnType, type VoucherPayout, type VoucherTypeKind, type PosVoucherType, type VoucherLabelTemplate, } from './gutschein.js';
27
32
  export { type GetMyDrawerStateOptions, type OpenMyShiftOptions, type RecordMyCashMovementOptions, type DrawerOpeningEntry, type LogMyDrawerOpeningsOptions, type GetMyShiftReportOptions, type TipPayout, type CloseMyShiftOptions, type AfterCountOption, type RecordMyShiftCountOptions, getMyDrawerState, openMyShift, recordMyCashMovement, logMyDrawerOpenings, getMyShiftReport, closeMyShift, recordMyShiftCount, sumDenominations, parseCentsAllowZero, newIdempotencyKey, shiftTipLines, durationText, type ShiftTipLine, type ShiftTipLineKey, } from './schicht.js';
28
- export { EUR_DENOMINATIONS, MOVEMENT_TYPES, MANUAL_MOVEMENT_TYPES, CASH_LOCATIONS, OPENING_REASONS, MANUAL_OPENING_REASONS, SHIFT_RECEIPT_KINDS, AFTER_COUNT_TYPES, type AfterCountType, type AfterCount, EXPECTED_PART_KEYS, DIFFERENCE_PART_TYPES, type ExpectedPartKey, type ShiftExpectedPart, type DifferencePartType, type ShiftDifferencePart, type LastShift, type ShiftCountResult, type EurDenomination, type MovementType, type ManualMovementType, type CashLocation, type OpeningReason, type ManualOpeningReason, type ShiftReceiptKind, type ShiftStatus, type ShiftActorRole, type Denominations, type ShiftActor, type DrawerInfo, type DrawerRights, type NonCashAmount, type ShiftTipTotals, type ShiftTip, type ShiftOwnerTip, type ShiftRunningTotals, type ShiftReconciliation, type Shift, type TipClaim, type DrawerOpening, type DrawerState, type CashMovement, type ShiftReceiptHeader, type ShiftReceiptMovement, type ShiftReceiptTip, type ShiftSummaryReceipt, type CashMovementReceipt, type ShiftReceipt, type OpenShiftResult, type CashMovementResult, type DrawerOpeningsResult, type ShiftReport, type CloseShiftResult, } from './schicht-typen.js';
33
+ export { EUR_DENOMINATIONS, MOVEMENT_TYPES, MANUAL_MOVEMENT_TYPES, CASH_LOCATIONS, OPENING_REASONS, MANUAL_OPENING_REASONS, SHIFT_RECEIPT_KINDS, AFTER_COUNT_TYPES, type AfterCountType, type AfterCount, EXPECTED_PART_KEYS, DIFFERENCE_PART_TYPES, type ExpectedPartKey, type ShiftExpectedPart, type DifferencePartType, type ShiftDifferencePart, type LastShift, type ShiftCountResult, type EurDenomination, type MovementType, type ManualMovementType, type CashLocation, type OpeningReason, type ManualOpeningReason, type ShiftReceiptKind, type ShiftStatus, type ShiftActorRole, type Denominations, type ShiftActor, type DrawerInfo, type DrawerRights, type NonCashAmount, type ShiftTipTotals, type ShiftTip, type ShiftOwnerTip, type ShiftDiscount, type ShiftRunningTotals, type ShiftReconciliation, type Shift, type TipClaim, type DrawerOpening, type DrawerState, type CashMovement, type ShiftReceiptHeader, type ShiftReceiptMovement, type ShiftReceiptTip, type ShiftSummaryReceipt, type CashMovementReceipt, type ShiftReceipt, type OpenShiftResult, type CashMovementResult, type DrawerOpeningsResult, type ShiftReport, type CloseShiftResult, } from './schicht-typen.js';
29
34
  export { type ShiftReceiptLayoutOptions, shiftReceiptLayout, cashMovementLayout } from '../receipt/shift-sheet.js';
30
35
  export { RECEIPT_OUTPUT_KINDS, RECEIPT_OUTPUT_RESULTS, type ReceiptOutputKind, type ReceiptOutputResult } from '../models/receipt-output.js';
31
36
  export { RETURN_DISPOSITIONS, isReturnDisposition, type ReturnDisposition } from '../models/cancellation.js';
32
- export { MESSAGES, ERROR_RULES, ERROR_CODE_RULES, ERROR_OUTCOME_RULES, CALLS_WITH_EFFECT, findErrorRule, messageOutcome, messageText, messageAppliesTo, RECEIPT_EMAIL_ERROR_MESSAGES, receiptEmailErrorMessage, CANCELLATION_PAYMENT_ERROR_MESSAGES, cancellationPaymentErrorMessage, CANCELLATION_VOUCHER_ERROR_MESSAGES, cancellationErrorMessage, VOUCHER_ERROR_MESSAGES, voucherErrorMessage, LABELS, labelText, RETURN_DISPOSITION_LABELS, receiptOutputLabel, type TextEntry, type MessageKey, type ErrorKind, type ErrorRule, type ErrorRuleDetail, type Surface, type ReceiptEmailMessageCode, type CancellationPaymentMessageCode, type LabelKey, } from './texte.js';
37
+ export { MESSAGES, ERROR_RULES, ERROR_CODE_RULES, ERROR_OUTCOME_RULES, CALLS_WITH_EFFECT, findErrorRule, messageOutcome, messageText, messageAppliesTo, RECEIPT_EMAIL_ERROR_MESSAGES, receiptEmailErrorMessage, CANCELLATION_PAYMENT_ERROR_MESSAGES, cancellationPaymentErrorMessage, CANCELLATION_VOUCHER_ERROR_MESSAGES, cancellationErrorMessage, VOUCHER_ERROR_MESSAGES, voucherErrorMessage, DEPOSIT_ERROR_MESSAGES, depositErrorMessage, EXTERNAL_VOUCHER_TILE_MESSAGES, EXTERNAL_VOUCHER_ARTICLE_MESSAGES, externalVoucherArticleErrorMessage, EXTERNAL_VOUCHERS_LABELS, EXTERNAL_VOUCHER_KIND_LABELS, TIP_KEPT_MODE_LABELS, LABELS, labelText, RETURN_DISPOSITION_LABELS, receiptOutputLabel, type TextEntry, type MessageKey, type ErrorKind, type ErrorRule, type ErrorRuleDetail, type Surface, type ReceiptEmailMessageCode, type CancellationPaymentMessageCode, type LabelKey, } from './texte.js';
33
38
  export { roundUpSuggestions } from './aufrunden.js';
@@ -6,26 +6,32 @@
6
6
  * die Backend-Functions (die Rewrites-Waechter der Web-App leiten daraus ab)
7
7
  * und sprechen den Kassenweg `/api/v3` (Schluessel und Werte englisch).
8
8
  */
9
- export { POS_SHORTCUT_ACTIONS, POS_SHORTCUT_DEFAULTS, POS_BUSINESS_DEFAULTS, POS_DEVICE_DEFAULTS, POS_DEVICE_OPTIONAL_FIELDS, POS_BUSINESS_OPTIONAL_FIELDS, POS_BUSINESS_OPTIONAL_CHOICES, POS_DEVICE_OPTIONAL_CHOICES, posTipKeptByDefault, posTipKinds, posTipStart, posCartWidth, POS_BUSINESS_VALUES, POS_DEVICE_VALUES, mergePosSettings, sanitizePosSettings, unknownPosSettingValues, posSettingsChanges, POS_SHORTCUT_SHARED_PAIRS, posShortcutConflict,
9
+ export { POS_SHORTCUT_ACTIONS, POS_SHORTCUT_DEFAULTS, POS_BUSINESS_DEFAULTS, POS_DEVICE_DEFAULTS, POS_DEVICE_OPTIONAL_FIELDS, POS_BUSINESS_OPTIONAL_FIELDS, POS_BUSINESS_OPTIONAL_CHOICES, POS_DEVICE_OPTIONAL_CHOICES, posTipKeptByDefault, posCustomDiscountAllowed, posTipKeptMode, tipKeptFor, DISCOUNT_PRESET_KIND, POS_BUSINESS_OPTIONAL_LISTS, posTipKinds, posTipStart, posCartWidth, POS_BUSINESS_VALUES, POS_DEVICE_VALUES, mergePosSettings, sanitizePosSettings, unknownPosSettingValues, posSettingsChanges, POS_SHORTCUT_SHARED_PAIRS, posShortcutConflict,
10
10
  // Die Enums als Laufzeitlisten, benannt nach ihrem Feld.
11
- THEME, FONT_SIZE, WATERMARK, QUANTITY, TIP_MODE, TIP_KINDS, TIP_START, CART_WIDTH, CHECKOUT_MODE, CARD_PROVIDER, RECEIPT_OUTPUT, LAYOUT, CATEGORY_POSITION, TILE_HEIGHT, PRINTER_TYPE, TERMINAL_VIA, TERMINAL_TYPE, PAPER_SIZE, CODE_PAGE, CUT, DRAWER_AUTO_OPEN, QR_MODE, LOGO_SIZE, SETTINGS_FONT_SIZE, TILE_STYLE, AUTO_LOGOUT_MINUTES, DISCOUNT, WATERMARK_SIDE, WATERMARK_STRENGTH, LOGO_SCALE, WATERMARK_SCALE, DONE_SCREEN_SECONDS, } from './settings.js';
11
+ THEME, FONT_SIZE, WATERMARK, QUANTITY, TIP_MODE, TIP_KINDS, TIP_START, TIP_KEPT_MODE, CART_WIDTH, CHECKOUT_MODE, CARD_PROVIDER, RECEIPT_OUTPUT, LAYOUT, CATEGORY_POSITION, TILE_HEIGHT, PRINTER_TYPE, TERMINAL_VIA, TERMINAL_TYPE, PAPER_SIZE, CODE_PAGE, CUT, DRAWER_AUTO_OPEN, QR_MODE, LOGO_SIZE, SETTINGS_FONT_SIZE, TILE_STYLE, AUTO_LOGOUT_MINUTES, DISCOUNT, WATERMARK_SIDE, WATERMARK_STRENGTH, LOGO_SCALE, WATERMARK_SCALE, DONE_SCREEN_SECONDS, } from './settings.js';
12
12
  export { fromArticleGroupPayload, fromPosArticlePayload, listMyArticleGroups, listMyArticles, QUANTITY_RULES, quantityRuleForUnit, quantityDefaults, allowedQuantity, isBookableArticle, tilePrompts, } from './artikel.js';
13
13
  export { REFERENCE_MODES, REFERENCE_INPUT_MAX, REFERENCE_LABEL_MAX, REFERENCE_HINT_MAX, REFERENCE_PATTERN_MAX, REFERENCE_PATTERN_TEMPLATES, cleanReferenceText, isValidReferencePattern, isDigitsOnlyPattern, checkReference, referenceLineName, fromReferencePayload, } from './kachel-referenz.js';
14
14
  export { ADD_ONS_MAX, ADD_ON_BLOCK_REASONS, isSelectableAddOn, addOnsFor, addOnReferencesValid, addOnsOfItem, addOnRemap, addOnDisplayOrder, orderAddOnLines, } from './zusaetze.js';
15
+ export { DEPOSIT_KINDS, DEPOSIT_TYPES, DEPOSIT_RETURN_MODES, DEPOSIT_ON_PREMISES_DEFAULTS, posDepositSettingsFromWire, depositEntriesFromWire, cashRegisterDepositFromWire, depositsFor, depositAmountOn, viennaDay, withDepositLines, depositReturnLine, } from './pfand.js';
16
+ export { ARTICLE_EXTERNAL_VOUCHER_TYPES, ARTICLE_EXTERNAL_VOUCHER_INVALID, ARTICLE_EXTERNAL_VOUCHER_VAT_RATES, EXTERNAL_VOUCHER_ARTICLE_REASONS, isArticleExternalVoucher, checkExternalVoucherValue, checkExternalVoucherArticle, externalVoucherTileBlock, } from './fremdgutschein-artikel.js';
17
+ // Form-Erkennung eigener Codes im Gutschein-Feld (Nachfrage statt Abweisung); dieselbe Funktion wie an der Wurzel.
18
+ export { ownVoucherCodeShape, OWN_VOUCHER_CODE_SHAPES } from '../models/voucher.js';
15
19
  export { getPosSettings, setMyPosSettings, setMyRegisterDeviceSettings, setMyPosLogo, posSettingsFromWire, } from './client.js';
16
20
  export { POS_ERROR_CODES, isPosErrorCode, posErrorCode, isPosError, posFieldErrors, } from './errors.js';
17
21
  export { distributeDiscount } from '../receipt/discount.js';
18
22
  // Reichweiten der Kassen-Rechte (Migration wie im Backend) -- bewusst NICHT im
19
23
  // Register-Unterpfad: dessen Exportnamen sind 1:1 Function-Namen (Rewrites).
20
- export { cancelScopeOf, receiptsScopeOf, stockViewOf, voucherPermsOf } from '../register/pairing.js';
24
+ export { cancelScopeOf, receiptsScopeOf, stockViewOf, voucherPermsOf, depositReturnOf } from '../register/pairing.js';
21
25
  export { PRINT_JOB_STATUSES, PRINT_JOB_SOURCES, isPrintJobFinished, listMyPrinters, createPrintJob, getPrintJob, } from './drucker.js';
22
26
  export { listMyTipRecipients } from './trinkgeld.js';
27
+ export { posDiscountPresets, discountPresetChipText, discountChipsFromPresets, checkDiscountPresets, discountBlockLines, INVALID_DISCOUNT_PRESET, DISCOUNT_PRESETS_MAX, DISCOUNT_PRESET_NAME_MAX, DISCOUNT_PRESET_PERCENT_BP, DISCOUNT_PRESET_AMOUNT_CENTS, DISCOUNT_PRESET_MESSAGES, } from './rabatt-vorlagen.js';
23
28
  // Prüfung (DEP) an der Kasse: Ordner auf dem USB-Stick (gleich in Web-Kasse und Kassen-App).
24
29
  export { depFolderName } from './dep.js';
25
30
  // Prüfung an der Kasse: Kasseninfo für den Prüfer, am Bildschirm und als Ausdruck (gleich im Dart-Zwilling).
26
31
  export { getRegisterInspectionInfo, inspectionInfoRows, inspectionInfoLines, } from './kasseninfo.js';
27
32
  // Connect-Bestand: die Kasse meldet Version und System von Kasseneck Connect.
28
33
  export { reportConnectState } from './connect-bestand.js';
34
+ export { learnReturnCode, listReturnCodes, matchReturnCode, } from './leergut.js';
29
35
  export { STOCK_LOCATION_TYPES, listMyStockLocations, listMyStock, setMyCashregisterStockLocation, } from './lager.js';
30
36
  export { listMyStocktakes, listMyStocktakeItems, listMyStocktakeCounts, recordMyStocktakeCount, voidMyStocktakeCount, parseQuantityMilli, } from './inventur.js';
31
37
  // Gutschein pruefen und Etikett nachdrucken an der Kasse; Gutschein-Sorten (Stufe 4b, 1.17.0).
@@ -39,5 +45,5 @@ export { RECEIPT_OUTPUT_KINDS, RECEIPT_OUTPUT_RESULTS } from '../models/receipt-
39
45
  // Rueckgabe-Wahl beim Storno (Kassen-Dialog); dieselbe Liste wie an der Wurzel.
40
46
  export { RETURN_DISPOSITIONS, isReturnDisposition } from '../models/cancellation.js';
41
47
  // Was die Kasse selbst sagt: ein Katalog fuer Browser-Kasse und App.
42
- export { MESSAGES, ERROR_RULES, ERROR_CODE_RULES, ERROR_OUTCOME_RULES, CALLS_WITH_EFFECT, findErrorRule, messageOutcome, messageText, messageAppliesTo, RECEIPT_EMAIL_ERROR_MESSAGES, receiptEmailErrorMessage, CANCELLATION_PAYMENT_ERROR_MESSAGES, cancellationPaymentErrorMessage, CANCELLATION_VOUCHER_ERROR_MESSAGES, cancellationErrorMessage, VOUCHER_ERROR_MESSAGES, voucherErrorMessage, LABELS, labelText, RETURN_DISPOSITION_LABELS, receiptOutputLabel, } from './texte.js';
48
+ export { MESSAGES, ERROR_RULES, ERROR_CODE_RULES, ERROR_OUTCOME_RULES, CALLS_WITH_EFFECT, findErrorRule, messageOutcome, messageText, messageAppliesTo, RECEIPT_EMAIL_ERROR_MESSAGES, receiptEmailErrorMessage, CANCELLATION_PAYMENT_ERROR_MESSAGES, cancellationPaymentErrorMessage, CANCELLATION_VOUCHER_ERROR_MESSAGES, cancellationErrorMessage, VOUCHER_ERROR_MESSAGES, voucherErrorMessage, DEPOSIT_ERROR_MESSAGES, depositErrorMessage, EXTERNAL_VOUCHER_TILE_MESSAGES, EXTERNAL_VOUCHER_ARTICLE_MESSAGES, externalVoucherArticleErrorMessage, EXTERNAL_VOUCHERS_LABELS, EXTERNAL_VOUCHER_KIND_LABELS, TIP_KEPT_MODE_LABELS, LABELS, labelText, RETURN_DISPOSITION_LABELS, receiptOutputLabel, } from './texte.js';
43
49
  export { roundUpSuggestions } from './aufrunden.js';
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Leergut-Codes an der Kasse (Pfand & Leergut): ein Code, den die Kasse im Leergut-Blatt noch nicht kennt,
3
+ * wird einer Pfandart zugeordnet und gelernt (`learnReturnCode`); `listReturnCodes` liest die gelernten Codes.
4
+ * `matchReturnCode` ist die Regel, mit der ein Scan im Leergut-Blatt einer Pfandart zugeordnet wird – Web-Kasse
5
+ * und Kassen-App (ueber den Dart-Zwilling) benutzen genau diese Regel.
6
+ */
7
+ import type { InternerTransport } from '../client/aufrufe.js';
8
+ import { type DepositEntry, type DepositType } from './pfand.js';
9
+ /** Ein gelernter Leergut-Code: die GTIN und die Pfandart, der sie zugeordnet ist. */
10
+ export interface ReturnCode {
11
+ gtin: string;
12
+ depositTypeId: string;
13
+ }
14
+ /** Eine Zeile der Zuordnung: Pfandart und Stueckzahl, die ein Scan ins Leergut-Blatt bringt. */
15
+ export interface ReturnCodeEntry {
16
+ depositTypeId: string;
17
+ quantity: number;
18
+ }
19
+ /** Ergebnis von `matchReturnCode`: die Eintraege oder `unknown` (Code ist keiner Pfandart zuzuordnen). */
20
+ export type ReturnCodeMatch = {
21
+ entries: ReturnCodeEntry[];
22
+ } | {
23
+ unknown: true;
24
+ };
25
+ /**
26
+ * Lernt einen Leergut-Code (`learnMyLeergutCode`, nur Kassenweg, Recht `depositReturn`): `gtin` muss eine gueltige
27
+ * GTIN sein, `depositTypeId` eine aktive Pfandart. Die Form wird vor dem Senden geprueft; was der Server nicht
28
+ * annimmt, lehnt er mit `invalid_deposit` oder `deposit_type_not_found` ab.
29
+ */
30
+ export declare function learnReturnCode(transport: InternerTransport, code: ReturnCode): Promise<ReturnCode>;
31
+ /** Liest die gelernten Leergut-Codes (`listMyLeergutCodes`, nur Kassenweg): nur aktive Pfandarten, nach GTIN sortiert. */
32
+ export declare function listReturnCodes(transport: InternerTransport): Promise<ReturnCode[]>;
33
+ /** Was `matchReturnCode` von einem Artikel braucht (Teil von `PosArticle`). */
34
+ export interface ReturnCodeArticle {
35
+ groupId?: string | null;
36
+ ean?: string | null;
37
+ number?: string | null;
38
+ internalCode?: string | null;
39
+ deposits?: DepositEntry[] | null;
40
+ externalVoucher?: unknown;
41
+ }
42
+ /** Was `matchReturnCode` von einer Gruppe braucht (Teil von `ArticleGroup`). */
43
+ export interface ReturnCodeGroup {
44
+ id: string;
45
+ deposits?: DepositEntry[] | null;
46
+ }
47
+ export interface ReturnCodeInput {
48
+ articles: ReadonlyArray<ReturnCodeArticle>;
49
+ groups: ReadonlyArray<ReturnCodeGroup>;
50
+ learned: ReadonlyArray<ReturnCode>;
51
+ depositTypes: ReadonlyArray<Pick<DepositType, 'id' | 'active'>>;
52
+ }
53
+ /**
54
+ * Ordnet einen Scan im Leergut-Blatt einer Pfandart zu. Reihenfolge: (1) gelernter Code -> 1 Stueck; (2) `gtin` eines
55
+ * Pfandeintrags an Artikel oder Gruppe -> 1 Stueck dieser Pfandart; (3) Artikel-EAN, -Nummer oder -Code mit wirksamer
56
+ * Pfandliste -> jeder Eintrag mit seiner `quantity` (Kiste: 1 Kiste + 20 Flaschen); sonst `unknown`. Es zaehlen nur
57
+ * aktive Pfandarten: ein Treffer auf eine stillgelegte oder unbekannte Pfandart ist `unknown` (die Suche endet am
58
+ * ersten Treffer, sie faellt nicht auf die naechste Stufe zurueck). Der Code wird getrimmt, ein leerer ist `unknown`.
59
+ */
60
+ export declare function matchReturnCode(code: string, input: ReturnCodeInput): ReturnCodeMatch;
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Leergut-Codes an der Kasse (Pfand & Leergut): ein Code, den die Kasse im Leergut-Blatt noch nicht kennt,
3
+ * wird einer Pfandart zugeordnet und gelernt (`learnReturnCode`); `listReturnCodes` liest die gelernten Codes.
4
+ * `matchReturnCode` ist die Regel, mit der ein Scan im Leergut-Blatt einer Pfandart zugeordnet wird – Web-Kasse
5
+ * und Kassen-App (ueber den Dart-Zwilling) benutzen genau diese Regel.
6
+ */
7
+ import { Gtin } from '@kreiseck/validator';
8
+ import { KasseneckValidationError } from '../client/errors.js';
9
+ import { depositsFor } from './pfand.js';
10
+ const istObjekt = (w) => w !== null && typeof w === 'object' && !Array.isArray(w);
11
+ function leergutCode(wert) {
12
+ if (!istObjekt(wert) || typeof wert['gtin'] !== 'string' || typeof wert['depositTypeId'] !== 'string')
13
+ return null;
14
+ return { gtin: wert['gtin'], depositTypeId: wert['depositTypeId'] };
15
+ }
16
+ /**
17
+ * Lernt einen Leergut-Code (`learnMyLeergutCode`, nur Kassenweg, Recht `depositReturn`): `gtin` muss eine gueltige
18
+ * GTIN sein, `depositTypeId` eine aktive Pfandart. Die Form wird vor dem Senden geprueft; was der Server nicht
19
+ * annimmt, lehnt er mit `invalid_deposit` oder `deposit_type_not_found` ab.
20
+ */
21
+ export async function learnReturnCode(transport, code) {
22
+ const name = 'learnMyLeergutCode';
23
+ const anfrage = (grund) => new KasseneckValidationError(name, grund, 'request');
24
+ if (!istObjekt(code))
25
+ throw anfrage('Anfrage muss ein Objekt sein');
26
+ const fremd = Object.keys(code).find((k) => k !== 'gtin' && k !== 'depositTypeId');
27
+ if (fremd != null)
28
+ throw anfrage(`unbekanntes Feld "${fremd}"`);
29
+ if (typeof code.gtin !== 'string' || !Gtin.isValid(code.gtin))
30
+ throw anfrage('gtin ist keine gueltige GTIN');
31
+ if (typeof code.depositTypeId !== 'string' || code.depositTypeId === '')
32
+ throw anfrage('depositTypeId fehlt');
33
+ const antwort = await transport(name, { gtin: code.gtin, depositTypeId: code.depositTypeId });
34
+ return leergutCode(antwort) ?? { gtin: code.gtin, depositTypeId: code.depositTypeId };
35
+ }
36
+ /** Liest die gelernten Leergut-Codes (`listMyLeergutCodes`, nur Kassenweg): nur aktive Pfandarten, nach GTIN sortiert. */
37
+ export async function listReturnCodes(transport) {
38
+ const antwort = await transport('listMyLeergutCodes', {});
39
+ const liste = istObjekt(antwort) && Array.isArray(antwort['codes']) ? antwort['codes'] : [];
40
+ return liste.map(leergutCode).filter((c) => c != null);
41
+ }
42
+ /**
43
+ * Ordnet einen Scan im Leergut-Blatt einer Pfandart zu. Reihenfolge: (1) gelernter Code -> 1 Stueck; (2) `gtin` eines
44
+ * Pfandeintrags an Artikel oder Gruppe -> 1 Stueck dieser Pfandart; (3) Artikel-EAN, -Nummer oder -Code mit wirksamer
45
+ * Pfandliste -> jeder Eintrag mit seiner `quantity` (Kiste: 1 Kiste + 20 Flaschen); sonst `unknown`. Es zaehlen nur
46
+ * aktive Pfandarten: ein Treffer auf eine stillgelegte oder unbekannte Pfandart ist `unknown` (die Suche endet am
47
+ * ersten Treffer, sie faellt nicht auf die naechste Stufe zurueck). Der Code wird getrimmt, ein leerer ist `unknown`.
48
+ */
49
+ export function matchReturnCode(code, input) {
50
+ const unbekannt = { unknown: true };
51
+ const gesucht = typeof code === 'string' ? code.trim() : '';
52
+ if (gesucht === '')
53
+ return unbekannt;
54
+ const aktiv = new Set(input.depositTypes.filter((t) => t.active).map((t) => t.id));
55
+ const eins = (depositTypeId) => (aktiv.has(depositTypeId) ? { entries: [{ depositTypeId, quantity: 1 }] } : unbekannt);
56
+ const gelernt = input.learned.find((l) => l.gtin === gesucht);
57
+ if (gelernt != null)
58
+ return eins(gelernt.depositTypeId);
59
+ const gruppeVon = (a) => input.groups.find((g) => g.id === a.groupId) ?? null;
60
+ for (const a of input.articles) {
61
+ const hit = (depositsFor(a, gruppeVon(a))).find((d) => d.gtin === gesucht);
62
+ if (hit != null)
63
+ return eins(hit.depositTypeId);
64
+ }
65
+ for (const g of input.groups) {
66
+ const hit = (g.deposits ?? []).find((d) => d.gtin === gesucht);
67
+ if (hit != null)
68
+ return eins(hit.depositTypeId);
69
+ }
70
+ const artikel = input.articles.find((a) => a.ean === gesucht || a.number === gesucht || a.internalCode === gesucht);
71
+ if (artikel == null)
72
+ return unbekannt;
73
+ const liste = depositsFor(artikel, gruppeVon(artikel));
74
+ if (liste.length === 0 || !liste.every((d) => aktiv.has(d.depositTypeId)))
75
+ return unbekannt;
76
+ return { entries: liste.map((d) => ({ depositTypeId: d.depositTypeId, quantity: d.quantity })) };
77
+ }
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Pfand & Leergut an der Kasse: Pfandarten und Einstellungen aus
3
+ * `getKasseSettings` (Block `deposit`), Pfandliste am Artikel und an der
4
+ * Gruppe (`deposits`) und die Pfand-Angaben des Kassenobjekts aus
5
+ * `listRegisterUsersForDevice`. Alles nur Lesen und Schreiben der Formen; die
6
+ * Rechnung (Betrag, Staffel nach Tag) kommt in einem eigenen Modul.
7
+ */
8
+ import type { ReceiptItem } from '../models/receipt-item.js';
9
+ /** Art einer Pfandart: Einweg oder Mehrweg. */
10
+ export declare const DEPOSIT_KINDS: readonly ["single_use", "reusable"];
11
+ export type DepositKind = typeof DEPOSIT_KINDS[number];
12
+ /** Gebindetyp einer Pfandart (frei, nur zur Anzeige). */
13
+ export declare const DEPOSIT_TYPES: readonly ["bottle", "crate", "keg", "cup", "glass", "other"];
14
+ export type DepositContainerType = typeof DEPOSIT_TYPES[number];
15
+ /** Wer nimmt Leergut an der Kasse zurueck: diese Kasse, eine gemeinsame Stelle oder niemand. */
16
+ export declare const DEPOSIT_RETURN_MODES: readonly ["here", "shared", "none"];
17
+ export type DepositReturnMode = typeof DEPOSIT_RETURN_MODES[number];
18
+ /** Vorbelegung, ob Getraenke vor Ort getrunken oder mitgenommen werden. */
19
+ export declare const DEPOSIT_ON_PREMISES_DEFAULTS: readonly ["on_premises", "takeaway", "ask"];
20
+ export type DepositOnPremisesDefault = typeof DEPOSIT_ON_PREMISES_DEFAULTS[number];
21
+ /** Ein Pfandbetrag ab einem Tag (`from`, Wiener Tag `YYYY-MM-DD`), in Cent je Stueck. */
22
+ export interface DepositAmount {
23
+ from: string;
24
+ cents: number;
25
+ }
26
+ /** Eine Pfandart des Betriebs. */
27
+ export interface DepositType {
28
+ id: string;
29
+ kind: DepositKind;
30
+ name: string;
31
+ type: DepositContainerType | null;
32
+ /** Betraege nach Gueltigkeit, wie vom Server geliefert (aufsteigend nach `from`). */
33
+ amounts: DepositAmount[];
34
+ /** Steuersatz in Prozent, mit dem Mehrweg-Leergut zurueckgenommen wird (Rueckgabesatz), oder null (noch nie ausgegeben). */
35
+ returnRate: number | null;
36
+ /** Die Pfandart steht an mindestens einem Artikel oder Beleg. */
37
+ used: boolean;
38
+ active: boolean;
39
+ }
40
+ /** Block `deposit` aus `getKasseSettings`; fehlt bei ausgeschaltetem Pfand. */
41
+ export interface DepositSettings {
42
+ singleUse: boolean;
43
+ reusable: boolean;
44
+ depositTypes: DepositType[];
45
+ }
46
+ /** Eine Pfandangabe an Artikel oder Gruppe (`deposits[]`). */
47
+ export interface DepositEntry {
48
+ depositTypeId: string;
49
+ quantity: number;
50
+ gtin?: string;
51
+ ownFilling?: boolean;
52
+ }
53
+ /** Gemeinsame Rueckgabestelle (Kassen-Pfandangaben). */
54
+ export interface DepositSharedReturnPoint {
55
+ name: string;
56
+ address: string;
57
+ }
58
+ /** Pfand-Angaben des Kassenobjekts aus `listRegisterUsersForDevice`; fehlt bei ausgeschaltetem Pfand. */
59
+ export interface CashRegisterDeposit {
60
+ returns: DepositReturnMode;
61
+ onPremisesDefault: DepositOnPremisesDefault;
62
+ usualQuantity: number;
63
+ sharedReturnPoint: DepositSharedReturnPoint | null;
64
+ }
65
+ /**
66
+ * Den Block `deposit` einer Antwort lesen. Kein Objekt (Pfand aus, alter
67
+ * Server) -> `undefined`: das Feld fehlt dann am Modell, es wird nichts erfunden.
68
+ * Eine Pfandart in unbekannter Form faellt weg.
69
+ */
70
+ export declare function posDepositSettingsFromWire(value: unknown): DepositSettings | undefined;
71
+ /** Die Pfandliste eines Artikels oder einer Gruppe; keine Liste -> `null`, unlesbare Eintraege fallen weg. */
72
+ export declare function depositEntriesFromWire(value: unknown): DepositEntry[] | null;
73
+ /** Die Pfand-Angaben eines Kassenobjekts; fehlt der Block oder ist er unbrauchbar -> `undefined`. */
74
+ export declare function cashRegisterDepositFromWire(value: unknown): CashRegisterDeposit | undefined;
75
+ /** Pfandangaben, wirksam fuer einen Artikel: Artikel vor Gruppe, `[]` = kein Pfand, `null`/fehlend = wie die Gruppe. */
76
+ export declare function depositsFor(article: {
77
+ deposits?: DepositEntry[] | null;
78
+ externalVoucher?: unknown;
79
+ } | null | undefined, group: {
80
+ deposits?: DepositEntry[] | null;
81
+ } | null | undefined): DepositEntry[];
82
+ /** Pfandbetrag in Cent am Wiener Tag `day` (`YYYY-MM-DD`): letzter Eintrag mit `from <= day`, sonst `null`. */
83
+ export declare function depositAmountOn(type: Pick<DepositType, 'amounts'>, day: string): number | null;
84
+ /** Wiener Kalendertag `YYYY-MM-DD` zum Zeitpunkt `nowMs` (nie der UTC-Tag). */
85
+ export declare function viennaDay(nowMs: number): string;
86
+ /** Eine Position des Korbs in der Leitungsform (`amount`/`quantity`, `vat`/`vatRate`, `addOnOf` ...). */
87
+ export type DepositPreviewItem = object | null;
88
+ /** Eine Pfand- oder Leergutzeile in der Leitungsform, wie der Server sie baut. */
89
+ export type DepositPreviewLine = Record<string, unknown>;
90
+ /** Fehlercodes der Vorschau (die /v3-Codes von `createReceipt`). */
91
+ export type DepositPreviewErrorCode = 'invalid_deposit' | 'deposit_set_by_server' | 'deposit_type_not_found' | 'invalid_deposit_quantity' | 'deposit_return_not_offered' | 'deposit_type_not_issued' | 'not_permitted';
92
+ /** Eingabe der Vorschau (ohne die Positionen): was der Server aus Konto, Kasse und Beleg wuesste. */
93
+ export interface DepositPreviewInput {
94
+ /** Pfand zu Artikeln selbst ableiten (`autoDeposits`). */
95
+ auto: boolean;
96
+ articles: ReadonlyMap<string, DepositPreviewArticle> | Readonly<Record<string, DepositPreviewArticle>>;
97
+ groups: ReadonlyMap<string, {
98
+ deposits?: DepositEntry[] | null;
99
+ }> | Readonly<Record<string, {
100
+ deposits?: DepositEntry[] | null;
101
+ }>>;
102
+ depositTypes: ReadonlyMap<string, DepositType> | Readonly<Record<string, DepositType>>;
103
+ /** Wiener Tag des Belegs. */
104
+ day: string;
105
+ /** Vor Ort getrunken: Einweg entfaellt. */
106
+ onPremises: boolean;
107
+ /** Pfand-Angaben der Kasse (nur `returns` zaehlt); ohne Angabe nimmt die Kasse kein Leergut zurueck. */
108
+ cashRegister?: Pick<CashRegisterDeposit, 'returns'> | null;
109
+ smallBusiness: boolean;
110
+ /** Der Benutzer darf Leergut zuruecknehmen (`depositReturnOf`). */
111
+ mayReturn: boolean;
112
+ }
113
+ /** Artikel, soweit die Vorschau ihn liest. */
114
+ export interface DepositPreviewArticle {
115
+ id?: string;
116
+ groupId?: string | null;
117
+ deposits?: DepositEntry[] | null;
118
+ externalVoucher?: unknown;
119
+ }
120
+ export type DepositPreviewResult<T> = {
121
+ ok: true;
122
+ items: T[];
123
+ } | {
124
+ ok: false;
125
+ code: DepositPreviewErrorCode;
126
+ };
127
+ /**
128
+ * Pfand- und Leergutzeilen eines Belegs wie der Server: leitet Pfand zu Artikeln ab (`auto`), prueft ausdrueckliche
129
+ * `deposit`-Zeilen und `deposit_return`-Zeilen und rechnet `addOnOf` und `depositFor` auf die neuen Positionen um.
130
+ * Ohne Pfand-/Leergutzeile und ohne Ableitung kommen die Positionen unveraendert zurueck. Die Fehlercodes sind die
131
+ * von `createReceipt`.
132
+ */
133
+ export declare function withDepositLines<T extends DepositPreviewItem>(items: readonly T[], input: DepositPreviewInput): DepositPreviewResult<T | DepositPreviewLine>;
134
+ /**
135
+ * Die Leergutzeile zu `quantity` Stueck einer Pfandart, wie `withDepositLines` sie fuer eine
136
+ * `deposit_return`-Eingabe baut (fuer die Korb-Vorschau). Wirft, wenn sich keine Zeile ergibt
137
+ * (unbekannte Pfandart, Menge ausserhalb 1 bis 1000, Mehrweg ohne Rueckgabesatz, ungueltige Codes);
138
+ * ob die Kasse Leergut annimmt, prueft der Aufrufer.
139
+ */
140
+ export declare function depositReturnLine(type: DepositType, quantity: number, options: {
141
+ day: string;
142
+ smallBusiness: boolean;
143
+ codes?: Record<string, number>;
144
+ }): ReceiptItem;