foodbot-cart-calculations 1.0.52 → 1.0.53
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/taxCalculation.js +14 -14
- package/index.js +2 -775
- package/package.json +1 -1
- package/sample.json +606 -0
|
@@ -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 * element.quantity - promoDiscountPackage
|
|
185
|
+
let afterDicsountPackage = packageItem.price * (packageItem.quantity * element.quantity) - promoDiscountPackage
|
|
186
186
|
|
|
187
187
|
afterDicsountPackage = parseFloat(afterDicsountPackage).toFixed(2)
|
|
188
188
|
afterDicsountPackage = afterDicsountPackage - pointsDisouuntPackage
|
|
@@ -201,8 +201,7 @@ function calculatePackageItemTax(cart, itemIndex, element, tax_settings, afterDi
|
|
|
201
201
|
|
|
202
202
|
let lastPrice = afterDicsountPackage
|
|
203
203
|
let itemtaxAmount = 0;
|
|
204
|
-
|
|
205
|
-
await getBeforeTaxPriceOfItem(itemTaxs, lastPrice, taxType, packageItem.quantity).then(async (resp) => {
|
|
204
|
+
await getBeforeTaxPriceOfItem(itemTaxs, lastPrice, taxType, (packageItem.quantity * element.quantity)).then(async (resp) => {
|
|
206
205
|
lastPrice = resp.beforeTax;
|
|
207
206
|
let lastPriceIeps = +resp.beforeTaxIeps;
|
|
208
207
|
let iepsTaxRate = +resp.iepsTaxRate;
|
|
@@ -624,7 +623,7 @@ async function getBeforeTaxPriceOfItem(taxes, price, taxType, quantity) {
|
|
|
624
623
|
// Calculate taxAmount based on tax type 1 = exclusive and 2 = inclusive
|
|
625
624
|
if (taxType == 2) {
|
|
626
625
|
beforeTax = (beforeTax / (1 + totalTax / 100)).toFixed(2);
|
|
627
|
-
|
|
626
|
+
}
|
|
628
627
|
|
|
629
628
|
// ieps tax type = 1 precentage 2 absoulte
|
|
630
629
|
taxes.forEach((tax) => {
|
|
@@ -638,19 +637,20 @@ async function getBeforeTaxPriceOfItem(taxes, price, taxType, quantity) {
|
|
|
638
637
|
iepsTaxRate = parseFloat(iepsTaxRate)
|
|
639
638
|
iepsTaxAmount = (tax.tax_rate * quantity).toFixed(2);
|
|
640
639
|
}
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
640
|
+
}
|
|
641
|
+
else if (tax.ieps_type && tax.ieps_type == 1) {
|
|
642
|
+
beforeTaxIeps = beforeTax ;
|
|
643
|
+
iepsTaxRate = tax.tax_rate
|
|
644
|
+
iepsTaxAmount = (firstAmount - beforeTax - taxAmount).toFixed(2);
|
|
645
|
+
}
|
|
646
|
+
else{
|
|
647
|
+
taxAmount = ((beforeTax * tax.tax_rate) / 100).toFixed(2);
|
|
648
|
+
}
|
|
650
649
|
});
|
|
651
650
|
resolve({ beforeTax, taxAmount, beforeTaxIeps, iepsTaxRate,iepsTaxAmount,iepsTaxRateQuantity });
|
|
652
|
-
});
|
|
651
|
+
});
|
|
653
652
|
}
|
|
653
|
+
|
|
654
654
|
function setTaxes(cart, ele) {
|
|
655
655
|
let index = -1;
|
|
656
656
|
if (ele.ieps_type) {
|