foodbot-cart-calculations 1.0.1 → 1.0.2

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.
@@ -56,21 +56,21 @@ function calculateTax2(cart, texSettings, taxType) {
56
56
  total = +element.item_price;
57
57
 
58
58
  if (element.isPackage == 1) {
59
- let result = await calculatePackageItemTax(cart, itemIndex, element, texSettings, afterDiscount);
59
+ let result = await calculatePackageItemTax(cart, itemIndex, element, texSettings, afterDiscount,taxType);
60
60
  cart = result.cart;
61
61
  element = result.element;
62
62
  } else {
63
- let result = await calculateItemTax(cart, itemIndex, element, texSettings, afterDiscount);
63
+ let result = await calculateItemTax(cart, itemIndex, element, texSettings, afterDiscount,taxType);
64
64
  cart = result.cart;
65
65
  element = result.element;
66
66
  }
67
67
 
68
68
  if (element.isPackage == 1) {
69
- let result = await calculatePackageModiTax(cart, itemIndex, element, texSettings, afterDiscount);
69
+ let result = await calculatePackageModiTax(cart, itemIndex, element, texSettings, afterDiscount,taxType);
70
70
  cart = result.cart;
71
71
  element = result.element;
72
72
  } else {
73
- let result = await calculateModiTax(cart, itemIndex, element, texSettings, afterDiscount);
73
+ let result = await calculateModiTax(cart, itemIndex, element, texSettings, afterDiscount,taxType);
74
74
  cart = result.cart;
75
75
  element = result.element;
76
76
  }
@@ -87,11 +87,11 @@ function calculateTax2(cart, texSettings, taxType) {
87
87
  });
88
88
  }
89
89
 
90
- function calculateItemTax(cart, itemIndex, element, tax_settings, afterDicsount) {
90
+ function calculateItemTax(cart, itemIndex, element, tax_settings, afterDicsount,taxType) {
91
91
  return new Promise(async (resolve, reject) => {
92
92
  getTaxSettings2(element.tax_id, tax_settings, element.ieps_tax).then(async (itemTaxs) => {
93
93
  let lastPrice = afterDicsount
94
- getBeforeTaxPriceOfItem(itemTaxs, lastPrice).then((resp) => {
94
+ getBeforeTaxPriceOfItem(itemTaxs, lastPrice,taxType).then((resp) => {
95
95
  lastPrice = +resp.beforeTax;
96
96
  let itemTotalTax = 0;
97
97
 
@@ -129,7 +129,7 @@ function calculateItemTax(cart, itemIndex, element, tax_settings, afterDicsount)
129
129
  })
130
130
  })
131
131
  }
132
- function calculatePackageItemTax(cart, itemIndex, element, tax_settings, afterDicsount) {
132
+ function calculatePackageItemTax(cart, itemIndex, element, tax_settings, afterDicsount,taxType) {
133
133
  return new Promise(async (resolve, reject) => {
134
134
  let itemTotalTax = 0;
135
135
  element.package_items.forEach((packageItem, packageItemIndex) => {
@@ -158,7 +158,7 @@ function calculatePackageItemTax(cart, itemIndex, element, tax_settings, afterDi
158
158
  let lastPrice = afterDicsountPackage
159
159
  let itemtaxAmount = 0;
160
160
 
161
- await getBeforeTaxPriceOfItem(itemTaxs, lastPrice).then(async (resp) => {
161
+ await getBeforeTaxPriceOfItem(itemTaxs, lastPrice,taxType).then(async (resp) => {
162
162
  lastPrice = +resp.beforeTax;
163
163
 
164
164
  itemTaxs.forEach(async (itemTaxArray, itemTaxIndex) => {
@@ -208,7 +208,7 @@ function calculatePackageItemTax(cart, itemIndex, element, tax_settings, afterDi
208
208
  })
209
209
  })
210
210
  }
211
- function calculateModiTax(cart, itemIndex, element, tax_settings, afterDicsount) {
211
+ function calculateModiTax(cart, itemIndex, element, tax_settings, afterDicsount,taxType) {
212
212
  return new Promise(async (resolve, reject) => {
213
213
  if (element && element.item_modifiers && element.item_modifiers.length > 0) {
214
214
  let itemModiTotalTax = 0
@@ -250,7 +250,7 @@ function calculateModiTax(cart, itemIndex, element, tax_settings, afterDicsount)
250
250
 
251
251
  let lastPrice = afterDicsount
252
252
  if (modiItemTaxs.length > 0) {
253
- await getBeforeTaxPriceOfItem(modiItemTaxs, lastPrice).then((resp) => {
253
+ await getBeforeTaxPriceOfItem(modiItemTaxs, lastPrice,taxType).then((resp) => {
254
254
  lastPrice = +resp.beforeTax;
255
255
 
256
256
  modiItemTaxs.forEach(async (modiItemTax, modiTaxItemIndex) => {
@@ -307,7 +307,7 @@ function calculateModiTax(cart, itemIndex, element, tax_settings, afterDicsount)
307
307
  }
308
308
  })
309
309
  }
310
- function calculatePackageModiTax(cart, itemIndex, element, tax_settings, afterDicsount) {
310
+ function calculatePackageModiTax(cart, itemIndex, element, tax_settings, afterDicsount,taxType) {
311
311
  return new Promise(async (resolve, reject) => {
312
312
  element.package_items.forEach((packageItem, packageItemIndex) => {
313
313
  element.package_items[packageItemIndex].tax_amount_modifier = 0
@@ -351,7 +351,7 @@ function calculatePackageModiTax(cart, itemIndex, element, tax_settings, afterDi
351
351
  let lastPrice = afterDicsount
352
352
 
353
353
  if (modiItemTaxs.length > 0) {
354
- await getBeforeTaxPriceOfItem(modiItemTaxs, lastPrice).then((resp) => {
354
+ await getBeforeTaxPriceOfItem(modiItemTaxs, lastPrice,taxType).then((resp) => {
355
355
  lastPrice = +resp.beforeTax;
356
356
  modiItemTaxs.forEach(async (modiItemTax, modiTaxItemIndex) => {
357
357
 
@@ -492,9 +492,8 @@ function isJson(str) {
492
492
  return true;
493
493
  }
494
494
 
495
- async function getBeforeTaxPriceOfItem(taxes, price) {
495
+ async function getBeforeTaxPriceOfItem(taxes, price,taxType) {
496
496
  return new Promise((resolve, reject) => {
497
- let taxType = this.taxType;
498
497
  let beforeTax = parseFloat(price);
499
498
  let taxRate = 0;
500
499
  let taxAmount = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foodbot-cart-calculations",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
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": {