@artisan-commerce/analytics-rn 0.3.0-canary.69 → 0.3.0-canary.70
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 +8 -0
- package/dist/bundle.cjs.js +23 -12
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.esm.js +23 -12
- package/dist/bundle.esm.js.map +1 -1
- package/package.json +5 -5
package/dist/bundle.esm.js
CHANGED
|
@@ -40,7 +40,7 @@ const getState$2 = () => {
|
|
|
40
40
|
|
|
41
41
|
var name = "@artisan-commerce/analytics-rn";
|
|
42
42
|
var description = "Artisn commerce analytics react native library";
|
|
43
|
-
var version = "0.3.0-canary.
|
|
43
|
+
var version = "0.3.0-canary.70";
|
|
44
44
|
var main = "./dist/bundle.esm.js";
|
|
45
45
|
var module = "./dist/bundle.esm.js";
|
|
46
46
|
var types = "./dist/bundle.d.ts";
|
|
@@ -82,9 +82,9 @@ var dependencies = {
|
|
|
82
82
|
"snake-case": "^3.0.4"
|
|
83
83
|
};
|
|
84
84
|
var devDependencies = {
|
|
85
|
-
"@artisan-commerce/products": "0.9.0-canary.
|
|
86
|
-
"@artisan-commerce/shopping-cart": "0.12.0-canary.
|
|
87
|
-
"@artisan-commerce/types": "0.14.0-canary.
|
|
85
|
+
"@artisan-commerce/products": "0.9.0-canary.43",
|
|
86
|
+
"@artisan-commerce/shopping-cart": "0.12.0-canary.66",
|
|
87
|
+
"@artisan-commerce/types": "0.14.0-canary.34",
|
|
88
88
|
"@babel/core": "^7.13.15",
|
|
89
89
|
"@babel/preset-env": "^7.10.4",
|
|
90
90
|
"@babel/preset-react": "^7.10.4",
|
|
@@ -103,7 +103,7 @@ var peerDependencies = {
|
|
|
103
103
|
react: ">=16.8.6",
|
|
104
104
|
"react-native-fbsdk-next": "*"
|
|
105
105
|
};
|
|
106
|
-
var gitHead = "
|
|
106
|
+
var gitHead = "bd05f9bb540ac313d058fb96936fa3810f7cc103";
|
|
107
107
|
var packageJSON = {
|
|
108
108
|
name: name,
|
|
109
109
|
description: description,
|
|
@@ -1473,7 +1473,7 @@ const getShoppingCartTotal = (shoppingCart, config = {}) => {
|
|
|
1473
1473
|
total: acc.total + normal
|
|
1474
1474
|
};
|
|
1475
1475
|
}, initialValue);
|
|
1476
|
-
const totalsWithBenefits = applyBenefits(shoppingCart
|
|
1476
|
+
const totalsWithBenefits = applyBenefits(shoppingCart, totals);
|
|
1477
1477
|
const { shippingCost = shoppingCart.shippingCost } = config;
|
|
1478
1478
|
if (!shippingCost) {
|
|
1479
1479
|
return totalsWithBenefits;
|
|
@@ -1503,14 +1503,16 @@ const getShoppingCartProducts = (shoppingCart, storeId) => {
|
|
|
1503
1503
|
return [...acc, ...products];
|
|
1504
1504
|
}, []);
|
|
1505
1505
|
};
|
|
1506
|
-
const applyBenefits = (
|
|
1506
|
+
const applyBenefits = (shoppingCart, shoppingCartTotals) => {
|
|
1507
|
+
const additionalInfo = shoppingCart["additional_info"];
|
|
1508
|
+
const benefits = shoppingCart["benefits"];
|
|
1507
1509
|
if (!benefits) {
|
|
1508
1510
|
return shoppingCartTotals;
|
|
1509
1511
|
}
|
|
1510
1512
|
const benefitsValues = Object.values(benefits);
|
|
1511
1513
|
return benefitsValues.reduce((acc, benefit) => {
|
|
1512
1514
|
if (benefit.type === "DISCOUNT_PERCENTAGE" && benefit.discountPercentage) {
|
|
1513
|
-
return applyBenefitByDiscountPercentage(benefit, acc,
|
|
1515
|
+
return applyBenefitByDiscountPercentage(benefit, acc, shoppingCart);
|
|
1514
1516
|
}
|
|
1515
1517
|
if (benefit.type === "DISCOUNT_FIXED" && benefit.discountFixed) {
|
|
1516
1518
|
return applyBenefitByDiscountFixed(benefit, acc, additionalInfo);
|
|
@@ -1518,13 +1520,23 @@ const applyBenefits = (additionalInfo, benefits, shoppingCartTotals) => {
|
|
|
1518
1520
|
return acc;
|
|
1519
1521
|
}, shoppingCartTotals);
|
|
1520
1522
|
};
|
|
1521
|
-
const applyBenefitByDiscountPercentage = (benefit, shoppingCartTotals,
|
|
1523
|
+
const applyBenefitByDiscountPercentage = (benefit, shoppingCartTotals, shoppingCart) => {
|
|
1524
|
+
let taxValue = 0;
|
|
1525
|
+
const additionalInfo = shoppingCart["additional_info"];
|
|
1526
|
+
const { billTotal } = shoppingCart;
|
|
1527
|
+
const { NORMAL } = billTotal;
|
|
1528
|
+
const { discounts } = NORMAL != null ? NORMAL : {};
|
|
1529
|
+
discounts == null ? void 0 : discounts.forEach((discount) => {
|
|
1530
|
+
if (discount.taxValue) {
|
|
1531
|
+
taxValue += discount.taxValue;
|
|
1532
|
+
}
|
|
1533
|
+
});
|
|
1522
1534
|
const { subtotal, total: prevTotal } = shoppingCartTotals;
|
|
1523
1535
|
const { totalDiscounts: prevTotalDiscounts } = shoppingCartTotals;
|
|
1524
1536
|
const discountPercentage = benefit.discountPercentage * 0.01;
|
|
1525
1537
|
if (typeof (additionalInfo == null ? void 0 : additionalInfo.copayment) !== "undefined") {
|
|
1526
1538
|
const copayment = additionalInfo == null ? void 0 : additionalInfo.copayment;
|
|
1527
|
-
const totalDiscount2 = copayment * discountPercentage;
|
|
1539
|
+
const totalDiscount2 = copayment * discountPercentage + taxValue;
|
|
1528
1540
|
const newTotalDiscounts2 = prevTotalDiscounts !== null ? prevTotalDiscounts + totalDiscount2 : totalDiscount2;
|
|
1529
1541
|
const newTotal2 = (copayment - totalDiscount2).toFixed(4);
|
|
1530
1542
|
return __spreadProps$c$1(__spreadValues$g$1({}, shoppingCartTotals), {
|
|
@@ -1532,8 +1544,7 @@ const applyBenefitByDiscountPercentage = (benefit, shoppingCartTotals, additiona
|
|
|
1532
1544
|
total: Number(newTotal2)
|
|
1533
1545
|
});
|
|
1534
1546
|
}
|
|
1535
|
-
const
|
|
1536
|
-
const totalDiscount = newSubtotal;
|
|
1547
|
+
const totalDiscount = subtotal * discountPercentage + taxValue;
|
|
1537
1548
|
const newTotalDiscounts = prevTotalDiscounts !== null ? prevTotalDiscounts + totalDiscount : totalDiscount;
|
|
1538
1549
|
const newTotal = prevTotal - totalDiscount;
|
|
1539
1550
|
return __spreadProps$c$1(__spreadValues$g$1({}, shoppingCartTotals), {
|