@pisell/pisellos 0.10.55 → 0.10.57
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/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/OpenData/index.js +2 -1
- package/dist/modules/Order/index.d.ts +1 -0
- package/dist/modules/Order/index.js +118 -59
- package/dist/modules/Order/utils/weighedProduct.d.ts +12 -0
- package/dist/modules/Order/utils/weighedProduct.js +94 -0
- package/dist/modules/Order/utils.d.ts +1 -1
- package/dist/modules/Order/utils.js +9 -6
- package/dist/modules/Payment/index.d.ts +0 -5
- package/dist/modules/Payment/index.js +35 -85
- package/dist/modules/ProductList/index.js +18 -5
- package/dist/modules/ResourcePlanner/planner.js +10 -8
- package/dist/modules/Rules/index.js +16 -14
- package/dist/modules/Rules/types.d.ts +2 -0
- package/dist/plugins/request.d.ts +4 -0
- package/dist/server/index.js +122 -69
- package/dist/server/modules/floor-plan/index.js +34 -3
- package/dist/server/modules/payment/index.d.ts +25 -6
- package/dist/server/modules/payment/index.js +660 -133
- package/dist/server/test.json +1 -1
- package/dist/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
- package/dist/shared/receipt/customerInvoiceLanguages.js +60 -0
- package/dist/shared/receipt/loadCustomerInvoiceLayout.d.ts +27 -0
- package/dist/shared/receipt/loadCustomerInvoiceLayout.js +184 -0
- package/dist/shared/receipt/small-ticket.d.ts +11 -0
- package/dist/shared/receipt/small-ticket.js +430 -255
- package/dist/shared/receipt/templateVisibility.d.ts +23 -0
- package/dist/shared/receipt/templateVisibility.js +64 -0
- package/dist/solution/BaseSales/index.d.ts +4 -2
- package/dist/solution/BaseSales/index.js +1328 -1214
- package/dist/solution/BaseSales/types.d.ts +5 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +40 -25
- package/dist/solution/BaseSales/utils.js +3 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +4 -1
- package/dist/solution/BookingTicket/index.js +120 -80
- package/dist/solution/OrderInvoicePreview/index.d.ts +10 -0
- package/dist/solution/OrderInvoicePreview/index.js +87 -16
- package/dist/solution/RegisterAndLogin/config.js +54 -11
- package/dist/solution/RegisterAndLogin/index.d.ts +2 -0
- package/dist/solution/RegisterAndLogin/index.js +1 -1
- package/dist/solution/RegisterAndLogin/utils.d.ts +12 -4
- package/dist/solution/RegisterAndLogin/utils.js +36 -16
- package/dist/solution/Sales/index.d.ts +2 -0
- package/dist/solution/Sales/index.js +15 -1
- package/dist/solution/ScanOrder/utils.js +3 -2
- package/dist/solution/UnifiedBookingSales/index.js +12 -13
- package/dist/solution/VenueBooking/index.d.ts +15 -2
- package/dist/solution/VenueBooking/index.js +1062 -785
- package/dist/solution/VenueBooking/types.d.ts +2 -1
- package/dist/solution/VenueBooking/types.js +1 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +7 -4
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
- package/dist/solution/VenueBooking/utils/smartPricing.js +273 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +6 -3
- package/lib/modules/OpenData/index.js +2 -1
- package/lib/modules/Order/index.d.ts +1 -0
- package/lib/modules/Order/index.js +71 -11
- package/lib/modules/Order/utils/weighedProduct.d.ts +12 -0
- package/lib/modules/Order/utils/weighedProduct.js +89 -0
- package/lib/modules/Order/utils.d.ts +1 -1
- package/lib/modules/Order/utils.js +5 -3
- package/lib/modules/Payment/index.d.ts +0 -5
- package/lib/modules/Payment/index.js +3 -28
- package/lib/modules/ProductList/index.js +14 -1
- package/lib/modules/ResourcePlanner/planner.js +10 -8
- package/lib/modules/Rules/index.js +16 -14
- package/lib/modules/Rules/types.d.ts +2 -0
- package/lib/plugins/request.d.ts +4 -0
- package/lib/server/index.js +72 -28
- package/lib/server/modules/floor-plan/index.js +29 -1
- package/lib/server/modules/payment/index.d.ts +25 -6
- package/lib/server/modules/payment/index.js +350 -78
- package/lib/server/test.json +1 -1
- package/lib/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
- package/lib/shared/receipt/customerInvoiceLanguages.js +58 -0
- package/lib/shared/receipt/loadCustomerInvoiceLayout.d.ts +27 -0
- package/lib/shared/receipt/loadCustomerInvoiceLayout.js +124 -0
- package/lib/shared/receipt/small-ticket.d.ts +11 -0
- package/lib/shared/receipt/small-ticket.js +234 -30
- package/lib/shared/receipt/templateVisibility.d.ts +23 -0
- package/lib/shared/receipt/templateVisibility.js +63 -0
- package/lib/solution/BaseSales/index.d.ts +4 -2
- package/lib/solution/BaseSales/index.js +79 -18
- package/lib/solution/BaseSales/types.d.ts +5 -1
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +24 -9
- package/lib/solution/BaseSales/utils.js +2 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +4 -1
- package/lib/solution/BookingTicket/index.js +14 -2
- package/lib/solution/OrderInvoicePreview/index.d.ts +10 -0
- package/lib/solution/OrderInvoicePreview/index.js +62 -10
- package/lib/solution/RegisterAndLogin/config.js +57 -11
- package/lib/solution/RegisterAndLogin/index.d.ts +2 -0
- package/lib/solution/RegisterAndLogin/index.js +9 -1
- package/lib/solution/RegisterAndLogin/utils.d.ts +12 -4
- package/lib/solution/RegisterAndLogin/utils.js +24 -17
- package/lib/solution/Sales/index.d.ts +2 -0
- package/lib/solution/Sales/index.js +10 -1
- package/lib/solution/ScanOrder/utils.js +2 -1
- package/lib/solution/UnifiedBookingSales/index.js +5 -6
- package/lib/solution/VenueBooking/index.d.ts +15 -2
- package/lib/solution/VenueBooking/index.js +243 -96
- package/lib/solution/VenueBooking/types.d.ts +2 -1
- package/lib/solution/VenueBooking/types.js +1 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +7 -4
- package/lib/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
- package/lib/solution/VenueBooking/utils/smartPricing.js +224 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +5 -2
- package/package.json +1 -1
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.loadCustomerInvoiceLayout = loadCustomerInvoiceLayout;
|
|
7
|
+
exports.loadCustomerInvoiceTemplate = loadCustomerInvoiceTemplate;
|
|
8
|
+
var _OpenData = require("../../modules/OpenData");
|
|
9
|
+
// Page-runtime caches: also retain DEFAULT on failure, without automatic retries.
|
|
10
|
+
const caches = new WeakMap();
|
|
11
|
+
const isRecord = value => !!value && typeof value === 'object' && !Array.isArray(value);
|
|
12
|
+
function documentId(value) {
|
|
13
|
+
if (typeof value !== 'string' && typeof value !== 'number') return null;
|
|
14
|
+
const text = String(value).trim();
|
|
15
|
+
if (!/^\d+$/.test(text)) return null;
|
|
16
|
+
const id = Number(text);
|
|
17
|
+
return Number.isSafeInteger(id) && id > 0 ? String(id) : null;
|
|
18
|
+
}
|
|
19
|
+
function loadCustomerInvoiceTemplate(request, scope) {
|
|
20
|
+
let cache = caches.get(request);
|
|
21
|
+
if (!cache) {
|
|
22
|
+
cache = {
|
|
23
|
+
scopes: new Map(),
|
|
24
|
+
documents: new Map()
|
|
25
|
+
};
|
|
26
|
+
caches.set(request, cache);
|
|
27
|
+
}
|
|
28
|
+
const target = `${scope.businessCode}+${scope.channel}`;
|
|
29
|
+
const key = JSON.stringify([scope.tenantId, scope.shopId, scope.identity, scope.businessCode, scope.channel]);
|
|
30
|
+
const cached = cache.scopes.get(key);
|
|
31
|
+
if (cached) return cached;
|
|
32
|
+
let id = null;
|
|
33
|
+
const task = (async () => {
|
|
34
|
+
const response = await request.post(`/open/my-pisell/${encodeURIComponent(String(scope.shopId))}/setting`, {
|
|
35
|
+
scope: 'board',
|
|
36
|
+
target,
|
|
37
|
+
section_code: ['documents']
|
|
38
|
+
}, {
|
|
39
|
+
pisell2: true,
|
|
40
|
+
prefix: false,
|
|
41
|
+
headers: scope.tenantId ? {
|
|
42
|
+
'Tenant-Id': String(scope.tenantId)
|
|
43
|
+
} : {},
|
|
44
|
+
manualErrorHandling: true,
|
|
45
|
+
skipErrorHandler: true,
|
|
46
|
+
timeout: 15000
|
|
47
|
+
});
|
|
48
|
+
if (response?.status !== true || response.code !== 200 || !isRecord(response.data)) throw new Error(response?.message || 'Invoice OpenData is unavailable');
|
|
49
|
+
const config = response.data;
|
|
50
|
+
const raw = config['documents.invoice_template'];
|
|
51
|
+
id = documentId(raw);
|
|
52
|
+
if (!id) {
|
|
53
|
+
// Preserve the existing non-numeric legacy template / invoice_edit contract.
|
|
54
|
+
const numericLike = /^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i;
|
|
55
|
+
return typeof raw === 'string' && raw.trim() && !numericLike.test(raw.trim()) ? {
|
|
56
|
+
layout: (0, _OpenData.normalizeInvoiceLayoutFromTemplateSettings)((0, _OpenData.normalizeInvoiceTemplateSettings)(config)),
|
|
57
|
+
language: readLanguage(config['documents.invoice_edit'])
|
|
58
|
+
} : defaultTemplate();
|
|
59
|
+
}
|
|
60
|
+
const docKey = JSON.stringify([key, id]);
|
|
61
|
+
let pending = cache.documents.get(docKey);
|
|
62
|
+
if (!pending) {
|
|
63
|
+
const expectedId = id;
|
|
64
|
+
pending = (async () => {
|
|
65
|
+
const result = await request.get(`/open/document/${expectedId}`, {}, {
|
|
66
|
+
publicInvoiceDocument: true
|
|
67
|
+
});
|
|
68
|
+
if (result?.status !== true || result.code !== 200) throw new Error(result?.message || 'Invoice Document request failed');
|
|
69
|
+
const doc = result.data;
|
|
70
|
+
if (!doc || documentId(doc.id) !== expectedId) throw new Error('Invoice Document is unavailable or its ID does not match');
|
|
71
|
+
if (!isRecord(doc.data) || !isRecord(doc.data.template_settings)) throw new Error('Invoice Document has no template_settings');
|
|
72
|
+
const settings = (0, _OpenData.normalizeRawInvoiceTemplateSettings)(doc.data.template_settings);
|
|
73
|
+
if (settings.modules.length === 0) throw new Error('Invoice Document has no usable template modules');
|
|
74
|
+
return {
|
|
75
|
+
layout: (0, _OpenData.normalizeInvoiceLayoutFromTemplateSettings)(settings),
|
|
76
|
+
language: readLanguage(doc.data.template_settings)
|
|
77
|
+
};
|
|
78
|
+
})().catch(error => fallback(error, target, expectedId));
|
|
79
|
+
cache.documents.set(docKey, pending);
|
|
80
|
+
}
|
|
81
|
+
return pending;
|
|
82
|
+
})().catch(error => fallback(error, target, id));
|
|
83
|
+
cache.scopes.set(key, task);
|
|
84
|
+
return task;
|
|
85
|
+
}
|
|
86
|
+
function fallback(error, target, id) {
|
|
87
|
+
console.warn('[OrderInvoicePreview] Template unavailable; using DEFAULT', {
|
|
88
|
+
target,
|
|
89
|
+
documentId: id,
|
|
90
|
+
message: error instanceof Error ? error.message : 'Template request failed'
|
|
91
|
+
});
|
|
92
|
+
return defaultTemplate();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Keep the existing layout-only API and its in-flight promise identity intact.
|
|
96
|
+
const layoutPromises = new WeakMap();
|
|
97
|
+
function loadCustomerInvoiceLayout(request, scope) {
|
|
98
|
+
const template = loadCustomerInvoiceTemplate(request, scope);
|
|
99
|
+
let layout = layoutPromises.get(template);
|
|
100
|
+
if (!layout) {
|
|
101
|
+
layout = template.then(value => value.layout);
|
|
102
|
+
layoutPromises.set(template, layout);
|
|
103
|
+
}
|
|
104
|
+
return layout;
|
|
105
|
+
}
|
|
106
|
+
function defaultTemplate() {
|
|
107
|
+
return {
|
|
108
|
+
layout: (0, _OpenData.getDefaultInvoiceLayoutConfig)(),
|
|
109
|
+
language: {}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function readLanguage(value) {
|
|
113
|
+
let settings = value;
|
|
114
|
+
if (typeof settings === 'string') {
|
|
115
|
+
try {
|
|
116
|
+
settings = JSON.parse(settings);
|
|
117
|
+
} catch {
|
|
118
|
+
return {};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return isRecord(settings) && isRecord(settings.language) ? {
|
|
122
|
+
...settings.language
|
|
123
|
+
} : {};
|
|
124
|
+
}
|
|
@@ -22,8 +22,15 @@ export interface BuildSmallTicketDataParams {
|
|
|
22
22
|
shopInfo?: SmallTicketShopInfo | null;
|
|
23
23
|
locales?: string[];
|
|
24
24
|
productMap?: Record<string | number, Record<string, any>>;
|
|
25
|
+
/** Resolved template settings or layout; omitted settings preserve native compatibility. */
|
|
26
|
+
templateSettings?: unknown;
|
|
27
|
+
/** Customer preview only: stable source identities for bilingual rows. */
|
|
28
|
+
includeReceiptKeys?: boolean;
|
|
25
29
|
}
|
|
26
30
|
export interface SmallTicketItem {
|
|
31
|
+
receipt_key?: string;
|
|
32
|
+
receipt_value_kind?: 'shared' | 'text';
|
|
33
|
+
receipt_item_kind?: 'shared';
|
|
27
34
|
item: string;
|
|
28
35
|
value: string;
|
|
29
36
|
size?: number;
|
|
@@ -32,6 +39,8 @@ export interface SmallTicketItem {
|
|
|
32
39
|
booking_uid?: string | number;
|
|
33
40
|
}
|
|
34
41
|
export interface SmallTicketProduct {
|
|
42
|
+
receipt_key?: string;
|
|
43
|
+
receipt_source_index?: number;
|
|
35
44
|
product_title: string;
|
|
36
45
|
product_quantity: number;
|
|
37
46
|
selling_price: string;
|
|
@@ -47,6 +56,8 @@ export interface SmallTicketProduct {
|
|
|
47
56
|
product_note?: string;
|
|
48
57
|
allergy?: string;
|
|
49
58
|
options?: Array<{
|
|
59
|
+
receipt_key?: string;
|
|
60
|
+
receipt_source_index?: number;
|
|
50
61
|
name: string;
|
|
51
62
|
num?: number;
|
|
52
63
|
price?: string;
|