foodbot-cart-calculations 1.0.54 → 1.0.56

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);
@@ -182,7 +182,7 @@ function calculatePackageItemTax(cart, itemIndex, element, tax_settings, afterDi
182
182
  let pointsDisouuntPackage = (packageItem.points_discount) ? packageItem.points_discount : 0
183
183
 
184
184
  let defaultComboDiscount = packageItem.default_combo_discount ? packageItem.default_combo_discount : 0
185
- let afterDicsountPackage = packageItem.price * (packageItem.quantity * element.quantity) - promoDiscountPackage
185
+ let afterDicsountPackage = packageItem.price * packageItem.quantity - promoDiscountPackage
186
186
 
187
187
  afterDicsountPackage = parseFloat(afterDicsountPackage).toFixed(2)
188
188
  afterDicsountPackage = afterDicsountPackage - pointsDisouuntPackage
@@ -201,7 +201,7 @@ function calculatePackageItemTax(cart, itemIndex, element, tax_settings, afterDi
201
201
 
202
202
  let lastPrice = afterDicsountPackage
203
203
  let itemtaxAmount = 0;
204
- await getBeforeTaxPriceOfItem(itemTaxs, lastPrice, taxType, (packageItem.quantity * element.quantity)).then(async (resp) => {
204
+ await getBeforeTaxPriceOfItem(itemTaxs, lastPrice, taxType, packageItem.quantity).then(async (resp) => {
205
205
  lastPrice = resp.beforeTax;
206
206
  let lastPriceIeps = +resp.beforeTaxIeps;
207
207
  let iepsTaxRate = +resp.iepsTaxRate;
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.56",
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": {