@artisan-commerce/analytics-web 0.2.0-canary.62 → 0.2.0-canary.64
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/CHANGELOG.md +16 -0
- package/dist/bundle.cjs.js +28 -5
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.esm.js +28 -5
- package/dist/bundle.esm.js.map +1 -1
- package/dist/bundle.umd.js +28 -5
- package/dist/bundle.umd.js.map +1 -1
- package/package.json +5 -5
package/dist/bundle.umd.js
CHANGED
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
|
|
42
42
|
var name = "@artisan-commerce/analytics-web";
|
|
43
43
|
var description = "Artisn commerce analytics web library";
|
|
44
|
-
var version = "0.2.0-canary.
|
|
44
|
+
var version = "0.2.0-canary.63";
|
|
45
45
|
var main = "./dist/bundle.cjs.js";
|
|
46
46
|
var module = "./dist/bundle.esm.js";
|
|
47
47
|
var types = "./dist/bundle.d.ts";
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
};
|
|
84
84
|
var devDependencies = {
|
|
85
85
|
"@artisan-commerce/products": "0.9.0-canary.40",
|
|
86
|
-
"@artisan-commerce/shopping-cart": "0.12.0-canary.
|
|
86
|
+
"@artisan-commerce/shopping-cart": "0.12.0-canary.60",
|
|
87
87
|
"@artisan-commerce/types": "0.14.0-canary.31"
|
|
88
88
|
};
|
|
89
89
|
var peerDependencies = {
|
|
@@ -1651,13 +1651,16 @@ ${key}: ${value}`;
|
|
|
1651
1651
|
}
|
|
1652
1652
|
const benefitsValues = Object.values(benefits);
|
|
1653
1653
|
return benefitsValues.reduce((acc, benefit) => {
|
|
1654
|
-
if (benefit.type === "
|
|
1655
|
-
return
|
|
1654
|
+
if (benefit.type === "DISCOUNT_PERCENTAGE" && benefit.discountPercentage) {
|
|
1655
|
+
return applyBenefitByDiscountPercentage(benefit, acc, additionalInfo);
|
|
1656
|
+
}
|
|
1657
|
+
if (benefit.type === "DISCOUNT_FIXED" && benefit.discountFixed) {
|
|
1658
|
+
return applyBenefitByDiscountFixed(benefit, acc, additionalInfo);
|
|
1656
1659
|
}
|
|
1657
1660
|
return acc;
|
|
1658
1661
|
}, shoppingCartTotals);
|
|
1659
1662
|
};
|
|
1660
|
-
const
|
|
1663
|
+
const applyBenefitByDiscountPercentage = (benefit, shoppingCartTotals, additionalInfo) => {
|
|
1661
1664
|
const { subtotal, total: prevTotal } = shoppingCartTotals;
|
|
1662
1665
|
const { totalDiscounts: prevTotalDiscounts } = shoppingCartTotals;
|
|
1663
1666
|
const discountPercentage = benefit.discountPercentage * 0.01;
|
|
@@ -1680,6 +1683,26 @@ ${key}: ${value}`;
|
|
|
1680
1683
|
total: newTotal
|
|
1681
1684
|
});
|
|
1682
1685
|
};
|
|
1686
|
+
const applyBenefitByDiscountFixed = (benefit, shoppingCartTotals, additionalInfo) => {
|
|
1687
|
+
const { total: prevTotal } = shoppingCartTotals;
|
|
1688
|
+
const { totalDiscounts: prevTotalDiscounts } = shoppingCartTotals;
|
|
1689
|
+
const discountFixed = Number(benefit.discountFixed);
|
|
1690
|
+
if (typeof (additionalInfo == null ? void 0 : additionalInfo.copayment) !== "undefined") {
|
|
1691
|
+
const copayment = additionalInfo == null ? void 0 : additionalInfo.copayment;
|
|
1692
|
+
const newTotalDiscounts2 = prevTotalDiscounts !== null ? prevTotalDiscounts + discountFixed : discountFixed;
|
|
1693
|
+
const newTotal2 = (copayment - discountFixed).toFixed(4);
|
|
1694
|
+
return __spreadProps$c$1(__spreadValues$g$1({}, shoppingCartTotals), {
|
|
1695
|
+
totalDiscounts: newTotalDiscounts2,
|
|
1696
|
+
total: Number(newTotal2)
|
|
1697
|
+
});
|
|
1698
|
+
}
|
|
1699
|
+
const newTotalDiscounts = prevTotalDiscounts !== null ? prevTotalDiscounts + discountFixed : discountFixed;
|
|
1700
|
+
const newTotal = prevTotal - discountFixed;
|
|
1701
|
+
return __spreadProps$c$1(__spreadValues$g$1({}, shoppingCartTotals), {
|
|
1702
|
+
totalDiscounts: newTotalDiscounts,
|
|
1703
|
+
total: newTotal
|
|
1704
|
+
});
|
|
1705
|
+
};
|
|
1683
1706
|
|
|
1684
1707
|
const isBaseProduct = (product) => {
|
|
1685
1708
|
const { attributes, description, name } = product;
|