foodbot-cart-calculations 1.0.33 → 1.0.35
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(
|
|
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
|
|
|
@@ -815,13 +815,15 @@ function getFreeProductOffer(cartObject, offer) {
|
|
|
815
815
|
offer.offer_products.offer_discount_products = offer.offer_products.offer_discount_products.map(Number);
|
|
816
816
|
|
|
817
817
|
var cartItem = carts;
|
|
818
|
-
|
|
819
818
|
if (offer.offer_products.order_modifiercost_use == 1) {
|
|
820
819
|
cartItem.sort(function (a, b) {
|
|
821
820
|
return a.item_price_with_modifier / a.quantity > b.item_price_with_modifier / b.quantity ? 1 : -1;
|
|
822
821
|
});
|
|
823
822
|
} else {
|
|
824
823
|
cartItem.sort(function (a, b) {
|
|
824
|
+
// If price is zero, move it to the end
|
|
825
|
+
if (a.item_price == 0) return 1;
|
|
826
|
+
if (b.item_price == 0) return -1;
|
|
825
827
|
return a.item_price / a.quantity > b.item_price / b.quantity ? 1 : -1;
|
|
826
828
|
});
|
|
827
829
|
}
|
package/package.json
CHANGED