foodbot-cart-calculations 1.0.32 → 1.0.34

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
@@ -71,10 +71,12 @@ function applyDistribution(body) {
71
71
  let delivery_cost = body.delivery_cost?body.delivery_cost:0;
72
72
  let service_amount = body.service_amount?body.service_amount:0;
73
73
 
74
+ //we took 2 value because in case of absolute we use tipValue
74
75
  let tipValue = body.tip_value?body.tip_value:0;
76
+ let tipValueReq = body.tip_value?body.tip_value:0;
75
77
 
76
78
  if (body.tip_type && body.tip_type == 'percentage') {
77
- tipValue = (mainCart.final_amount * parseInt(tipValue)) / 100
79
+ tipValue = (mainCart.final_amount * parseInt(tipValueReq)) / 100
78
80
  tipValue = parseFloat(tipValue).toFixed(2)
79
81
  }
80
82
 
@@ -83,6 +85,12 @@ function applyDistribution(body) {
83
85
  mainCart.final_amount = parseFloat(mainCart.final_amount) + parseFloat(delivery_cost) + parseFloat(service_amount);
84
86
  mainCart.cash_expected = parseFloat(mainCart.cash_expected) + parseFloat(delivery_cost) + parseFloat(service_amount);
85
87
 
88
+ //In a case when calculation of order done from pos.
89
+ if (body.tip_type && body.tip_type == 'percentage' && body.isPos && body.isPos == 1) {
90
+ tipValue = (mainCart.final_amount * parseInt(tipValueReq)) / 100;
91
+ tipValue = parseFloat(tipValue).toFixed(2)
92
+ }
93
+
86
94
  taxData.total_after_tax = parseFloat(taxData.total_after_tax) + parseFloat(tipValue);
87
95
  taxData.total_after_tax = parseFloat(taxData.total_after_tax).toFixed(2);
88
96
 
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const calculation = require('./calculations');
2
- const fs = require('fs');
3
- const path = require('path')
2
+ // const fs = require('fs');
3
+ // const path = require('path')
4
4
 
5
5
  async function calculateTax(inputJSON) {
6
6
  return new Promise(async (resolve, reject) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foodbot-cart-calculations",
3
- "version": "1.0.32",
3
+ "version": "1.0.34",
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": {