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