foodbot-cart-calculations 1.0.31 → 1.0.33

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.
@@ -76,9 +76,15 @@ function calculateTax2(cart, texSettings, taxType) {
76
76
  if (itemIndex == cart.item_details.length - 1) {
77
77
  cart.cart_total_with_tax = parseFloat(cart.cartTotal) + parseFloat(cart.tax_amount);
78
78
  cart.cart_total_with_tax = parseFloat(cart.cart_total_with_tax).toFixed(2);
79
- setTimeout(() => {
79
+
80
+ await new Promise((resolve) => {
81
+ setTimeout(async () => {
82
+ resolve(); // Resolve after processing all items
83
+ }, 300)});
84
+
85
+ // setTimeout(() => {
80
86
  resolve(cart);
81
- }, 100);
87
+ // }, 500);
82
88
  }
83
89
 
84
90
  });
@@ -381,7 +387,7 @@ function calculatePackageModiTax(cart, itemIndex, element, tax_settings, afterDi
381
387
  let taxId = []
382
388
  let iepsTax;
383
389
  if (modi.is_tax_rate_same == 1) {
384
- if (modi.linked_product && modi.linked_product.product_tax_id) {
390
+ if (modi.linked_product && modi.linked_product.product_tax_id && Array.isArray(modi.linked_product.product_tax_id)) {
385
391
  taxId = modi.linked_product.product_tax_id
386
392
  iepsTax = modi.linked_product.ieps_tax
387
393
  } else {
package/index.js CHANGED
@@ -1,4 +1,7 @@
1
1
  const calculation = require('./calculations');
2
+ // const fs = require('fs');
3
+ // const path = require('path')
4
+
2
5
  async function calculateTax(inputJSON) {
3
6
  return new Promise(async (resolve, reject) => {
4
7
  try {
@@ -359,7 +362,19 @@ async function calculateTax(inputJSON) {
359
362
  // }
360
363
 
361
364
  // calculateTax(json).then(res=>{
362
- // console.log(JSON.stringify(res))
365
+ // // console.log(JSON.stringify(res))
366
+
367
+ // const jsonResponse = JSON.stringify(res, null, 2); // Format the JSON with indentation
368
+ // const filePath = path.join(__dirname, 'response.json'); // File path in the same directory
369
+
370
+ // fs.writeFile(filePath, jsonResponse, 'utf8', err => {
371
+ // if (err) {
372
+ // console.error('Error writing to file:', err);
373
+ // } else {
374
+ // console.log('Response successfully written to response.json');
375
+ // }
376
+ // });
377
+
363
378
  // }).catch(err=>{
364
379
  // console.log(err)
365
380
  // })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foodbot-cart-calculations",
3
- "version": "1.0.31",
3
+ "version": "1.0.33",
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": {