foodbot-cart-calculations 1.0.54 → 1.0.55

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.
@@ -1081,10 +1081,17 @@ function setPackageDefaultDiscount(cart) {
1081
1081
  item.package_items.forEach(function (v) {
1082
1082
  //this commemted code is sceniore when user can also increas item quantity i think which is wrong
1083
1083
  // itemTotal += ((item.quantity * v.quantity) * v.price);
1084
- itemTotal += (item.quantity * (v.quantity * v.price));
1084
+ if(item.quantity > 1){
1085
+ itemTotal += (v.quantity * v.price);
1086
+ }else{
1087
+ itemTotal += (item.quantity * (v.quantity * v.price));
1088
+ }
1085
1089
  })
1086
1090
  let packagePrice = item.quantity * item.item_price;
1091
+ // console.log(packagePrice);
1087
1092
  let totalDiscount = (packagePrice < itemTotal) ? (parseFloat(itemTotal) - parseFloat(packagePrice)).toFixed(2) : 0;
1093
+ // console.log(itemTotal);
1094
+ // console.log(totalDiscount);
1088
1095
  await distributeDiscount(item.package_items, totalDiscount, itemTotal, item.quantity).then(ele => {
1089
1096
  item.package_items = ele;
1090
1097
  if (index == cart.item_details.length - 1) {
@@ -1125,7 +1132,6 @@ function distributeDiscount(packageItems, totalDiscount, itemTotal, quantity) {
1125
1132
  totalApplied = (parseFloat(totalApplied) + parseFloat(discountPerItem)).toFixed(2);
1126
1133
  item.default_combo_discount = parseFloat(discountPerItem).toFixed(2);
1127
1134
  if (index == packageItems.length - 1) {
1128
-
1129
1135
  let remaningOfferAmount = (parseFloat(totalDiscount) - parseFloat(totalApplied)).toFixed(2);
1130
1136
  for (const updateItem of packageItems) {
1131
1137
  let updateDisc = (parseFloat(updateItem.default_combo_discount) + parseFloat(remaningOfferAmount)).toFixed(2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foodbot-cart-calculations",
3
- "version": "1.0.54",
3
+ "version": "1.0.55",
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": {