foodbot-cart-calculations 1.0.27 → 1.0.28

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
@@ -68,13 +68,9 @@ function applyDistribution(body) {
68
68
  }
69
69
  mainCart.order_items = taxData
70
70
 
71
-
72
71
  let delivery_cost = body.delivery_cost?body.delivery_cost:0;
73
72
  let service_amount = body.service_amount?body.service_amount:0;
74
73
 
75
- mainCart.final_amount = parseFloat(mainCart.final_amount) + parseFloat(delivery_cost) + parseFloat(service_amount);
76
- mainCart.cash_expected = parseFloat(mainCart.cash_expected) + parseFloat(delivery_cost) + parseFloat(service_amount);
77
-
78
74
  let tipValue = body.tip_value?body.tip_value:0;
79
75
 
80
76
  if (body.tip_type && body.tip_type == 'percentage') {
@@ -82,6 +78,11 @@ function applyDistribution(body) {
82
78
  tipValue = parseFloat(tipValue).toFixed(2)
83
79
  }
84
80
 
81
+ mainCart.tip_amount = parseFloat(tipValue).toFixed(2);
82
+
83
+ mainCart.final_amount = parseFloat(mainCart.final_amount) + parseFloat(delivery_cost) + parseFloat(service_amount);
84
+ mainCart.cash_expected = parseFloat(mainCart.cash_expected) + parseFloat(delivery_cost) + parseFloat(service_amount);
85
+
85
86
  taxData.total_after_tax = parseFloat(taxData.total_after_tax) + parseFloat(tipValue);
86
87
  taxData.total_after_tax = parseFloat(taxData.total_after_tax).toFixed(2);
87
88
 
@@ -96,7 +97,6 @@ function applyDistribution(body) {
96
97
 
97
98
  mainCart.discount = mainCart.order_items.discount;
98
99
  mainCart.order_items.total=parseFloat(mainCart.order_items.total).toFixed(2)
99
-
100
100
 
101
101
  resolve(mainCart);
102
102
  }).catch(err => {
@@ -439,7 +439,7 @@ function getOfferDetails(carts, offer = []) {
439
439
  const offerBuyProducts = offer.offer_products.offer_buy_products.map(Number);
440
440
  const offerGetProducts = offer.offer_products.offer_get_products.map(Number);
441
441
  addItemQuantity(carts.item_details, offer).then((data) => {
442
- const descending = data.sort((a, b) => (parseInt(b.amount) > parseInt(a.amount)) ? -1 : 1);
442
+ const descending = data.sort((a, b) => (parseInt(b.amount) > parseInt(a.amount)) ? 1 : -1);
443
443
  let total = 0
444
444
  let buyItemAmount=0;
445
445
  let buyItemss =[]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foodbot-cart-calculations",
3
- "version": "1.0.27",
3
+ "version": "1.0.28",
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": {