@pisell/pisellos 2.3.137 → 2.3.139

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 (40) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  2. package/dist/modules/Order/utils.js +1 -1
  3. package/dist/modules/ResourcePlanner/planner.js +10 -8
  4. package/dist/server/test.json +1 -1
  5. package/dist/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
  6. package/dist/shared/receipt/customerInvoiceLanguages.js +60 -0
  7. package/dist/shared/receipt/loadCustomerInvoiceLayout.d.ts +5 -0
  8. package/dist/shared/receipt/loadCustomerInvoiceLayout.js +46 -4
  9. package/dist/shared/receipt/small-ticket.d.ts +9 -0
  10. package/dist/shared/receipt/small-ticket.js +246 -186
  11. package/dist/solution/OrderInvoicePreview/index.d.ts +10 -0
  12. package/dist/solution/OrderInvoicePreview/index.js +84 -14
  13. package/dist/solution/RegisterAndLogin/config.js +33 -11
  14. package/dist/solution/RegisterAndLogin/index.d.ts +2 -0
  15. package/dist/solution/RegisterAndLogin/index.js +1 -1
  16. package/dist/solution/RegisterAndLogin/utils.d.ts +12 -4
  17. package/dist/solution/RegisterAndLogin/utils.js +36 -16
  18. package/dist/solution/Sales/index.d.ts +2 -0
  19. package/dist/solution/Sales/index.js +15 -1
  20. package/dist/solution/UnifiedBookingSales/index.js +3 -4
  21. package/lib/modules/Order/utils.js +1 -1
  22. package/lib/modules/ResourcePlanner/planner.js +10 -8
  23. package/lib/server/test.json +1 -1
  24. package/lib/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
  25. package/lib/shared/receipt/customerInvoiceLanguages.js +58 -0
  26. package/lib/shared/receipt/loadCustomerInvoiceLayout.d.ts +5 -0
  27. package/lib/shared/receipt/loadCustomerInvoiceLayout.js +42 -4
  28. package/lib/shared/receipt/small-ticket.d.ts +9 -0
  29. package/lib/shared/receipt/small-ticket.js +122 -9
  30. package/lib/solution/OrderInvoicePreview/index.d.ts +10 -0
  31. package/lib/solution/OrderInvoicePreview/index.js +60 -7
  32. package/lib/solution/RegisterAndLogin/config.js +32 -11
  33. package/lib/solution/RegisterAndLogin/index.d.ts +2 -0
  34. package/lib/solution/RegisterAndLogin/index.js +9 -1
  35. package/lib/solution/RegisterAndLogin/utils.d.ts +12 -4
  36. package/lib/solution/RegisterAndLogin/utils.js +24 -17
  37. package/lib/solution/Sales/index.d.ts +2 -0
  38. package/lib/solution/Sales/index.js +10 -1
  39. package/lib/solution/UnifiedBookingSales/index.js +3 -4
  40. package/package.json +1 -1
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.normalizeCustomerInvoiceLanguage = normalizeCustomerInvoiceLanguage;
7
+ exports.resolveCustomerInvoiceLanguages = resolveCustomerInvoiceLanguages;
8
+ const aliases = {
9
+ en: 'en',
10
+ en_us: 'en',
11
+ en_gb: 'en',
12
+ en_au: 'en',
13
+ cn: 'zh_CN',
14
+ zh: 'zh_CN',
15
+ zh_cn: 'zh_CN',
16
+ zh_hans: 'zh_CN',
17
+ zh_sg: 'zh_CN',
18
+ hk: 'zh_HK',
19
+ zh_hk: 'zh_HK',
20
+ zh_tw: 'zh_HK',
21
+ zh_hant: 'zh_HK',
22
+ ja: 'ja',
23
+ ja_jp: 'ja',
24
+ jp: 'ja',
25
+ pt: 'pt',
26
+ pt_br: 'pt',
27
+ pt_pt: 'pt',
28
+ cn_en: 'cn_en',
29
+ en_cn: 'cn_en'
30
+ };
31
+ function normalizeCustomerInvoiceLanguage(value) {
32
+ return aliases[value.trim().toLowerCase().replace(/-/g, '_')];
33
+ }
34
+ function option(code) {
35
+ return {
36
+ code,
37
+ locales: code === 'cn_en' ? ['en', 'zh_CN'] : [code]
38
+ };
39
+ }
40
+
41
+ /** Preserve configured insertion order; a print count never repeats an option. */
42
+ function resolveCustomerInvoiceLanguages(language, pageLocale) {
43
+ const options = [];
44
+ const seen = new Set();
45
+ Object.entries(language).forEach(([key, count]) => {
46
+ if (typeof count !== 'number' || !Number.isFinite(count) || count <= 0) return;
47
+ const code = normalizeCustomerInvoiceLanguage(key);
48
+ if (!code || seen.has(code)) return;
49
+ seen.add(code);
50
+ options.push(option(code));
51
+ });
52
+ if (options.length) return options;
53
+ const normalized = normalizeCustomerInvoiceLanguage(pageLocale);
54
+ // A page locale is a single language, never a bilingual printer mode.
55
+ const requested = pageLocale.toLowerCase().replace(/_/g, '-');
56
+ const fallback = normalized && normalized !== 'cn_en' ? normalized : requested.startsWith('zh-tw') || requested.startsWith('zh-hk') ? 'zh_HK' : requested.startsWith('zh') ? 'zh_CN' : requested.startsWith('ja') ? 'ja' : requested.startsWith('pt') ? 'pt' : 'en';
57
+ return [option(fallback)];
58
+ }
@@ -11,6 +11,10 @@ export interface PublicInvoiceDocumentResponse {
11
11
  } | null;
12
12
  } | null;
13
13
  }
14
+ export interface CustomerInvoiceTemplate {
15
+ layout: InvoiceLayoutConfig;
16
+ language: Record<string, unknown>;
17
+ }
14
18
  interface TemplateScope {
15
19
  tenantId: string | number;
16
20
  shopId: string | number;
@@ -18,5 +22,6 @@ interface TemplateScope {
18
22
  businessCode: string;
19
23
  channel: string;
20
24
  }
25
+ export declare function loadCustomerInvoiceTemplate(request: RequestPlugin, scope: TemplateScope): Promise<CustomerInvoiceTemplate>;
21
26
  export declare function loadCustomerInvoiceLayout(request: RequestPlugin, scope: TemplateScope): Promise<InvoiceLayoutConfig>;
22
27
  export {};
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.loadCustomerInvoiceLayout = loadCustomerInvoiceLayout;
7
+ exports.loadCustomerInvoiceTemplate = loadCustomerInvoiceTemplate;
7
8
  var _OpenData = require("../../modules/OpenData");
8
9
  // Page-runtime caches: also retain DEFAULT on failure, without automatic retries.
9
10
  const caches = new WeakMap();
@@ -15,7 +16,7 @@ function documentId(value) {
15
16
  const id = Number(text);
16
17
  return Number.isSafeInteger(id) && id > 0 ? String(id) : null;
17
18
  }
18
- function loadCustomerInvoiceLayout(request, scope) {
19
+ function loadCustomerInvoiceTemplate(request, scope) {
19
20
  let cache = caches.get(request);
20
21
  if (!cache) {
21
22
  cache = {
@@ -51,7 +52,10 @@ function loadCustomerInvoiceLayout(request, scope) {
51
52
  if (!id) {
52
53
  // Preserve the existing non-numeric legacy template / invoice_edit contract.
53
54
  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
+ 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();
55
59
  }
56
60
  const docKey = JSON.stringify([key, id]);
57
61
  let pending = cache.documents.get(docKey);
@@ -67,7 +71,10 @@ function loadCustomerInvoiceLayout(request, scope) {
67
71
  if (!isRecord(doc.data) || !isRecord(doc.data.template_settings)) throw new Error('Invoice Document has no template_settings');
68
72
  const settings = (0, _OpenData.normalizeRawInvoiceTemplateSettings)(doc.data.template_settings);
69
73
  if (settings.modules.length === 0) throw new Error('Invoice Document has no usable template modules');
70
- return (0, _OpenData.normalizeInvoiceLayoutFromTemplateSettings)(settings);
74
+ return {
75
+ layout: (0, _OpenData.normalizeInvoiceLayoutFromTemplateSettings)(settings),
76
+ language: readLanguage(doc.data.template_settings)
77
+ };
71
78
  })().catch(error => fallback(error, target, expectedId));
72
79
  cache.documents.set(docKey, pending);
73
80
  }
@@ -82,5 +89,36 @@ function fallback(error, target, id) {
82
89
  documentId: id,
83
90
  message: error instanceof Error ? error.message : 'Template request failed'
84
91
  });
85
- return (0, _OpenData.getDefaultInvoiceLayoutConfig)();
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
+ } : {};
86
124
  }
@@ -22,8 +22,13 @@ export interface BuildSmallTicketDataParams {
22
22
  shopInfo?: SmallTicketShopInfo | null;
23
23
  locales?: string[];
24
24
  productMap?: Record<string | number, Record<string, any>>;
25
+ /** Customer preview only: stable source identities for bilingual rows. */
26
+ includeReceiptKeys?: boolean;
25
27
  }
26
28
  export interface SmallTicketItem {
29
+ receipt_key?: string;
30
+ receipt_value_kind?: 'shared' | 'text';
31
+ receipt_item_kind?: 'shared';
27
32
  item: string;
28
33
  value: string;
29
34
  size?: number;
@@ -32,6 +37,8 @@ export interface SmallTicketItem {
32
37
  booking_uid?: string | number;
33
38
  }
34
39
  export interface SmallTicketProduct {
40
+ receipt_key?: string;
41
+ receipt_source_index?: number;
35
42
  product_title: string;
36
43
  product_quantity: number;
37
44
  selling_price: string;
@@ -47,6 +54,8 @@ export interface SmallTicketProduct {
47
54
  product_note?: string;
48
55
  allergy?: string;
49
56
  options?: Array<{
57
+ receipt_key?: string;
58
+ receipt_source_index?: number;
50
59
  name: string;
51
60
  num?: number;
52
61
  price?: string;