@pisell/pisellos 0.0.404 → 0.0.405
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.
|
@@ -15,9 +15,10 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
15
15
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
16
16
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
17
17
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
18
|
+
import Decimal from 'decimal.js';
|
|
18
19
|
import { BaseModule } from "../BaseModule";
|
|
19
20
|
import { ScheduleModule } from "../Schedule";
|
|
20
|
-
import { calculatePriceDetails, getSurcharge, getTax } from "./utils";
|
|
21
|
+
import { calculatePriceDetails, getSurcharge, getSurchargeAmount, getTax } from "./utils";
|
|
21
22
|
export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
22
23
|
_inherits(SummaryModule, _BaseModule);
|
|
23
24
|
var _super = _createSuper(SummaryModule);
|
|
@@ -186,8 +187,8 @@ export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
186
187
|
}, {
|
|
187
188
|
key: "getSurchargeforUtils",
|
|
188
189
|
value: function getSurchargeforUtils(items) {
|
|
189
|
-
|
|
190
|
-
var
|
|
190
|
+
// const surchargeList = this.store.surchargeList;
|
|
191
|
+
var surchargeList = getSurcharge({
|
|
191
192
|
service: items,
|
|
192
193
|
addons: [],
|
|
193
194
|
bookingDetail: null,
|
|
@@ -195,12 +196,18 @@ export var SummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
195
196
|
}, {
|
|
196
197
|
isEdit: false,
|
|
197
198
|
isInScheduleByDate: ScheduleModule.isInScheduleByDate,
|
|
198
|
-
surcharge_list: surchargeList,
|
|
199
|
+
surcharge_list: this.store.surchargeList,
|
|
199
200
|
scheduleById: {}
|
|
200
201
|
});
|
|
202
|
+
var surchargeAmount = new Decimal(getSurchargeAmount({
|
|
203
|
+
bookingDetail: null,
|
|
204
|
+
bookingId: undefined
|
|
205
|
+
}, surchargeList, {
|
|
206
|
+
isEdit: false
|
|
207
|
+
}));
|
|
201
208
|
return {
|
|
202
209
|
surchargeList: surchargeList,
|
|
203
|
-
surchargeAmount: surchargeAmount
|
|
210
|
+
surchargeAmount: surchargeAmount.toFixed(2)
|
|
204
211
|
};
|
|
205
212
|
}
|
|
206
213
|
}]);
|
|
@@ -55,10 +55,10 @@ export var calculatePriceDetails = function calculatePriceDetails(shopInfo, item
|
|
|
55
55
|
}),
|
|
56
56
|
tax = _getTax.tax,
|
|
57
57
|
originTax = _getTax.originTax;
|
|
58
|
-
var total = shopInfo !== null && shopInfo !== void 0 && shopInfo.is_price_include_tax ? subtotal.plus(surchargeAmount) : subtotal.plus(
|
|
58
|
+
var total = shopInfo !== null && shopInfo !== void 0 && shopInfo.is_price_include_tax ? subtotal.plus(surchargeAmount) : subtotal.plus(tax).plus(surchargeAmount);
|
|
59
59
|
|
|
60
60
|
// 计算总价 不包含折扣卡商品券折扣信息价格
|
|
61
|
-
var originTotal = shopInfo !== null && shopInfo !== void 0 && shopInfo.is_price_include_tax ? subOriginTotal : subOriginTotal.plus(totalTaxFee);
|
|
61
|
+
var originTotal = shopInfo !== null && shopInfo !== void 0 && shopInfo.is_price_include_tax ? subOriginTotal.plus(surchargeAmount) : subOriginTotal.plus(totalTaxFee).plus(surchargeAmount);
|
|
62
62
|
|
|
63
63
|
// 计算定金
|
|
64
64
|
var deposit = calculateDeposit(items);
|
|
@@ -847,6 +847,14 @@ export var getSurcharge = function getSurcharge(_ref10, options) {
|
|
|
847
847
|
}
|
|
848
848
|
return [];
|
|
849
849
|
}
|
|
850
|
+
|
|
851
|
+
// 用于“计算总价”的场景:每次调用都应重新计算(避免重复调用导致 surcharge_fee 累加)
|
|
852
|
+
// 注意:同一次调用内仍会在多条 surcharge 配置之间累加
|
|
853
|
+
resetItemsSurchargeSideEffects({
|
|
854
|
+
service: service,
|
|
855
|
+
addons: addons
|
|
856
|
+
});
|
|
857
|
+
|
|
850
858
|
// 无附加费规则
|
|
851
859
|
if (!Array.isArray(surcharge_list) || !(surcharge_list !== null && surcharge_list !== void 0 && surcharge_list.length)) return [];
|
|
852
860
|
|
|
@@ -1132,4 +1140,66 @@ export var getSurcharge = function getSurcharge(_ref10, options) {
|
|
|
1132
1140
|
});
|
|
1133
1141
|
}
|
|
1134
1142
|
return surchargeWithAmount;
|
|
1135
|
-
};
|
|
1143
|
+
};
|
|
1144
|
+
function resetItemsSurchargeSideEffects(_ref12) {
|
|
1145
|
+
var service = _ref12.service,
|
|
1146
|
+
addons = _ref12.addons;
|
|
1147
|
+
var resetItem = function resetItem(item) {
|
|
1148
|
+
if (!item) return;
|
|
1149
|
+
item.surcharge_fee = 0;
|
|
1150
|
+
item.surcharge_rounding_remainder = 0;
|
|
1151
|
+
item.relation_surcharge_ids = [];
|
|
1152
|
+
};
|
|
1153
|
+
if (Array.isArray(service)) {
|
|
1154
|
+
var _iterator10 = _createForOfIteratorHelper(service),
|
|
1155
|
+
_step10;
|
|
1156
|
+
try {
|
|
1157
|
+
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
1158
|
+
var item = _step10.value;
|
|
1159
|
+
resetItem(item);
|
|
1160
|
+
var _iterator11 = _createForOfIteratorHelper((item === null || item === void 0 ? void 0 : item.bundle) || []),
|
|
1161
|
+
_step11;
|
|
1162
|
+
try {
|
|
1163
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
1164
|
+
var bundleItem = _step11.value;
|
|
1165
|
+
resetItem(bundleItem);
|
|
1166
|
+
}
|
|
1167
|
+
} catch (err) {
|
|
1168
|
+
_iterator11.e(err);
|
|
1169
|
+
} finally {
|
|
1170
|
+
_iterator11.f();
|
|
1171
|
+
}
|
|
1172
|
+
var _iterator12 = _createForOfIteratorHelper((item === null || item === void 0 ? void 0 : item.relation_details) || []),
|
|
1173
|
+
_step12;
|
|
1174
|
+
try {
|
|
1175
|
+
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
|
1176
|
+
var relationDetail = _step12.value;
|
|
1177
|
+
resetItem(relationDetail);
|
|
1178
|
+
}
|
|
1179
|
+
} catch (err) {
|
|
1180
|
+
_iterator12.e(err);
|
|
1181
|
+
} finally {
|
|
1182
|
+
_iterator12.f();
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
} catch (err) {
|
|
1186
|
+
_iterator10.e(err);
|
|
1187
|
+
} finally {
|
|
1188
|
+
_iterator10.f();
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
if (Array.isArray(addons === null || addons === void 0 ? void 0 : addons.value)) {
|
|
1192
|
+
var _iterator13 = _createForOfIteratorHelper(addons.value),
|
|
1193
|
+
_step13;
|
|
1194
|
+
try {
|
|
1195
|
+
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
1196
|
+
var _item3 = _step13.value;
|
|
1197
|
+
resetItem(_item3);
|
|
1198
|
+
}
|
|
1199
|
+
} catch (err) {
|
|
1200
|
+
_iterator13.e(err);
|
|
1201
|
+
} finally {
|
|
1202
|
+
_iterator13.f();
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
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
|
+
));
|
|
17
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
28
|
|
|
19
29
|
// src/modules/Summary/index.ts
|
|
@@ -22,6 +32,7 @@ __export(Summary_exports, {
|
|
|
22
32
|
SummaryModule: () => SummaryModule
|
|
23
33
|
});
|
|
24
34
|
module.exports = __toCommonJS(Summary_exports);
|
|
35
|
+
var import_decimal = __toESM(require("decimal.js"));
|
|
25
36
|
var import_BaseModule = require("../BaseModule");
|
|
26
37
|
var import_Schedule = require("../Schedule");
|
|
27
38
|
var import_utils = require("./utils");
|
|
@@ -100,11 +111,11 @@ var SummaryModule = class extends import_BaseModule.BaseModule {
|
|
|
100
111
|
});
|
|
101
112
|
}
|
|
102
113
|
getSurchargeforUtils(items) {
|
|
103
|
-
const surchargeList = this.store.surchargeList;
|
|
104
|
-
const surchargeAmount = (0, import_utils.
|
|
114
|
+
const surchargeList = (0, import_utils.getSurcharge)({ service: items, addons: [], bookingDetail: null, bookingId: void 0 }, { isEdit: false, isInScheduleByDate: import_Schedule.ScheduleModule.isInScheduleByDate, surcharge_list: this.store.surchargeList, scheduleById: {} });
|
|
115
|
+
const surchargeAmount = new import_decimal.default((0, import_utils.getSurchargeAmount)({ bookingDetail: null, bookingId: void 0 }, surchargeList, { isEdit: false }));
|
|
105
116
|
return {
|
|
106
117
|
surchargeList,
|
|
107
|
-
surchargeAmount
|
|
118
|
+
surchargeAmount: surchargeAmount.toFixed(2)
|
|
108
119
|
};
|
|
109
120
|
}
|
|
110
121
|
};
|
|
@@ -56,8 +56,8 @@ var calculatePriceDetails = (shopInfo, items, isInScheduleByDate, surchargeList)
|
|
|
56
56
|
tax_rate: shopInfo == null ? void 0 : shopInfo.tax_rate,
|
|
57
57
|
is_price_include_tax: shopInfo == null ? void 0 : shopInfo.is_price_include_tax
|
|
58
58
|
});
|
|
59
|
-
const total = (shopInfo == null ? void 0 : shopInfo.is_price_include_tax) ? subtotal.plus(surchargeAmount) : subtotal.plus(
|
|
60
|
-
const originTotal = (shopInfo == null ? void 0 : shopInfo.is_price_include_tax) ? subOriginTotal : subOriginTotal.plus(totalTaxFee);
|
|
59
|
+
const total = (shopInfo == null ? void 0 : shopInfo.is_price_include_tax) ? subtotal.plus(surchargeAmount) : subtotal.plus(tax).plus(surchargeAmount);
|
|
60
|
+
const originTotal = (shopInfo == null ? void 0 : shopInfo.is_price_include_tax) ? subOriginTotal.plus(surchargeAmount) : subOriginTotal.plus(totalTaxFee).plus(surchargeAmount);
|
|
61
61
|
const deposit = calculateDeposit(items);
|
|
62
62
|
return {
|
|
63
63
|
subtotal: subtotal.toFixed(2),
|
|
@@ -501,6 +501,7 @@ var getSurcharge = ({ service, addons, bookingDetail, bookingId }, options) => {
|
|
|
501
501
|
}
|
|
502
502
|
return [];
|
|
503
503
|
}
|
|
504
|
+
resetItemsSurchargeSideEffects({ service, addons });
|
|
504
505
|
if (!Array.isArray(surcharge_list) || !(surcharge_list == null ? void 0 : surcharge_list.length))
|
|
505
506
|
return [];
|
|
506
507
|
const surchargeWithAmount = [];
|
|
@@ -708,6 +709,28 @@ var getSurcharge = ({ service, addons, bookingDetail, bookingId }, options) => {
|
|
|
708
709
|
}
|
|
709
710
|
return surchargeWithAmount;
|
|
710
711
|
};
|
|
712
|
+
function resetItemsSurchargeSideEffects({ service, addons }) {
|
|
713
|
+
const resetItem = (item) => {
|
|
714
|
+
if (!item)
|
|
715
|
+
return;
|
|
716
|
+
item.surcharge_fee = 0;
|
|
717
|
+
item.surcharge_rounding_remainder = 0;
|
|
718
|
+
item.relation_surcharge_ids = [];
|
|
719
|
+
};
|
|
720
|
+
if (Array.isArray(service)) {
|
|
721
|
+
for (let item of service) {
|
|
722
|
+
resetItem(item);
|
|
723
|
+
for (let bundleItem of (item == null ? void 0 : item.bundle) || [])
|
|
724
|
+
resetItem(bundleItem);
|
|
725
|
+
for (let relationDetail of (item == null ? void 0 : item.relation_details) || [])
|
|
726
|
+
resetItem(relationDetail);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
if (Array.isArray(addons == null ? void 0 : addons.value)) {
|
|
730
|
+
for (let item of addons.value)
|
|
731
|
+
resetItem(item);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
711
734
|
// Annotate the CommonJS export names for ESM import in node:
|
|
712
735
|
0 && (module.exports = {
|
|
713
736
|
calculateDeposit,
|