@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
|
@@ -1,830 +0,0 @@
|
|
|
1
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
4
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
5
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
9
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
10
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
14
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
15
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
16
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
17
|
-
import dayjs from 'dayjs';
|
|
18
|
-
import Decimal from 'decimal.js';
|
|
19
|
-
var DEFAULT_LOCALES = ['en', 'zh_CN'];
|
|
20
|
-
var LABELS = {
|
|
21
|
-
en: {
|
|
22
|
-
contactName: 'Contact name',
|
|
23
|
-
contactMobile: 'Contact Mobile',
|
|
24
|
-
email: 'email',
|
|
25
|
-
dineIn: 'Dine-in',
|
|
26
|
-
takeAway: 'Take away',
|
|
27
|
-
delivery: 'Delivery',
|
|
28
|
-
pickUp: 'Pick-up',
|
|
29
|
-
shopService: 'Dine-in',
|
|
30
|
-
pickUpTime: 'Pick-up time',
|
|
31
|
-
asap: 'ASAP',
|
|
32
|
-
cash: 'Cash',
|
|
33
|
-
eftpos: 'Eftpos',
|
|
34
|
-
wallet: 'Wallet',
|
|
35
|
-
giftCard: 'Gift card',
|
|
36
|
-
remainingAmount: 'Remaining amount',
|
|
37
|
-
redeemPoints: 'Redeem points',
|
|
38
|
-
remainingPoints: 'Remaining points',
|
|
39
|
-
table: 'Table',
|
|
40
|
-
orderDiscount: 'Order discount',
|
|
41
|
-
payProcessingFee: 'Pay processing fee',
|
|
42
|
-
rounding: 'Rounding'
|
|
43
|
-
},
|
|
44
|
-
zh_CN: {
|
|
45
|
-
contactName: '联系人姓名',
|
|
46
|
-
contactMobile: '联系电话',
|
|
47
|
-
email: '邮箱',
|
|
48
|
-
dineIn: '堂食',
|
|
49
|
-
takeAway: '外带',
|
|
50
|
-
delivery: '配送',
|
|
51
|
-
pickUp: '自提',
|
|
52
|
-
shopService: '堂食',
|
|
53
|
-
pickUpTime: '取餐时间',
|
|
54
|
-
asap: '尽快',
|
|
55
|
-
cash: '现金支付',
|
|
56
|
-
eftpos: '刷卡支付',
|
|
57
|
-
wallet: '钱包支付',
|
|
58
|
-
giftCard: '礼品卡',
|
|
59
|
-
remainingAmount: '剩余金额',
|
|
60
|
-
redeemPoints: '本次使用积分',
|
|
61
|
-
remainingPoints: '剩余积分',
|
|
62
|
-
table: '桌台',
|
|
63
|
-
orderDiscount: '整单折扣',
|
|
64
|
-
payProcessingFee: '支付手续费',
|
|
65
|
-
rounding: '抹零'
|
|
66
|
-
},
|
|
67
|
-
zh_HK: {
|
|
68
|
-
contactName: '聯絡人姓名',
|
|
69
|
-
contactMobile: '聯絡電話',
|
|
70
|
-
email: '電郵',
|
|
71
|
-
dineIn: '堂食',
|
|
72
|
-
takeAway: '外帶',
|
|
73
|
-
delivery: '配送',
|
|
74
|
-
pickUp: '自取',
|
|
75
|
-
shopService: '堂食',
|
|
76
|
-
pickUpTime: '取餐時間',
|
|
77
|
-
asap: '盡快',
|
|
78
|
-
cash: '現金支付',
|
|
79
|
-
eftpos: '刷卡支付',
|
|
80
|
-
wallet: '錢包支付',
|
|
81
|
-
giftCard: '禮品卡',
|
|
82
|
-
remainingAmount: '剩餘金額',
|
|
83
|
-
redeemPoints: '本次使用積分',
|
|
84
|
-
remainingPoints: '剩餘積分',
|
|
85
|
-
table: '桌台',
|
|
86
|
-
orderDiscount: '整單折扣',
|
|
87
|
-
payProcessingFee: '支付手續費',
|
|
88
|
-
rounding: '抹零'
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
export function buildSmallTicketData(params) {
|
|
92
|
-
var order = params.order || {};
|
|
93
|
-
var shopInfo = params.shopInfo || {};
|
|
94
|
-
var locales = resolveLocales(shopInfo, params.locales);
|
|
95
|
-
var productMap = params.productMap || {};
|
|
96
|
-
return locales.reduce(function (data, locale) {
|
|
97
|
-
data[locale] = buildLocaleData({
|
|
98
|
-
order: order,
|
|
99
|
-
shopInfo: shopInfo,
|
|
100
|
-
locale: locale,
|
|
101
|
-
productMap: productMap
|
|
102
|
-
});
|
|
103
|
-
return data;
|
|
104
|
-
}, {});
|
|
105
|
-
}
|
|
106
|
-
export function hasSmallTicketData(value) {
|
|
107
|
-
return !!value && _typeof(value) === 'object' && Object.keys(value).length > 0;
|
|
108
|
-
}
|
|
109
|
-
function buildLocaleData(params) {
|
|
110
|
-
var order = params.order,
|
|
111
|
-
shopInfo = params.shopInfo,
|
|
112
|
-
locale = params.locale,
|
|
113
|
-
productMap = params.productMap;
|
|
114
|
-
var products = buildProducts(order, locale, productMap);
|
|
115
|
-
var summary = getSummary(order);
|
|
116
|
-
var currencySymbol = getCurrencySymbol(order, shopInfo);
|
|
117
|
-
return {
|
|
118
|
-
base_data: buildBaseData({
|
|
119
|
-
order: order,
|
|
120
|
-
shopInfo: shopInfo,
|
|
121
|
-
locale: locale
|
|
122
|
-
}),
|
|
123
|
-
products: products,
|
|
124
|
-
fees: buildFees({
|
|
125
|
-
order: order,
|
|
126
|
-
shopInfo: shopInfo,
|
|
127
|
-
locale: locale,
|
|
128
|
-
products: products,
|
|
129
|
-
summary: summary,
|
|
130
|
-
currencySymbol: currencySymbol
|
|
131
|
-
}),
|
|
132
|
-
customer: buildCustomer(order, locale),
|
|
133
|
-
appointment: buildAppointment(order, locale),
|
|
134
|
-
// delivery: buildDelivery(order, locale),
|
|
135
|
-
resources: buildResources(order, locale),
|
|
136
|
-
payment_data: buildPaymentData({
|
|
137
|
-
order: order,
|
|
138
|
-
locale: locale,
|
|
139
|
-
currencySymbol: currencySymbol
|
|
140
|
-
}),
|
|
141
|
-
tickets: Array.isArray(order.tickets) ? order.tickets : [],
|
|
142
|
-
source_shop: [],
|
|
143
|
-
refund_data: [],
|
|
144
|
-
expend_data: []
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
function buildBaseData(params) {
|
|
148
|
-
var _order$metadata;
|
|
149
|
-
var order = params.order,
|
|
150
|
-
shopInfo = params.shopInfo,
|
|
151
|
-
locale = params.locale;
|
|
152
|
-
var orderNumber = stringify(order.buzzer || order.shop_full_order_number);
|
|
153
|
-
return {
|
|
154
|
-
shop_name: stringify(shopInfo.name || order.shop_name),
|
|
155
|
-
note: stringify(order.note),
|
|
156
|
-
shop_order_number: stringify(order.shop_order_number),
|
|
157
|
-
order_number: orderNumber,
|
|
158
|
-
shop_tax_number: stringify(shopInfo.tax_number || order.shop_tax_number),
|
|
159
|
-
shop_phone: stringify(shopInfo.phone || order.shop_phone),
|
|
160
|
-
shop_address: stringify(shopInfo.address || buildShopAddress(shopInfo) || order.shop_address),
|
|
161
|
-
original_payment_status: stringify(order.payment_status),
|
|
162
|
-
is_repeat: 0,
|
|
163
|
-
buzzer: stringify(order.buzzer || order.pickup_number || ((_order$metadata = order.metadata) === null || _order$metadata === void 0 ? void 0 : _order$metadata.buzzer)),
|
|
164
|
-
order_no: orderNumber,
|
|
165
|
-
order_time: formatDateTime(order.created_at || order.sales_time || new Date(), locale)
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
function buildProducts(order, locale, productMap) {
|
|
169
|
-
var products = Array.isArray(order.products) ? order.products : [];
|
|
170
|
-
return products.map(function (product) {
|
|
171
|
-
var _ref, _ref2, _product$product_quan, _ref3, _ref4, _ref5, _product$original_pri, _ref6, _ref7, _product$selling_pric, _product$product_id;
|
|
172
|
-
var quantity = toNumber((_ref = (_ref2 = (_product$product_quan = product.product_quantity) !== null && _product$product_quan !== void 0 ? _product$product_quan : product.quantity) !== null && _ref2 !== void 0 ? _ref2 : product.num) !== null && _ref !== void 0 ? _ref : 1, 1);
|
|
173
|
-
var originalPrice = (_ref3 = (_ref4 = (_ref5 = (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : product.selling_price) !== null && _ref5 !== void 0 ? _ref5 : product.payment_price) !== null && _ref4 !== void 0 ? _ref4 : product.price) !== null && _ref3 !== void 0 ? _ref3 : 0;
|
|
174
|
-
var sellingPrice = (_ref6 = (_ref7 = (_product$selling_pric = product.selling_price) !== null && _product$selling_pric !== void 0 ? _product$selling_pric : product.payment_price) !== null && _ref7 !== void 0 ? _ref7 : product.price) !== null && _ref6 !== void 0 ? _ref6 : originalPrice;
|
|
175
|
-
var productTitle = resolveProductTitle({
|
|
176
|
-
product: product,
|
|
177
|
-
productMap: productMap,
|
|
178
|
-
locale: locale
|
|
179
|
-
});
|
|
180
|
-
var parentProduct = resolveProductFromMap((_product$product_id = product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : product.id, productMap);
|
|
181
|
-
var currencySymbol = getCurrencySymbol(order, null);
|
|
182
|
-
var options = normalizeProductOptions({
|
|
183
|
-
product: product,
|
|
184
|
-
locale: locale,
|
|
185
|
-
currencySymbol: currencySymbol,
|
|
186
|
-
parentProduct: parentProduct
|
|
187
|
-
});
|
|
188
|
-
var combinations = normalizeProductCombinations({
|
|
189
|
-
product: product,
|
|
190
|
-
productMap: productMap,
|
|
191
|
-
locale: locale,
|
|
192
|
-
currencySymbol: currencySymbol,
|
|
193
|
-
parentProduct: parentProduct
|
|
194
|
-
});
|
|
195
|
-
var resolvedVariant = resolveProductVariantText({
|
|
196
|
-
product: product,
|
|
197
|
-
parentProduct: parentProduct,
|
|
198
|
-
locale: locale
|
|
199
|
-
});
|
|
200
|
-
return _objectSpread(_objectSpread(_objectSpread({
|
|
201
|
-
product_title: productTitle,
|
|
202
|
-
product_quantity: quantity,
|
|
203
|
-
selling_price: formatMoney(sellingPrice, currencySymbol),
|
|
204
|
-
original_price: formatMoney(originalPrice, currencySymbol),
|
|
205
|
-
total_original_price: formatMoney(new Decimal(toMoneyNumber(originalPrice)).mul(quantity), currencySymbol),
|
|
206
|
-
extension_list: Array.isArray(product.extension_list) ? product.extension_list : []
|
|
207
|
-
}, options.length ? {
|
|
208
|
-
options: options
|
|
209
|
-
} : {}), resolvedVariant ? {
|
|
210
|
-
variant: resolvedVariant
|
|
211
|
-
} : {}), Array.isArray(product.combinations) ? {
|
|
212
|
-
combinations: product.combinations
|
|
213
|
-
} : combinations.length ? {
|
|
214
|
-
combinations: combinations
|
|
215
|
-
} : {});
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
function resolveProductTitle(params) {
|
|
219
|
-
var _product$product_id2;
|
|
220
|
-
var product = params.product,
|
|
221
|
-
productMap = params.productMap,
|
|
222
|
-
locale = params.locale;
|
|
223
|
-
var ownTitle = getProductTitleSource(product, locale);
|
|
224
|
-
// if (ownTitle) return ownTitle;
|
|
225
|
-
|
|
226
|
-
var productId = (_product$product_id2 = product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : product.id;
|
|
227
|
-
var fallbackProduct = resolveProductFromMap(productId, productMap);
|
|
228
|
-
if (!fallbackProduct) return ownTitle || '';
|
|
229
|
-
return getProductTitleSource(fallbackProduct, locale);
|
|
230
|
-
}
|
|
231
|
-
function normalizeProductOptions(params) {
|
|
232
|
-
var _product$product_sku;
|
|
233
|
-
var product = params.product,
|
|
234
|
-
locale = params.locale,
|
|
235
|
-
currencySymbol = params.currencySymbol,
|
|
236
|
-
parentProduct = params.parentProduct;
|
|
237
|
-
var rawOptions = Array.isArray(params.options) ? params.options : Array.isArray(product.options) ? product.options : Array.isArray((_product$product_sku = product.product_sku) === null || _product$product_sku === void 0 ? void 0 : _product$product_sku.option) ? product.product_sku.option : [];
|
|
238
|
-
return rawOptions.map(function (option) {
|
|
239
|
-
var _ref8, _option$original_pric, _ref9, _option$value, _option$num;
|
|
240
|
-
var price = (_ref8 = (_option$original_pric = option.original_price) !== null && _option$original_pric !== void 0 ? _option$original_pric : option.add_price) !== null && _ref8 !== void 0 ? _ref8 : option.price;
|
|
241
|
-
var value = (_ref9 = (_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : option.option) !== null && _ref9 !== void 0 ? _ref9 : option.item;
|
|
242
|
-
var name = getProductTitleSource(option, locale) || resolveOptionTitleFromParentProduct({
|
|
243
|
-
option: option,
|
|
244
|
-
parentProduct: parentProduct,
|
|
245
|
-
locale: locale
|
|
246
|
-
});
|
|
247
|
-
return _objectSpread(_objectSpread(_objectSpread({
|
|
248
|
-
name: name
|
|
249
|
-
}, option.num !== undefined || option.quantity !== undefined ? {
|
|
250
|
-
num: toNumber((_option$num = option.num) !== null && _option$num !== void 0 ? _option$num : option.quantity, 1)
|
|
251
|
-
} : {}), price !== undefined && price !== null && price !== '' ? {
|
|
252
|
-
price: formatMoney(price, currencySymbol)
|
|
253
|
-
} : {}), value !== undefined && value !== null && value !== '' ? {
|
|
254
|
-
value: getLocalizedValue(value, locale)
|
|
255
|
-
} : {});
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
function normalizeProductCombinations(params) {
|
|
259
|
-
var product = params.product,
|
|
260
|
-
productMap = params.productMap,
|
|
261
|
-
locale = params.locale,
|
|
262
|
-
currencySymbol = params.currencySymbol,
|
|
263
|
-
parentProduct = params.parentProduct;
|
|
264
|
-
var bundles = Array.isArray(product.product_bundle) ? product.product_bundle : [];
|
|
265
|
-
return bundles.map(function (bundle) {
|
|
266
|
-
var _ref10, _bundle$num;
|
|
267
|
-
var combinationsOptions = normalizeProductOptions({
|
|
268
|
-
product: {},
|
|
269
|
-
locale: locale,
|
|
270
|
-
currencySymbol: currencySymbol,
|
|
271
|
-
options: Array.isArray(bundle.option) ? bundle.option : [],
|
|
272
|
-
parentProduct: parentProduct
|
|
273
|
-
});
|
|
274
|
-
var baseTitle = resolveBundleProductTitle({
|
|
275
|
-
bundle: bundle,
|
|
276
|
-
productMap: productMap,
|
|
277
|
-
locale: locale,
|
|
278
|
-
parentProduct: parentProduct
|
|
279
|
-
});
|
|
280
|
-
var optionTitle = buildOptionTitleSuffix(combinationsOptions);
|
|
281
|
-
return {
|
|
282
|
-
product_title: "".concat(baseTitle).concat(optionTitle),
|
|
283
|
-
product_quantity: toNumber((_ref10 = (_bundle$num = bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle.quantity) !== null && _ref10 !== void 0 ? _ref10 : 1, 1),
|
|
284
|
-
price: formatBundlePrice(bundle, currencySymbol),
|
|
285
|
-
combinations_options: combinationsOptions
|
|
286
|
-
};
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
function resolveBundleProductTitle(params) {
|
|
290
|
-
var _ref11, _ref12, _bundle$bundle_produc;
|
|
291
|
-
var bundle = params.bundle,
|
|
292
|
-
productMap = params.productMap,
|
|
293
|
-
locale = params.locale,
|
|
294
|
-
parentProduct = params.parentProduct;
|
|
295
|
-
var ownTitle = getProductTitleSource(bundle, locale);
|
|
296
|
-
if (ownTitle) return ownTitle;
|
|
297
|
-
var parentBundleItem = resolveBundleItemFromParentProduct({
|
|
298
|
-
bundle: bundle,
|
|
299
|
-
parentProduct: parentProduct
|
|
300
|
-
});
|
|
301
|
-
var parentBundleTitle = parentBundleItem ? getProductTitleSource(parentBundleItem, locale) : '';
|
|
302
|
-
if (parentBundleTitle) return parentBundleTitle;
|
|
303
|
-
var productId = (_ref11 = (_ref12 = (_bundle$bundle_produc = bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle._bundle_product_id) !== null && _ref12 !== void 0 ? _ref12 : bundle.product_id) !== null && _ref11 !== void 0 ? _ref11 : bundle.id;
|
|
304
|
-
var fallbackProduct = resolveProductFromMap(productId, productMap);
|
|
305
|
-
if (!fallbackProduct) return '';
|
|
306
|
-
return getProductTitleSource(fallbackProduct, locale);
|
|
307
|
-
}
|
|
308
|
-
function resolveProductFromMap(productId, productMap) {
|
|
309
|
-
if (productId === undefined || productId === null || productId === '') return null;
|
|
310
|
-
return productMap[productId] || productMap[String(productId)] || null;
|
|
311
|
-
}
|
|
312
|
-
function resolveProductVariantText(params) {
|
|
313
|
-
var _product$product_vari;
|
|
314
|
-
var product = params.product,
|
|
315
|
-
parentProduct = params.parentProduct,
|
|
316
|
-
locale = params.locale;
|
|
317
|
-
if (product.variant) return getLocalizedValue(product.variant, locale);
|
|
318
|
-
if (!parentProduct) return '';
|
|
319
|
-
var productVariantId = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : product.variant_id;
|
|
320
|
-
if (!isNonZeroId(productVariantId)) return '';
|
|
321
|
-
var matchedVariant = normalizeArray(parentProduct.variant).find(function (variant) {
|
|
322
|
-
return isSameId(variant.id, productVariantId);
|
|
323
|
-
});
|
|
324
|
-
if (!matchedVariant) return '';
|
|
325
|
-
var resolvedFromSkuKey = resolveVariantTextFromSkuKey({
|
|
326
|
-
skuKey: matchedVariant.sku_key,
|
|
327
|
-
parentProduct: parentProduct,
|
|
328
|
-
locale: locale
|
|
329
|
-
});
|
|
330
|
-
if (resolvedFromSkuKey) return resolvedFromSkuKey;
|
|
331
|
-
return resolveVariantTextFromNameMap({
|
|
332
|
-
nameMap: matchedVariant.name || matchedVariant.title,
|
|
333
|
-
parentProduct: parentProduct,
|
|
334
|
-
locale: locale
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
function resolveVariantTextFromSkuKey(params) {
|
|
338
|
-
var skuKey = stringify(params.skuKey);
|
|
339
|
-
if (!skuKey) return '';
|
|
340
|
-
return skuKey.split('_').map(function (item) {
|
|
341
|
-
var _item$split = item.split(':'),
|
|
342
|
-
_item$split2 = _slicedToArray(_item$split, 2),
|
|
343
|
-
groupPositionId = _item$split2[0],
|
|
344
|
-
itemPositionId = _item$split2[1];
|
|
345
|
-
return resolveVariantTextItem({
|
|
346
|
-
parentProduct: params.parentProduct,
|
|
347
|
-
groupPositionId: groupPositionId,
|
|
348
|
-
itemPositionId: itemPositionId,
|
|
349
|
-
locale: params.locale
|
|
350
|
-
});
|
|
351
|
-
}).filter(Boolean).join(',');
|
|
352
|
-
}
|
|
353
|
-
function resolveVariantTextFromNameMap(params) {
|
|
354
|
-
if (!params.nameMap || _typeof(params.nameMap) !== 'object') return '';
|
|
355
|
-
return Object.entries(params.nameMap).map(function (_ref13) {
|
|
356
|
-
var _ref14 = _slicedToArray(_ref13, 2),
|
|
357
|
-
groupPositionId = _ref14[0],
|
|
358
|
-
value = _ref14[1];
|
|
359
|
-
var group = resolveVariantGroup(params.parentProduct, groupPositionId);
|
|
360
|
-
if (!group) return '';
|
|
361
|
-
var groupName = getLocalizedValue(group.name, params.locale);
|
|
362
|
-
var itemName = getLocalizedValue(value, params.locale);
|
|
363
|
-
if (!groupName || !itemName) return '';
|
|
364
|
-
return "".concat(groupName, ":").concat(itemName);
|
|
365
|
-
}).filter(Boolean).join(',');
|
|
366
|
-
}
|
|
367
|
-
function resolveVariantTextItem(params) {
|
|
368
|
-
var group = resolveVariantGroup(params.parentProduct, params.groupPositionId);
|
|
369
|
-
var item = resolveVariantItem(group, params.itemPositionId);
|
|
370
|
-
if (!group || !item) return '';
|
|
371
|
-
var groupName = getLocalizedValue(group.name, params.locale);
|
|
372
|
-
var itemName = getLocalizedValue(item.name, params.locale);
|
|
373
|
-
if (!groupName || !itemName) return '';
|
|
374
|
-
return "".concat(groupName, ":").concat(itemName);
|
|
375
|
-
}
|
|
376
|
-
function resolveVariantGroup(parentProduct, groupPositionId) {
|
|
377
|
-
return normalizeArray(parentProduct.variant_group).find(function (group) {
|
|
378
|
-
return isSameId(group.position_id, groupPositionId) || isSameId(group.id, groupPositionId);
|
|
379
|
-
}) || null;
|
|
380
|
-
}
|
|
381
|
-
function resolveVariantItem(group, itemPositionId) {
|
|
382
|
-
if (!group) return null;
|
|
383
|
-
return normalizeArray(group.variant_item).find(function (item) {
|
|
384
|
-
return isSameId(item.position_id, itemPositionId) || isSameId(item.id, itemPositionId);
|
|
385
|
-
}) || null;
|
|
386
|
-
}
|
|
387
|
-
function getProductTitleSource(source, locale) {
|
|
388
|
-
if (!source || _typeof(source) !== 'object') return '';
|
|
389
|
-
return resolveTitleValue(source.product_title, locale) || resolveTitleValue(source.title, locale) || resolveTitleValue(source.name, locale);
|
|
390
|
-
}
|
|
391
|
-
function resolveTitleValue(value, locale) {
|
|
392
|
-
var _ref15, _ref16, _value$locale;
|
|
393
|
-
if (value === undefined || value === null) return '';
|
|
394
|
-
if (_typeof(value) !== 'object') return stringify(value);
|
|
395
|
-
var dashedLocale = locale.replace('_', '-');
|
|
396
|
-
var underscoredLocale = locale.replace('-', '_');
|
|
397
|
-
return stringify((_ref15 = (_ref16 = (_value$locale = value[locale]) !== null && _value$locale !== void 0 ? _value$locale : value[dashedLocale]) !== null && _ref16 !== void 0 ? _ref16 : value[underscoredLocale]) !== null && _ref15 !== void 0 ? _ref15 : '');
|
|
398
|
-
}
|
|
399
|
-
function resolveOptionTitleFromParentProduct(params) {
|
|
400
|
-
var option = params.option,
|
|
401
|
-
parentProduct = params.parentProduct,
|
|
402
|
-
locale = params.locale;
|
|
403
|
-
if (!parentProduct) return '';
|
|
404
|
-
var optionItems = flattenOptionItems(parentProduct);
|
|
405
|
-
var matchedOption = optionItems.find(function (item) {
|
|
406
|
-
return isOptionItemMatch(option, item);
|
|
407
|
-
});
|
|
408
|
-
return getProductTitleSource(matchedOption, locale);
|
|
409
|
-
}
|
|
410
|
-
function flattenOptionItems(parentProduct) {
|
|
411
|
-
var optionGroups = Array.isArray(parentProduct.option_group) ? parentProduct.option_group : [];
|
|
412
|
-
return optionGroups.flatMap(function (group) {
|
|
413
|
-
var items = normalizeArray(group.option_item || group.option_items || group.option || group.options || group.items || group.children || group.product_option_item);
|
|
414
|
-
return items.map(function (item) {
|
|
415
|
-
var _ref17, _item$option_group_id;
|
|
416
|
-
return _objectSpread(_objectSpread({}, item), {}, {
|
|
417
|
-
option_group_id: (_ref17 = (_item$option_group_id = item.option_group_id) !== null && _item$option_group_id !== void 0 ? _item$option_group_id : group.id) !== null && _ref17 !== void 0 ? _ref17 : group.option_group_id
|
|
418
|
-
});
|
|
419
|
-
});
|
|
420
|
-
});
|
|
421
|
-
}
|
|
422
|
-
function isOptionItemMatch(option, item) {
|
|
423
|
-
var _ref18, _option$option_group_, _ref19, _item$option_group_it, _option$option_group_2, _item$option_group_id2;
|
|
424
|
-
var optionItemId = (_ref18 = (_option$option_group_ = option.option_group_item_id) !== null && _option$option_group_ !== void 0 ? _option$option_group_ : option.product_option_item_id) !== null && _ref18 !== void 0 ? _ref18 : option.id;
|
|
425
|
-
var itemId = (_ref19 = (_item$option_group_it = item.option_group_item_id) !== null && _item$option_group_it !== void 0 ? _item$option_group_it : item.product_option_item_id) !== null && _ref19 !== void 0 ? _ref19 : item.id;
|
|
426
|
-
if (!isSameId(optionItemId, itemId)) return false;
|
|
427
|
-
var optionGroupId = (_option$option_group_2 = option.option_group_id) !== null && _option$option_group_2 !== void 0 ? _option$option_group_2 : option.group_id;
|
|
428
|
-
var itemGroupId = (_item$option_group_id2 = item.option_group_id) !== null && _item$option_group_id2 !== void 0 ? _item$option_group_id2 : item.group_id;
|
|
429
|
-
if (isPresentId(optionGroupId) && isPresentId(itemGroupId)) {
|
|
430
|
-
return isSameId(optionGroupId, itemGroupId);
|
|
431
|
-
}
|
|
432
|
-
return true;
|
|
433
|
-
}
|
|
434
|
-
function resolveBundleItemFromParentProduct(params) {
|
|
435
|
-
var _ref20, _bundle$bundle_varian, _bundle$bundle_id, _bundle$bundle_group_, _ref22, _bundle$bundle_produc2;
|
|
436
|
-
var bundle = params.bundle,
|
|
437
|
-
parentProduct = params.parentProduct;
|
|
438
|
-
if (!parentProduct) return null;
|
|
439
|
-
var bundleItems = flattenBundleItems(parentProduct);
|
|
440
|
-
var bundleVariantId = (_ref20 = (_bundle$bundle_varian = bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle.variant_id) !== null && _ref20 !== void 0 ? _ref20 : bundle.product_variant_id;
|
|
441
|
-
if (isNonZeroId(bundleVariantId)) {
|
|
442
|
-
var matchedByVariant = bundleItems.find(function (item) {
|
|
443
|
-
var _ref21, _item$bundle_variant_;
|
|
444
|
-
return isSameId((_ref21 = (_item$bundle_variant_ = item.bundle_variant_id) !== null && _item$bundle_variant_ !== void 0 ? _item$bundle_variant_ : item.variant_id) !== null && _ref21 !== void 0 ? _ref21 : item.product_variant_id, bundleVariantId);
|
|
445
|
-
});
|
|
446
|
-
if (matchedByVariant) return matchedByVariant;
|
|
447
|
-
}
|
|
448
|
-
var bundleId = (_bundle$bundle_id = bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle.id;
|
|
449
|
-
if (isPresentId(bundleId)) {
|
|
450
|
-
var matchedByBundleId = bundleItems.find(function (item) {
|
|
451
|
-
var _item$id;
|
|
452
|
-
return isSameId((_item$id = item.id) !== null && _item$id !== void 0 ? _item$id : item.bundle_id, bundleId);
|
|
453
|
-
});
|
|
454
|
-
if (matchedByBundleId) return matchedByBundleId;
|
|
455
|
-
}
|
|
456
|
-
var bundleGroupId = (_bundle$bundle_group_ = bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle.group_id;
|
|
457
|
-
var bundleProductId = (_ref22 = (_bundle$bundle_produc2 = bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle._bundle_product_id) !== null && _ref22 !== void 0 ? _ref22 : bundle.product_id;
|
|
458
|
-
if (isPresentId(bundleGroupId) && isPresentId(bundleProductId)) {
|
|
459
|
-
var matchedByGroupAndProduct = bundleItems.find(function (item) {
|
|
460
|
-
var _item$group_id, _ref23, _item$bundle_product_;
|
|
461
|
-
return isSameId((_item$group_id = item.group_id) !== null && _item$group_id !== void 0 ? _item$group_id : item.bundle_group_id, bundleGroupId) && isSameId((_ref23 = (_item$bundle_product_ = item.bundle_product_id) !== null && _item$bundle_product_ !== void 0 ? _item$bundle_product_ : item._bundle_product_id) !== null && _ref23 !== void 0 ? _ref23 : item.product_id, bundleProductId);
|
|
462
|
-
});
|
|
463
|
-
if (matchedByGroupAndProduct) return matchedByGroupAndProduct;
|
|
464
|
-
}
|
|
465
|
-
if (isPresentId(bundleProductId)) {
|
|
466
|
-
return bundleItems.find(function (item) {
|
|
467
|
-
var _ref24, _item$bundle_product_2;
|
|
468
|
-
return isSameId((_ref24 = (_item$bundle_product_2 = item.bundle_product_id) !== null && _item$bundle_product_2 !== void 0 ? _item$bundle_product_2 : item._bundle_product_id) !== null && _ref24 !== void 0 ? _ref24 : item.product_id, bundleProductId);
|
|
469
|
-
}) || null;
|
|
470
|
-
}
|
|
471
|
-
return null;
|
|
472
|
-
}
|
|
473
|
-
function flattenBundleItems(parentProduct) {
|
|
474
|
-
var bundleGroups = Array.isArray(parentProduct.bundle_group) ? parentProduct.bundle_group : [];
|
|
475
|
-
return bundleGroups.flatMap(function (group) {
|
|
476
|
-
var items = Array.isArray(group.bundle_item) ? group.bundle_item : [];
|
|
477
|
-
return items.map(function (item) {
|
|
478
|
-
var _ref25, _item$group_id2;
|
|
479
|
-
return _objectSpread(_objectSpread({}, item), {}, {
|
|
480
|
-
group_id: (_ref25 = (_item$group_id2 = item.group_id) !== null && _item$group_id2 !== void 0 ? _item$group_id2 : group.id) !== null && _ref25 !== void 0 ? _ref25 : group.group_id
|
|
481
|
-
});
|
|
482
|
-
});
|
|
483
|
-
});
|
|
484
|
-
}
|
|
485
|
-
function isNonZeroId(value) {
|
|
486
|
-
return isPresentId(value) && String(value) !== '0';
|
|
487
|
-
}
|
|
488
|
-
function isPresentId(value) {
|
|
489
|
-
return value !== undefined && value !== null && value !== '';
|
|
490
|
-
}
|
|
491
|
-
function isSameId(left, right) {
|
|
492
|
-
if (!isPresentId(left) || !isPresentId(right)) return false;
|
|
493
|
-
return String(left) === String(right);
|
|
494
|
-
}
|
|
495
|
-
function buildOptionTitleSuffix(options) {
|
|
496
|
-
var text = options.map(function (option) {
|
|
497
|
-
var _option$num2;
|
|
498
|
-
var name = stringify(option.name).trim();
|
|
499
|
-
if (!name) return '';
|
|
500
|
-
var quantity = (_option$num2 = option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1;
|
|
501
|
-
return "".concat(name, " x ").concat(quantity);
|
|
502
|
-
}).filter(Boolean).join(', ');
|
|
503
|
-
return text ? "(".concat(text, ")") : '';
|
|
504
|
-
}
|
|
505
|
-
function formatBundlePrice(bundle, currencySymbol) {
|
|
506
|
-
var _ref26, _ref27, _bundle$bundle_sellin;
|
|
507
|
-
var value = (_ref26 = (_ref27 = (_bundle$bundle_sellin = bundle.bundle_selling_price) !== null && _bundle$bundle_sellin !== void 0 ? _bundle$bundle_sellin : bundle.bundle_sum_price) !== null && _ref27 !== void 0 ? _ref27 : bundle.price) !== null && _ref26 !== void 0 ? _ref26 : 0;
|
|
508
|
-
var amount = new Decimal(toMoneyNumber(value));
|
|
509
|
-
var isNegative = bundle.price_type === 'markdown' || bundle.price_type === 'markup' && bundle.price_type_ext === 'product_price';
|
|
510
|
-
if (isNegative) return "-".concat(currencySymbol).concat(amount.abs().toFixed(2));
|
|
511
|
-
return formatMoney(amount, currencySymbol);
|
|
512
|
-
}
|
|
513
|
-
function buildFees(params) {
|
|
514
|
-
var order = params.order,
|
|
515
|
-
shopInfo = params.shopInfo,
|
|
516
|
-
locale = params.locale,
|
|
517
|
-
products = params.products,
|
|
518
|
-
summary = params.summary,
|
|
519
|
-
currencySymbol = params.currencySymbol;
|
|
520
|
-
var fees = [];
|
|
521
|
-
for (var _i = 0, _normalizeArray = normalizeArray(order.surcharges || summary.surcharges); _i < _normalizeArray.length; _i++) {
|
|
522
|
-
var _ref28, _surcharge$amount;
|
|
523
|
-
var surcharge = _normalizeArray[_i];
|
|
524
|
-
var value = (_ref28 = (_surcharge$amount = surcharge.amount) !== null && _surcharge$amount !== void 0 ? _surcharge$amount : surcharge.value) !== null && _ref28 !== void 0 ? _ref28 : surcharge.total_amount;
|
|
525
|
-
if (!isNonZero(value)) continue;
|
|
526
|
-
fees.push({
|
|
527
|
-
item: getLocalizedValue(surcharge.name || surcharge.title || surcharge.item, locale),
|
|
528
|
-
value: formatMoney(value, currencySymbol)
|
|
529
|
-
});
|
|
530
|
-
}
|
|
531
|
-
var discountAmount = summary.discount_amount || order.discount_amount || order.shop_discount;
|
|
532
|
-
if (isNonZero(discountAmount)) {
|
|
533
|
-
fees.push({
|
|
534
|
-
item: label(locale, 'orderDiscount'),
|
|
535
|
-
value: formatMoney(new Decimal(toMoneyNumber(discountAmount)).neg(), currencySymbol)
|
|
536
|
-
});
|
|
537
|
-
}
|
|
538
|
-
var taxFee = summary.tax_fee || order.tax_fee;
|
|
539
|
-
if (isNonZero(taxFee)) {
|
|
540
|
-
fees.push({
|
|
541
|
-
item: stringify(summary.tax_title || order.tax_title || shopInfo.tax_title),
|
|
542
|
-
value: formatMoney(taxFee, currencySymbol)
|
|
543
|
-
});
|
|
544
|
-
}
|
|
545
|
-
var roundingAmount = summary.rounding_amount || order.rounding_amount;
|
|
546
|
-
if (isNonZero(roundingAmount)) {
|
|
547
|
-
fees.push({
|
|
548
|
-
item: label(locale, 'rounding'),
|
|
549
|
-
value: formatMoney(roundingAmount, currencySymbol)
|
|
550
|
-
});
|
|
551
|
-
}
|
|
552
|
-
var payProcessingFee = summary.pay_service_charge_amount || order.pay_service_charge_amount;
|
|
553
|
-
if (isNonZero(payProcessingFee)) {
|
|
554
|
-
fees.push({
|
|
555
|
-
item: label(locale, 'payProcessingFee'),
|
|
556
|
-
value: formatMoney(payProcessingFee, currencySymbol)
|
|
557
|
-
});
|
|
558
|
-
}
|
|
559
|
-
return {
|
|
560
|
-
fees: fees,
|
|
561
|
-
countFee: _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
562
|
-
total_amount: formatMoney(summary.total_amount || order.total_amount, currencySymbol),
|
|
563
|
-
product_expect_amount: formatMoney(summary.product_expect_amount || summary.product_amount || order.product_expect_amount, currencySymbol),
|
|
564
|
-
expect_amount: formatMoney(summary.expect_amount || order.expect_amount || summary.total_amount || order.total_amount, currencySymbol),
|
|
565
|
-
product_quantity: toNumber(summary.product_quantity || products.reduce(function (sum, product) {
|
|
566
|
-
return sum + product.product_quantity;
|
|
567
|
-
}, 0), 0),
|
|
568
|
-
has_pay: formatMoney(sumPayments(order.payments), currencySymbol),
|
|
569
|
-
payment_method: '',
|
|
570
|
-
tax_title: stringify(summary.tax_title || order.tax_title || shopInfo.tax_title),
|
|
571
|
-
total_refund_amount: formatMoney(summary.total_refund_amount || order.total_refund_amount, currencySymbol)
|
|
572
|
-
}, isNonZero(roundingAmount) ? {
|
|
573
|
-
rounding_amount: formatMoney(roundingAmount, currencySymbol)
|
|
574
|
-
} : {}), isNonZero(discountAmount) ? {
|
|
575
|
-
order_total_discount: formatMoney(discountAmount, currencySymbol)
|
|
576
|
-
} : {}), isNonZero(payProcessingFee) ? {
|
|
577
|
-
pay_processing_fee: formatMoney(payProcessingFee, currencySymbol)
|
|
578
|
-
} : {}), isNonZero(taxFee) ? {
|
|
579
|
-
tax_fee: formatMoney(taxFee, currencySymbol)
|
|
580
|
-
} : {})
|
|
581
|
-
};
|
|
582
|
-
}
|
|
583
|
-
function buildCustomer(order, locale) {
|
|
584
|
-
var _order$customer, _order$customer2, _order$customer3, _order$customer4;
|
|
585
|
-
return [{
|
|
586
|
-
item: label(locale, 'contactName'),
|
|
587
|
-
value: normalizeCustomerDisplayValue(order.customer_name || ((_order$customer = order.customer) === null || _order$customer === void 0 ? void 0 : _order$customer.name) || ((_order$customer2 = order.customer) === null || _order$customer2 === void 0 ? void 0 : _order$customer2.display_name))
|
|
588
|
-
}, {
|
|
589
|
-
item: label(locale, 'contactMobile'),
|
|
590
|
-
value: stringify(order.phone || ((_order$customer3 = order.customer) === null || _order$customer3 === void 0 ? void 0 : _order$customer3.phone))
|
|
591
|
-
}, {
|
|
592
|
-
item: label(locale, 'email'),
|
|
593
|
-
value: stringify(order.email || ((_order$customer4 = order.customer) === null || _order$customer4 === void 0 ? void 0 : _order$customer4.email))
|
|
594
|
-
}];
|
|
595
|
-
}
|
|
596
|
-
function normalizeCustomerDisplayValue(value) {
|
|
597
|
-
var text = stringify(value).trim();
|
|
598
|
-
if (!text) return 'Walk-In';
|
|
599
|
-
if (text.toLowerCase() === 'select a customer') return 'Walk-In';
|
|
600
|
-
return text;
|
|
601
|
-
}
|
|
602
|
-
function buildDelivery(order, locale) {
|
|
603
|
-
var _order$metadata2;
|
|
604
|
-
var serviceType = stringify(((_order$metadata2 = order.metadata) === null || _order$metadata2 === void 0 ? void 0 : _order$metadata2.service_type) || order.service_type || order.delivery_type);
|
|
605
|
-
if (!serviceType) return [];
|
|
606
|
-
var serviceTypeLabelKey = serviceTypeToLabelKey(serviceType);
|
|
607
|
-
var items = [{
|
|
608
|
-
item: '',
|
|
609
|
-
value: label(locale, serviceTypeLabelKey),
|
|
610
|
-
size: 2,
|
|
611
|
-
align: 'left'
|
|
612
|
-
}];
|
|
613
|
-
if (serviceType === 'shop_server' || serviceType === 'shop_service') {
|
|
614
|
-
items.push({
|
|
615
|
-
item: label(locale, 'pickUpTime'),
|
|
616
|
-
value: label(locale, 'asap')
|
|
617
|
-
});
|
|
618
|
-
}
|
|
619
|
-
return items;
|
|
620
|
-
}
|
|
621
|
-
function buildAppointment(order, locale) {
|
|
622
|
-
var _order$metadata3, _order$metadata4, _order$form_data;
|
|
623
|
-
var tableName = order.table_name || ((_order$metadata3 = order.metadata) === null || _order$metadata3 === void 0 ? void 0 : _order$metadata3.table_name) || ((_order$metadata4 = order.metadata) === null || _order$metadata4 === void 0 || (_order$metadata4 = _order$metadata4.table) === null || _order$metadata4 === void 0 ? void 0 : _order$metadata4.name) || ((_order$form_data = order.form_data) === null || _order$form_data === void 0 ? void 0 : _order$form_data.table_name);
|
|
624
|
-
if (!tableName) return [];
|
|
625
|
-
return [{
|
|
626
|
-
item: label(locale, 'table'),
|
|
627
|
-
value: getLocalizedValue(tableName, locale)
|
|
628
|
-
}];
|
|
629
|
-
}
|
|
630
|
-
function buildResources(order, locale) {
|
|
631
|
-
return normalizeArray(order.resources || order.resource_list).map(function (resource) {
|
|
632
|
-
return {
|
|
633
|
-
id: resource.id || resource.resource_id || '',
|
|
634
|
-
code: '',
|
|
635
|
-
title: getLocalizedValue(resource.title || resource.name, locale),
|
|
636
|
-
form_title: getLocalizedValue(resource.form_title || resource.type || '', locale)
|
|
637
|
-
};
|
|
638
|
-
});
|
|
639
|
-
}
|
|
640
|
-
function buildPaymentData(params) {
|
|
641
|
-
var payments = normalizeArray(params.order.payments);
|
|
642
|
-
return payments.filter(function (payment) {
|
|
643
|
-
return isPrintablePayment(payment);
|
|
644
|
-
}).map(function (payment) {
|
|
645
|
-
var _payment$amount;
|
|
646
|
-
var items = [{
|
|
647
|
-
item: paymentMethodName(payment, params.locale),
|
|
648
|
-
value: formatMoney((_payment$amount = payment.amount) !== null && _payment$amount !== void 0 ? _payment$amount : payment.origin_amount, params.currencySymbol)
|
|
649
|
-
}];
|
|
650
|
-
var fundRecord = getFundRecord(payment);
|
|
651
|
-
if (fundRecord) {
|
|
652
|
-
items.push.apply(items, _toConsumableArray(buildFundRecordPaymentItems({
|
|
653
|
-
payment: payment,
|
|
654
|
-
fundRecord: fundRecord,
|
|
655
|
-
locale: params.locale,
|
|
656
|
-
currencySymbol: params.currencySymbol
|
|
657
|
-
})));
|
|
658
|
-
} else {
|
|
659
|
-
var _ref29, _payment$remaining_am, _payment$metadata;
|
|
660
|
-
var remainingAmount = (_ref29 = (_payment$remaining_am = payment.remaining_amount) !== null && _payment$remaining_am !== void 0 ? _payment$remaining_am : payment.balance) !== null && _ref29 !== void 0 ? _ref29 : (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.remaining_amount;
|
|
661
|
-
if (remainingAmount !== undefined && remainingAmount !== null) {
|
|
662
|
-
items.push({
|
|
663
|
-
item: label(params.locale, 'remainingAmount'),
|
|
664
|
-
value: formatMoney(remainingAmount, params.currencySymbol)
|
|
665
|
-
});
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
items.push({
|
|
669
|
-
item: formatDateTime(payment.paid_at || payment.created_at || payment.updated_at || new Date(), params.locale),
|
|
670
|
-
value: ''
|
|
671
|
-
});
|
|
672
|
-
return items;
|
|
673
|
-
});
|
|
674
|
-
}
|
|
675
|
-
function buildFundRecordPaymentItems(params) {
|
|
676
|
-
var payment = params.payment,
|
|
677
|
-
fundRecord = params.fundRecord,
|
|
678
|
-
locale = params.locale,
|
|
679
|
-
currencySymbol = params.currencySymbol;
|
|
680
|
-
var items = [];
|
|
681
|
-
var usingBeforeValue = fundRecord.using_before_value;
|
|
682
|
-
var usingAfterValue = fundRecord.using_after_value;
|
|
683
|
-
if (isPointCardPayment(payment) && usingBeforeValue !== undefined && usingAfterValue !== undefined) {
|
|
684
|
-
var usedPoints = new Decimal(toMoneyNumber(usingBeforeValue)).minus(toMoneyNumber(usingAfterValue));
|
|
685
|
-
items.push({
|
|
686
|
-
item: label(locale, 'redeemPoints'),
|
|
687
|
-
value: trimDecimal(usedPoints)
|
|
688
|
-
});
|
|
689
|
-
items.push({
|
|
690
|
-
item: label(locale, 'remainingPoints'),
|
|
691
|
-
value: trimDecimal(new Decimal(toMoneyNumber(usingAfterValue)))
|
|
692
|
-
});
|
|
693
|
-
return items;
|
|
694
|
-
}
|
|
695
|
-
if (usingAfterValue !== undefined && usingAfterValue !== null) {
|
|
696
|
-
items.push({
|
|
697
|
-
item: label(locale, 'remainingAmount'),
|
|
698
|
-
value: formatMoney(usingAfterValue, currencySymbol)
|
|
699
|
-
});
|
|
700
|
-
}
|
|
701
|
-
return items;
|
|
702
|
-
}
|
|
703
|
-
function getFundRecord(payment) {
|
|
704
|
-
var fundRecord = payment.fund_record;
|
|
705
|
-
if (!fundRecord || _typeof(fundRecord) !== 'object' || Array.isArray(fundRecord)) return null;
|
|
706
|
-
if (!fundRecord.voucher_id && !fundRecord.code) return null;
|
|
707
|
-
return fundRecord;
|
|
708
|
-
}
|
|
709
|
-
function isPointCardPayment(payment) {
|
|
710
|
-
var _payment$fund_record;
|
|
711
|
-
var code = stringify(payment.code || payment.payment_method).toUpperCase();
|
|
712
|
-
var type = stringify(payment.type || ((_payment$fund_record = payment.fund_record) === null || _payment$fund_record === void 0 ? void 0 : _payment$fund_record.tag)).toLowerCase();
|
|
713
|
-
return code === 'POINTCARD' || type === 'point_card';
|
|
714
|
-
}
|
|
715
|
-
function maskMachineCode(code) {
|
|
716
|
-
var text = stringify(code);
|
|
717
|
-
if (text.length <= 6) return text;
|
|
718
|
-
return "".concat(text.slice(0, 2), "**").concat(text.slice(-4));
|
|
719
|
-
}
|
|
720
|
-
function trimDecimal(value) {
|
|
721
|
-
return value.toDecimalPlaces(2).toFixed(2).replace(/\.?0+$/, '');
|
|
722
|
-
}
|
|
723
|
-
function getFundRecordPaymentName(payment, locale) {
|
|
724
|
-
var fundRecord = getFundRecord(payment);
|
|
725
|
-
if (!fundRecord) return '';
|
|
726
|
-
var name = getLocalizedValue(fundRecord.wallet_pass_name, locale);
|
|
727
|
-
var code = maskMachineCode(fundRecord.code);
|
|
728
|
-
if (!name && !code) return '';
|
|
729
|
-
if (!code) return name;
|
|
730
|
-
var fallbackName = getLocalizedValue(payment.name || payment.title || payment.payment_method_name || payment.method_name || payment.code, locale);
|
|
731
|
-
return "".concat(name || fallbackName, "(").concat(code, ")");
|
|
732
|
-
}
|
|
733
|
-
function appendMachineCodeToName(name, payment) {
|
|
734
|
-
var fundRecord = getFundRecord(payment);
|
|
735
|
-
if (!(fundRecord !== null && fundRecord !== void 0 && fundRecord.code)) return name;
|
|
736
|
-
return "".concat(name, "(").concat(maskMachineCode(fundRecord.code), ")");
|
|
737
|
-
}
|
|
738
|
-
function paymentMethodName(payment, locale) {
|
|
739
|
-
var fundRecordName = getFundRecordPaymentName(payment, locale);
|
|
740
|
-
if (fundRecordName) return fundRecordName;
|
|
741
|
-
var raw = payment.name || payment.title || payment.payment_method_name || payment.method_name;
|
|
742
|
-
if (raw) return appendMachineCodeToName(getLocalizedValue(raw, locale), payment);
|
|
743
|
-
var code = stringify(payment.code || payment.type || payment.payment_method || payment.method).toLowerCase();
|
|
744
|
-
if (code.includes('cash')) return label(locale, 'cash');
|
|
745
|
-
if (code.includes('eftpos') || code.includes('card')) return label(locale, 'eftpos');
|
|
746
|
-
if (code.includes('wallet')) return label(locale, 'wallet');
|
|
747
|
-
if (code.includes('gift')) return label(locale, 'giftCard');
|
|
748
|
-
return stringify(payment.code || payment.type || payment.payment_method || payment.method);
|
|
749
|
-
}
|
|
750
|
-
function getSummary(order) {
|
|
751
|
-
return order.summary && _typeof(order.summary) === 'object' ? order.summary : order;
|
|
752
|
-
}
|
|
753
|
-
function getCurrencySymbol(order, shopInfo) {
|
|
754
|
-
return stringify(order.currency_symbol || (shopInfo === null || shopInfo === void 0 ? void 0 : shopInfo.currency_symbol) || order.shop_symbol || '$') || '$';
|
|
755
|
-
}
|
|
756
|
-
function resolveLocales(shopInfo, locales) {
|
|
757
|
-
var preferred = [].concat(_toConsumableArray(locales || []), [shopInfo.primary_locale], DEFAULT_LOCALES).filter(Boolean);
|
|
758
|
-
return Array.from(new Set(preferred.map(normalizeLocaleKey)));
|
|
759
|
-
}
|
|
760
|
-
function normalizeLocaleKey(locale) {
|
|
761
|
-
return locale.replace('-', '_');
|
|
762
|
-
}
|
|
763
|
-
function label(locale, key) {
|
|
764
|
-
var _LABELS$locale;
|
|
765
|
-
return ((_LABELS$locale = LABELS[locale]) === null || _LABELS$locale === void 0 ? void 0 : _LABELS$locale[key]) || LABELS.en[key] || key;
|
|
766
|
-
}
|
|
767
|
-
function getLocalizedValue(value, locale) {
|
|
768
|
-
var _ref30, _ref31, _ref32, _value$locale2;
|
|
769
|
-
if (value === undefined || value === null) return '';
|
|
770
|
-
if (_typeof(value) !== 'object') return stringify(value);
|
|
771
|
-
var dashedLocale = locale.replace('_', '-');
|
|
772
|
-
return stringify((_ref30 = (_ref31 = (_ref32 = (_value$locale2 = value[locale]) !== null && _value$locale2 !== void 0 ? _value$locale2 : value[dashedLocale]) !== null && _ref32 !== void 0 ? _ref32 : value.default) !== null && _ref31 !== void 0 ? _ref31 : value.en) !== null && _ref30 !== void 0 ? _ref30 : '');
|
|
773
|
-
}
|
|
774
|
-
function serviceTypeToLabelKey(serviceType) {
|
|
775
|
-
var normalized = serviceType.toLowerCase();
|
|
776
|
-
if (normalized.includes('take')) return 'takeAway';
|
|
777
|
-
if (normalized.includes('delivery')) return 'delivery';
|
|
778
|
-
if (normalized.includes('pick')) return 'pickUp';
|
|
779
|
-
if (normalized.includes('shop')) return 'shopService';
|
|
780
|
-
return 'dineIn';
|
|
781
|
-
}
|
|
782
|
-
function buildShopAddress(shopInfo) {
|
|
783
|
-
return [shopInfo.address_street, shopInfo.address_detail, shopInfo.city, shopInfo.province, shopInfo.country, shopInfo.zip].filter(Boolean).join(', ');
|
|
784
|
-
}
|
|
785
|
-
function formatDateTime(value, locale) {
|
|
786
|
-
var date = dayjs(value);
|
|
787
|
-
if (!date.isValid()) return stringify(value);
|
|
788
|
-
if (locale === 'en') return date.format('HH:mm:ss DD/MM/YYYY');
|
|
789
|
-
return date.format('YYYY/MM/DD HH:mm:ss');
|
|
790
|
-
}
|
|
791
|
-
function formatMoney(value, currencySymbol) {
|
|
792
|
-
if (value instanceof Decimal) return "".concat(currencySymbol).concat(value.toFixed(2));
|
|
793
|
-
if (typeof value === 'string' && value.trim().startsWith(currencySymbol)) return value;
|
|
794
|
-
var amount = new Decimal(toMoneyNumber(value));
|
|
795
|
-
return "".concat(currencySymbol).concat(amount.toFixed(2));
|
|
796
|
-
}
|
|
797
|
-
function sumPayments(payments) {
|
|
798
|
-
return normalizeArray(payments).filter(function (payment) {
|
|
799
|
-
return isPrintablePayment(payment);
|
|
800
|
-
}).reduce(function (sum, payment) {
|
|
801
|
-
var _payment$amount2;
|
|
802
|
-
return sum.plus(toMoneyNumber((_payment$amount2 = payment.amount) !== null && _payment$amount2 !== void 0 ? _payment$amount2 : payment.origin_amount));
|
|
803
|
-
}, new Decimal(0));
|
|
804
|
-
}
|
|
805
|
-
function isPrintablePayment(payment) {
|
|
806
|
-
var status = stringify(payment.status).toLowerCase();
|
|
807
|
-
if (!status) return true;
|
|
808
|
-
return ['paid', 'success', 'succeeded', 'completed'].includes(status);
|
|
809
|
-
}
|
|
810
|
-
function normalizeArray(value) {
|
|
811
|
-
return Array.isArray(value) ? value : [];
|
|
812
|
-
}
|
|
813
|
-
function isNonZero(value) {
|
|
814
|
-
return !new Decimal(toMoneyNumber(value)).isZero();
|
|
815
|
-
}
|
|
816
|
-
function toMoneyNumber(value) {
|
|
817
|
-
if (value instanceof Decimal) return value.toString();
|
|
818
|
-
if (typeof value === 'number') return Number.isFinite(value) ? value : 0;
|
|
819
|
-
if (typeof value !== 'string') return 0;
|
|
820
|
-
var normalized = value.replace(/[^\d.-]/g, '');
|
|
821
|
-
return normalized || 0;
|
|
822
|
-
}
|
|
823
|
-
function toNumber(value, fallback) {
|
|
824
|
-
var numberValue = Number(value);
|
|
825
|
-
return Number.isFinite(numberValue) ? numberValue : fallback;
|
|
826
|
-
}
|
|
827
|
-
function stringify(value) {
|
|
828
|
-
if (value === undefined || value === null) return '';
|
|
829
|
-
return String(value);
|
|
830
|
-
}
|