foodbot-cart-calculations 1.0.7 → 1.0.9

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/calculations.js CHANGED
@@ -78,7 +78,7 @@ function applyDistribution(body) {
78
78
  mainCart.final_amount = parseFloat(mainCart.final_amount) + parseFloat(tipValue);
79
79
  mainCart.cash_expected = parseFloat(mainCart.cash_expected) + parseFloat(tipValue);
80
80
 
81
- mainCart.order_items.discount = parseFloat(mainCart.order_items.discount) + parseFloat(mainCart.store_value)
81
+ mainCart.order_items.discount = parseFloat(mainCart.order_items.discount) ;
82
82
  mainCart.order_items.discount = parseFloat(mainCart.order_items.discount).toFixed(2)
83
83
 
84
84
  mainCart.discount = mainCart.order_items.discount;
@@ -35,7 +35,7 @@ function getPointsDiscount(cartObject, points, userDetails) {
35
35
  if (!points) {
36
36
  resolve(0);
37
37
  } else {
38
- let pointsAmount = '0';
38
+ let pointsAmount = 0;
39
39
  let count = 0;
40
40
  let storeAmount = points.store_value;
41
41
  let indexes = [];
@@ -74,7 +74,7 @@ function getPointsDiscount(cartObject, points, userDetails) {
74
74
 
75
75
  if (count == carts.length) {
76
76
  let singlePriceDiscount = pointsAmount / itemsTotal;
77
- singlePriceDiscount = parseFloat(singlePriceDiscount).toFixed(6);
77
+ singlePriceDiscount = (itemsTotal && itemsTotal > 0)?parseFloat(singlePriceDiscount).toFixed(6):0;
78
78
 
79
79
  let storeValue = 0
80
80
  let itemDiscount = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foodbot-cart-calculations",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "Package for cart calculations in which it performs discount distribution and tax distribution on order",
5
5
  "main": "index.js",
6
6
  "scripts": {