@pisell/pisellos 0.0.148 → 0.0.149
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.
|
@@ -28,6 +28,7 @@ import { BaseModule } from "../../modules/BaseModule";
|
|
|
28
28
|
import { ShopDiscountHooks } from "./types";
|
|
29
29
|
import { DiscountModule } from "../../modules/Discount";
|
|
30
30
|
import { RulesModule } from "../../modules/Rules";
|
|
31
|
+
import Decimal from 'decimal.js';
|
|
31
32
|
export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
32
33
|
_inherits(ShopDiscountImpl, _BaseModule);
|
|
33
34
|
var _super = _createSuper(ShopDiscountImpl);
|
|
@@ -447,7 +448,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
447
448
|
});
|
|
448
449
|
if (index !== -1) {
|
|
449
450
|
editModeDiscountList[index] = _objectSpread(_objectSpread({}, editModeDiscountList[index]), {}, {
|
|
450
|
-
amount: discount.amount
|
|
451
|
+
amount: new Decimal(discount.amount || 0).plus(new Decimal(editModeDiscountList[index].amount || 0)).toNumber(),
|
|
452
|
+
savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.num) || 1).plus(new Decimal(editModeDiscountList[index].savedAmount || 0)).toNumber()
|
|
451
453
|
});
|
|
452
454
|
} else {
|
|
453
455
|
var _discount$discount2, _discount$discount3, _discount$discount4;
|
|
@@ -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/solution/ShopDiscount/index.ts
|
|
@@ -27,6 +37,7 @@ var import_BaseModule = require("../../modules/BaseModule");
|
|
|
27
37
|
var import_types = require("./types");
|
|
28
38
|
var import_Discount = require("../../modules/Discount");
|
|
29
39
|
var import_Rules = require("../../modules/Rules");
|
|
40
|
+
var import_decimal = __toESM(require("decimal.js"));
|
|
30
41
|
var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
31
42
|
constructor(name, version) {
|
|
32
43
|
super(name, version);
|
|
@@ -283,7 +294,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
283
294
|
if (index !== -1) {
|
|
284
295
|
editModeDiscountList[index] = {
|
|
285
296
|
...editModeDiscountList[index],
|
|
286
|
-
amount: discount.amount
|
|
297
|
+
amount: new import_decimal.default(discount.amount || 0).plus(new import_decimal.default(editModeDiscountList[index].amount || 0)).toNumber(),
|
|
298
|
+
savedAmount: new import_decimal.default(discount.amount || 0).times((product == null ? void 0 : product.num) || 1).plus(new import_decimal.default(editModeDiscountList[index].savedAmount || 0)).toNumber()
|
|
287
299
|
};
|
|
288
300
|
} else {
|
|
289
301
|
editModeDiscountList.push({
|