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