foodbot-cart-calculations 1.0.59 → 1.0.61
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 -6
- package/functions/promotionCalculation.js +3 -1
- package/package.json +1 -1
- package/response.json +459 -459
- package/sample.json +3336 -399
package/calculations.js
CHANGED
|
@@ -137,12 +137,15 @@ function applyDistribution(body) {
|
|
|
137
137
|
|
|
138
138
|
if(mainCart.order_items && mainCart.order_items.item_details && mainCart.order_items.item_details.length > 0){
|
|
139
139
|
mainCart.order_items.item_details.forEach((item) =>{
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
140
|
+
const promoDisc = parseFloat(item.promotion_discount_modifier ?? 0);
|
|
141
|
+
const pointItemDisc = parseFloat(item.points_discount ?? 0);
|
|
142
|
+
const pointDisc = parseFloat(item.points_discount_modifier ?? 0);
|
|
143
|
+
const totalDiscount = promoDisc + pointDisc + pointItemDisc;
|
|
144
|
+
const totalItemCost = item.item_price_with_modifier * item.quantity;
|
|
145
|
+
const finalItemCost = totalItemCost - totalDiscount;
|
|
146
|
+
|
|
147
|
+
item.total_item_cost = +finalItemCost.toFixed(2);
|
|
148
|
+
item.per_item_cost = +(finalItemCost / item.quantity).toFixed(2);
|
|
146
149
|
})
|
|
147
150
|
}
|
|
148
151
|
resolve(mainCart);
|
|
@@ -147,7 +147,9 @@ function getCategorySpeificOffer(carts, offer) {
|
|
|
147
147
|
if(!res.purchase_points){
|
|
148
148
|
let itemId = res.item_id?.toString().length > 10 ? res.item_id : parseInt(res.item_id);
|
|
149
149
|
if (!res.event && (offer.offer_discount_type == 'manual' || (offer.offer_products.offer_discount_products.includes(itemId) && res.isPackage == 0) || (offer.offer_products.package_items.includes(itemId) && res.isPackage == 1))) {
|
|
150
|
-
|
|
150
|
+
// let ItemPriceWithMod = res.item_price_with_modifier ? res.item_price_with_modifier : (res.item_price || res.item_cost)
|
|
151
|
+
let ItemPriceWithMod = res.item_price_with_modifier ?? res.item_price ?? res.item_cost;
|
|
152
|
+
foundItemsSum = foundItemsSum + ItemPriceWithMod * res.quantity
|
|
151
153
|
return foundItemsSum
|
|
152
154
|
}
|
|
153
155
|
}
|
package/package.json
CHANGED