foodbot-cart-calculations 1.0.45 → 1.0.46
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 +16 -23
- package/functions/pointsCalculation.js +90 -137
- package/functions/promotionCalculation.js +8 -13
- package/index.js +3 -3
- package/package.json +1 -1
- package/response.json +0 -239
- package/sampleInput.json +0 -231
package/calculations.js
CHANGED
|
@@ -8,15 +8,10 @@ function applyDistribution(body) {
|
|
|
8
8
|
let mainCart = body
|
|
9
9
|
let promotion = (body.promotion_applied && body.promotion_applied) ? body.promotion_applied : {};
|
|
10
10
|
let deliveryCost = (body.delivery_cost && body.delivery_cost) ? body.delivery_cost : 0;
|
|
11
|
-
|
|
12
|
-
if(body?.order_items?.delivery_discount)
|
|
11
|
+
|
|
12
|
+
if(body?.order_items?.delivery_discount)
|
|
13
13
|
body.order_items.delivery_discount = 0
|
|
14
14
|
body.order_items.is_delivery_discount = false
|
|
15
|
-
}
|
|
16
|
-
if (body?.order_items?.service_discount) {
|
|
17
|
-
body.order_items.service_discount = 0;
|
|
18
|
-
body.order_items.is_service_discount = false;
|
|
19
|
-
}
|
|
20
15
|
|
|
21
16
|
promoCalculation.setPackageDefaultDiscount(body.order_items).then(res => {
|
|
22
17
|
promoCalculation.offerCalculation(res, promotion, deliveryCost).then(final => {
|
|
@@ -35,7 +30,8 @@ function applyDistribution(body) {
|
|
|
35
30
|
}
|
|
36
31
|
mainCart.store_value = 0;
|
|
37
32
|
|
|
38
|
-
pointsCalculation.getPointsDiscount(final, body.loyalty_points_details, body.user_detais
|
|
33
|
+
pointsCalculation.getPointsDiscount(final, body.loyalty_points_details, body.user_detais).then(pointsCal => {
|
|
34
|
+
|
|
39
35
|
if (typeof (final.store_value) == "undefined" || isNaN(final.store_value))
|
|
40
36
|
final.store_value = 0
|
|
41
37
|
if (body.loyalty_points_details && parseInt(body.loyalty_points_details.points_redeemed) == 0) {
|
|
@@ -77,26 +73,23 @@ function applyDistribution(body) {
|
|
|
77
73
|
mainCart.cash_expected = parseFloat(taxData.cartTotal) + parseFloat(taxData.tax_amount);
|
|
78
74
|
}
|
|
79
75
|
mainCart.order_items = taxData
|
|
80
|
-
|
|
76
|
+
|
|
81
77
|
let delivery_cost = body.delivery_cost ? body.delivery_cost : 0;
|
|
82
|
-
let service_amount = body.service_amount ? body.service_amount : 0;
|
|
83
78
|
// Adjust delivery cost based on delivery discount
|
|
84
79
|
if (final.is_delivery_discount) {
|
|
85
|
-
delivery_cost = Math.max(0, delivery_cost - final.delivery_discount);
|
|
80
|
+
delivery_cost = Math.max(0, delivery_cost - final.delivery_discount);
|
|
86
81
|
body.delivery_cost = delivery_cost; // Update body accordingly
|
|
87
82
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
let tipValue = body.tip_value?body.tip_value:0;
|
|
95
|
-
let tipValueReq = body.tip_value?body.tip_value:0;
|
|
83
|
+
|
|
84
|
+
let service_amount = body.service_amount?body.service_amount:0;
|
|
85
|
+
|
|
86
|
+
//we took 2 value because in case of absolute we use tipValue
|
|
87
|
+
let tipValue = body.tip_value?body.tip_value:0;
|
|
88
|
+
let tipValueReq = body.tip_value?body.tip_value:0;
|
|
96
89
|
|
|
97
90
|
if (body.tip_type && body.tip_type == 'percentage') {
|
|
98
|
-
|
|
99
|
-
|
|
91
|
+
tipValue = (mainCart.final_amount * parseInt(tipValueReq)) / 100
|
|
92
|
+
tipValue = parseFloat(tipValue).toFixed(2)
|
|
100
93
|
}
|
|
101
94
|
|
|
102
95
|
mainCart.tip_amount = parseFloat(tipValue).toFixed(2);
|
|
@@ -112,10 +105,10 @@ function applyDistribution(body) {
|
|
|
112
105
|
|
|
113
106
|
taxData.total_after_tax = parseFloat(taxData.total_after_tax) + parseFloat(tipValue);
|
|
114
107
|
taxData.total_after_tax = parseFloat(taxData.total_after_tax).toFixed(2);
|
|
115
|
-
|
|
108
|
+
|
|
116
109
|
mainCart.final_amount = parseFloat(mainCart.final_amount) + parseFloat(tipValue);
|
|
117
110
|
mainCart.cash_expected = parseFloat(mainCart.cash_expected) + parseFloat(tipValue);
|
|
118
|
-
|
|
111
|
+
|
|
119
112
|
taxData.final_amount = parseFloat(taxData.final_amount).toFixed(2);
|
|
120
113
|
taxData.cash_expected = parseFloat(taxData.cash_expected).toFixed(2);
|
|
121
114
|
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
function getPointsDiscount(cartObject, points, userDetails
|
|
1
|
+
function getPointsDiscount(cartObject, points, userDetails) {
|
|
2
2
|
return new Promise(function (resolve, reject) {
|
|
3
3
|
try {
|
|
4
4
|
let itemsTotal = 0
|
|
5
5
|
let carts = cartObject.item_details
|
|
6
|
-
let deliveryDiscount = 0;
|
|
7
|
-
let serviceDiscount = 0;
|
|
8
6
|
|
|
9
7
|
carts.forEach(function (v) {
|
|
10
8
|
delete v.points_discount_modifier;
|
|
@@ -34,11 +32,8 @@ function getPointsDiscount(cartObject, points, userDetails, deliveryCost = 0, se
|
|
|
34
32
|
});
|
|
35
33
|
}
|
|
36
34
|
});
|
|
37
|
-
|
|
38
35
|
if (!points) {
|
|
39
|
-
|
|
40
|
-
cartObject.service_discount = 0;
|
|
41
|
-
resolve(cartObject);
|
|
36
|
+
resolve(0);
|
|
42
37
|
} else {
|
|
43
38
|
let pointsAmount = 0;
|
|
44
39
|
let count = 0;
|
|
@@ -76,81 +71,77 @@ function getPointsDiscount(cartObject, points, userDetails, deliveryCost = 0, se
|
|
|
76
71
|
element.point_discount_status = true;
|
|
77
72
|
}
|
|
78
73
|
count++;
|
|
79
|
-
});
|
|
80
74
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
packDis = (parseFloat(packDis) + parseFloat(packageItem.points_discount)).toFixed(2);
|
|
152
|
-
|
|
153
|
-
packageItem.modifiers.forEach((modi, modiIndex) => {
|
|
75
|
+
if (count == carts.length) {
|
|
76
|
+
let singlePriceDiscount = pointsAmount / itemsTotal;
|
|
77
|
+
singlePriceDiscount = (itemsTotal && itemsTotal > 0)?parseFloat(singlePriceDiscount).toFixed(6):0;
|
|
78
|
+
|
|
79
|
+
let storeValue = 0
|
|
80
|
+
let itemDiscount = 0;
|
|
81
|
+
let itemTotalDicount = 0;
|
|
82
|
+
|
|
83
|
+
carts.forEach((item, index) => {
|
|
84
|
+
item.points_discount = item.points_discount ? item.points_discount : 0;
|
|
85
|
+
item.points_discount_modifier = item.points_discount_modifier ? item.points_discount_modifier : 0;
|
|
86
|
+
|
|
87
|
+
if (item.isPackage == 1) {
|
|
88
|
+
if (item.point_discount_status) {
|
|
89
|
+
let promoDiscount = (item.promotion_discount) ? item.promotion_discount : 0;
|
|
90
|
+
itemDiscount = ((item.item_price * item.quantity) - promoDiscount) * singlePriceDiscount;
|
|
91
|
+
itemDiscount = parseFloat(itemDiscount).toFixed(2);
|
|
92
|
+
itemTotalDicount = parseFloat(itemDiscount) + parseFloat(itemTotalDicount);
|
|
93
|
+
|
|
94
|
+
if (itemDiscount > 0)
|
|
95
|
+
indexes.push(index);
|
|
96
|
+
|
|
97
|
+
item.points_discount = itemDiscount;
|
|
98
|
+
item.points_discount_modifier = 0;
|
|
99
|
+
|
|
100
|
+
let packDis = 0;
|
|
101
|
+
|
|
102
|
+
item.package_items.forEach((packageItem, packageItemIndex) => {
|
|
103
|
+
let packageItemPromoDiscount = (packageItem.promotion_discount) ? packageItem.promotion_discount : 0;
|
|
104
|
+
packageItem.points_discount_modifier = 0;
|
|
105
|
+
|
|
106
|
+
packageItem.points_discount = ((((packageItem.price * parseInt(item.quantity)) - parseFloat((packageItem.default_combo_discount)) - parseFloat(packageItemPromoDiscount))) * parseFloat(singlePriceDiscount)).toFixed(2);
|
|
107
|
+
packDis = (parseFloat(packDis) + parseFloat(packageItem.points_discount)).toFixed(2);
|
|
108
|
+
|
|
109
|
+
packageItem.modifiers.forEach((modi, modiIndex) => {
|
|
110
|
+
let modiItemAmount = 0;
|
|
111
|
+
let modiPromoDiscount = (modi.promotion_discount) ? modi.promotion_discount : 0;
|
|
112
|
+
modiItemAmount = (((parseFloat(modi.modifier_item_price) * parseInt(modi.quantity)) * item.quantity) - modiPromoDiscount) * parseFloat(singlePriceDiscount);
|
|
113
|
+
modiItemAmount = parseFloat(modiItemAmount).toFixed(2);
|
|
114
|
+
itemTotalDicount = parseFloat(itemTotalDicount) + parseFloat(modiItemAmount);
|
|
115
|
+
itemTotalDicount = parseFloat(itemTotalDicount).toFixed(2);
|
|
116
|
+
modi.points_discount = modiItemAmount;
|
|
117
|
+
packageItem.points_discount_modifier = (parseFloat(packageItem.points_discount_modifier) + parseFloat(modi.points_discount)).toFixed(2);
|
|
118
|
+
});
|
|
119
|
+
packageItem.points_discount_modifier = (parseFloat(packageItem.points_discount) + parseFloat(packageItem.points_discount_modifier)).toFixed(2);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
if (itemDiscount != packDis && item.package_items) {
|
|
123
|
+
if (packDis > itemDiscount) {
|
|
124
|
+
let diff = (parseFloat(packDis) - parseFloat(itemDiscount)).toFixed(2);
|
|
125
|
+
item.package_items[0].points_discount = (parseFloat(item.package_items[0].points_discount) - parseFloat(diff)).toFixed(2);
|
|
126
|
+
} else {
|
|
127
|
+
let diff = (parseFloat(itemDiscount) - parseFloat(packDis)).toFixed(2);
|
|
128
|
+
item.package_items[0].points_discount = (parseFloat(item.package_items[0].points_discount) - parseFloat(diff)).toFixed(2);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
} else {
|
|
133
|
+
if (item.point_discount_status) {
|
|
134
|
+
let promoDiscount = (item.promotion_discount) ? item.promotion_discount : 0;
|
|
135
|
+
itemDiscount = ((item.item_price * item.quantity) - promoDiscount) * singlePriceDiscount;
|
|
136
|
+
itemDiscount = parseFloat(itemDiscount).toFixed(2);
|
|
137
|
+
itemTotalDicount = parseFloat(itemDiscount) + parseFloat(itemTotalDicount);
|
|
138
|
+
|
|
139
|
+
if (itemDiscount > 0)
|
|
140
|
+
indexes.push(index);
|
|
141
|
+
|
|
142
|
+
item.points_discount = itemDiscount;
|
|
143
|
+
|
|
144
|
+
item.item_modifiers.forEach((modi, modiIndex) => {
|
|
154
145
|
let modiItemAmount = 0;
|
|
155
146
|
let modiPromoDiscount = (modi.promotion_discount) ? modi.promotion_discount : 0;
|
|
156
147
|
modiItemAmount = (((parseFloat(modi.modifier_item_price) * parseInt(modi.quantity)) * item.quantity) - modiPromoDiscount) * parseFloat(singlePriceDiscount);
|
|
@@ -158,73 +149,35 @@ function getPointsDiscount(cartObject, points, userDetails, deliveryCost = 0, se
|
|
|
158
149
|
itemTotalDicount = parseFloat(itemTotalDicount) + parseFloat(modiItemAmount);
|
|
159
150
|
itemTotalDicount = parseFloat(itemTotalDicount).toFixed(2);
|
|
160
151
|
modi.points_discount = modiItemAmount;
|
|
161
|
-
packageItem.points_discount_modifier = (parseFloat(packageItem.points_discount_modifier) + parseFloat(modi.points_discount)).toFixed(2);
|
|
162
152
|
});
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
if (itemDiscount != packDis && item.package_items) {
|
|
167
|
-
if (packDis > itemDiscount) {
|
|
168
|
-
let diff = (parseFloat(packDis) - parseFloat(itemDiscount)).toFixed(2);
|
|
169
|
-
item.package_items[0].points_discount = (parseFloat(item.package_items[0].points_discount) - parseFloat(diff)).toFixed(2);
|
|
170
|
-
} else {
|
|
171
|
-
let diff = (parseFloat(itemDiscount) - parseFloat(packDis)).toFixed(2);
|
|
172
|
-
item.package_items[0].points_discount = (parseFloat(item.package_items[0].points_discount) - parseFloat(diff)).toFixed(2);
|
|
173
|
-
}
|
|
153
|
+
|
|
154
|
+
item.points_discount_modifier = itemTotalDicount;
|
|
174
155
|
}
|
|
175
156
|
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
item.points_discount = itemDiscount;
|
|
187
|
-
|
|
188
|
-
item.item_modifiers.forEach((modi, modiIndex) => {
|
|
189
|
-
let modiItemAmount = 0;
|
|
190
|
-
let modiPromoDiscount = (modi.promotion_discount) ? modi.promotion_discount : 0;
|
|
191
|
-
modiItemAmount = (((parseFloat(modi.modifier_item_price) * parseInt(modi.quantity)) * item.quantity) - modiPromoDiscount) * parseFloat(singlePriceDiscount);
|
|
192
|
-
modiItemAmount = parseFloat(modiItemAmount).toFixed(2);
|
|
193
|
-
itemTotalDicount = parseFloat(itemTotalDicount) + parseFloat(modiItemAmount);
|
|
194
|
-
itemTotalDicount = parseFloat(itemTotalDicount).toFixed(2);
|
|
195
|
-
modi.points_discount = modiItemAmount;
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
item.points_discount_modifier = itemTotalDicount;
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
if ((Number(itemTotalDicount) < Number(pointsAmount) || Number(itemTotalDicount) > Number(pointsAmount)) && pointsAmount > 0 && itemTotalDicount > 0) {
|
|
160
|
+
let difference = Number(pointsAmount) - Number(itemTotalDicount);
|
|
161
|
+
difference = parseFloat(difference).toFixed(2);
|
|
162
|
+
if (index > -1) {
|
|
163
|
+
carts[indexes[0]].points_discount = (difference > 0) ? parseFloat(carts[indexes[0]].points_discount) + parseFloat(difference) : parseFloat(carts[indexes[0]].points_discount) - Math.abs(difference);
|
|
164
|
+
carts[indexes[0]].points_discount = parseFloat(carts[indexes[0]].points_discount).toFixed(2);
|
|
165
|
+
itemTotalDicount = (difference < 0) ? itemTotalDicount + difference : itemTotalDicount - Math.abs(difference);
|
|
166
|
+
itemTotalDicount = parseFloat(itemTotalDicount).toFixed(2);
|
|
199
167
|
}
|
|
200
168
|
}
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
if ((Number(itemTotalDicount) < Number(pointsAmount) || Number(itemTotalDicount) > Number(pointsAmount)) && pointsAmount > 0 && itemTotalDicount > 0) {
|
|
204
|
-
let difference = Number(pointsAmount) - Number(itemTotalDicount);
|
|
205
|
-
difference = parseFloat(difference).toFixed(2);
|
|
206
|
-
if (indexes.length > 0) {
|
|
207
|
-
carts[indexes[0]].points_discount = (difference > 0) ? parseFloat(carts[indexes[0]].points_discount) + parseFloat(difference) : parseFloat(carts[indexes[0]].points_discount) - Math.abs(difference);
|
|
208
|
-
carts[indexes[0]].points_discount = parseFloat(carts[indexes[0]].points_discount).toFixed(2);
|
|
209
|
-
itemTotalDicount = (difference < 0) ? itemTotalDicount + difference : itemTotalDicount - Math.abs(difference);
|
|
210
|
-
itemTotalDicount = parseFloat(itemTotalDicount).toFixed(2);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
169
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
cartObject.delivery_discount = deliveryDiscount;
|
|
218
|
-
cartObject.service_discount = serviceDiscount;
|
|
170
|
+
cartObject.item_details = carts
|
|
171
|
+
cartObject.store_value = pointsAmount
|
|
172
|
+
cartObject.point_discount_amount = pointsAmount
|
|
219
173
|
|
|
220
|
-
|
|
221
|
-
|
|
174
|
+
resolve(cartObject);
|
|
175
|
+
}
|
|
176
|
+
});
|
|
222
177
|
} else {
|
|
223
178
|
cartObject.item_details = carts
|
|
224
179
|
cartObject.store_value = pointsAmount
|
|
225
180
|
cartObject.point_discount_amount = pointsAmount
|
|
226
|
-
cartObject.delivery_discount = 0;
|
|
227
|
-
cartObject.service_discount = 0;
|
|
228
181
|
|
|
229
182
|
resolve(cartObject);
|
|
230
183
|
}
|
|
@@ -164,7 +164,7 @@ function getCategorySpeificOffer(carts, offer) {
|
|
|
164
164
|
if (offer.oo_offer_type == 'percentage') {
|
|
165
165
|
let itemTotalDiscount = 0
|
|
166
166
|
itemAmount = ((parseFloat(element.item_price) * parseFloat(element.quantity)) * parseFloat(offer.oo_offer_value)) / 100;
|
|
167
|
-
itemTotalDiscount = parseFloat(itemTotalDiscount) + parseFloat(itemAmount)
|
|
167
|
+
itemTotalDiscount = (parseFloat(itemTotalDiscount) + parseFloat(itemAmount)).toFixed(2)
|
|
168
168
|
let itemDiscount = parseFloat(itemAmount).toFixed(2);
|
|
169
169
|
|
|
170
170
|
total = parseFloat(total) + parseFloat(itemDiscount)
|
|
@@ -181,7 +181,7 @@ function getCategorySpeificOffer(carts, offer) {
|
|
|
181
181
|
let modiItemAmount = 0
|
|
182
182
|
modiItemAmount = (((parseFloat(modi.modifier_item_price) * parseFloat(modi.quantity))) * element.quantity * parseFloat(offer.oo_offer_value)) / 100;
|
|
183
183
|
|
|
184
|
-
itemTotalDiscount = parseFloat(itemTotalDiscount) + parseFloat(modiItemAmount)
|
|
184
|
+
itemTotalDiscount = (parseFloat(itemTotalDiscount) + parseFloat(modiItemAmount)).toFixed(2)
|
|
185
185
|
let discount = parseFloat(modiItemAmount).toFixed(2)
|
|
186
186
|
total = parseFloat(total) + parseFloat(discount)
|
|
187
187
|
total = parseFloat(total).toFixed(2);
|
|
@@ -232,7 +232,7 @@ function getCategorySpeificOffer(carts, offer) {
|
|
|
232
232
|
modiItemAmount = ((parseFloat(modi.modifier_item_price) * parseInt(modi.quantity)) * element.quantity) * parseFloat(singlePriceDiscount);
|
|
233
233
|
|
|
234
234
|
modiItemAmount = parseFloat(modiItemAmount).toFixed(2)
|
|
235
|
-
itemTotalDiscount = parseFloat(itemTotalDiscount) + parseFloat(modiItemAmount)
|
|
235
|
+
itemTotalDiscount = (parseFloat(itemTotalDiscount) + parseFloat(modiItemAmount)).toFixed(2)
|
|
236
236
|
total = parseFloat(total) + parseFloat(modiItemAmount)
|
|
237
237
|
total = parseFloat(total).toFixed(2);
|
|
238
238
|
carts.item_details[index].package_items[packageItemIndex].modifiers[modiIndex].promotion_discount = parseFloat(modiItemAmount).toFixed(2)
|
|
@@ -281,7 +281,7 @@ function getCategorySpeificOffer(carts, offer) {
|
|
|
281
281
|
if (offer.oo_offer_type == 'percentage') {
|
|
282
282
|
let itemTotalDiscount = 0
|
|
283
283
|
itemAmount = ((parseFloat(element.item_price) * parseFloat(element.quantity)) * parseFloat(offer.oo_offer_value)) / 100;
|
|
284
|
-
itemTotalDiscount = parseFloat(itemTotalDiscount) + parseFloat(itemAmount)
|
|
284
|
+
itemTotalDiscount = parseFloat(itemTotalDiscount) + parseFloat(itemAmount).toFixed(2)
|
|
285
285
|
let itemDiscount = parseFloat(itemAmount).toFixed(2)
|
|
286
286
|
|
|
287
287
|
total = parseFloat(total) + parseFloat(itemDiscount)
|
|
@@ -295,7 +295,7 @@ function getCategorySpeificOffer(carts, offer) {
|
|
|
295
295
|
let modiItemAmount = 0
|
|
296
296
|
modiItemAmount = (((parseFloat(modi.modifier_item_price) * parseFloat(modi.quantity))) * element.quantity * parseFloat(offer.oo_offer_value)) / 100;
|
|
297
297
|
|
|
298
|
-
itemTotalDiscount = parseFloat(itemTotalDiscount) + parseFloat(modiItemAmount)
|
|
298
|
+
itemTotalDiscount = (parseFloat(itemTotalDiscount) + parseFloat(modiItemAmount)).toFixed(2)
|
|
299
299
|
let discount = parseFloat(modiItemAmount).toFixed(2)
|
|
300
300
|
total = parseFloat(total) + parseFloat(discount)
|
|
301
301
|
total = parseFloat(total).toFixed(2);
|
|
@@ -329,7 +329,7 @@ function getCategorySpeificOffer(carts, offer) {
|
|
|
329
329
|
modiItemAmount = ((parseFloat(modi.modifier_item_price) * parseInt(modi.quantity)) * element.quantity) * parseFloat(singlePriceDiscount);
|
|
330
330
|
|
|
331
331
|
modiItemAmount = parseFloat(modiItemAmount).toFixed(2)
|
|
332
|
-
itemTotalDiscount = parseFloat(itemTotalDiscount) + parseFloat(modiItemAmount)
|
|
332
|
+
itemTotalDiscount = (parseFloat(itemTotalDiscount) + parseFloat(modiItemAmount)).toFixed(2)
|
|
333
333
|
total = parseFloat(total) + parseFloat(modiItemAmount)
|
|
334
334
|
total = parseFloat(total).toFixed(2);
|
|
335
335
|
carts.item_details[index].item_modifiers[modiIndex].promotion_discount = parseFloat(modiItemAmount).toFixed(2)
|
|
@@ -359,7 +359,7 @@ function getCategorySpeificOffer(carts, offer) {
|
|
|
359
359
|
|
|
360
360
|
total = parseFloat(total).toFixed(2)
|
|
361
361
|
|
|
362
|
-
itemTotalDiscount = parseFloat(itemTotalDiscount) + parseFloat(itemAmount)
|
|
362
|
+
itemTotalDiscount = (parseFloat(itemTotalDiscount) + parseFloat(itemAmount)).toFixed(2)
|
|
363
363
|
remaningOfferAmount = remaningOfferAmount - itemAmount
|
|
364
364
|
carts.item_details[index].promotion_discount = (parseFloat(carts.item_details[index].promotion_discount) + parseFloat(itemAmount)).toFixed(2);
|
|
365
365
|
carts.item_details[index].promotion_discount_modifier = (parseFloat(carts.item_details[index].promotion_discount_modifier) + parseFloat(itemAmount)).toFixed(2);
|
|
@@ -376,13 +376,8 @@ function getCategorySpeificOffer(carts, offer) {
|
|
|
376
376
|
let difference = Number(offerAmount) - Number(total)
|
|
377
377
|
difference = parseFloat(difference).toFixed(2)
|
|
378
378
|
difference = Math.abs(difference)
|
|
379
|
-
|
|
380
379
|
if (indexes.length > 0) {
|
|
381
380
|
|
|
382
|
-
// console.log("difference", difference)
|
|
383
|
-
// console.log("total", total)
|
|
384
|
-
// console.log("offerAmount", offerAmount)
|
|
385
|
-
|
|
386
381
|
carts.item_details[indexes[0]].promotion_discount = (Number(total) < Number(offerAmount)) ? parseFloat(carts.item_details[indexes[0]].promotion_discount) + parseFloat(difference) : parseFloat(carts.item_details[indexes[0]].promotion_discount) - difference
|
|
387
382
|
carts.item_details[indexes[0]].promotion_discount = parseFloat(carts.item_details[indexes[0]].promotion_discount).toFixed(2)
|
|
388
383
|
|
|
@@ -394,7 +389,7 @@ function getCategorySpeificOffer(carts, offer) {
|
|
|
394
389
|
total = parseFloat(total).toFixed(2)
|
|
395
390
|
}
|
|
396
391
|
}
|
|
397
|
-
|
|
392
|
+
console.log("total", total)
|
|
398
393
|
carts.discount = total
|
|
399
394
|
resolve(carts);
|
|
400
395
|
}
|
package/index.js
CHANGED
|
@@ -360,9 +360,9 @@ async function calculateTax(inputJSON) {
|
|
|
360
360
|
// "delivery_cost": 0,
|
|
361
361
|
// "service_amount": 0
|
|
362
362
|
// }
|
|
363
|
-
|
|
363
|
+
|
|
364
364
|
// calculateTax(json).then(res=>{
|
|
365
|
-
// console.log(JSON.stringify(res))
|
|
365
|
+
// // console.log(JSON.stringify(res))
|
|
366
366
|
|
|
367
367
|
// const jsonResponse = JSON.stringify(res, null, 2); // Format the JSON with indentation
|
|
368
368
|
// const filePath = path.join(__dirname, 'response.json'); // File path in the same directory
|
|
@@ -378,5 +378,5 @@ async function calculateTax(inputJSON) {
|
|
|
378
378
|
// }).catch(err=>{
|
|
379
379
|
// console.log(err)
|
|
380
380
|
// })
|
|
381
|
-
|
|
381
|
+
|
|
382
382
|
module.exports = { calculateTax }
|
package/package.json
CHANGED
package/response.json
DELETED
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"status": "success",
|
|
3
|
-
"status_code": 200,
|
|
4
|
-
"message": "Tax calculated successfully",
|
|
5
|
-
"data": {
|
|
6
|
-
"order_type": "delivery",
|
|
7
|
-
"request_id": "259629f21a457bb4",
|
|
8
|
-
"restaurant_id": 1158,
|
|
9
|
-
"brand_id": "18f3f889-5f82-4268-9340-61ffac64d30a",
|
|
10
|
-
"branch_id": 3168,
|
|
11
|
-
"order_items": {
|
|
12
|
-
"item_details": [
|
|
13
|
-
{
|
|
14
|
-
"menu_id": 662,
|
|
15
|
-
"item_id": 21239,
|
|
16
|
-
"item_image": "https://res.cloudinary.com/http-foodbot-ai/image/upload/f_auto,q_auto,fl_lossy/v1724495427/prod/menu_item/file1724495427370menu_item_pbh8lf.jpg",
|
|
17
|
-
"category_id": 3888,
|
|
18
|
-
"item_price": 145,
|
|
19
|
-
"item_price_with_modifier": 145,
|
|
20
|
-
"quantity": 1,
|
|
21
|
-
"item_modifiers": [
|
|
22
|
-
{
|
|
23
|
-
"modifer_cat": 5040,
|
|
24
|
-
"modifier_category_id": 5040,
|
|
25
|
-
"modifier_caetgory_name": "Elige tu base ",
|
|
26
|
-
"modifier_item_id": 30321,
|
|
27
|
-
"modifier_sequence": "00",
|
|
28
|
-
"modifier_item_price": 0,
|
|
29
|
-
"modifier_item_name": "Arroz spicy",
|
|
30
|
-
"is_tax_rate_same": 1,
|
|
31
|
-
"ieps_tax": null,
|
|
32
|
-
"tax_rate": 0,
|
|
33
|
-
"quantity": 1,
|
|
34
|
-
"item_id": 21239,
|
|
35
|
-
"tax_id": [
|
|
36
|
-
{
|
|
37
|
-
"tax_id": "425a195c-3b37-11ed-af0e-42010ad46021"
|
|
38
|
-
}
|
|
39
|
-
],
|
|
40
|
-
"modifier_trx_id": "4052-4d0e-b968",
|
|
41
|
-
"linked_product": "",
|
|
42
|
-
"price_list_id": "2e6524d5-803e-4839-933b-758d16457bd1",
|
|
43
|
-
"promotion_discount_modifier": 0,
|
|
44
|
-
"tax_amount": "0.000000",
|
|
45
|
-
"tax_array": [
|
|
46
|
-
{
|
|
47
|
-
"tax_id": "425a195c-3b37-11ed-af0e-42010ad46021",
|
|
48
|
-
"tax_label": "IVA 16%",
|
|
49
|
-
"tax_rate": 16,
|
|
50
|
-
"tax_sequence": 1,
|
|
51
|
-
"base_price_effected": 0,
|
|
52
|
-
"tax_amount": "0.000000",
|
|
53
|
-
"base_price": "0.00",
|
|
54
|
-
"tax_rate_quantity": 0
|
|
55
|
-
}
|
|
56
|
-
],
|
|
57
|
-
"points_discount": "0.00"
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
"modifer_cat": 5045,
|
|
61
|
-
"modifier_category_id": 5045,
|
|
62
|
-
"modifier_caetgory_name": "Elige tu salsa",
|
|
63
|
-
"modifier_item_id": 30331,
|
|
64
|
-
"modifier_sequence": "10",
|
|
65
|
-
"modifier_item_price": 0,
|
|
66
|
-
"modifier_item_name": "Salsa Schezwan",
|
|
67
|
-
"is_tax_rate_same": 1,
|
|
68
|
-
"ieps_tax": null,
|
|
69
|
-
"tax_rate": 0,
|
|
70
|
-
"quantity": 1,
|
|
71
|
-
"item_id": 21239,
|
|
72
|
-
"tax_id": [
|
|
73
|
-
{
|
|
74
|
-
"tax_id": "425a195c-3b37-11ed-af0e-42010ad46021"
|
|
75
|
-
}
|
|
76
|
-
],
|
|
77
|
-
"modifier_trx_id": "6681-4517-48a6",
|
|
78
|
-
"linked_product": "",
|
|
79
|
-
"price_list_id": "2e6524d5-803e-4839-933b-758d16457bd1",
|
|
80
|
-
"promotion_discount_modifier": 0,
|
|
81
|
-
"tax_amount": "0.000000",
|
|
82
|
-
"tax_array": [
|
|
83
|
-
{
|
|
84
|
-
"tax_id": "425a195c-3b37-11ed-af0e-42010ad46021",
|
|
85
|
-
"tax_label": "IVA 16%",
|
|
86
|
-
"tax_rate": 16,
|
|
87
|
-
"tax_sequence": 1,
|
|
88
|
-
"base_price_effected": 0,
|
|
89
|
-
"tax_amount": "0.000000",
|
|
90
|
-
"base_price": "0.00",
|
|
91
|
-
"tax_rate_quantity": 0
|
|
92
|
-
}
|
|
93
|
-
],
|
|
94
|
-
"points_discount": "0.00"
|
|
95
|
-
}
|
|
96
|
-
],
|
|
97
|
-
"item_display_text": "Beef n' broccoli",
|
|
98
|
-
"item_name": "Beef n' broccoli",
|
|
99
|
-
"tax_rate": 16,
|
|
100
|
-
"isPackage": 0,
|
|
101
|
-
"package_items": [],
|
|
102
|
-
"actual_price": 145,
|
|
103
|
-
"item_event": "new",
|
|
104
|
-
"tax_id": [
|
|
105
|
-
{
|
|
106
|
-
"tax_id": "425a195c-3b37-11ed-af0e-42010ad46021"
|
|
107
|
-
}
|
|
108
|
-
],
|
|
109
|
-
"ieps_tax": {
|
|
110
|
-
"status": 0
|
|
111
|
-
},
|
|
112
|
-
"special_instruction": "",
|
|
113
|
-
"item_key": "21239-5040:30321-1|5045:30331-1",
|
|
114
|
-
"promotion_discount_modifier": 0,
|
|
115
|
-
"total_item_price": 145,
|
|
116
|
-
"tax_amount": "0.000000",
|
|
117
|
-
"tax_array": [
|
|
118
|
-
{
|
|
119
|
-
"tax_id": "425a195c-3b37-11ed-af0e-42010ad46021",
|
|
120
|
-
"tax_label": "IVA 16%",
|
|
121
|
-
"tax_rate": 16,
|
|
122
|
-
"tax_sequence": 1,
|
|
123
|
-
"base_price_effected": 0,
|
|
124
|
-
"tax_amount": "0.000000",
|
|
125
|
-
"base_price": "0.00",
|
|
126
|
-
"tax_rate_quantity": 0
|
|
127
|
-
}
|
|
128
|
-
],
|
|
129
|
-
"tax_amount_modifier": "0.000000",
|
|
130
|
-
"total_tax_amount": "0.000000",
|
|
131
|
-
"point_discount_status": true,
|
|
132
|
-
"points_discount": "180.00",
|
|
133
|
-
"points_discount_modifier": "180.00",
|
|
134
|
-
"promotion_discount": 0
|
|
135
|
-
}
|
|
136
|
-
],
|
|
137
|
-
"is_delivery_discount": true,
|
|
138
|
-
"total": "145.00",
|
|
139
|
-
"discount": "0.00",
|
|
140
|
-
"points_redeem_message": "",
|
|
141
|
-
"store_value": 180,
|
|
142
|
-
"point_discount_amount": 180,
|
|
143
|
-
"points_discount": 180,
|
|
144
|
-
"cartTotal": "0.00",
|
|
145
|
-
"tax_amount": "0.000000",
|
|
146
|
-
"merged_tax_array": [
|
|
147
|
-
{
|
|
148
|
-
"tax_id": "425a195c-3b37-11ed-af0e-42010ad46021",
|
|
149
|
-
"tax_label": "IVA 16%",
|
|
150
|
-
"tax_rate": 16,
|
|
151
|
-
"tax_sequence": 1,
|
|
152
|
-
"base_price_effected": 0,
|
|
153
|
-
"tax_amount": "0.000000",
|
|
154
|
-
"base_price": "0.000000",
|
|
155
|
-
"tax_rate_quantity": 0
|
|
156
|
-
}
|
|
157
|
-
],
|
|
158
|
-
"cart_total_with_tax": "0.00",
|
|
159
|
-
"sub_total": "0.00",
|
|
160
|
-
"total_after_tax": "0.00",
|
|
161
|
-
"final_amount": "NaN",
|
|
162
|
-
"cash_expected": "NaN",
|
|
163
|
-
"delivery_discount": "35.00",
|
|
164
|
-
"service_discount": 0,
|
|
165
|
-
"is_service_discount": false
|
|
166
|
-
},
|
|
167
|
-
"tax_settings": [
|
|
168
|
-
{
|
|
169
|
-
"tax_id": "425a195c-3b37-11ed-af0e-42010ad46021",
|
|
170
|
-
"tax_label": "IVA 16%",
|
|
171
|
-
"tax_rate": 16,
|
|
172
|
-
"tax_sequence": 1,
|
|
173
|
-
"base_price_effected": 0
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
"tax_id": "21036b00-bdb4-4485-aaba-d088a721a67f",
|
|
177
|
-
"tax_label": "IVA 8%",
|
|
178
|
-
"tax_rate": 8,
|
|
179
|
-
"tax_sequence": 1,
|
|
180
|
-
"base_price_effected": 0
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
"tax_id": "e47296aa-b5ae-449f-ab5f-ff50f43a648a",
|
|
184
|
-
"tax_label": "Sin IVA",
|
|
185
|
-
"tax_rate": 0,
|
|
186
|
-
"tax_sequence": 3,
|
|
187
|
-
"base_price_effected": 0
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
"tax_id": "21036b00-bdb4-4485-aaba-d088a721a67f1",
|
|
191
|
-
"tax_label": "IEPS 8%",
|
|
192
|
-
"tax_rate": 8,
|
|
193
|
-
"tax_sequence": 2,
|
|
194
|
-
"base_price_effected": 0
|
|
195
|
-
}
|
|
196
|
-
],
|
|
197
|
-
"tip_type": "absolute",
|
|
198
|
-
"tip_value": 0,
|
|
199
|
-
"tax_type": 2,
|
|
200
|
-
"delivery_cost": 5,
|
|
201
|
-
"service_amount": "10",
|
|
202
|
-
"store_value": 180,
|
|
203
|
-
"store_value_without_roundoff": 406,
|
|
204
|
-
"loyalty_points_details": {
|
|
205
|
-
"points": 406,
|
|
206
|
-
"redeemable": "yes",
|
|
207
|
-
"store_value": 180,
|
|
208
|
-
"redeem_categories": [
|
|
209
|
-
{
|
|
210
|
-
"product_id": "All",
|
|
211
|
-
"category_id": "All"
|
|
212
|
-
}
|
|
213
|
-
],
|
|
214
|
-
"original_store_value": 406,
|
|
215
|
-
"status": true,
|
|
216
|
-
"points_redeemed": 180,
|
|
217
|
-
"show_purchase": false,
|
|
218
|
-
"point_amount": 180,
|
|
219
|
-
"full_redemption": true,
|
|
220
|
-
"enable_delivery_points_usage": 1,
|
|
221
|
-
"enable_service_charge_usage": 1
|
|
222
|
-
},
|
|
223
|
-
"user_detais": {
|
|
224
|
-
"member_id": "35a7920d-653c-4156-9fbd-0c2d6f00629f",
|
|
225
|
-
"first_name": "Spider",
|
|
226
|
-
"last_name": "Man",
|
|
227
|
-
"country_code": "52",
|
|
228
|
-
"created_on": "2025-07-28T12:30:57.280Z",
|
|
229
|
-
"reward_plan_name": "Refer Plan new test",
|
|
230
|
-
"reward_plan_id": 14,
|
|
231
|
-
"calling_code": "52",
|
|
232
|
-
"name": "Spider Man"
|
|
233
|
-
},
|
|
234
|
-
"discount": "0.00",
|
|
235
|
-
"final_amount": 15,
|
|
236
|
-
"cash_expected": 15,
|
|
237
|
-
"tip_amount": "0.00"
|
|
238
|
-
}
|
|
239
|
-
}
|
package/sampleInput.json
DELETED
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"order_type": "delivery",
|
|
3
|
-
"request_id": "259629f21a457bb4",
|
|
4
|
-
"restaurant_id": 1158,
|
|
5
|
-
"brand_id": "18f3f889-5f82-4268-9340-61ffac64d30a",
|
|
6
|
-
"branch_id": 3168,
|
|
7
|
-
"order_items": {
|
|
8
|
-
"item_details": [
|
|
9
|
-
{
|
|
10
|
-
"menu_id": 662,
|
|
11
|
-
"item_id": 21239,
|
|
12
|
-
"item_image": "https://res.cloudinary.com/http-foodbot-ai/image/upload/f_auto,q_auto,fl_lossy/v1724495427/prod/menu_item/file1724495427370menu_item_pbh8lf.jpg",
|
|
13
|
-
"category_id": 3888,
|
|
14
|
-
"item_price": 145,
|
|
15
|
-
"item_price_with_modifier": 145,
|
|
16
|
-
"quantity": 1,
|
|
17
|
-
"item_modifiers": [
|
|
18
|
-
{
|
|
19
|
-
"modifer_cat": 5040,
|
|
20
|
-
"modifier_category_id": 5040,
|
|
21
|
-
"modifier_caetgory_name": "Elige tu base ",
|
|
22
|
-
"modifier_item_id": 30321,
|
|
23
|
-
"modifier_sequence": "00",
|
|
24
|
-
"modifier_item_price": 0,
|
|
25
|
-
"modifier_item_name": "Arroz spicy",
|
|
26
|
-
"is_tax_rate_same": 1,
|
|
27
|
-
"ieps_tax": null,
|
|
28
|
-
"tax_rate": 0,
|
|
29
|
-
"quantity": 1,
|
|
30
|
-
"item_id": 21239,
|
|
31
|
-
"tax_id": [
|
|
32
|
-
{
|
|
33
|
-
"tax_id": "425a195c-3b37-11ed-af0e-42010ad46021"
|
|
34
|
-
}
|
|
35
|
-
],
|
|
36
|
-
"modifier_trx_id": "4052-4d0e-b968",
|
|
37
|
-
"linked_product": "",
|
|
38
|
-
"price_list_id": "2e6524d5-803e-4839-933b-758d16457bd1",
|
|
39
|
-
"promotion_discount_modifier": 0,
|
|
40
|
-
"points_discount": "0.00",
|
|
41
|
-
"tax_amount": "0.000000",
|
|
42
|
-
"tax_array": [
|
|
43
|
-
{
|
|
44
|
-
"tax_id": "425a195c-3b37-11ed-af0e-42010ad46021",
|
|
45
|
-
"tax_label": "IVA 16%",
|
|
46
|
-
"tax_rate": 16,
|
|
47
|
-
"tax_sequence": 1,
|
|
48
|
-
"base_price_effected": 0,
|
|
49
|
-
"tax_amount": "0.000000",
|
|
50
|
-
"base_price": "0.00",
|
|
51
|
-
"tax_rate_quantity": 0
|
|
52
|
-
}
|
|
53
|
-
]
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
"modifer_cat": 5045,
|
|
57
|
-
"modifier_category_id": 5045,
|
|
58
|
-
"modifier_caetgory_name": "Elige tu salsa",
|
|
59
|
-
"modifier_item_id": 30331,
|
|
60
|
-
"modifier_sequence": "10",
|
|
61
|
-
"modifier_item_price": 0,
|
|
62
|
-
"modifier_item_name": "Salsa Schezwan",
|
|
63
|
-
"is_tax_rate_same": 1,
|
|
64
|
-
"ieps_tax": null,
|
|
65
|
-
"tax_rate": 0,
|
|
66
|
-
"quantity": 1,
|
|
67
|
-
"item_id": 21239,
|
|
68
|
-
"tax_id": [
|
|
69
|
-
{
|
|
70
|
-
"tax_id": "425a195c-3b37-11ed-af0e-42010ad46021"
|
|
71
|
-
}
|
|
72
|
-
],
|
|
73
|
-
"modifier_trx_id": "6681-4517-48a6",
|
|
74
|
-
"linked_product": "",
|
|
75
|
-
"price_list_id": "2e6524d5-803e-4839-933b-758d16457bd1",
|
|
76
|
-
"promotion_discount_modifier": 0,
|
|
77
|
-
"points_discount": "0.00",
|
|
78
|
-
"tax_amount": "0.000000",
|
|
79
|
-
"tax_array": [
|
|
80
|
-
{
|
|
81
|
-
"tax_id": "425a195c-3b37-11ed-af0e-42010ad46021",
|
|
82
|
-
"tax_label": "IVA 16%",
|
|
83
|
-
"tax_rate": 16,
|
|
84
|
-
"tax_sequence": 1,
|
|
85
|
-
"base_price_effected": 0,
|
|
86
|
-
"tax_amount": "0.000000",
|
|
87
|
-
"base_price": "0.00",
|
|
88
|
-
"tax_rate_quantity": 0
|
|
89
|
-
}
|
|
90
|
-
]
|
|
91
|
-
}
|
|
92
|
-
],
|
|
93
|
-
"item_display_text": "Beef n' broccoli",
|
|
94
|
-
"item_name": "Beef n' broccoli",
|
|
95
|
-
"tax_rate": 16,
|
|
96
|
-
"isPackage": 0,
|
|
97
|
-
"package_items": [],
|
|
98
|
-
"actual_price": 145,
|
|
99
|
-
"item_event": "new",
|
|
100
|
-
"tax_id": [
|
|
101
|
-
{
|
|
102
|
-
"tax_id": "425a195c-3b37-11ed-af0e-42010ad46021"
|
|
103
|
-
}
|
|
104
|
-
],
|
|
105
|
-
"ieps_tax": {
|
|
106
|
-
"status": 0
|
|
107
|
-
},
|
|
108
|
-
"special_instruction": "",
|
|
109
|
-
"item_key": "21239-5040:30321-1|5045:30331-1",
|
|
110
|
-
"promotion_discount_modifier": 0,
|
|
111
|
-
"total_item_price": 145,
|
|
112
|
-
"point_discount_status": true,
|
|
113
|
-
"points_discount": "145.00",
|
|
114
|
-
"points_discount_modifier": "145.00",
|
|
115
|
-
"tax_amount": "0.000000",
|
|
116
|
-
"tax_array": [
|
|
117
|
-
{
|
|
118
|
-
"tax_id": "425a195c-3b37-11ed-af0e-42010ad46021",
|
|
119
|
-
"tax_label": "IVA 16%",
|
|
120
|
-
"tax_rate": 16,
|
|
121
|
-
"tax_sequence": 1,
|
|
122
|
-
"base_price_effected": 0,
|
|
123
|
-
"tax_amount": "0.000000",
|
|
124
|
-
"base_price": "0.00",
|
|
125
|
-
"tax_rate_quantity": 0
|
|
126
|
-
}
|
|
127
|
-
],
|
|
128
|
-
"tax_amount_modifier": "0.000000",
|
|
129
|
-
"total_tax_amount": "0.000000",
|
|
130
|
-
"promotion_discount": 0
|
|
131
|
-
}
|
|
132
|
-
],
|
|
133
|
-
"is_delivery_discount": false,
|
|
134
|
-
"total": "145.00",
|
|
135
|
-
"discount": "0.00",
|
|
136
|
-
"points_redeem_message": "",
|
|
137
|
-
"store_value": "145.00",
|
|
138
|
-
"point_discount_amount": "145.00",
|
|
139
|
-
"points_discount": "145.00",
|
|
140
|
-
"cartTotal": "0.00",
|
|
141
|
-
"tax_amount": "0.000000",
|
|
142
|
-
"merged_tax_array": [
|
|
143
|
-
{
|
|
144
|
-
"tax_id": "425a195c-3b37-11ed-af0e-42010ad46021",
|
|
145
|
-
"tax_label": "IVA 16%",
|
|
146
|
-
"tax_rate": 16,
|
|
147
|
-
"tax_sequence": 1,
|
|
148
|
-
"base_price_effected": 0,
|
|
149
|
-
"tax_amount": "0.000000",
|
|
150
|
-
"base_price": "0.000000",
|
|
151
|
-
"tax_rate_quantity": 0
|
|
152
|
-
}
|
|
153
|
-
],
|
|
154
|
-
"cart_total_with_tax": "0.00",
|
|
155
|
-
"sub_total": "0.00",
|
|
156
|
-
"total_after_tax": "0.00",
|
|
157
|
-
"final_amount": "NaN",
|
|
158
|
-
"cash_expected": "NaN"
|
|
159
|
-
},
|
|
160
|
-
"tax_settings": [
|
|
161
|
-
{
|
|
162
|
-
"tax_id": "425a195c-3b37-11ed-af0e-42010ad46021",
|
|
163
|
-
"tax_label": "IVA 16%",
|
|
164
|
-
"tax_rate": 16,
|
|
165
|
-
"tax_sequence": 1,
|
|
166
|
-
"base_price_effected": 0
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
"tax_id": "21036b00-bdb4-4485-aaba-d088a721a67f",
|
|
170
|
-
"tax_label": "IVA 8%",
|
|
171
|
-
"tax_rate": 8,
|
|
172
|
-
"tax_sequence": 1,
|
|
173
|
-
"base_price_effected": 0
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
"tax_id": "e47296aa-b5ae-449f-ab5f-ff50f43a648a",
|
|
177
|
-
"tax_label": "Sin IVA",
|
|
178
|
-
"tax_rate": 0,
|
|
179
|
-
"tax_sequence": 3,
|
|
180
|
-
"base_price_effected": 0
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
"tax_id": "21036b00-bdb4-4485-aaba-d088a721a67f1",
|
|
184
|
-
"tax_label": "IEPS 8%",
|
|
185
|
-
"tax_rate": 8,
|
|
186
|
-
"tax_sequence": 2,
|
|
187
|
-
"base_price_effected": 0
|
|
188
|
-
}
|
|
189
|
-
],
|
|
190
|
-
"tip_type": "absolute",
|
|
191
|
-
"tip_value": 0,
|
|
192
|
-
"tax_type": 2,
|
|
193
|
-
"delivery_cost": "40",
|
|
194
|
-
"service_amount": "10",
|
|
195
|
-
"store_value": "150.00",
|
|
196
|
-
"store_value_without_roundoff": 406,
|
|
197
|
-
"loyalty_points_details": {
|
|
198
|
-
"points": 406,
|
|
199
|
-
"redeemable": "yes",
|
|
200
|
-
"store_value": 150,
|
|
201
|
-
"redeem_categories": [
|
|
202
|
-
{
|
|
203
|
-
"product_id": "All",
|
|
204
|
-
"category_id": "All"
|
|
205
|
-
}
|
|
206
|
-
],
|
|
207
|
-
"original_store_value": 406,
|
|
208
|
-
"status": true,
|
|
209
|
-
"points_redeemed": 150,
|
|
210
|
-
"show_purchase": false,
|
|
211
|
-
"point_amount": 150,
|
|
212
|
-
"full_redemption": true,
|
|
213
|
-
"enable_delivery_points_usage": 1,
|
|
214
|
-
"enable_service_charge_usage": 1
|
|
215
|
-
},
|
|
216
|
-
"user_detais": {
|
|
217
|
-
"member_id": "35a7920d-653c-4156-9fbd-0c2d6f00629f",
|
|
218
|
-
"first_name": "Spider",
|
|
219
|
-
"last_name": "Man",
|
|
220
|
-
"country_code": "52",
|
|
221
|
-
"created_on": "2025-07-28T12:30:57.280Z",
|
|
222
|
-
"reward_plan_name": "Refer Plan new test",
|
|
223
|
-
"reward_plan_id": 14,
|
|
224
|
-
"calling_code": "52",
|
|
225
|
-
"name": "Spider Man"
|
|
226
|
-
},
|
|
227
|
-
"discount": "0.00",
|
|
228
|
-
"final_amount": 50,
|
|
229
|
-
"cash_expected": 50,
|
|
230
|
-
"tip_amount": "0.00"
|
|
231
|
-
}
|