@pisell/pisellos 0.0.568 → 0.0.569

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