@pisell/pisellos 0.10.18 → 0.10.20

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.
@@ -3,7 +3,7 @@ import { BaseModule } from '../BaseModule';
3
3
  import type { ScheduleModule } from '../Schedule';
4
4
  import type { OpenDataConfig, OpenDataFetchParams, OpenDataAvailabilityResult, InvoiceLayoutConfig, InvoiceTemplateSettings } from './types';
5
5
  export * from './types';
6
- export { computeAvailability, getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeInvoiceLayoutConfig, normalizeInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings, } from './utils';
6
+ export { computeAvailability, getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeInvoiceLayoutConfig, normalizeInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings, resolveInvoiceReceiptLocales, } from './utils';
7
7
  export declare class OpenDataModule extends BaseModule implements Module {
8
8
  protected defaultName: string;
9
9
  protected defaultVersion: string;
@@ -18,7 +18,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
18
18
  import { BaseModule } from "../BaseModule";
19
19
  import { computeAvailability, normalizeInvoiceLayoutConfig, normalizeInvoiceTemplateSettings } from "./utils";
20
20
  export * from "./types";
21
- export { computeAvailability, getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeInvoiceLayoutConfig, normalizeInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings } from "./utils";
21
+ export { computeAvailability, getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeInvoiceLayoutConfig, normalizeInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings, resolveInvoiceReceiptLocales } from "./utils";
22
22
  export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
23
23
  _inherits(OpenDataModule, _BaseModule);
24
24
  var _super = _createSuper(OpenDataModule);
@@ -1,6 +1,11 @@
1
1
  import type { OpenDataConfig, OpenDataAvailabilityResult, ComputeAvailabilityParams, InvoiceLayoutConfig, InvoiceTemplateSettings } from './types';
2
2
  export declare function getDefaultInvoiceLayoutConfig(): InvoiceLayoutConfig;
3
3
  export declare function getDefaultInvoiceTemplateSettings(): InvoiceTemplateSettings;
4
+ /**
5
+ * 将非 DEFAULT Invoice 模板启用的语言转换为 small_ticket_data locale。
6
+ * cn_en 是中英组合打印模式,因此展开为 en 与 zh_CN 两份数据。
7
+ */
8
+ export declare function resolveInvoiceReceiptLocales(settings?: InvoiceTemplateSettings | null): string[];
4
9
  /**
5
10
  * 规范化已经提取出的公开 template_settings 值,供打印入口复用。
6
11
  */
@@ -3,9 +3,16 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
3
3
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
4
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
5
5
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
7
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
8
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
9
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
10
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
11
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
6
12
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
7
13
  import dayjs from 'dayjs';
8
14
  import { getDateIsInSchedule } from "../Schedule/getDateIsInSchedule";
15
+ import { INVOICE_MODULE_KEYS } from "./types";
9
16
  function isRecord(value) {
10
17
  return !!value && _typeof(value) === 'object' && !Array.isArray(value);
11
18
  }
@@ -22,7 +29,12 @@ function parseInvoiceRecord(value) {
22
29
  }
23
30
  export function getDefaultInvoiceLayoutConfig() {
24
31
  return {
25
- module: []
32
+ module: INVOICE_MODULE_KEYS.map(function (key) {
33
+ return {
34
+ key: key,
35
+ is_show: 1
36
+ };
37
+ })
26
38
  };
27
39
  }
28
40
  export function getDefaultInvoiceTemplateSettings() {
@@ -32,6 +44,42 @@ export function getDefaultInvoiceTemplateSettings() {
32
44
  modules: []
33
45
  };
34
46
  }
47
+ var INVOICE_RECEIPT_LOCALE_ORDER = ['en', 'zh_CN', 'zh_HK', 'ja', 'pt'];
48
+ var INVOICE_RECEIPT_LOCALE_MAPPING = {
49
+ en: ['en'],
50
+ zh_cn: ['zh_CN'],
51
+ zh_hk: ['zh_HK'],
52
+ ja: ['ja'],
53
+ pt: ['pt'],
54
+ cn_en: ['en', 'zh_CN']
55
+ };
56
+
57
+ /**
58
+ * 将非 DEFAULT Invoice 模板启用的语言转换为 small_ticket_data locale。
59
+ * cn_en 是中英组合打印模式,因此展开为 en 与 zh_CN 两份数据。
60
+ */
61
+ export function resolveInvoiceReceiptLocales(settings) {
62
+ if (typeof (settings === null || settings === void 0 ? void 0 : settings.template) !== 'string' || settings.template.trim().length === 0 || settings.template.trim().toUpperCase() === 'DEFAULT' || !isRecord(settings.language)) {
63
+ return [];
64
+ }
65
+ var enabledLocales = new Set();
66
+ Object.entries(settings.language).forEach(function (_ref) {
67
+ var _INVOICE_RECEIPT_LOCA;
68
+ var _ref2 = _slicedToArray(_ref, 2),
69
+ rawKey = _ref2[0],
70
+ count = _ref2[1];
71
+ if (typeof count !== 'number' || !Number.isFinite(count) || count <= 0) {
72
+ return;
73
+ }
74
+ var key = rawKey.trim().toLowerCase().replace(/-/g, '_');
75
+ (_INVOICE_RECEIPT_LOCA = INVOICE_RECEIPT_LOCALE_MAPPING[key]) === null || _INVOICE_RECEIPT_LOCA === void 0 || _INVOICE_RECEIPT_LOCA.forEach(function (locale) {
76
+ enabledLocales.add(locale);
77
+ });
78
+ });
79
+ return INVOICE_RECEIPT_LOCALE_ORDER.filter(function (locale) {
80
+ return enabledLocales.has(locale);
81
+ });
82
+ }
35
83
  function normalizeInvoiceTemplate(value) {
36
84
  if (typeof value !== 'string' || value.trim().length === 0) return 'DEFAULT';
37
85
  return value.trim().toUpperCase() === 'DEFAULT' ? 'DEFAULT' : value;
@@ -82,8 +130,10 @@ export function normalizeInvoiceTemplateSettings(config) {
82
130
  * 将 invoice_edit.modules 原样投影为 Web Invoice 使用的 module 字段。
83
131
  */
84
132
  export function normalizeInvoiceLayoutConfig(config) {
133
+ var modules = normalizeInvoiceTemplateSettings(config).modules;
134
+ if (modules.length === 0) return getDefaultInvoiceLayoutConfig();
85
135
  return {
86
- module: normalizeInvoiceTemplateSettings(config).modules
136
+ module: modules
87
137
  };
88
138
  }
89
139
  function toBoolean(value) {
@@ -532,6 +532,11 @@ declare class Server {
532
532
  private handleOrderDraftSubmit;
533
533
  private handlePendingSyncCheckoutOrder;
534
534
  private buildPendingSyncCheckoutOrder;
535
+ /**
536
+ * Checkout 与本地小票必须消费同一份规范化子项快照。
537
+ * 商品/预约只折叠持久化 ID 或协议 UID 相同的行;支付额外兼容 payment_number。
538
+ */
539
+ private normalizeCheckoutCollections;
535
540
  /**
536
541
  * Android 结账自动小票由当前设备设置控制;其它平台保持原有行为。
537
542
  */
@@ -43,7 +43,8 @@ import { filterBookingsFromOrders, sortBookings } from "./modules/order/utils/fi
43
43
  import { buildSmallTicketData, hasSmallTicketData } from "./utils/small-ticket";
44
44
  import { BaseSalesImpl } from "../solution/BaseSales";
45
45
  import { getOrderPaymentIdentityKeys, isIdentifiedPendingOrderPayment, isPendingOrderPayment, mergeOrderPaymentListsByIdentity } from "../modules/Order/payment-utils";
46
- import { getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings } from "../modules/OpenData";
46
+ import { normalizeOrderCollections } from "../modules/Order/utils/orderCollectionIdentity";
47
+ import { getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings, resolveInvoiceReceiptLocales } from "../modules/OpenData";
47
48
  var OS_FULFILLMENT_REF_MODE_FIELD = '_os_fulfillment_ref_mode';
48
49
  var OS_INVOICE_LAYOUT_CONFIG_FIELD = '_os_invoice_layout_config';
49
50
  var OS_INVOICE_TEMPLATE_SETTINGS_FIELD = '_os_invoice_template_settings';
@@ -2435,7 +2436,7 @@ var Server = /*#__PURE__*/function () {
2435
2436
  return this.ensureCheckoutOrderNumbers(normalizedData, title);
2436
2437
  case 6:
2437
2438
  numberedData = _context31.sent;
2438
- checkoutData = this.applyCheckoutFulfillmentBuzzer(numberedData, title);
2439
+ checkoutData = this.normalizeCheckoutCollections(this.applyCheckoutFulfillmentBuzzer(numberedData, title));
2439
2440
  remoteCheckoutData = this.buildRemoteCheckoutData(checkoutData, title);
2440
2441
  if ((_this$app5 = this.app) !== null && _this$app5 !== void 0 && (_this$app5 = _this$app5.request) !== null && _this$app5 !== void 0 && _this$app5.post) {
2441
2442
  _context31.next = 11;
@@ -5751,17 +5752,16 @@ var Server = /*#__PURE__*/function () {
5751
5752
  device_id: (_params$deviceId = params.deviceId) !== null && _params$deviceId !== void 0 ? _params$deviceId : deviceId,
5752
5753
  payload: {
5753
5754
  type: params.isManualPrint ? '0' : '99',
5755
+ template_settings: this.normalizePrintInvoiceTemplateSettings(params.invoiceTemplateSettings),
5754
5756
  data: params.receiptOnly ? {
5755
5757
  order_id: printIdentity,
5756
5758
  small_ticket_data: (_params$syncedOrder = params.syncedOrder) === null || _params$syncedOrder === void 0 || (_params$syncedOrder = _params$syncedOrder.payment_info) === null || _params$syncedOrder === void 0 ? void 0 : _params$syncedOrder.small_ticket_data,
5757
- template_settings: this.normalizePrintInvoiceTemplateSettings(params.invoiceTemplateSettings),
5758
5759
  skip_wristband: true,
5759
5760
  skip_voucher: true
5760
5761
  } : {
5761
5762
  order_id: printIdentity,
5762
5763
  machine_code_print_info: (_params$syncedOrder2 = params.syncedOrder) === null || _params$syncedOrder2 === void 0 || (_params$syncedOrder2 = _params$syncedOrder2.payment_info) === null || _params$syncedOrder2 === void 0 ? void 0 : _params$syncedOrder2.machine_code_print_info,
5763
5764
  machine_code_print_info_v2: (_params$syncedOrder3 = params.syncedOrder) === null || _params$syncedOrder3 === void 0 ? void 0 : _params$syncedOrder3.machine_code_print_info_v2,
5764
- template_settings: this.normalizePrintInvoiceTemplateSettings(params.invoiceTemplateSettings),
5765
5765
  skip_receipt: true
5766
5766
  }
5767
5767
  },
@@ -5825,7 +5825,8 @@ var Server = /*#__PURE__*/function () {
5825
5825
  case 2:
5826
5826
  _context58.next = 4;
5827
5827
  return this.withLocalSmallTicketData(params.order, {
5828
- requireFullyPaid: params.requireFullyPaid
5828
+ requireFullyPaid: params.requireFullyPaid,
5829
+ invoiceTemplateSettings: params.invoiceTemplateSettings
5829
5830
  });
5830
5831
  case 4:
5831
5832
  printableOrder = _context58.sent;
@@ -6086,13 +6087,14 @@ var Server = /*#__PURE__*/function () {
6086
6087
  return this.ensureCheckoutOrderNumbers(normalizedData, title);
6087
6088
  case 14:
6088
6089
  numberedData = _context60.sent;
6089
- checkoutData = this.applyCheckoutFulfillmentBuzzer(numberedData, title);
6090
+ checkoutData = this.normalizeCheckoutCollections(this.applyCheckoutFulfillmentBuzzer(numberedData, title));
6090
6091
  _context60.next = 18;
6091
6092
  return this.handlePendingSyncCheckoutOrder({
6092
6093
  backendPath: backendPath,
6093
6094
  data: checkoutData,
6094
6095
  title: title,
6095
- reason: 'checkout 已转入设备任务同步'
6096
+ reason: 'checkout 已转入设备任务同步',
6097
+ invoiceTemplateSettings: invoiceTemplateSettings
6096
6098
  });
6097
6099
  case 18:
6098
6100
  pendingResult = _context60.sent;
@@ -6339,13 +6341,13 @@ var Server = /*#__PURE__*/function () {
6339
6341
  value: function () {
6340
6342
  var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
6341
6343
  var _this14 = this;
6342
- var backendPath, data, title, reason, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
6344
+ var backendPath, data, title, reason, invoiceTemplateSettings, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
6343
6345
  return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6344
6346
  while (1) switch (_context63.prev = _context63.next) {
6345
6347
  case 0:
6346
- backendPath = params.backendPath, data = params.data, title = params.title, reason = params.reason;
6348
+ backendPath = params.backendPath, data = params.data, title = params.title, reason = params.reason, invoiceTemplateSettings = params.invoiceTemplateSettings;
6347
6349
  _context63.next = 3;
6348
- return this.buildPendingSyncCheckoutOrder(data);
6350
+ return this.buildPendingSyncCheckoutOrder(data, invoiceTemplateSettings);
6349
6351
  case 3:
6350
6352
  pendingOrder = _context63.sent;
6351
6353
  if (pendingOrder) {
@@ -6436,7 +6438,7 @@ var Server = /*#__PURE__*/function () {
6436
6438
  }, {
6437
6439
  key: "buildPendingSyncCheckoutOrder",
6438
6440
  value: function () {
6439
- var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(data) {
6441
+ var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(data, invoiceTemplateSettings) {
6440
6442
  var hasStorageKey, pendingOrder, productMap, orderWithProductTitles;
6441
6443
  return _regeneratorRuntime().wrap(function _callee64$(_context64) {
6442
6444
  while (1) switch (_context64.prev = _context64.next) {
@@ -6454,10 +6456,10 @@ var Server = /*#__PURE__*/function () {
6454
6456
  }
6455
6457
  return _context64.abrupt("return", null);
6456
6458
  case 5:
6457
- pendingOrder = _objectSpread(_objectSpread({}, data), {}, {
6459
+ pendingOrder = this.normalizeCheckoutCollections(_objectSpread(_objectSpread({}, data), {}, {
6458
6460
  need_sync: 1,
6459
6461
  is_draft_order: 0
6460
- });
6462
+ }));
6461
6463
  _context64.next = 8;
6462
6464
  return this.buildSmallTicketProductMap(pendingOrder);
6463
6465
  case 8:
@@ -6465,7 +6467,8 @@ var Server = /*#__PURE__*/function () {
6465
6467
  orderWithProductTitles = this.withPendingSyncProductTitles(pendingOrder, productMap);
6466
6468
  return _context64.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
6467
6469
  requireFullyPaid: true,
6468
- productMap: productMap
6470
+ productMap: productMap,
6471
+ invoiceTemplateSettings: invoiceTemplateSettings
6469
6472
  }));
6470
6473
  case 11:
6471
6474
  case "end":
@@ -6473,11 +6476,28 @@ var Server = /*#__PURE__*/function () {
6473
6476
  }
6474
6477
  }, _callee64, this);
6475
6478
  }));
6476
- function buildPendingSyncCheckoutOrder(_x71) {
6479
+ function buildPendingSyncCheckoutOrder(_x71, _x72) {
6477
6480
  return _buildPendingSyncCheckoutOrder.apply(this, arguments);
6478
6481
  }
6479
6482
  return buildPendingSyncCheckoutOrder;
6480
6483
  }()
6484
+ /**
6485
+ * Checkout 与本地小票必须消费同一份规范化子项快照。
6486
+ * 商品/预约只折叠持久化 ID 或协议 UID 相同的行;支付额外兼容 payment_number。
6487
+ */
6488
+ }, {
6489
+ key: "normalizeCheckoutCollections",
6490
+ value: function normalizeCheckoutCollections(data) {
6491
+ if (!data || _typeof(data) !== 'object' || Array.isArray(data)) return data;
6492
+ var normalized = normalizeOrderCollections(data, {
6493
+ ensureUid: false
6494
+ }).order;
6495
+ if (Array.isArray(normalized.payments)) {
6496
+ normalized.payments = mergeOrderPaymentListsByIdentity([], normalized.payments);
6497
+ }
6498
+ return normalized;
6499
+ }
6500
+
6481
6501
  /**
6482
6502
  * Android 结账自动小票由当前设备设置控制;其它平台保持原有行为。
6483
6503
  */
@@ -6610,7 +6630,7 @@ var Server = /*#__PURE__*/function () {
6610
6630
  }
6611
6631
  }, _callee65, null, [[0, 7]]);
6612
6632
  }));
6613
- return function (_x73) {
6633
+ return function (_x74) {
6614
6634
  return _ref70.apply(this, arguments);
6615
6635
  };
6616
6636
  }()));
@@ -6630,7 +6650,7 @@ var Server = /*#__PURE__*/function () {
6630
6650
  }
6631
6651
  }, _callee66, this);
6632
6652
  }));
6633
- function buildSmallTicketProductMap(_x72) {
6653
+ function buildSmallTicketProductMap(_x73) {
6634
6654
  return _buildSmallTicketProductMap.apply(this, arguments);
6635
6655
  }
6636
6656
  return buildSmallTicketProductMap;
@@ -6693,7 +6713,7 @@ var Server = /*#__PURE__*/function () {
6693
6713
  }
6694
6714
  }, _callee67, this, [[4, 10]]);
6695
6715
  }));
6696
- function buildSalesDetailProductSnapshotMap(_x74) {
6716
+ function buildSalesDetailProductSnapshotMap(_x75) {
6697
6717
  return _buildSalesDetailProductSnapshotMap.apply(this, arguments);
6698
6718
  }
6699
6719
  return buildSalesDetailProductSnapshotMap;
@@ -6795,7 +6815,7 @@ var Server = /*#__PURE__*/function () {
6795
6815
  }
6796
6816
  }, _callee68, this);
6797
6817
  }));
6798
- function withSalesDetailProductSnapshots(_x75) {
6818
+ function withSalesDetailProductSnapshots(_x76) {
6799
6819
  return _withSalesDetailProductSnapshots.apply(this, arguments);
6800
6820
  }
6801
6821
  return withSalesDetailProductSnapshots;
@@ -6998,7 +7018,7 @@ var Server = /*#__PURE__*/function () {
6998
7018
  }
6999
7019
  }, _callee69, this, [[4, 21]]);
7000
7020
  }));
7001
- function enrichPaymentNamesByCode(_x76) {
7021
+ function enrichPaymentNamesByCode(_x77) {
7002
7022
  return _enrichPaymentNamesByCode.apply(this, arguments);
7003
7023
  }
7004
7024
  return enrichPaymentNamesByCode;
@@ -7045,6 +7065,7 @@ var Server = /*#__PURE__*/function () {
7045
7065
  smallTicketData = buildSmallTicketData({
7046
7066
  order: enrichedOrder,
7047
7067
  shopInfo: this.getSmallTicketShopInfo(),
7068
+ locales: resolveInvoiceReceiptLocales(options === null || options === void 0 ? void 0 : options.invoiceTemplateSettings),
7048
7069
  productMap: productMap
7049
7070
  });
7050
7071
  return _context70.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
@@ -7065,7 +7086,7 @@ var Server = /*#__PURE__*/function () {
7065
7086
  }
7066
7087
  }, _callee70, this, [[4, 20]]);
7067
7088
  }));
7068
- function withLocalSmallTicketData(_x77, _x78) {
7089
+ function withLocalSmallTicketData(_x78, _x79) {
7069
7090
  return _withLocalSmallTicketData.apply(this, arguments);
7070
7091
  }
7071
7092
  return withLocalSmallTicketData;
@@ -7234,7 +7255,7 @@ var Server = /*#__PURE__*/function () {
7234
7255
  }
7235
7256
  }, _callee71, this, [[7, 37]]);
7236
7257
  }));
7237
- function fetchAndPersistSalesOrderByLookup(_x79, _x80, _x81) {
7258
+ function fetchAndPersistSalesOrderByLookup(_x80, _x81, _x82) {
7238
7259
  return _fetchAndPersistSalesOrderByLookup.apply(this, arguments);
7239
7260
  }
7240
7261
  return fetchAndPersistSalesOrderByLookup;
@@ -7476,7 +7497,7 @@ var Server = /*#__PURE__*/function () {
7476
7497
  }
7477
7498
  }, _callee72, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
7478
7499
  }));
7479
- function handleUpdateLocalOrdersBatch(_x82) {
7500
+ function handleUpdateLocalOrdersBatch(_x83) {
7480
7501
  return _handleUpdateLocalOrdersBatch.apply(this, arguments);
7481
7502
  }
7482
7503
  return handleUpdateLocalOrdersBatch;
@@ -7968,7 +7989,7 @@ var Server = /*#__PURE__*/function () {
7968
7989
  }
7969
7990
  }, _callee74, this);
7970
7991
  }));
7971
- function computeOrderQueryResult(_x83) {
7992
+ function computeOrderQueryResult(_x84) {
7972
7993
  return _computeOrderQueryResult.apply(this, arguments);
7973
7994
  }
7974
7995
  return computeOrderQueryResult;
@@ -8022,7 +8043,7 @@ var Server = /*#__PURE__*/function () {
8022
8043
  }
8023
8044
  }, _callee75, this);
8024
8045
  }));
8025
- function computeBookingQueryResult(_x84) {
8046
+ function computeBookingQueryResult(_x85) {
8026
8047
  return _computeBookingQueryResult.apply(this, arguments);
8027
8048
  }
8028
8049
  return computeBookingQueryResult;
@@ -8387,7 +8408,7 @@ var Server = /*#__PURE__*/function () {
8387
8408
  }
8388
8409
  }, _callee76, this);
8389
8410
  }));
8390
- function computeProductQueryResult(_x85, _x86) {
8411
+ function computeProductQueryResult(_x86, _x87) {
8391
8412
  return _computeProductQueryResult.apply(this, arguments);
8392
8413
  }
8393
8414
  return computeProductQueryResult;
@@ -8488,7 +8509,7 @@ var Server = /*#__PURE__*/function () {
8488
8509
  }
8489
8510
  }, _callee77, this, [[4, 24, 27, 30], [8, 16]]);
8490
8511
  }));
8491
- function recomputeAndNotifyProductQuery(_x87) {
8512
+ function recomputeAndNotifyProductQuery(_x88) {
8492
8513
  return _recomputeAndNotifyProductQuery.apply(this, arguments);
8493
8514
  }
8494
8515
  return recomputeAndNotifyProductQuery;
@@ -95,6 +95,58 @@ var LABELS = {
95
95
  rounding: '抹零',
96
96
  gross: '重量',
97
97
  tare: '去皮'
98
+ },
99
+ ja: {
100
+ contactName: '連絡先名',
101
+ contactMobile: '連絡先電話',
102
+ email: 'メール',
103
+ dineIn: '店内飲食',
104
+ takeAway: 'テイクアウト',
105
+ delivery: '配達',
106
+ pickUp: '受け取り',
107
+ shopService: '店内飲食',
108
+ pickUpTime: '受取時間',
109
+ asap: 'できるだけ早く',
110
+ cash: '現金',
111
+ eftpos: 'カード',
112
+ wallet: 'ウォレット',
113
+ giftCard: 'ギフトカード',
114
+ remainingAmount: '残高',
115
+ redeemPoints: '利用ポイント',
116
+ remainingPoints: '残りポイント',
117
+ table: 'テーブル',
118
+ orderDiscount: '注文割引',
119
+ manualDiscount: '手動割引',
120
+ payProcessingFee: '決済手数料',
121
+ rounding: '端数調整',
122
+ gross: '総重量',
123
+ tare: '風袋'
124
+ },
125
+ pt: {
126
+ contactName: 'Nome de contato',
127
+ contactMobile: 'Celular de contato',
128
+ email: 'e-mail',
129
+ dineIn: 'Consumo no local',
130
+ takeAway: 'Para levar',
131
+ delivery: 'Entrega',
132
+ pickUp: 'Recolha',
133
+ shopService: 'Consumo no local',
134
+ pickUpTime: 'Hora de recolha',
135
+ asap: 'Assim que possível',
136
+ cash: 'Dinheiro',
137
+ eftpos: 'Cartão',
138
+ wallet: 'Carteira',
139
+ giftCard: 'Cartão-presente',
140
+ remainingAmount: 'Saldo restante',
141
+ redeemPoints: 'Pontos utilizados',
142
+ remainingPoints: 'Pontos restantes',
143
+ table: 'Mesa',
144
+ orderDiscount: 'Desconto do pedido',
145
+ manualDiscount: 'Desconto manual',
146
+ payProcessingFee: 'Taxa de processamento',
147
+ rounding: 'Arredondamento',
148
+ gross: 'Peso bruto',
149
+ tare: 'Tara'
98
150
  }
99
151
  };
100
152
  export function buildSmallTicketData(params) {
@@ -253,11 +253,15 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
253
253
  }, {
254
254
  key: "getBookingTicketBusinessCode",
255
255
  value: function getBookingTicketBusinessCode() {
256
- var _this$otherParams$bus, _this$otherParams2, _this$otherParams3;
257
- var businessCode = (_this$otherParams$bus = (_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.businessCode) !== null && _this$otherParams$bus !== void 0 ? _this$otherParams$bus : (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.business_code;
258
- if (businessCode === undefined || businessCode === null) return null;
259
- var normalized = String(businessCode).trim();
260
- return normalized || null;
256
+ var _this$otherParams2, _this$otherParams3, _this$getOrderHeader, _this$store$order, _this$getSalesOrder;
257
+ var candidates = [(_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.businessCode, (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.business_code, (_this$getOrderHeader = this.getOrderHeader()) === null || _this$getOrderHeader === void 0 ? void 0 : _this$getOrderHeader.business_code, (_this$store$order = this.store.order) === null || _this$store$order === void 0 || (_this$store$order = _this$store$order.getTempOrder()) === null || _this$store$order === void 0 ? void 0 : _this$store$order.business_code, (_this$getSalesOrder = this.getSalesOrder()) === null || _this$getSalesOrder === void 0 || (_this$getSalesOrder = _this$getSalesOrder.raw) === null || _this$getSalesOrder === void 0 ? void 0 : _this$getSalesOrder.business_code];
258
+ for (var _i = 0, _candidates = candidates; _i < _candidates.length; _i++) {
259
+ var candidate = _candidates[_i];
260
+ if (candidate === undefined || candidate === null) continue;
261
+ var normalized = String(candidate).trim();
262
+ if (normalized) return normalized;
263
+ }
264
+ return null;
261
265
  }
262
266
  }, {
263
267
  key: "getIdGeneratorPlugin",
@@ -916,12 +920,12 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
916
920
  key: "setBookingStatus",
917
921
  value: (function () {
918
922
  var _setBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(status) {
919
- var _this$store$order, _this$store$order$get;
923
+ var _this$store$order2, _this$store$order2$ge;
920
924
  var tempOrder, orderId, scheduleId, bookings, previous, _data, res;
921
925
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
922
926
  while (1) switch (_context12.prev = _context12.next) {
923
927
  case 0:
924
- tempOrder = (_this$store$order = this.store.order) === null || _this$store$order === void 0 || (_this$store$order$get = _this$store$order.getTempOrder) === null || _this$store$order$get === void 0 ? void 0 : _this$store$order$get.call(_this$store$order);
928
+ tempOrder = (_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 || (_this$store$order2$ge = _this$store$order2.getTempOrder) === null || _this$store$order2$ge === void 0 ? void 0 : _this$store$order2$ge.call(_this$store$order2);
925
929
  if (tempOrder) {
926
930
  _context12.next = 3;
927
931
  break;
@@ -1000,7 +1004,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1000
1004
  key: "transitionChildBooking",
1001
1005
  value: (function () {
1002
1006
  var _transitionChildBooking = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(params) {
1003
- var _this$store$order2, _this$store$order2$ge;
1007
+ var _this$store$order3, _this$store$order3$ge;
1004
1008
  var schedule_event_id, action, tempOrder, orderId, bookings, targetStatus, previous, _data2, res;
1005
1009
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1006
1010
  while (1) switch (_context13.prev = _context13.next) {
@@ -1018,7 +1022,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1018
1022
  }
1019
1023
  throw new Error('transitionChildBooking: action 不能为空');
1020
1024
  case 5:
1021
- tempOrder = (_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 || (_this$store$order2$ge = _this$store$order2.getTempOrder) === null || _this$store$order2$ge === void 0 ? void 0 : _this$store$order2$ge.call(_this$store$order2);
1025
+ tempOrder = (_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 || (_this$store$order3$ge = _this$store$order3.getTempOrder) === null || _this$store$order3$ge === void 0 ? void 0 : _this$store$order3$ge.call(_this$store$order3);
1022
1026
  if (tempOrder) {
1023
1027
  _context13.next = 8;
1024
1028
  break;
@@ -1085,7 +1089,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1085
1089
  key: "refreshSalesDetail",
1086
1090
  value: (function () {
1087
1091
  var _refreshSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
1088
- var _this$store$order3, _this$store$order3$ge;
1092
+ var _this$store$order4, _this$store$order4$ge;
1089
1093
  var params,
1090
1094
  tempOrder,
1091
1095
  orderId,
@@ -1094,7 +1098,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1094
1098
  while (1) switch (_context14.prev = _context14.next) {
1095
1099
  case 0:
1096
1100
  params = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : {};
1097
- tempOrder = (_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 || (_this$store$order3$ge = _this$store$order3.getTempOrder) === null || _this$store$order3$ge === void 0 ? void 0 : _this$store$order3$ge.call(_this$store$order3);
1101
+ tempOrder = (_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 || (_this$store$order4$ge = _this$store$order4.getTempOrder) === null || _this$store$order4$ge === void 0 ? void 0 : _this$store$order4$ge.call(_this$store$order4);
1098
1102
  if (tempOrder) {
1099
1103
  _context14.next = 4;
1100
1104
  break;
@@ -1377,8 +1381,8 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1377
1381
  }, {
1378
1382
  key: "getCart",
1379
1383
  value: function getCart() {
1380
- var _this$store$order$get2, _this$store$order4, _salesDetail$bookings, _operatingDayBoundary, _operatingDayBoundary2, _tempOrder$_extend;
1381
- var tempOrder = (_this$store$order$get2 = (_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 ? void 0 : _this$store$order4.getTempOrder()) !== null && _this$store$order$get2 !== void 0 ? _this$store$order$get2 : null;
1384
+ var _this$store$order$get, _this$store$order5, _salesDetail$bookings, _operatingDayBoundary, _operatingDayBoundary2, _tempOrder$_extend;
1385
+ var tempOrder = (_this$store$order$get = (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 ? void 0 : _this$store$order5.getTempOrder()) !== null && _this$store$order$get !== void 0 ? _this$store$order$get : null;
1382
1386
  var salesDetail = this.getSalesOrder();
1383
1387
  var bookings = (_salesDetail$bookings = salesDetail === null || salesDetail === void 0 ? void 0 : salesDetail.bookings) !== null && _salesDetail$bookings !== void 0 ? _salesDetail$bookings : (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.bookings) || [];
1384
1388
  var operatingDayBoundary;
@@ -1665,13 +1669,13 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1665
1669
  }, {
1666
1670
  key: "setOrderCustomer",
1667
1671
  value: function setOrderCustomer(customer, options) {
1668
- var _this$store$order$get3,
1672
+ var _this$store$order$get2,
1669
1673
  _this3 = this;
1670
1674
  if (!customer) {
1671
1675
  this.clearOrderCustomer();
1672
1676
  return;
1673
1677
  }
1674
- var previousCustomerId = (_this$store$order$get3 = this.store.order.getOrderCustomer()) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.customer_id;
1678
+ var previousCustomerId = (_this$store$order$get2 = this.store.order.getOrderCustomer()) === null || _this$store$order$get2 === void 0 ? void 0 : _this$store$order$get2.customer_id;
1675
1679
  var snapshotBeforeSet = this.store.order.getOrderCustomerSnapshot();
1676
1680
  var patch = formatOrderCustomerPatch(customer);
1677
1681
  var customerUnchanged = Number(previousCustomerId || 0) === Number(patch.customer_id || 0);
@@ -2428,10 +2432,10 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2428
2432
  }, {
2429
2433
  key: "buildAddProductCtx",
2430
2434
  value: function buildAddProductCtx(extra) {
2431
- var _extra$date2, _ref12, _this$getOrderCustome4, _this$getOrderCustome5, _this$store$order$get4, _extra$presetStartTim2;
2435
+ var _extra$date2, _ref12, _this$getOrderCustome4, _this$getOrderCustome5, _this$store$order$get3, _extra$presetStartTim2;
2432
2436
  var bookingContextState = this.store.bookingContext.getState();
2433
2437
  var date = (_extra$date2 = extra === null || extra === void 0 ? void 0 : extra.date) !== null && _extra$date2 !== void 0 ? _extra$date2 : bookingContextState.date;
2434
- var orderCustomerId = (_ref12 = (_this$getOrderCustome4 = (_this$getOrderCustome5 = this.getOrderCustomerSnapshot()) === null || _this$getOrderCustome5 === void 0 ? void 0 : _this$getOrderCustome5.id) !== null && _this$getOrderCustome4 !== void 0 ? _this$getOrderCustome4 : (_this$store$order$get4 = this.store.order.getTempOrder()) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.customer_id) !== null && _ref12 !== void 0 ? _ref12 : undefined;
2438
+ var orderCustomerId = (_ref12 = (_this$getOrderCustome4 = (_this$getOrderCustome5 = this.getOrderCustomerSnapshot()) === null || _this$getOrderCustome5 === void 0 ? void 0 : _this$getOrderCustome5.id) !== null && _this$getOrderCustome4 !== void 0 ? _this$getOrderCustome4 : (_this$store$order$get3 = this.store.order.getTempOrder()) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.customer_id) !== null && _ref12 !== void 0 ? _ref12 : undefined;
2435
2439
  return _objectSpread(_objectSpread({
2436
2440
  bookingConfig: bookingContextState.bookingConfig,
2437
2441
  resourcesOrigin: bookingContextState.resourcesOrigin,
@@ -2987,7 +2991,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2987
2991
  key: "handleRedeem",
2988
2992
  value: function () {
2989
2993
  var _handleRedeem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
2990
- var _this$store$order5, _this$store$order5$ge, _this$store$order6, _ref20, _tempOrder$order_id2;
2994
+ var _this$store$order6, _this$store$order6$ge, _this$store$order7, _ref20, _tempOrder$order_id2;
2991
2995
  var voucherIds, status, voucherIdSet, tempOrder, vouchers, hasUpdatedVoucher, nextVouchers, identity, externalSaleNumber, orderId, orderLookup;
2992
2996
  return _regeneratorRuntime().wrap(function _callee36$(_context36) {
2993
2997
  while (1) switch (_context36.prev = _context36.next) {
@@ -3003,8 +3007,8 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3003
3007
  }
3004
3008
  });
3005
3009
  voucherIdSet = new Set(voucherIds);
3006
- tempOrder = (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 || (_this$store$order5$ge = _this$store$order5.getTempOrder) === null || _this$store$order5$ge === void 0 ? void 0 : _this$store$order5$ge.call(_this$store$order5);
3007
- vouchers = (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.vouchers) || ((_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getVouchers()) || [];
3010
+ tempOrder = (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 || (_this$store$order6$ge = _this$store$order6.getTempOrder) === null || _this$store$order6$ge === void 0 ? void 0 : _this$store$order6$ge.call(_this$store$order6);
3011
+ vouchers = (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.vouchers) || ((_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 ? void 0 : _this$store$order7.getVouchers()) || [];
3008
3012
  hasUpdatedVoucher = false;
3009
3013
  nextVouchers = vouchers.map(function (voucher) {
3010
3014
  if (!voucherIdSet.has(voucher.voucher_id)) return voucher;
@@ -1 +1,46 @@
1
- "use strict";
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _examples.BUY_X_GET_Y_FREE_STRATEGY;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _examples.ITEM_REWARD_STRATEGY;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "PromotionAdapter", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _adapter.PromotionAdapter;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "PromotionEvaluator", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _evaluator.PromotionEvaluator;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "default", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _adapter.default;
40
+ }
41
+ });
42
+ var _evaluator = require("./evaluator");
43
+ var _adapter = _interopRequireWildcard(require("./adapter"));
44
+ var _examples = require("./examples");
45
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
46
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -3,7 +3,7 @@ import { BaseModule } from '../BaseModule';
3
3
  import type { ScheduleModule } from '../Schedule';
4
4
  import type { OpenDataConfig, OpenDataFetchParams, OpenDataAvailabilityResult, InvoiceLayoutConfig, InvoiceTemplateSettings } from './types';
5
5
  export * from './types';
6
- export { computeAvailability, getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeInvoiceLayoutConfig, normalizeInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings, } from './utils';
6
+ export { computeAvailability, getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeInvoiceLayoutConfig, normalizeInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings, resolveInvoiceReceiptLocales, } from './utils';
7
7
  export declare class OpenDataModule extends BaseModule implements Module {
8
8
  protected defaultName: string;
9
9
  protected defaultVersion: string;
@@ -10,7 +10,8 @@ var _exportNames = {
10
10
  getDefaultInvoiceTemplateSettings: true,
11
11
  normalizeInvoiceLayoutConfig: true,
12
12
  normalizeInvoiceTemplateSettings: true,
13
- normalizeRawInvoiceTemplateSettings: true
13
+ normalizeRawInvoiceTemplateSettings: true,
14
+ resolveInvoiceReceiptLocales: true
14
15
  };
15
16
  exports.OpenDataModule = void 0;
16
17
  Object.defineProperty(exports, "computeAvailability", {
@@ -49,6 +50,12 @@ Object.defineProperty(exports, "normalizeRawInvoiceTemplateSettings", {
49
50
  return _utils.normalizeRawInvoiceTemplateSettings;
50
51
  }
51
52
  });
53
+ Object.defineProperty(exports, "resolveInvoiceReceiptLocales", {
54
+ enumerable: true,
55
+ get: function () {
56
+ return _utils.resolveInvoiceReceiptLocales;
57
+ }
58
+ });
52
59
  var _BaseModule = require("../BaseModule");
53
60
  var _utils = require("./utils");
54
61
  var _types = require("./types");
@@ -1,6 +1,11 @@
1
1
  import type { OpenDataConfig, OpenDataAvailabilityResult, ComputeAvailabilityParams, InvoiceLayoutConfig, InvoiceTemplateSettings } from './types';
2
2
  export declare function getDefaultInvoiceLayoutConfig(): InvoiceLayoutConfig;
3
3
  export declare function getDefaultInvoiceTemplateSettings(): InvoiceTemplateSettings;
4
+ /**
5
+ * 将非 DEFAULT Invoice 模板启用的语言转换为 small_ticket_data locale。
6
+ * cn_en 是中英组合打印模式,因此展开为 en 与 zh_CN 两份数据。
7
+ */
8
+ export declare function resolveInvoiceReceiptLocales(settings?: InvoiceTemplateSettings | null): string[];
4
9
  /**
5
10
  * 规范化已经提取出的公开 template_settings 值,供打印入口复用。
6
11
  */
@@ -9,8 +9,10 @@ exports.getDefaultInvoiceTemplateSettings = getDefaultInvoiceTemplateSettings;
9
9
  exports.normalizeInvoiceLayoutConfig = normalizeInvoiceLayoutConfig;
10
10
  exports.normalizeInvoiceTemplateSettings = normalizeInvoiceTemplateSettings;
11
11
  exports.normalizeRawInvoiceTemplateSettings = normalizeRawInvoiceTemplateSettings;
12
+ exports.resolveInvoiceReceiptLocales = resolveInvoiceReceiptLocales;
12
13
  var _dayjs = _interopRequireDefault(require("dayjs"));
13
14
  var _getDateIsInSchedule = require("../Schedule/getDateIsInSchedule");
15
+ var _types = require("./types");
14
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
17
  function isRecord(value) {
16
18
  return !!value && typeof value === 'object' && !Array.isArray(value);
@@ -28,7 +30,10 @@ function parseInvoiceRecord(value) {
28
30
  }
29
31
  function getDefaultInvoiceLayoutConfig() {
30
32
  return {
31
- module: []
33
+ module: _types.INVOICE_MODULE_KEYS.map(key => ({
34
+ key,
35
+ is_show: 1
36
+ }))
32
37
  };
33
38
  }
34
39
  function getDefaultInvoiceTemplateSettings() {
@@ -38,6 +43,36 @@ function getDefaultInvoiceTemplateSettings() {
38
43
  modules: []
39
44
  };
40
45
  }
46
+ const INVOICE_RECEIPT_LOCALE_ORDER = ['en', 'zh_CN', 'zh_HK', 'ja', 'pt'];
47
+ const INVOICE_RECEIPT_LOCALE_MAPPING = {
48
+ en: ['en'],
49
+ zh_cn: ['zh_CN'],
50
+ zh_hk: ['zh_HK'],
51
+ ja: ['ja'],
52
+ pt: ['pt'],
53
+ cn_en: ['en', 'zh_CN']
54
+ };
55
+
56
+ /**
57
+ * 将非 DEFAULT Invoice 模板启用的语言转换为 small_ticket_data locale。
58
+ * cn_en 是中英组合打印模式,因此展开为 en 与 zh_CN 两份数据。
59
+ */
60
+ function resolveInvoiceReceiptLocales(settings) {
61
+ if (typeof settings?.template !== 'string' || settings.template.trim().length === 0 || settings.template.trim().toUpperCase() === 'DEFAULT' || !isRecord(settings.language)) {
62
+ return [];
63
+ }
64
+ const enabledLocales = new Set();
65
+ Object.entries(settings.language).forEach(([rawKey, count]) => {
66
+ if (typeof count !== 'number' || !Number.isFinite(count) || count <= 0) {
67
+ return;
68
+ }
69
+ const key = rawKey.trim().toLowerCase().replace(/-/g, '_');
70
+ INVOICE_RECEIPT_LOCALE_MAPPING[key]?.forEach(locale => {
71
+ enabledLocales.add(locale);
72
+ });
73
+ });
74
+ return INVOICE_RECEIPT_LOCALE_ORDER.filter(locale => enabledLocales.has(locale));
75
+ }
41
76
  function normalizeInvoiceTemplate(value) {
42
77
  if (typeof value !== 'string' || value.trim().length === 0) return 'DEFAULT';
43
78
  return value.trim().toUpperCase() === 'DEFAULT' ? 'DEFAULT' : value;
@@ -88,8 +123,10 @@ function normalizeInvoiceTemplateSettings(config) {
88
123
  * 将 invoice_edit.modules 原样投影为 Web Invoice 使用的 module 字段。
89
124
  */
90
125
  function normalizeInvoiceLayoutConfig(config) {
126
+ const modules = normalizeInvoiceTemplateSettings(config).modules;
127
+ if (modules.length === 0) return getDefaultInvoiceLayoutConfig();
91
128
  return {
92
- module: normalizeInvoiceTemplateSettings(config).modules
129
+ module: modules
93
130
  };
94
131
  }
95
132
  function toBoolean(value) {
@@ -532,6 +532,11 @@ declare class Server {
532
532
  private handleOrderDraftSubmit;
533
533
  private handlePendingSyncCheckoutOrder;
534
534
  private buildPendingSyncCheckoutOrder;
535
+ /**
536
+ * Checkout 与本地小票必须消费同一份规范化子项快照。
537
+ * 商品/预约只折叠持久化 ID 或协议 UID 相同的行;支付额外兼容 payment_number。
538
+ */
539
+ private normalizeCheckoutCollections;
535
540
  /**
536
541
  * Android 结账自动小票由当前设备设置控制;其它平台保持原有行为。
537
542
  */
@@ -27,6 +27,7 @@ var _filterBookings = require("./modules/order/utils/filterBookings");
27
27
  var _smallTicket = require("./utils/small-ticket");
28
28
  var _BaseSales = require("../solution/BaseSales");
29
29
  var _paymentUtils = require("../modules/Order/payment-utils");
30
+ var _orderCollectionIdentity = require("../modules/Order/utils/orderCollectionIdentity");
30
31
  var _OpenData = require("../modules/OpenData");
31
32
  var _modules = require("./modules");
32
33
  Object.keys(_modules).forEach(function (key) {
@@ -631,7 +632,7 @@ class Server {
631
632
  } = params;
632
633
  const normalizedData = await this.normalizeCheckoutSubmitData(params.data, title);
633
634
  const numberedData = await this.ensureCheckoutOrderNumbers(normalizedData, title);
634
- const checkoutData = this.applyCheckoutFulfillmentBuzzer(numberedData, title);
635
+ const checkoutData = this.normalizeCheckoutCollections(this.applyCheckoutFulfillmentBuzzer(numberedData, title));
635
636
  const remoteCheckoutData = this.buildRemoteCheckoutData(checkoutData, title);
636
637
  if (!this.app?.request?.post) {
637
638
  throw new Error('app.request 不可用');
@@ -3682,17 +3683,16 @@ class Server {
3682
3683
  device_id: params.deviceId ?? deviceId,
3683
3684
  payload: {
3684
3685
  type: params.isManualPrint ? '0' : '99',
3686
+ template_settings: this.normalizePrintInvoiceTemplateSettings(params.invoiceTemplateSettings),
3685
3687
  data: params.receiptOnly ? {
3686
3688
  order_id: printIdentity,
3687
3689
  small_ticket_data: params.syncedOrder?.payment_info?.small_ticket_data,
3688
- template_settings: this.normalizePrintInvoiceTemplateSettings(params.invoiceTemplateSettings),
3689
3690
  skip_wristband: true,
3690
3691
  skip_voucher: true
3691
3692
  } : {
3692
3693
  order_id: printIdentity,
3693
3694
  machine_code_print_info: params.syncedOrder?.payment_info?.machine_code_print_info,
3694
3695
  machine_code_print_info_v2: params.syncedOrder?.machine_code_print_info_v2,
3695
- template_settings: this.normalizePrintInvoiceTemplateSettings(params.invoiceTemplateSettings),
3696
3696
  skip_receipt: true
3697
3697
  }
3698
3698
  },
@@ -3726,7 +3726,8 @@ class Server {
3726
3726
  };
3727
3727
  }
3728
3728
  const printableOrder = await this.withLocalSmallTicketData(params.order, {
3729
- requireFullyPaid: params.requireFullyPaid
3729
+ requireFullyPaid: params.requireFullyPaid,
3730
+ invoiceTemplateSettings: params.invoiceTemplateSettings
3730
3731
  });
3731
3732
  if (!(0, _smallTicket.hasSmallTicketData)(printableOrder.payment_info?.small_ticket_data)) {
3732
3733
  return {
@@ -4115,12 +4116,13 @@ class Server {
4115
4116
  }
4116
4117
  const normalizedData = await this.normalizeCheckoutSubmitData(data, title);
4117
4118
  const numberedData = await this.ensureCheckoutOrderNumbers(normalizedData, title);
4118
- const checkoutData = this.applyCheckoutFulfillmentBuzzer(numberedData, title);
4119
+ const checkoutData = this.normalizeCheckoutCollections(this.applyCheckoutFulfillmentBuzzer(numberedData, title));
4119
4120
  const pendingResult = await this.handlePendingSyncCheckoutOrder({
4120
4121
  backendPath,
4121
4122
  data: checkoutData,
4122
4123
  title,
4123
- reason: 'checkout 已转入设备任务同步'
4124
+ reason: 'checkout 已转入设备任务同步',
4125
+ invoiceTemplateSettings
4124
4126
  });
4125
4127
  if (pendingResult?.status === true) {
4126
4128
  const pendingOrder = pendingResult.data;
@@ -4299,9 +4301,10 @@ class Server {
4299
4301
  backendPath,
4300
4302
  data,
4301
4303
  title,
4302
- reason
4304
+ reason,
4305
+ invoiceTemplateSettings
4303
4306
  } = params;
4304
- const pendingOrder = await this.buildPendingSyncCheckoutOrder(data);
4307
+ const pendingOrder = await this.buildPendingSyncCheckoutOrder(data, invoiceTemplateSettings);
4305
4308
  if (!pendingOrder) {
4306
4309
  this.logError(`${title}: checkout 失败且订单缺少本地存储标识`, {
4307
4310
  backendPath,
@@ -4367,23 +4370,39 @@ class Server {
4367
4370
  };
4368
4371
  }
4369
4372
  }
4370
- async buildPendingSyncCheckoutOrder(data) {
4373
+ async buildPendingSyncCheckoutOrder(data, invoiceTemplateSettings) {
4371
4374
  if (!data || typeof data !== 'object') return null;
4372
4375
  const hasStorageKey = data.external_sale_number !== undefined && data.external_sale_number !== null && data.external_sale_number !== '' ? true : data.order_id !== undefined && data.order_id !== null && data.order_id !== '';
4373
4376
  if (!hasStorageKey) return null;
4374
- const pendingOrder = {
4377
+ const pendingOrder = this.normalizeCheckoutCollections({
4375
4378
  ...data,
4376
4379
  need_sync: 1,
4377
4380
  is_draft_order: 0
4378
- };
4381
+ });
4379
4382
  const productMap = await this.buildSmallTicketProductMap(pendingOrder);
4380
4383
  const orderWithProductTitles = this.withPendingSyncProductTitles(pendingOrder, productMap);
4381
4384
  return this.withLocalSmallTicketData(orderWithProductTitles, {
4382
4385
  requireFullyPaid: true,
4383
- productMap
4386
+ productMap,
4387
+ invoiceTemplateSettings
4384
4388
  });
4385
4389
  }
4386
4390
 
4391
+ /**
4392
+ * Checkout 与本地小票必须消费同一份规范化子项快照。
4393
+ * 商品/预约只折叠持久化 ID 或协议 UID 相同的行;支付额外兼容 payment_number。
4394
+ */
4395
+ normalizeCheckoutCollections(data) {
4396
+ if (!data || typeof data !== 'object' || Array.isArray(data)) return data;
4397
+ const normalized = (0, _orderCollectionIdentity.normalizeOrderCollections)(data, {
4398
+ ensureUid: false
4399
+ }).order;
4400
+ if (Array.isArray(normalized.payments)) {
4401
+ normalized.payments = (0, _paymentUtils.mergeOrderPaymentListsByIdentity)([], normalized.payments);
4402
+ }
4403
+ return normalized;
4404
+ }
4405
+
4387
4406
  /**
4388
4407
  * Android 结账自动小票由当前设备设置控制;其它平台保持原有行为。
4389
4408
  */
@@ -4706,6 +4725,7 @@ class Server {
4706
4725
  const smallTicketData = (0, _smallTicket.buildSmallTicketData)({
4707
4726
  order: enrichedOrder,
4708
4727
  shopInfo: this.getSmallTicketShopInfo(),
4728
+ locales: (0, _OpenData.resolveInvoiceReceiptLocales)(options?.invoiceTemplateSettings),
4709
4729
  productMap
4710
4730
  });
4711
4731
  return {
@@ -87,6 +87,58 @@ const LABELS = {
87
87
  rounding: '抹零',
88
88
  gross: '重量',
89
89
  tare: '去皮'
90
+ },
91
+ ja: {
92
+ contactName: '連絡先名',
93
+ contactMobile: '連絡先電話',
94
+ email: 'メール',
95
+ dineIn: '店内飲食',
96
+ takeAway: 'テイクアウト',
97
+ delivery: '配達',
98
+ pickUp: '受け取り',
99
+ shopService: '店内飲食',
100
+ pickUpTime: '受取時間',
101
+ asap: 'できるだけ早く',
102
+ cash: '現金',
103
+ eftpos: 'カード',
104
+ wallet: 'ウォレット',
105
+ giftCard: 'ギフトカード',
106
+ remainingAmount: '残高',
107
+ redeemPoints: '利用ポイント',
108
+ remainingPoints: '残りポイント',
109
+ table: 'テーブル',
110
+ orderDiscount: '注文割引',
111
+ manualDiscount: '手動割引',
112
+ payProcessingFee: '決済手数料',
113
+ rounding: '端数調整',
114
+ gross: '総重量',
115
+ tare: '風袋'
116
+ },
117
+ pt: {
118
+ contactName: 'Nome de contato',
119
+ contactMobile: 'Celular de contato',
120
+ email: 'e-mail',
121
+ dineIn: 'Consumo no local',
122
+ takeAway: 'Para levar',
123
+ delivery: 'Entrega',
124
+ pickUp: 'Recolha',
125
+ shopService: 'Consumo no local',
126
+ pickUpTime: 'Hora de recolha',
127
+ asap: 'Assim que possível',
128
+ cash: 'Dinheiro',
129
+ eftpos: 'Cartão',
130
+ wallet: 'Carteira',
131
+ giftCard: 'Cartão-presente',
132
+ remainingAmount: 'Saldo restante',
133
+ redeemPoints: 'Pontos utilizados',
134
+ remainingPoints: 'Pontos restantes',
135
+ table: 'Mesa',
136
+ orderDiscount: 'Desconto do pedido',
137
+ manualDiscount: 'Desconto manual',
138
+ payProcessingFee: 'Taxa de processamento',
139
+ rounding: 'Arredondamento',
140
+ gross: 'Peso bruto',
141
+ tare: 'Tara'
90
142
  }
91
143
  };
92
144
  function buildSmallTicketData(params) {
@@ -196,10 +196,13 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
196
196
  await this.configureIdGeneratorFromOpenData();
197
197
  }
198
198
  getBookingTicketBusinessCode() {
199
- const businessCode = this.otherParams?.businessCode ?? this.otherParams?.business_code;
200
- if (businessCode === undefined || businessCode === null) return null;
201
- const normalized = String(businessCode).trim();
202
- return normalized || null;
199
+ const candidates = [this.otherParams?.businessCode, this.otherParams?.business_code, this.getOrderHeader()?.business_code, this.store.order?.getTempOrder()?.business_code, this.getSalesOrder()?.raw?.business_code];
200
+ for (const candidate of candidates) {
201
+ if (candidate === undefined || candidate === null) continue;
202
+ const normalized = String(candidate).trim();
203
+ if (normalized) return normalized;
204
+ }
205
+ return null;
203
206
  }
204
207
  getIdGeneratorPlugin() {
205
208
  const appPlugin = this.core.getPlugin('app');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.10.18",
4
+ "version": "0.10.20",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",