@pisell/pisellos 2.3.128 → 2.3.130

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 (160) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.js +3 -1
  3. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  4. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  5. package/dist/model/strategy/adapter/walletPass/evaluator.js +4 -2
  6. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +58 -19
  7. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +24 -12
  8. package/dist/modules/Customer/index.js +6 -3
  9. package/dist/modules/Customer/types.d.ts +2 -0
  10. package/dist/modules/Discount/availability.d.ts +7 -0
  11. package/dist/modules/Discount/availability.js +49 -0
  12. package/dist/modules/Discount/entitlementPass.d.ts +34 -0
  13. package/dist/modules/Discount/entitlementPass.js +147 -0
  14. package/dist/modules/Discount/index.d.ts +2 -2
  15. package/dist/modules/Discount/index.js +37 -151
  16. package/dist/modules/Discount/types.d.ts +36 -5
  17. package/dist/modules/FulfillmentTiming/index.d.ts +11 -0
  18. package/dist/modules/FulfillmentTiming/index.js +407 -0
  19. package/dist/modules/FulfillmentTiming/types.d.ts +67 -0
  20. package/dist/modules/FulfillmentTiming/types.js +1 -0
  21. package/dist/modules/OpenData/types.d.ts +6 -0
  22. package/dist/modules/Order/index.d.ts +12 -0
  23. package/dist/modules/Order/index.js +498 -247
  24. package/dist/modules/Order/pickupTiming.d.ts +46 -0
  25. package/dist/modules/Order/pickupTiming.js +53 -0
  26. package/dist/modules/Order/types.d.ts +5 -1
  27. package/dist/modules/Order/utils/orderCollectionIdentity.js +16 -12
  28. package/dist/modules/Order/utils.d.ts +1 -1
  29. package/dist/modules/Order/utils.js +117 -66
  30. package/dist/modules/Payment/index.js +9 -10
  31. package/dist/modules/Payment/types.d.ts +21 -1
  32. package/dist/modules/Payment/types.js +2 -0
  33. package/dist/modules/Payment/walletpass.d.ts +1 -1
  34. package/dist/modules/Payment/walletpass.js +80 -47
  35. package/dist/modules/Rules/index.d.ts +2 -2
  36. package/dist/modules/Rules/index.js +480 -186
  37. package/dist/modules/Rules/types.d.ts +4 -0
  38. package/dist/modules/Schedule/index.d.ts +8 -0
  39. package/dist/modules/Schedule/index.js +141 -39
  40. package/dist/modules/index.d.ts +1 -0
  41. package/dist/modules/index.js +1 -0
  42. package/dist/plugins/request.d.ts +7 -0
  43. package/dist/server/modules/order/types.d.ts +2 -0
  44. package/dist/server/utils/small-ticket.d.ts +1 -85
  45. package/dist/server/utils/small-ticket.js +2 -2542
  46. package/dist/shared/payment/loadPaymentMethods.d.ts +9 -0
  47. package/dist/shared/payment/loadPaymentMethods.js +66 -0
  48. package/dist/shared/receipt/loadCustomerInvoiceLayout.d.ts +22 -0
  49. package/dist/shared/receipt/loadCustomerInvoiceLayout.js +142 -0
  50. package/dist/shared/receipt/small-ticket.d.ts +85 -0
  51. package/dist/shared/receipt/small-ticket.js +2576 -0
  52. package/dist/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
  53. package/dist/shared/sales/loadSalesOrderSnapshot.js +21 -0
  54. package/dist/solution/BaseSales/index.d.ts +25 -0
  55. package/dist/solution/BaseSales/index.js +1226 -1040
  56. package/dist/solution/BaseSales/pickupTiming.d.ts +43 -0
  57. package/dist/solution/BaseSales/pickupTiming.js +589 -0
  58. package/dist/solution/BaseSales/types.d.ts +2 -2
  59. package/dist/solution/BaseSales/utils/cartPromotion.js +141 -126
  60. package/dist/solution/BaseSales/utils/parseSalesResponse.js +3 -0
  61. package/dist/solution/BookingByStep/index.d.ts +1 -1
  62. package/dist/solution/BookingTicket/index.d.ts +4 -5
  63. package/dist/solution/BookingTicket/index.js +60 -63
  64. package/dist/solution/BookingTicket/types.d.ts +5 -1
  65. package/dist/solution/BookingTicket/utils/cartView.js +3 -1
  66. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
  67. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +338 -147
  68. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +8 -4
  69. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +6 -0
  70. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +19 -6
  71. package/dist/solution/OrderInvoicePreview/index.d.ts +56 -0
  72. package/dist/solution/OrderInvoicePreview/index.js +269 -0
  73. package/dist/solution/ShopDiscount/index.d.ts +2 -0
  74. package/dist/solution/ShopDiscount/index.js +99 -42
  75. package/dist/solution/ShopDiscount/utils.d.ts +4 -2
  76. package/dist/solution/ShopDiscount/utils.js +43 -23
  77. package/dist/solution/UnifiedBookingSales/index.d.ts +13 -4
  78. package/dist/solution/UnifiedBookingSales/index.js +874 -709
  79. package/dist/solution/index.d.ts +1 -0
  80. package/dist/solution/index.js +2 -1
  81. package/lib/index.d.ts +2 -0
  82. package/lib/index.js +21 -1
  83. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  84. package/lib/model/strategy/adapter/walletPass/evaluator.js +2 -0
  85. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +35 -6
  86. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +13 -6
  87. package/lib/modules/Customer/index.js +5 -1
  88. package/lib/modules/Customer/types.d.ts +2 -0
  89. package/lib/modules/Discount/availability.d.ts +7 -0
  90. package/lib/modules/Discount/availability.js +43 -0
  91. package/lib/modules/Discount/entitlementPass.d.ts +34 -0
  92. package/lib/modules/Discount/entitlementPass.js +141 -0
  93. package/lib/modules/Discount/index.d.ts +2 -2
  94. package/lib/modules/Discount/index.js +23 -129
  95. package/lib/modules/Discount/types.d.ts +36 -5
  96. package/lib/modules/FulfillmentTiming/index.d.ts +11 -0
  97. package/lib/modules/FulfillmentTiming/index.js +359 -0
  98. package/lib/modules/FulfillmentTiming/types.d.ts +67 -0
  99. package/lib/modules/FulfillmentTiming/types.js +5 -0
  100. package/lib/modules/OpenData/types.d.ts +6 -0
  101. package/lib/modules/Order/index.d.ts +12 -0
  102. package/lib/modules/Order/index.js +252 -48
  103. package/lib/modules/Order/pickupTiming.d.ts +46 -0
  104. package/lib/modules/Order/pickupTiming.js +61 -0
  105. package/lib/modules/Order/types.d.ts +5 -1
  106. package/lib/modules/Order/utils/orderCollectionIdentity.js +14 -11
  107. package/lib/modules/Order/utils.d.ts +1 -1
  108. package/lib/modules/Order/utils.js +51 -7
  109. package/lib/modules/Payment/index.js +3 -4
  110. package/lib/modules/Payment/types.d.ts +21 -1
  111. package/lib/modules/Payment/types.js +1 -0
  112. package/lib/modules/Payment/walletpass.d.ts +1 -1
  113. package/lib/modules/Payment/walletpass.js +29 -9
  114. package/lib/modules/Rules/index.d.ts +2 -2
  115. package/lib/modules/Rules/index.js +357 -110
  116. package/lib/modules/Rules/types.d.ts +4 -0
  117. package/lib/modules/Schedule/index.d.ts +8 -0
  118. package/lib/modules/Schedule/index.js +68 -12
  119. package/lib/modules/index.d.ts +1 -0
  120. package/lib/modules/index.js +11 -0
  121. package/lib/plugins/request.d.ts +7 -0
  122. package/lib/server/modules/order/types.d.ts +2 -0
  123. package/lib/server/utils/small-ticket.d.ts +1 -85
  124. package/lib/server/utils/small-ticket.js +9 -2305
  125. package/lib/shared/payment/loadPaymentMethods.d.ts +9 -0
  126. package/lib/shared/payment/loadPaymentMethods.js +40 -0
  127. package/lib/shared/receipt/loadCustomerInvoiceLayout.d.ts +22 -0
  128. package/lib/shared/receipt/loadCustomerInvoiceLayout.js +86 -0
  129. package/lib/shared/receipt/small-ticket.d.ts +85 -0
  130. package/lib/shared/receipt/small-ticket.js +2342 -0
  131. package/lib/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
  132. package/lib/shared/sales/loadSalesOrderSnapshot.js +22 -0
  133. package/lib/solution/BaseSales/index.d.ts +25 -0
  134. package/lib/solution/BaseSales/index.js +102 -3
  135. package/lib/solution/BaseSales/pickupTiming.d.ts +43 -0
  136. package/lib/solution/BaseSales/pickupTiming.js +269 -0
  137. package/lib/solution/BaseSales/types.d.ts +2 -2
  138. package/lib/solution/BaseSales/utils/cartPromotion.js +12 -4
  139. package/lib/solution/BaseSales/utils/parseSalesResponse.js +3 -0
  140. package/lib/solution/BookingByStep/index.d.ts +1 -1
  141. package/lib/solution/BookingTicket/index.d.ts +4 -5
  142. package/lib/solution/BookingTicket/index.js +36 -33
  143. package/lib/solution/BookingTicket/types.d.ts +5 -1
  144. package/lib/solution/BookingTicket/utils/cartView.js +3 -1
  145. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
  146. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +174 -42
  147. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +8 -4
  148. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +6 -0
  149. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +11 -3
  150. package/lib/solution/OrderInvoicePreview/index.d.ts +56 -0
  151. package/lib/solution/OrderInvoicePreview/index.js +192 -0
  152. package/lib/solution/ShopDiscount/index.d.ts +2 -0
  153. package/lib/solution/ShopDiscount/index.js +55 -9
  154. package/lib/solution/ShopDiscount/utils.d.ts +4 -2
  155. package/lib/solution/ShopDiscount/utils.js +42 -25
  156. package/lib/solution/UnifiedBookingSales/index.d.ts +13 -4
  157. package/lib/solution/UnifiedBookingSales/index.js +132 -48
  158. package/lib/solution/index.d.ts +1 -0
  159. package/lib/solution/index.js +11 -0
  160. package/package.json +1 -1
@@ -0,0 +1,9 @@
1
+ import type { RequestPlugin } from '../../plugins/request';
2
+ import type { PaymentMethod } from '../../modules/Payment/types';
3
+ /** Shared read-only transport; customer hosts route the remote path under /h5. */
4
+ export declare function loadPaymentMethods(request: RequestPlugin, options: {
5
+ transport: 'remote' | 'os-server';
6
+ filterPaymentMethods: boolean;
7
+ }): Promise<PaymentMethod[]>;
8
+ /** Enrich a copy: never overwrite historical names or change payment amounts. */
9
+ export declare function withPaymentMethodNames(order: Record<string, any>, methods: PaymentMethod[]): Record<string, any>;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.loadPaymentMethods = loadPaymentMethods;
7
+ exports.withPaymentMethodNames = withPaymentMethodNames;
8
+ /** Shared read-only transport; customer hosts route the remote path under /h5. */
9
+ async function loadPaymentMethods(request, options) {
10
+ const response = await request.get('/pay/custom-payment/all', {
11
+ filterPaymentMethods: options.filterPaymentMethods
12
+ }, options.transport === 'os-server' ? {
13
+ osServer: true
14
+ } : {
15
+ manualErrorHandling: true,
16
+ skipErrorHandler: true
17
+ });
18
+ const methods = response?.data ?? response;
19
+ if (!Array.isArray(methods)) throw new Error('Payment methods are unavailable');
20
+ return methods;
21
+ }
22
+
23
+ /** Enrich a copy: never overwrite historical names or change payment amounts. */
24
+ function withPaymentMethodNames(order, methods) {
25
+ if (!Array.isArray(order.payments)) return order;
26
+ return {
27
+ ...order,
28
+ payments: order.payments.map(payment => {
29
+ if (payment.name || payment.title || payment.payment_method_name || payment.method_name) return payment;
30
+ const id = payment.custom_payment_id;
31
+ const hasId = id !== undefined && id !== null && String(id).trim() !== '';
32
+ const code = payment.code || payment.type || payment.payment_method || payment.method;
33
+ const method = methods.find(candidate => hasId ? String(candidate.id) === String(id) : !!code && candidate.code === code);
34
+ return method?.name ? {
35
+ ...payment,
36
+ payment_method_name: method.name
37
+ } : payment;
38
+ })
39
+ };
40
+ }
@@ -0,0 +1,22 @@
1
+ import type { RequestPlugin } from '../../plugins/request';
2
+ import { type InvoiceLayoutConfig } from '../../modules/OpenData';
3
+ export interface PublicInvoiceDocumentResponse {
4
+ status: boolean;
5
+ code: number;
6
+ message?: string;
7
+ data: {
8
+ id: number;
9
+ data?: {
10
+ template_settings?: unknown;
11
+ } | null;
12
+ } | null;
13
+ }
14
+ interface TemplateScope {
15
+ tenantId: string | number;
16
+ shopId: string | number;
17
+ identity: string;
18
+ businessCode: string;
19
+ channel: string;
20
+ }
21
+ export declare function loadCustomerInvoiceLayout(request: RequestPlugin, scope: TemplateScope): Promise<InvoiceLayoutConfig>;
22
+ export {};
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.loadCustomerInvoiceLayout = loadCustomerInvoiceLayout;
7
+ var _OpenData = require("../../modules/OpenData");
8
+ // Page-runtime caches: also retain DEFAULT on failure, without automatic retries.
9
+ const caches = new WeakMap();
10
+ const isRecord = value => !!value && typeof value === 'object' && !Array.isArray(value);
11
+ function documentId(value) {
12
+ if (typeof value !== 'string' && typeof value !== 'number') return null;
13
+ const text = String(value).trim();
14
+ if (!/^\d+$/.test(text)) return null;
15
+ const id = Number(text);
16
+ return Number.isSafeInteger(id) && id > 0 ? String(id) : null;
17
+ }
18
+ function loadCustomerInvoiceLayout(request, scope) {
19
+ let cache = caches.get(request);
20
+ if (!cache) {
21
+ cache = {
22
+ scopes: new Map(),
23
+ documents: new Map()
24
+ };
25
+ caches.set(request, cache);
26
+ }
27
+ const target = `${scope.businessCode}+${scope.channel}`;
28
+ const key = JSON.stringify([scope.tenantId, scope.shopId, scope.identity, scope.businessCode, scope.channel]);
29
+ const cached = cache.scopes.get(key);
30
+ if (cached) return cached;
31
+ let id = null;
32
+ const task = (async () => {
33
+ const response = await request.post(`/open/my-pisell/${encodeURIComponent(String(scope.shopId))}/setting`, {
34
+ scope: 'board',
35
+ target,
36
+ section_code: ['documents']
37
+ }, {
38
+ pisell2: true,
39
+ prefix: false,
40
+ headers: scope.tenantId ? {
41
+ 'Tenant-Id': String(scope.tenantId)
42
+ } : {},
43
+ manualErrorHandling: true,
44
+ skipErrorHandler: true,
45
+ timeout: 15000
46
+ });
47
+ if (response?.status !== true || response.code !== 200 || !isRecord(response.data)) throw new Error(response?.message || 'Invoice OpenData is unavailable');
48
+ const config = response.data;
49
+ const raw = config['documents.invoice_template'];
50
+ id = documentId(raw);
51
+ if (!id) {
52
+ // Preserve the existing non-numeric legacy template / invoice_edit contract.
53
+ const numericLike = /^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i;
54
+ return typeof raw === 'string' && raw.trim() && !numericLike.test(raw.trim()) ? (0, _OpenData.normalizeInvoiceLayoutFromTemplateSettings)((0, _OpenData.normalizeInvoiceTemplateSettings)(config)) : (0, _OpenData.getDefaultInvoiceLayoutConfig)();
55
+ }
56
+ const docKey = JSON.stringify([key, id]);
57
+ let pending = cache.documents.get(docKey);
58
+ if (!pending) {
59
+ const expectedId = id;
60
+ pending = (async () => {
61
+ const result = await request.get(`/open/document/${expectedId}`, {}, {
62
+ publicInvoiceDocument: true
63
+ });
64
+ if (result?.status !== true || result.code !== 200) throw new Error(result?.message || 'Invoice Document request failed');
65
+ const doc = result.data;
66
+ if (!doc || documentId(doc.id) !== expectedId) throw new Error('Invoice Document is unavailable or its ID does not match');
67
+ if (!isRecord(doc.data) || !isRecord(doc.data.template_settings)) throw new Error('Invoice Document has no template_settings');
68
+ const settings = (0, _OpenData.normalizeRawInvoiceTemplateSettings)(doc.data.template_settings);
69
+ if (settings.modules.length === 0) throw new Error('Invoice Document has no usable template modules');
70
+ return (0, _OpenData.normalizeInvoiceLayoutFromTemplateSettings)(settings);
71
+ })().catch(error => fallback(error, target, expectedId));
72
+ cache.documents.set(docKey, pending);
73
+ }
74
+ return pending;
75
+ })().catch(error => fallback(error, target, id));
76
+ cache.scopes.set(key, task);
77
+ return task;
78
+ }
79
+ function fallback(error, target, id) {
80
+ console.warn('[OrderInvoicePreview] Template unavailable; using DEFAULT', {
81
+ target,
82
+ documentId: id,
83
+ message: error instanceof Error ? error.message : 'Template request failed'
84
+ });
85
+ return (0, _OpenData.getDefaultInvoiceLayoutConfig)();
86
+ }
@@ -0,0 +1,85 @@
1
+ export interface SmallTicketShopInfo {
2
+ name?: string;
3
+ phone?: string;
4
+ address?: string;
5
+ address_street?: string;
6
+ address_detail?: string;
7
+ city?: string;
8
+ province?: string;
9
+ country?: string;
10
+ zip?: string;
11
+ tax_number?: string;
12
+ tax_title?: string;
13
+ is_price_include_tax?: 0 | 1 | boolean;
14
+ currency_symbol?: string;
15
+ currency_code?: string;
16
+ primary_locale?: string;
17
+ timezone?: string;
18
+ [key: string]: any;
19
+ }
20
+ export interface BuildSmallTicketDataParams {
21
+ order: Record<string, any>;
22
+ shopInfo?: SmallTicketShopInfo | null;
23
+ locales?: string[];
24
+ productMap?: Record<string | number, Record<string, any>>;
25
+ }
26
+ export interface SmallTicketItem {
27
+ item: string;
28
+ value: string;
29
+ size?: number;
30
+ align?: string;
31
+ product_uid?: string | number;
32
+ booking_uid?: string | number;
33
+ }
34
+ export interface SmallTicketProduct {
35
+ product_title: string;
36
+ product_quantity: number;
37
+ selling_price: string;
38
+ total_selling_price: string;
39
+ original_price: string;
40
+ base_price?: string;
41
+ total_original_price: string;
42
+ options_total_price?: string;
43
+ package_items_total_price?: string;
44
+ extension_list: any[];
45
+ product_uid?: string | number;
46
+ booking_uid?: string | number;
47
+ product_note?: string;
48
+ allergy?: string;
49
+ options?: Array<{
50
+ name: string;
51
+ num?: number;
52
+ price?: string;
53
+ total_price: string;
54
+ value?: string;
55
+ }>;
56
+ variant?: string;
57
+ combinations?: any[];
58
+ }
59
+ export type SmallTicketAppointment = SmallTicketItem[];
60
+ export interface SmallTicketLocaleData {
61
+ base_data: Record<string, any>;
62
+ products: SmallTicketProduct[];
63
+ fees: {
64
+ fees: SmallTicketItem[];
65
+ countFee: Record<string, any>;
66
+ };
67
+ customer: SmallTicketItem[];
68
+ appointment: SmallTicketAppointment;
69
+ delivery?: SmallTicketItem[];
70
+ resources: Array<{
71
+ id: string | number;
72
+ code: string;
73
+ title: string;
74
+ form_title: string;
75
+ }>;
76
+ payment_data: SmallTicketItem[][];
77
+ wallets: SmallTicketItem[][];
78
+ tickets: any[];
79
+ source_shop: any[];
80
+ refund_data: SmallTicketItem[][];
81
+ expend_data: any[];
82
+ }
83
+ export type SmallTicketData = Record<string, SmallTicketLocaleData>;
84
+ export declare function buildSmallTicketData(params: BuildSmallTicketDataParams): SmallTicketData;
85
+ export declare function hasSmallTicketData(value: any): boolean;