@pisell/pisellos 2.2.243 → 2.2.244
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/promotion/evaluator.js +2 -3
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/walletPass/utils.js +4 -7
- package/dist/modules/Cart/utils/cartProduct.js +3 -24
- package/dist/modules/Cart/utils/changePrice.js +11 -11
- package/dist/modules/Customer/index.d.ts +0 -20
- package/dist/modules/Customer/index.js +83 -172
- package/dist/modules/Customer/types.d.ts +0 -2
- package/dist/modules/Discount/index.js +3 -4
- package/dist/modules/Discount/types.d.ts +0 -1
- package/dist/modules/OpenData/index.d.ts +0 -8
- package/dist/modules/OpenData/index.js +17 -37
- package/dist/modules/Order/index.d.ts +18 -268
- package/dist/modules/Order/index.js +757 -3306
- package/dist/modules/Order/types.d.ts +31 -279
- package/dist/modules/Order/types.js +0 -38
- package/dist/modules/Order/utils.d.ts +5 -147
- package/dist/modules/Order/utils.js +103 -746
- package/dist/modules/Payment/index.d.ts +13 -10
- package/dist/modules/Payment/index.js +837 -467
- package/dist/modules/Payment/types.d.ts +0 -2
- package/dist/modules/Payment/utils.js +1 -2
- package/dist/modules/Payment/walletpass.js +7 -14
- package/dist/modules/ProductList/index.d.ts +12 -16
- package/dist/modules/ProductList/index.js +59 -133
- package/dist/modules/ProductList/types.d.ts +0 -14
- package/dist/modules/Quotation/index.d.ts +1 -0
- package/dist/modules/Quotation/index.js +22 -25
- package/dist/modules/Rules/index.d.ts +0 -4
- package/dist/modules/Rules/index.js +69 -93
- package/dist/modules/Rules/types.d.ts +0 -1
- package/dist/modules/SalesSummary/index.d.ts +25 -8
- package/dist/modules/SalesSummary/index.js +35 -86
- package/dist/modules/SalesSummary/types.d.ts +1 -4
- package/dist/modules/SalesSummary/utils.d.ts +25 -2
- package/dist/modules/SalesSummary/utils.js +162 -794
- package/dist/modules/Schedule/index.d.ts +0 -7
- package/dist/modules/Schedule/index.js +2 -24
- package/dist/modules/Summary/index.js +3 -4
- package/dist/modules/index.d.ts +0 -2
- package/dist/modules/index.js +1 -3
- package/dist/plugins/request.d.ts +0 -1
- package/dist/server/index.d.ts +1 -204
- package/dist/server/index.js +928 -3658
- package/dist/server/modules/index.d.ts +0 -2
- package/dist/server/modules/index.js +0 -2
- package/dist/server/modules/order/index.d.ts +4 -120
- package/dist/server/modules/order/index.js +483 -1779
- package/dist/server/modules/order/types.d.ts +3 -32
- package/dist/server/modules/order/types.js +0 -8
- package/dist/server/modules/order/utils/filterBookings.js +3 -26
- package/dist/server/modules/order/utils/filterOrders.js +8 -23
- package/dist/server/modules/products/index.d.ts +7 -34
- package/dist/server/modules/products/index.js +317 -631
- package/dist/server/modules/resource/index.d.ts +0 -2
- package/dist/server/modules/resource/index.js +3 -29
- package/dist/server/modules/schedule/index.d.ts +4 -4
- package/dist/server/modules/schedule/index.js +88 -111
- package/dist/solution/BaseSales/index.d.ts +9 -131
- package/dist/solution/BaseSales/index.js +447 -1944
- package/dist/solution/BaseSales/types.d.ts +6 -76
- package/dist/solution/BaseSales/types.js +4 -5
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +0 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +24 -105
- package/dist/solution/BaseSales/utils.d.ts +1 -1
- package/dist/solution/BaseSales/utils.js +21 -62
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +10 -270
- package/dist/solution/BookingTicket/index.js +237 -1772
- package/dist/solution/BookingTicket/types.d.ts +1 -118
- package/dist/solution/BookingTicket/types.js +2 -41
- package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +0 -40
- package/dist/solution/BookingTicket/utils/bookingStatus.js +0 -70
- package/dist/solution/BookingTicket/utils/cartView.d.ts +1 -9
- package/dist/solution/BookingTicket/utils/cartView.js +7 -94
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +0 -5
- package/dist/solution/BookingTicket/utils/scan/index.js +8 -20
- package/dist/solution/Checkout/appointmentDemo.json +1 -0
- package/dist/solution/Checkout/index.d.ts +0 -1
- package/dist/solution/Checkout/index.js +9 -10
- package/dist/solution/RegisterAndLogin/config.js +10 -2
- package/dist/solution/ScanOrder/index.d.ts +3 -9
- package/dist/solution/ScanOrder/index.js +134 -241
- package/dist/solution/ScanOrder/types.d.ts +5 -9
- package/dist/solution/ScanOrder/types.js +3 -2
- package/dist/solution/ScanOrder/utils.d.ts +1 -1
- package/dist/solution/ScanOrder/utils.js +22 -84
- package/dist/solution/VenueBooking/index.d.ts +2 -5
- package/dist/solution/VenueBooking/index.js +59 -110
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +2 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
- package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
- package/dist/types/index.d.ts +0 -10
- package/lib/model/strategy/adapter/promotion/evaluator.js +1 -2
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/model/strategy/adapter/walletPass/utils.js +2 -3
- package/lib/modules/Cart/utils/cartProduct.js +3 -20
- package/lib/modules/Cart/utils/changePrice.js +20 -12
- package/lib/modules/Customer/index.d.ts +0 -20
- package/lib/modules/Customer/index.js +11 -64
- package/lib/modules/Customer/types.d.ts +0 -2
- package/lib/modules/Discount/index.js +1 -5
- package/lib/modules/Discount/types.d.ts +0 -1
- package/lib/modules/OpenData/index.d.ts +0 -8
- package/lib/modules/OpenData/index.js +5 -19
- package/lib/modules/Order/index.d.ts +18 -268
- package/lib/modules/Order/index.js +344 -2149
- package/lib/modules/Order/types.d.ts +31 -279
- package/lib/modules/Order/types.js +0 -1
- package/lib/modules/Order/utils.d.ts +5 -147
- package/lib/modules/Order/utils.js +46 -614
- package/lib/modules/Payment/index.d.ts +13 -10
- package/lib/modules/Payment/index.js +150 -18
- package/lib/modules/Payment/types.d.ts +0 -2
- package/lib/modules/Payment/utils.js +1 -2
- package/lib/modules/Payment/walletpass.js +3 -7
- package/lib/modules/ProductList/index.d.ts +12 -16
- package/lib/modules/ProductList/index.js +4 -41
- package/lib/modules/ProductList/types.d.ts +0 -14
- package/lib/modules/Quotation/index.d.ts +1 -0
- package/lib/modules/Quotation/index.js +16 -19
- package/lib/modules/Rules/index.d.ts +0 -4
- package/lib/modules/Rules/index.js +120 -136
- package/lib/modules/Rules/types.d.ts +0 -1
- package/lib/modules/SalesSummary/index.d.ts +25 -8
- package/lib/modules/SalesSummary/index.js +4 -30
- package/lib/modules/SalesSummary/types.d.ts +1 -4
- package/lib/modules/SalesSummary/utils.d.ts +25 -2
- package/lib/modules/SalesSummary/utils.js +91 -645
- package/lib/modules/Schedule/index.d.ts +0 -7
- package/lib/modules/Schedule/index.js +1 -17
- package/lib/modules/Summary/index.js +4 -5
- package/lib/modules/index.d.ts +0 -2
- package/lib/modules/index.js +1 -5
- package/lib/plugins/request.d.ts +0 -1
- package/lib/server/index.d.ts +1 -204
- package/lib/server/index.js +57 -1888
- package/lib/server/modules/index.d.ts +0 -2
- package/lib/server/modules/index.js +0 -3
- package/lib/server/modules/order/index.d.ts +4 -120
- package/lib/server/modules/order/index.js +142 -919
- package/lib/server/modules/order/types.d.ts +3 -32
- package/lib/server/modules/order/utils/filterBookings.js +5 -24
- package/lib/server/modules/order/utils/filterOrders.js +6 -15
- package/lib/server/modules/products/index.d.ts +7 -34
- package/lib/server/modules/products/index.js +54 -189
- package/lib/server/modules/resource/index.d.ts +0 -2
- package/lib/server/modules/resource/index.js +3 -27
- package/lib/server/modules/schedule/index.d.ts +4 -4
- package/lib/server/modules/schedule/index.js +40 -47
- package/lib/solution/BaseSales/index.d.ts +9 -131
- package/lib/solution/BaseSales/index.js +63 -1106
- package/lib/solution/BaseSales/types.d.ts +6 -76
- package/lib/solution/BaseSales/types.js +1 -3
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +0 -1
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +18 -106
- package/lib/solution/BaseSales/utils.d.ts +1 -1
- package/lib/solution/BaseSales/utils.js +10 -54
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +10 -270
- package/lib/solution/BookingTicket/index.js +29 -922
- package/lib/solution/BookingTicket/types.d.ts +1 -118
- package/lib/solution/BookingTicket/types.js +0 -11
- package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +0 -40
- package/lib/solution/BookingTicket/utils/bookingStatus.js +2 -44
- package/lib/solution/BookingTicket/utils/cartView.d.ts +1 -9
- package/lib/solution/BookingTicket/utils/cartView.js +6 -61
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +0 -5
- package/lib/solution/BookingTicket/utils/scan/index.js +3 -17
- package/lib/solution/Checkout/appointmentDemo.json +1 -0
- package/lib/solution/Checkout/index.d.ts +0 -1
- package/lib/solution/Checkout/index.js +2 -1
- package/lib/solution/RegisterAndLogin/config.js +10 -2
- package/lib/solution/ScanOrder/index.d.ts +3 -9
- package/lib/solution/ScanOrder/index.js +70 -153
- package/lib/solution/ScanOrder/types.d.ts +5 -9
- package/lib/solution/ScanOrder/utils.d.ts +1 -1
- package/lib/solution/ScanOrder/utils.js +17 -83
- package/lib/solution/VenueBooking/index.d.ts +2 -5
- package/lib/solution/VenueBooking/index.js +17 -54
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +2 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
- package/lib/solution/VenueBooking/utils/slotMerge.js +0 -10
- package/lib/types/index.d.ts +0 -10
- package/package.json +1 -1
- package/dist/modules/BookingContext/index.d.ts +0 -48
- package/dist/modules/BookingContext/index.js +0 -566
- package/dist/modules/BookingContext/types.d.ts +0 -102
- package/dist/modules/BookingContext/types.js +0 -51
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -284
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -145
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -76
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -218
- package/dist/modules/BookingContext/utils/flexible.d.ts +0 -28
- package/dist/modules/BookingContext/utils/flexible.js +0 -56
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
- package/dist/modules/BookingContext/utils/formatResourceList.js +0 -38
- package/dist/modules/BookingContext/utils/index.d.ts +0 -11
- package/dist/modules/BookingContext/utils/index.js +0 -11
- package/dist/modules/BookingContext/utils/noResource.d.ts +0 -13
- package/dist/modules/BookingContext/utils/noResource.js +0 -77
- package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts +0 -1
- package/dist/modules/BookingContext/utils/orderLineDisplay.js +0 -36
- package/dist/modules/BookingContext/utils/productExtend.d.ts +0 -72
- package/dist/modules/BookingContext/utils/productExtend.js +0 -339
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
- package/dist/modules/BookingContext/utils/resourceErrors.js +0 -74
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
- package/dist/modules/BookingContext/utils/resourceSelection.js +0 -24
- package/dist/modules/BookingContext/utils/resources.d.ts +0 -80
- package/dist/modules/BookingContext/utils/resources.js +0 -486
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
- package/dist/modules/BookingContext/utils/serviceTimes.js +0 -151
- package/dist/modules/BookingContext/utils/timeSlices.d.ts +0 -42
- package/dist/modules/BookingContext/utils/timeSlices.js +0 -100
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +0 -106
- package/dist/modules/Order/utils/manualProductDiscount.js +0 -210
- package/dist/modules/SurchargeList/index.d.ts +0 -16
- package/dist/modules/SurchargeList/index.js +0 -162
- package/dist/modules/SurchargeList/types.d.ts +0 -11
- package/dist/modules/SurchargeList/types.js +0 -1
- package/dist/server/modules/payment/index.d.ts +0 -28
- package/dist/server/modules/payment/index.js +0 -305
- package/dist/server/modules/payment/types.d.ts +0 -9
- package/dist/server/modules/payment/types.js +0 -1
- package/dist/server/test.json +0 -713
- package/dist/server/utils/small-ticket.d.ts +0 -71
- package/dist/server/utils/small-ticket.js +0 -830
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +0 -287
- package/dist/solution/BaseSales/utils/cartPromotion.js +0 -1438
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
- package/dist/solution/BaseSales/utils/quotationPrice.js +0 -237
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -117
- package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -346
- package/dist/solution/BookingTicket/utils/addTimeAvailability.d.ts +0 -35
- package/dist/solution/BookingTicket/utils/addTimeAvailability.js +0 -95
- package/dist/solution/BookingTicket/utils/exampleData.d.ts +0 -123
- package/dist/solution/BookingTicket/utils/exampleData.js +0 -183
- package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +0 -185
- package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.js +0 -438
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -36
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +0 -399
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -32
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +0 -56
- package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +0 -21
- package/dist/solution/BookingTicket/utils/scan/scanProductValues.js +0 -150
- package/dist/solution/BookingTicket/utils/sessionCatalogStale.d.ts +0 -23
- package/dist/solution/BookingTicket/utils/sessionCatalogStale.js +0 -78
- package/lib/modules/BookingContext/index.d.ts +0 -48
- package/lib/modules/BookingContext/index.js +0 -368
- package/lib/modules/BookingContext/types.d.ts +0 -102
- package/lib/modules/BookingContext/types.js +0 -34
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -276
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -151
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -76
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -201
- package/lib/modules/BookingContext/utils/flexible.d.ts +0 -28
- package/lib/modules/BookingContext/utils/flexible.js +0 -80
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
- package/lib/modules/BookingContext/utils/formatResourceList.js +0 -50
- package/lib/modules/BookingContext/utils/index.d.ts +0 -11
- package/lib/modules/BookingContext/utils/index.js +0 -43
- package/lib/modules/BookingContext/utils/noResource.d.ts +0 -13
- package/lib/modules/BookingContext/utils/noResource.js +0 -90
- package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +0 -1
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +0 -56
- package/lib/modules/BookingContext/utils/productExtend.d.ts +0 -72
- package/lib/modules/BookingContext/utils/productExtend.js +0 -283
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
- package/lib/modules/BookingContext/utils/resourceErrors.js +0 -80
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
- package/lib/modules/BookingContext/utils/resourceSelection.js +0 -46
- package/lib/modules/BookingContext/utils/resources.d.ts +0 -80
- package/lib/modules/BookingContext/utils/resources.js +0 -377
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
- package/lib/modules/BookingContext/utils/serviceTimes.js +0 -162
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +0 -42
- package/lib/modules/BookingContext/utils/timeSlices.js +0 -124
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +0 -106
- package/lib/modules/Order/utils/manualProductDiscount.js +0 -206
- package/lib/modules/SurchargeList/index.d.ts +0 -16
- package/lib/modules/SurchargeList/index.js +0 -89
- package/lib/modules/SurchargeList/types.d.ts +0 -11
- package/lib/modules/SurchargeList/types.js +0 -17
- package/lib/server/modules/payment/index.d.ts +0 -28
- package/lib/server/modules/payment/index.js +0 -192
- package/lib/server/modules/payment/types.d.ts +0 -9
- package/lib/server/modules/payment/types.js +0 -17
- package/lib/server/test.json +0 -713
- package/lib/server/utils/small-ticket.d.ts +0 -71
- package/lib/server/utils/small-ticket.js +0 -781
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +0 -287
- package/lib/solution/BaseSales/utils/cartPromotion.js +0 -992
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
- package/lib/solution/BaseSales/utils/quotationPrice.js +0 -277
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -117
- package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -318
- package/lib/solution/BookingTicket/utils/addTimeAvailability.d.ts +0 -35
- package/lib/solution/BookingTicket/utils/addTimeAvailability.js +0 -125
- package/lib/solution/BookingTicket/utils/exampleData.d.ts +0 -123
- package/lib/solution/BookingTicket/utils/exampleData.js +0 -0
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +0 -185
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +0 -254
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -36
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +0 -168
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -32
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +0 -51
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +0 -21
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +0 -127
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.d.ts +0 -23
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +0 -85
|
@@ -29,450 +29,67 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
// src/modules/Order/utils.ts
|
|
30
30
|
var utils_exports = {};
|
|
31
31
|
__export(utils_exports, {
|
|
32
|
-
buildManualProductDiscountItem: () => import_manualProductDiscount.buildManualProductDiscountItem,
|
|
33
32
|
buildSubmitPayload: () => buildSubmitPayload,
|
|
34
|
-
calculateOrderProductsDeposit: () => calculateOrderProductsDeposit,
|
|
35
|
-
clearTempOrderHolderAssignments: () => clearTempOrderHolderAssignments,
|
|
36
33
|
composeLinePrice: () => composeLinePrice,
|
|
37
34
|
createDefaultOrderRulesHooks: () => createDefaultOrderRulesHooks,
|
|
38
35
|
createDefaultTempOrder: () => createDefaultTempOrder,
|
|
39
36
|
createEmptySummary: () => import_utils2.createEmptySummary,
|
|
40
37
|
createUuidV4: () => createUuidV4,
|
|
41
|
-
ensureManualProductDiscountList: () => import_manualProductDiscount.ensureManualProductDiscountList,
|
|
42
|
-
ensureProductSku: () => ensureProductSku,
|
|
43
|
-
findManualProductDiscountItem: () => import_manualProductDiscount.findManualProductDiscountItem,
|
|
44
38
|
formatDateTime: () => formatDateTime,
|
|
45
39
|
formatV1Product: () => formatV1Product,
|
|
46
40
|
generateDuration: () => generateDuration,
|
|
47
41
|
getAllDiscountList: () => getAllDiscountList,
|
|
48
|
-
getBundleSellingMagnitude: () => getBundleSellingMagnitude,
|
|
49
|
-
getBundleSignedUnit: () => getBundleSignedUnit,
|
|
50
|
-
getOrderProductLineUid: () => getOrderProductLineUid,
|
|
51
|
-
getProductSkuOptions: () => getProductSkuOptions,
|
|
52
|
-
hasAssignedHolderId: () => hasAssignedHolderId,
|
|
53
|
-
indexOrderProductsByUid: () => indexOrderProductsByUid,
|
|
54
|
-
isEmptyOrderProductDisplayValue: () => isEmptyOrderProductDisplayValue,
|
|
55
|
-
isMarkdownBundle: () => isMarkdownBundle,
|
|
56
42
|
isTempOrder: () => isTempOrder,
|
|
57
43
|
mapPaymentItemToOrderPayment: () => mapPaymentItemToOrderPayment,
|
|
58
44
|
mapPaymentItemsToOrderPayments: () => mapPaymentItemsToOrderPayments,
|
|
59
|
-
mergeManualProductDiscountIntoList: () => import_manualProductDiscount.mergeManualProductDiscountIntoList,
|
|
60
|
-
mergeOrderProductDisplayFields: () => mergeOrderProductDisplayFields,
|
|
61
45
|
mergeRelationForms: () => mergeRelationForms,
|
|
62
46
|
normalizeBookingIsAll: () => normalizeBookingIsAll,
|
|
63
47
|
normalizeBookingSubType: () => normalizeBookingSubType,
|
|
64
|
-
normalizeOrderProductDiscountList: () => normalizeOrderProductDiscountList,
|
|
65
|
-
normalizeProductSkuOptions: () => normalizeProductSkuOptions,
|
|
66
48
|
normalizeSubmitBooking: () => normalizeSubmitBooking,
|
|
67
49
|
normalizeSubmitCollectPaxValue: () => normalizeSubmitCollectPaxValue,
|
|
68
|
-
resolveEffectivePerUnitDiscount: () => resolveEffectivePerUnitDiscount,
|
|
69
|
-
resolveManualDiscountMessage: () => import_manualProductDiscount.resolveManualDiscountMessage,
|
|
70
|
-
resolveManualDiscountOriginTotal: () => import_manualProductDiscount.resolveManualDiscountOriginTotal,
|
|
71
|
-
resolveManualDiscountReasonFromSources: () => import_manualProductDiscount.resolveManualDiscountReasonFromSources,
|
|
72
|
-
resolveManualOverrideLineOriginalPrice: () => resolveManualOverrideLineOriginalPrice,
|
|
73
|
-
resolveRulesManualDiscountFlag: () => resolveRulesManualDiscountFlag,
|
|
74
|
-
resolveSafeProductNum: () => import_manualProductDiscount.resolveSafeProductNum,
|
|
75
50
|
resolveSubmitCollectPax: () => resolveSubmitCollectPax,
|
|
76
|
-
|
|
77
|
-
stripManualProductDiscountItems: () => import_manualProductDiscount.stripManualProductDiscountItems,
|
|
78
|
-
sumOptionUnitPrice: () => sumOptionUnitPrice,
|
|
79
|
-
syncManualProductDiscountProductNum: () => import_manualProductDiscount.syncManualProductDiscountProductNum
|
|
51
|
+
sumOptionUnitPrice: () => sumOptionUnitPrice
|
|
80
52
|
});
|
|
81
53
|
module.exports = __toCommonJS(utils_exports);
|
|
82
54
|
var import_dayjs = __toESM(require("dayjs"));
|
|
83
55
|
var import_decimal = __toESM(require("decimal.js"));
|
|
84
56
|
var import_utils = require("../../solution/ScanOrder/utils");
|
|
85
57
|
var import_utils2 = require("../../solution/ScanOrder/utils");
|
|
86
|
-
var import_manualProductDiscount = require("./utils/manualProductDiscount");
|
|
87
58
|
function composeLinePrice(params) {
|
|
88
59
|
const { mainPrice, bundle, useOriginalBundle } = params;
|
|
89
60
|
let total = new import_decimal.default(Number(mainPrice) || 0);
|
|
90
61
|
if (Array.isArray(bundle)) {
|
|
91
62
|
for (const item of bundle) {
|
|
92
|
-
const
|
|
63
|
+
const rawPrice = useOriginalBundle ? (item == null ? void 0 : item.original_price) ?? (item == null ? void 0 : item.product_price) ?? (item == null ? void 0 : item.price) : (item == null ? void 0 : item.bundle_selling_price) ?? (item == null ? void 0 : item.price);
|
|
64
|
+
const price = new import_decimal.default(Number(rawPrice) || 0);
|
|
93
65
|
const rawNum = (item == null ? void 0 : item.num) ?? (item == null ? void 0 : item.quantity) ?? 1;
|
|
94
66
|
const num = new import_decimal.default(Number(rawNum) || 0);
|
|
95
|
-
total = total.plus(
|
|
67
|
+
total = total.plus(price.times(num));
|
|
96
68
|
}
|
|
97
69
|
}
|
|
98
70
|
return total.toDecimalPlaces(2).toFixed(2);
|
|
99
71
|
}
|
|
100
|
-
function normalizeProductSkuOptions(options) {
|
|
101
|
-
if (!Array.isArray(options))
|
|
102
|
-
return [];
|
|
103
|
-
return options.map((option) => {
|
|
104
|
-
const normalized = {
|
|
105
|
-
...option && typeof option === "object" ? option : {}
|
|
106
|
-
};
|
|
107
|
-
const addPrice = normalized.add_price ?? normalized.price;
|
|
108
|
-
if (addPrice !== void 0)
|
|
109
|
-
normalized.add_price = addPrice;
|
|
110
|
-
delete normalized.price;
|
|
111
|
-
return normalized;
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
function ensureProductSku(product) {
|
|
115
|
-
const rawSku = (product == null ? void 0 : product.product_sku) && typeof product.product_sku === "object" ? product.product_sku : {};
|
|
116
|
-
return {
|
|
117
|
-
...rawSku,
|
|
118
|
-
option: normalizeProductSkuOptions(rawSku.option)
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
function getProductSkuOptions(product) {
|
|
122
|
-
return ensureProductSku(product).option;
|
|
123
|
-
}
|
|
124
72
|
function sumOptionUnitPrice(options) {
|
|
125
73
|
let total = new import_decimal.default(0);
|
|
126
74
|
if (!Array.isArray(options))
|
|
127
75
|
return total;
|
|
128
76
|
for (const opt of options) {
|
|
129
|
-
const price = new import_decimal.default(Number(
|
|
77
|
+
const price = new import_decimal.default(Number(opt == null ? void 0 : opt.price) || 0);
|
|
130
78
|
const num = new import_decimal.default(Number(opt == null ? void 0 : opt.num) || 0);
|
|
131
79
|
total = total.plus(price.times(num));
|
|
132
80
|
}
|
|
133
81
|
return total;
|
|
134
82
|
}
|
|
135
|
-
function getSafeOrderProductNum(num) {
|
|
136
|
-
const parsedNum = Number(num ?? 1);
|
|
137
|
-
if (!Number.isFinite(parsedNum) || parsedNum < 1)
|
|
138
|
-
return 1;
|
|
139
|
-
return Math.floor(parsedNum);
|
|
140
|
-
}
|
|
141
|
-
function getOrderProductDepositUnitTotal(product) {
|
|
142
|
-
const metadata = product.metadata || {};
|
|
143
|
-
const paymentPrice = metadata.main_product_attached_bundle_payment_price;
|
|
144
|
-
const mainSellingPrice = metadata.main_product_selling_price;
|
|
145
|
-
const fallbackPrice = product.selling_price;
|
|
146
|
-
return new import_decimal.default(Number(paymentPrice ?? mainSellingPrice ?? fallbackPrice) || 0);
|
|
147
|
-
}
|
|
148
|
-
function normalizeDepositProtocols(protocols) {
|
|
149
|
-
if (!Array.isArray(protocols))
|
|
150
|
-
return [];
|
|
151
|
-
return protocols.reduce((result, protocol) => {
|
|
152
|
-
const id = Number(protocol == null ? void 0 : protocol.id);
|
|
153
|
-
if (!Number.isFinite(id))
|
|
154
|
-
return result;
|
|
155
|
-
result.push({
|
|
156
|
-
id: Math.floor(id),
|
|
157
|
-
title: String((protocol == null ? void 0 : protocol.title) || "")
|
|
158
|
-
});
|
|
159
|
-
return result;
|
|
160
|
-
}, []);
|
|
161
|
-
}
|
|
162
|
-
function getDepositPolicyIds(depositData) {
|
|
163
|
-
const ids = [
|
|
164
|
-
...Array.isArray(depositData == null ? void 0 : depositData.self_deposit_policy_ids) ? depositData.self_deposit_policy_ids : [],
|
|
165
|
-
...Array.isArray(depositData == null ? void 0 : depositData.deposit_policy_ids) ? depositData.deposit_policy_ids : []
|
|
166
|
-
];
|
|
167
|
-
return ids.reduce((result, id) => {
|
|
168
|
-
const normalizedId = Number(id);
|
|
169
|
-
if (!Number.isFinite(normalizedId))
|
|
170
|
-
return result;
|
|
171
|
-
result.push(Math.floor(normalizedId));
|
|
172
|
-
return result;
|
|
173
|
-
}, []);
|
|
174
|
-
}
|
|
175
|
-
function handleOrderProductDeposit(params) {
|
|
176
|
-
const { depositData, total, num } = params;
|
|
177
|
-
if (!depositData)
|
|
178
|
-
return { result: false, depositTotal: new import_decimal.default(0) };
|
|
179
|
-
const { deposit_fixed, deposit_percentage } = depositData;
|
|
180
|
-
if (typeof deposit_fixed !== "string" || typeof deposit_percentage !== "string") {
|
|
181
|
-
return { result: false, depositTotal: new import_decimal.default(0) };
|
|
182
|
-
}
|
|
183
|
-
const depositFixed = new import_decimal.default(deposit_fixed || 0);
|
|
184
|
-
const depositPercent = new import_decimal.default(deposit_percentage || 0);
|
|
185
|
-
const productTotalPrice = new import_decimal.default(total || 0);
|
|
186
|
-
const deposit = depositFixed.plus(depositPercent.times(productTotalPrice));
|
|
187
|
-
return { depositTotal: deposit.times(num), result: true };
|
|
188
|
-
}
|
|
189
|
-
function resolveOrderProductDepositSource(product, runtimeOrigin) {
|
|
190
|
-
const record = product;
|
|
191
|
-
const origin = record._origin || runtimeOrigin || {};
|
|
192
|
-
const originProduct = origin.product || {};
|
|
193
|
-
return {
|
|
194
|
-
...originProduct,
|
|
195
|
-
...origin,
|
|
196
|
-
...record,
|
|
197
|
-
custom_deposit_data: record.custom_deposit_data ?? origin.custom_deposit_data ?? originProduct.custom_deposit_data,
|
|
198
|
-
variant: record.variant ?? origin.variant ?? originProduct.variant
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
function getOrderProductDeposit(product, runtimeOrigin) {
|
|
202
|
-
const depositProduct = resolveOrderProductDepositSource(product, runtimeOrigin);
|
|
203
|
-
const depositData = depositProduct.custom_deposit_data;
|
|
204
|
-
if ((depositData == null ? void 0 : depositData.has_deposit) != 1)
|
|
205
|
-
return null;
|
|
206
|
-
const num = getSafeOrderProductNum(product.num);
|
|
207
|
-
const total = getOrderProductDepositUnitTotal(product).times(num);
|
|
208
|
-
const allProtocols = normalizeDepositProtocols(depositData.deposit_policy_data);
|
|
209
|
-
const protocolIds = [];
|
|
210
|
-
let depositTotal = new import_decimal.default(0);
|
|
211
|
-
let hasDeposit = false;
|
|
212
|
-
if (typeof depositData.deposit_fixed === "string" && typeof depositData.deposit_percentage === "string") {
|
|
213
|
-
const result = handleOrderProductDeposit({
|
|
214
|
-
depositData,
|
|
215
|
-
total,
|
|
216
|
-
num
|
|
217
|
-
});
|
|
218
|
-
if (result.result) {
|
|
219
|
-
depositTotal = result.depositTotal;
|
|
220
|
-
protocolIds.push(...getDepositPolicyIds({
|
|
221
|
-
self_deposit_policy_ids: depositData.self_deposit_policy_ids
|
|
222
|
-
}));
|
|
223
|
-
hasDeposit = true;
|
|
224
|
-
}
|
|
225
|
-
} else {
|
|
226
|
-
const productVariantId = depositProduct.product_variant_id ?? product.product_variant_id;
|
|
227
|
-
if (productVariantId) {
|
|
228
|
-
const variantProduct = (depositProduct.variant || []).find(
|
|
229
|
-
(item) => (item == null ? void 0 : item.id) === productVariantId
|
|
230
|
-
);
|
|
231
|
-
const variantDepositData = variantProduct == null ? void 0 : variantProduct.custom_deposit_data;
|
|
232
|
-
const result = handleOrderProductDeposit({
|
|
233
|
-
depositData: variantDepositData,
|
|
234
|
-
total,
|
|
235
|
-
num
|
|
236
|
-
});
|
|
237
|
-
if (result.result) {
|
|
238
|
-
depositTotal = result.depositTotal;
|
|
239
|
-
protocolIds.push(...getDepositPolicyIds({
|
|
240
|
-
self_deposit_policy_ids: variantDepositData == null ? void 0 : variantDepositData.self_deposit_policy_ids
|
|
241
|
-
}));
|
|
242
|
-
hasDeposit = true;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
if (Array.isArray(product.product_bundle) && product.product_bundle.length) {
|
|
246
|
-
depositTotal = product.product_bundle.reduce((accumulator, bundleProduct) => {
|
|
247
|
-
const bundleDepositData = bundleProduct == null ? void 0 : bundleProduct.custom_deposit_data;
|
|
248
|
-
const result = handleOrderProductDeposit({
|
|
249
|
-
depositData: bundleDepositData,
|
|
250
|
-
total: bundleProduct == null ? void 0 : bundleProduct.price,
|
|
251
|
-
num: getSafeOrderProductNum((bundleProduct == null ? void 0 : bundleProduct.num) || 1)
|
|
252
|
-
});
|
|
253
|
-
if (!result.result)
|
|
254
|
-
return accumulator;
|
|
255
|
-
protocolIds.push(...getDepositPolicyIds({
|
|
256
|
-
self_deposit_policy_ids: bundleDepositData == null ? void 0 : bundleDepositData.self_deposit_policy_ids
|
|
257
|
-
}));
|
|
258
|
-
hasDeposit = true;
|
|
259
|
-
return accumulator.plus(result.depositTotal);
|
|
260
|
-
}, new import_decimal.default(0));
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
if (!hasDeposit)
|
|
264
|
-
return null;
|
|
265
|
-
const protocolIdSet = new Set(protocolIds);
|
|
266
|
-
const protocols = allProtocols.filter((protocol) => protocolIdSet.has(protocol.id));
|
|
267
|
-
return {
|
|
268
|
-
total: depositTotal.toNumber(),
|
|
269
|
-
protocols
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
function calculateOrderProductsDeposit(products = [], options) {
|
|
273
|
-
var _a, _b, _c;
|
|
274
|
-
const protocolMap = /* @__PURE__ */ new Map();
|
|
275
|
-
let total = new import_decimal.default(0);
|
|
276
|
-
let hasDeposit = false;
|
|
277
|
-
for (const product of products || []) {
|
|
278
|
-
const productUid = (_a = product.metadata) == null ? void 0 : _a.unique_identification_number;
|
|
279
|
-
const runtimeOrigin = productUid ? (_c = (_b = options == null ? void 0 : options.productsByUid) == null ? void 0 : _b[productUid]) == null ? void 0 : _c.origin : void 0;
|
|
280
|
-
const deposit = getOrderProductDeposit(product, runtimeOrigin);
|
|
281
|
-
product.deposit = deposit;
|
|
282
|
-
if (!(deposit == null ? void 0 : deposit.total) || Number(deposit.total) <= 0)
|
|
283
|
-
continue;
|
|
284
|
-
total = total.plus(deposit.total);
|
|
285
|
-
for (const discount of product.discount_list || []) {
|
|
286
|
-
total = total.minus((discount == null ? void 0 : discount.amount) || 0);
|
|
287
|
-
}
|
|
288
|
-
for (const protocol of deposit.protocols || []) {
|
|
289
|
-
if (!protocolMap.has(protocol.id))
|
|
290
|
-
protocolMap.set(protocol.id, protocol);
|
|
291
|
-
}
|
|
292
|
-
hasDeposit = true;
|
|
293
|
-
}
|
|
294
|
-
const roundedTotal = total.toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP);
|
|
295
|
-
const protocols = [...protocolMap.values()];
|
|
296
|
-
return {
|
|
297
|
-
total: roundedTotal.toNumber(),
|
|
298
|
-
totalText: roundedTotal.toFixed(2),
|
|
299
|
-
protocols,
|
|
300
|
-
deposit_policy_ids: protocols.map((protocol) => protocol.id),
|
|
301
|
-
hasDeposit
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
function isMarkdownBundle(bundle) {
|
|
305
|
-
if (!bundle || typeof bundle !== "object")
|
|
306
|
-
return false;
|
|
307
|
-
const ext = bundle.price_type_ext ?? bundle.custom_price_type_ext;
|
|
308
|
-
const type = bundle.price_type ?? bundle.custom_price_type;
|
|
309
|
-
return type === "markdown" && ext !== "product_price";
|
|
310
|
-
}
|
|
311
|
-
function getBundleSignedUnit(bundle, options) {
|
|
312
|
-
if (!bundle || typeof bundle !== "object")
|
|
313
|
-
return new import_decimal.default(0);
|
|
314
|
-
const useOriginal = (options == null ? void 0 : options.useOriginal) ?? false;
|
|
315
|
-
if (isMarkdownBundle(bundle)) {
|
|
316
|
-
const catalog = useOriginal ? bundle.original_price ?? bundle.product_price ?? bundle.custom_price ?? bundle.base_price ?? bundle.price : bundle.custom_price ?? bundle.product_price ?? bundle.original_price ?? bundle.base_price ?? bundle.price;
|
|
317
|
-
if (catalog !== void 0 && catalog !== null && catalog !== "") {
|
|
318
|
-
const raw = new import_decimal.default(Number(catalog) || 0);
|
|
319
|
-
if (raw.lt(0))
|
|
320
|
-
return raw;
|
|
321
|
-
return raw.minus(sumOptionUnitPrice(bundle.option)).negated();
|
|
322
|
-
}
|
|
323
|
-
return new import_decimal.default(Number(bundle.bundle_selling_price) || 0).abs().negated();
|
|
324
|
-
}
|
|
325
|
-
const rawPrice = useOriginal ? bundle.original_price ?? bundle.product_price ?? bundle.price : bundle.bundle_selling_price ?? bundle.price;
|
|
326
|
-
return new import_decimal.default(Number(rawPrice) || 0);
|
|
327
|
-
}
|
|
328
|
-
function getBundleSellingMagnitude(bundle) {
|
|
329
|
-
return getBundleSignedUnit(bundle).abs();
|
|
330
|
-
}
|
|
331
|
-
function resolveRulesManualDiscountFlag(metadata) {
|
|
332
|
-
if (!metadata)
|
|
333
|
-
return void 0;
|
|
334
|
-
if (metadata.is_manual_discount === true || metadata.is_manual_discount === 1) {
|
|
335
|
-
return true;
|
|
336
|
-
}
|
|
337
|
-
const priceOverride = metadata.price_override;
|
|
338
|
-
if (priceOverride !== void 0 && priceOverride !== null && priceOverride !== "") {
|
|
339
|
-
return true;
|
|
340
|
-
}
|
|
341
|
-
return void 0;
|
|
342
|
-
}
|
|
343
|
-
function normalizeOrderProductDiscountAmount(amount) {
|
|
344
|
-
if (amount === void 0 || amount === null)
|
|
345
|
-
return void 0;
|
|
346
|
-
return String(amount);
|
|
347
|
-
}
|
|
348
|
-
function normalizeOrderProductDiscountList(discountList) {
|
|
349
|
-
if (!Array.isArray(discountList))
|
|
350
|
-
return [];
|
|
351
|
-
return discountList.filter((item) => !!item && typeof item === "object").map((item) => {
|
|
352
|
-
const normalized = {
|
|
353
|
-
discount_id: Number.isFinite(Number(item.discount_id)) ? Number(item.discount_id) : 0
|
|
354
|
-
};
|
|
355
|
-
if (item.order_discount_id === null) {
|
|
356
|
-
normalized.order_discount_id = null;
|
|
357
|
-
} else if (item.order_discount_id !== void 0) {
|
|
358
|
-
const orderDiscountId = Number(item.order_discount_id);
|
|
359
|
-
if (Number.isFinite(orderDiscountId)) {
|
|
360
|
-
normalized.order_discount_id = orderDiscountId;
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
if (item.type !== void 0)
|
|
364
|
-
normalized.type = item.type;
|
|
365
|
-
const amount = normalizeOrderProductDiscountAmount(item.amount);
|
|
366
|
-
if (amount !== void 0)
|
|
367
|
-
normalized.amount = amount;
|
|
368
|
-
if (item.discount && typeof item.discount === "object") {
|
|
369
|
-
normalized.discount = { ...item.discount };
|
|
370
|
-
}
|
|
371
|
-
if (item.metadata === null) {
|
|
372
|
-
normalized.metadata = null;
|
|
373
|
-
} else if (item.metadata && typeof item.metadata === "object") {
|
|
374
|
-
normalized.metadata = { ...item.metadata };
|
|
375
|
-
}
|
|
376
|
-
return normalized;
|
|
377
|
-
});
|
|
378
|
-
}
|
|
379
|
-
function resolveManualOverrideLineOriginalPrice(params, fallbackCompositeOriginal) {
|
|
380
|
-
var _a, _b;
|
|
381
|
-
const metadata = params.metadata || {};
|
|
382
|
-
const priceOverride = metadata.price_override;
|
|
383
|
-
if (priceOverride === void 0 || priceOverride === null || priceOverride === "") {
|
|
384
|
-
return fallbackCompositeOriginal;
|
|
385
|
-
}
|
|
386
|
-
const refTotal = (_b = (_a = metadata.origin) == null ? void 0 : _a._extend) == null ? void 0 : _b.origin_total;
|
|
387
|
-
if (refTotal !== void 0 && refTotal !== null && refTotal !== "") {
|
|
388
|
-
const parsed = Number(refTotal);
|
|
389
|
-
if (Number.isFinite(parsed)) {
|
|
390
|
-
return new import_decimal.default(parsed).toDecimalPlaces(2).toFixed(2);
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
const lineOriginal = params.lineOriginalPrice;
|
|
394
|
-
if (lineOriginal !== void 0 && lineOriginal !== null && lineOriginal !== "") {
|
|
395
|
-
const parsedLine = Number(lineOriginal);
|
|
396
|
-
const parsedFallback = Number(fallbackCompositeOriginal);
|
|
397
|
-
if (Number.isFinite(parsedLine) && Number.isFinite(parsedFallback) && parsedLine > parsedFallback) {
|
|
398
|
-
return new import_decimal.default(parsedLine).toDecimalPlaces(2).toFixed(2);
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
return fallbackCompositeOriginal;
|
|
402
|
-
}
|
|
403
|
-
function resolveEffectivePerUnitDiscount(product) {
|
|
404
|
-
const discountList = Array.isArray(product == null ? void 0 : product.discount_list) ? product.discount_list : [];
|
|
405
|
-
const fromList = discountList.reduce(
|
|
406
|
-
(sum, discount) => sum + Number((discount == null ? void 0 : discount.amount) || 0),
|
|
407
|
-
0
|
|
408
|
-
);
|
|
409
|
-
const hasPromoDiscountItem = discountList.some((item) => (item == null ? void 0 : item.type) === "promotion");
|
|
410
|
-
if (hasPromoDiscountItem)
|
|
411
|
-
return fromList;
|
|
412
|
-
const metadata = (product == null ? void 0 : product.metadata) || {};
|
|
413
|
-
const promo = metadata._promotion;
|
|
414
|
-
if ((promo == null ? void 0 : promo.inPromotion) !== true)
|
|
415
|
-
return fromList;
|
|
416
|
-
const optionSum = sumOptionUnitPrice(getProductSkuOptions(product)).toNumber();
|
|
417
|
-
if (!discountList.length && metadata.source_product_price != null && metadata.main_product_selling_price != null) {
|
|
418
|
-
const source = Number(metadata.source_product_price);
|
|
419
|
-
const selling = Number(metadata.main_product_selling_price) - optionSum;
|
|
420
|
-
if (Number.isFinite(source) && Number.isFinite(selling) && source !== selling) {
|
|
421
|
-
return fromList + (source - selling);
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
const originalPrice = Number(promo.originalPrice);
|
|
425
|
-
const finalPrice = Number(promo.finalPrice);
|
|
426
|
-
if (!Number.isFinite(originalPrice) || !Number.isFinite(finalPrice))
|
|
427
|
-
return fromList;
|
|
428
|
-
return fromList + (originalPrice - finalPrice);
|
|
429
|
-
}
|
|
430
83
|
function createDefaultOrderRulesHooks() {
|
|
431
84
|
const toUnitPriceString = (totalLike, num) => {
|
|
432
85
|
const effectiveNum = Number(num) > 0 ? Number(num) : 1;
|
|
433
86
|
return new import_decimal.default(Number(totalLike) || 0).dividedBy(effectiveNum).toDecimalPlaces(2).toString();
|
|
434
87
|
};
|
|
435
|
-
const getBundleIdentity = (bundle) => {
|
|
436
|
-
return [
|
|
437
|
-
bundle.bundle_id ?? bundle.id ?? "",
|
|
438
|
-
bundle.bundle_product_id ?? bundle._bundle_product_id ?? bundle.product_id ?? "",
|
|
439
|
-
bundle.bundle_variant_id ?? bundle.variant_id ?? bundle.product_variant_id ?? 0,
|
|
440
|
-
bundle.bundle_group_id ?? bundle.group_id ?? ""
|
|
441
|
-
].join("|");
|
|
442
|
-
};
|
|
443
|
-
const mergeRulesBundlePrices = (currentBundle, rulesBundle) => {
|
|
444
|
-
if (!Array.isArray(rulesBundle))
|
|
445
|
-
return rulesBundle;
|
|
446
|
-
const currentByIdentity = /* @__PURE__ */ new Map();
|
|
447
|
-
(currentBundle || []).forEach((bundle) => {
|
|
448
|
-
if (!bundle || typeof bundle !== "object")
|
|
449
|
-
return;
|
|
450
|
-
currentByIdentity.set(getBundleIdentity(bundle), bundle);
|
|
451
|
-
});
|
|
452
|
-
return rulesBundle.map((bundle) => {
|
|
453
|
-
if (!bundle || typeof bundle !== "object")
|
|
454
|
-
return bundle;
|
|
455
|
-
const current = currentByIdentity.get(getBundleIdentity(bundle));
|
|
456
|
-
if (!current)
|
|
457
|
-
return bundle;
|
|
458
|
-
const isProductPriceBundle = (bundle.price_type_ext ?? current.price_type_ext) === "product_price";
|
|
459
|
-
if (!isProductPriceBundle)
|
|
460
|
-
return bundle;
|
|
461
|
-
const sourcePrice = current.price ?? current.custom_price ?? current.original_price ?? current.bundle_selling_price;
|
|
462
|
-
const originalPrice = current.original_price ?? current.product_price ?? current.price ?? current.custom_price ?? sourcePrice;
|
|
463
|
-
return {
|
|
464
|
-
...bundle,
|
|
465
|
-
...sourcePrice !== void 0 ? { price: sourcePrice } : {},
|
|
466
|
-
...originalPrice !== void 0 ? { original_price: originalPrice } : {},
|
|
467
|
-
...current.original_total !== void 0 ? { original_total: current.original_total } : {}
|
|
468
|
-
};
|
|
469
|
-
});
|
|
470
|
-
};
|
|
471
88
|
return {
|
|
472
89
|
getProduct: (product) => {
|
|
473
90
|
var _a, _b, _c, _d, _e, _f;
|
|
474
91
|
const metadataAny = product.metadata || {};
|
|
475
|
-
const optionSum = sumOptionUnitPrice(
|
|
92
|
+
const optionSum = sumOptionUnitPrice(product.product_option_item);
|
|
476
93
|
let sourcePrice;
|
|
477
94
|
if (metadataAny.source_product_price !== void 0) {
|
|
478
95
|
sourcePrice = String(metadataAny.source_product_price);
|
|
@@ -497,10 +114,10 @@ function createDefaultOrderRulesHooks() {
|
|
|
497
114
|
id: product.product_id,
|
|
498
115
|
// Rules 引擎用 _id 作为 processedProductsMap 键;必须与购物车行级 identity 一致,
|
|
499
116
|
// 否则同 SKU 不同小料会在 calcDiscount 重组时互相覆盖。
|
|
500
|
-
// 不透明 identity 契约下,normalizeOrderProduct /
|
|
117
|
+
// 不透明 identity 契约下,normalizeOrderProduct / restoreTempOrderFromStorage 已保证唯一值存在;
|
|
501
118
|
// 留 fingerprint 分支仅作 Rules 单测里直接传裸 product 时的兜底。
|
|
502
119
|
_id: ((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) ? `${product.product_id}_${product.product_variant_id}_${product.metadata.unique_identification_number}` : `${product.product_id}_${product.product_variant_id}_${(0, import_utils.buildProductLineFingerprint)(
|
|
503
|
-
|
|
120
|
+
product.product_option_item,
|
|
504
121
|
product.product_bundle
|
|
505
122
|
)}`,
|
|
506
123
|
// Rules 内部 getProductTotalPrice / getProductOriginTotalPrice 会各自再叠加 bundle + option,
|
|
@@ -518,27 +135,22 @@ function createDefaultOrderRulesHooks() {
|
|
|
518
135
|
bundle: product.product_bundle || [],
|
|
519
136
|
booking_id: ((_b = product.metadata) == null ? void 0 : _b.booking_id) || null,
|
|
520
137
|
isClient: false,
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
holder_id: (_c = product.metadata) == null ? void 0 : _c.holder_id,
|
|
525
|
-
startDate: ((_d = product.metadata) == null ? void 0 : _d.start_date) || ((_e = product.metadata) == null ? void 0 : _e.startDate),
|
|
526
|
-
main_product_selling_price: metadataAny.main_product_selling_price !== void 0 ? new import_decimal.default(Number(metadataAny.main_product_selling_price) || 0).minus(optionSum).toDecimalPlaces(2).toString() : void 0,
|
|
527
|
-
inPromotion: ((_f = metadataAny._promotion) == null ? void 0 : _f.inPromotion) === true,
|
|
528
|
-
_promotion: metadataAny._promotion
|
|
138
|
+
isManualDiscount: ((_c = product.metadata) == null ? void 0 : _c.is_manual_discount) || false,
|
|
139
|
+
holder_id: (_d = product.metadata) == null ? void 0 : _d.holder_id,
|
|
140
|
+
startDate: ((_e = product.metadata) == null ? void 0 : _e.start_date) || ((_f = product.metadata) == null ? void 0 : _f.startDate)
|
|
529
141
|
};
|
|
530
142
|
},
|
|
531
143
|
setProduct: (product, values) => {
|
|
532
144
|
const nextNum = Number(values.quantity ?? product.num ?? 1) || 1;
|
|
533
145
|
const metadataAny = product.metadata || {};
|
|
534
146
|
const existedSource = metadataAny.source_product_price ?? product.selling_price ?? "0";
|
|
535
|
-
const nextOptions =
|
|
147
|
+
const nextOptions = product.product_option_item;
|
|
536
148
|
const optionSum = sumOptionUnitPrice(nextOptions);
|
|
537
149
|
const nextSourceSellingPrice = values.main_product_selling_price !== void 0 ? String(values.main_product_selling_price) : values.price !== void 0 ? String(values.price) : values.total !== void 0 ? toUnitPriceString(values.total, nextNum) : String(existedSource);
|
|
538
150
|
const nextSourceOriginalPrice = values.original_price !== void 0 ? String(values.original_price) : String(existedSource);
|
|
539
151
|
const nextMainSellingPrice = new import_decimal.default(Number(nextSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
540
152
|
const nextMainOriginalPrice = new import_decimal.default(Number(nextSourceOriginalPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
541
|
-
const nextBundle = values.bundle
|
|
153
|
+
const nextBundle = values.bundle ?? product.product_bundle;
|
|
542
154
|
const composedSellingPrice = composeLinePrice({
|
|
543
155
|
mainPrice: nextMainSellingPrice,
|
|
544
156
|
bundle: nextBundle
|
|
@@ -548,14 +160,10 @@ function createDefaultOrderRulesHooks() {
|
|
|
548
160
|
bundle: nextBundle,
|
|
549
161
|
useOriginalBundle: true
|
|
550
162
|
});
|
|
551
|
-
const finalOriginalPrice = resolveManualOverrideLineOriginalPrice(
|
|
552
|
-
{ num: nextNum, metadata: metadataAny, lineOriginalPrice: product.original_price },
|
|
553
|
-
composedOriginalPrice
|
|
554
|
-
);
|
|
555
163
|
return {
|
|
556
164
|
...product,
|
|
557
165
|
selling_price: composedSellingPrice,
|
|
558
|
-
original_price:
|
|
166
|
+
original_price: composedOriginalPrice,
|
|
559
167
|
discount_list: values.discount_list ?? product.discount_list,
|
|
560
168
|
num: values.quantity ?? product.num,
|
|
561
169
|
product_bundle: nextBundle,
|
|
@@ -641,7 +249,6 @@ function formatSubmitOptionItems(options) {
|
|
|
641
249
|
return [];
|
|
642
250
|
return options.map((d) => {
|
|
643
251
|
const option = {
|
|
644
|
-
...d && typeof d === "object" ? d : {},
|
|
645
252
|
num: d == null ? void 0 : d.num,
|
|
646
253
|
option_group_item_id: d == null ? void 0 : d.option_group_item_id,
|
|
647
254
|
option_group_id: d == null ? void 0 : d.option_group_id
|
|
@@ -649,7 +256,6 @@ function formatSubmitOptionItems(options) {
|
|
|
649
256
|
const addPrice = (d == null ? void 0 : d.add_price) ?? (d == null ? void 0 : d.price);
|
|
650
257
|
if (addPrice !== void 0)
|
|
651
258
|
option.add_price = String(addPrice);
|
|
652
|
-
delete option.price;
|
|
653
259
|
return option;
|
|
654
260
|
});
|
|
655
261
|
}
|
|
@@ -671,8 +277,9 @@ function formatSubmitBundleItems(bundle) {
|
|
|
671
277
|
return bundle.map((b) => {
|
|
672
278
|
const rawBundle = b && typeof b === "object" ? b : {};
|
|
673
279
|
const existedMetadata = rawBundle.metadata && typeof rawBundle.metadata === "object" ? rawBundle.metadata : {};
|
|
674
|
-
const sellingPrice =
|
|
675
|
-
|
|
280
|
+
const sellingPrice = toMoneyString(
|
|
281
|
+
rawBundle.bundle_selling_price ?? rawBundle.price
|
|
282
|
+
);
|
|
676
283
|
const priceValue = rawBundle.price ?? rawBundle.custom_price ?? rawBundle.bundle_selling_price;
|
|
677
284
|
const relationSurchargeIds = Array.isArray(rawBundle.relation_surcharge_ids) ? rawBundle.relation_surcharge_ids : Array.isArray(existedMetadata.relation_surcharge_ids) ? existedMetadata.relation_surcharge_ids : [];
|
|
678
285
|
const surchargeFee = toMoneyString(
|
|
@@ -694,7 +301,6 @@ function formatSubmitBundleItems(bundle) {
|
|
|
694
301
|
price_type: rawBundle.price_type ?? rawBundle.custom_price_type ?? "",
|
|
695
302
|
price_type_ext: rawBundle.price_type_ext ?? rawBundle.custom_price_type_ext ?? "",
|
|
696
303
|
bundle_selling_price: sellingPrice,
|
|
697
|
-
bundle_payment_price: paymentPrice,
|
|
698
304
|
option: formatSubmitOptionItems(rawBundle.option),
|
|
699
305
|
bundle_group_id: (rawBundle == null ? void 0 : rawBundle.bundle_group_id) ?? (rawBundle == null ? void 0 : rawBundle.group_id),
|
|
700
306
|
bundle_id: (rawBundle == null ? void 0 : rawBundle.bundle_id) ?? (rawBundle == null ? void 0 : rawBundle.id),
|
|
@@ -713,15 +319,10 @@ function normalizeSubmitProduct(product) {
|
|
|
713
319
|
const { unique_identification_number: _runtimeUid, ...submitProduct } = product;
|
|
714
320
|
const {
|
|
715
321
|
num,
|
|
322
|
+
product_option_item: productOptionItem,
|
|
716
323
|
surcharge_fee: _productSurchargeFee,
|
|
717
|
-
discount_amount: _deprecatedDiscountAmount,
|
|
718
|
-
discount_type: _deprecatedDiscountType,
|
|
719
|
-
discountway: _deprecatedDiscountway,
|
|
720
|
-
product_discount_reason: _deprecatedProductDiscountReason,
|
|
721
|
-
discount_per: _deprecatedDiscountPer,
|
|
722
324
|
...productRest
|
|
723
325
|
} = submitProduct;
|
|
724
|
-
delete productRest[`product_${"option"}_item`];
|
|
725
326
|
const rawMetadata = submitProduct.metadata || {};
|
|
726
327
|
const bookingUid = rawMetadata.booking_uid;
|
|
727
328
|
const cleanMetadata = {};
|
|
@@ -731,9 +332,6 @@ function normalizeSubmitProduct(product) {
|
|
|
731
332
|
const priceMetaKeys = [
|
|
732
333
|
"main_product_original_price",
|
|
733
334
|
"main_product_selling_price",
|
|
734
|
-
"main_product_attached_bundle_selling_price",
|
|
735
|
-
"main_product_attached_bundle_payment_price",
|
|
736
|
-
"average_discount_amount_rate",
|
|
737
335
|
"source_product_price",
|
|
738
336
|
"main_product_attached_bundle_surcharge_fee",
|
|
739
337
|
"main_product_attached_bundle_tax_fee",
|
|
@@ -758,19 +356,21 @@ function normalizeSubmitProduct(product) {
|
|
|
758
356
|
}
|
|
759
357
|
const productSku = {
|
|
760
358
|
...submitProduct.product_sku && typeof submitProduct.product_sku === "object" ? submitProduct.product_sku : {},
|
|
761
|
-
option: formatSubmitOptionItems(
|
|
359
|
+
option: formatSubmitOptionItems(
|
|
360
|
+
(productOptionItem == null ? void 0 : productOptionItem.length) ? productOptionItem : (_a = submitProduct.product_sku) == null ? void 0 : _a.option
|
|
361
|
+
)
|
|
762
362
|
};
|
|
763
363
|
return {
|
|
764
364
|
...productRest,
|
|
765
365
|
...bookingUid ? { booking_uid: bookingUid } : {},
|
|
766
366
|
product_quantity: toBundleNumber(num ?? submitProduct.product_quantity, 1),
|
|
767
367
|
product_sku: productSku,
|
|
768
|
-
discount_list:
|
|
368
|
+
discount_list: submitProduct.discount_list || [],
|
|
769
369
|
product_bundle: formatSubmitBundleItems(submitProduct.product_bundle),
|
|
770
370
|
metadata: cleanMetadata,
|
|
771
|
-
// 出站兼容:后端消费 payment_price
|
|
772
|
-
//
|
|
773
|
-
payment_price: submitProduct.
|
|
371
|
+
// 出站兼容:后端消费 payment_price 字段,这里从 selling_price 直接派生。
|
|
372
|
+
// 新语义下 selling_price 是 composite(含 option/bundle),payment_price 同语义。
|
|
373
|
+
payment_price: submitProduct.selling_price
|
|
774
374
|
};
|
|
775
375
|
}
|
|
776
376
|
var SUBMIT_BOOKING_METADATA_WHITELIST = [
|
|
@@ -778,8 +378,7 @@ var SUBMIT_BOOKING_METADATA_WHITELIST = [
|
|
|
778
378
|
"collect_pax",
|
|
779
379
|
"capacity",
|
|
780
380
|
"holder_id",
|
|
781
|
-
"resource_select_type"
|
|
782
|
-
"holder"
|
|
381
|
+
"resource_select_type"
|
|
783
382
|
];
|
|
784
383
|
function normalizeBookingIsAll(booking) {
|
|
785
384
|
return booking.is_all === true || booking.is_all === 1 || booking.is_all === "1" || booking.is_all === "true" ? 1 : 0;
|
|
@@ -826,23 +425,22 @@ function createDefaultTempOrder(params) {
|
|
|
826
425
|
return {
|
|
827
426
|
order_id: null,
|
|
828
427
|
external_sale_number: "",
|
|
829
|
-
order_number:
|
|
830
|
-
shop_order_number:
|
|
831
|
-
shop_full_order_number:
|
|
832
|
-
type: "",
|
|
833
|
-
business_code:
|
|
428
|
+
order_number: "",
|
|
429
|
+
shop_order_number: "",
|
|
430
|
+
shop_full_order_number: "",
|
|
431
|
+
type: "appointment_booking",
|
|
432
|
+
business_code: "appointment_booking",
|
|
834
433
|
platform: "h5",
|
|
835
434
|
sales_channel: "my_pisel",
|
|
836
435
|
order_sales_channel: "online_store",
|
|
837
436
|
status: "normal",
|
|
838
437
|
payment_status: "payment_processing",
|
|
839
438
|
shipping_status: "unfulfilled",
|
|
840
|
-
customer_id:
|
|
439
|
+
customer_id: null,
|
|
841
440
|
customer_name: "",
|
|
842
441
|
country_calling_code: "",
|
|
843
442
|
phone: "",
|
|
844
443
|
email: "",
|
|
845
|
-
customer: null,
|
|
846
444
|
is_price_include_tax: 1,
|
|
847
445
|
tax_title: "",
|
|
848
446
|
tax_country_code: "",
|
|
@@ -855,13 +453,14 @@ function createDefaultTempOrder(params) {
|
|
|
855
453
|
surcharge_fee: "0.00",
|
|
856
454
|
note: "",
|
|
857
455
|
schedule_date: params.now,
|
|
858
|
-
created_at:
|
|
456
|
+
created_at: params.now,
|
|
859
457
|
request_unique_idempotency_token: "",
|
|
860
458
|
vouchers: [],
|
|
861
459
|
products: [],
|
|
862
460
|
bookings: [],
|
|
863
461
|
payments: [],
|
|
864
462
|
surcharges: [],
|
|
463
|
+
discount_list: [],
|
|
865
464
|
relation_forms: [],
|
|
866
465
|
contacts: [],
|
|
867
466
|
contacts_info: null,
|
|
@@ -873,7 +472,6 @@ function createDefaultTempOrder(params) {
|
|
|
873
472
|
};
|
|
874
473
|
}
|
|
875
474
|
function buildSubmitPayload(params) {
|
|
876
|
-
var _a;
|
|
877
475
|
const {
|
|
878
476
|
tempOrder,
|
|
879
477
|
cacheId,
|
|
@@ -882,7 +480,6 @@ function buildSubmitPayload(params) {
|
|
|
882
480
|
businessCode,
|
|
883
481
|
channel,
|
|
884
482
|
type,
|
|
885
|
-
summary,
|
|
886
483
|
enhance
|
|
887
484
|
} = params;
|
|
888
485
|
const scheduleDate = tempOrder.schedule_date || tempOrder.created_at || formatDateTime(now);
|
|
@@ -900,7 +497,7 @@ function buildSubmitPayload(params) {
|
|
|
900
497
|
shop_service_type: _shopServiceType,
|
|
901
498
|
start_time: _startTime,
|
|
902
499
|
customer: _customer,
|
|
903
|
-
|
|
500
|
+
shop_full_order_number: _shopFullOrderNumber,
|
|
904
501
|
tax_fee: _rootTaxFee,
|
|
905
502
|
total_amount: _totalAmount,
|
|
906
503
|
total_refund_amount: _totalRefundAmount,
|
|
@@ -908,25 +505,12 @@ function buildSubmitPayload(params) {
|
|
|
908
505
|
holder_id: _holderId,
|
|
909
506
|
...tempOrderRest
|
|
910
507
|
} = tempOrder;
|
|
911
|
-
let submitType = type ?? tempOrder.type;
|
|
912
|
-
if (!submitType) {
|
|
913
|
-
if ((_a = tempOrder == null ? void 0 : tempOrder.bookings) == null ? void 0 : _a.length) {
|
|
914
|
-
submitType = "appointment_booking";
|
|
915
|
-
} else {
|
|
916
|
-
submitType = "virtual";
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
508
|
const payload = {
|
|
920
509
|
...tempOrderRest,
|
|
921
|
-
customer_id: tempOrder.customer_id ?? 1,
|
|
922
|
-
customer_name: tempOrder.customer_name || "Walk-In",
|
|
923
|
-
order_number: tempOrder.order_number ?? null,
|
|
924
|
-
shop_order_number: tempOrder.shop_order_number ?? null,
|
|
925
|
-
shop_full_order_number: tempOrder.shop_full_order_number ?? null,
|
|
926
510
|
platform: normalizeSubmitPlatform(platform),
|
|
927
|
-
request_unique_idempotency_token:
|
|
928
|
-
type:
|
|
929
|
-
business_code: businessCode ?? tempOrder.business_code,
|
|
511
|
+
request_unique_idempotency_token: tempOrder.request_unique_idempotency_token || `${tempOrder.external_sale_number}_${now.getTime()}`,
|
|
512
|
+
type: type ?? tempOrder.type ?? "table-order",
|
|
513
|
+
business_code: businessCode ?? tempOrder.business_code ?? "table-order",
|
|
930
514
|
sales_channel: tempOrder.sales_channel || "my_pisel",
|
|
931
515
|
order_sales_channel: channel ?? tempOrder.order_sales_channel ?? "online_store",
|
|
932
516
|
status: tempOrder.status || "normal",
|
|
@@ -941,16 +525,17 @@ function buildSubmitPayload(params) {
|
|
|
941
525
|
note: tempOrder.note || "",
|
|
942
526
|
delivery_type: tempOrder.delivery_type || "nil",
|
|
943
527
|
schedule_date: scheduleDate,
|
|
944
|
-
|
|
528
|
+
created_at: tempOrder.created_at || formatDateTime(now),
|
|
945
529
|
bookings: (tempOrder.bookings || []).filter(
|
|
946
|
-
(booking) => Number(booking.parent_id) !== 0
|
|
530
|
+
(booking) => Number(booking.parent_id ?? 0) !== 0
|
|
947
531
|
).map((booking) => normalizeSubmitBooking(booking)),
|
|
948
532
|
payments: tempOrder.payments || [],
|
|
533
|
+
// discount_list: tempOrder.discount_list || [],
|
|
949
534
|
relation_forms: tempOrder.relation_forms || [],
|
|
950
535
|
// contacts: tempOrder.contacts || [],
|
|
951
536
|
contacts_info: tempOrder.contacts_info && !Array.isArray(tempOrder.contacts_info) ? tempOrder.contacts_info : null,
|
|
952
537
|
// holder: tempOrder.holder || null,
|
|
953
|
-
|
|
538
|
+
// summary,
|
|
954
539
|
metadata: (() => {
|
|
955
540
|
const {
|
|
956
541
|
collect_pax: _collectPax,
|
|
@@ -963,13 +548,7 @@ function buildSubmitPayload(params) {
|
|
|
963
548
|
(product) => normalizeSubmitProduct(product)
|
|
964
549
|
)
|
|
965
550
|
};
|
|
966
|
-
|
|
967
|
-
return payload;
|
|
968
|
-
const enhancedPayload = enhance(payload, { tempOrder, bookingUuid, now });
|
|
969
|
-
return {
|
|
970
|
-
...enhancedPayload,
|
|
971
|
-
summary: enhancedPayload.summary ?? payload.summary
|
|
972
|
-
};
|
|
551
|
+
return enhance ? enhance(payload, { tempOrder, bookingUuid, now }) : payload;
|
|
973
552
|
}
|
|
974
553
|
function mapPaymentItemToOrderPayment(paymentItem) {
|
|
975
554
|
const item = paymentItem;
|
|
@@ -989,11 +568,7 @@ function mapPaymentItemToOrderPayment(paymentItem) {
|
|
|
989
568
|
metadata[key] = item[key];
|
|
990
569
|
}
|
|
991
570
|
}
|
|
992
|
-
const timestamp = (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
|
|
993
|
-
const paymentTime = item.payment_time ?? timestamp;
|
|
994
|
-
const createdAt = item.created_at ?? timestamp;
|
|
995
571
|
return {
|
|
996
|
-
...item.order_payment_id !== void 0 ? { order_payment_id: item.order_payment_id } : {},
|
|
997
572
|
amount: String(item.amount ?? "0.00"),
|
|
998
573
|
code: String(item.code || ""),
|
|
999
574
|
custom_payment_id: Number(customPaymentId ?? 0),
|
|
@@ -1003,15 +578,14 @@ function mapPaymentItemToOrderPayment(paymentItem) {
|
|
|
1003
578
|
...item.origin_amount !== void 0 ? { origin_amount: String(item.origin_amount) } : {},
|
|
1004
579
|
...item.service_fee !== void 0 ? { service_fee: String(item.service_fee) } : {},
|
|
1005
580
|
...item.status !== void 0 ? { status: item.status } : {},
|
|
1006
|
-
payment_time:
|
|
1007
|
-
created_at: createdAt,
|
|
581
|
+
...item.payment_time !== void 0 ? { payment_time: item.payment_time } : {},
|
|
1008
582
|
...item.wallet_pass_usage_unit !== void 0 ? { wallet_pass_usage_unit: item.wallet_pass_usage_unit } : {},
|
|
1009
583
|
...item.wallet_pass_use_value !== void 0 ? { wallet_pass_use_value: item.wallet_pass_use_value } : {},
|
|
1010
|
-
...item.fund_record && typeof item.fund_record === "object" && !Array.isArray(item.fund_record) ? { fund_record: { ...item.fund_record } } : {},
|
|
1011
584
|
metadata,
|
|
1012
585
|
...item.rounding_amount !== void 0 ? { rounding_amount: String(item.rounding_amount) } : {},
|
|
1013
586
|
...item.service_charge !== void 0 ? { service_charge: item.service_charge } : {},
|
|
1014
587
|
...item.order_payment_type !== void 0 ? { order_payment_type: item.order_payment_type } : {},
|
|
588
|
+
...item.created_at !== void 0 ? { created_at: item.created_at } : {},
|
|
1015
589
|
...item.updated_at !== void 0 ? { updated_at: item.updated_at } : {}
|
|
1016
590
|
};
|
|
1017
591
|
}
|
|
@@ -1037,168 +611,26 @@ function formatV1Product(products) {
|
|
|
1037
611
|
};
|
|
1038
612
|
});
|
|
1039
613
|
}
|
|
1040
|
-
function hasAssignedHolderId(value) {
|
|
1041
|
-
if (value === void 0 || value === null || value === "")
|
|
1042
|
-
return false;
|
|
1043
|
-
if (Array.isArray(value))
|
|
1044
|
-
return value.length > 0;
|
|
1045
|
-
return true;
|
|
1046
|
-
}
|
|
1047
|
-
function clearTempOrderHolderAssignments(tempOrder) {
|
|
1048
|
-
var _a;
|
|
1049
|
-
let changed = false;
|
|
1050
|
-
const resetHolderField = (target, key = "holder_id") => {
|
|
1051
|
-
if (!hasAssignedHolderId(target[key]))
|
|
1052
|
-
return;
|
|
1053
|
-
target[key] = null;
|
|
1054
|
-
changed = true;
|
|
1055
|
-
};
|
|
1056
|
-
for (const product of tempOrder.products || []) {
|
|
1057
|
-
if (product.metadata && typeof product.metadata === "object") {
|
|
1058
|
-
resetHolderField(product.metadata);
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
for (const booking of tempOrder.bookings || []) {
|
|
1062
|
-
const bookingRecord = booking;
|
|
1063
|
-
if (booking.metadata && typeof booking.metadata === "object") {
|
|
1064
|
-
resetHolderField(booking.metadata);
|
|
1065
|
-
}
|
|
1066
|
-
if (bookingRecord.holder !== void 0 && bookingRecord.holder !== null) {
|
|
1067
|
-
delete bookingRecord.holder;
|
|
1068
|
-
changed = true;
|
|
1069
|
-
}
|
|
1070
|
-
}
|
|
1071
|
-
const productsByUid = (_a = tempOrder._extend) == null ? void 0 : _a.productsByUid;
|
|
1072
|
-
if (productsByUid && typeof productsByUid === "object") {
|
|
1073
|
-
for (const entry of Object.values(productsByUid)) {
|
|
1074
|
-
const origin = entry == null ? void 0 : entry.origin;
|
|
1075
|
-
if (!origin || typeof origin !== "object")
|
|
1076
|
-
continue;
|
|
1077
|
-
if (origin.metadata && typeof origin.metadata === "object") {
|
|
1078
|
-
resetHolderField(origin.metadata);
|
|
1079
|
-
}
|
|
1080
|
-
if (origin._extend && typeof origin._extend === "object") {
|
|
1081
|
-
resetHolderField(origin._extend);
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
return changed;
|
|
1086
|
-
}
|
|
1087
|
-
function getOrderProductLineUid(product) {
|
|
1088
|
-
var _a;
|
|
1089
|
-
if (!product || typeof product !== "object")
|
|
1090
|
-
return null;
|
|
1091
|
-
const uid = ((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) ?? product.unique_identification_number;
|
|
1092
|
-
if (uid === void 0 || uid === null || uid === "")
|
|
1093
|
-
return null;
|
|
1094
|
-
return String(uid);
|
|
1095
|
-
}
|
|
1096
|
-
function isEmptyOrderProductDisplayValue(value) {
|
|
1097
|
-
if (value === void 0 || value === null)
|
|
1098
|
-
return true;
|
|
1099
|
-
if (typeof value === "string")
|
|
1100
|
-
return value.trim() === "";
|
|
1101
|
-
if (typeof value === "object") {
|
|
1102
|
-
const record = value;
|
|
1103
|
-
return !Object.values(record).some(
|
|
1104
|
-
(item) => typeof item === "string" && item.trim() !== ""
|
|
1105
|
-
);
|
|
1106
|
-
}
|
|
1107
|
-
return false;
|
|
1108
|
-
}
|
|
1109
|
-
function mergeOrderProductDisplayFields(previous, next) {
|
|
1110
|
-
const merged = { ...next };
|
|
1111
|
-
const displayFields = [
|
|
1112
|
-
"product_title",
|
|
1113
|
-
"product_name",
|
|
1114
|
-
"product_cover",
|
|
1115
|
-
"cover",
|
|
1116
|
-
"variant_title",
|
|
1117
|
-
"product_sku",
|
|
1118
|
-
"payment_price"
|
|
1119
|
-
];
|
|
1120
|
-
displayFields.forEach((field) => {
|
|
1121
|
-
if (isEmptyOrderProductDisplayValue(merged[field]) && !isEmptyOrderProductDisplayValue(previous[field])) {
|
|
1122
|
-
merged[field] = previous[field];
|
|
1123
|
-
}
|
|
1124
|
-
});
|
|
1125
|
-
if (previous.metadata || next.metadata) {
|
|
1126
|
-
merged.metadata = {
|
|
1127
|
-
...previous.metadata || {},
|
|
1128
|
-
...next.metadata || {}
|
|
1129
|
-
};
|
|
1130
|
-
["product_title", "product_name"].forEach((field) => {
|
|
1131
|
-
var _a;
|
|
1132
|
-
if (isEmptyOrderProductDisplayValue(merged.metadata[field]) && !isEmptyOrderProductDisplayValue((_a = previous.metadata) == null ? void 0 : _a[field])) {
|
|
1133
|
-
merged.metadata[field] = previous.metadata[field];
|
|
1134
|
-
}
|
|
1135
|
-
});
|
|
1136
|
-
}
|
|
1137
|
-
if (previous._extend && !merged._extend) {
|
|
1138
|
-
merged._extend = previous._extend;
|
|
1139
|
-
}
|
|
1140
|
-
return merged;
|
|
1141
|
-
}
|
|
1142
|
-
function indexOrderProductsByUid(products) {
|
|
1143
|
-
const map = /* @__PURE__ */ new Map();
|
|
1144
|
-
(products || []).forEach((product, index) => {
|
|
1145
|
-
const uid = getOrderProductLineUid(product);
|
|
1146
|
-
if (uid) {
|
|
1147
|
-
map.set(uid, product);
|
|
1148
|
-
return;
|
|
1149
|
-
}
|
|
1150
|
-
map.set(`__index__:${index}`, product);
|
|
1151
|
-
});
|
|
1152
|
-
return map;
|
|
1153
|
-
}
|
|
1154
614
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1155
615
|
0 && (module.exports = {
|
|
1156
|
-
buildManualProductDiscountItem,
|
|
1157
616
|
buildSubmitPayload,
|
|
1158
|
-
calculateOrderProductsDeposit,
|
|
1159
|
-
clearTempOrderHolderAssignments,
|
|
1160
617
|
composeLinePrice,
|
|
1161
618
|
createDefaultOrderRulesHooks,
|
|
1162
619
|
createDefaultTempOrder,
|
|
1163
620
|
createEmptySummary,
|
|
1164
621
|
createUuidV4,
|
|
1165
|
-
ensureManualProductDiscountList,
|
|
1166
|
-
ensureProductSku,
|
|
1167
|
-
findManualProductDiscountItem,
|
|
1168
622
|
formatDateTime,
|
|
1169
623
|
formatV1Product,
|
|
1170
624
|
generateDuration,
|
|
1171
625
|
getAllDiscountList,
|
|
1172
|
-
getBundleSellingMagnitude,
|
|
1173
|
-
getBundleSignedUnit,
|
|
1174
|
-
getOrderProductLineUid,
|
|
1175
|
-
getProductSkuOptions,
|
|
1176
|
-
hasAssignedHolderId,
|
|
1177
|
-
indexOrderProductsByUid,
|
|
1178
|
-
isEmptyOrderProductDisplayValue,
|
|
1179
|
-
isMarkdownBundle,
|
|
1180
626
|
isTempOrder,
|
|
1181
627
|
mapPaymentItemToOrderPayment,
|
|
1182
628
|
mapPaymentItemsToOrderPayments,
|
|
1183
|
-
mergeManualProductDiscountIntoList,
|
|
1184
|
-
mergeOrderProductDisplayFields,
|
|
1185
629
|
mergeRelationForms,
|
|
1186
630
|
normalizeBookingIsAll,
|
|
1187
631
|
normalizeBookingSubType,
|
|
1188
|
-
normalizeOrderProductDiscountList,
|
|
1189
|
-
normalizeProductSkuOptions,
|
|
1190
632
|
normalizeSubmitBooking,
|
|
1191
633
|
normalizeSubmitCollectPaxValue,
|
|
1192
|
-
resolveEffectivePerUnitDiscount,
|
|
1193
|
-
resolveManualDiscountMessage,
|
|
1194
|
-
resolveManualDiscountOriginTotal,
|
|
1195
|
-
resolveManualDiscountReasonFromSources,
|
|
1196
|
-
resolveManualOverrideLineOriginalPrice,
|
|
1197
|
-
resolveRulesManualDiscountFlag,
|
|
1198
|
-
resolveSafeProductNum,
|
|
1199
634
|
resolveSubmitCollectPax,
|
|
1200
|
-
|
|
1201
|
-
stripManualProductDiscountItems,
|
|
1202
|
-
sumOptionUnitPrice,
|
|
1203
|
-
syncManualProductDiscountProductNum
|
|
635
|
+
sumOptionUnitPrice
|
|
1204
636
|
});
|