foodbot-cart-calculations 1.0.13 → 1.0.15

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/calculations.js CHANGED
@@ -70,6 +70,7 @@ function applyDistribution(body) {
70
70
  }
71
71
 
72
72
  taxData.total_after_tax = parseFloat(taxData.total_after_tax) + parseFloat(tipValue);
73
+ taxData.total_after_tax = parseFloat(taxData.total_after_tax).toFixed(2);
73
74
 
74
75
 
75
76
  mainCart.order_items = taxData
@@ -77,6 +78,8 @@ function applyDistribution(body) {
77
78
  mainCart.cash_expected = taxData.cartTotal
78
79
  mainCart.final_amount = parseFloat(mainCart.final_amount) + parseFloat(tipValue);
79
80
  mainCart.cash_expected = parseFloat(mainCart.cash_expected) + parseFloat(tipValue);
81
+ taxData.final_amount = parseFloat(taxData.final_amount).toFixed(2);
82
+ taxData.cash_expected = parseFloat(taxData.cash_expected).toFixed(2);
80
83
 
81
84
  mainCart.order_items.discount = parseFloat(mainCart.order_items.discount) ;
82
85
  mainCart.order_items.discount = parseFloat(mainCart.order_items.discount).toFixed(2)
@@ -604,8 +604,6 @@ 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
 
@@ -619,7 +617,7 @@ 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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foodbot-cart-calculations",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
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": {