foodbot-cart-calculations 1.0.21 → 1.0.22

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
@@ -86,6 +86,11 @@ function applyDistribution(body) {
86
86
 
87
87
  mainCart.discount = mainCart.order_items.discount;
88
88
  mainCart.order_items.total=parseFloat(mainCart.order_items.total).toFixed(2)
89
+
90
+ let delivery_cost = body.delivery_cost?body.delivery_cost:0;
91
+ let service_amount = body.service_amount?body.service_amount:0;
92
+ mainCart.final_amount = parseFloat(mainCart.final_amount) + parseFloat(delivery_cost) + parseFloat(service_amount);
93
+ mainCart.cash_expected = parseFloat(mainCart.cash_expected) + parseFloat(delivery_cost) + parseFloat(service_amount);
89
94
  resolve(mainCart);
90
95
  }).catch(err => {
91
96
  reject(err);
@@ -31,6 +31,7 @@ function offerCalculation(carts, offer) {
31
31
  if (offer && offer.offer_discount_type && offer.offer_discount_type == 'buy_x_get_y') {
32
32
  getOfferDetails(carts, offer).then(res => {
33
33
  carts = res
34
+ console.log("res",res)
34
35
  if (offer && offer.oo_offer_type == 'percentage' && offer.discount_roundoff && offer.discount_roundoff == 1) {
35
36
 
36
37
  // offer.oo_offer_types = JSON.parse(JSON.stringify(offer.oo_offer_type))
@@ -438,9 +439,7 @@ function getOfferDetails(carts, offer = []) {
438
439
  const offerBuyProducts = offer.offer_products.offer_buy_products.map(Number);
439
440
  const offerGetProducts = offer.offer_products.offer_get_products.map(Number);
440
441
  addItemQuantity(carts.item_details, offer).then((data) => {
441
-
442
- const descending = data.sort((a, b) => (parseInt(b.amount) < parseInt(a.amount)) ? -1 : 1);
443
- // console.log("data where we sort based on amount",JSON.stringify(descending))
442
+ const descending = data.sort((a, b) => (parseInt(b.amount) > parseInt(a.amount)) ? -1 : 1);
444
443
  let total = 0
445
444
  let buyItemAmount=0;
446
445
  let buyItemss =[]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foodbot-cart-calculations",
3
- "version": "1.0.21",
3
+ "version": "1.0.22",
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": {