@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,87 +1,112 @@
|
|
|
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/modules/SalesSummary/utils.ts
|
|
30
|
+
var utils_exports = {};
|
|
31
|
+
__export(utils_exports, {
|
|
32
|
+
calculateSalesSummary: () => calculateSalesSummary,
|
|
33
|
+
createEmptySalesSummary: () => createEmptySalesSummary
|
|
5
34
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var _utils2 = require("../Order/utils");
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
35
|
+
module.exports = __toCommonJS(utils_exports);
|
|
36
|
+
var import_decimal = __toESM(require("decimal.js"));
|
|
37
|
+
var import_utils = require("../Summary/utils");
|
|
38
|
+
var import_utils2 = require("../Order/utils");
|
|
12
39
|
function toDecimal(value) {
|
|
13
|
-
return new
|
|
40
|
+
return new import_decimal.default(value || 0);
|
|
14
41
|
}
|
|
15
42
|
function toFixed2(value) {
|
|
16
|
-
return new
|
|
43
|
+
return new import_decimal.default(value || 0).toFixed(2);
|
|
17
44
|
}
|
|
18
45
|
function toAmountFormat(value) {
|
|
19
|
-
return new
|
|
46
|
+
return new import_decimal.default(value || 0).toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP);
|
|
20
47
|
}
|
|
21
48
|
function toBackendTaxFee(value) {
|
|
22
49
|
return toBcScale(value, 2);
|
|
23
50
|
}
|
|
24
51
|
function toBcScale(value, scale) {
|
|
25
|
-
const factor = new
|
|
26
|
-
return new
|
|
52
|
+
const factor = new import_decimal.default(10).pow(scale);
|
|
53
|
+
return new import_decimal.default(value || 0).times(factor).toDecimalPlaces(0, import_decimal.default.ROUND_DOWN).div(factor);
|
|
27
54
|
}
|
|
28
55
|
function bcAdd(left, right, scale) {
|
|
29
|
-
return toBcScale(new
|
|
56
|
+
return toBcScale(new import_decimal.default(left || 0).plus(right || 0), scale);
|
|
30
57
|
}
|
|
31
58
|
function bcSub(left, right, scale) {
|
|
32
|
-
return toBcScale(new
|
|
59
|
+
return toBcScale(new import_decimal.default(left || 0).minus(right || 0), scale);
|
|
33
60
|
}
|
|
34
61
|
function bcMul(left, right, scale) {
|
|
35
|
-
return toBcScale(new
|
|
62
|
+
return toBcScale(new import_decimal.default(left || 0).times(right || 0), scale);
|
|
36
63
|
}
|
|
37
64
|
function bcDiv(left, right, scale) {
|
|
38
|
-
const divisor = new
|
|
39
|
-
if (divisor.eq(0))
|
|
40
|
-
|
|
65
|
+
const divisor = new import_decimal.default(right || 0);
|
|
66
|
+
if (divisor.eq(0))
|
|
67
|
+
return new import_decimal.default(0);
|
|
68
|
+
return toBcScale(new import_decimal.default(left || 0).div(divisor), scale);
|
|
41
69
|
}
|
|
42
70
|
function getSafeNum(num) {
|
|
43
|
-
if (!num || Number.isNaN(num))
|
|
44
|
-
|
|
71
|
+
if (!num || Number.isNaN(num))
|
|
72
|
+
return 1;
|
|
73
|
+
if (num < 1)
|
|
74
|
+
return 1;
|
|
45
75
|
return Math.floor(num);
|
|
46
76
|
}
|
|
47
77
|
function getBundleUnitPrice(product, useOriginal = false) {
|
|
48
78
|
const bundleItems = product.product_bundle || [];
|
|
49
79
|
return bundleItems.reduce((sum, item) => {
|
|
50
|
-
const quantity = getSafeNum(item
|
|
51
|
-
|
|
52
|
-
const signedUnit = (0, _utils2.getBundleSignedUnit)(item, {
|
|
53
|
-
useOriginal
|
|
54
|
-
});
|
|
80
|
+
const quantity = getSafeNum(item == null ? void 0 : item.num);
|
|
81
|
+
const signedUnit = (0, import_utils2.getBundleSignedUnit)(item, { useOriginal });
|
|
55
82
|
return sum.plus(signedUnit.times(quantity));
|
|
56
|
-
}, new
|
|
83
|
+
}, new import_decimal.default(0));
|
|
57
84
|
}
|
|
58
|
-
|
|
59
|
-
// 单商品 composite 单价(随后再乘商品数量):
|
|
60
|
-
// 新语义 v2 下 `metadata.main_product_selling_price` 已经是"含 option、含主商品折扣"的主价,
|
|
61
|
-
// composite 单价 = main_product_selling_price + Σ(bundle_selling_price × num)。
|
|
62
|
-
// 不再叠加 options(会重复计算),也不再用 variant/selling_price 兜底(选项已固化进 metadata)。
|
|
63
85
|
function getUnitPaymentTotal(product) {
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
const
|
|
86
|
+
var _a, _b;
|
|
87
|
+
const mainSelling = (_a = product.metadata) == null ? void 0 : _a.main_product_selling_price;
|
|
88
|
+
const mainOriginal = (_b = product.metadata) == null ? void 0 : _b.main_product_original_price;
|
|
89
|
+
const basePrice = mainSelling !== void 0 ? toDecimal(mainSelling) : mainOriginal !== void 0 ? toDecimal(mainOriginal) : toDecimal(product.selling_price);
|
|
67
90
|
return basePrice.plus(getBundleUnitPrice(product));
|
|
68
91
|
}
|
|
69
92
|
function getUnitOriginalTotal(product) {
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
const
|
|
93
|
+
var _a, _b;
|
|
94
|
+
const mainOriginal = (_a = product.metadata) == null ? void 0 : _a.main_product_original_price;
|
|
95
|
+
const mainSelling = (_b = product.metadata) == null ? void 0 : _b.main_product_selling_price;
|
|
96
|
+
const basePrice = mainOriginal !== void 0 ? toDecimal(mainOriginal) : mainSelling !== void 0 ? toDecimal(mainSelling) : toDecimal(product.original_price || product.selling_price);
|
|
73
97
|
return basePrice.plus(getBundleUnitPrice(product, true));
|
|
74
98
|
}
|
|
75
99
|
function isGeneratedVoucherProduct(product) {
|
|
76
100
|
const record = product;
|
|
77
|
-
const metadata = record
|
|
78
|
-
return record
|
|
101
|
+
const metadata = (record == null ? void 0 : record.metadata) || {};
|
|
102
|
+
return (record == null ? void 0 : record.extension_type) === "product_voucher" || metadata.parent_order_detail_id !== void 0 || metadata.gift_card_type !== void 0;
|
|
79
103
|
}
|
|
80
104
|
function buildSurchargeServiceItems(products) {
|
|
81
|
-
return products.map(product => {
|
|
105
|
+
return products.map((product) => {
|
|
106
|
+
var _a, _b;
|
|
82
107
|
const quantity = getSafeNum(product.num);
|
|
83
108
|
const unitTotal = getUnitPaymentTotal(product);
|
|
84
|
-
const options = (0,
|
|
109
|
+
const options = (0, import_utils2.getProductSkuOptions)(product);
|
|
85
110
|
const persistedSurchargeFee = getPersistedMainSurchargeFee(product);
|
|
86
111
|
return {
|
|
87
112
|
id: product.product_id,
|
|
@@ -94,9 +119,7 @@ function buildSurchargeServiceItems(products) {
|
|
|
94
119
|
product: {
|
|
95
120
|
discount_list: product.discount_list || [],
|
|
96
121
|
product_bundle: product.product_bundle || [],
|
|
97
|
-
product_sku: product.product_sku || {
|
|
98
|
-
option: options
|
|
99
|
-
}
|
|
122
|
+
product_sku: product.product_sku || { option: options }
|
|
100
123
|
}
|
|
101
124
|
},
|
|
102
125
|
bundle: product.product_bundle || [],
|
|
@@ -104,99 +127,124 @@ function buildSurchargeServiceItems(products) {
|
|
|
104
127
|
options,
|
|
105
128
|
relation_details: [],
|
|
106
129
|
metadata: {
|
|
107
|
-
...
|
|
108
|
-
__persisted_surcharge_fee: persistedSurchargeFee
|
|
130
|
+
...product.metadata || {},
|
|
131
|
+
__persisted_surcharge_fee: persistedSurchargeFee == null ? void 0 : persistedSurchargeFee.toFixed(2)
|
|
109
132
|
},
|
|
110
|
-
start_date: product.metadata
|
|
111
|
-
start_time: product.metadata
|
|
133
|
+
start_date: ((_a = product.metadata) == null ? void 0 : _a.start_date) || "",
|
|
134
|
+
start_time: ((_b = product.metadata) == null ? void 0 : _b.start_time) || ""
|
|
112
135
|
};
|
|
113
136
|
});
|
|
114
137
|
}
|
|
115
138
|
function getRelationSurchargeIds(item) {
|
|
116
|
-
|
|
117
|
-
|
|
139
|
+
var _a;
|
|
140
|
+
const ids = [
|
|
141
|
+
...Array.isArray(item == null ? void 0 : item.relation_surcharge_ids) ? item.relation_surcharge_ids : [],
|
|
142
|
+
...Array.isArray((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a.relation_surcharge_ids) ? item.metadata.relation_surcharge_ids : []
|
|
143
|
+
];
|
|
144
|
+
return [...new Set(ids.filter((id) => id !== void 0 && id !== null && id !== ""))];
|
|
118
145
|
}
|
|
119
146
|
function getSurchargeConfigId(config) {
|
|
120
|
-
return config
|
|
147
|
+
return (config == null ? void 0 : config.id) ?? (config == null ? void 0 : config.surcharge_id);
|
|
121
148
|
}
|
|
122
149
|
function getSurchargeConfigById(surchargeList) {
|
|
123
|
-
const map = new Map();
|
|
150
|
+
const map = /* @__PURE__ */ new Map();
|
|
124
151
|
for (const config of surchargeList || []) {
|
|
125
152
|
const id = getSurchargeConfigId(config);
|
|
126
|
-
if (id !==
|
|
153
|
+
if (id !== void 0)
|
|
154
|
+
map.set(id, config);
|
|
127
155
|
}
|
|
128
156
|
return map;
|
|
129
157
|
}
|
|
130
158
|
function getMainSurchargeUnitAmount(product) {
|
|
159
|
+
var _a, _b;
|
|
131
160
|
const record = product;
|
|
132
|
-
return toDecimal(
|
|
161
|
+
return toDecimal(
|
|
162
|
+
((_a = record.metadata) == null ? void 0 : _a.main_product_attached_bundle_selling_price) ?? ((_b = record.metadata) == null ? void 0 : _b.main_product_selling_price) ?? record.selling_price ?? 0
|
|
163
|
+
);
|
|
133
164
|
}
|
|
134
165
|
function getBundleSurchargeUnitAmount(bundle) {
|
|
135
|
-
return toDecimal(bundle
|
|
166
|
+
return toDecimal((bundle == null ? void 0 : bundle.bundle_selling_price) ?? (bundle == null ? void 0 : bundle.bundle_sum_price) ?? (bundle == null ? void 0 : bundle.price) ?? 0);
|
|
136
167
|
}
|
|
137
168
|
function getBundleProductId(bundle) {
|
|
138
|
-
const id = bundle
|
|
139
|
-
if (id ===
|
|
169
|
+
const id = (bundle == null ? void 0 : bundle.bundle_product_id) ?? (bundle == null ? void 0 : bundle._bundle_product_id) ?? (bundle == null ? void 0 : bundle.product_id);
|
|
170
|
+
if (id === void 0 || id === null || id === "")
|
|
171
|
+
return null;
|
|
140
172
|
const parsed = Number(id);
|
|
141
|
-
if (!Number.isFinite(parsed))
|
|
173
|
+
if (!Number.isFinite(parsed))
|
|
174
|
+
return null;
|
|
142
175
|
return parsed;
|
|
143
176
|
}
|
|
144
177
|
function getPersistedMainSurchargeFee(product) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
178
|
+
var _a;
|
|
179
|
+
if ((product == null ? void 0 : product.order_detail_id) === void 0 || (product == null ? void 0 : product.order_detail_id) === null)
|
|
180
|
+
return null;
|
|
181
|
+
const value = (product == null ? void 0 : product.surcharge_fee) ?? (product == null ? void 0 : product.main_product_attached_bundle_surcharge_fee) ?? ((_a = product == null ? void 0 : product.metadata) == null ? void 0 : _a.main_product_attached_bundle_surcharge_fee);
|
|
182
|
+
if (value === void 0 || value === null || value === "")
|
|
183
|
+
return null;
|
|
148
184
|
return toDecimal(value);
|
|
149
185
|
}
|
|
150
186
|
function getPersistedSourceSurchargeFee(sourceItem) {
|
|
151
|
-
|
|
152
|
-
|
|
187
|
+
var _a;
|
|
188
|
+
const value = (_a = sourceItem == null ? void 0 : sourceItem.metadata) == null ? void 0 : _a.__persisted_surcharge_fee;
|
|
189
|
+
if (value === void 0 || value === null || value === "")
|
|
190
|
+
return null;
|
|
153
191
|
return toDecimal(value);
|
|
154
192
|
}
|
|
155
193
|
function getPersistedSurchargeRemainder(item, sourceItem) {
|
|
156
|
-
|
|
157
|
-
|
|
194
|
+
var _a, _b;
|
|
195
|
+
const value = ((_a = sourceItem == null ? void 0 : sourceItem.metadata) == null ? void 0 : _a.surcharge_rounding_remainder) ?? (item == null ? void 0 : item.surcharge_rounding_remainder) ?? ((_b = item == null ? void 0 : item.metadata) == null ? void 0 : _b.surcharge_rounding_remainder);
|
|
196
|
+
if (value === void 0 || value === null || value === "")
|
|
197
|
+
return null;
|
|
158
198
|
return toDecimal(value);
|
|
159
199
|
}
|
|
160
200
|
function getPersistedQuantity(item, fallbackQuantity) {
|
|
161
|
-
const isPersistedLine = item
|
|
162
|
-
if (!isPersistedLine)
|
|
163
|
-
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
201
|
+
const isPersistedLine = (item == null ? void 0 : item.order_detail_id) !== void 0 && (item == null ? void 0 : item.order_detail_id) !== null;
|
|
202
|
+
if (!isPersistedLine)
|
|
203
|
+
return new import_decimal.default(0);
|
|
204
|
+
const value = (item == null ? void 0 : item.product_quantity) ?? (item == null ? void 0 : item.quantity);
|
|
205
|
+
const parsed = new import_decimal.default(value || 0);
|
|
206
|
+
if (parsed.lte(0))
|
|
207
|
+
return import_decimal.default.min(fallbackQuantity, 1);
|
|
208
|
+
return import_decimal.default.min(fallbackQuantity, parsed);
|
|
167
209
|
}
|
|
168
210
|
function getPersistedBundleSurchargeFee(bundle, product) {
|
|
169
|
-
|
|
170
|
-
if (bundle
|
|
171
|
-
|
|
172
|
-
if (
|
|
211
|
+
var _a;
|
|
212
|
+
if ((bundle == null ? void 0 : bundle.order_detail_id) === void 0 && (product == null ? void 0 : product.order_detail_id) === void 0)
|
|
213
|
+
return null;
|
|
214
|
+
if ((bundle == null ? void 0 : bundle.order_detail_id) === null && (product == null ? void 0 : product.order_detail_id) === null)
|
|
215
|
+
return null;
|
|
216
|
+
const value = (bundle == null ? void 0 : bundle.surcharge_fee) ?? ((_a = bundle == null ? void 0 : bundle.metadata) == null ? void 0 : _a.surcharge_fee);
|
|
217
|
+
if (value === void 0 || value === null || value === "")
|
|
218
|
+
return null;
|
|
173
219
|
return toDecimal(value);
|
|
174
220
|
}
|
|
175
221
|
function createSurchargeAllocationNodes(products, sourceItems) {
|
|
222
|
+
var _a;
|
|
176
223
|
const nodes = [];
|
|
177
224
|
for (let productIndex = 0; productIndex < products.length; productIndex++) {
|
|
178
225
|
const product = products[productIndex];
|
|
179
226
|
const sourceItem = sourceItems[productIndex] || {};
|
|
180
|
-
const productQuantity = new
|
|
227
|
+
const productQuantity = new import_decimal.default(getSafeNum(product.num));
|
|
181
228
|
for (let bundleIndex = 0; bundleIndex < (product.product_bundle || []).length; bundleIndex++) {
|
|
182
229
|
const bundle = product.product_bundle[bundleIndex];
|
|
183
|
-
if (!isBundleOriginalPrice(bundle))
|
|
184
|
-
|
|
230
|
+
if (!isBundleOriginalPrice(bundle))
|
|
231
|
+
continue;
|
|
232
|
+
const sourceBundle = ((_a = sourceItem == null ? void 0 : sourceItem.bundle) == null ? void 0 : _a[bundleIndex]) || {};
|
|
185
233
|
nodes.push({
|
|
186
|
-
kind:
|
|
234
|
+
kind: "bundle",
|
|
187
235
|
target: bundle,
|
|
188
236
|
source: sourceBundle,
|
|
189
237
|
productId: getBundleProductId(bundle),
|
|
190
238
|
unitAmount: getBundleSurchargeUnitAmount(bundle),
|
|
191
|
-
quantity: new
|
|
192
|
-
persistedQuantity: getPersistedQuantity(bundle, new
|
|
239
|
+
quantity: new import_decimal.default(getSafeNum((bundle == null ? void 0 : bundle.num) ?? (bundle == null ? void 0 : bundle.quantity))).times(productQuantity),
|
|
240
|
+
persistedQuantity: getPersistedQuantity(bundle, new import_decimal.default(getSafeNum((bundle == null ? void 0 : bundle.num) ?? (bundle == null ? void 0 : bundle.quantity))).times(productQuantity)),
|
|
193
241
|
relationSurchargeIds: getRelationSurchargeIds(sourceBundle).length ? getRelationSurchargeIds(sourceBundle) : getRelationSurchargeIds(bundle),
|
|
194
242
|
persistedUnitSurchargeFee: getPersistedBundleSurchargeFee(bundle, product),
|
|
195
243
|
persistedSurchargeRemainder: getPersistedSurchargeRemainder(bundle, sourceBundle)
|
|
196
244
|
});
|
|
197
245
|
}
|
|
198
246
|
nodes.push({
|
|
199
|
-
kind:
|
|
247
|
+
kind: "main",
|
|
200
248
|
target: product,
|
|
201
249
|
source: sourceItem,
|
|
202
250
|
productId: product.product_id ?? null,
|
|
@@ -213,25 +261,26 @@ function createSurchargeAllocationNodes(products, sourceItems) {
|
|
|
213
261
|
function resetProductSurchargeFields(products) {
|
|
214
262
|
for (const product of products) {
|
|
215
263
|
product.surcharge_fee = 0;
|
|
216
|
-
product.main_product_attached_bundle_surcharge_fee =
|
|
264
|
+
product.main_product_attached_bundle_surcharge_fee = "0.00";
|
|
217
265
|
product.surcharge_rounding_remainder = 0;
|
|
218
266
|
product.relation_surcharge_ids = [];
|
|
219
267
|
for (const bundle of product.product_bundle || []) {
|
|
220
268
|
bundle.surcharge_fee = 0;
|
|
221
269
|
bundle.relation_surcharge_ids = [];
|
|
222
270
|
bundle.metadata = {
|
|
223
|
-
...
|
|
224
|
-
surcharge_fee:
|
|
225
|
-
surcharge_rounding_remainder:
|
|
271
|
+
...bundle.metadata || {},
|
|
272
|
+
surcharge_fee: "0.00",
|
|
273
|
+
surcharge_rounding_remainder: "0.00",
|
|
226
274
|
relation_surcharge_ids: []
|
|
227
275
|
};
|
|
228
276
|
}
|
|
229
277
|
}
|
|
230
278
|
}
|
|
231
279
|
function getPersistedSurchargeIds(nodes) {
|
|
232
|
-
const ids = new Set();
|
|
280
|
+
const ids = /* @__PURE__ */ new Set();
|
|
233
281
|
for (const node of nodes) {
|
|
234
|
-
if (!node.persistedUnitSurchargeFee || node.persistedUnitSurchargeFee.lte(0))
|
|
282
|
+
if (!node.persistedUnitSurchargeFee || node.persistedUnitSurchargeFee.lte(0))
|
|
283
|
+
continue;
|
|
235
284
|
for (const surchargeId of node.relationSurchargeIds) {
|
|
236
285
|
ids.add(surchargeId);
|
|
237
286
|
}
|
|
@@ -239,10 +288,13 @@ function getPersistedSurchargeIds(nodes) {
|
|
|
239
288
|
return ids;
|
|
240
289
|
}
|
|
241
290
|
function buildSurchargeQuantityTotals(nodes) {
|
|
242
|
-
const totals = new Map();
|
|
291
|
+
const totals = /* @__PURE__ */ new Map();
|
|
243
292
|
for (const node of nodes) {
|
|
244
293
|
for (const surchargeId of node.relationSurchargeIds) {
|
|
245
|
-
totals.set(
|
|
294
|
+
totals.set(
|
|
295
|
+
surchargeId,
|
|
296
|
+
(totals.get(surchargeId) || new import_decimal.default(0)).plus(node.quantity)
|
|
297
|
+
);
|
|
246
298
|
}
|
|
247
299
|
}
|
|
248
300
|
return totals;
|
|
@@ -250,10 +302,14 @@ function buildSurchargeQuantityTotals(nodes) {
|
|
|
250
302
|
function getFallbackAllProductSurchargeIds(surchargeList) {
|
|
251
303
|
return (surchargeList || []).reduce((ids, config) => {
|
|
252
304
|
const id = getSurchargeConfigId(config);
|
|
253
|
-
if (id ===
|
|
254
|
-
|
|
255
|
-
if (Number(config.
|
|
256
|
-
|
|
305
|
+
if (id === void 0)
|
|
306
|
+
return ids;
|
|
307
|
+
if (Number(config.open_product ?? 0) === 0)
|
|
308
|
+
return ids;
|
|
309
|
+
if (Number(config.is_all ?? 0) !== 1)
|
|
310
|
+
return ids;
|
|
311
|
+
if (Number(config.open_schedule ?? 0) === 1 && config.schedule_type !== "all")
|
|
312
|
+
return ids;
|
|
257
313
|
ids.push(id);
|
|
258
314
|
return ids;
|
|
259
315
|
}, []);
|
|
@@ -263,9 +319,9 @@ function getBackendSurchargeState(stateMap, surchargeId, config) {
|
|
|
263
319
|
if (!state) {
|
|
264
320
|
state = {
|
|
265
321
|
config,
|
|
266
|
-
amount: new
|
|
267
|
-
totalOffsetFee: new
|
|
268
|
-
calculatedQuantity: new
|
|
322
|
+
amount: new import_decimal.default(0),
|
|
323
|
+
totalOffsetFee: new import_decimal.default(0),
|
|
324
|
+
calculatedQuantity: new import_decimal.default(0),
|
|
269
325
|
fixedIncluded: false,
|
|
270
326
|
fixedRemainderAssigned: false
|
|
271
327
|
};
|
|
@@ -274,30 +330,26 @@ function getBackendSurchargeState(stateMap, surchargeId, config) {
|
|
|
274
330
|
return state;
|
|
275
331
|
}
|
|
276
332
|
function buildSurchargeResultItem(config, surchargeId, amount, index) {
|
|
277
|
-
const name = config
|
|
333
|
+
const name = (config == null ? void 0 : config.name) || (config == null ? void 0 : config.label) || {};
|
|
278
334
|
return {
|
|
279
335
|
key: `custom_surcharge_${index}`,
|
|
280
336
|
label: name,
|
|
281
337
|
name,
|
|
282
338
|
value: amount.toNumber(),
|
|
283
339
|
surcharge_id: surchargeId,
|
|
284
|
-
description: config
|
|
285
|
-
type:
|
|
286
|
-
fixed: config
|
|
340
|
+
description: config == null ? void 0 : config.description,
|
|
341
|
+
type: "default",
|
|
342
|
+
fixed: config == null ? void 0 : config.fixed,
|
|
287
343
|
amount: amount.toNumber(),
|
|
288
|
-
percentage: config
|
|
344
|
+
percentage: config == null ? void 0 : config.percentage,
|
|
289
345
|
metadata: {
|
|
290
|
-
open_product: config
|
|
346
|
+
open_product: config == null ? void 0 : config.open_product
|
|
291
347
|
}
|
|
292
348
|
};
|
|
293
349
|
}
|
|
294
350
|
function applySurchargeNodeResult(node, params) {
|
|
295
|
-
const {
|
|
296
|
-
|
|
297
|
-
roundingRemainder,
|
|
298
|
-
surchargeIds
|
|
299
|
-
} = params;
|
|
300
|
-
if (node.kind === 'main') {
|
|
351
|
+
const { unitSurchargeFee, roundingRemainder, surchargeIds } = params;
|
|
352
|
+
if (node.kind === "main") {
|
|
301
353
|
node.target.surcharge_fee = unitSurchargeFee.toNumber();
|
|
302
354
|
node.target.main_product_attached_bundle_surcharge_fee = toFixed2(unitSurchargeFee);
|
|
303
355
|
node.target.surcharge_rounding_remainder = roundingRemainder.toNumber();
|
|
@@ -307,18 +359,14 @@ function applySurchargeNodeResult(node, params) {
|
|
|
307
359
|
node.target.surcharge_fee = unitSurchargeFee.toNumber();
|
|
308
360
|
node.target.relation_surcharge_ids = surchargeIds;
|
|
309
361
|
node.target.metadata = {
|
|
310
|
-
...
|
|
362
|
+
...node.target.metadata || {},
|
|
311
363
|
surcharge_fee: toFixed2(unitSurchargeFee),
|
|
312
364
|
surcharge_rounding_remainder: toFixed2(roundingRemainder),
|
|
313
365
|
relation_surcharge_ids: surchargeIds
|
|
314
366
|
};
|
|
315
367
|
}
|
|
316
368
|
function calculateBackendProductSurcharges(params) {
|
|
317
|
-
const {
|
|
318
|
-
products,
|
|
319
|
-
sourceItems,
|
|
320
|
-
surchargeList
|
|
321
|
-
} = params;
|
|
369
|
+
const { products, sourceItems, surchargeList } = params;
|
|
322
370
|
resetProductSurchargeFields(products);
|
|
323
371
|
const configById = getSurchargeConfigById(surchargeList);
|
|
324
372
|
const nodes = createSurchargeAllocationNodes(products, sourceItems);
|
|
@@ -330,33 +378,49 @@ function calculateBackendProductSurcharges(params) {
|
|
|
330
378
|
}
|
|
331
379
|
const persistedSurchargeIds = getPersistedSurchargeIds(nodes);
|
|
332
380
|
const quantityTotals = buildSurchargeQuantityTotals(nodes);
|
|
333
|
-
const stateMap = new Map();
|
|
381
|
+
const stateMap = /* @__PURE__ */ new Map();
|
|
334
382
|
for (const node of nodes) {
|
|
335
|
-
let unitSurchargeFee = new
|
|
336
|
-
let roundingRemainder = new
|
|
383
|
+
let unitSurchargeFee = new import_decimal.default(0);
|
|
384
|
+
let roundingRemainder = new import_decimal.default(0);
|
|
337
385
|
const appliedSurchargeIds = [];
|
|
338
386
|
let persistedRemainderApplied = false;
|
|
339
387
|
for (const surchargeId of node.relationSurchargeIds) {
|
|
340
388
|
const config = configById.get(surchargeId);
|
|
341
|
-
const totalQuantity = quantityTotals.get(surchargeId) || new
|
|
342
|
-
if (totalQuantity.lte(0))
|
|
389
|
+
const totalQuantity = quantityTotals.get(surchargeId) || new import_decimal.default(0);
|
|
390
|
+
if (totalQuantity.lte(0))
|
|
391
|
+
continue;
|
|
343
392
|
const persistedUnitSurchargeFee = node.persistedUnitSurchargeFee;
|
|
344
393
|
if (persistedUnitSurchargeFee && persistedUnitSurchargeFee.gt(0)) {
|
|
345
|
-
const persistedQuantity =
|
|
346
|
-
const deltaQuantity =
|
|
347
|
-
const
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
const
|
|
353
|
-
|
|
354
|
-
|
|
394
|
+
const persistedQuantity = import_decimal.default.min(node.persistedQuantity, node.quantity);
|
|
395
|
+
const deltaQuantity = import_decimal.default.max(node.quantity.minus(persistedQuantity), 0);
|
|
396
|
+
const state2 = getBackendSurchargeState(
|
|
397
|
+
stateMap,
|
|
398
|
+
surchargeId,
|
|
399
|
+
config || { surcharge_id: surchargeId }
|
|
400
|
+
);
|
|
401
|
+
const persistedSurchargeRemainder = !persistedRemainderApplied && node.persistedSurchargeRemainder ? node.persistedSurchargeRemainder : new import_decimal.default(0);
|
|
402
|
+
state2.amount = bcAdd(
|
|
403
|
+
bcAdd(
|
|
404
|
+
state2.amount,
|
|
405
|
+
bcMul(persistedUnitSurchargeFee, persistedQuantity, 2),
|
|
406
|
+
2
|
|
407
|
+
),
|
|
408
|
+
persistedSurchargeRemainder,
|
|
409
|
+
2
|
|
410
|
+
);
|
|
411
|
+
const fixed2 = new import_decimal.default((config == null ? void 0 : config.fixed) || 0);
|
|
412
|
+
if (fixed2.gt(0))
|
|
413
|
+
state2.fixedIncluded = true;
|
|
414
|
+
let nodeTotalSurcharge = bcAdd(
|
|
415
|
+
bcMul(persistedUnitSurchargeFee, persistedQuantity, 2),
|
|
416
|
+
persistedSurchargeRemainder,
|
|
417
|
+
2
|
|
418
|
+
);
|
|
355
419
|
if (config && deltaQuantity.gt(0)) {
|
|
356
|
-
const
|
|
357
|
-
const deltaUnitPercentageFee =
|
|
420
|
+
const percentage2 = new import_decimal.default(config.percentage || 0);
|
|
421
|
+
const deltaUnitPercentageFee = import_decimal.default.max(0, bcMul(node.unitAmount, percentage2, 2));
|
|
358
422
|
const deltaSurcharge = bcMul(deltaQuantity, deltaUnitPercentageFee, 2);
|
|
359
|
-
|
|
423
|
+
state2.amount = bcAdd(state2.amount, deltaSurcharge, 2);
|
|
360
424
|
nodeTotalSurcharge = bcAdd(nodeTotalSurcharge, deltaSurcharge, 2);
|
|
361
425
|
}
|
|
362
426
|
if (node.quantity.gt(0)) {
|
|
@@ -369,25 +433,34 @@ function calculateBackendProductSurcharges(params) {
|
|
|
369
433
|
appliedSurchargeIds.push(surchargeId);
|
|
370
434
|
continue;
|
|
371
435
|
}
|
|
372
|
-
if (!config)
|
|
373
|
-
|
|
374
|
-
const
|
|
375
|
-
const
|
|
436
|
+
if (!config)
|
|
437
|
+
continue;
|
|
438
|
+
const percentage = new import_decimal.default(config.percentage || 0);
|
|
439
|
+
const fixed = new import_decimal.default(config.fixed || 0);
|
|
440
|
+
const unitPercentageFee = import_decimal.default.max(0, bcMul(node.unitAmount, percentage, 2));
|
|
376
441
|
const percentageTotalFee = bcMul(node.quantity, unitPercentageFee, 2);
|
|
377
|
-
let unitFixedFee = new
|
|
378
|
-
let fixedRemainder = new
|
|
442
|
+
let unitFixedFee = new import_decimal.default(0);
|
|
443
|
+
let fixedRemainder = new import_decimal.default(0);
|
|
379
444
|
if (fixed.gt(0) && !persistedSurchargeIds.has(surchargeId)) {
|
|
380
445
|
unitFixedFee = bcDiv(fixed, totalQuantity, 2);
|
|
381
446
|
const distributedFixed = bcMul(unitFixedFee, totalQuantity, 2);
|
|
382
447
|
fixedRemainder = bcSub(fixed, distributedFixed, 2);
|
|
383
448
|
}
|
|
384
|
-
const currentUnitSurcharge =
|
|
385
|
-
|
|
449
|
+
const currentUnitSurcharge = import_decimal.default.max(
|
|
450
|
+
0,
|
|
451
|
+
bcAdd(unitPercentageFee, unitFixedFee, 2)
|
|
452
|
+
);
|
|
453
|
+
if (currentUnitSurcharge.lte(0))
|
|
454
|
+
continue;
|
|
386
455
|
const state = getBackendSurchargeState(stateMap, surchargeId, config);
|
|
387
456
|
state.amount = bcAdd(state.amount, percentageTotalFee, 2);
|
|
388
|
-
const precisePercentage =
|
|
389
|
-
const offsetBaseFee =
|
|
390
|
-
state.totalOffsetFee = bcAdd(
|
|
457
|
+
const precisePercentage = import_decimal.default.max(0, bcMul(node.unitAmount, percentage, 6));
|
|
458
|
+
const offsetBaseFee = import_decimal.default.max(0, bcSub(precisePercentage, unitPercentageFee, 6));
|
|
459
|
+
state.totalOffsetFee = bcAdd(
|
|
460
|
+
state.totalOffsetFee,
|
|
461
|
+
bcMul(offsetBaseFee, node.quantity, 6),
|
|
462
|
+
6
|
|
463
|
+
);
|
|
391
464
|
state.calculatedQuantity = bcAdd(state.calculatedQuantity, node.quantity, 6);
|
|
392
465
|
if (!state.fixedIncluded && fixed.gt(0) && !persistedSurchargeIds.has(surchargeId)) {
|
|
393
466
|
state.amount = bcAdd(state.amount, fixed, 2);
|
|
@@ -401,7 +474,7 @@ function calculateBackendProductSurcharges(params) {
|
|
|
401
474
|
const totalOffsetFee = toAmountFormat(state.totalOffsetFee);
|
|
402
475
|
state.amount = bcAdd(state.amount, totalOffsetFee, 2);
|
|
403
476
|
roundingRemainder = bcAdd(roundingRemainder, totalOffsetFee, 2);
|
|
404
|
-
state.totalOffsetFee = new
|
|
477
|
+
state.totalOffsetFee = new import_decimal.default(0);
|
|
405
478
|
}
|
|
406
479
|
unitSurchargeFee = bcAdd(unitSurchargeFee, currentUnitSurcharge, 2);
|
|
407
480
|
appliedSurchargeIds.push(surchargeId);
|
|
@@ -414,62 +487,73 @@ function calculateBackendProductSurcharges(params) {
|
|
|
414
487
|
}
|
|
415
488
|
const result = (surchargeList || []).reduce((items, config, index) => {
|
|
416
489
|
const surchargeId = getSurchargeConfigId(config);
|
|
417
|
-
if (surchargeId ===
|
|
490
|
+
if (surchargeId === void 0)
|
|
491
|
+
return items;
|
|
418
492
|
const state = stateMap.get(surchargeId);
|
|
419
|
-
if (!state || state.amount.lte(0))
|
|
493
|
+
if (!state || state.amount.lte(0))
|
|
494
|
+
return items;
|
|
420
495
|
items.push(buildSurchargeResultItem(config, surchargeId, state.amount, index));
|
|
421
496
|
return items;
|
|
422
497
|
}, []);
|
|
423
|
-
const includedIds = new Set(
|
|
498
|
+
const includedIds = new Set(
|
|
499
|
+
result.map((item) => item == null ? void 0 : item.surcharge_id).filter((id) => id !== void 0)
|
|
500
|
+
);
|
|
424
501
|
for (const [surchargeId, state] of stateMap.entries()) {
|
|
425
|
-
if (includedIds.has(surchargeId) || state.amount.lte(0))
|
|
502
|
+
if (includedIds.has(surchargeId) || state.amount.lte(0))
|
|
503
|
+
continue;
|
|
426
504
|
result.push(buildSurchargeResultItem(state.config, surchargeId, state.amount, result.length));
|
|
427
505
|
}
|
|
428
506
|
return result;
|
|
429
507
|
}
|
|
430
508
|
function getProductDepositData(product) {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
509
|
+
var _a, _b, _c;
|
|
510
|
+
const rootDepositData = (_a = product._origin) == null ? void 0 : _a.custom_deposit_data;
|
|
511
|
+
if (rootDepositData && typeof rootDepositData === "object")
|
|
512
|
+
return rootDepositData;
|
|
513
|
+
const nestedDepositData = (_c = (_b = product._origin) == null ? void 0 : _b.product) == null ? void 0 : _c.custom_deposit_data;
|
|
514
|
+
if (nestedDepositData && typeof nestedDepositData === "object")
|
|
515
|
+
return nestedDepositData;
|
|
516
|
+
return void 0;
|
|
436
517
|
}
|
|
437
518
|
function collectDepositPolicyIds(depositData) {
|
|
438
|
-
const rawIds = [
|
|
519
|
+
const rawIds = [
|
|
520
|
+
...Array.isArray(depositData == null ? void 0 : depositData.self_deposit_policy_ids) ? depositData.self_deposit_policy_ids : [],
|
|
521
|
+
...Array.isArray(depositData == null ? void 0 : depositData.deposit_policy_ids) ? depositData.deposit_policy_ids : []
|
|
522
|
+
];
|
|
439
523
|
return rawIds.reduce((result, id) => {
|
|
440
524
|
const normalizedId = Number(id);
|
|
441
|
-
if (!Number.isFinite(normalizedId))
|
|
525
|
+
if (!Number.isFinite(normalizedId))
|
|
526
|
+
return result;
|
|
442
527
|
result.push(Math.floor(normalizedId));
|
|
443
528
|
return result;
|
|
444
529
|
}, []);
|
|
445
530
|
}
|
|
446
531
|
function collectDepositPolicyData(depositData) {
|
|
447
|
-
const rawPolicyData = Array.isArray(depositData
|
|
532
|
+
const rawPolicyData = Array.isArray(depositData == null ? void 0 : depositData.deposit_policy_data) ? depositData.deposit_policy_data : [];
|
|
448
533
|
return rawPolicyData.reduce((result, policy) => {
|
|
449
|
-
const normalizedId = Number(policy
|
|
450
|
-
if (!Number.isFinite(normalizedId))
|
|
534
|
+
const normalizedId = Number(policy == null ? void 0 : policy.id);
|
|
535
|
+
if (!Number.isFinite(normalizedId))
|
|
536
|
+
return result;
|
|
451
537
|
result.push({
|
|
452
538
|
id: Math.floor(normalizedId),
|
|
453
|
-
title: String(policy
|
|
539
|
+
title: String((policy == null ? void 0 : policy.title) || "")
|
|
454
540
|
});
|
|
455
541
|
return result;
|
|
456
542
|
}, []);
|
|
457
543
|
}
|
|
458
544
|
function calculateProductsDeposit(products) {
|
|
459
|
-
let totalDeposit = new
|
|
545
|
+
let totalDeposit = new import_decimal.default(0);
|
|
460
546
|
let hasDeposit = false;
|
|
461
|
-
const policyIds = new Set();
|
|
462
|
-
const policyDataMap = new Map();
|
|
547
|
+
const policyIds = /* @__PURE__ */ new Set();
|
|
548
|
+
const policyDataMap = /* @__PURE__ */ new Map();
|
|
463
549
|
for (const product of products) {
|
|
464
550
|
const depositData = getProductDepositData(product);
|
|
465
|
-
if (!depositData || depositData.has_deposit != 1)
|
|
551
|
+
if (!depositData || depositData.has_deposit != 1)
|
|
552
|
+
continue;
|
|
466
553
|
const num = getSafeNum(product.num);
|
|
467
554
|
const unitTotal = getUnitPaymentTotal(product);
|
|
468
555
|
const productTotal = unitTotal.times(num);
|
|
469
|
-
const {
|
|
470
|
-
deposit_fixed,
|
|
471
|
-
deposit_percentage
|
|
472
|
-
} = depositData;
|
|
556
|
+
const { deposit_fixed, deposit_percentage } = depositData;
|
|
473
557
|
const fixed = toDecimal(deposit_fixed);
|
|
474
558
|
const percentage = toDecimal(deposit_percentage);
|
|
475
559
|
const itemDeposit = fixed.plus(percentage.times(productTotal));
|
|
@@ -485,12 +569,13 @@ function calculateProductsDeposit(products) {
|
|
|
485
569
|
policyIds.add(policy.id);
|
|
486
570
|
}
|
|
487
571
|
}
|
|
488
|
-
if (!hasDeposit)
|
|
572
|
+
if (!hasDeposit)
|
|
573
|
+
return void 0;
|
|
489
574
|
for (const id of policyIds) {
|
|
490
575
|
if (!policyDataMap.has(id)) {
|
|
491
576
|
policyDataMap.set(id, {
|
|
492
577
|
id,
|
|
493
|
-
title:
|
|
578
|
+
title: ""
|
|
494
579
|
});
|
|
495
580
|
}
|
|
496
581
|
}
|
|
@@ -502,93 +587,75 @@ function calculateProductsDeposit(products) {
|
|
|
502
587
|
};
|
|
503
588
|
}
|
|
504
589
|
function isBundleOriginalPrice(item) {
|
|
505
|
-
return item
|
|
590
|
+
return (item == null ? void 0 : item.price_type) === "markup" && (item == null ? void 0 : item.price_type_ext) === "product_price";
|
|
506
591
|
}
|
|
507
592
|
function isBundleMarkupOrDiscount(item) {
|
|
508
|
-
const isMarkup = item
|
|
509
|
-
const isDiscount = item
|
|
593
|
+
const isMarkup = (item == null ? void 0 : item.price_type) === "markup" && ((item == null ? void 0 : item.price_type_ext) === "" || !(item == null ? void 0 : item.price_type_ext));
|
|
594
|
+
const isDiscount = (item == null ? void 0 : item.price_type) === "markdown" && ((item == null ? void 0 : item.price_type_ext) === "" || !(item == null ? void 0 : item.price_type_ext));
|
|
510
595
|
return isMarkup || isDiscount;
|
|
511
596
|
}
|
|
512
|
-
|
|
513
|
-
/**
|
|
514
|
-
* 计算单个商品税费(返回精确值,不四舍五入)。
|
|
515
|
-
* 与 Summary/utils.ts 的 getProductItemTax 公式一致,但不依赖 bookingDetail。
|
|
516
|
-
*
|
|
517
|
-
* @param taxRate 百分比税率(如 5 表示 5%),函数内部会 /100
|
|
518
|
-
*/
|
|
519
597
|
function calculateSingleItemTax(params) {
|
|
520
|
-
const {
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
} = params;
|
|
526
|
-
if (price.lte(0)) return new _decimal.default(0);
|
|
527
|
-
if (isChargeTax === 0 || !isChargeTax) return new _decimal.default(0);
|
|
598
|
+
const { price, taxRate, isPriceIncludeTax, isChargeTax } = params;
|
|
599
|
+
if (price.lte(0))
|
|
600
|
+
return new import_decimal.default(0);
|
|
601
|
+
if (isChargeTax === 0 || !isChargeTax)
|
|
602
|
+
return new import_decimal.default(0);
|
|
528
603
|
const rate = taxRate.div(100);
|
|
529
604
|
if (isPriceIncludeTax === 0) {
|
|
530
605
|
return price.times(rate);
|
|
531
606
|
}
|
|
532
|
-
const divisor = new
|
|
533
|
-
if (divisor.lte(0))
|
|
607
|
+
const divisor = new import_decimal.default(1).plus(rate);
|
|
608
|
+
if (divisor.lte(0))
|
|
609
|
+
return new import_decimal.default(0);
|
|
534
610
|
return price.dividedBy(divisor).times(rate);
|
|
535
611
|
}
|
|
536
|
-
|
|
537
|
-
/**
|
|
538
|
-
* 主商品 + 非原价(加价/减价)子商品的"折扣后"售价合计(含 option、含主商品折扣,未减整单折扣)。
|
|
539
|
-
*
|
|
540
|
-
* 对齐后端 metadata.main_product_attached_bundle_selling_price:
|
|
541
|
-
* - `metadata.main_product_selling_price` 已是"含 option、含折扣"的主价;
|
|
542
|
-
* - 叠加 `markup` / `markdown` 类 bundle(原价 bundle 由 `calculateProductsTax` 独立处理)。
|
|
543
|
-
*/
|
|
544
612
|
function getMainAttachedBundleSellingTotal(product) {
|
|
545
|
-
|
|
613
|
+
var _a, _b;
|
|
614
|
+
const mainSelling = ((_a = product.metadata) == null ? void 0 : _a.main_product_selling_price) ?? ((_b = product.metadata) == null ? void 0 : _b.main_product_original_price) ?? 0;
|
|
546
615
|
let total = toDecimal(mainSelling);
|
|
547
616
|
const bundleItems = product.product_bundle || [];
|
|
548
617
|
for (const bundleItem of bundleItems) {
|
|
549
618
|
if (isBundleMarkupOrDiscount(bundleItem)) {
|
|
550
|
-
|
|
551
|
-
const unit = (0, _utils2.getBundleSignedUnit)(bundleItem);
|
|
619
|
+
const unit = (0, import_utils2.getBundleSignedUnit)(bundleItem);
|
|
552
620
|
const qty = getSafeNum(bundleItem.num ?? bundleItem.quantity);
|
|
553
621
|
total = total.plus(unit.times(qty));
|
|
554
622
|
}
|
|
555
623
|
}
|
|
556
|
-
return
|
|
624
|
+
return import_decimal.default.max(total, 0);
|
|
557
625
|
}
|
|
558
|
-
|
|
559
|
-
/**
|
|
560
|
-
* 获取主商品税费基数(含 option、含主商品折扣、含加价/减价 bundle、已减整单折扣均摊)。
|
|
561
|
-
*
|
|
562
|
-
* 对齐后端 handleMainProductTaxFee:税基使用 main_product_attached_bundle_payment_price。
|
|
563
|
-
* - 优先读取均摊层写入的 payment 价;
|
|
564
|
-
* - 兜底退化为 selling 合计(无整单折扣时两者相等)。
|
|
565
|
-
*/
|
|
566
626
|
function getMainProductPaymentTotal(product) {
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
627
|
+
var _a;
|
|
628
|
+
const attachedPayment = (_a = product.metadata) == null ? void 0 : _a.main_product_attached_bundle_payment_price;
|
|
629
|
+
if (attachedPayment !== void 0 && attachedPayment !== null && attachedPayment !== "") {
|
|
630
|
+
return import_decimal.default.max(toDecimal(attachedPayment), 0);
|
|
570
631
|
}
|
|
571
632
|
return getMainAttachedBundleSellingTotal(product);
|
|
572
633
|
}
|
|
573
634
|
function getExplicitTaxRemainder(item) {
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
635
|
+
var _a;
|
|
636
|
+
const value = (item == null ? void 0 : item.tax_fee_rounding_remainder) ?? ((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a.tax_fee_rounding_remainder);
|
|
637
|
+
if (value === void 0 || value === null || value === "")
|
|
638
|
+
return null;
|
|
639
|
+
return new import_decimal.default(value || 0);
|
|
577
640
|
}
|
|
578
641
|
function getPersistedTaxRemainder(item, parentProduct) {
|
|
579
|
-
const isPersistedLine = item
|
|
580
|
-
if (!isPersistedLine)
|
|
642
|
+
const isPersistedLine = (item == null ? void 0 : item.order_detail_id) !== void 0 && (item == null ? void 0 : item.order_detail_id) !== null || (parentProduct == null ? void 0 : parentProduct.order_detail_id) !== void 0 && (parentProduct == null ? void 0 : parentProduct.order_detail_id) !== null;
|
|
643
|
+
if (!isPersistedLine)
|
|
644
|
+
return null;
|
|
581
645
|
return getExplicitTaxRemainder(item);
|
|
582
646
|
}
|
|
583
647
|
function getPersistedMainTaxFee(product) {
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
648
|
+
var _a;
|
|
649
|
+
if ((product == null ? void 0 : product.order_detail_id) === void 0 || (product == null ? void 0 : product.order_detail_id) === null)
|
|
650
|
+
return null;
|
|
651
|
+
const value = ((_a = product == null ? void 0 : product.metadata) == null ? void 0 : _a.main_product_attached_bundle_tax_fee) ?? (product == null ? void 0 : product.main_product_attached_bundle_tax_fee) ?? (product == null ? void 0 : product.tax_fee);
|
|
652
|
+
if (value === void 0 || value === null || value === "")
|
|
653
|
+
return null;
|
|
587
654
|
return toDecimal(value);
|
|
588
655
|
}
|
|
589
656
|
function writeTaxRemainder(item, roundingRemainder) {
|
|
590
657
|
item.tax_fee_rounding_remainder = roundingRemainder.toNumber();
|
|
591
|
-
if (item.metadata && typeof item.metadata ===
|
|
658
|
+
if (item.metadata && typeof item.metadata === "object") {
|
|
592
659
|
item.metadata.tax_fee_rounding_remainder = roundingRemainder.toFixed(2);
|
|
593
660
|
}
|
|
594
661
|
}
|
|
@@ -604,7 +671,7 @@ function resetTaxRemainderFields(products) {
|
|
|
604
671
|
for (const bundle of product.product_bundle || []) {
|
|
605
672
|
const bundleRemainder = getPersistedTaxRemainder(bundle, product);
|
|
606
673
|
bundle.metadata = {
|
|
607
|
-
...
|
|
674
|
+
...bundle.metadata || {}
|
|
608
675
|
};
|
|
609
676
|
if (bundleRemainder !== null) {
|
|
610
677
|
bundle.metadata.tax_fee_rounding_remainder = bundleRemainder.toFixed(2);
|
|
@@ -618,49 +685,47 @@ function resetTaxRemainderFields(products) {
|
|
|
618
685
|
}
|
|
619
686
|
}
|
|
620
687
|
function getBundlePaymentPrice(bundle, product) {
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
const
|
|
688
|
+
var _a;
|
|
689
|
+
if ((bundle == null ? void 0 : bundle.bundle_payment_price) !== void 0)
|
|
690
|
+
return toDecimal(bundle.bundle_payment_price);
|
|
691
|
+
const basePrice = toDecimal((bundle == null ? void 0 : bundle.bundle_selling_price) ?? (bundle == null ? void 0 : bundle.bundle_sum_price) ?? (bundle == null ? void 0 : bundle.price) ?? 0);
|
|
692
|
+
if (!isBundleOriginalPrice(bundle))
|
|
693
|
+
return basePrice;
|
|
694
|
+
const averageDiscountRate = toDecimal(
|
|
695
|
+
((_a = product.metadata) == null ? void 0 : _a.average_discount_amount_rate) ?? 1
|
|
696
|
+
);
|
|
625
697
|
return toAmountFormat(bcMul(basePrice, averageDiscountRate, 6));
|
|
626
698
|
}
|
|
627
699
|
function applyBackendTaxRemainder(params) {
|
|
628
|
-
const {
|
|
629
|
-
|
|
630
|
-
rawTax,
|
|
631
|
-
formattedTax,
|
|
700
|
+
const { target, rawTax, formattedTax, quantity, state } = params;
|
|
701
|
+
const taxFeeDifference = bcMul(
|
|
702
|
+
bcSub(rawTax, formattedTax, 6),
|
|
632
703
|
quantity,
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
const taxFeeDifference = bcMul(bcSub(rawTax, formattedTax, 6), quantity, 6);
|
|
704
|
+
6
|
|
705
|
+
);
|
|
636
706
|
state.difference = bcAdd(state.difference, taxFeeDifference, 6);
|
|
637
|
-
if (state.difference.lt(
|
|
707
|
+
if (state.difference.lt(5e-3))
|
|
708
|
+
return new import_decimal.default(0);
|
|
638
709
|
const roundingRemainder = toAmountFormat(state.difference);
|
|
639
710
|
writeTaxRemainder(target, roundingRemainder);
|
|
640
711
|
state.difference = bcSub(state.difference, roundingRemainder, 6);
|
|
641
712
|
return roundingRemainder;
|
|
642
713
|
}
|
|
643
|
-
|
|
644
|
-
/**
|
|
645
|
-
* 遍历所有商品计算税费,回写 tax_fee 到每个商品及 bundle 原价子商品,处理舍入差值。
|
|
646
|
-
* 参照 Summary/utils.ts 的 processItemsTax,适配 SalesSummaryProduct 结构。
|
|
647
|
-
*/
|
|
648
714
|
function calculateProductsTax(products, taxRate, isPriceIncludeTax) {
|
|
649
|
-
const rate = new
|
|
650
|
-
const taxRemainderState = {
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
let totalTax = new _decimal.default(0);
|
|
654
|
-
let totalOriginTax = new _decimal.default(0);
|
|
715
|
+
const rate = new import_decimal.default(taxRate);
|
|
716
|
+
const taxRemainderState = { difference: new import_decimal.default(0) };
|
|
717
|
+
let totalTax = new import_decimal.default(0);
|
|
718
|
+
let totalOriginTax = new import_decimal.default(0);
|
|
655
719
|
resetTaxRemainderFields(products);
|
|
656
720
|
for (const product of products) {
|
|
657
|
-
const quantity = new
|
|
658
|
-
let productUnitTax = new
|
|
659
|
-
let productUnitOriginTax = new
|
|
721
|
+
const quantity = new import_decimal.default(getSafeNum(product.num));
|
|
722
|
+
let productUnitTax = new import_decimal.default(0);
|
|
723
|
+
let productUnitOriginTax = new import_decimal.default(0);
|
|
660
724
|
const bundleItems = product.product_bundle || [];
|
|
661
725
|
for (const bundleItem of bundleItems) {
|
|
662
|
-
if (!isBundleOriginalPrice(bundleItem))
|
|
663
|
-
|
|
726
|
+
if (!isBundleOriginalPrice(bundleItem))
|
|
727
|
+
continue;
|
|
728
|
+
const bundleQuantity = new import_decimal.default(getSafeNum(bundleItem.num ?? bundleItem.quantity));
|
|
664
729
|
const totalBundleQuantity = bundleQuantity.times(quantity);
|
|
665
730
|
const bundlePrice = getBundlePaymentPrice(bundleItem, product);
|
|
666
731
|
const bundleOriginalPrice = toDecimal(bundleItem.original_price ?? bundleItem.product_price ?? bundleItem.price ?? 0);
|
|
@@ -681,7 +746,8 @@ function calculateProductsTax(products, taxRate, isPriceIncludeTax) {
|
|
|
681
746
|
quantity: totalBundleQuantity,
|
|
682
747
|
state: taxRemainderState
|
|
683
748
|
});
|
|
684
|
-
if (persistedBundleRemainder)
|
|
749
|
+
if (persistedBundleRemainder)
|
|
750
|
+
writeTaxRemainder(bundleItem, persistedBundleRemainder);
|
|
685
751
|
const bundleOrigTaxPrecise = calculateSingleItemTax({
|
|
686
752
|
price: bundleOriginalPrice.plus(bundleSurchargeFee),
|
|
687
753
|
taxRate: rate,
|
|
@@ -696,8 +762,7 @@ function calculateProductsTax(products, taxRate, isPriceIncludeTax) {
|
|
|
696
762
|
totalOriginTax = totalOriginTax.plus(bundleOrigTaxRounded.times(totalBundleQuantity));
|
|
697
763
|
}
|
|
698
764
|
const mainTotal = getMainProductPaymentTotal(product);
|
|
699
|
-
const
|
|
700
|
-
const surchargeFee = toDecimal(product.surcharge_fee).plus(quantity.gt(0) ? surchargeRoundingRemainder.div(quantity) : 0);
|
|
765
|
+
const surchargeFee = toDecimal(product.surcharge_fee);
|
|
701
766
|
const mainTaxableBase = mainTotal.lte(0) ? surchargeFee : mainTotal.plus(surchargeFee);
|
|
702
767
|
const mainTaxPrecise = calculateSingleItemTax({
|
|
703
768
|
price: mainTaxableBase,
|
|
@@ -709,10 +774,10 @@ function calculateProductsTax(products, taxRate, isPriceIncludeTax) {
|
|
|
709
774
|
const persistedMainRemainder = getPersistedTaxRemainder(product);
|
|
710
775
|
const persistedMainTaxFee = getPersistedMainTaxFee(product);
|
|
711
776
|
const persistedQuantity = getPersistedQuantity(product, quantity);
|
|
712
|
-
const deltaQuantity =
|
|
777
|
+
const deltaQuantity = import_decimal.default.max(quantity.minus(persistedQuantity), 0);
|
|
713
778
|
const shouldUsePersistedMainTax = persistedMainTaxFee && persistedMainTaxFee.gt(0) && persistedQuantity.gte(quantity);
|
|
714
779
|
const shouldSplitPersistedMainTax = persistedMainTaxFee && persistedMainTaxFee.gt(0) && persistedQuantity.gt(0) && deltaQuantity.gt(0);
|
|
715
|
-
const mainRemainder = shouldUsePersistedMainTax || shouldSplitPersistedMainTax ? new
|
|
780
|
+
const mainRemainder = shouldUsePersistedMainTax || shouldSplitPersistedMainTax ? new import_decimal.default(0) : persistedMainRemainder ?? applyBackendTaxRemainder({
|
|
716
781
|
target: product,
|
|
717
782
|
rawTax: mainTaxPrecise,
|
|
718
783
|
formattedTax: mainTaxRounded,
|
|
@@ -731,66 +796,55 @@ function calculateProductsTax(products, taxRate, isPriceIncludeTax) {
|
|
|
731
796
|
isChargeTax: product.is_charge_tax ?? 0
|
|
732
797
|
});
|
|
733
798
|
const originalTaxRounded = toAmountFormat(originalTaxPrecise);
|
|
734
|
-
const effectiveMainUnitTax = shouldUsePersistedMainTax ? persistedMainTaxFee : shouldSplitPersistedMainTax ? persistedMainTaxFee.times(persistedQuantity).plus(mainTaxRounded.times(deltaQuantity)).div(quantity).toDecimalPlaces(2,
|
|
799
|
+
const effectiveMainUnitTax = shouldUsePersistedMainTax ? persistedMainTaxFee : shouldSplitPersistedMainTax ? persistedMainTaxFee.times(persistedQuantity).plus(mainTaxRounded.times(deltaQuantity)).div(quantity).toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP) : mainTaxRounded;
|
|
735
800
|
productUnitTax = productUnitTax.plus(effectiveMainUnitTax);
|
|
736
801
|
productUnitOriginTax = productUnitOriginTax.plus(originalTaxRounded);
|
|
737
|
-
product.main_product_attached_bundle_tax_fee = effectiveMainUnitTax.toDecimalPlaces(2,
|
|
738
|
-
product.tax_fee = productUnitTax.toDecimalPlaces(2,
|
|
739
|
-
product.original_tax_fee = productUnitOriginTax.toDecimalPlaces(2,
|
|
740
|
-
totalTax = totalTax.plus(
|
|
802
|
+
product.main_product_attached_bundle_tax_fee = effectiveMainUnitTax.toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP).toFixed(2);
|
|
803
|
+
product.tax_fee = productUnitTax.toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP).toFixed(2);
|
|
804
|
+
product.original_tax_fee = productUnitOriginTax.toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP).toNumber();
|
|
805
|
+
totalTax = totalTax.plus(
|
|
806
|
+
shouldUsePersistedMainTax ? persistedMainTaxFee.times(quantity).plus(persistedMainRemainder || 0) : shouldSplitPersistedMainTax ? persistedMainTaxFee.times(persistedQuantity).plus(mainTaxRounded.times(deltaQuantity)) : mainTaxRounded.times(quantity).plus(mainRemainder)
|
|
807
|
+
);
|
|
741
808
|
totalOriginTax = totalOriginTax.plus(originalTaxRounded.times(quantity));
|
|
742
|
-
if (product.tax_fee_rounding_remainder ===
|
|
809
|
+
if (product.tax_fee_rounding_remainder === void 0) {
|
|
743
810
|
product.tax_fee_rounding_remainder = 0;
|
|
744
811
|
}
|
|
745
812
|
}
|
|
746
813
|
return {
|
|
747
|
-
tax: totalTax.toDecimalPlaces(2,
|
|
748
|
-
originTax: totalOriginTax.toDecimalPlaces(2,
|
|
814
|
+
tax: totalTax.toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP),
|
|
815
|
+
originTax: totalOriginTax.toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP)
|
|
749
816
|
};
|
|
750
817
|
}
|
|
751
|
-
|
|
752
|
-
/**
|
|
753
|
-
* 整单折扣(shop_discount)按各行 selling 合计占比均摊到 payment 维度。
|
|
754
|
-
*
|
|
755
|
-
* 文档口径:
|
|
756
|
-
* - payment_price = selling_price − 整单折扣均摊;rate = payment/selling(全行同一 rate);
|
|
757
|
-
* - 附加费不受整单折扣影响(基数仍用 selling,本函数写 main_product_attached_bundle_selling_price);
|
|
758
|
-
* - 税费受整单折扣影响(基数用 payment,本函数写 main_product_attached_bundle_payment_price 与
|
|
759
|
-
* 原价子商品 bundle_payment_price)。
|
|
760
|
-
*
|
|
761
|
-
* 与后端一致:bundle_payment_price = bundle_selling_price × rate,
|
|
762
|
-
* main_product_attached_bundle_payment_price = main_product_attached_bundle_selling_price × rate。
|
|
763
|
-
*/
|
|
764
818
|
function allocateShopDiscountToPayment(products, productAmount, shopDiscountAmount) {
|
|
765
|
-
const effectiveDiscount = productAmount.lte(0) ? new
|
|
766
|
-
let allocatedDiscount = new
|
|
819
|
+
const effectiveDiscount = productAmount.lte(0) ? new import_decimal.default(0) : import_decimal.default.max(import_decimal.default.min(productAmount, shopDiscountAmount), 0);
|
|
820
|
+
let allocatedDiscount = new import_decimal.default(0);
|
|
767
821
|
products.forEach((product, index) => {
|
|
768
|
-
const quantity = new
|
|
822
|
+
const quantity = new import_decimal.default(getSafeNum(product.num));
|
|
769
823
|
const sellingUnit = getUnitPaymentTotal(product);
|
|
770
824
|
const lineSellingTotal = sellingUnit.times(quantity);
|
|
771
|
-
const lineDiscount = effectiveDiscount.lte(0) ? new
|
|
825
|
+
const lineDiscount = effectiveDiscount.lte(0) ? new import_decimal.default(0) : index === products.length - 1 ? import_decimal.default.max(effectiveDiscount.minus(allocatedDiscount), 0) : toAmountFormat(lineSellingTotal.div(productAmount).times(effectiveDiscount));
|
|
772
826
|
allocatedDiscount = allocatedDiscount.plus(lineDiscount);
|
|
773
|
-
const unitDiscount = quantity.lte(0) ? new
|
|
774
|
-
const paymentUnit =
|
|
775
|
-
const rate = sellingUnit.lte(0) ? new
|
|
827
|
+
const unitDiscount = quantity.lte(0) ? new import_decimal.default(0) : lineDiscount.div(quantity);
|
|
828
|
+
const paymentUnit = import_decimal.default.max(sellingUnit.minus(unitDiscount), 0);
|
|
829
|
+
const rate = sellingUnit.lte(0) ? new import_decimal.default(1) : toBcScale(paymentUnit.div(sellingUnit), 6);
|
|
776
830
|
const mainSellingTotal = getMainAttachedBundleSellingTotal(product);
|
|
777
831
|
const mainPaymentTotal = toAmountFormat(bcMul(mainSellingTotal, rate, 6));
|
|
778
832
|
product.metadata = {
|
|
779
|
-
...
|
|
833
|
+
...product.metadata || {},
|
|
780
834
|
average_discount_amount_rate: rate.toString(),
|
|
781
835
|
main_product_attached_bundle_selling_price: mainSellingTotal.toFixed(2),
|
|
782
836
|
main_product_attached_bundle_payment_price: mainPaymentTotal.toFixed(2)
|
|
783
837
|
};
|
|
784
838
|
for (const bundle of product.product_bundle || []) {
|
|
785
|
-
// 原价子商品:bundle_payment_price = bundle_selling_price × rate
|
|
786
|
-
// markdown 子商品:以净额幅度 × rate(与后端一致,存正净额)
|
|
787
839
|
if (isBundleOriginalPrice(bundle)) {
|
|
788
|
-
const bundleSelling = toDecimal(
|
|
840
|
+
const bundleSelling = toDecimal(
|
|
841
|
+
bundle.bundle_selling_price ?? bundle.bundle_sum_price ?? bundle.price ?? 0
|
|
842
|
+
);
|
|
789
843
|
bundle.bundle_payment_price = toAmountFormat(bcMul(bundleSelling, rate, 6)).toFixed(2);
|
|
790
844
|
continue;
|
|
791
845
|
}
|
|
792
|
-
if ((0,
|
|
793
|
-
const magnitude = (0,
|
|
846
|
+
if ((0, import_utils2.isMarkdownBundle)(bundle)) {
|
|
847
|
+
const magnitude = (0, import_utils2.getBundleSellingMagnitude)(bundle);
|
|
794
848
|
bundle.custom_price = bundle.custom_price ?? bundle.price;
|
|
795
849
|
bundle.price = magnitude.toFixed(2);
|
|
796
850
|
bundle.bundle_selling_price = magnitude.toFixed(2);
|
|
@@ -803,25 +857,25 @@ function allocateShopDiscountToPayment(products, productAmount, shopDiscountAmou
|
|
|
803
857
|
function createEmptySalesSummary() {
|
|
804
858
|
return {
|
|
805
859
|
product_quantity: 0,
|
|
806
|
-
product_original_amount:
|
|
807
|
-
product_amount:
|
|
808
|
-
product_expect_amount:
|
|
809
|
-
product_tax_fee:
|
|
810
|
-
shipping_fee:
|
|
811
|
-
shipping_tax_fee:
|
|
812
|
-
tax_fee:
|
|
813
|
-
surcharge_fee:
|
|
860
|
+
product_original_amount: "0.00",
|
|
861
|
+
product_amount: "0.00",
|
|
862
|
+
product_expect_amount: "0.00",
|
|
863
|
+
product_tax_fee: "0.00",
|
|
864
|
+
shipping_fee: "0.00",
|
|
865
|
+
shipping_tax_fee: "0.00",
|
|
866
|
+
tax_fee: "0.00",
|
|
867
|
+
surcharge_fee: "0.00",
|
|
814
868
|
surcharges: [],
|
|
815
|
-
discount_amount:
|
|
816
|
-
deposit_amount:
|
|
817
|
-
expect_amount:
|
|
818
|
-
total_amount:
|
|
819
|
-
total_refund_amount:
|
|
820
|
-
customer_paid_amount:
|
|
821
|
-
order_paid_amount:
|
|
822
|
-
amount_gap:
|
|
823
|
-
rounding_amount:
|
|
824
|
-
pay_service_charge_amount:
|
|
869
|
+
discount_amount: "0.00",
|
|
870
|
+
deposit_amount: "0.00",
|
|
871
|
+
expect_amount: "0.00",
|
|
872
|
+
total_amount: "0.00",
|
|
873
|
+
total_refund_amount: "0.00",
|
|
874
|
+
customer_paid_amount: "0.00",
|
|
875
|
+
order_paid_amount: "0.00",
|
|
876
|
+
amount_gap: "0.00",
|
|
877
|
+
rounding_amount: "0.00",
|
|
878
|
+
pay_service_charge_amount: "0.00"
|
|
825
879
|
};
|
|
826
880
|
}
|
|
827
881
|
function calculateSalesSummary(params) {
|
|
@@ -834,54 +888,71 @@ function calculateSalesSummary(params) {
|
|
|
834
888
|
isInScheduleByDate,
|
|
835
889
|
shopDiscount
|
|
836
890
|
} = params;
|
|
837
|
-
if (!products
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
const
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
891
|
+
if (!(products == null ? void 0 : products.length))
|
|
892
|
+
return createEmptySalesSummary();
|
|
893
|
+
const summaryProducts = products.filter((product) => !isGeneratedVoucherProduct(product));
|
|
894
|
+
if (!summaryProducts.length)
|
|
895
|
+
return createEmptySalesSummary();
|
|
896
|
+
const productQuantity = summaryProducts.reduce(
|
|
897
|
+
(sum, item) => sum + getSafeNum(item.num),
|
|
898
|
+
0
|
|
899
|
+
);
|
|
900
|
+
const productOriginalAmount = summaryProducts.reduce(
|
|
901
|
+
(sum, item) => sum.plus(getUnitOriginalTotal(item).times(getSafeNum(item.num))),
|
|
902
|
+
new import_decimal.default(0)
|
|
903
|
+
);
|
|
904
|
+
const productAmount = summaryProducts.reduce(
|
|
905
|
+
(sum, item) => sum.plus(getUnitPaymentTotal(item).times(getSafeNum(item.num))),
|
|
906
|
+
new import_decimal.default(0)
|
|
907
|
+
);
|
|
908
|
+
const shopDiscountAmount = import_decimal.default.max(new import_decimal.default(Number(shopDiscount) || 0), 0);
|
|
909
|
+
const hasPersistedSurchargeSnapshot = summaryProducts.some((product) => {
|
|
910
|
+
var _a;
|
|
911
|
+
return (_a = getPersistedMainSurchargeFee(product)) == null ? void 0 : _a.gt(0);
|
|
846
912
|
});
|
|
847
|
-
// 整单折扣均摊:附加费基数用 selling(不受折扣),税费基数用 payment(受折扣)。
|
|
848
|
-
// persisted 快照(已下单编辑)优先采信后端回传值,不重算均摊。
|
|
849
913
|
if (!hasPersistedSurchargeSnapshot) {
|
|
850
914
|
allocateShopDiscountToPayment(summaryProducts, productAmount, shopDiscountAmount);
|
|
851
915
|
}
|
|
852
916
|
const surchargeServiceItems = buildSurchargeServiceItems(summaryProducts);
|
|
853
|
-
(0,
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
917
|
+
(0, import_utils.getSurcharge)(
|
|
918
|
+
{
|
|
919
|
+
service: surchargeServiceItems,
|
|
920
|
+
addons: [],
|
|
921
|
+
bookingDetail: null,
|
|
922
|
+
bookingId: void 0
|
|
923
|
+
},
|
|
924
|
+
{
|
|
925
|
+
isEdit: false,
|
|
926
|
+
isInScheduleByDate,
|
|
927
|
+
surcharge_list: surchargeList,
|
|
928
|
+
scheduleById
|
|
929
|
+
}
|
|
930
|
+
);
|
|
864
931
|
const surcharge = calculateBackendProductSurcharges({
|
|
865
932
|
products: summaryProducts,
|
|
866
933
|
sourceItems: surchargeServiceItems,
|
|
867
934
|
surchargeList
|
|
868
935
|
});
|
|
869
|
-
const surchargeAmount = new
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
936
|
+
const surchargeAmount = new import_decimal.default(
|
|
937
|
+
(0, import_utils.getSurchargeAmount)(
|
|
938
|
+
{ bookingDetail: null, bookingId: void 0 },
|
|
939
|
+
surcharge,
|
|
940
|
+
{ isEdit: false }
|
|
941
|
+
) || 0
|
|
942
|
+
);
|
|
943
|
+
const hasTaxRate = taxRate !== void 0 && taxRate !== null && taxRate > 0;
|
|
876
944
|
let productTaxFee;
|
|
877
945
|
if (hasTaxRate) {
|
|
878
946
|
const taxResult = calculateProductsTax(summaryProducts, taxRate, isPriceIncludeTax);
|
|
879
947
|
productTaxFee = taxResult.tax;
|
|
880
948
|
} else {
|
|
881
|
-
productTaxFee = summaryProducts.reduce(
|
|
949
|
+
productTaxFee = summaryProducts.reduce(
|
|
950
|
+
(sum, item) => sum.plus(toDecimal(item.tax_fee).times(getSafeNum(item.num))),
|
|
951
|
+
new import_decimal.default(0)
|
|
952
|
+
);
|
|
882
953
|
}
|
|
883
954
|
const orderAmountBeforeDiscount = productAmount.plus(surchargeAmount).plus(isPriceIncludeTax === 1 ? 0 : productTaxFee);
|
|
884
|
-
const totalAmount =
|
|
955
|
+
const totalAmount = import_decimal.default.max(0, orderAmountBeforeDiscount.minus(shopDiscountAmount));
|
|
885
956
|
const deposit = calculateProductsDeposit(summaryProducts);
|
|
886
957
|
return {
|
|
887
958
|
product_quantity: productQuantity,
|
|
@@ -889,22 +960,27 @@ function calculateSalesSummary(params) {
|
|
|
889
960
|
product_amount: toFixed2(productAmount),
|
|
890
961
|
product_expect_amount: toFixed2(productAmount),
|
|
891
962
|
product_tax_fee: toFixed2(productTaxFee),
|
|
892
|
-
shipping_fee:
|
|
893
|
-
shipping_tax_fee:
|
|
963
|
+
shipping_fee: "0.00",
|
|
964
|
+
shipping_tax_fee: "0.00",
|
|
894
965
|
tax_fee: toFixed2(productTaxFee),
|
|
895
966
|
surcharge_fee: toFixed2(surchargeAmount),
|
|
896
967
|
surcharges: surcharge,
|
|
897
968
|
discount_amount: toFixed2(shopDiscountAmount),
|
|
898
|
-
deposit_amount: deposit ? deposit.total :
|
|
969
|
+
deposit_amount: deposit ? deposit.total : "0.00",
|
|
899
970
|
deposit,
|
|
900
971
|
expect_amount: toFixed2(totalAmount),
|
|
901
972
|
total_amount: toFixed2(totalAmount),
|
|
902
|
-
total_refund_amount:
|
|
903
|
-
customer_paid_amount:
|
|
904
|
-
order_paid_amount:
|
|
905
|
-
amount_gap:
|
|
906
|
-
rounding_amount:
|
|
907
|
-
pay_service_charge_amount:
|
|
973
|
+
total_refund_amount: "0.00",
|
|
974
|
+
customer_paid_amount: "0.00",
|
|
975
|
+
order_paid_amount: "0.00",
|
|
976
|
+
amount_gap: "0.00",
|
|
977
|
+
rounding_amount: "0.00",
|
|
978
|
+
pay_service_charge_amount: "0.00",
|
|
908
979
|
is_price_include_tax: isPriceIncludeTax
|
|
909
980
|
};
|
|
910
|
-
}
|
|
981
|
+
}
|
|
982
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
983
|
+
0 && (module.exports = {
|
|
984
|
+
calculateSalesSummary,
|
|
985
|
+
createEmptySalesSummary
|
|
986
|
+
});
|