@pisell/pisellos 0.0.566 → 0.0.567
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.
|
@@ -271,7 +271,8 @@ function calculateProductsTax(products, taxRate, isPriceIncludeTax) {
|
|
|
271
271
|
|
|
272
272
|
// --- 主商品折后税费 ---
|
|
273
273
|
var mainTotal = getMainProductPaymentTotal(product);
|
|
274
|
-
var
|
|
274
|
+
var surchargeRoundingRemainder = toDecimal(product.surcharge_rounding_remainder);
|
|
275
|
+
var surchargeFee = toDecimal(product.surcharge_fee).plus(quantity.gt(0) ? surchargeRoundingRemainder.div(quantity) : 0);
|
|
275
276
|
var mainTaxableBase = mainTotal.lte(0) ? surchargeFee : mainTotal.plus(surchargeFee);
|
|
276
277
|
var mainTaxPrecise = calculateSingleItemTax({
|
|
277
278
|
price: mainTaxableBase,
|
|
@@ -440,8 +441,9 @@ export function calculateSalesSummary(params) {
|
|
|
440
441
|
isEdit: false
|
|
441
442
|
}) || 0);
|
|
442
443
|
for (var i = 0; i < products.length; i++) {
|
|
443
|
-
var _surchargeServiceItem;
|
|
444
|
+
var _surchargeServiceItem, _surchargeServiceItem2;
|
|
444
445
|
products[i].surcharge_fee = ((_surchargeServiceItem = surchargeServiceItems[i]) === null || _surchargeServiceItem === void 0 ? void 0 : _surchargeServiceItem.surcharge_fee) || 0;
|
|
446
|
+
products[i].surcharge_rounding_remainder = ((_surchargeServiceItem2 = surchargeServiceItems[i]) === null || _surchargeServiceItem2 === void 0 ? void 0 : _surchargeServiceItem2.surcharge_rounding_remainder) || 0;
|
|
445
447
|
}
|
|
446
448
|
var hasTaxRate = taxRate !== undefined && taxRate !== null && taxRate > 0;
|
|
447
449
|
var productTaxFee;
|
|
@@ -1174,7 +1174,7 @@ export var getSurcharge = function getSurcharge(_ref14, options) {
|
|
|
1174
1174
|
var _item2$item;
|
|
1175
1175
|
var originSurchargeFee = new Decimal(_item2.item.surcharge_fee || 0);
|
|
1176
1176
|
// 保留两位小数
|
|
1177
|
-
var surchargeFee = originSurchargeFee.plus(itemSurcharge).plus(fixedSurcharge).toDecimalPlaces(2, Decimal.
|
|
1177
|
+
var surchargeFee = originSurchargeFee.plus(itemSurcharge).plus(fixedSurcharge).toDecimalPlaces(2, Decimal.ROUND_DOWN).toNumber();
|
|
1178
1178
|
productTotalSurcharge = productTotalSurcharge.plus(new Decimal(surchargeFee).times(itemQuantity).toNumber());
|
|
1179
1179
|
_item2.item.surcharge_fee = surchargeFee;
|
|
1180
1180
|
_item2.item.relation_surcharge_ids = [].concat(_toConsumableArray(((_item2$item = _item2.item) === null || _item2$item === void 0 ? void 0 : _item2$item.relation_surcharge_ids) || []), [id]);
|
|
@@ -1182,7 +1182,7 @@ export var getSurcharge = function getSurcharge(_ref14, options) {
|
|
|
1182
1182
|
var _item2$item2;
|
|
1183
1183
|
var _originSurchargeFee = new Decimal(_item2.item.surcharge_fee || 0);
|
|
1184
1184
|
// 保留两位小数
|
|
1185
|
-
var _surchargeFee = _originSurchargeFee.plus(itemSurcharge).plus(fixedSurcharge).toDecimalPlaces(2, Decimal.
|
|
1185
|
+
var _surchargeFee = _originSurchargeFee.plus(itemSurcharge).plus(fixedSurcharge).toDecimalPlaces(2, Decimal.ROUND_DOWN).toNumber();
|
|
1186
1186
|
productTotalSurcharge = productTotalSurcharge.plus(new Decimal(_surchargeFee).times(itemQuantity).toNumber());
|
|
1187
1187
|
_item2.item.surcharge_fee = _surchargeFee;
|
|
1188
1188
|
_item2.item.relation_surcharge_ids = [].concat(_toConsumableArray(((_item2$item2 = _item2.item) === null || _item2$item2 === void 0 ? void 0 : _item2$item2.relation_surcharge_ids) || []), [id]);
|
|
@@ -0,0 +1,49 @@
|
|
|
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);
|
|
28
|
+
|
|
29
|
+
// src/model/strategy/adapter/promotion/index.ts
|
|
30
|
+
var promotion_exports = {};
|
|
31
|
+
__export(promotion_exports, {
|
|
32
|
+
BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
|
|
33
|
+
PromotionAdapter: () => import_adapter.PromotionAdapter,
|
|
34
|
+
PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
|
|
35
|
+
X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
|
|
36
|
+
default: () => import_adapter2.default
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(promotion_exports);
|
|
39
|
+
var import_evaluator = require("./evaluator");
|
|
40
|
+
var import_adapter = require("./adapter");
|
|
41
|
+
var import_adapter2 = __toESM(require("./adapter"));
|
|
42
|
+
var import_examples = require("./examples");
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
BUY_X_GET_Y_FREE_STRATEGY,
|
|
46
|
+
PromotionAdapter,
|
|
47
|
+
PromotionEvaluator,
|
|
48
|
+
X_ITEMS_FOR_Y_PRICE_STRATEGY
|
|
49
|
+
});
|
|
@@ -227,7 +227,8 @@ function calculateProductsTax(products, taxRate, isPriceIncludeTax) {
|
|
|
227
227
|
for (const product of products) {
|
|
228
228
|
const quantity = new import_decimal.default(getSafeNum(product.num));
|
|
229
229
|
const mainTotal = getMainProductPaymentTotal(product);
|
|
230
|
-
const
|
|
230
|
+
const surchargeRoundingRemainder = toDecimal(product.surcharge_rounding_remainder);
|
|
231
|
+
const surchargeFee = toDecimal(product.surcharge_fee).plus(quantity.gt(0) ? surchargeRoundingRemainder.div(quantity) : 0);
|
|
231
232
|
const mainTaxableBase = mainTotal.lte(0) ? surchargeFee : mainTotal.plus(surchargeFee);
|
|
232
233
|
const mainTaxPrecise = calculateSingleItemTax({
|
|
233
234
|
price: mainTaxableBase,
|
|
@@ -329,7 +330,7 @@ function createEmptySalesSummary() {
|
|
|
329
330
|
};
|
|
330
331
|
}
|
|
331
332
|
function calculateSalesSummary(params) {
|
|
332
|
-
var _a;
|
|
333
|
+
var _a, _b;
|
|
333
334
|
const {
|
|
334
335
|
products,
|
|
335
336
|
isPriceIncludeTax,
|
|
@@ -376,6 +377,7 @@ function calculateSalesSummary(params) {
|
|
|
376
377
|
);
|
|
377
378
|
for (let i = 0; i < products.length; i++) {
|
|
378
379
|
products[i].surcharge_fee = ((_a = surchargeServiceItems[i]) == null ? void 0 : _a.surcharge_fee) || 0;
|
|
380
|
+
products[i].surcharge_rounding_remainder = ((_b = surchargeServiceItems[i]) == null ? void 0 : _b.surcharge_rounding_remainder) || 0;
|
|
379
381
|
}
|
|
380
382
|
const hasTaxRate = taxRate !== void 0 && taxRate !== null && taxRate > 0;
|
|
381
383
|
let productTaxFee;
|
|
@@ -746,13 +746,13 @@ var getSurcharge = ({ service, addons, bookingDetail, bookingId }, options) => {
|
|
|
746
746
|
if (open_product !== 0) {
|
|
747
747
|
if (item.isMain) {
|
|
748
748
|
const originSurchargeFee = new import_decimal.default(item.item.surcharge_fee || 0);
|
|
749
|
-
const surchargeFee = originSurchargeFee.plus(itemSurcharge).plus(fixedSurcharge).toDecimalPlaces(2, import_decimal.default.
|
|
749
|
+
const surchargeFee = originSurchargeFee.plus(itemSurcharge).plus(fixedSurcharge).toDecimalPlaces(2, import_decimal.default.ROUND_DOWN).toNumber();
|
|
750
750
|
productTotalSurcharge = productTotalSurcharge.plus(new import_decimal.default(surchargeFee).times(itemQuantity).toNumber());
|
|
751
751
|
item.item.surcharge_fee = surchargeFee;
|
|
752
752
|
item.item.relation_surcharge_ids = [...((_c = item.item) == null ? void 0 : _c.relation_surcharge_ids) || [], id];
|
|
753
753
|
} else {
|
|
754
754
|
const originSurchargeFee = new import_decimal.default(item.item.surcharge_fee || 0);
|
|
755
|
-
const surchargeFee = originSurchargeFee.plus(itemSurcharge).plus(fixedSurcharge).toDecimalPlaces(2, import_decimal.default.
|
|
755
|
+
const surchargeFee = originSurchargeFee.plus(itemSurcharge).plus(fixedSurcharge).toDecimalPlaces(2, import_decimal.default.ROUND_DOWN).toNumber();
|
|
756
756
|
productTotalSurcharge = productTotalSurcharge.plus(new import_decimal.default(surchargeFee).times(itemQuantity).toNumber());
|
|
757
757
|
item.item.surcharge_fee = surchargeFee;
|
|
758
758
|
item.item.relation_surcharge_ids = [...((_d = item.item) == null ? void 0 : _d.relation_surcharge_ids) || [], id];
|