@artisan-commerce/analytics-web 0.2.0-canary.67 → 0.2.0-canary.69
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 +22 -11
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.esm.js +22 -11
- package/dist/bundle.esm.js.map +1 -1
- package/dist/bundle.umd.js +22 -11
- package/dist/bundle.umd.js.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.2.0-canary.69](https://bitbucket.org/tradesystem/artisn_sdk/compare/@artisan-commerce/analytics-web@0.2.0-canary.68...@artisan-commerce/analytics-web@0.2.0-canary.69) (2022-04-05)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @artisan-commerce/analytics-web
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.2.0-canary.68](https://bitbucket.org/tradesystem/artisn_sdk/compare/@artisan-commerce/analytics-web@0.2.0-canary.67...@artisan-commerce/analytics-web@0.2.0-canary.68) (2022-03-07)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @artisan-commerce/analytics-web
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## [0.2.0-canary.67](https://bitbucket.org/tradesystem/artisn_sdk/compare/@artisan-commerce/analytics-web@0.2.0-canary.66...@artisan-commerce/analytics-web@0.2.0-canary.67) (2022-02-10)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @artisan-commerce/analytics-web
|
package/dist/bundle.cjs.js
CHANGED
|
@@ -39,7 +39,7 @@ const getState$2 = () => {
|
|
|
39
39
|
|
|
40
40
|
var name = "@artisan-commerce/analytics-web";
|
|
41
41
|
var description = "Artisn commerce analytics web library";
|
|
42
|
-
var version = "0.2.0-canary.
|
|
42
|
+
var version = "0.2.0-canary.68";
|
|
43
43
|
var main = "./dist/bundle.cjs.js";
|
|
44
44
|
var module$1 = "./dist/bundle.esm.js";
|
|
45
45
|
var types = "./dist/bundle.d.ts";
|
|
@@ -80,9 +80,9 @@ var dependencies = {
|
|
|
80
80
|
"snake-case": "^3.0.4"
|
|
81
81
|
};
|
|
82
82
|
var devDependencies = {
|
|
83
|
-
"@artisan-commerce/products": "0.9.0-canary.
|
|
84
|
-
"@artisan-commerce/shopping-cart": "0.12.0-canary.
|
|
85
|
-
"@artisan-commerce/types": "0.14.0-canary.
|
|
83
|
+
"@artisan-commerce/products": "0.9.0-canary.42",
|
|
84
|
+
"@artisan-commerce/shopping-cart": "0.12.0-canary.65",
|
|
85
|
+
"@artisan-commerce/types": "0.14.0-canary.33"
|
|
86
86
|
};
|
|
87
87
|
var peerDependencies = {
|
|
88
88
|
"@artisan-commerce/products": "*",
|
|
@@ -1614,7 +1614,7 @@ const getShoppingCartTotal = (shoppingCart, config = {}) => {
|
|
|
1614
1614
|
total: acc.total + normal
|
|
1615
1615
|
};
|
|
1616
1616
|
}, initialValue);
|
|
1617
|
-
const totalsWithBenefits = applyBenefits(shoppingCart
|
|
1617
|
+
const totalsWithBenefits = applyBenefits(shoppingCart, totals);
|
|
1618
1618
|
const { shippingCost = shoppingCart.shippingCost } = config;
|
|
1619
1619
|
if (!shippingCost) {
|
|
1620
1620
|
return totalsWithBenefits;
|
|
@@ -1644,14 +1644,16 @@ const getShoppingCartProducts = (shoppingCart, storeId) => {
|
|
|
1644
1644
|
return [...acc, ...products];
|
|
1645
1645
|
}, []);
|
|
1646
1646
|
};
|
|
1647
|
-
const applyBenefits = (
|
|
1647
|
+
const applyBenefits = (shoppingCart, shoppingCartTotals) => {
|
|
1648
|
+
const additionalInfo = shoppingCart["additional_info"];
|
|
1649
|
+
const benefits = shoppingCart["benefits"];
|
|
1648
1650
|
if (!benefits) {
|
|
1649
1651
|
return shoppingCartTotals;
|
|
1650
1652
|
}
|
|
1651
1653
|
const benefitsValues = Object.values(benefits);
|
|
1652
1654
|
return benefitsValues.reduce((acc, benefit) => {
|
|
1653
1655
|
if (benefit.type === "DISCOUNT_PERCENTAGE" && benefit.discountPercentage) {
|
|
1654
|
-
return applyBenefitByDiscountPercentage(benefit, acc,
|
|
1656
|
+
return applyBenefitByDiscountPercentage(benefit, acc, shoppingCart);
|
|
1655
1657
|
}
|
|
1656
1658
|
if (benefit.type === "DISCOUNT_FIXED" && benefit.discountFixed) {
|
|
1657
1659
|
return applyBenefitByDiscountFixed(benefit, acc, additionalInfo);
|
|
@@ -1659,13 +1661,23 @@ const applyBenefits = (additionalInfo, benefits, shoppingCartTotals) => {
|
|
|
1659
1661
|
return acc;
|
|
1660
1662
|
}, shoppingCartTotals);
|
|
1661
1663
|
};
|
|
1662
|
-
const applyBenefitByDiscountPercentage = (benefit, shoppingCartTotals,
|
|
1664
|
+
const applyBenefitByDiscountPercentage = (benefit, shoppingCartTotals, shoppingCart) => {
|
|
1665
|
+
let taxValue = 0;
|
|
1666
|
+
const additionalInfo = shoppingCart["additional_info"];
|
|
1667
|
+
const { billTotal } = shoppingCart;
|
|
1668
|
+
const { NORMAL } = billTotal;
|
|
1669
|
+
const { discounts } = NORMAL != null ? NORMAL : {};
|
|
1670
|
+
discounts == null ? void 0 : discounts.forEach((discount) => {
|
|
1671
|
+
if (discount.taxValue) {
|
|
1672
|
+
taxValue += discount.taxValue;
|
|
1673
|
+
}
|
|
1674
|
+
});
|
|
1663
1675
|
const { subtotal, total: prevTotal } = shoppingCartTotals;
|
|
1664
1676
|
const { totalDiscounts: prevTotalDiscounts } = shoppingCartTotals;
|
|
1665
1677
|
const discountPercentage = benefit.discountPercentage * 0.01;
|
|
1666
1678
|
if (typeof (additionalInfo == null ? void 0 : additionalInfo.copayment) !== "undefined") {
|
|
1667
1679
|
const copayment = additionalInfo == null ? void 0 : additionalInfo.copayment;
|
|
1668
|
-
const totalDiscount2 = copayment * discountPercentage;
|
|
1680
|
+
const totalDiscount2 = copayment * discountPercentage + taxValue;
|
|
1669
1681
|
const newTotalDiscounts2 = prevTotalDiscounts !== null ? prevTotalDiscounts + totalDiscount2 : totalDiscount2;
|
|
1670
1682
|
const newTotal2 = (copayment - totalDiscount2).toFixed(4);
|
|
1671
1683
|
return __spreadProps$c$1(__spreadValues$g$1({}, shoppingCartTotals), {
|
|
@@ -1673,8 +1685,7 @@ const applyBenefitByDiscountPercentage = (benefit, shoppingCartTotals, additiona
|
|
|
1673
1685
|
total: Number(newTotal2)
|
|
1674
1686
|
});
|
|
1675
1687
|
}
|
|
1676
|
-
const
|
|
1677
|
-
const totalDiscount = newSubtotal;
|
|
1688
|
+
const totalDiscount = subtotal * discountPercentage + taxValue;
|
|
1678
1689
|
const newTotalDiscounts = prevTotalDiscounts !== null ? prevTotalDiscounts + totalDiscount : totalDiscount;
|
|
1679
1690
|
const newTotal = prevTotal - totalDiscount;
|
|
1680
1691
|
return __spreadProps$c$1(__spreadValues$g$1({}, shoppingCartTotals), {
|