foodbot-cart-calculations 1.0.30 → 1.0.32
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/functions/pointsCalculation.js +1 -1
- package/functions/taxCalculation.js +10 -2
- package/index.js +16 -1
- package/package.json +1 -1
|
@@ -37,7 +37,7 @@ function getPointsDiscount(cartObject, points, userDetails) {
|
|
|
37
37
|
} else {
|
|
38
38
|
let pointsAmount = 0;
|
|
39
39
|
let count = 0;
|
|
40
|
-
let storeAmount = points.store_value;
|
|
40
|
+
let storeAmount = points.store_value ?? (points.original_store_value ?? 0);
|
|
41
41
|
let indexes = [];
|
|
42
42
|
|
|
43
43
|
if (points.redeem_categories && points.redeem_categories != '') {
|
|
@@ -76,7 +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
|
-
|
|
79
|
+
|
|
80
|
+
await new Promise((resolve) => {
|
|
81
|
+
setTimeout(async () => {
|
|
82
|
+
resolve(); // Resolve after processing all items
|
|
83
|
+
}, 300)});
|
|
84
|
+
|
|
85
|
+
// setTimeout(() => {
|
|
86
|
+
resolve(cart);
|
|
87
|
+
// }, 500);
|
|
80
88
|
}
|
|
81
89
|
|
|
82
90
|
});
|
|
@@ -379,7 +387,7 @@ function calculatePackageModiTax(cart, itemIndex, element, tax_settings, afterDi
|
|
|
379
387
|
let taxId = []
|
|
380
388
|
let iepsTax;
|
|
381
389
|
if (modi.is_tax_rate_same == 1) {
|
|
382
|
-
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)) {
|
|
383
391
|
taxId = modi.linked_product.product_tax_id
|
|
384
392
|
iepsTax = modi.linked_product.ieps_tax
|
|
385
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