foodbot-cart-calculations 1.0.12 → 1.0.14

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.
@@ -604,14 +604,12 @@ async function getBeforeTaxPriceOfItem(taxes, price, taxType, quantity) {
604
604
  }
605
605
  if (tax.ieps_type && tax.ieps_type == 1) {
606
606
  totalTax += parseFloat(tax.tax_rate);
607
- }else if(tax.ieps_type && tax.ieps_type == 2){
608
- beforeTax = beforeTax - tax.tax_rate * quantity
609
607
  }
610
608
  });
611
609
 
612
610
  // Calculate taxAmount based on tax type 1 = exclusive and 2 = inclusive
613
611
  if (taxType == 2) {
614
- beforeTax = (beforeTax / (1 + totalTax / 100));
612
+ beforeTax = (beforeTax / (1 + totalTax / 100)).toFixed(2);
615
613
  }
616
614
 
617
615
  // ieps tax type = 1 precentage 2 absoulte
@@ -619,21 +617,21 @@ async function getBeforeTaxPriceOfItem(taxes, price, taxType, quantity) {
619
617
  if (tax.ieps_type && tax.ieps_type == 2) {
620
618
  // Adjust beforeTax based on tax type
621
619
  if (beforeTax >= tax.tax_rate) {
622
- beforeTaxIeps = taxType == 1 ? beforeTax : beforeTax;
620
+ beforeTaxIeps = taxType == 1 ? beforeTax : beforeTax - tax.tax_rate * quantity;
623
621
  beforeTaxIeps = parseFloat(beforeTaxIeps).toFixed(2)
624
622
  iepsTaxRate = tax.tax_rate * quantity / beforeTaxIeps
625
623
  iepsTaxRateQuantity = tax.tax_rate * quantity
626
624
  iepsTaxRate = parseFloat(iepsTaxRate)
627
- iepsTaxAmount = tax.tax_rate * quantity;
625
+ iepsTaxAmount = (tax.tax_rate * quantity).toFixed(2);
628
626
  }
629
627
  }
630
628
  else if (tax.ieps_type && tax.ieps_type == 1) {
631
629
  beforeTaxIeps = beforeTax ;
632
630
  iepsTaxRate = tax.tax_rate
633
- iepsTaxAmount = (firstAmount - beforeTax - taxAmount);
631
+ iepsTaxAmount = (firstAmount - beforeTax - taxAmount).toFixed(2);
634
632
  }
635
633
  else{
636
- taxAmount = ((beforeTax * tax.tax_rate) / 100);
634
+ taxAmount = ((beforeTax * tax.tax_rate) / 100).toFixed(2);
637
635
  }
638
636
  });
639
637
  resolve({ beforeTax, taxAmount, beforeTaxIeps, iepsTaxRate,iepsTaxAmount,iepsTaxRateQuantity });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foodbot-cart-calculations",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
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": {