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