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