foodbot-cart-calculations 1.0.33 → 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 +9 -1
- package/package.json +1 -1
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(
|
|
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/package.json
CHANGED