@kreiseck/kasseneck-api 1.26.0 → 1.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/cjs/models/receipt-errors.d.ts +1 -1
- package/dist/cjs/models/receipt-errors.js +2 -0
- package/dist/cjs/models/receipt-item.d.ts +10 -0
- package/dist/cjs/models/receipt-item.js +8 -0
- package/dist/cjs/pos/artikel.d.ts +17 -0
- package/dist/cjs/pos/artikel.js +7 -0
- package/dist/cjs/pos/index.d.ts +1 -0
- package/dist/cjs/pos/index.js +13 -3
- package/dist/cjs/pos/texte.d.ts +13 -0
- package/dist/cjs/pos/texte.js +5 -0
- package/dist/cjs/pos/zusaetze.d.ts +70 -0
- package/dist/cjs/pos/zusaetze.js +159 -0
- package/dist/cjs/receipt/grid.js +16 -3
- package/dist/cjs/receipt/layout.js +16 -9
- package/dist/cjs/stored/vokabular.d.ts +1 -1
- package/dist/cjs/stored/vokabular.js +7 -4
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/models/receipt-errors.d.ts +1 -1
- package/dist/esm/models/receipt-errors.js +2 -0
- package/dist/esm/models/receipt-item.d.ts +10 -0
- package/dist/esm/models/receipt-item.js +8 -0
- package/dist/esm/pos/artikel.d.ts +17 -0
- package/dist/esm/pos/artikel.js +6 -0
- package/dist/esm/pos/index.d.ts +1 -0
- package/dist/esm/pos/index.js +1 -0
- package/dist/esm/pos/texte.d.ts +13 -0
- package/dist/esm/pos/texte.js +5 -0
- package/dist/esm/pos/zusaetze.d.ts +70 -0
- package/dist/esm/pos/zusaetze.js +148 -0
- package/dist/esm/receipt/grid.js +16 -3
- package/dist/esm/receipt/layout.js +16 -9
- package/dist/esm/stored/vokabular.d.ts +1 -1
- package/dist/esm/stored/vokabular.js +7 -4
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/fixtures/add-on-cases.json +103 -0
- package/fixtures/expected/add-ons.grid32.txt +31 -0
- package/fixtures/expected/add-ons.grid48.txt +27 -0
- package/fixtures/expected/add-ons.lines.json +270 -0
- package/fixtures/expected/add-ons.sheet32.json +212 -0
- package/fixtures/expected/add-ons.sheet48.json +188 -0
- package/fixtures/hobex-hps-codes.json +1 -1
- package/fixtures/invoice-api.schema.json +1 -1
- package/fixtures/invoice-texts.json +1 -1
- package/fixtures/manifest.json +8 -0
- package/fixtures/pos-texts.json +16 -1
- package/fixtures/receipts/add-ons.json +70 -0
- package/fixtures/surface.json +10 -1
- package/fixtures/v3/antworten/belege.json +1 -1
- package/fixtures/v3/antworten/belegmail.json +1 -1
- package/fixtures/v3/antworten/berichte.json +1 -1
- package/fixtures/v3/antworten/kasse-belege.json +1 -1
- package/fixtures/v3/antworten/kasse.json +2 -2
- package/fixtures/v3/antworten/lager.json +1 -1
- package/fixtures/v3/antworten/rechnungen.json +1 -1
- package/fixtures/v3/antworten/storno.json +1 -1
- package/fixtures/v3/stored/belege.json +1 -1
- package/fixtures/v3/stored/kasse.json +2 -2
- package/fixtures/v3/stored/rechnungen.json +1 -1
- package/fixtures/v3/v3-vokabular.json +31 -12
- package/fixtures/v3/zahlbetrag-faelle.json +1 -1
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.KATALOGE = exports.ARTIKEL_FELDER = exports.SCHEMAS = exports.VOKABULAR_QUELLE = void 0;
|
|
6
6
|
/** Fingerabdruck des Vertrags-Exports, aus dem diese Datei stammt (`_quelle.sha256`). */
|
|
7
|
-
exports.VOKABULAR_QUELLE = "
|
|
7
|
+
exports.VOKABULAR_QUELLE = "842340e1f94c14fab01ffe96277d76dff4482b97df2e355daa583ff49c2db634";
|
|
8
8
|
/** Schema je Endpunkt (aussen -> innen) und Wertverweise auf die Kataloge. */
|
|
9
9
|
exports.SCHEMAS = {
|
|
10
10
|
"getReceipt": {
|
|
@@ -22,7 +22,8 @@ exports.SCHEMAS = {
|
|
|
22
22
|
{
|
|
23
23
|
"__": "items",
|
|
24
24
|
"receivedImmediately": "sofortErhalten",
|
|
25
|
-
"keptByEmployee": "direkt"
|
|
25
|
+
"keptByEmployee": "direkt",
|
|
26
|
+
"addOnOf": "zusatzZu"
|
|
26
27
|
}
|
|
27
28
|
],
|
|
28
29
|
"manualReceipt": {
|
|
@@ -390,7 +391,8 @@ exports.SCHEMAS = {
|
|
|
390
391
|
"hint": "hinweis",
|
|
391
392
|
"pattern": "muster",
|
|
392
393
|
"patternStrict": "musterStreng"
|
|
393
|
-
}
|
|
394
|
+
},
|
|
395
|
+
"addOns": "zusaetze"
|
|
394
396
|
}
|
|
395
397
|
]
|
|
396
398
|
},
|
|
@@ -435,7 +437,8 @@ exports.ARTIKEL_FELDER = [
|
|
|
435
437
|
"stockLocationIds",
|
|
436
438
|
"minStockByLocation",
|
|
437
439
|
"askPrice",
|
|
438
|
-
"reference"
|
|
440
|
+
"reference",
|
|
441
|
+
"addOns"
|
|
439
442
|
];
|
|
440
443
|
/** Wertkataloge innen (deutsch) -> aussen (englisch). */
|
|
441
444
|
exports.KATALOGE = {
|
package/dist/cjs/version.d.ts
CHANGED
package/dist/cjs/version.js
CHANGED
|
@@ -18,7 +18,7 @@ import { KasseneckApiError } from '../client/errors.js';
|
|
|
18
18
|
* ...) stehen in [PAYMENT_ERROR_CODES]. Ein Code ausserhalb bleibt ueber
|
|
19
19
|
* `KasseneckApiError.code` lesbar.
|
|
20
20
|
*/
|
|
21
|
-
export declare const RECEIPT_ERROR_CODES: readonly ["cancellation_reference_unavailable", "cashregister_closed", "cashregister_decommissioned", "final_receipt_expired", "final_receipt_not_allowed", "idempotency_conflict", "module_inactive", "not_permitted", "receipt_limit_exceeded", "receipt_not_found", "receipt_outcome_unknown", "receipt_type_invalid", "server_error", "signature_incomplete", "signature_missing", "signing_failed", "small_business_vat_not_allowed", "tip_invalid", "tip_not_allowed", "tip_recipient_unknown", "validation", "voucher_balance_changed", "account_not_found", "action_confirmation_required", "admin_required", "api_not_approved", "app_check_invalid", "app_check_missing", "cashregister_not_assigned", "cashregister_not_found", "cashregister_token_invalid", "cashregister_token_missing", "dialect_mismatch", "internal_translation_error", "live_not_enabled", "method_not_allowed", "mfa_required", "not_found", "password_change_required", "register_user_no_business", "register_user_not_allowed", "register_user_not_found", "response_translation_failed", "second_factor_required", "session_expired", "session_other_cashregister", "unauthorized", "user_disabled", "user_verification_failed", "route_missing", "response_unreadable"];
|
|
21
|
+
export declare const RECEIPT_ERROR_CODES: readonly ["cancellation_reference_unavailable", "cashregister_closed", "cashregister_decommissioned", "final_receipt_expired", "final_receipt_not_allowed", "idempotency_conflict", "invalid_add_on_reference", "module_inactive", "not_permitted", "receipt_limit_exceeded", "receipt_not_found", "receipt_outcome_unknown", "receipt_type_invalid", "server_error", "signature_incomplete", "signature_missing", "signing_failed", "small_business_vat_not_allowed", "tip_invalid", "tip_not_allowed", "tip_recipient_unknown", "validation", "voucher_balance_changed", "account_not_found", "action_confirmation_required", "admin_required", "api_not_approved", "app_check_invalid", "app_check_missing", "cashregister_not_assigned", "cashregister_not_found", "cashregister_token_invalid", "cashregister_token_missing", "dialect_mismatch", "internal_translation_error", "live_not_enabled", "method_not_allowed", "mfa_required", "not_found", "password_change_required", "register_user_no_business", "register_user_not_allowed", "register_user_not_found", "response_translation_failed", "second_factor_required", "session_expired", "session_other_cashregister", "unauthorized", "user_disabled", "user_verification_failed", "route_missing", "response_unreadable"];
|
|
22
22
|
export type ReceiptErrorCode = (typeof RECEIPT_ERROR_CODES)[number];
|
|
23
23
|
export declare function isReceiptErrorCode(value: unknown): value is ReceiptErrorCode;
|
|
24
24
|
/** Der Code eines geworfenen Fehlers, wenn er in [RECEIPT_ERROR_CODES] steht; sonst `undefined`. */
|
|
@@ -27,6 +27,8 @@ export const RECEIPT_ERROR_CODES = Object.freeze([
|
|
|
27
27
|
// Seit 1.15.0 (Vertrag): derselbe idempotencyKey mit anderem Inhalt, nichts geschrieben. Seit 1.22.0 sendet
|
|
28
28
|
// dieses Paket den Schluessel, wenn der Aufrufer ihn angibt (`idempotencyKey` an sellReceipt/createReceipt).
|
|
29
29
|
'idempotency_conflict',
|
|
30
|
+
// Seit 1.27.0 (Zusatz-Kacheln): addOnOf zeigt nicht nach vorne auf eine Warenposition, die selbst kein Zusatz ist.
|
|
31
|
+
'invalid_add_on_reference',
|
|
30
32
|
'module_inactive',
|
|
31
33
|
'not_permitted',
|
|
32
34
|
'receipt_limit_exceeded',
|
|
@@ -61,6 +61,12 @@ export interface ReceiptItem {
|
|
|
61
61
|
originalIndex?: number;
|
|
62
62
|
/** Nur an Storno-Zeilen mit `articleId`: wohin die Ware ging (Lager-Kern Stufe 2). */
|
|
63
63
|
returnDisposition?: ReturnDisposition;
|
|
64
|
+
/**
|
|
65
|
+
* Zusatz-Kacheln (1.27.0): Index der Hauptposition im selben Beleg; nur an
|
|
66
|
+
* Zusatzpositionen. Der Server prueft: ganze Zahl, zeigt nach vorne auf eine
|
|
67
|
+
* Warenposition, die selbst kein Zusatz ist (`invalid_add_on_reference`).
|
|
68
|
+
*/
|
|
69
|
+
addOnOf?: number;
|
|
64
70
|
}
|
|
65
71
|
/** Empfaenger einer Trinkgeld-Position (Kassen-Benutzer, Snapshot des Namens). */
|
|
66
72
|
export interface TipRecipient {
|
|
@@ -99,6 +105,8 @@ export interface ReceiptItemPayload {
|
|
|
99
105
|
keptByEmployee?: boolean;
|
|
100
106
|
/** Artikel-Verweis, siehe [ReceiptItem.articleId]. */
|
|
101
107
|
articleId?: string;
|
|
108
|
+
/** Hauptposition eines Zusatzes, siehe [ReceiptItem.addOnOf]. */
|
|
109
|
+
addOnOf?: number;
|
|
102
110
|
}
|
|
103
111
|
/**
|
|
104
112
|
* Nutzlast-Form, die dieses Paket **liest** — v2 und v1 nebeneinander, alles
|
|
@@ -144,6 +152,8 @@ export interface ReceiptItemPayloadRead {
|
|
|
144
152
|
originalIndex?: number | null;
|
|
145
153
|
/** Storno-Zeile mit `articleId`: Rueckgabe-Wahl, siehe [ReceiptItem.returnDisposition]. */
|
|
146
154
|
returnDisposition?: string | null;
|
|
155
|
+
/** Hauptposition eines Zusatzes, siehe [ReceiptItem.addOnOf]. */
|
|
156
|
+
addOnOf?: number | null;
|
|
147
157
|
}
|
|
148
158
|
export declare function toReceiptItemPayload(item: ReceiptItem): ReceiptItemPayload;
|
|
149
159
|
/**
|
|
@@ -57,6 +57,9 @@ export function toReceiptItemPayload(item) {
|
|
|
57
57
|
// Artikel-Verweis reist mit (Erloesgruppen im Bericht); leere Werte nicht.
|
|
58
58
|
if (item.articleId != null && item.articleId !== '')
|
|
59
59
|
nutzlast.articleId = item.articleId;
|
|
60
|
+
// Zusatz-Kacheln: Verweis auf die Hauptposition nur, wenn gesetzt.
|
|
61
|
+
if (istIndex(item.addOnOf))
|
|
62
|
+
nutzlast.addOnOf = item.addOnOf;
|
|
60
63
|
return nutzlast;
|
|
61
64
|
}
|
|
62
65
|
/**
|
|
@@ -107,8 +110,13 @@ export function fromReceiptItemPayload(payload) {
|
|
|
107
110
|
// unbekannter Wert faellt weg wie am Rand des Servers).
|
|
108
111
|
...(Number.isInteger(payload.originalIndex) && payload.originalIndex >= 0 ? { originalIndex: payload.originalIndex } : {}),
|
|
109
112
|
...(isReturnDisposition(payload.returnDisposition) ? { returnDisposition: payload.returnDisposition } : {}),
|
|
113
|
+
// Zusatz-Kacheln: Verweis auf die Hauptposition (nur eine ganze Zahl >= 0).
|
|
114
|
+
...(istIndex(payload.addOnOf) ? { addOnOf: payload.addOnOf } : {}),
|
|
110
115
|
};
|
|
111
116
|
}
|
|
117
|
+
function istIndex(wert) {
|
|
118
|
+
return Number.isInteger(wert) && wert >= 0;
|
|
119
|
+
}
|
|
112
120
|
/** Erster brauchbarer Zahlenwert der Reihe; `null`/`undefined`/NaN zaehlen nicht. */
|
|
113
121
|
function ersteZahl(...werte) {
|
|
114
122
|
for (const wert of werte) {
|
|
@@ -14,6 +14,13 @@ export interface ArticleGroup {
|
|
|
14
14
|
symbol: string | null;
|
|
15
15
|
sort: number;
|
|
16
16
|
vatRate: number | null;
|
|
17
|
+
/**
|
|
18
|
+
* Zusaetze der Gruppe (Zusatz-Kacheln, 1.27.0): Artikel-Kennungen in der
|
|
19
|
+
* Reihenfolge des Fensters; null = keine. Optional, damit bestehende Literale
|
|
20
|
+
* weiter uebersetzen; der Leser setzt das Feld immer. Wirksam wird die Liste
|
|
21
|
+
* erst ueber [addOnsFor].
|
|
22
|
+
*/
|
|
23
|
+
addOns?: string[] | null;
|
|
17
24
|
}
|
|
18
25
|
export interface ArticleGroupPayload {
|
|
19
26
|
id?: string | null;
|
|
@@ -22,7 +29,10 @@ export interface ArticleGroupPayload {
|
|
|
22
29
|
symbol?: string | null;
|
|
23
30
|
sort?: number | null;
|
|
24
31
|
vatRate?: number | null;
|
|
32
|
+
addOns?: unknown;
|
|
25
33
|
}
|
|
34
|
+
/** Zusatzliste am Draht: nur eine Liste von Texten zaehlt, sonst null. Paketintern. */
|
|
35
|
+
export declare function addOnListe(wert: unknown): string[] | null;
|
|
26
36
|
export declare function fromArticleGroupPayload(p: ArticleGroupPayload): ArticleGroup;
|
|
27
37
|
/**
|
|
28
38
|
* Mengenregel eines Artikels (Draht `quantityRule`): `piece` = ganze Stueck
|
|
@@ -105,6 +115,12 @@ export interface PosArticle {
|
|
|
105
115
|
askPrice?: boolean;
|
|
106
116
|
/** Kasse fragt beim Antippen eine Referenz ab; null = aus. Der Leser setzt es immer. */
|
|
107
117
|
reference?: PosReference | null;
|
|
118
|
+
/**
|
|
119
|
+
* Eigene Zusatzliste (Zusatz-Kacheln, 1.27.0): null = wie die Gruppe, [] =
|
|
120
|
+
* keine, sonst die Liste in der Reihenfolge des Fensters. Der Leser setzt es
|
|
121
|
+
* immer; wirksam wird es ueber [addOnsFor].
|
|
122
|
+
*/
|
|
123
|
+
addOns?: string[] | null;
|
|
108
124
|
}
|
|
109
125
|
/**
|
|
110
126
|
* Kann die Kachel gebucht werden? Mit festem Preis immer, ohne Preis nur mit
|
|
@@ -144,6 +160,7 @@ export interface PosArticlePayload {
|
|
|
144
160
|
serviceVoucher?: boolean | null;
|
|
145
161
|
askPrice?: boolean | null;
|
|
146
162
|
reference?: unknown;
|
|
163
|
+
addOns?: unknown;
|
|
147
164
|
}
|
|
148
165
|
export declare function fromPosArticlePayload(p: PosArticlePayload): PosArticle;
|
|
149
166
|
/**
|
package/dist/esm/pos/artikel.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { KasseneckValidationError } from '../client/errors.js';
|
|
2
2
|
import { fromReferencePayload } from './kachel-referenz.js';
|
|
3
|
+
/** Zusatzliste am Draht: nur eine Liste von Texten zaehlt, sonst null. Paketintern. */
|
|
4
|
+
export function addOnListe(wert) {
|
|
5
|
+
return Array.isArray(wert) ? wert.filter((s) => typeof s === 'string' && s !== '') : null;
|
|
6
|
+
}
|
|
3
7
|
export function fromArticleGroupPayload(p) {
|
|
4
8
|
return {
|
|
5
9
|
id: p.id ?? '',
|
|
@@ -8,6 +12,7 @@ export function fromArticleGroupPayload(p) {
|
|
|
8
12
|
symbol: p.symbol ?? null,
|
|
9
13
|
sort: typeof p.sort === 'number' ? p.sort : 0,
|
|
10
14
|
vatRate: typeof p.vatRate === 'number' ? p.vatRate : null,
|
|
15
|
+
addOns: addOnListe(p.addOns),
|
|
11
16
|
};
|
|
12
17
|
}
|
|
13
18
|
/**
|
|
@@ -86,6 +91,7 @@ export function fromPosArticlePayload(p) {
|
|
|
86
91
|
serviceVoucher: p.serviceVoucher === true,
|
|
87
92
|
askPrice: p.askPrice === true,
|
|
88
93
|
reference: fromReferencePayload(p.reference),
|
|
94
|
+
addOns: addOnListe(p.addOns),
|
|
89
95
|
};
|
|
90
96
|
}
|
|
91
97
|
/**
|
package/dist/esm/pos/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
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, posTipKeptByDefault, POS_BUSINESS_VALUES, POS_DEVICE_VALUES, mergePosSettings, sanitizePosSettings, unknownPosSettingValues, posSettingsChanges, type PosOpen, POS_SHORTCUT_SHARED_PAIRS, posShortcutConflict, THEME, FONT_SIZE, WATERMARK, QUANTITY, TIP_MODE, 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
|
+
export { ADD_ONS_MAX, ADD_ON_BLOCK_REASONS, type AddOnBlockReason, isSelectableAddOn, addOnsFor, addOnReferencesValid, addOnsOfItem, addOnRemap, addOnDisplayOrder, orderAddOnLines, } from './zusaetze.js';
|
|
12
13
|
export { getPosSettings, setMyPosSettings, setMyRegisterDeviceSettings, setMyPosLogo, posSettingsFromWire, type SetMyPosLogoOptions, } from './client.js';
|
|
13
14
|
export { POS_ERROR_CODES, type PosErrorCode, isPosErrorCode, posErrorCode, isPosError, type PosFieldError, posFieldErrors, } from './errors.js';
|
|
14
15
|
export { distributeDiscount } from '../receipt/discount.js';
|
package/dist/esm/pos/index.js
CHANGED
|
@@ -11,6 +11,7 @@ export { POS_SHORTCUT_ACTIONS, POS_SHORTCUT_DEFAULTS, POS_BUSINESS_DEFAULTS, POS
|
|
|
11
11
|
THEME, FONT_SIZE, WATERMARK, QUANTITY, TIP_MODE, 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
|
+
export { ADD_ONS_MAX, ADD_ON_BLOCK_REASONS, isSelectableAddOn, addOnsFor, addOnReferencesValid, addOnsOfItem, addOnRemap, addOnDisplayOrder, orderAddOnLines, } from './zusaetze.js';
|
|
14
15
|
export { getPosSettings, setMyPosSettings, setMyRegisterDeviceSettings, setMyPosLogo, posSettingsFromWire, } from './client.js';
|
|
15
16
|
export { POS_ERROR_CODES, isPosErrorCode, posErrorCode, isPosError, posFieldErrors, } from './errors.js';
|
|
16
17
|
export { distributeDiscount } from '../receipt/discount.js';
|
package/dist/esm/pos/texte.d.ts
CHANGED
|
@@ -2084,6 +2084,19 @@ declare const BESCHRIFTUNGEN_ROH: {
|
|
|
2084
2084
|
readonly 'tile_prompt.apply_anyway': {
|
|
2085
2085
|
readonly text: "Trotzdem übernehmen";
|
|
2086
2086
|
};
|
|
2087
|
+
readonly 'addons.title': {
|
|
2088
|
+
readonly text: "Zusätze zu {name}";
|
|
2089
|
+
readonly placeholders: readonly ["name"];
|
|
2090
|
+
};
|
|
2091
|
+
readonly 'addons.none': {
|
|
2092
|
+
readonly text: "Ohne Zusatz";
|
|
2093
|
+
};
|
|
2094
|
+
readonly 'addons.done': {
|
|
2095
|
+
readonly text: "Fertig";
|
|
2096
|
+
};
|
|
2097
|
+
readonly 'addons.open': {
|
|
2098
|
+
readonly text: "Zusätze";
|
|
2099
|
+
};
|
|
2087
2100
|
readonly 'voucher.tab': {
|
|
2088
2101
|
readonly text: "Gutscheine";
|
|
2089
2102
|
};
|
package/dist/esm/pos/texte.js
CHANGED
|
@@ -1047,6 +1047,11 @@ const BESCHRIFTUNGEN_ROH = {
|
|
|
1047
1047
|
'tile_prompt.quantity': { text: 'Menge' },
|
|
1048
1048
|
'tile_prompt.apply': { text: 'Übernehmen' },
|
|
1049
1049
|
'tile_prompt.apply_anyway': { text: 'Trotzdem übernehmen' },
|
|
1050
|
+
// Zusatz-Kacheln (1.27.0): Fenster nach dem Antippen einer Hauptleistung, Knopf an der Korbzeile.
|
|
1051
|
+
'addons.title': { text: 'Zusätze zu {name}', placeholders: ['name'] },
|
|
1052
|
+
'addons.none': { text: 'Ohne Zusatz' },
|
|
1053
|
+
'addons.done': { text: 'Fertig' },
|
|
1054
|
+
'addons.open': { text: 'Zusätze' },
|
|
1050
1055
|
// Gutschein-Sorten als Kacheln im Reiter „Gutscheine“ (Stufe 4b, 1.17.0): Kachel je Sorte mit Betrag
|
|
1051
1056
|
// oder „Betrag eingeben“, darunter klein die Art; dazu die feste Kachel „Leistungsgutschein“.
|
|
1052
1057
|
'voucher.tab': { text: 'Gutscheine' },
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { ArticleGroup, PosArticle } from './artikel.js';
|
|
2
|
+
/**
|
|
3
|
+
* Zusatz-Kacheln (1.27.0): Tippt man eine Hauptleistung an, oeffnet die Kasse
|
|
4
|
+
* ein Fenster mit ihren Zusaetzen. Die Liste steht an der Gruppe, je Artikel
|
|
5
|
+
* abweichend (`addOns`: null = wie die Gruppe, [] = keine, sonst eigene Liste).
|
|
6
|
+
* Jeder Zusatz wird eine eigene Belegposition mit `addOnOf` = Index der
|
|
7
|
+
* Hauptposition. Die Regeln rechnen Backend (`gemeinsam/zusatz-core.js`), npm
|
|
8
|
+
* und Dart gleich; der Vertrag sind die Pruefaelle `fixtures/add-on-cases.json`.
|
|
9
|
+
*/
|
|
10
|
+
/** Hoechstens so viele Zusaetze je Liste (der Server weist mehr ab). */
|
|
11
|
+
export declare const ADD_ONS_MAX = 30;
|
|
12
|
+
/** Warum ein Artikel kein Zusatz sein kann (Panel zeigt den Grund an). */
|
|
13
|
+
export declare const ADD_ON_BLOCK_REASONS: readonly ["inactive", "own_list", "asks_price", "reference", "asks_quantity", "no_price", "service_voucher"];
|
|
14
|
+
export type AddOnBlockReason = typeof ADD_ON_BLOCK_REASONS[number];
|
|
15
|
+
type ZusatzArtikel = Pick<PosArticle, 'id' | 'active' | 'unitPriceCents'> & Partial<Pick<PosArticle, 'addOns' | 'askPrice' | 'reference' | 'askQuantity' | 'serviceVoucher'>>;
|
|
16
|
+
type ArtikelNachId<T> = ReadonlyMap<string, T> | Readonly<Record<string, T>>;
|
|
17
|
+
/**
|
|
18
|
+
* Taugt der Artikel als Zusatz? `null` = ja. Im Fenster wird ohne Abfrage
|
|
19
|
+
* gebucht: Betrag, Referenz oder Menge fragen geht nicht, ein Preis muss
|
|
20
|
+
* feststehen (0 erlaubt), ein Leistungsgutschein liefe am Gutschein-Weg vorbei,
|
|
21
|
+
* und ein Artikel mit eigener Liste oeffnete selbst ein Fenster (eine Ebene).
|
|
22
|
+
*/
|
|
23
|
+
export declare function isSelectableAddOn(a: ZusatzArtikel): AddOnBlockReason | null;
|
|
24
|
+
/**
|
|
25
|
+
* Wirksame Zusatzliste eines Artikels: eigene Liste (auch leer) vor der der
|
|
26
|
+
* Gruppe; still heraus fallen der Artikel selbst, Unbekanntes, Dubletten und
|
|
27
|
+
* alles, was nicht als Zusatz taugt. Leer = kein Fenster.
|
|
28
|
+
*/
|
|
29
|
+
export declare function addOnsFor<T extends ZusatzArtikel>(article: ZusatzArtikel, group: Pick<ArticleGroup, 'addOns'> | null | undefined, articleById: ArtikelNachId<T>): string[];
|
|
30
|
+
type MitVerweis = {
|
|
31
|
+
addOnOf?: number | null;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Halten die Verweise den Server-Regeln stand? Ganze Zahl, zeigt nach vorne
|
|
35
|
+
* auf eine Warenposition, die selbst kein Zusatz ist (sonst antwortet
|
|
36
|
+
* createReceipt mit `invalid_add_on_reference`).
|
|
37
|
+
*/
|
|
38
|
+
export declare function addOnReferencesValid(items: readonly (MitVerweis & {
|
|
39
|
+
kind?: string | null;
|
|
40
|
+
})[]): boolean;
|
|
41
|
+
/** Indizes der Zusaetze einer Hauptposition (Storno: mit vormerken, abwaehlbar). */
|
|
42
|
+
export declare function addOnsOfItem(items: readonly MitVerweis[], index: number): number[];
|
|
43
|
+
/**
|
|
44
|
+
* Storno: Verweis je Storno-Position (in der Reihenfolge der stornierten
|
|
45
|
+
* Positionen, Menge > 0). Ein Zusatz behaelt ihn nur, wenn seine Hauptposition
|
|
46
|
+
* mit storniert wird, umgerechnet auf den neuen Index; sonst `null`.
|
|
47
|
+
*/
|
|
48
|
+
export declare function addOnRemap(items: readonly MitVerweis[], quantities: readonly number[]): (number | null)[];
|
|
49
|
+
/** Ist Position `i` ein gueltiger Zusatz (Verweis nach vorne auf eine Hauptposition)? Paketintern (Layout). */
|
|
50
|
+
export declare function istGueltigerZusatz(items: readonly MitVerweis[], i: number): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Bon-Reihenfolge: jede Hauptposition, direkt gefolgt von ihren Zusaetzen
|
|
53
|
+
* (stabil). Positionen mit ungueltigem Verweis bleiben an ihrem Platz.
|
|
54
|
+
*/
|
|
55
|
+
export declare function addOnDisplayOrder(items: readonly MitVerweis[]): number[];
|
|
56
|
+
/**
|
|
57
|
+
* Warenkorb -> Belegpositionen: Zeilen tragen die Zeilen-Id ihrer Hauptzeile
|
|
58
|
+
* (`addOnOf`). Sortiert jeden Zusatz hinter seine Hauptzeile (stabil) und
|
|
59
|
+
* rechnet den Verweis in den Index um. Fehlt die Hauptzeile (geloescht oder
|
|
60
|
+
* vorher herausgefiltert, etwa ein Gutschein-Verkauf), bleibt die Zeile ohne
|
|
61
|
+
* Verweis an ihrem Platz.
|
|
62
|
+
*/
|
|
63
|
+
export declare function orderAddOnLines<T extends {
|
|
64
|
+
id: string;
|
|
65
|
+
addOnOf?: string | null;
|
|
66
|
+
}>(lines: readonly T[]): {
|
|
67
|
+
line: T;
|
|
68
|
+
addOnOf: number | null;
|
|
69
|
+
}[];
|
|
70
|
+
export {};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zusatz-Kacheln (1.27.0): Tippt man eine Hauptleistung an, oeffnet die Kasse
|
|
3
|
+
* ein Fenster mit ihren Zusaetzen. Die Liste steht an der Gruppe, je Artikel
|
|
4
|
+
* abweichend (`addOns`: null = wie die Gruppe, [] = keine, sonst eigene Liste).
|
|
5
|
+
* Jeder Zusatz wird eine eigene Belegposition mit `addOnOf` = Index der
|
|
6
|
+
* Hauptposition. Die Regeln rechnen Backend (`gemeinsam/zusatz-core.js`), npm
|
|
7
|
+
* und Dart gleich; der Vertrag sind die Pruefaelle `fixtures/add-on-cases.json`.
|
|
8
|
+
*/
|
|
9
|
+
/** Hoechstens so viele Zusaetze je Liste (der Server weist mehr ab). */
|
|
10
|
+
export const ADD_ONS_MAX = 30;
|
|
11
|
+
/** Warum ein Artikel kein Zusatz sein kann (Panel zeigt den Grund an). */
|
|
12
|
+
export const ADD_ON_BLOCK_REASONS = ['inactive', 'own_list', 'asks_price', 'reference', 'asks_quantity', 'no_price', 'service_voucher'];
|
|
13
|
+
const eigeneListe = (a) => Array.isArray(a.addOns) && a.addOns.length > 0;
|
|
14
|
+
/**
|
|
15
|
+
* Taugt der Artikel als Zusatz? `null` = ja. Im Fenster wird ohne Abfrage
|
|
16
|
+
* gebucht: Betrag, Referenz oder Menge fragen geht nicht, ein Preis muss
|
|
17
|
+
* feststehen (0 erlaubt), ein Leistungsgutschein liefe am Gutschein-Weg vorbei,
|
|
18
|
+
* und ein Artikel mit eigener Liste oeffnete selbst ein Fenster (eine Ebene).
|
|
19
|
+
*/
|
|
20
|
+
export function isSelectableAddOn(a) {
|
|
21
|
+
if (a.active === false)
|
|
22
|
+
return 'inactive';
|
|
23
|
+
if (eigeneListe(a))
|
|
24
|
+
return 'own_list';
|
|
25
|
+
if (a.askPrice === true)
|
|
26
|
+
return 'asks_price';
|
|
27
|
+
if (a.reference != null)
|
|
28
|
+
return 'reference';
|
|
29
|
+
if (a.askQuantity === true)
|
|
30
|
+
return 'asks_quantity';
|
|
31
|
+
if (typeof a.unitPriceCents !== 'number' || !Number.isInteger(a.unitPriceCents) || a.unitPriceCents < 0)
|
|
32
|
+
return 'no_price';
|
|
33
|
+
if (a.serviceVoucher === true)
|
|
34
|
+
return 'service_voucher';
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
function nachId(karte, id) {
|
|
38
|
+
if (karte instanceof Map)
|
|
39
|
+
return karte.get(id);
|
|
40
|
+
return Object.prototype.hasOwnProperty.call(karte, id) ? karte[id] : undefined;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Wirksame Zusatzliste eines Artikels: eigene Liste (auch leer) vor der der
|
|
44
|
+
* Gruppe; still heraus fallen der Artikel selbst, Unbekanntes, Dubletten und
|
|
45
|
+
* alles, was nicht als Zusatz taugt. Leer = kein Fenster.
|
|
46
|
+
*/
|
|
47
|
+
export function addOnsFor(article, group, articleById) {
|
|
48
|
+
const liste = Array.isArray(article.addOns) ? article.addOns : (group && Array.isArray(group.addOns) ? group.addOns : []);
|
|
49
|
+
const raus = [];
|
|
50
|
+
for (const id of liste) {
|
|
51
|
+
if (typeof id !== 'string' || id === article.id || raus.includes(id))
|
|
52
|
+
continue;
|
|
53
|
+
const z = nachId(articleById, id);
|
|
54
|
+
if (!z || isSelectableAddOn(z) !== null)
|
|
55
|
+
continue;
|
|
56
|
+
raus.push(id);
|
|
57
|
+
}
|
|
58
|
+
return raus;
|
|
59
|
+
}
|
|
60
|
+
const hatVerweis = (it) => it != null && typeof it === 'object' && Object.prototype.hasOwnProperty.call(it, 'addOnOf') && it.addOnOf !== undefined;
|
|
61
|
+
// Positionsarten, die nie Zusatz oder Hauptposition sind (Trinkgeld, Rabatt, Gutschein).
|
|
62
|
+
const OHNE_ZUSATZ = new Set(['tip', 'discount', 'voucher', 'voucher_float']);
|
|
63
|
+
/**
|
|
64
|
+
* Halten die Verweise den Server-Regeln stand? Ganze Zahl, zeigt nach vorne
|
|
65
|
+
* auf eine Warenposition, die selbst kein Zusatz ist (sonst antwortet
|
|
66
|
+
* createReceipt mit `invalid_add_on_reference`).
|
|
67
|
+
*/
|
|
68
|
+
export function addOnReferencesValid(items) {
|
|
69
|
+
return items.every((it, i) => {
|
|
70
|
+
if (!hatVerweis(it))
|
|
71
|
+
return true;
|
|
72
|
+
const z = it.addOnOf;
|
|
73
|
+
if (typeof z !== 'number' || !Number.isInteger(z) || z < 0 || z >= i)
|
|
74
|
+
return false;
|
|
75
|
+
const ziel = items[z];
|
|
76
|
+
if (OHNE_ZUSATZ.has(it.kind ?? '') || OHNE_ZUSATZ.has(ziel?.kind ?? ''))
|
|
77
|
+
return false;
|
|
78
|
+
return !hatVerweis(ziel);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/** Indizes der Zusaetze einer Hauptposition (Storno: mit vormerken, abwaehlbar). */
|
|
82
|
+
export function addOnsOfItem(items, index) {
|
|
83
|
+
const raus = [];
|
|
84
|
+
items.forEach((it, i) => { if (hatVerweis(it) && it.addOnOf === index)
|
|
85
|
+
raus.push(i); });
|
|
86
|
+
return raus;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Storno: Verweis je Storno-Position (in der Reihenfolge der stornierten
|
|
90
|
+
* Positionen, Menge > 0). Ein Zusatz behaelt ihn nur, wenn seine Hauptposition
|
|
91
|
+
* mit storniert wird, umgerechnet auf den neuen Index; sonst `null`.
|
|
92
|
+
*/
|
|
93
|
+
export function addOnRemap(items, quantities) {
|
|
94
|
+
const neu = new Map();
|
|
95
|
+
const raus = [];
|
|
96
|
+
items.forEach((it, i) => {
|
|
97
|
+
if (!((quantities[i] ?? 0) > 0))
|
|
98
|
+
return;
|
|
99
|
+
neu.set(i, raus.length);
|
|
100
|
+
raus.push(hatVerweis(it) && neu.has(it.addOnOf) ? neu.get(it.addOnOf) : null);
|
|
101
|
+
});
|
|
102
|
+
return raus;
|
|
103
|
+
}
|
|
104
|
+
/** Ist Position `i` ein gueltiger Zusatz (Verweis nach vorne auf eine Hauptposition)? Paketintern (Layout). */
|
|
105
|
+
export function istGueltigerZusatz(items, i) {
|
|
106
|
+
const it = items[i];
|
|
107
|
+
return it != null && hatVerweis(it) && Number.isInteger(it.addOnOf)
|
|
108
|
+
&& it.addOnOf >= 0 && it.addOnOf < i && !hatVerweis(items[it.addOnOf]);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Bon-Reihenfolge: jede Hauptposition, direkt gefolgt von ihren Zusaetzen
|
|
112
|
+
* (stabil). Positionen mit ungueltigem Verweis bleiben an ihrem Platz.
|
|
113
|
+
*/
|
|
114
|
+
export function addOnDisplayOrder(items) {
|
|
115
|
+
const gueltig = (_it, i) => istGueltigerZusatz(items, i);
|
|
116
|
+
const raus = [];
|
|
117
|
+
items.forEach((it, i) => {
|
|
118
|
+
if (gueltig(it, i))
|
|
119
|
+
return;
|
|
120
|
+
raus.push(i);
|
|
121
|
+
items.forEach((z, j) => { if (j > i && gueltig(z, j) && z.addOnOf === i)
|
|
122
|
+
raus.push(j); });
|
|
123
|
+
});
|
|
124
|
+
return raus;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Warenkorb -> Belegpositionen: Zeilen tragen die Zeilen-Id ihrer Hauptzeile
|
|
128
|
+
* (`addOnOf`). Sortiert jeden Zusatz hinter seine Hauptzeile (stabil) und
|
|
129
|
+
* rechnet den Verweis in den Index um. Fehlt die Hauptzeile (geloescht oder
|
|
130
|
+
* vorher herausgefiltert, etwa ein Gutschein-Verkauf), bleibt die Zeile ohne
|
|
131
|
+
* Verweis an ihrem Platz.
|
|
132
|
+
*/
|
|
133
|
+
export function orderAddOnLines(lines) {
|
|
134
|
+
const ids = new Set(lines.map((l) => l.id));
|
|
135
|
+
const istZusatz = (l) => typeof l.addOnOf === 'string' && l.addOnOf !== l.id && ids.has(l.addOnOf)
|
|
136
|
+
&& !lines.some((h) => h.id === l.addOnOf && typeof h.addOnOf === 'string' && ids.has(h.addOnOf));
|
|
137
|
+
const raus = [];
|
|
138
|
+
for (const l of lines) {
|
|
139
|
+
if (istZusatz(l))
|
|
140
|
+
continue;
|
|
141
|
+
const index = raus.length;
|
|
142
|
+
raus.push({ line: l, addOnOf: null });
|
|
143
|
+
for (const z of lines)
|
|
144
|
+
if (istZusatz(z) && z.addOnOf === l.id)
|
|
145
|
+
raus.push({ line: z, addOnOf: index });
|
|
146
|
+
}
|
|
147
|
+
return raus;
|
|
148
|
+
}
|
package/dist/esm/receipt/grid.js
CHANGED
|
@@ -99,7 +99,19 @@ export function renderReceiptGrid(layout, options = {}) {
|
|
|
99
99
|
const breiten = gridColumnWidths(z.columns.map((c) => c.width), zeichen);
|
|
100
100
|
// Inhalt jeder nicht-letzten Spalte um 1 Zeichen schmaler: garantierter Abstand.
|
|
101
101
|
const inhalt = breiten.map((b, i) => (i < breiten.length - 1 ? Math.max(1, b - 1) : b));
|
|
102
|
-
|
|
102
|
+
// Haengender Einzug wie bei Textzeilen: eine linksbuendige Spalte mit
|
|
103
|
+
// fuehrenden Leerzeichen bricht mit demselben Einzug um; ein Spiegelstrich
|
|
104
|
+
// „+ “ danach zaehlt mit (Zusatzzeile „ + 1 x …“: Fortsetzung unter der
|
|
105
|
+
// Menge). Ohne fuehrende Leerzeichen dieselben Zeichen wie bisher.
|
|
106
|
+
const einzugVon = (c, i) => {
|
|
107
|
+
const e = c.align === 'left' ? (/^ +(?:\+ )?/.exec(c.text)?.[0].length ?? 0) : 0;
|
|
108
|
+
return e > 0 && e < inhalt[i] && c.text.slice(e).trim() !== '' ? e : 0;
|
|
109
|
+
};
|
|
110
|
+
const einzuege = z.columns.map(einzugVon);
|
|
111
|
+
const umbrechen = (text, breite, e) => (e > 0
|
|
112
|
+
? wrapText(text.slice(e), breite - e).map((t, k) => (k === 0 ? text.slice(0, e) : ' '.repeat(e)) + t)
|
|
113
|
+
: wrapText(text, breite));
|
|
114
|
+
const teile = z.columns.map((c, i) => umbrechen(c.text, inhalt[i], einzuege[i]));
|
|
103
115
|
// Fliessregel: laeuft nach der ersten Zeile nur noch EINE Spalte weiter (die anderen sind
|
|
104
116
|
// fertig), bekommt ihr Rest die volle Breite -- auf 58 mm sonst 18-Zeichen-Schnipsel.
|
|
105
117
|
// Laufen mehrere weiter, bleibt das Raster (sonst verschoeben sich die Nachbarn).
|
|
@@ -118,8 +130,9 @@ export function renderReceiptGrid(layout, options = {}) {
|
|
|
118
130
|
const i = weiterlaufend[0];
|
|
119
131
|
// Rest aus dem Originaltext (nicht aus den schmal umbrochenen Stuecken), damit
|
|
120
132
|
// Bindestrich-/Hartbrueche der schmalen Spalte nicht als Leerzeichen zurueckbleiben.
|
|
121
|
-
const
|
|
122
|
-
|
|
133
|
+
const e = einzuege[i];
|
|
134
|
+
const rest = e > 0 ? restNach(z.columns[i].text.slice(e), teile[i][0].slice(e)) : restNach(z.columns[i].text, teile[i][0]);
|
|
135
|
+
for (const t of (e > 0 ? wrapText(rest, zeichen - e).map((x) => ' '.repeat(e) + x) : wrapText(rest, zeichen)))
|
|
123
136
|
lines.push({ text: ausrichten(t, zeichen, z.columns[i].align), kind: 'columns', bold: z.bold === true });
|
|
124
137
|
}
|
|
125
138
|
break;
|
|
@@ -2,6 +2,7 @@ import { VatRate, VoucherAction, VoucherType } from '../enums/index.js';
|
|
|
2
2
|
import { CANCELLATION_REASONS, isCancellationReason, receiptCompanyTaxInfo, receiptItemTotalCents, isDiscountItem, isTipItem, receiptSubSumCents, receiptSumCents, receiptValueVoucherSign, voucherIsValid, } from '../models/index.js';
|
|
3
3
|
import { parseServerTimeStamp, toViennaWallClock } from '../vienna-time.js';
|
|
4
4
|
import { KasseneckValidationError } from '../client/errors.js';
|
|
5
|
+
import { addOnDisplayOrder, istGueltigerZusatz } from '../pos/zusaetze.js';
|
|
5
6
|
export const CURRENT_LAYOUT_RULESET = 2;
|
|
6
7
|
/** Die Optionen von [buildReceiptLayout]; jede andere wird abgewiesen. */
|
|
7
8
|
const LAYOUT_OPTIONEN = new Set(['paperSize', 'ruleset', 'testCashregister', 'testSignature', 'registrationInfo']);
|
|
@@ -818,8 +819,10 @@ function trinkgeldZeilen(name, teile) {
|
|
|
818
819
|
* Aufteilung als Fussnote darunter (siehe trinkgeldZeilen).
|
|
819
820
|
*/
|
|
820
821
|
const rabattZeilen = trinkgeldZeilen;
|
|
821
|
-
/**
|
|
822
|
-
|
|
822
|
+
/** Vorsatz einer Zusatzzeile (Zusatz-Kacheln, 1.27.0): eingerueckt unter der Hauptposition. */
|
|
823
|
+
const ZUSATZ_VORSATZ = ' + ';
|
|
824
|
+
/** Positionszeile: Menge, Bezeichnung, ab Menge 2 der Einzelpreis; ein Zusatz eingerueckt mit „+ “. */
|
|
825
|
+
function positionsZeile(item, satz, zusatz = false) {
|
|
823
826
|
const menge = String(item.quantity);
|
|
824
827
|
// Vorbild: Menge auf zwei Zeichen auffuellen, danach ' x ' — bei drei- und
|
|
825
828
|
// mehrstelligen Mengen faellt das Leerzeichen dahinter weg.
|
|
@@ -829,7 +832,7 @@ function positionsZeile(item, satz) {
|
|
|
829
832
|
return {
|
|
830
833
|
kind: 'columns',
|
|
831
834
|
columns: [
|
|
832
|
-
{ text: `${kopf}${item.name}${einzelpreis}`, width: 7, align: 'left' },
|
|
835
|
+
{ text: `${zusatz ? ZUSATZ_VORSATZ : ''}${kopf}${item.name}${einzelpreis}`, width: 7, align: 'left' },
|
|
833
836
|
{ text: `${formatCents(receiptItemTotalCents(item))} ${satz.category}`, width: 5, align: 'right' },
|
|
834
837
|
],
|
|
835
838
|
};
|
|
@@ -1153,22 +1156,26 @@ export function buildReceiptLayout(receipt, company, options = {}) {
|
|
|
1153
1156
|
.reduce((summe, it) => summe + receiptItemTotalCents(it), 0);
|
|
1154
1157
|
let zwischensummeGezeigt = false;
|
|
1155
1158
|
const gutscheinZuordnung = gutscheinPositionen(receipt);
|
|
1159
|
+
// Zusatz-Kacheln: Zusaetze direkt unter ihrer Hauptposition (stabil); ohne
|
|
1160
|
+
// Verweise ist die Reihenfolge die des Belegs (byte-gleich).
|
|
1161
|
+
const reihe = addOnDisplayOrder(receipt.items);
|
|
1162
|
+
const an = (k) => receipt.items[reihe[k]];
|
|
1156
1163
|
let i = 0;
|
|
1157
|
-
while (i <
|
|
1158
|
-
const item =
|
|
1164
|
+
while (i < reihe.length) {
|
|
1165
|
+
const item = an(i);
|
|
1159
1166
|
if (!isTipItem(item) && !isDiscountItem(item)) {
|
|
1160
1167
|
const satz = steuersatz(item.vat);
|
|
1161
1168
|
gruppeVon(satz).bruttoCents += receiptItemTotalCents(item);
|
|
1162
|
-
const gutschein = gutscheinZuordnung.get(i);
|
|
1163
|
-
lines.push(...(gutschein ? gutscheinPositionsZeilen(item, satz, gutschein) : [positionsZeile(item, satz)]));
|
|
1169
|
+
const gutschein = gutscheinZuordnung.get(reihe[i]);
|
|
1170
|
+
lines.push(...(gutschein ? gutscheinPositionsZeilen(item, satz, gutschein) : [positionsZeile(item, satz, istGueltigerZusatz(receipt.items, reihe[i]))]));
|
|
1164
1171
|
i += 1;
|
|
1165
1172
|
continue;
|
|
1166
1173
|
}
|
|
1167
1174
|
const artVon = (it) => (isTipItem(it) ? 'tip' : 'discount');
|
|
1168
1175
|
const art = artVon(item);
|
|
1169
1176
|
const gruppe = [];
|
|
1170
|
-
while (i <
|
|
1171
|
-
gruppe.push(
|
|
1177
|
+
while (i < reihe.length && artVon(an(i)) === art && !(!isTipItem(an(i)) && !isDiscountItem(an(i))) && an(i).name === item.name) {
|
|
1178
|
+
gruppe.push(an(i));
|
|
1172
1179
|
i += 1;
|
|
1173
1180
|
}
|
|
1174
1181
|
const teile = [];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Fingerabdruck des Vertrags-Exports, aus dem diese Datei stammt (`_quelle.sha256`). */
|
|
2
|
-
export declare const VOKABULAR_QUELLE = "
|
|
2
|
+
export declare const VOKABULAR_QUELLE = "842340e1f94c14fab01ffe96277d76dff4482b97df2e355daa583ff49c2db634";
|
|
3
3
|
/** Schema-Notation des Vertrags: Blatt 'aussen': 'innen', Objekt { __: 'innen', ... }, Liste [ { __: 'innen', ... } ]. */
|
|
4
4
|
export type SchemaEintrag = string | SchemaObjekt | readonly [SchemaObjekt];
|
|
5
5
|
export interface SchemaObjekt {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Erzeugt von scripts/stored-vokabular.mjs aus fixtures/v3/v3-vokabular.json.
|
|
2
2
|
// Nicht von Hand aendern: test/stored.test.ts vergleicht mit dem Vertrag.
|
|
3
3
|
/** Fingerabdruck des Vertrags-Exports, aus dem diese Datei stammt (`_quelle.sha256`). */
|
|
4
|
-
export const VOKABULAR_QUELLE = "
|
|
4
|
+
export const VOKABULAR_QUELLE = "842340e1f94c14fab01ffe96277d76dff4482b97df2e355daa583ff49c2db634";
|
|
5
5
|
/** Schema je Endpunkt (aussen -> innen) und Wertverweise auf die Kataloge. */
|
|
6
6
|
export const SCHEMAS = {
|
|
7
7
|
"getReceipt": {
|
|
@@ -19,7 +19,8 @@ export const SCHEMAS = {
|
|
|
19
19
|
{
|
|
20
20
|
"__": "items",
|
|
21
21
|
"receivedImmediately": "sofortErhalten",
|
|
22
|
-
"keptByEmployee": "direkt"
|
|
22
|
+
"keptByEmployee": "direkt",
|
|
23
|
+
"addOnOf": "zusatzZu"
|
|
23
24
|
}
|
|
24
25
|
],
|
|
25
26
|
"manualReceipt": {
|
|
@@ -387,7 +388,8 @@ export const SCHEMAS = {
|
|
|
387
388
|
"hint": "hinweis",
|
|
388
389
|
"pattern": "muster",
|
|
389
390
|
"patternStrict": "musterStreng"
|
|
390
|
-
}
|
|
391
|
+
},
|
|
392
|
+
"addOns": "zusaetze"
|
|
391
393
|
}
|
|
392
394
|
]
|
|
393
395
|
},
|
|
@@ -432,7 +434,8 @@ export const ARTIKEL_FELDER = [
|
|
|
432
434
|
"stockLocationIds",
|
|
433
435
|
"minStockByLocation",
|
|
434
436
|
"askPrice",
|
|
435
|
-
"reference"
|
|
437
|
+
"reference",
|
|
438
|
+
"addOns"
|
|
436
439
|
];
|
|
437
440
|
/** Wertkataloge innen (deutsch) -> aussen (englisch). */
|
|
438
441
|
export const KATALOGE = {
|
package/dist/esm/version.d.ts
CHANGED
package/dist/esm/version.js
CHANGED