@pisell/pisellos 2.2.242 → 2.2.244

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 (314) hide show
  1. package/dist/model/strategy/adapter/promotion/evaluator.js +2 -3
  2. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  3. package/dist/model/strategy/adapter/walletPass/utils.js +4 -7
  4. package/dist/modules/Cart/utils/cartProduct.js +3 -24
  5. package/dist/modules/Cart/utils/changePrice.js +11 -11
  6. package/dist/modules/Customer/index.d.ts +0 -20
  7. package/dist/modules/Customer/index.js +83 -172
  8. package/dist/modules/Customer/types.d.ts +0 -2
  9. package/dist/modules/Discount/index.js +3 -4
  10. package/dist/modules/Discount/types.d.ts +0 -1
  11. package/dist/modules/OpenData/index.d.ts +0 -8
  12. package/dist/modules/OpenData/index.js +17 -37
  13. package/dist/modules/Order/index.d.ts +18 -268
  14. package/dist/modules/Order/index.js +757 -3306
  15. package/dist/modules/Order/types.d.ts +31 -279
  16. package/dist/modules/Order/types.js +0 -38
  17. package/dist/modules/Order/utils.d.ts +5 -147
  18. package/dist/modules/Order/utils.js +103 -746
  19. package/dist/modules/Payment/index.d.ts +13 -10
  20. package/dist/modules/Payment/index.js +837 -467
  21. package/dist/modules/Payment/types.d.ts +0 -2
  22. package/dist/modules/Payment/utils.js +1 -2
  23. package/dist/modules/Payment/walletpass.js +7 -14
  24. package/dist/modules/ProductList/index.d.ts +12 -16
  25. package/dist/modules/ProductList/index.js +59 -133
  26. package/dist/modules/ProductList/types.d.ts +0 -14
  27. package/dist/modules/Quotation/index.d.ts +1 -0
  28. package/dist/modules/Quotation/index.js +22 -25
  29. package/dist/modules/Rules/index.d.ts +0 -4
  30. package/dist/modules/Rules/index.js +69 -93
  31. package/dist/modules/Rules/types.d.ts +0 -1
  32. package/dist/modules/SalesSummary/index.d.ts +25 -8
  33. package/dist/modules/SalesSummary/index.js +35 -86
  34. package/dist/modules/SalesSummary/types.d.ts +1 -4
  35. package/dist/modules/SalesSummary/utils.d.ts +25 -2
  36. package/dist/modules/SalesSummary/utils.js +162 -794
  37. package/dist/modules/Schedule/index.d.ts +0 -7
  38. package/dist/modules/Schedule/index.js +2 -24
  39. package/dist/modules/Summary/index.js +3 -4
  40. package/dist/modules/index.d.ts +0 -2
  41. package/dist/modules/index.js +1 -3
  42. package/dist/plugins/request.d.ts +0 -1
  43. package/dist/server/index.d.ts +1 -204
  44. package/dist/server/index.js +928 -3659
  45. package/dist/server/modules/index.d.ts +0 -2
  46. package/dist/server/modules/index.js +0 -2
  47. package/dist/server/modules/order/index.d.ts +4 -120
  48. package/dist/server/modules/order/index.js +483 -1779
  49. package/dist/server/modules/order/types.d.ts +3 -32
  50. package/dist/server/modules/order/types.js +0 -8
  51. package/dist/server/modules/order/utils/filterBookings.js +3 -26
  52. package/dist/server/modules/order/utils/filterOrders.js +8 -23
  53. package/dist/server/modules/products/index.d.ts +7 -34
  54. package/dist/server/modules/products/index.js +317 -631
  55. package/dist/server/modules/resource/index.d.ts +0 -2
  56. package/dist/server/modules/resource/index.js +3 -29
  57. package/dist/server/modules/schedule/index.d.ts +4 -4
  58. package/dist/server/modules/schedule/index.js +88 -111
  59. package/dist/solution/BaseSales/index.d.ts +9 -131
  60. package/dist/solution/BaseSales/index.js +447 -1944
  61. package/dist/solution/BaseSales/types.d.ts +6 -76
  62. package/dist/solution/BaseSales/types.js +4 -5
  63. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +0 -1
  64. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +24 -105
  65. package/dist/solution/BaseSales/utils.d.ts +1 -1
  66. package/dist/solution/BaseSales/utils.js +21 -62
  67. package/dist/solution/BookingByStep/index.d.ts +1 -1
  68. package/dist/solution/BookingTicket/index.d.ts +10 -270
  69. package/dist/solution/BookingTicket/index.js +237 -1772
  70. package/dist/solution/BookingTicket/types.d.ts +1 -118
  71. package/dist/solution/BookingTicket/types.js +2 -41
  72. package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +0 -40
  73. package/dist/solution/BookingTicket/utils/bookingStatus.js +0 -70
  74. package/dist/solution/BookingTicket/utils/cartView.d.ts +1 -9
  75. package/dist/solution/BookingTicket/utils/cartView.js +7 -94
  76. package/dist/solution/BookingTicket/utils/scan/index.d.ts +0 -5
  77. package/dist/solution/BookingTicket/utils/scan/index.js +8 -20
  78. package/dist/solution/Checkout/appointmentDemo.json +1 -0
  79. package/dist/solution/Checkout/index.d.ts +0 -1
  80. package/dist/solution/Checkout/index.js +9 -10
  81. package/dist/solution/RegisterAndLogin/config.js +10 -2
  82. package/dist/solution/ScanOrder/index.d.ts +3 -9
  83. package/dist/solution/ScanOrder/index.js +134 -241
  84. package/dist/solution/ScanOrder/types.d.ts +5 -9
  85. package/dist/solution/ScanOrder/types.js +3 -2
  86. package/dist/solution/ScanOrder/utils.d.ts +1 -1
  87. package/dist/solution/ScanOrder/utils.js +22 -84
  88. package/dist/solution/VenueBooking/index.d.ts +2 -5
  89. package/dist/solution/VenueBooking/index.js +59 -110
  90. package/dist/solution/VenueBooking/sales-section-4-annotated.json +2 -0
  91. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  92. package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
  93. package/dist/types/index.d.ts +0 -10
  94. package/lib/model/strategy/adapter/promotion/evaluator.js +1 -2
  95. package/lib/model/strategy/adapter/walletPass/utils.js +2 -3
  96. package/lib/modules/Cart/utils/cartProduct.js +3 -20
  97. package/lib/modules/Cart/utils/changePrice.js +20 -12
  98. package/lib/modules/Customer/index.d.ts +0 -20
  99. package/lib/modules/Customer/index.js +11 -64
  100. package/lib/modules/Customer/types.d.ts +0 -2
  101. package/lib/modules/Discount/index.js +1 -5
  102. package/lib/modules/Discount/types.d.ts +0 -1
  103. package/lib/modules/OpenData/index.d.ts +0 -8
  104. package/lib/modules/OpenData/index.js +5 -19
  105. package/lib/modules/Order/index.d.ts +18 -268
  106. package/lib/modules/Order/index.js +344 -2149
  107. package/lib/modules/Order/types.d.ts +31 -279
  108. package/lib/modules/Order/types.js +0 -1
  109. package/lib/modules/Order/utils.d.ts +5 -147
  110. package/lib/modules/Order/utils.js +46 -614
  111. package/lib/modules/Payment/index.d.ts +13 -10
  112. package/lib/modules/Payment/index.js +150 -18
  113. package/lib/modules/Payment/types.d.ts +0 -2
  114. package/lib/modules/Payment/utils.js +1 -2
  115. package/lib/modules/Payment/walletpass.js +3 -7
  116. package/lib/modules/ProductList/index.d.ts +12 -16
  117. package/lib/modules/ProductList/index.js +4 -41
  118. package/lib/modules/ProductList/types.d.ts +0 -14
  119. package/lib/modules/Quotation/index.d.ts +1 -0
  120. package/lib/modules/Quotation/index.js +16 -19
  121. package/lib/modules/Rules/index.d.ts +0 -4
  122. package/lib/modules/Rules/index.js +120 -136
  123. package/lib/modules/Rules/types.d.ts +0 -1
  124. package/lib/modules/SalesSummary/index.d.ts +25 -8
  125. package/lib/modules/SalesSummary/index.js +4 -30
  126. package/lib/modules/SalesSummary/types.d.ts +1 -4
  127. package/lib/modules/SalesSummary/utils.d.ts +25 -2
  128. package/lib/modules/SalesSummary/utils.js +91 -645
  129. package/lib/modules/Schedule/index.d.ts +0 -7
  130. package/lib/modules/Schedule/index.js +1 -17
  131. package/lib/modules/Summary/index.js +4 -5
  132. package/lib/modules/index.d.ts +0 -2
  133. package/lib/modules/index.js +1 -5
  134. package/lib/plugins/request.d.ts +0 -1
  135. package/lib/server/index.d.ts +1 -204
  136. package/lib/server/index.js +57 -1889
  137. package/lib/server/modules/index.d.ts +0 -2
  138. package/lib/server/modules/index.js +0 -3
  139. package/lib/server/modules/order/index.d.ts +4 -120
  140. package/lib/server/modules/order/index.js +142 -919
  141. package/lib/server/modules/order/types.d.ts +3 -32
  142. package/lib/server/modules/order/utils/filterBookings.js +5 -24
  143. package/lib/server/modules/order/utils/filterOrders.js +6 -15
  144. package/lib/server/modules/products/index.d.ts +7 -34
  145. package/lib/server/modules/products/index.js +54 -189
  146. package/lib/server/modules/resource/index.d.ts +0 -2
  147. package/lib/server/modules/resource/index.js +3 -27
  148. package/lib/server/modules/schedule/index.d.ts +4 -4
  149. package/lib/server/modules/schedule/index.js +40 -47
  150. package/lib/solution/BaseSales/index.d.ts +9 -131
  151. package/lib/solution/BaseSales/index.js +63 -1106
  152. package/lib/solution/BaseSales/types.d.ts +6 -76
  153. package/lib/solution/BaseSales/types.js +1 -3
  154. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +0 -1
  155. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +18 -106
  156. package/lib/solution/BaseSales/utils.d.ts +1 -1
  157. package/lib/solution/BaseSales/utils.js +10 -54
  158. package/lib/solution/BookingByStep/index.d.ts +1 -1
  159. package/lib/solution/BookingTicket/index.d.ts +10 -270
  160. package/lib/solution/BookingTicket/index.js +29 -922
  161. package/lib/solution/BookingTicket/types.d.ts +1 -118
  162. package/lib/solution/BookingTicket/types.js +0 -11
  163. package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +0 -40
  164. package/lib/solution/BookingTicket/utils/bookingStatus.js +2 -44
  165. package/lib/solution/BookingTicket/utils/cartView.d.ts +1 -9
  166. package/lib/solution/BookingTicket/utils/cartView.js +6 -61
  167. package/lib/solution/BookingTicket/utils/scan/index.d.ts +0 -5
  168. package/lib/solution/BookingTicket/utils/scan/index.js +3 -17
  169. package/lib/solution/Checkout/appointmentDemo.json +1 -0
  170. package/lib/solution/Checkout/index.d.ts +0 -1
  171. package/lib/solution/Checkout/index.js +2 -1
  172. package/lib/solution/RegisterAndLogin/config.js +10 -2
  173. package/lib/solution/ScanOrder/index.d.ts +3 -9
  174. package/lib/solution/ScanOrder/index.js +70 -153
  175. package/lib/solution/ScanOrder/types.d.ts +5 -9
  176. package/lib/solution/ScanOrder/utils.d.ts +1 -1
  177. package/lib/solution/ScanOrder/utils.js +17 -83
  178. package/lib/solution/VenueBooking/index.d.ts +2 -5
  179. package/lib/solution/VenueBooking/index.js +17 -54
  180. package/lib/solution/VenueBooking/sales-section-4-annotated.json +2 -0
  181. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  182. package/lib/solution/VenueBooking/utils/slotMerge.js +0 -10
  183. package/lib/types/index.d.ts +0 -10
  184. package/package.json +1 -1
  185. package/dist/modules/BookingContext/index.d.ts +0 -48
  186. package/dist/modules/BookingContext/index.js +0 -566
  187. package/dist/modules/BookingContext/types.d.ts +0 -102
  188. package/dist/modules/BookingContext/types.js +0 -51
  189. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  190. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -284
  191. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  192. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -145
  193. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -76
  194. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -218
  195. package/dist/modules/BookingContext/utils/flexible.d.ts +0 -28
  196. package/dist/modules/BookingContext/utils/flexible.js +0 -56
  197. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  198. package/dist/modules/BookingContext/utils/formatResourceList.js +0 -38
  199. package/dist/modules/BookingContext/utils/index.d.ts +0 -11
  200. package/dist/modules/BookingContext/utils/index.js +0 -11
  201. package/dist/modules/BookingContext/utils/noResource.d.ts +0 -13
  202. package/dist/modules/BookingContext/utils/noResource.js +0 -77
  203. package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts +0 -1
  204. package/dist/modules/BookingContext/utils/orderLineDisplay.js +0 -36
  205. package/dist/modules/BookingContext/utils/productExtend.d.ts +0 -72
  206. package/dist/modules/BookingContext/utils/productExtend.js +0 -339
  207. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  208. package/dist/modules/BookingContext/utils/resourceErrors.js +0 -74
  209. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  210. package/dist/modules/BookingContext/utils/resourceSelection.js +0 -24
  211. package/dist/modules/BookingContext/utils/resources.d.ts +0 -80
  212. package/dist/modules/BookingContext/utils/resources.js +0 -486
  213. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  214. package/dist/modules/BookingContext/utils/serviceTimes.js +0 -151
  215. package/dist/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  216. package/dist/modules/BookingContext/utils/timeSlices.js +0 -100
  217. package/dist/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  218. package/dist/modules/Order/utils/manualProductDiscount.js +0 -210
  219. package/dist/modules/SurchargeList/index.d.ts +0 -16
  220. package/dist/modules/SurchargeList/index.js +0 -162
  221. package/dist/modules/SurchargeList/types.d.ts +0 -11
  222. package/dist/modules/SurchargeList/types.js +0 -1
  223. package/dist/server/modules/payment/index.d.ts +0 -28
  224. package/dist/server/modules/payment/index.js +0 -305
  225. package/dist/server/modules/payment/types.d.ts +0 -9
  226. package/dist/server/modules/payment/types.js +0 -1
  227. package/dist/server/test.json +0 -713
  228. package/dist/server/utils/small-ticket.d.ts +0 -71
  229. package/dist/server/utils/small-ticket.js +0 -830
  230. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +0 -287
  231. package/dist/solution/BaseSales/utils/cartPromotion.js +0 -1438
  232. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  233. package/dist/solution/BaseSales/utils/quotationPrice.js +0 -237
  234. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -117
  235. package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -346
  236. package/dist/solution/BookingTicket/utils/addTimeAvailability.d.ts +0 -35
  237. package/dist/solution/BookingTicket/utils/addTimeAvailability.js +0 -95
  238. package/dist/solution/BookingTicket/utils/exampleData.d.ts +0 -123
  239. package/dist/solution/BookingTicket/utils/exampleData.js +0 -183
  240. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +0 -185
  241. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.js +0 -438
  242. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -36
  243. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +0 -399
  244. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -32
  245. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +0 -56
  246. package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +0 -21
  247. package/dist/solution/BookingTicket/utils/scan/scanProductValues.js +0 -150
  248. package/dist/solution/BookingTicket/utils/sessionCatalogStale.d.ts +0 -23
  249. package/dist/solution/BookingTicket/utils/sessionCatalogStale.js +0 -78
  250. package/lib/modules/BookingContext/index.d.ts +0 -48
  251. package/lib/modules/BookingContext/index.js +0 -368
  252. package/lib/modules/BookingContext/types.d.ts +0 -102
  253. package/lib/modules/BookingContext/types.js +0 -34
  254. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  255. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -276
  256. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  257. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -151
  258. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -76
  259. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -201
  260. package/lib/modules/BookingContext/utils/flexible.d.ts +0 -28
  261. package/lib/modules/BookingContext/utils/flexible.js +0 -80
  262. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  263. package/lib/modules/BookingContext/utils/formatResourceList.js +0 -50
  264. package/lib/modules/BookingContext/utils/index.d.ts +0 -11
  265. package/lib/modules/BookingContext/utils/index.js +0 -43
  266. package/lib/modules/BookingContext/utils/noResource.d.ts +0 -13
  267. package/lib/modules/BookingContext/utils/noResource.js +0 -90
  268. package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +0 -1
  269. package/lib/modules/BookingContext/utils/orderLineDisplay.js +0 -56
  270. package/lib/modules/BookingContext/utils/productExtend.d.ts +0 -72
  271. package/lib/modules/BookingContext/utils/productExtend.js +0 -283
  272. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  273. package/lib/modules/BookingContext/utils/resourceErrors.js +0 -80
  274. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  275. package/lib/modules/BookingContext/utils/resourceSelection.js +0 -46
  276. package/lib/modules/BookingContext/utils/resources.d.ts +0 -80
  277. package/lib/modules/BookingContext/utils/resources.js +0 -377
  278. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  279. package/lib/modules/BookingContext/utils/serviceTimes.js +0 -162
  280. package/lib/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  281. package/lib/modules/BookingContext/utils/timeSlices.js +0 -124
  282. package/lib/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  283. package/lib/modules/Order/utils/manualProductDiscount.js +0 -206
  284. package/lib/modules/SurchargeList/index.d.ts +0 -16
  285. package/lib/modules/SurchargeList/index.js +0 -89
  286. package/lib/modules/SurchargeList/types.d.ts +0 -11
  287. package/lib/modules/SurchargeList/types.js +0 -17
  288. package/lib/server/modules/payment/index.d.ts +0 -28
  289. package/lib/server/modules/payment/index.js +0 -192
  290. package/lib/server/modules/payment/types.d.ts +0 -9
  291. package/lib/server/modules/payment/types.js +0 -17
  292. package/lib/server/test.json +0 -713
  293. package/lib/server/utils/small-ticket.d.ts +0 -71
  294. package/lib/server/utils/small-ticket.js +0 -781
  295. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +0 -287
  296. package/lib/solution/BaseSales/utils/cartPromotion.js +0 -992
  297. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  298. package/lib/solution/BaseSales/utils/quotationPrice.js +0 -277
  299. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -117
  300. package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -318
  301. package/lib/solution/BookingTicket/utils/addTimeAvailability.d.ts +0 -35
  302. package/lib/solution/BookingTicket/utils/addTimeAvailability.js +0 -125
  303. package/lib/solution/BookingTicket/utils/exampleData.d.ts +0 -123
  304. package/lib/solution/BookingTicket/utils/exampleData.js +0 -0
  305. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +0 -185
  306. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +0 -254
  307. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -36
  308. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +0 -168
  309. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -32
  310. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +0 -51
  311. package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +0 -21
  312. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +0 -127
  313. package/lib/solution/BookingTicket/utils/sessionCatalogStale.d.ts +0 -23
  314. package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +0 -85
@@ -1,781 +0,0 @@
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);
28
-
29
- // src/server/utils/small-ticket.ts
30
- var small_ticket_exports = {};
31
- __export(small_ticket_exports, {
32
- buildSmallTicketData: () => buildSmallTicketData,
33
- hasSmallTicketData: () => hasSmallTicketData
34
- });
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 = {
40
- 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
- payProcessingFee: "Pay processing fee",
61
- rounding: "Rounding"
62
- },
63
- zh_CN: {
64
- contactName: "联系人姓名",
65
- contactMobile: "联系电话",
66
- email: "邮箱",
67
- dineIn: "堂食",
68
- takeAway: "外带",
69
- delivery: "配送",
70
- pickUp: "自提",
71
- shopService: "堂食",
72
- pickUpTime: "取餐时间",
73
- asap: "尽快",
74
- cash: "现金支付",
75
- eftpos: "刷卡支付",
76
- wallet: "钱包支付",
77
- giftCard: "礼品卡",
78
- remainingAmount: "剩余金额",
79
- redeemPoints: "本次使用积分",
80
- remainingPoints: "剩余积分",
81
- table: "桌台",
82
- orderDiscount: "整单折扣",
83
- payProcessingFee: "支付手续费",
84
- rounding: "抹零"
85
- },
86
- zh_HK: {
87
- contactName: "聯絡人姓名",
88
- contactMobile: "聯絡電話",
89
- email: "電郵",
90
- dineIn: "堂食",
91
- takeAway: "外帶",
92
- delivery: "配送",
93
- pickUp: "自取",
94
- shopService: "堂食",
95
- pickUpTime: "取餐時間",
96
- asap: "盡快",
97
- cash: "現金支付",
98
- eftpos: "刷卡支付",
99
- wallet: "錢包支付",
100
- giftCard: "禮品卡",
101
- remainingAmount: "剩餘金額",
102
- redeemPoints: "本次使用積分",
103
- remainingPoints: "剩餘積分",
104
- table: "桌台",
105
- orderDiscount: "整單折扣",
106
- payProcessingFee: "支付手續費",
107
- rounding: "抹零"
108
- }
109
- };
110
- function buildSmallTicketData(params) {
111
- const order = params.order || {};
112
- const shopInfo = params.shopInfo || {};
113
- const locales = resolveLocales(shopInfo, params.locales);
114
- const productMap = params.productMap || {};
115
- return locales.reduce((data, locale) => {
116
- data[locale] = buildLocaleData({ order, shopInfo, locale, productMap });
117
- return data;
118
- }, {});
119
- }
120
- function hasSmallTicketData(value) {
121
- return !!value && typeof value === "object" && Object.keys(value).length > 0;
122
- }
123
- function buildLocaleData(params) {
124
- const { order, shopInfo, locale, productMap } = params;
125
- const products = buildProducts(order, locale, productMap);
126
- const summary = getSummary(order);
127
- const currencySymbol = getCurrencySymbol(order, shopInfo);
128
- return {
129
- base_data: buildBaseData({ order, shopInfo, locale }),
130
- products,
131
- fees: buildFees({ order, shopInfo, locale, products, summary, currencySymbol }),
132
- customer: buildCustomer(order, locale),
133
- appointment: buildAppointment(order, locale),
134
- // delivery: buildDelivery(order, locale),
135
- resources: buildResources(order, locale),
136
- payment_data: buildPaymentData({ order, locale, currencySymbol }),
137
- tickets: Array.isArray(order.tickets) ? order.tickets : [],
138
- source_shop: [],
139
- refund_data: [],
140
- expend_data: []
141
- };
142
- }
143
- function buildBaseData(params) {
144
- var _a;
145
- const { order, shopInfo, locale } = params;
146
- const orderNumber = stringify(
147
- order.buzzer || order.shop_full_order_number
148
- );
149
- return {
150
- shop_name: stringify(shopInfo.name || order.shop_name),
151
- note: stringify(order.note),
152
- shop_order_number: stringify(order.shop_order_number),
153
- order_number: orderNumber,
154
- shop_tax_number: stringify(shopInfo.tax_number || order.shop_tax_number),
155
- shop_phone: stringify(shopInfo.phone || order.shop_phone),
156
- shop_address: stringify(shopInfo.address || buildShopAddress(shopInfo) || order.shop_address),
157
- original_payment_status: stringify(order.payment_status),
158
- is_repeat: 0,
159
- buzzer: stringify(order.buzzer || order.pickup_number || ((_a = order.metadata) == null ? void 0 : _a.buzzer)),
160
- order_no: orderNumber,
161
- order_time: formatDateTime(order.created_at || order.sales_time || /* @__PURE__ */ new Date(), locale)
162
- };
163
- }
164
- function buildProducts(order, locale, productMap) {
165
- const products = Array.isArray(order.products) ? order.products : [];
166
- return products.map((product) => {
167
- const quantity = toNumber(product.product_quantity ?? product.quantity ?? product.num ?? 1, 1);
168
- const originalPrice = product.original_price ?? product.selling_price ?? product.payment_price ?? product.price ?? 0;
169
- const sellingPrice = product.selling_price ?? product.payment_price ?? product.price ?? originalPrice;
170
- const productTitle = resolveProductTitle({ product, productMap, locale });
171
- const parentProduct = resolveProductFromMap(product.product_id ?? product.id, productMap);
172
- const currencySymbol = getCurrencySymbol(order, null);
173
- const options = normalizeProductOptions({
174
- product,
175
- locale,
176
- currencySymbol,
177
- parentProduct
178
- });
179
- const combinations = normalizeProductCombinations({
180
- product,
181
- productMap,
182
- locale,
183
- currencySymbol,
184
- parentProduct
185
- });
186
- const resolvedVariant = resolveProductVariantText({ product, parentProduct, locale });
187
- return {
188
- product_title: productTitle,
189
- product_quantity: quantity,
190
- selling_price: formatMoney(sellingPrice, currencySymbol),
191
- original_price: formatMoney(originalPrice, currencySymbol),
192
- total_original_price: formatMoney(new import_decimal.default(toMoneyNumber(originalPrice)).mul(quantity), currencySymbol),
193
- extension_list: Array.isArray(product.extension_list) ? product.extension_list : [],
194
- ...options.length ? { options } : {},
195
- ...resolvedVariant ? { variant: resolvedVariant } : {},
196
- ...Array.isArray(product.combinations) ? { combinations: product.combinations } : combinations.length ? { combinations } : {}
197
- };
198
- });
199
- }
200
- function resolveProductTitle(params) {
201
- const { product, productMap, locale } = params;
202
- const ownTitle = getProductTitleSource(product, locale);
203
- const productId = product.product_id ?? product.id;
204
- const fallbackProduct = resolveProductFromMap(productId, productMap);
205
- if (!fallbackProduct)
206
- return ownTitle || "";
207
- return getProductTitleSource(fallbackProduct, locale);
208
- }
209
- function normalizeProductOptions(params) {
210
- var _a;
211
- const { product, locale, currencySymbol, parentProduct } = params;
212
- 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 : [];
213
- return rawOptions.map((option) => {
214
- const price = option.original_price ?? option.add_price ?? option.price;
215
- const value = option.value ?? option.option ?? option.item;
216
- const name = getProductTitleSource(option, locale) || resolveOptionTitleFromParentProduct({ option, parentProduct, locale });
217
- return {
218
- name,
219
- ...option.num !== void 0 || option.quantity !== void 0 ? { num: toNumber(option.num ?? option.quantity, 1) } : {},
220
- ...price !== void 0 && price !== null && price !== "" ? { price: formatMoney(price, currencySymbol) } : {},
221
- ...value !== void 0 && value !== null && value !== "" ? { value: getLocalizedValue(value, locale) } : {}
222
- };
223
- });
224
- }
225
- function normalizeProductCombinations(params) {
226
- const { product, productMap, locale, currencySymbol, parentProduct } = params;
227
- const bundles = Array.isArray(product.product_bundle) ? product.product_bundle : [];
228
- return bundles.map((bundle) => {
229
- const combinationsOptions = normalizeProductOptions({
230
- product: {},
231
- locale,
232
- currencySymbol,
233
- options: Array.isArray(bundle.option) ? bundle.option : [],
234
- parentProduct
235
- });
236
- const baseTitle = resolveBundleProductTitle({
237
- bundle,
238
- productMap,
239
- locale,
240
- parentProduct
241
- });
242
- const optionTitle = buildOptionTitleSuffix(combinationsOptions);
243
- return {
244
- product_title: `${baseTitle}${optionTitle}`,
245
- product_quantity: toNumber(bundle.num ?? bundle.quantity ?? 1, 1),
246
- price: formatBundlePrice(bundle, currencySymbol),
247
- combinations_options: combinationsOptions
248
- };
249
- });
250
- }
251
- function resolveBundleProductTitle(params) {
252
- const { bundle, productMap, locale, parentProduct } = params;
253
- const ownTitle = getProductTitleSource(bundle, locale);
254
- if (ownTitle)
255
- return ownTitle;
256
- const parentBundleItem = resolveBundleItemFromParentProduct({ bundle, parentProduct });
257
- const parentBundleTitle = parentBundleItem ? getProductTitleSource(parentBundleItem, locale) : "";
258
- if (parentBundleTitle)
259
- return parentBundleTitle;
260
- const productId = bundle.bundle_product_id ?? bundle._bundle_product_id ?? bundle.product_id ?? bundle.id;
261
- const fallbackProduct = resolveProductFromMap(productId, productMap);
262
- if (!fallbackProduct)
263
- return "";
264
- return getProductTitleSource(fallbackProduct, locale);
265
- }
266
- function resolveProductFromMap(productId, productMap) {
267
- if (productId === void 0 || productId === null || productId === "")
268
- return null;
269
- return productMap[productId] || productMap[String(productId)] || null;
270
- }
271
- function resolveProductVariantText(params) {
272
- const { product, parentProduct, locale } = params;
273
- if (product.variant)
274
- return getLocalizedValue(product.variant, locale);
275
- if (!parentProduct)
276
- return "";
277
- const productVariantId = product.product_variant_id ?? product.variant_id;
278
- if (!isNonZeroId(productVariantId))
279
- return "";
280
- const matchedVariant = normalizeArray(parentProduct.variant).find((variant) => isSameId(variant.id, productVariantId));
281
- if (!matchedVariant)
282
- return "";
283
- const resolvedFromSkuKey = resolveVariantTextFromSkuKey({
284
- skuKey: matchedVariant.sku_key,
285
- parentProduct,
286
- locale
287
- });
288
- if (resolvedFromSkuKey)
289
- return resolvedFromSkuKey;
290
- return resolveVariantTextFromNameMap({
291
- nameMap: matchedVariant.name || matchedVariant.title,
292
- parentProduct,
293
- locale
294
- });
295
- }
296
- function resolveVariantTextFromSkuKey(params) {
297
- const skuKey = stringify(params.skuKey);
298
- if (!skuKey)
299
- return "";
300
- return skuKey.split("_").map((item) => {
301
- const [groupPositionId, itemPositionId] = item.split(":");
302
- return resolveVariantTextItem({
303
- parentProduct: params.parentProduct,
304
- groupPositionId,
305
- itemPositionId,
306
- locale: params.locale
307
- });
308
- }).filter(Boolean).join(",");
309
- }
310
- function resolveVariantTextFromNameMap(params) {
311
- if (!params.nameMap || typeof params.nameMap !== "object")
312
- return "";
313
- return Object.entries(params.nameMap).map(([groupPositionId, value]) => {
314
- const group = resolveVariantGroup(params.parentProduct, groupPositionId);
315
- if (!group)
316
- return "";
317
- const groupName = getLocalizedValue(group.name, params.locale);
318
- const itemName = getLocalizedValue(value, params.locale);
319
- if (!groupName || !itemName)
320
- return "";
321
- return `${groupName}:${itemName}`;
322
- }).filter(Boolean).join(",");
323
- }
324
- function resolveVariantTextItem(params) {
325
- const group = resolveVariantGroup(params.parentProduct, params.groupPositionId);
326
- const item = resolveVariantItem(group, params.itemPositionId);
327
- if (!group || !item)
328
- return "";
329
- const groupName = getLocalizedValue(group.name, params.locale);
330
- const itemName = getLocalizedValue(item.name, params.locale);
331
- if (!groupName || !itemName)
332
- return "";
333
- return `${groupName}:${itemName}`;
334
- }
335
- function resolveVariantGroup(parentProduct, groupPositionId) {
336
- return normalizeArray(parentProduct.variant_group).find(
337
- (group) => isSameId(group.position_id, groupPositionId) || isSameId(group.id, groupPositionId)
338
- ) || null;
339
- }
340
- function resolveVariantItem(group, itemPositionId) {
341
- if (!group)
342
- return null;
343
- return normalizeArray(group.variant_item).find(
344
- (item) => isSameId(item.position_id, itemPositionId) || isSameId(item.id, itemPositionId)
345
- ) || null;
346
- }
347
- function getProductTitleSource(source, locale) {
348
- if (!source || typeof source !== "object")
349
- return "";
350
- return resolveTitleValue(source.product_title, locale) || resolveTitleValue(source.title, locale) || resolveTitleValue(source.name, locale);
351
- }
352
- function resolveTitleValue(value, locale) {
353
- if (value === void 0 || value === null)
354
- return "";
355
- if (typeof value !== "object")
356
- return stringify(value);
357
- const dashedLocale = locale.replace("_", "-");
358
- const underscoredLocale = locale.replace("-", "_");
359
- return stringify(value[locale] ?? value[dashedLocale] ?? value[underscoredLocale] ?? "");
360
- }
361
- function resolveOptionTitleFromParentProduct(params) {
362
- const { option, parentProduct, locale } = params;
363
- if (!parentProduct)
364
- return "";
365
- const optionItems = flattenOptionItems(parentProduct);
366
- const matchedOption = optionItems.find((item) => isOptionItemMatch(option, item));
367
- return getProductTitleSource(matchedOption, locale);
368
- }
369
- function flattenOptionItems(parentProduct) {
370
- const optionGroups = Array.isArray(parentProduct.option_group) ? parentProduct.option_group : [];
371
- return optionGroups.flatMap((group) => {
372
- const items = normalizeArray(
373
- group.option_item || group.option_items || group.option || group.options || group.items || group.children || group.product_option_item
374
- );
375
- return items.map((item) => ({
376
- ...item,
377
- option_group_id: item.option_group_id ?? group.id ?? group.option_group_id
378
- }));
379
- });
380
- }
381
- function isOptionItemMatch(option, item) {
382
- const optionItemId = option.option_group_item_id ?? option.product_option_item_id ?? option.id;
383
- const itemId = item.option_group_item_id ?? item.product_option_item_id ?? item.id;
384
- if (!isSameId(optionItemId, itemId))
385
- return false;
386
- const optionGroupId = option.option_group_id ?? option.group_id;
387
- const itemGroupId = item.option_group_id ?? item.group_id;
388
- if (isPresentId(optionGroupId) && isPresentId(itemGroupId)) {
389
- return isSameId(optionGroupId, itemGroupId);
390
- }
391
- return true;
392
- }
393
- function resolveBundleItemFromParentProduct(params) {
394
- const { bundle, parentProduct } = params;
395
- if (!parentProduct)
396
- return null;
397
- const bundleItems = flattenBundleItems(parentProduct);
398
- const bundleVariantId = bundle.bundle_variant_id ?? bundle.variant_id ?? bundle.product_variant_id;
399
- if (isNonZeroId(bundleVariantId)) {
400
- const matchedByVariant = bundleItems.find(
401
- (item) => isSameId(item.bundle_variant_id ?? item.variant_id ?? item.product_variant_id, bundleVariantId)
402
- );
403
- if (matchedByVariant)
404
- return matchedByVariant;
405
- }
406
- const bundleId = bundle.bundle_id ?? bundle.id;
407
- if (isPresentId(bundleId)) {
408
- const matchedByBundleId = bundleItems.find((item) => isSameId(item.id ?? item.bundle_id, bundleId));
409
- if (matchedByBundleId)
410
- return matchedByBundleId;
411
- }
412
- const bundleGroupId = bundle.bundle_group_id ?? bundle.group_id;
413
- const bundleProductId = bundle.bundle_product_id ?? bundle._bundle_product_id ?? bundle.product_id;
414
- if (isPresentId(bundleGroupId) && isPresentId(bundleProductId)) {
415
- const matchedByGroupAndProduct = bundleItems.find(
416
- (item) => isSameId(item.group_id ?? item.bundle_group_id, bundleGroupId) && isSameId(item.bundle_product_id ?? item._bundle_product_id ?? item.product_id, bundleProductId)
417
- );
418
- if (matchedByGroupAndProduct)
419
- return matchedByGroupAndProduct;
420
- }
421
- if (isPresentId(bundleProductId)) {
422
- return bundleItems.find(
423
- (item) => isSameId(item.bundle_product_id ?? item._bundle_product_id ?? item.product_id, bundleProductId)
424
- ) || null;
425
- }
426
- return null;
427
- }
428
- function flattenBundleItems(parentProduct) {
429
- const bundleGroups = Array.isArray(parentProduct.bundle_group) ? parentProduct.bundle_group : [];
430
- return bundleGroups.flatMap((group) => {
431
- const items = Array.isArray(group.bundle_item) ? group.bundle_item : [];
432
- return items.map((item) => ({
433
- ...item,
434
- group_id: item.group_id ?? group.id ?? group.group_id
435
- }));
436
- });
437
- }
438
- function isNonZeroId(value) {
439
- return isPresentId(value) && String(value) !== "0";
440
- }
441
- function isPresentId(value) {
442
- return value !== void 0 && value !== null && value !== "";
443
- }
444
- function isSameId(left, right) {
445
- if (!isPresentId(left) || !isPresentId(right))
446
- return false;
447
- return String(left) === String(right);
448
- }
449
- function buildOptionTitleSuffix(options) {
450
- const text = options.map((option) => {
451
- const name = stringify(option.name).trim();
452
- if (!name)
453
- return "";
454
- const quantity = option.num ?? 1;
455
- return `${name} x ${quantity}`;
456
- }).filter(Boolean).join(", ");
457
- return text ? `(${text})` : "";
458
- }
459
- function formatBundlePrice(bundle, currencySymbol) {
460
- const value = bundle.bundle_selling_price ?? bundle.bundle_sum_price ?? bundle.price ?? 0;
461
- const amount = new import_decimal.default(toMoneyNumber(value));
462
- const isNegative = bundle.price_type === "markdown" || bundle.price_type === "markup" && bundle.price_type_ext === "product_price";
463
- if (isNegative)
464
- return `-${currencySymbol}${amount.abs().toFixed(2)}`;
465
- return formatMoney(amount, currencySymbol);
466
- }
467
- function buildFees(params) {
468
- const { order, shopInfo, locale, products, summary, currencySymbol } = params;
469
- const fees = [];
470
- for (const surcharge of normalizeArray(order.surcharges || summary.surcharges)) {
471
- const value = surcharge.amount ?? surcharge.value ?? surcharge.total_amount;
472
- if (!isNonZero(value))
473
- continue;
474
- fees.push({
475
- item: getLocalizedValue(surcharge.name || surcharge.title || surcharge.item, locale),
476
- value: formatMoney(value, currencySymbol)
477
- });
478
- }
479
- const discountAmount = summary.discount_amount || order.discount_amount || order.shop_discount;
480
- if (isNonZero(discountAmount)) {
481
- fees.push({
482
- item: label(locale, "orderDiscount"),
483
- value: formatMoney(new import_decimal.default(toMoneyNumber(discountAmount)).neg(), currencySymbol)
484
- });
485
- }
486
- const taxFee = summary.tax_fee || order.tax_fee;
487
- if (isNonZero(taxFee)) {
488
- fees.push({
489
- item: stringify(summary.tax_title || order.tax_title || shopInfo.tax_title),
490
- value: formatMoney(taxFee, currencySymbol)
491
- });
492
- }
493
- const roundingAmount = summary.rounding_amount || order.rounding_amount;
494
- if (isNonZero(roundingAmount)) {
495
- fees.push({
496
- item: label(locale, "rounding"),
497
- value: formatMoney(roundingAmount, currencySymbol)
498
- });
499
- }
500
- const payProcessingFee = summary.pay_service_charge_amount || order.pay_service_charge_amount;
501
- if (isNonZero(payProcessingFee)) {
502
- fees.push({
503
- item: label(locale, "payProcessingFee"),
504
- value: formatMoney(payProcessingFee, currencySymbol)
505
- });
506
- }
507
- return {
508
- fees,
509
- countFee: {
510
- total_amount: formatMoney(summary.total_amount || order.total_amount, currencySymbol),
511
- product_expect_amount: formatMoney(
512
- summary.product_expect_amount || summary.product_amount || order.product_expect_amount,
513
- currencySymbol
514
- ),
515
- expect_amount: formatMoney(summary.expect_amount || order.expect_amount || summary.total_amount || order.total_amount, currencySymbol),
516
- product_quantity: toNumber(
517
- summary.product_quantity || products.reduce((sum, product) => sum + product.product_quantity, 0),
518
- 0
519
- ),
520
- has_pay: formatMoney(sumPayments(order.payments), currencySymbol),
521
- payment_method: "",
522
- tax_title: stringify(summary.tax_title || order.tax_title || shopInfo.tax_title),
523
- total_refund_amount: formatMoney(summary.total_refund_amount || order.total_refund_amount, currencySymbol),
524
- ...isNonZero(roundingAmount) ? { rounding_amount: formatMoney(roundingAmount, currencySymbol) } : {},
525
- ...isNonZero(discountAmount) ? { order_total_discount: formatMoney(discountAmount, currencySymbol) } : {},
526
- ...isNonZero(payProcessingFee) ? { pay_processing_fee: formatMoney(payProcessingFee, currencySymbol) } : {},
527
- ...isNonZero(taxFee) ? { tax_fee: formatMoney(taxFee, currencySymbol) } : {}
528
- }
529
- };
530
- }
531
- function buildCustomer(order, locale) {
532
- var _a, _b, _c, _d;
533
- return [
534
- { 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)) },
535
- { item: label(locale, "contactMobile"), value: stringify(order.phone || ((_c = order.customer) == null ? void 0 : _c.phone)) },
536
- { item: label(locale, "email"), value: stringify(order.email || ((_d = order.customer) == null ? void 0 : _d.email)) }
537
- ];
538
- }
539
- function normalizeCustomerDisplayValue(value) {
540
- const text = stringify(value).trim();
541
- if (!text)
542
- return "Walk-In";
543
- if (text.toLowerCase() === "select a customer")
544
- return "Walk-In";
545
- return text;
546
- }
547
- function buildAppointment(order, locale) {
548
- var _a, _b, _c, _d;
549
- 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);
550
- if (!tableName)
551
- return [];
552
- return [
553
- {
554
- item: label(locale, "table"),
555
- value: getLocalizedValue(tableName, locale)
556
- }
557
- ];
558
- }
559
- function buildResources(order, locale) {
560
- return normalizeArray(order.resources || order.resource_list).map((resource) => ({
561
- id: resource.id || resource.resource_id || "",
562
- code: "",
563
- title: getLocalizedValue(resource.title || resource.name, locale),
564
- form_title: getLocalizedValue(resource.form_title || resource.type || "", locale)
565
- }));
566
- }
567
- function buildPaymentData(params) {
568
- const payments = normalizeArray(params.order.payments);
569
- return payments.filter((payment) => isPrintablePayment(payment)).map((payment) => {
570
- var _a;
571
- const items = [
572
- {
573
- item: paymentMethodName(payment, params.locale),
574
- value: formatMoney(payment.amount ?? payment.origin_amount, params.currencySymbol)
575
- }
576
- ];
577
- const fundRecord = getFundRecord(payment);
578
- if (fundRecord) {
579
- items.push(...buildFundRecordPaymentItems({ payment, fundRecord, locale: params.locale, currencySymbol: params.currencySymbol }));
580
- } else {
581
- const remainingAmount = payment.remaining_amount ?? payment.balance ?? ((_a = payment.metadata) == null ? void 0 : _a.remaining_amount);
582
- if (remainingAmount !== void 0 && remainingAmount !== null) {
583
- items.push({
584
- item: label(params.locale, "remainingAmount"),
585
- value: formatMoney(remainingAmount, params.currencySymbol)
586
- });
587
- }
588
- }
589
- items.push({
590
- item: formatDateTime(payment.paid_at || payment.created_at || payment.updated_at || /* @__PURE__ */ new Date(), params.locale),
591
- value: ""
592
- });
593
- return items;
594
- });
595
- }
596
- function buildFundRecordPaymentItems(params) {
597
- const { payment, fundRecord, locale, currencySymbol } = params;
598
- const items = [];
599
- const usingBeforeValue = fundRecord.using_before_value;
600
- const usingAfterValue = fundRecord.using_after_value;
601
- if (isPointCardPayment(payment) && usingBeforeValue !== void 0 && usingAfterValue !== void 0) {
602
- const usedPoints = new import_decimal.default(toMoneyNumber(usingBeforeValue)).minus(toMoneyNumber(usingAfterValue));
603
- items.push({
604
- item: label(locale, "redeemPoints"),
605
- value: trimDecimal(usedPoints)
606
- });
607
- items.push({
608
- item: label(locale, "remainingPoints"),
609
- value: trimDecimal(new import_decimal.default(toMoneyNumber(usingAfterValue)))
610
- });
611
- return items;
612
- }
613
- if (usingAfterValue !== void 0 && usingAfterValue !== null) {
614
- items.push({
615
- item: label(locale, "remainingAmount"),
616
- value: formatMoney(usingAfterValue, currencySymbol)
617
- });
618
- }
619
- return items;
620
- }
621
- function getFundRecord(payment) {
622
- const fundRecord = payment.fund_record;
623
- if (!fundRecord || typeof fundRecord !== "object" || Array.isArray(fundRecord))
624
- return null;
625
- if (!fundRecord.voucher_id && !fundRecord.code)
626
- return null;
627
- return fundRecord;
628
- }
629
- function isPointCardPayment(payment) {
630
- var _a;
631
- const code = stringify(payment.code || payment.payment_method).toUpperCase();
632
- const type = stringify(payment.type || ((_a = payment.fund_record) == null ? void 0 : _a.tag)).toLowerCase();
633
- return code === "POINTCARD" || type === "point_card";
634
- }
635
- function maskMachineCode(code) {
636
- const text = stringify(code);
637
- if (text.length <= 6)
638
- return text;
639
- return `${text.slice(0, 2)}**${text.slice(-4)}`;
640
- }
641
- function trimDecimal(value) {
642
- return value.toDecimalPlaces(2).toFixed(2).replace(/\.?0+$/, "");
643
- }
644
- function getFundRecordPaymentName(payment, locale) {
645
- const fundRecord = getFundRecord(payment);
646
- if (!fundRecord)
647
- return "";
648
- const name = getLocalizedValue(fundRecord.wallet_pass_name, locale);
649
- const code = maskMachineCode(fundRecord.code);
650
- if (!name && !code)
651
- return "";
652
- if (!code)
653
- return name;
654
- const fallbackName = getLocalizedValue(
655
- payment.name || payment.title || payment.payment_method_name || payment.method_name || payment.code,
656
- locale
657
- );
658
- return `${name || fallbackName}(${code})`;
659
- }
660
- function appendMachineCodeToName(name, payment) {
661
- const fundRecord = getFundRecord(payment);
662
- if (!(fundRecord == null ? void 0 : fundRecord.code))
663
- return name;
664
- return `${name}(${maskMachineCode(fundRecord.code)})`;
665
- }
666
- function paymentMethodName(payment, locale) {
667
- const fundRecordName = getFundRecordPaymentName(payment, locale);
668
- if (fundRecordName)
669
- return fundRecordName;
670
- const raw = payment.name || payment.title || payment.payment_method_name || payment.method_name;
671
- if (raw)
672
- return appendMachineCodeToName(getLocalizedValue(raw, locale), payment);
673
- const code = stringify(payment.code || payment.type || payment.payment_method || payment.method).toLowerCase();
674
- if (code.includes("cash"))
675
- return label(locale, "cash");
676
- if (code.includes("eftpos") || code.includes("card"))
677
- return label(locale, "eftpos");
678
- if (code.includes("wallet"))
679
- return label(locale, "wallet");
680
- if (code.includes("gift"))
681
- return label(locale, "giftCard");
682
- return stringify(payment.code || payment.type || payment.payment_method || payment.method);
683
- }
684
- function getSummary(order) {
685
- return order.summary && typeof order.summary === "object" ? order.summary : order;
686
- }
687
- function getCurrencySymbol(order, shopInfo) {
688
- return stringify(order.currency_symbol || (shopInfo == null ? void 0 : shopInfo.currency_symbol) || order.shop_symbol || "$") || "$";
689
- }
690
- function resolveLocales(shopInfo, locales) {
691
- const preferred = [
692
- ...locales || [],
693
- shopInfo.primary_locale,
694
- ...DEFAULT_LOCALES
695
- ].filter(Boolean);
696
- return Array.from(new Set(preferred.map(normalizeLocaleKey)));
697
- }
698
- function normalizeLocaleKey(locale) {
699
- return locale.replace("-", "_");
700
- }
701
- function label(locale, key) {
702
- var _a;
703
- return ((_a = LABELS[locale]) == null ? void 0 : _a[key]) || LABELS.en[key] || key;
704
- }
705
- function getLocalizedValue(value, locale) {
706
- if (value === void 0 || value === null)
707
- return "";
708
- if (typeof value !== "object")
709
- return stringify(value);
710
- const dashedLocale = locale.replace("_", "-");
711
- return stringify(
712
- value[locale] ?? value[dashedLocale] ?? value.default ?? value.en ?? ""
713
- );
714
- }
715
- function buildShopAddress(shopInfo) {
716
- return [
717
- shopInfo.address_street,
718
- shopInfo.address_detail,
719
- shopInfo.city,
720
- shopInfo.province,
721
- shopInfo.country,
722
- shopInfo.zip
723
- ].filter(Boolean).join(", ");
724
- }
725
- function formatDateTime(value, locale) {
726
- const date = (0, import_dayjs.default)(value);
727
- if (!date.isValid())
728
- return stringify(value);
729
- if (locale === "en")
730
- return date.format("HH:mm:ss DD/MM/YYYY");
731
- return date.format("YYYY/MM/DD HH:mm:ss");
732
- }
733
- function formatMoney(value, currencySymbol) {
734
- if (value instanceof import_decimal.default)
735
- return `${currencySymbol}${value.toFixed(2)}`;
736
- if (typeof value === "string" && value.trim().startsWith(currencySymbol))
737
- return value;
738
- const amount = new import_decimal.default(toMoneyNumber(value));
739
- return `${currencySymbol}${amount.toFixed(2)}`;
740
- }
741
- function sumPayments(payments) {
742
- return normalizeArray(payments).filter((payment) => isPrintablePayment(payment)).reduce((sum, payment) => {
743
- return sum.plus(toMoneyNumber(payment.amount ?? payment.origin_amount));
744
- }, new import_decimal.default(0));
745
- }
746
- function isPrintablePayment(payment) {
747
- const status = stringify(payment.status).toLowerCase();
748
- if (!status)
749
- return true;
750
- return ["paid", "success", "succeeded", "completed"].includes(status);
751
- }
752
- function normalizeArray(value) {
753
- return Array.isArray(value) ? value : [];
754
- }
755
- function isNonZero(value) {
756
- return !new import_decimal.default(toMoneyNumber(value)).isZero();
757
- }
758
- function toMoneyNumber(value) {
759
- if (value instanceof import_decimal.default)
760
- return value.toString();
761
- if (typeof value === "number")
762
- return Number.isFinite(value) ? value : 0;
763
- if (typeof value !== "string")
764
- return 0;
765
- const normalized = value.replace(/[^\d.-]/g, "");
766
- return normalized || 0;
767
- }
768
- function toNumber(value, fallback) {
769
- const numberValue = Number(value);
770
- return Number.isFinite(numberValue) ? numberValue : fallback;
771
- }
772
- function stringify(value) {
773
- if (value === void 0 || value === null)
774
- return "";
775
- return String(value);
776
- }
777
- // Annotate the CommonJS export names for ESM import in node:
778
- 0 && (module.exports = {
779
- buildSmallTicketData,
780
- hasSmallTicketData
781
- });