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