@pisell/pisellos 2.3.74 → 2.3.76

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 (283) hide show
  1. package/dist/core/index.js +6 -10
  2. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  3. package/dist/model/strategy/adapter/walletPass/example.js +3 -26
  4. package/dist/model/strategy/strategy-example.js +5 -19
  5. package/dist/modules/Cart/index.js +0 -3
  6. package/dist/modules/Cart/utils/cartProduct.js +0 -1
  7. package/dist/modules/Date/index.js +1 -5
  8. package/dist/modules/Discount/index.js +2 -4
  9. package/dist/modules/OpenData/index.js +0 -2
  10. package/dist/modules/Order/index.d.ts +1 -1
  11. package/dist/modules/Order/index.js +75 -91
  12. package/dist/modules/Order/types.d.ts +3 -1
  13. package/dist/modules/Payment/index.js +97 -162
  14. package/dist/modules/Rules/index.js +1 -4
  15. package/dist/modules/Schedule/index.js +0 -1
  16. package/dist/modules/Schedule/utils.js +0 -1
  17. package/dist/modules/Step/index.js +0 -1
  18. package/dist/plugins/request.js +1 -4
  19. package/dist/plugins/window.js +2 -6
  20. package/dist/server/index.js +97 -129
  21. package/dist/server/modules/menu/index.js +32 -41
  22. package/dist/server/modules/order/index.js +2 -4
  23. package/dist/server/modules/products/index.js +24 -42
  24. package/dist/server/modules/quotation/index.js +29 -38
  25. package/dist/server/modules/resource/index.js +3 -4
  26. package/dist/server/modules/schedule/index.js +27 -35
  27. package/dist/server/utils/product.js +0 -1
  28. package/dist/solution/BaseSales/index.js +100 -72
  29. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +5 -0
  30. package/dist/solution/BaseSales/utils/cartPromotion.js +15 -6
  31. package/dist/solution/BookingByStep/index.js +7 -59
  32. package/dist/solution/BookingByStep/utils/capacity.js +1 -11
  33. package/dist/solution/BookingByStep/utils/resources.js +1 -3
  34. package/dist/solution/BookingByStep/utils/timeslots.js +2 -43
  35. package/dist/solution/BookingTicket/index.js +0 -2
  36. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +6 -7
  37. package/dist/solution/BookingTicket/utils/scan/handleScan.js +25 -31
  38. package/dist/solution/BookingTicket/utils/scan/index.js +6 -10
  39. package/dist/solution/BuyTickets/index.js +9 -12
  40. package/dist/solution/Checkout/index.js +177 -252
  41. package/dist/solution/Checkout/utils/index.js +4 -16
  42. package/dist/solution/RegisterAndLogin/index.js +30 -76
  43. package/dist/solution/ScanOrder/index.js +50 -60
  44. package/dist/solution/ShopDiscount/index.js +2 -7
  45. package/dist/solution/VenueBooking/index.js +45 -55
  46. package/dist/utils/task.js +15 -18
  47. package/dist/utils/watch.js +0 -1
  48. package/lib/apis/picoding.js +2 -0
  49. package/lib/core/index.js +134 -134
  50. package/lib/effects/index.js +46 -57
  51. package/lib/index.js +82 -49
  52. package/lib/model/index.js +14 -21
  53. package/lib/model/strategy/adapter/dataVariant/adapter.js +38 -50
  54. package/lib/model/strategy/adapter/dataVariant/evaluator.js +162 -236
  55. package/lib/model/strategy/adapter/dataVariant/examples.js +229 -237
  56. package/lib/model/strategy/adapter/dataVariant/index.js +39 -34
  57. package/lib/model/strategy/adapter/dataVariant/type.js +57 -28
  58. package/lib/model/strategy/adapter/index.js +100 -64
  59. package/lib/model/strategy/adapter/itemRule/adapter.js +156 -144
  60. package/lib/model/strategy/adapter/itemRule/evaluator.js +36 -48
  61. package/lib/model/strategy/adapter/itemRule/examples.js +295 -225
  62. package/lib/model/strategy/adapter/itemRule/index.js +83 -57
  63. package/lib/model/strategy/adapter/itemRule/type.js +97 -36
  64. package/lib/model/strategy/adapter/promotion/adapter.js +91 -69
  65. package/lib/model/strategy/adapter/promotion/evaluator.js +444 -310
  66. package/lib/model/strategy/adapter/promotion/examples.js +222 -234
  67. package/lib/model/strategy/adapter/promotion/index.js +1 -0
  68. package/lib/model/strategy/adapter/promotion/type.js +243 -36
  69. package/lib/model/strategy/adapter/type.js +4 -16
  70. package/lib/model/strategy/adapter/walletPass/evaluator.js +180 -150
  71. package/lib/model/strategy/adapter/walletPass/example.js +217 -190
  72. package/lib/model/strategy/adapter/walletPass/index.js +75 -51
  73. package/lib/model/strategy/adapter/walletPass/locales.js +36 -58
  74. package/lib/model/strategy/adapter/walletPass/type.js +4 -16
  75. package/lib/model/strategy/adapter/walletPass/utils.js +588 -378
  76. package/lib/model/strategy/engine.js +270 -168
  77. package/lib/model/strategy/index.js +49 -34
  78. package/lib/model/strategy/strategy-example.js +243 -239
  79. package/lib/model/strategy/type.js +100 -40
  80. package/lib/modules/Account/index.js +39 -53
  81. package/lib/modules/Account/types.js +20 -33
  82. package/lib/modules/AccountList/index.js +116 -154
  83. package/lib/modules/AccountList/types.js +30 -31
  84. package/lib/modules/AccountList/utils.js +18 -30
  85. package/lib/modules/BaseModule.js +23 -42
  86. package/lib/modules/BookingContext/index.js +158 -136
  87. package/lib/modules/BookingContext/types.js +46 -32
  88. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +138 -146
  89. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +78 -83
  90. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +170 -150
  91. package/lib/modules/BookingContext/utils/flexible.js +38 -55
  92. package/lib/modules/BookingContext/utils/formatResourceList.js +19 -34
  93. package/lib/modules/BookingContext/utils/index.js +124 -41
  94. package/lib/modules/BookingContext/utils/noResource.js +58 -70
  95. package/lib/modules/BookingContext/utils/orderLineDisplay.js +14 -41
  96. package/lib/modules/BookingContext/utils/productExtend.js +202 -155
  97. package/lib/modules/BookingContext/utils/resourceErrors.js +53 -53
  98. package/lib/modules/BookingContext/utils/resourceSelection.js +19 -41
  99. package/lib/modules/BookingContext/utils/resources.js +209 -167
  100. package/lib/modules/BookingContext/utils/serviceTimes.js +115 -116
  101. package/lib/modules/BookingContext/utils/timeSlices.js +76 -86
  102. package/lib/modules/Cart/index.js +170 -124
  103. package/lib/modules/Cart/types.js +46 -51
  104. package/lib/modules/Cart/utils/cartAccount.js +40 -39
  105. package/lib/modules/Cart/utils/cartDate.js +56 -61
  106. package/lib/modules/Cart/utils/cartDiscount.js +28 -33
  107. package/lib/modules/Cart/utils/cartNote.js +27 -32
  108. package/lib/modules/Cart/utils/cartProduct.js +321 -251
  109. package/lib/modules/Cart/utils/cartRelationForms.js +29 -35
  110. package/lib/modules/Cart/utils/cartResource.js +70 -78
  111. package/lib/modules/Cart/utils/changePrice.js +22 -50
  112. package/lib/modules/Cart/utils/index.js +106 -48
  113. package/lib/modules/Customer/constants.js +13 -34
  114. package/lib/modules/Customer/index.js +235 -172
  115. package/lib/modules/Customer/types.js +38 -35
  116. package/lib/modules/Date/index.js +116 -115
  117. package/lib/modules/Date/types.js +16 -28
  118. package/lib/modules/Date/utils.js +174 -123
  119. package/lib/modules/Discount/index.js +122 -127
  120. package/lib/modules/Discount/types.js +9 -31
  121. package/lib/modules/Guests/index.js +30 -56
  122. package/lib/modules/Guests/types.js +23 -33
  123. package/lib/modules/Holder/index.js +209 -189
  124. package/lib/modules/Holder/types.js +4 -16
  125. package/lib/modules/Holder/utils.js +20 -49
  126. package/lib/modules/OpenData/index.js +70 -76
  127. package/lib/modules/OpenData/types.js +4 -16
  128. package/lib/modules/OpenData/utils.js +44 -78
  129. package/lib/modules/Order/index.d.ts +1 -1
  130. package/lib/modules/Order/index.js +1733 -2121
  131. package/lib/modules/Order/payment-utils.js +77 -120
  132. package/lib/modules/Order/types.d.ts +3 -1
  133. package/lib/modules/Order/types.js +88 -35
  134. package/lib/modules/Order/utils/bundleDiscountHydration.js +41 -74
  135. package/lib/modules/Order/utils/discountProductLineIdentity.js +142 -100
  136. package/lib/modules/Order/utils/manualProductDiscount.js +124 -123
  137. package/lib/modules/Order/utils/orderCollectionIdentity.js +184 -244
  138. package/lib/modules/Order/utils.js +814 -647
  139. package/lib/modules/Payment/cash.js +20 -33
  140. package/lib/modules/Payment/cashRecommendationAlgorithm.js +145 -76
  141. package/lib/modules/Payment/eftpos.js +16 -30
  142. package/lib/modules/Payment/index.js +532 -399
  143. package/lib/modules/Payment/mx51.js +1 -0
  144. package/lib/modules/Payment/types.js +230 -108
  145. package/lib/modules/Payment/utils.js +52 -51
  146. package/lib/modules/Payment/walletpass.js +485 -660
  147. package/lib/modules/Product/index.js +51 -46
  148. package/lib/modules/Product/types.js +4 -16
  149. package/lib/modules/Product/utils.js +32 -33
  150. package/lib/modules/ProductList/index.js +113 -123
  151. package/lib/modules/ProductList/types.js +9 -31
  152. package/lib/modules/Quotation/index.js +81 -118
  153. package/lib/modules/Quotation/types.js +4 -16
  154. package/lib/modules/Resource/index.js +27 -59
  155. package/lib/modules/Resource/types.js +22 -32
  156. package/lib/modules/Resource/utils.js +30 -38
  157. package/lib/modules/ResourcePlanner/index.js +25 -23
  158. package/lib/modules/ResourcePlanner/localClock.js +54 -119
  159. package/lib/modules/ResourcePlanner/planner.js +589 -770
  160. package/lib/modules/ResourcePlanner/types.js +10 -29
  161. package/lib/modules/Rules/index.js +1218 -959
  162. package/lib/modules/Rules/types.js +17 -40
  163. package/lib/modules/SalesSummary/index.js +85 -90
  164. package/lib/modules/SalesSummary/types.js +4 -16
  165. package/lib/modules/SalesSummary/utils.js +355 -430
  166. package/lib/modules/ScanOrderLogger/index.js +59 -79
  167. package/lib/modules/ScanOrderLogger/providers/feishu.js +54 -78
  168. package/lib/modules/ScanOrderLogger/providers/grafana.js +13 -36
  169. package/lib/modules/ScanOrderLogger/types.js +4 -16
  170. package/lib/modules/Schedule/getDateIsInSchedule.js +334 -163
  171. package/lib/modules/Schedule/index.js +100 -114
  172. package/lib/modules/Schedule/type.js +4 -16
  173. package/lib/modules/Schedule/types.js +4 -16
  174. package/lib/modules/Schedule/utils.js +433 -291
  175. package/lib/modules/Step/index.js +40 -52
  176. package/lib/modules/Step/tyeps.js +4 -16
  177. package/lib/modules/Summary/index.js +66 -71
  178. package/lib/modules/Summary/types.js +4 -16
  179. package/lib/modules/Summary/utils.js +773 -418
  180. package/lib/modules/SurchargeList/index.js +46 -60
  181. package/lib/modules/SurchargeList/types.js +4 -16
  182. package/lib/modules/index.js +245 -63
  183. package/lib/plugins/app.js +4 -16
  184. package/lib/plugins/index.js +36 -25
  185. package/lib/plugins/request.js +137 -126
  186. package/lib/plugins/shopStore.js +4 -16
  187. package/lib/plugins/user.js +4 -16
  188. package/lib/plugins/window.js +171 -179
  189. package/lib/server/index.js +3050 -2665
  190. package/lib/server/modules/floor-plan/index.js +118 -134
  191. package/lib/server/modules/floor-plan/types.js +15 -30
  192. package/lib/server/modules/index.js +106 -68
  193. package/lib/server/modules/menu/index.js +142 -122
  194. package/lib/server/modules/menu/types.js +18 -31
  195. package/lib/server/modules/order/index.js +784 -1002
  196. package/lib/server/modules/order/types.js +122 -33
  197. package/lib/server/modules/order/utils/filterBookings.js +219 -194
  198. package/lib/server/modules/order/utils/filterOrders.js +118 -92
  199. package/lib/server/modules/payment/index.js +59 -83
  200. package/lib/server/modules/payment/types.js +4 -16
  201. package/lib/server/modules/products/index.js +583 -471
  202. package/lib/server/modules/products/types.js +44 -34
  203. package/lib/server/modules/quotation/index.js +137 -172
  204. package/lib/server/modules/quotation/types.js +21 -31
  205. package/lib/server/modules/resource/index.js +220 -186
  206. package/lib/server/modules/resource/types.js +42 -33
  207. package/lib/server/modules/schedule/index.js +135 -123
  208. package/lib/server/modules/schedule/types.js +14 -21
  209. package/lib/server/modules/schedule/utils.js +334 -163
  210. package/lib/server/types.js +4 -16
  211. package/lib/server/utils/index.js +25 -23
  212. package/lib/server/utils/product.js +196 -139
  213. package/lib/server/utils/schedule.js +34 -41
  214. package/lib/server/utils/small-ticket.js +479 -456
  215. package/lib/server/utils/time.js +40 -49
  216. package/lib/solution/BaseSales/index.js +1220 -1412
  217. package/lib/solution/BaseSales/types.js +42 -38
  218. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +5 -0
  219. package/lib/solution/BaseSales/utils/cartPromotion.js +652 -498
  220. package/lib/solution/BaseSales/utils/parseSalesResponse.js +85 -105
  221. package/lib/solution/BaseSales/utils/quotationPrice.js +56 -114
  222. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +108 -145
  223. package/lib/solution/BaseSales/utils.js +158 -143
  224. package/lib/solution/BookingByStep/index.js +1527 -1340
  225. package/lib/solution/BookingByStep/types.js +40 -99
  226. package/lib/solution/BookingByStep/utils/capacity.js +192 -160
  227. package/lib/solution/BookingByStep/utils/products.js +42 -52
  228. package/lib/solution/BookingByStep/utils/resources.js +527 -330
  229. package/lib/solution/BookingByStep/utils/stock.js +65 -44
  230. package/lib/solution/BookingByStep/utils/timeslots.js +129 -131
  231. package/lib/solution/BookingTicket/index.js +607 -522
  232. package/lib/solution/BookingTicket/types.js +99 -77
  233. package/lib/solution/BookingTicket/utils/addProductDecision.js +226 -189
  234. package/lib/solution/BookingTicket/utils/addTimeAvailability.js +58 -89
  235. package/lib/solution/BookingTicket/utils/bookingStatus.js +107 -78
  236. package/lib/solution/BookingTicket/utils/cartView.js +114 -99
  237. package/lib/solution/BookingTicket/utils/exampleData.js +185 -0
  238. package/lib/solution/BookingTicket/utils/orderCustomer.js +18 -41
  239. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +219 -86
  240. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +168 -116
  241. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +79 -91
  242. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +54 -41
  243. package/lib/solution/BookingTicket/utils/scan/handleScan.js +84 -81
  244. package/lib/solution/BookingTicket/utils/scan/index.js +98 -104
  245. package/lib/solution/BookingTicket/utils/scan/scanCache.js +90 -43
  246. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +52 -64
  247. package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +56 -58
  248. package/lib/solution/BookingTicket/utils/weighingProductSku.js +34 -48
  249. package/lib/solution/BuyTickets/index.js +67 -70
  250. package/lib/solution/BuyTickets/types.js +22 -38
  251. package/lib/solution/Checkout/index.js +1451 -1158
  252. package/lib/solution/Checkout/types.js +91 -61
  253. package/lib/solution/Checkout/utils/index.js +228 -156
  254. package/lib/solution/PlaceOrder/index.js +55 -0
  255. package/lib/solution/RegisterAndLogin/config.js +493 -460
  256. package/lib/solution/RegisterAndLogin/index.js +633 -630
  257. package/lib/solution/RegisterAndLogin/types.js +189 -76
  258. package/lib/solution/RegisterAndLogin/utils.js +183 -125
  259. package/lib/solution/Sales/index.js +328 -324
  260. package/lib/solution/Sales/types.js +27 -33
  261. package/lib/solution/ScanOrder/index.js +832 -864
  262. package/lib/solution/ScanOrder/types.js +33 -34
  263. package/lib/solution/ScanOrder/utils.js +409 -374
  264. package/lib/solution/ShopDiscount/index.js +226 -232
  265. package/lib/solution/ShopDiscount/types.js +15 -37
  266. package/lib/solution/ShopDiscount/utils.js +300 -172
  267. package/lib/solution/UnifiedBookingSales/index.js +1035 -1201
  268. package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +99 -159
  269. package/lib/solution/UnifiedBookingSales/types.js +10 -32
  270. package/lib/solution/VenueBooking/index.js +811 -879
  271. package/lib/solution/VenueBooking/types.js +19 -39
  272. package/lib/solution/VenueBooking/utils/dateSummary.js +27 -56
  273. package/lib/solution/VenueBooking/utils/resource.js +31 -54
  274. package/lib/solution/VenueBooking/utils/slotMerge.js +94 -107
  275. package/lib/solution/VenueBooking/utils/timeSlot.js +132 -132
  276. package/lib/solution/VenueBooking/utils.js +130 -67
  277. package/lib/solution/index.js +124 -41
  278. package/lib/store/createStore.js +32 -29
  279. package/lib/types/index.js +4 -16
  280. package/lib/utils/payment-number.js +26 -46
  281. package/lib/utils/task.js +36 -36
  282. package/lib/utils/watch.js +81 -47
  283. package/package.json +2 -1
@@ -1,119 +1,92 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ "use strict";
28
2
 
29
- // src/server/utils/small-ticket.ts
30
- var small_ticket_exports = {};
31
- __export(small_ticket_exports, {
32
- buildSmallTicketData: () => buildSmallTicketData,
33
- hasSmallTicketData: () => hasSmallTicketData
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
34
5
  });
35
- module.exports = __toCommonJS(small_ticket_exports);
36
- var import_dayjs = __toESM(require("dayjs"));
37
- var import_decimal = __toESM(require("decimal.js"));
38
- var DEFAULT_LOCALES = ["en", "zh_CN"];
39
- var LABELS = {
6
+ exports.buildSmallTicketData = buildSmallTicketData;
7
+ exports.hasSmallTicketData = hasSmallTicketData;
8
+ var _dayjs = _interopRequireDefault(require("dayjs"));
9
+ var _decimal = _interopRequireDefault(require("decimal.js"));
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ const DEFAULT_LOCALES = ['en', 'zh_CN'];
12
+ const LABELS = {
40
13
  en: {
41
- contactName: "Contact name",
42
- contactMobile: "Contact Mobile",
43
- email: "email",
44
- dineIn: "Dine-in",
45
- takeAway: "Take away",
46
- delivery: "Delivery",
47
- pickUp: "Pick-up",
48
- shopService: "Dine-in",
49
- pickUpTime: "Pick-up time",
50
- asap: "ASAP",
51
- cash: "Cash",
52
- eftpos: "Eftpos",
53
- wallet: "Wallet",
54
- giftCard: "Gift card",
55
- remainingAmount: "Remaining amount",
56
- redeemPoints: "Redeem points",
57
- remainingPoints: "Remaining points",
58
- table: "Table",
59
- orderDiscount: "Order discount",
60
- manualDiscount: "Manual discount",
61
- payProcessingFee: "Pay processing fee",
62
- rounding: "Rounding",
63
- gross: "Gross",
64
- tare: "Tare"
14
+ contactName: 'Contact name',
15
+ contactMobile: 'Contact Mobile',
16
+ email: 'email',
17
+ dineIn: 'Dine-in',
18
+ takeAway: 'Take away',
19
+ delivery: 'Delivery',
20
+ pickUp: 'Pick-up',
21
+ shopService: 'Dine-in',
22
+ pickUpTime: 'Pick-up time',
23
+ asap: 'ASAP',
24
+ cash: 'Cash',
25
+ eftpos: 'Eftpos',
26
+ wallet: 'Wallet',
27
+ giftCard: 'Gift card',
28
+ remainingAmount: 'Remaining amount',
29
+ redeemPoints: 'Redeem points',
30
+ remainingPoints: 'Remaining points',
31
+ table: 'Table',
32
+ orderDiscount: 'Order discount',
33
+ manualDiscount: 'Manual discount',
34
+ payProcessingFee: 'Pay processing fee',
35
+ rounding: 'Rounding',
36
+ gross: 'Gross',
37
+ tare: 'Tare'
65
38
  },
66
39
  zh_CN: {
67
- contactName: "联系人姓名",
68
- contactMobile: "联系电话",
69
- email: "邮箱",
70
- dineIn: "堂食",
71
- takeAway: "外带",
72
- delivery: "配送",
73
- pickUp: "自提",
74
- shopService: "堂食",
75
- pickUpTime: "取餐时间",
76
- asap: "尽快",
77
- cash: "现金支付",
78
- eftpos: "刷卡支付",
79
- wallet: "钱包支付",
80
- giftCard: "礼品卡",
81
- remainingAmount: "剩余金额",
82
- redeemPoints: "本次使用积分",
83
- remainingPoints: "剩余积分",
84
- table: "桌台",
85
- orderDiscount: "整单折扣",
86
- manualDiscount: "手动折扣",
87
- payProcessingFee: "支付手续费",
88
- rounding: "抹零",
89
- gross: "重量",
90
- tare: "去皮"
40
+ contactName: '联系人姓名',
41
+ contactMobile: '联系电话',
42
+ email: '邮箱',
43
+ dineIn: '堂食',
44
+ takeAway: '外带',
45
+ delivery: '配送',
46
+ pickUp: '自提',
47
+ shopService: '堂食',
48
+ pickUpTime: '取餐时间',
49
+ asap: '尽快',
50
+ cash: '现金支付',
51
+ eftpos: '刷卡支付',
52
+ wallet: '钱包支付',
53
+ giftCard: '礼品卡',
54
+ remainingAmount: '剩余金额',
55
+ redeemPoints: '本次使用积分',
56
+ remainingPoints: '剩余积分',
57
+ table: '桌台',
58
+ orderDiscount: '整单折扣',
59
+ manualDiscount: '手动折扣',
60
+ payProcessingFee: '支付手续费',
61
+ rounding: '抹零',
62
+ gross: '重量',
63
+ tare: '去皮'
91
64
  },
92
65
  zh_HK: {
93
- contactName: "聯絡人姓名",
94
- contactMobile: "聯絡電話",
95
- email: "電郵",
96
- dineIn: "堂食",
97
- takeAway: "外帶",
98
- delivery: "配送",
99
- pickUp: "自取",
100
- shopService: "堂食",
101
- pickUpTime: "取餐時間",
102
- asap: "盡快",
103
- cash: "現金支付",
104
- eftpos: "刷卡支付",
105
- wallet: "錢包支付",
106
- giftCard: "禮品卡",
107
- remainingAmount: "剩餘金額",
108
- redeemPoints: "本次使用積分",
109
- remainingPoints: "剩餘積分",
110
- table: "桌台",
111
- orderDiscount: "整單折扣",
112
- manualDiscount: "手動折扣",
113
- payProcessingFee: "支付手續費",
114
- rounding: "抹零",
115
- gross: "重量",
116
- tare: "去皮"
66
+ contactName: '聯絡人姓名',
67
+ contactMobile: '聯絡電話',
68
+ email: '電郵',
69
+ dineIn: '堂食',
70
+ takeAway: '外帶',
71
+ delivery: '配送',
72
+ pickUp: '自取',
73
+ shopService: '堂食',
74
+ pickUpTime: '取餐時間',
75
+ asap: '盡快',
76
+ cash: '現金支付',
77
+ eftpos: '刷卡支付',
78
+ wallet: '錢包支付',
79
+ giftCard: '禮品卡',
80
+ remainingAmount: '剩餘金額',
81
+ redeemPoints: '本次使用積分',
82
+ remainingPoints: '剩餘積分',
83
+ table: '桌台',
84
+ orderDiscount: '整單折扣',
85
+ manualDiscount: '手動折扣',
86
+ payProcessingFee: '支付手續費',
87
+ rounding: '抹零',
88
+ gross: '重量',
89
+ tare: '去皮'
117
90
  }
118
91
  };
119
92
  function buildSmallTicketData(params) {
@@ -122,27 +95,52 @@ function buildSmallTicketData(params) {
122
95
  const locales = resolveLocales(shopInfo, params.locales);
123
96
  const productMap = params.productMap || {};
124
97
  return locales.reduce((data, locale) => {
125
- data[locale] = buildLocaleData({ order, shopInfo, locale, productMap });
98
+ data[locale] = buildLocaleData({
99
+ order,
100
+ shopInfo,
101
+ locale,
102
+ productMap
103
+ });
126
104
  return data;
127
105
  }, {});
128
106
  }
129
107
  function hasSmallTicketData(value) {
130
- return !!value && typeof value === "object" && Object.keys(value).length > 0;
108
+ return !!value && typeof value === 'object' && Object.keys(value).length > 0;
131
109
  }
132
110
  function buildLocaleData(params) {
133
- const { order, shopInfo, locale, productMap } = params;
111
+ const {
112
+ order,
113
+ shopInfo,
114
+ locale,
115
+ productMap
116
+ } = params;
134
117
  const products = buildProducts(order, locale, productMap);
135
118
  const summary = getSummary(order);
136
119
  const currencySymbol = getCurrencySymbol(order, shopInfo);
137
120
  return {
138
- base_data: buildBaseData({ order, shopInfo, locale }),
121
+ base_data: buildBaseData({
122
+ order,
123
+ shopInfo,
124
+ locale
125
+ }),
139
126
  products,
140
- fees: buildFees({ order, shopInfo, locale, products, summary, currencySymbol }),
127
+ fees: buildFees({
128
+ order,
129
+ shopInfo,
130
+ locale,
131
+ products,
132
+ summary,
133
+ currencySymbol
134
+ }),
141
135
  customer: buildCustomer(order, locale),
142
136
  appointment: buildAppointment(order, locale),
143
137
  // delivery: buildDelivery(order, locale),
144
138
  resources: buildResources(order, locale),
145
- payment_data: buildPaymentData({ order, locale, currencySymbol }),
139
+ payment_data: buildPaymentData({
140
+ order,
141
+ locale,
142
+ currencySymbol
143
+ }),
146
144
  tickets: Array.isArray(order.tickets) ? order.tickets : [],
147
145
  source_shop: [],
148
146
  refund_data: [],
@@ -150,11 +148,12 @@ function buildLocaleData(params) {
150
148
  };
151
149
  }
152
150
  function buildBaseData(params) {
153
- var _a;
154
- const { order, shopInfo, locale } = params;
155
- const orderNumber = stringify(
156
- order.buzzer || order.shop_full_order_number
157
- );
151
+ const {
152
+ order,
153
+ shopInfo,
154
+ locale
155
+ } = params;
156
+ const orderNumber = stringify(order.buzzer || order.shop_full_order_number);
158
157
  return {
159
158
  shop_name: stringify(shopInfo.name || order.shop_name),
160
159
  note: stringify(order.note),
@@ -165,18 +164,22 @@ function buildBaseData(params) {
165
164
  shop_address: stringify(shopInfo.address || buildShopAddress(shopInfo) || order.shop_address),
166
165
  original_payment_status: stringify(order.payment_status),
167
166
  is_repeat: 0,
168
- buzzer: stringify(order.buzzer || order.pickup_number || ((_a = order.metadata) == null ? void 0 : _a.buzzer)),
167
+ buzzer: stringify(order.buzzer || order.pickup_number || order.metadata?.buzzer),
169
168
  order_no: orderNumber,
170
- order_time: formatDateTime(order.created_at || order.sales_time || /* @__PURE__ */ new Date(), locale)
169
+ order_time: formatDateTime(order.created_at || order.sales_time || new Date(), locale)
171
170
  };
172
171
  }
173
172
  function buildProducts(order, locale, productMap) {
174
173
  const products = Array.isArray(order.products) ? order.products : [];
175
- return products.map((product) => {
174
+ return products.map(product => {
176
175
  const quantity = toNumber(product.product_quantity ?? product.quantity ?? product.num ?? 1, 1);
177
176
  const originalPrice = product.original_price ?? product.selling_price ?? product.payment_price ?? product.price ?? 0;
178
177
  const sellingPrice = product.selling_price ?? product.payment_price ?? product.price ?? originalPrice;
179
- const productTitle = resolveProductTitle({ product, productMap, locale });
178
+ const productTitle = resolveProductTitle({
179
+ product,
180
+ productMap,
181
+ locale
182
+ });
180
183
  const parentProduct = resolveProductFromMap(product.product_id ?? product.id, productMap);
181
184
  const currencySymbol = getCurrencySymbol(order, null);
182
185
  const options = normalizeProductOptions({
@@ -192,7 +195,11 @@ function buildProducts(order, locale, productMap) {
192
195
  currencySymbol,
193
196
  parentProduct
194
197
  });
195
- const resolvedVariant = resolveProductVariantText({ product, parentProduct, locale });
198
+ const resolvedVariant = resolveProductVariantText({
199
+ product,
200
+ parentProduct,
201
+ locale
202
+ });
196
203
  const extensionList = buildProductExtensionList({
197
204
  product,
198
205
  locale,
@@ -205,20 +212,33 @@ function buildProducts(order, locale, productMap) {
205
212
  product_quantity: quantity,
206
213
  selling_price: formatMoney(sellingPrice, currencySymbol),
207
214
  original_price: formatMoney(originalPrice, currencySymbol),
208
- total_original_price: formatMoney(new import_decimal.default(toMoneyNumber(originalPrice)).mul(quantity), currencySymbol),
215
+ total_original_price: formatMoney(new _decimal.default(toMoneyNumber(originalPrice)).mul(quantity), currencySymbol),
209
216
  extension_list: extensionList,
210
- ...options.length ? { options } : {},
211
- ...resolvedVariant ? { variant: resolvedVariant } : {},
212
- ...Array.isArray(product.combinations) ? { combinations: product.combinations } : combinations.length ? { combinations } : {}
217
+ ...(options.length ? {
218
+ options
219
+ } : {}),
220
+ ...(resolvedVariant ? {
221
+ variant: resolvedVariant
222
+ } : {}),
223
+ ...(Array.isArray(product.combinations) ? {
224
+ combinations: product.combinations
225
+ } : combinations.length ? {
226
+ combinations
227
+ } : {})
213
228
  };
214
229
  });
215
230
  }
216
231
  function normalizeProductDiscounts(params) {
217
- const { product, locale, currencySymbol, quantity } = params;
218
- return normalizeArray(product.discount_list).map((discount) => {
232
+ const {
233
+ product,
234
+ locale,
235
+ currencySymbol,
236
+ quantity
237
+ } = params;
238
+ return normalizeArray(product.discount_list).map(discount => {
219
239
  const title = resolveDiscountTitleWithPercent(discount, locale);
220
240
  const amount = discount.amount ?? discount.value ?? discount.discount_amount;
221
- const formattedAmount = formatNegativeMoney(new import_decimal.default(toMoneyNumber(amount)).mul(quantity), currencySymbol);
241
+ const formattedAmount = formatNegativeMoney(new _decimal.default(toMoneyNumber(amount)).mul(quantity), currencySymbol);
222
242
  return {
223
243
  item: title,
224
244
  value: formattedAmount
@@ -226,35 +246,54 @@ function normalizeProductDiscounts(params) {
226
246
  });
227
247
  }
228
248
  function buildProductExtensionList(params) {
229
- const { product, locale, currencySymbol, quantity, originalPrice } = params;
230
- const discountList = normalizeProductDiscounts({ product, locale, currencySymbol, quantity });
231
- const extensionList = [
232
- ...buildProductOpenWeightRows({ product, locale, currencySymbol }),
233
- ...quantity > 1 ? [{
234
- item: buildProductQuantityPriceText({ quantity, currencySymbol, price: originalPrice }),
235
- value: ""
236
- }] : []
237
- ];
249
+ const {
250
+ product,
251
+ locale,
252
+ currencySymbol,
253
+ quantity,
254
+ originalPrice
255
+ } = params;
256
+ const discountList = normalizeProductDiscounts({
257
+ product,
258
+ locale,
259
+ currencySymbol,
260
+ quantity
261
+ });
262
+ const extensionList = [...buildProductOpenWeightRows({
263
+ product,
264
+ locale,
265
+ currencySymbol
266
+ }), ...(quantity > 1 ? [{
267
+ item: buildProductQuantityPriceText({
268
+ quantity,
269
+ currencySymbol,
270
+ price: originalPrice
271
+ }),
272
+ value: ''
273
+ }] : [])];
238
274
  const productExtensionList = extensionList.length ? extensionList : normalizeArray(product.extension_list);
239
275
  return [...productExtensionList, ...discountList];
240
276
  }
241
277
  function buildProductOpenWeightRows(params) {
242
- const { product, locale, currencySymbol } = params;
278
+ const {
279
+ product,
280
+ locale,
281
+ currencySymbol
282
+ } = params;
243
283
  const productSku = product.product_sku || {};
244
- if (productSku.open_sold_weight != 1)
245
- return [];
246
- const unit = productSku.unit ?? "";
247
- const manualFlag = productSku.weight_source === "manual" ? "(M) " : "";
284
+ if (productSku.open_sold_weight != 1) return [];
285
+ const unit = productSku.unit ?? '';
286
+ const manualFlag = productSku.weight_source === 'manual' ? '(M) ' : '';
248
287
  const hasTare = toNumber(productSku.tare_weight, 0) > 0;
249
288
  const rows = [];
250
289
  if (hasTare) {
251
290
  rows.push({
252
- item: `${manualFlag}${label(locale, "gross")}: ${productSku.weight ?? 0}${unit}`,
253
- value: ""
291
+ item: `${manualFlag}${label(locale, 'gross')}: ${productSku.weight ?? 0}${unit}`,
292
+ value: ''
254
293
  });
255
294
  rows.push({
256
- item: `${label(locale, "tare")}: ${productSku.tare_weight}${unit}`,
257
- value: ""
295
+ item: `${label(locale, 'tare')}: ${productSku.tare_weight}${unit}`,
296
+ value: ''
258
297
  });
259
298
  }
260
299
  const netWeight = productSku.net_weight ?? 0;
@@ -262,71 +301,87 @@ function buildProductOpenWeightRows(params) {
262
301
  const netItem = `${netWeight} ${unit} NET @ ${currencySymbol}${unitPrice}/${unit}`;
263
302
  rows.push({
264
303
  item: hasTare ? netItem : `${manualFlag}${netItem}`,
265
- value: ""
304
+ value: ''
266
305
  });
267
306
  return rows;
268
307
  }
269
308
  function buildProductQuantityPriceText(params) {
270
- const { quantity, currencySymbol, price } = params;
309
+ const {
310
+ quantity,
311
+ currencySymbol,
312
+ price
313
+ } = params;
271
314
  return `${quantity} @ ${currencySymbol}${stringify(price)} EACH`;
272
315
  }
273
316
  function resolveDiscountTitleWithPercent(discount, locale) {
274
- var _a, _b;
275
317
  const title = resolveDiscountTitle(discount, locale);
276
- const percentRaw = (_a = discount.discount) == null ? void 0 : _a.percent;
277
- const cardType = ((_b = discount.discount) == null ? void 0 : _b.discount_card_type) ?? "percent";
278
- const percent = percentRaw !== void 0 && percentRaw !== null ? Math.trunc(Number(percentRaw)) : NaN;
279
- if (percentRaw === void 0 || percentRaw === null)
280
- return title;
281
- if (cardType !== "percent")
282
- return title;
283
- if (Number.isNaN(percent))
284
- return title;
318
+ const percentRaw = discount.discount?.percent;
319
+ const cardType = discount.discount?.discount_card_type ?? 'percent';
320
+ const percent = percentRaw !== undefined && percentRaw !== null ? Math.trunc(Number(percentRaw)) : NaN;
321
+ if (percentRaw === undefined || percentRaw === null) return title;
322
+ if (cardType !== 'percent') return title;
323
+ if (Number.isNaN(percent)) return title;
285
324
  return `${title} (${percent}%)`;
286
325
  }
287
326
  function resolveDiscountTitle(discount, locale) {
288
- var _a, _b, _c;
289
- const title = getLocalizedValue(
290
- ((_a = discount.discount) == null ? void 0 : _a.name) ?? ((_b = discount.discount) == null ? void 0 : _b.title) ?? ((_c = discount.discount) == null ? void 0 : _c.message) ?? discount.name ?? discount.title ?? discount.message,
291
- locale
292
- );
293
- if (title)
294
- return title;
295
- if (discount.type === "product")
296
- return label(locale, "manualDiscount");
297
- return "";
327
+ const title = getLocalizedValue(discount.discount?.name ?? discount.discount?.title ?? discount.discount?.message ?? discount.name ?? discount.title ?? discount.message, locale);
328
+ if (title) return title;
329
+ if (discount.type === 'product') return label(locale, 'manualDiscount');
330
+ return '';
298
331
  }
299
332
  function resolveProductTitle(params) {
300
- const { product, productMap, locale } = params;
333
+ const {
334
+ product,
335
+ productMap,
336
+ locale
337
+ } = params;
301
338
  const ownTitle = getProductTitleSource(product, locale);
302
- if (ownTitle)
303
- return ownTitle;
339
+ if (ownTitle) return ownTitle;
304
340
  const productId = product.product_id ?? product.id;
305
341
  const fallbackProduct = resolveProductFromMap(productId, productMap);
306
- if (!fallbackProduct)
307
- return ownTitle || "";
342
+ if (!fallbackProduct) return ownTitle || '';
308
343
  return getProductTitleSource(fallbackProduct, locale);
309
344
  }
310
345
  function normalizeProductOptions(params) {
311
- var _a;
312
- const { product, locale, currencySymbol, parentProduct } = params;
313
- const rawOptions = Array.isArray(params.options) ? params.options : Array.isArray(product.options) ? product.options : Array.isArray((_a = product.product_sku) == null ? void 0 : _a.option) ? product.product_sku.option : [];
314
- return rawOptions.map((option) => {
346
+ const {
347
+ product,
348
+ locale,
349
+ currencySymbol,
350
+ parentProduct
351
+ } = params;
352
+ const rawOptions = Array.isArray(params.options) ? params.options : Array.isArray(product.options) ? product.options : Array.isArray(product.product_sku?.option) ? product.product_sku.option : [];
353
+ return rawOptions.map(option => {
315
354
  const price = option.original_price ?? option.add_price ?? option.price;
316
355
  const value = option.value ?? option.option ?? option.item;
317
- const name = getProductTitleSource(option, locale) || resolveOptionTitleFromParentProduct({ option, parentProduct, locale });
356
+ const name = getProductTitleSource(option, locale) || resolveOptionTitleFromParentProduct({
357
+ option,
358
+ parentProduct,
359
+ locale
360
+ });
318
361
  return {
319
362
  name,
320
- ...option.num !== void 0 || option.quantity !== void 0 ? { num: toNumber(option.num ?? option.quantity, 1) } : {},
321
- ...price !== void 0 && price !== null && price !== "" ? { price: formatMoney(price, currencySymbol) } : {},
322
- ...value !== void 0 && value !== null && value !== "" ? { value: getLocalizedValue(value, locale) } : {}
363
+ ...(option.num !== undefined || option.quantity !== undefined ? {
364
+ num: toNumber(option.num ?? option.quantity, 1)
365
+ } : {}),
366
+ ...(price !== undefined && price !== null && price !== '' ? {
367
+ price: formatMoney(price, currencySymbol)
368
+ } : {}),
369
+ ...(value !== undefined && value !== null && value !== '' ? {
370
+ value: getLocalizedValue(value, locale)
371
+ } : {})
323
372
  };
324
373
  });
325
374
  }
326
375
  function normalizeProductCombinations(params) {
327
- const { product, productMap, locale, currencySymbol, parentProduct } = params;
376
+ const {
377
+ product,
378
+ productMap,
379
+ locale,
380
+ currencySymbol,
381
+ parentProduct
382
+ } = params;
328
383
  const bundles = Array.isArray(product.product_bundle) ? product.product_bundle : [];
329
- return bundles.map((bundle) => {
384
+ return bundles.map(bundle => {
330
385
  const combinationsOptions = normalizeProductOptions({
331
386
  product: {},
332
387
  locale,
@@ -350,44 +405,47 @@ function normalizeProductCombinations(params) {
350
405
  });
351
406
  }
352
407
  function resolveBundleProductTitle(params) {
353
- const { bundle, productMap, locale, parentProduct } = params;
408
+ const {
409
+ bundle,
410
+ productMap,
411
+ locale,
412
+ parentProduct
413
+ } = params;
354
414
  const ownTitle = getProductTitleSource(bundle, locale);
355
- if (ownTitle)
356
- return ownTitle;
357
- const parentBundleItem = resolveBundleItemFromParentProduct({ bundle, parentProduct });
358
- const parentBundleTitle = parentBundleItem ? getProductTitleSource(parentBundleItem, locale) : "";
359
- if (parentBundleTitle)
360
- return parentBundleTitle;
415
+ if (ownTitle) return ownTitle;
416
+ const parentBundleItem = resolveBundleItemFromParentProduct({
417
+ bundle,
418
+ parentProduct
419
+ });
420
+ const parentBundleTitle = parentBundleItem ? getProductTitleSource(parentBundleItem, locale) : '';
421
+ if (parentBundleTitle) return parentBundleTitle;
361
422
  const productId = bundle.bundle_product_id ?? bundle._bundle_product_id ?? bundle.product_id ?? bundle.id;
362
423
  const fallbackProduct = resolveProductFromMap(productId, productMap);
363
- if (!fallbackProduct)
364
- return "";
424
+ if (!fallbackProduct) return '';
365
425
  return getProductTitleSource(fallbackProduct, locale);
366
426
  }
367
427
  function resolveProductFromMap(productId, productMap) {
368
- if (productId === void 0 || productId === null || productId === "")
369
- return null;
428
+ if (productId === undefined || productId === null || productId === '') return null;
370
429
  return productMap[productId] || productMap[String(productId)] || null;
371
430
  }
372
431
  function resolveProductVariantText(params) {
373
- const { product, parentProduct, locale } = params;
374
- if (product.variant)
375
- return getLocalizedValue(product.variant, locale);
376
- if (!parentProduct)
377
- return "";
432
+ const {
433
+ product,
434
+ parentProduct,
435
+ locale
436
+ } = params;
437
+ if (product.variant) return getLocalizedValue(product.variant, locale);
438
+ if (!parentProduct) return '';
378
439
  const productVariantId = product.product_variant_id ?? product.variant_id;
379
- if (!isNonZeroId(productVariantId))
380
- return "";
381
- const matchedVariant = normalizeArray(parentProduct.variant).find((variant) => isSameId(variant.id, productVariantId));
382
- if (!matchedVariant)
383
- return "";
440
+ if (!isNonZeroId(productVariantId)) return '';
441
+ const matchedVariant = normalizeArray(parentProduct.variant).find(variant => isSameId(variant.id, productVariantId));
442
+ if (!matchedVariant) return '';
384
443
  const resolvedFromSkuKey = resolveVariantTextFromSkuKey({
385
444
  skuKey: matchedVariant.sku_key,
386
445
  parentProduct,
387
446
  locale
388
447
  });
389
- if (resolvedFromSkuKey)
390
- return resolvedFromSkuKey;
448
+ if (resolvedFromSkuKey) return resolvedFromSkuKey;
391
449
  return resolveVariantTextFromNameMap({
392
450
  nameMap: matchedVariant.name || matchedVariant.title,
393
451
  parentProduct,
@@ -396,86 +454,71 @@ function resolveProductVariantText(params) {
396
454
  }
397
455
  function resolveVariantTextFromSkuKey(params) {
398
456
  const skuKey = stringify(params.skuKey);
399
- if (!skuKey)
400
- return "";
401
- return skuKey.split("_").map((item) => {
402
- const [groupPositionId, itemPositionId] = item.split(":");
457
+ if (!skuKey) return '';
458
+ return skuKey.split('_').map(item => {
459
+ const [groupPositionId, itemPositionId] = item.split(':');
403
460
  return resolveVariantTextItem({
404
461
  parentProduct: params.parentProduct,
405
462
  groupPositionId,
406
463
  itemPositionId,
407
464
  locale: params.locale
408
465
  });
409
- }).filter(Boolean).join(",");
466
+ }).filter(Boolean).join(',');
410
467
  }
411
468
  function resolveVariantTextFromNameMap(params) {
412
- if (!params.nameMap || typeof params.nameMap !== "object")
413
- return "";
469
+ if (!params.nameMap || typeof params.nameMap !== 'object') return '';
414
470
  return Object.entries(params.nameMap).map(([groupPositionId, value]) => {
415
471
  const group = resolveVariantGroup(params.parentProduct, groupPositionId);
416
- if (!group)
417
- return "";
472
+ if (!group) return '';
418
473
  const groupName = getLocalizedValue(group.name, params.locale);
419
474
  const itemName = getLocalizedValue(value, params.locale);
420
- if (!groupName || !itemName)
421
- return "";
475
+ if (!groupName || !itemName) return '';
422
476
  return `${groupName}:${itemName}`;
423
- }).filter(Boolean).join(",");
477
+ }).filter(Boolean).join(',');
424
478
  }
425
479
  function resolveVariantTextItem(params) {
426
480
  const group = resolveVariantGroup(params.parentProduct, params.groupPositionId);
427
481
  const item = resolveVariantItem(group, params.itemPositionId);
428
- if (!group || !item)
429
- return "";
482
+ if (!group || !item) return '';
430
483
  const groupName = getLocalizedValue(group.name, params.locale);
431
484
  const itemName = getLocalizedValue(item.name, params.locale);
432
- if (!groupName || !itemName)
433
- return "";
485
+ if (!groupName || !itemName) return '';
434
486
  return `${groupName}:${itemName}`;
435
487
  }
436
488
  function resolveVariantGroup(parentProduct, groupPositionId) {
437
- return normalizeArray(parentProduct.variant_group).find(
438
- (group) => isSameId(group.position_id, groupPositionId) || isSameId(group.id, groupPositionId)
439
- ) || null;
489
+ return normalizeArray(parentProduct.variant_group).find(group => isSameId(group.position_id, groupPositionId) || isSameId(group.id, groupPositionId)) || null;
440
490
  }
441
491
  function resolveVariantItem(group, itemPositionId) {
442
- if (!group)
443
- return null;
444
- return normalizeArray(group.variant_item).find(
445
- (item) => isSameId(item.position_id, itemPositionId) || isSameId(item.id, itemPositionId)
446
- ) || null;
492
+ if (!group) return null;
493
+ return normalizeArray(group.variant_item).find(item => isSameId(item.position_id, itemPositionId) || isSameId(item.id, itemPositionId)) || null;
447
494
  }
448
495
  function getProductTitleSource(source, locale) {
449
- if (!source || typeof source !== "object")
450
- return "";
496
+ if (!source || typeof source !== 'object') return '';
451
497
  return resolveTitleValue(source.product_title, locale) || resolveTitleValue(source.title, locale) || resolveTitleValue(source.name, locale);
452
498
  }
453
499
  function resolveTitleValue(value, locale) {
454
- if (value === void 0 || value === null)
455
- return "";
456
- if (typeof value !== "object")
457
- return stringify(value);
458
- const dashedLocale = locale.replace("_", "-");
459
- const underscoredLocale = locale.replace("-", "_");
460
- return stringify(
461
- value[locale] ?? value[dashedLocale] ?? value[underscoredLocale] ?? value.original ?? value.auto ?? ""
462
- );
500
+ if (value === undefined || value === null) return '';
501
+ if (typeof value !== 'object') return stringify(value);
502
+ const dashedLocale = locale.replace('_', '-');
503
+ const underscoredLocale = locale.replace('-', '_');
504
+ return stringify(value[locale] ?? value[dashedLocale] ?? value[underscoredLocale] ?? value.original ?? value.auto ?? '');
463
505
  }
464
506
  function resolveOptionTitleFromParentProduct(params) {
465
- const { option, parentProduct, locale } = params;
466
- if (!parentProduct)
467
- return "";
507
+ const {
508
+ option,
509
+ parentProduct,
510
+ locale
511
+ } = params;
512
+ if (!parentProduct) return '';
468
513
  const optionItems = flattenOptionItems(parentProduct);
469
- const matchedOption = optionItems.find((item) => isOptionItemMatch(option, item));
514
+ const matchedOption = optionItems.find(item => isOptionItemMatch(option, item));
470
515
  return getProductTitleSource(matchedOption, locale);
471
516
  }
472
517
  function flattenOptionItems(parentProduct) {
473
518
  const optionGroups = Array.isArray(parentProduct.option_group) ? parentProduct.option_group : [];
474
- return optionGroups.flatMap((group) => {
475
- const items = normalizeArray(
476
- group.option_item || group.option_items || group.option || group.options || group.items || group.children || group.product_option_item
477
- );
478
- return items.map((item) => ({
519
+ return optionGroups.flatMap(group => {
520
+ const items = normalizeArray(group.option_item || group.option_items || group.option || group.options || group.items || group.children || group.product_option_item);
521
+ return items.map(item => ({
479
522
  ...item,
480
523
  option_group_id: item.option_group_id ?? group.id ?? group.option_group_id
481
524
  }));
@@ -484,8 +527,7 @@ function flattenOptionItems(parentProduct) {
484
527
  function isOptionItemMatch(option, item) {
485
528
  const optionItemId = option.option_group_item_id ?? option.product_option_item_id ?? option.id;
486
529
  const itemId = item.option_group_item_id ?? item.product_option_item_id ?? item.id;
487
- if (!isSameId(optionItemId, itemId))
488
- return false;
530
+ if (!isSameId(optionItemId, itemId)) return false;
489
531
  const optionGroupId = option.option_group_id ?? option.group_id;
490
532
  const itemGroupId = item.option_group_id ?? item.group_id;
491
533
  if (isPresentId(optionGroupId) && isPresentId(itemGroupId)) {
@@ -494,86 +536,83 @@ function isOptionItemMatch(option, item) {
494
536
  return true;
495
537
  }
496
538
  function resolveBundleItemFromParentProduct(params) {
497
- const { bundle, parentProduct } = params;
498
- if (!parentProduct)
499
- return null;
539
+ const {
540
+ bundle,
541
+ parentProduct
542
+ } = params;
543
+ if (!parentProduct) return null;
500
544
  const bundleItems = flattenBundleItems(parentProduct);
501
545
  const bundleVariantId = bundle.bundle_variant_id ?? bundle.variant_id ?? bundle.product_variant_id;
502
546
  if (isNonZeroId(bundleVariantId)) {
503
- const matchedByVariant = bundleItems.find(
504
- (item) => isSameId(item.bundle_variant_id ?? item.variant_id ?? item.product_variant_id, bundleVariantId)
505
- );
506
- if (matchedByVariant)
507
- return matchedByVariant;
547
+ const matchedByVariant = bundleItems.find(item => isSameId(item.bundle_variant_id ?? item.variant_id ?? item.product_variant_id, bundleVariantId));
548
+ if (matchedByVariant) return matchedByVariant;
508
549
  }
509
550
  const bundleId = bundle.bundle_id ?? bundle.id;
510
551
  if (isPresentId(bundleId)) {
511
- const matchedByBundleId = bundleItems.find((item) => isSameId(item.id ?? item.bundle_id, bundleId));
512
- if (matchedByBundleId)
513
- return matchedByBundleId;
552
+ const matchedByBundleId = bundleItems.find(item => isSameId(item.id ?? item.bundle_id, bundleId));
553
+ if (matchedByBundleId) return matchedByBundleId;
514
554
  }
515
555
  const bundleGroupId = bundle.bundle_group_id ?? bundle.group_id;
516
556
  const bundleProductId = bundle.bundle_product_id ?? bundle._bundle_product_id ?? bundle.product_id;
517
557
  if (isPresentId(bundleGroupId) && isPresentId(bundleProductId)) {
518
- const matchedByGroupAndProduct = bundleItems.find(
519
- (item) => isSameId(item.group_id ?? item.bundle_group_id, bundleGroupId) && isSameId(item.bundle_product_id ?? item._bundle_product_id ?? item.product_id, bundleProductId)
520
- );
521
- if (matchedByGroupAndProduct)
522
- return matchedByGroupAndProduct;
558
+ const matchedByGroupAndProduct = bundleItems.find(item => isSameId(item.group_id ?? item.bundle_group_id, bundleGroupId) && isSameId(item.bundle_product_id ?? item._bundle_product_id ?? item.product_id, bundleProductId));
559
+ if (matchedByGroupAndProduct) return matchedByGroupAndProduct;
523
560
  }
524
561
  if (isPresentId(bundleProductId)) {
525
- return bundleItems.find(
526
- (item) => isSameId(item.bundle_product_id ?? item._bundle_product_id ?? item.product_id, bundleProductId)
527
- ) || null;
562
+ return bundleItems.find(item => isSameId(item.bundle_product_id ?? item._bundle_product_id ?? item.product_id, bundleProductId)) || null;
528
563
  }
529
564
  return null;
530
565
  }
531
566
  function flattenBundleItems(parentProduct) {
532
567
  const bundleGroups = Array.isArray(parentProduct.bundle_group) ? parentProduct.bundle_group : [];
533
- return bundleGroups.flatMap((group) => {
568
+ return bundleGroups.flatMap(group => {
534
569
  const items = Array.isArray(group.bundle_item) ? group.bundle_item : [];
535
- return items.map((item) => ({
570
+ return items.map(item => ({
536
571
  ...item,
537
572
  group_id: item.group_id ?? group.id ?? group.group_id
538
573
  }));
539
574
  });
540
575
  }
541
576
  function isNonZeroId(value) {
542
- return isPresentId(value) && String(value) !== "0";
577
+ return isPresentId(value) && String(value) !== '0';
543
578
  }
544
579
  function isPresentId(value) {
545
- return value !== void 0 && value !== null && value !== "";
580
+ return value !== undefined && value !== null && value !== '';
546
581
  }
547
582
  function isSameId(left, right) {
548
- if (!isPresentId(left) || !isPresentId(right))
549
- return false;
583
+ if (!isPresentId(left) || !isPresentId(right)) return false;
550
584
  return String(left) === String(right);
551
585
  }
552
586
  function buildOptionTitleSuffix(options) {
553
- const text = options.map((option) => {
587
+ const text = options.map(option => {
554
588
  const name = stringify(option.name).trim();
555
- if (!name)
556
- return "";
589
+ if (!name) return '';
557
590
  const quantity = option.num ?? 1;
558
591
  return `${name} x ${quantity}`;
559
- }).filter(Boolean).join(", ");
560
- return text ? `(${text})` : "";
592
+ }).filter(Boolean).join(', ');
593
+ return text ? `(${text})` : '';
561
594
  }
562
595
  function formatBundlePrice(bundle, currencySymbol) {
563
596
  const value = bundle.bundle_selling_price ?? bundle.bundle_sum_price ?? bundle.price ?? 0;
564
- const amount = new import_decimal.default(toMoneyNumber(value));
565
- const isNegative = bundle.price_type === "markdown";
566
- if (isNegative)
567
- return `-${currencySymbol}${amount.abs().toFixed(2)}`;
597
+ const amount = new _decimal.default(toMoneyNumber(value));
598
+ // 套餐价格协议:只有 markdown 是减价;加价与商品原价都保持正数。
599
+ const isNegative = bundle.price_type === 'markdown';
600
+ if (isNegative) return `-${currencySymbol}${amount.abs().toFixed(2)}`;
568
601
  return formatMoney(amount, currencySymbol);
569
602
  }
570
603
  function buildFees(params) {
571
- const { order, shopInfo, locale, products, summary, currencySymbol } = params;
604
+ const {
605
+ order,
606
+ shopInfo,
607
+ locale,
608
+ products,
609
+ summary,
610
+ currencySymbol
611
+ } = params;
572
612
  const fees = [];
573
613
  for (const surcharge of normalizeArray(order.surcharges || summary.surcharges)) {
574
614
  const value = surcharge.amount ?? surcharge.value ?? surcharge.total_amount;
575
- if (!isNonZero(value))
576
- continue;
615
+ if (!isNonZero(value)) continue;
577
616
  fees.push({
578
617
  item: getLocalizedValue(surcharge.name || surcharge.title || surcharge.item, locale),
579
618
  value: formatMoney(value, currencySymbol)
@@ -582,7 +621,7 @@ function buildFees(params) {
582
621
  const discountAmount = order.shop_discount ?? summary.discount_amount ?? order.discount_amount;
583
622
  if (isNonZero(discountAmount)) {
584
623
  fees.push({
585
- item: label(locale, "orderDiscount"),
624
+ item: label(locale, 'orderDiscount'),
586
625
  value: formatNegativeMoney(discountAmount, currencySymbol)
587
626
  });
588
627
  }
@@ -596,126 +635,154 @@ function buildFees(params) {
596
635
  const roundingAmount = summary.rounding_amount || order.rounding_amount;
597
636
  if (isNonZero(roundingAmount)) {
598
637
  fees.push({
599
- item: label(locale, "rounding"),
638
+ item: label(locale, 'rounding'),
600
639
  value: formatMoney(roundingAmount, currencySymbol)
601
640
  });
602
641
  }
603
642
  const payProcessingFee = summary.pay_service_charge_amount || order.pay_service_charge_amount;
604
643
  if (isNonZero(payProcessingFee)) {
605
644
  fees.push({
606
- item: label(locale, "payProcessingFee"),
645
+ item: label(locale, 'payProcessingFee'),
607
646
  value: formatMoney(payProcessingFee, currencySymbol)
608
647
  });
609
648
  }
610
649
  const productExpectAmount = summary.product_expect_amount || summary.product_amount || order.product_expect_amount;
611
650
  const productOriginalAmount = summary.product_original_amount ?? order.product_original_amount ?? productExpectAmount;
612
- const totalSavingsAmount = new import_decimal.default(toMoneyNumber(productOriginalAmount)).minus(toMoneyNumber(productExpectAmount)).plus(toMoneyNumber(discountAmount));
651
+ const totalSavingsAmount = new _decimal.default(toMoneyNumber(productOriginalAmount)).minus(toMoneyNumber(productExpectAmount)).plus(toMoneyNumber(discountAmount));
613
652
  return {
614
653
  fees,
615
654
  countFee: {
616
655
  total_amount: formatMoney(summary.total_amount || order.total_amount, currencySymbol),
617
656
  product_expect_amount: formatMoney(productExpectAmount, currencySymbol),
618
657
  expect_amount: formatMoney(summary.expect_amount || order.expect_amount || summary.total_amount || order.total_amount, currencySymbol),
619
- product_quantity: toNumber(
620
- summary.product_quantity || products.reduce((sum, product) => sum + product.product_quantity, 0),
621
- 0
622
- ),
658
+ product_quantity: toNumber(summary.product_quantity || products.reduce((sum, product) => sum + product.product_quantity, 0), 0),
623
659
  has_pay: formatMoney(calculateReceiptPaidAmount(order, summary), currencySymbol),
624
- payment_method: "",
660
+ payment_method: '',
625
661
  tax_title: stringify(summary.tax_title || order.tax_title || shopInfo.tax_title),
626
662
  total_refund_amount: formatMoney(summary.total_refund_amount || order.total_refund_amount, currencySymbol),
627
- ...isNonZero(roundingAmount) ? { rounding_amount: formatMoney(roundingAmount, currencySymbol) } : {},
628
- ...isNonZero(totalSavingsAmount) ? { order_total_discount: formatMoney(totalSavingsAmount, currencySymbol) } : {},
629
- ...isNonZero(payProcessingFee) ? { pay_processing_fee: formatMoney(payProcessingFee, currencySymbol) } : {},
630
- ...isNonZero(taxFee) ? { tax_fee: formatMoney(taxFee, currencySymbol) } : {}
663
+ ...(isNonZero(roundingAmount) ? {
664
+ rounding_amount: formatMoney(roundingAmount, currencySymbol)
665
+ } : {}),
666
+ ...(isNonZero(totalSavingsAmount) ? {
667
+ order_total_discount: formatMoney(totalSavingsAmount, currencySymbol)
668
+ } : {}),
669
+ ...(isNonZero(payProcessingFee) ? {
670
+ pay_processing_fee: formatMoney(payProcessingFee, currencySymbol)
671
+ } : {}),
672
+ ...(isNonZero(taxFee) ? {
673
+ tax_fee: formatMoney(taxFee, currencySymbol)
674
+ } : {})
631
675
  }
632
676
  };
633
677
  }
634
678
  function buildCustomer(order, locale) {
635
- var _a, _b, _c, _d;
636
- return [
637
- { item: label(locale, "contactName"), value: normalizeCustomerDisplayValue(order.customer_name || ((_a = order.customer) == null ? void 0 : _a.name) || ((_b = order.customer) == null ? void 0 : _b.display_name)) },
638
- { item: label(locale, "contactMobile"), value: stringify(order.phone || ((_c = order.customer) == null ? void 0 : _c.phone)) },
639
- { item: label(locale, "email"), value: stringify(order.email || ((_d = order.customer) == null ? void 0 : _d.email)) }
640
- ];
679
+ return [{
680
+ item: label(locale, 'contactName'),
681
+ value: normalizeCustomerDisplayValue(order.customer_name || order.customer?.name || order.customer?.display_name)
682
+ }, {
683
+ item: label(locale, 'contactMobile'),
684
+ value: stringify(order.phone || order.customer?.phone)
685
+ }, {
686
+ item: label(locale, 'email'),
687
+ value: stringify(order.email || order.customer?.email)
688
+ }];
641
689
  }
642
690
  function normalizeCustomerDisplayValue(value) {
643
691
  const text = stringify(value).trim();
644
- if (!text)
645
- return "Walk-In";
646
- if (text.toLowerCase() === "select a customer")
647
- return "Walk-In";
692
+ if (!text) return 'Walk-In';
693
+ if (text.toLowerCase() === 'select a customer') return 'Walk-In';
648
694
  return text;
649
695
  }
696
+ function buildDelivery(order, locale) {
697
+ const serviceType = stringify(order.metadata?.service_type || order.service_type || order.delivery_type);
698
+ if (!serviceType) return [];
699
+ const serviceTypeLabelKey = serviceTypeToLabelKey(serviceType);
700
+ const items = [{
701
+ item: '',
702
+ value: label(locale, serviceTypeLabelKey),
703
+ size: 2,
704
+ align: 'left'
705
+ }];
706
+ if (serviceType === 'shop_server' || serviceType === 'shop_service') {
707
+ items.push({
708
+ item: label(locale, 'pickUpTime'),
709
+ value: label(locale, 'asap')
710
+ });
711
+ }
712
+ return items;
713
+ }
650
714
  function buildAppointment(order, locale) {
651
- var _a, _b, _c, _d;
652
- const tableName = order.table_name || ((_a = order.metadata) == null ? void 0 : _a.table_name) || ((_c = (_b = order.metadata) == null ? void 0 : _b.table) == null ? void 0 : _c.name) || ((_d = order.form_data) == null ? void 0 : _d.table_name);
653
- if (!tableName)
654
- return [];
655
- return [
656
- {
657
- item: label(locale, "table"),
658
- value: getLocalizedValue(tableName, locale)
659
- }
660
- ];
715
+ const tableName = order.table_name || order.metadata?.table_name || order.metadata?.table?.name || order.form_data?.table_name;
716
+ if (!tableName) return [];
717
+ return [{
718
+ item: label(locale, 'table'),
719
+ value: getLocalizedValue(tableName, locale)
720
+ }];
661
721
  }
662
722
  function buildResources(order, locale) {
663
- return normalizeArray(order.resources || order.resource_list).map((resource) => ({
664
- id: resource.id || resource.resource_id || "",
665
- code: "",
723
+ return normalizeArray(order.resources || order.resource_list).map(resource => ({
724
+ id: resource.id || resource.resource_id || '',
725
+ code: '',
666
726
  title: getLocalizedValue(resource.title || resource.name, locale),
667
- form_title: getLocalizedValue(resource.form_title || resource.type || "", locale)
727
+ form_title: getLocalizedValue(resource.form_title || resource.type || '', locale)
668
728
  }));
669
729
  }
670
730
  function buildPaymentData(params) {
671
731
  const payments = normalizeArray(params.order.payments);
672
- return payments.filter((payment) => isPrintablePayment(payment)).map((payment) => {
673
- var _a;
674
- const items = [
675
- {
676
- item: paymentMethodName(payment, params.locale),
677
- value: formatMoney(payment.amount ?? payment.origin_amount, params.currencySymbol)
678
- }
679
- ];
732
+ return payments.filter(payment => isPrintablePayment(payment)).map(payment => {
733
+ const items = [{
734
+ item: paymentMethodName(payment, params.locale),
735
+ value: formatMoney(payment.amount ?? payment.origin_amount, params.currencySymbol)
736
+ }];
680
737
  const fundRecord = getFundRecord(payment);
681
738
  if (fundRecord) {
682
- items.push(...buildFundRecordPaymentItems({ payment, fundRecord, locale: params.locale, currencySymbol: params.currencySymbol }));
739
+ items.push(...buildFundRecordPaymentItems({
740
+ payment,
741
+ fundRecord,
742
+ locale: params.locale,
743
+ currencySymbol: params.currencySymbol
744
+ }));
683
745
  } else {
684
- const remainingAmount = payment.remaining_amount ?? payment.balance ?? ((_a = payment.metadata) == null ? void 0 : _a.remaining_amount);
685
- if (remainingAmount !== void 0 && remainingAmount !== null) {
746
+ const remainingAmount = payment.remaining_amount ?? payment.balance ?? payment.metadata?.remaining_amount;
747
+ if (remainingAmount !== undefined && remainingAmount !== null) {
686
748
  items.push({
687
- item: label(params.locale, "remainingAmount"),
749
+ item: label(params.locale, 'remainingAmount'),
688
750
  value: formatMoney(remainingAmount, params.currencySymbol)
689
751
  });
690
752
  }
691
753
  }
692
754
  items.push({
693
- item: formatDateTime(payment.paid_at || payment.created_at || payment.updated_at || /* @__PURE__ */ new Date(), params.locale),
694
- value: ""
755
+ item: formatDateTime(payment.paid_at || payment.created_at || payment.updated_at || new Date(), params.locale),
756
+ value: ''
695
757
  });
696
758
  return items;
697
759
  });
698
760
  }
699
761
  function buildFundRecordPaymentItems(params) {
700
- const { payment, fundRecord, locale, currencySymbol } = params;
762
+ const {
763
+ payment,
764
+ fundRecord,
765
+ locale,
766
+ currencySymbol
767
+ } = params;
701
768
  const items = [];
702
769
  const usingBeforeValue = fundRecord.using_before_value;
703
770
  const usingAfterValue = fundRecord.using_after_value;
704
- if (isPointCardPayment(payment) && usingBeforeValue !== void 0 && usingAfterValue !== void 0) {
705
- const usedPoints = new import_decimal.default(toMoneyNumber(usingBeforeValue)).minus(toMoneyNumber(usingAfterValue));
771
+ if (isPointCardPayment(payment) && usingBeforeValue !== undefined && usingAfterValue !== undefined) {
772
+ const usedPoints = new _decimal.default(toMoneyNumber(usingBeforeValue)).minus(toMoneyNumber(usingAfterValue));
706
773
  items.push({
707
- item: label(locale, "redeemPoints"),
774
+ item: label(locale, 'redeemPoints'),
708
775
  value: trimDecimal(usedPoints)
709
776
  });
710
777
  items.push({
711
- item: label(locale, "remainingPoints"),
712
- value: trimDecimal(new import_decimal.default(toMoneyNumber(usingAfterValue)))
778
+ item: label(locale, 'remainingPoints'),
779
+ value: trimDecimal(new _decimal.default(toMoneyNumber(usingAfterValue)))
713
780
  });
714
781
  return items;
715
782
  }
716
- if (usingAfterValue !== void 0 && usingAfterValue !== null) {
783
+ if (usingAfterValue !== undefined && usingAfterValue !== null) {
717
784
  items.push({
718
- item: label(locale, "remainingAmount"),
785
+ item: label(locale, 'remainingAmount'),
719
786
  value: formatMoney(usingAfterValue, currencySymbol)
720
787
  });
721
788
  }
@@ -723,169 +790,131 @@ function buildFundRecordPaymentItems(params) {
723
790
  }
724
791
  function getFundRecord(payment) {
725
792
  const fundRecord = payment.fund_record;
726
- if (!fundRecord || typeof fundRecord !== "object" || Array.isArray(fundRecord))
727
- return null;
728
- if (!fundRecord.voucher_id && !fundRecord.code)
729
- return null;
793
+ if (!fundRecord || typeof fundRecord !== 'object' || Array.isArray(fundRecord)) return null;
794
+ if (!fundRecord.voucher_id && !fundRecord.code) return null;
730
795
  return fundRecord;
731
796
  }
732
797
  function isPointCardPayment(payment) {
733
- var _a;
734
798
  const code = stringify(payment.code || payment.payment_method).toUpperCase();
735
- const type = stringify(payment.type || ((_a = payment.fund_record) == null ? void 0 : _a.tag)).toLowerCase();
736
- return code === "POINTCARD" || type === "point_card";
799
+ const type = stringify(payment.type || payment.fund_record?.tag).toLowerCase();
800
+ return code === 'POINTCARD' || type === 'point_card';
737
801
  }
738
802
  function maskMachineCode(code) {
739
803
  const text = stringify(code);
740
- if (text.length <= 6)
741
- return text;
804
+ if (text.length <= 6) return text;
742
805
  return `${text.slice(0, 2)}**${text.slice(-4)}`;
743
806
  }
744
807
  function trimDecimal(value) {
745
- return value.toDecimalPlaces(2).toFixed(2).replace(/\.?0+$/, "");
808
+ return value.toDecimalPlaces(2).toFixed(2).replace(/\.?0+$/, '');
746
809
  }
747
810
  function getFundRecordPaymentName(payment, locale) {
748
811
  const fundRecord = getFundRecord(payment);
749
- if (!fundRecord)
750
- return "";
812
+ if (!fundRecord) return '';
751
813
  const name = getLocalizedValue(fundRecord.wallet_pass_name, locale);
752
814
  const code = maskMachineCode(fundRecord.code);
753
- if (!name && !code)
754
- return "";
755
- if (!code)
756
- return name;
757
- const fallbackName = getLocalizedValue(
758
- payment.name || payment.title || payment.payment_method_name || payment.method_name || payment.code,
759
- locale
760
- );
815
+ if (!name && !code) return '';
816
+ if (!code) return name;
817
+ const fallbackName = getLocalizedValue(payment.name || payment.title || payment.payment_method_name || payment.method_name || payment.code, locale);
761
818
  return `${name || fallbackName}(${code})`;
762
819
  }
763
820
  function appendMachineCodeToName(name, payment) {
764
821
  const fundRecord = getFundRecord(payment);
765
- if (!(fundRecord == null ? void 0 : fundRecord.code))
766
- return name;
822
+ if (!fundRecord?.code) return name;
767
823
  return `${name}(${maskMachineCode(fundRecord.code)})`;
768
824
  }
769
825
  function paymentMethodName(payment, locale) {
770
826
  const fundRecordName = getFundRecordPaymentName(payment, locale);
771
- if (fundRecordName)
772
- return fundRecordName;
827
+ if (fundRecordName) return fundRecordName;
773
828
  const raw = payment.name || payment.title || payment.payment_method_name || payment.method_name;
774
- if (raw)
775
- return appendMachineCodeToName(getLocalizedValue(raw, locale), payment);
829
+ if (raw) return appendMachineCodeToName(getLocalizedValue(raw, locale), payment);
776
830
  const code = stringify(payment.code || payment.type || payment.payment_method || payment.method).toLowerCase();
777
- if (code.includes("cash"))
778
- return label(locale, "cash");
779
- if (code.includes("eftpos") || code.includes("card"))
780
- return label(locale, "eftpos");
781
- if (code.includes("wallet"))
782
- return label(locale, "wallet");
783
- if (code.includes("gift"))
784
- return label(locale, "giftCard");
831
+ if (code.includes('cash')) return label(locale, 'cash');
832
+ if (code.includes('eftpos') || code.includes('card')) return label(locale, 'eftpos');
833
+ if (code.includes('wallet')) return label(locale, 'wallet');
834
+ if (code.includes('gift')) return label(locale, 'giftCard');
785
835
  return stringify(payment.code || payment.type || payment.payment_method || payment.method);
786
836
  }
787
837
  function getSummary(order) {
788
- return order.summary && typeof order.summary === "object" ? order.summary : order;
838
+ return order.summary && typeof order.summary === 'object' ? order.summary : order;
789
839
  }
790
840
  function getCurrencySymbol(order, shopInfo) {
791
- return stringify(order.currency_symbol || (shopInfo == null ? void 0 : shopInfo.currency_symbol) || order.shop_symbol || "$") || "$";
841
+ return stringify(order.currency_symbol || shopInfo?.currency_symbol || order.shop_symbol || '$') || '$';
792
842
  }
793
843
  function resolveLocales(shopInfo, locales) {
794
- const preferred = [
795
- ...locales || [],
796
- shopInfo.primary_locale,
797
- ...DEFAULT_LOCALES
798
- ].filter(Boolean);
844
+ const preferred = [...(locales || []), shopInfo.primary_locale, ...DEFAULT_LOCALES].filter(Boolean);
799
845
  return Array.from(new Set(preferred.map(normalizeLocaleKey)));
800
846
  }
801
847
  function normalizeLocaleKey(locale) {
802
- return locale.replace("-", "_");
848
+ return locale.replace('-', '_');
803
849
  }
804
850
  function label(locale, key) {
805
- var _a;
806
- return ((_a = LABELS[locale]) == null ? void 0 : _a[key]) || LABELS.en[key] || key;
851
+ return LABELS[locale]?.[key] || LABELS.en[key] || key;
807
852
  }
808
853
  function getLocalizedValue(value, locale) {
809
- if (value === void 0 || value === null)
810
- return "";
811
- if (typeof value !== "object")
812
- return stringify(value);
813
- const dashedLocale = locale.replace("_", "-");
814
- const underscoredLocale = locale.replace("-", "_");
815
- return stringify(
816
- value[locale] ?? value[dashedLocale] ?? value[underscoredLocale] ?? value.original ?? value.auto ?? value.default ?? value.en ?? ""
817
- );
854
+ if (value === undefined || value === null) return '';
855
+ if (typeof value !== 'object') return stringify(value);
856
+ const dashedLocale = locale.replace('_', '-');
857
+ const underscoredLocale = locale.replace('-', '_');
858
+ return stringify(value[locale] ?? value[dashedLocale] ?? value[underscoredLocale] ?? value.original ?? value.auto ?? value.default ?? value.en ?? '');
859
+ }
860
+ function serviceTypeToLabelKey(serviceType) {
861
+ const normalized = serviceType.toLowerCase();
862
+ if (normalized.includes('take')) return 'takeAway';
863
+ if (normalized.includes('delivery')) return 'delivery';
864
+ if (normalized.includes('pick')) return 'pickUp';
865
+ if (normalized.includes('shop')) return 'shopService';
866
+ return 'dineIn';
818
867
  }
819
868
  function buildShopAddress(shopInfo) {
820
- return [
821
- shopInfo.address_street,
822
- shopInfo.address_detail,
823
- shopInfo.city,
824
- shopInfo.province,
825
- shopInfo.country,
826
- shopInfo.zip
827
- ].filter(Boolean).join(", ");
869
+ return [shopInfo.address_street, shopInfo.address_detail, shopInfo.city, shopInfo.province, shopInfo.country, shopInfo.zip].filter(Boolean).join(', ');
828
870
  }
829
871
  function formatDateTime(value, locale) {
830
- const date = (0, import_dayjs.default)(value);
831
- if (!date.isValid())
832
- return stringify(value);
833
- if (locale === "en")
834
- return date.format("HH:mm:ss DD/MM/YYYY");
835
- return date.format("YYYY/MM/DD HH:mm:ss");
872
+ const date = (0, _dayjs.default)(value);
873
+ if (!date.isValid()) return stringify(value);
874
+ if (locale === 'en') return date.format('HH:mm:ss DD/MM/YYYY');
875
+ return date.format('YYYY/MM/DD HH:mm:ss');
836
876
  }
837
877
  function formatMoney(value, currencySymbol) {
838
- if (value instanceof import_decimal.default)
839
- return `${currencySymbol}${value.toFixed(2)}`;
840
- if (typeof value === "string" && value.trim().startsWith(currencySymbol))
841
- return value;
842
- const amount = new import_decimal.default(toMoneyNumber(value));
878
+ if (value instanceof _decimal.default) return `${currencySymbol}${value.toFixed(2)}`;
879
+ if (typeof value === 'string' && value.trim().startsWith(currencySymbol)) return value;
880
+ const amount = new _decimal.default(toMoneyNumber(value));
843
881
  return `${currencySymbol}${amount.toFixed(2)}`;
844
882
  }
845
883
  function formatNegativeMoney(value, currencySymbol) {
846
- const amount = new import_decimal.default(toMoneyNumber(value)).abs();
884
+ const amount = new _decimal.default(toMoneyNumber(value)).abs();
847
885
  return `-${currencySymbol}${amount.toFixed(2)}`;
848
886
  }
849
887
  function calculateReceiptPaidAmount(order, summary) {
850
888
  const paidAmount = sumPayments(order.payments);
851
- const payProcessingFee = new import_decimal.default(
852
- toMoneyNumber(summary.pay_service_charge_amount ?? order.pay_service_charge_amount)
853
- );
854
- if (payProcessingFee.lte(0))
855
- return paidAmount;
856
- const totalAmount = new import_decimal.default(toMoneyNumber(summary.total_amount ?? order.total_amount));
857
- if (totalAmount.gt(0) && paidAmount.gte(totalAmount))
858
- return paidAmount;
889
+ const payProcessingFee = new _decimal.default(toMoneyNumber(summary.pay_service_charge_amount ?? order.pay_service_charge_amount));
890
+ if (payProcessingFee.lte(0)) return paidAmount;
891
+ const totalAmount = new _decimal.default(toMoneyNumber(summary.total_amount ?? order.total_amount));
892
+ if (totalAmount.gt(0) && paidAmount.gte(totalAmount)) return paidAmount;
859
893
  const paidAmountWithFee = paidAmount.plus(payProcessingFee);
860
- if (totalAmount.gt(0) && paidAmountWithFee.gt(totalAmount))
861
- return totalAmount;
894
+ if (totalAmount.gt(0) && paidAmountWithFee.gt(totalAmount)) return totalAmount;
862
895
  return paidAmountWithFee;
863
896
  }
864
897
  function sumPayments(payments) {
865
- return normalizeArray(payments).filter((payment) => isPrintablePayment(payment)).reduce((sum, payment) => {
898
+ return normalizeArray(payments).filter(payment => isPrintablePayment(payment)).reduce((sum, payment) => {
866
899
  return sum.plus(toMoneyNumber(payment.amount ?? payment.origin_amount));
867
- }, new import_decimal.default(0));
900
+ }, new _decimal.default(0));
868
901
  }
869
902
  function isPrintablePayment(payment) {
870
903
  const status = stringify(payment.status).toLowerCase();
871
- if (!status)
872
- return true;
873
- return ["paid", "success", "succeeded", "completed"].includes(status);
904
+ if (!status) return true;
905
+ return ['paid', 'success', 'succeeded', 'completed'].includes(status);
874
906
  }
875
907
  function normalizeArray(value) {
876
908
  return Array.isArray(value) ? value : [];
877
909
  }
878
910
  function isNonZero(value) {
879
- return !new import_decimal.default(toMoneyNumber(value)).isZero();
911
+ return !new _decimal.default(toMoneyNumber(value)).isZero();
880
912
  }
881
913
  function toMoneyNumber(value) {
882
- if (value instanceof import_decimal.default)
883
- return value.toString();
884
- if (typeof value === "number")
885
- return Number.isFinite(value) ? value : 0;
886
- if (typeof value !== "string")
887
- return 0;
888
- const normalized = value.replace(/[^\d.-]/g, "");
914
+ if (value instanceof _decimal.default) return value.toString();
915
+ if (typeof value === 'number') return Number.isFinite(value) ? value : 0;
916
+ if (typeof value !== 'string') return 0;
917
+ const normalized = value.replace(/[^\d.-]/g, '');
889
918
  return normalized || 0;
890
919
  }
891
920
  function toNumber(value, fallback) {
@@ -893,12 +922,6 @@ function toNumber(value, fallback) {
893
922
  return Number.isFinite(numberValue) ? numberValue : fallback;
894
923
  }
895
924
  function stringify(value) {
896
- if (value === void 0 || value === null)
897
- return "";
925
+ if (value === undefined || value === null) return '';
898
926
  return String(value);
899
- }
900
- // Annotate the CommonJS export names for ESM import in node:
901
- 0 && (module.exports = {
902
- buildSmallTicketData,
903
- hasSmallTicketData
904
- });
927
+ }