@pisell/pisellos 2.2.244 → 2.2.245

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