foodbot-cart-calculations 1.0.43 → 1.0.45
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 +23 -16
- package/functions/pointsCalculation.js +137 -90
- package/index.js +3 -3
- package/package.json +1 -1
- package/response.json +239 -0
- package/sampleInput.json +231 -0
package/calculations.js
CHANGED
|
@@ -8,10 +8,15 @@ 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
|
+
}
|
|
15
20
|
|
|
16
21
|
promoCalculation.setPackageDefaultDiscount(body.order_items).then(res => {
|
|
17
22
|
promoCalculation.offerCalculation(res, promotion, deliveryCost).then(final => {
|
|
@@ -30,8 +35,7 @@ function applyDistribution(body) {
|
|
|
30
35
|
}
|
|
31
36
|
mainCart.store_value = 0;
|
|
32
37
|
|
|
33
|
-
pointsCalculation.getPointsDiscount(final, body.loyalty_points_details, body.user_detais).then(pointsCal => {
|
|
34
|
-
|
|
38
|
+
pointsCalculation.getPointsDiscount(final, body.loyalty_points_details, body.user_detais, body.delivery_cost, body.service_amount).then(pointsCal => {
|
|
35
39
|
if (typeof (final.store_value) == "undefined" || isNaN(final.store_value))
|
|
36
40
|
final.store_value = 0
|
|
37
41
|
if (body.loyalty_points_details && parseInt(body.loyalty_points_details.points_redeemed) == 0) {
|
|
@@ -73,23 +77,26 @@ function applyDistribution(body) {
|
|
|
73
77
|
mainCart.cash_expected = parseFloat(taxData.cartTotal) + parseFloat(taxData.tax_amount);
|
|
74
78
|
}
|
|
75
79
|
mainCart.order_items = taxData
|
|
76
|
-
|
|
80
|
+
|
|
77
81
|
let delivery_cost = body.delivery_cost ? body.delivery_cost : 0;
|
|
82
|
+
let service_amount = body.service_amount ? body.service_amount : 0;
|
|
78
83
|
// Adjust delivery cost based on delivery discount
|
|
79
84
|
if (final.is_delivery_discount) {
|
|
80
|
-
delivery_cost = Math.max(0, delivery_cost - final.delivery_discount);
|
|
85
|
+
delivery_cost = Math.max(0, delivery_cost - final.delivery_discount);
|
|
81
86
|
body.delivery_cost = delivery_cost; // Update body accordingly
|
|
82
87
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
// Adjust service amount based on service discount
|
|
89
|
+
if (final.is_service_discount) {
|
|
90
|
+
service_amount = Math.max(0, service_amount - final.service_discount);
|
|
91
|
+
body.service_amount = service_amount;
|
|
92
|
+
}
|
|
93
|
+
//we took 2 value because in case of absolute we use tipValue
|
|
94
|
+
let tipValue = body.tip_value?body.tip_value:0;
|
|
95
|
+
let tipValueReq = body.tip_value?body.tip_value:0;
|
|
89
96
|
|
|
90
97
|
if (body.tip_type && body.tip_type == 'percentage') {
|
|
91
|
-
|
|
92
|
-
|
|
98
|
+
tipValue = (mainCart.final_amount * parseInt(tipValueReq)) / 100
|
|
99
|
+
tipValue = parseFloat(tipValue).toFixed(2)
|
|
93
100
|
}
|
|
94
101
|
|
|
95
102
|
mainCart.tip_amount = parseFloat(tipValue).toFixed(2);
|
|
@@ -105,10 +112,10 @@ function applyDistribution(body) {
|
|
|
105
112
|
|
|
106
113
|
taxData.total_after_tax = parseFloat(taxData.total_after_tax) + parseFloat(tipValue);
|
|
107
114
|
taxData.total_after_tax = parseFloat(taxData.total_after_tax).toFixed(2);
|
|
108
|
-
|
|
115
|
+
|
|
109
116
|
mainCart.final_amount = parseFloat(mainCart.final_amount) + parseFloat(tipValue);
|
|
110
117
|
mainCart.cash_expected = parseFloat(mainCart.cash_expected) + parseFloat(tipValue);
|
|
111
|
-
|
|
118
|
+
|
|
112
119
|
taxData.final_amount = parseFloat(taxData.final_amount).toFixed(2);
|
|
113
120
|
taxData.cash_expected = parseFloat(taxData.cash_expected).toFixed(2);
|
|
114
121
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
function getPointsDiscount(cartObject, points, userDetails) {
|
|
1
|
+
function getPointsDiscount(cartObject, points, userDetails, deliveryCost = 0, serviceAmount = 0) {
|
|
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;
|
|
6
8
|
|
|
7
9
|
carts.forEach(function (v) {
|
|
8
10
|
delete v.points_discount_modifier;
|
|
@@ -32,8 +34,11 @@ function getPointsDiscount(cartObject, points, userDetails) {
|
|
|
32
34
|
});
|
|
33
35
|
}
|
|
34
36
|
});
|
|
37
|
+
|
|
35
38
|
if (!points) {
|
|
36
|
-
|
|
39
|
+
cartObject.delivery_discount = 0;
|
|
40
|
+
cartObject.service_discount = 0;
|
|
41
|
+
resolve(cartObject);
|
|
37
42
|
} else {
|
|
38
43
|
let pointsAmount = 0;
|
|
39
44
|
let count = 0;
|
|
@@ -71,77 +76,81 @@ function getPointsDiscount(cartObject, points, userDetails) {
|
|
|
71
76
|
element.point_discount_status = true;
|
|
72
77
|
}
|
|
73
78
|
count++;
|
|
79
|
+
});
|
|
74
80
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
81
|
+
// Apply points to service charge if enabled
|
|
82
|
+
if (points.enable_service_charge_usage === 1 && serviceAmount > 0 && storeAmount > 0) {
|
|
83
|
+
cartObject.is_service_discount = true;
|
|
84
|
+
if (parseFloat(storeAmount) >= parseFloat(serviceAmount)) {
|
|
85
|
+
serviceDiscount = parseFloat(serviceAmount);
|
|
86
|
+
pointsAmount = parseFloat(pointsAmount) + parseFloat(serviceAmount);
|
|
87
|
+
storeAmount = parseFloat(storeAmount) - parseFloat(serviceAmount);
|
|
88
|
+
} else {
|
|
89
|
+
serviceDiscount = parseFloat(storeAmount);
|
|
90
|
+
pointsAmount = parseFloat(pointsAmount) + parseFloat(storeAmount);
|
|
91
|
+
storeAmount = 0;
|
|
92
|
+
}
|
|
93
|
+
serviceDiscount = parseFloat(serviceDiscount).toFixed(2);
|
|
94
|
+
cartObject.service_discount = serviceDiscount;
|
|
95
|
+
} else {
|
|
96
|
+
cartObject.service_discount = 0;
|
|
97
|
+
cartObject.is_service_discount = false;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Apply points to delivery if enabled
|
|
101
|
+
if (points.enable_delivery_points_usage === 1 && deliveryCost > 0 && storeAmount > 0) {
|
|
102
|
+
cartObject.is_delivery_discount = true;
|
|
103
|
+
if (parseFloat(storeAmount) >= parseFloat(deliveryCost)) {
|
|
104
|
+
deliveryDiscount = parseFloat(deliveryCost);
|
|
105
|
+
pointsAmount = parseFloat(pointsAmount) + parseFloat(deliveryCost);
|
|
106
|
+
storeAmount = parseFloat(storeAmount) - parseFloat(deliveryCost);
|
|
107
|
+
} else {
|
|
108
|
+
deliveryDiscount = parseFloat(storeAmount);
|
|
109
|
+
pointsAmount = parseFloat(pointsAmount) + parseFloat(storeAmount);
|
|
110
|
+
storeAmount = 0;
|
|
111
|
+
}
|
|
112
|
+
deliveryDiscount = parseFloat(deliveryDiscount).toFixed(2);
|
|
113
|
+
cartObject.delivery_discount = deliveryDiscount;
|
|
114
|
+
} else {
|
|
115
|
+
cartObject.delivery_discount = 0;
|
|
116
|
+
cartObject.is_delivery_discount = false;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (count == carts.length) {
|
|
120
|
+
let singlePriceDiscount = pointsAmount / itemsTotal;
|
|
121
|
+
singlePriceDiscount = (itemsTotal && itemsTotal > 0)?parseFloat(singlePriceDiscount).toFixed(6):0;
|
|
122
|
+
|
|
123
|
+
let storeValue = 0
|
|
124
|
+
let itemDiscount = 0;
|
|
125
|
+
let itemTotalDicount = 0;
|
|
126
|
+
|
|
127
|
+
carts.forEach((item, index) => {
|
|
128
|
+
item.points_discount = item.points_discount ? item.points_discount : 0;
|
|
129
|
+
item.points_discount_modifier = item.points_discount_modifier ? item.points_discount_modifier : 0;
|
|
130
|
+
|
|
131
|
+
if (item.isPackage == 1) {
|
|
132
|
+
if (item.point_discount_status) {
|
|
133
|
+
let promoDiscount = (item.promotion_discount) ? item.promotion_discount : 0;
|
|
134
|
+
itemDiscount = ((item.item_price * item.quantity) - promoDiscount) * singlePriceDiscount;
|
|
135
|
+
itemDiscount = parseFloat(itemDiscount).toFixed(2);
|
|
136
|
+
itemTotalDicount = parseFloat(itemDiscount) + parseFloat(itemTotalDicount);
|
|
137
|
+
|
|
138
|
+
if (itemDiscount > 0)
|
|
139
|
+
indexes.push(index);
|
|
140
|
+
|
|
141
|
+
item.points_discount = itemDiscount;
|
|
142
|
+
item.points_discount_modifier = 0;
|
|
143
|
+
|
|
144
|
+
let packDis = 0;
|
|
145
|
+
|
|
146
|
+
item.package_items.forEach((packageItem, packageItemIndex) => {
|
|
147
|
+
let packageItemPromoDiscount = (packageItem.promotion_discount) ? packageItem.promotion_discount : 0;
|
|
148
|
+
packageItem.points_discount_modifier = 0;
|
|
149
|
+
|
|
150
|
+
packageItem.points_discount = ((((packageItem.price * parseInt(item.quantity)) - parseFloat((packageItem.default_combo_discount)) - parseFloat(packageItemPromoDiscount))) * parseFloat(singlePriceDiscount)).toFixed(2);
|
|
151
|
+
packDis = (parseFloat(packDis) + parseFloat(packageItem.points_discount)).toFixed(2);
|
|
152
|
+
|
|
153
|
+
packageItem.modifiers.forEach((modi, modiIndex) => {
|
|
145
154
|
let modiItemAmount = 0;
|
|
146
155
|
let modiPromoDiscount = (modi.promotion_discount) ? modi.promotion_discount : 0;
|
|
147
156
|
modiItemAmount = (((parseFloat(modi.modifier_item_price) * parseInt(modi.quantity)) * item.quantity) - modiPromoDiscount) * parseFloat(singlePriceDiscount);
|
|
@@ -149,35 +158,73 @@ function getPointsDiscount(cartObject, points, userDetails) {
|
|
|
149
158
|
itemTotalDicount = parseFloat(itemTotalDicount) + parseFloat(modiItemAmount);
|
|
150
159
|
itemTotalDicount = parseFloat(itemTotalDicount).toFixed(2);
|
|
151
160
|
modi.points_discount = modiItemAmount;
|
|
161
|
+
packageItem.points_discount_modifier = (parseFloat(packageItem.points_discount_modifier) + parseFloat(modi.points_discount)).toFixed(2);
|
|
152
162
|
});
|
|
153
|
-
|
|
154
|
-
|
|
163
|
+
packageItem.points_discount_modifier = (parseFloat(packageItem.points_discount) + parseFloat(packageItem.points_discount_modifier)).toFixed(2);
|
|
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
|
+
}
|
|
155
174
|
}
|
|
156
175
|
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
176
|
+
} else {
|
|
177
|
+
if (item.point_discount_status) {
|
|
178
|
+
let promoDiscount = (item.promotion_discount) ? item.promotion_discount : 0;
|
|
179
|
+
itemDiscount = ((item.item_price * item.quantity) - promoDiscount) * singlePriceDiscount;
|
|
180
|
+
itemDiscount = parseFloat(itemDiscount).toFixed(2);
|
|
181
|
+
itemTotalDicount = parseFloat(itemDiscount) + parseFloat(itemTotalDicount);
|
|
182
|
+
|
|
183
|
+
if (itemDiscount > 0)
|
|
184
|
+
indexes.push(index);
|
|
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;
|
|
167
199
|
}
|
|
168
200
|
}
|
|
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
|
+
}
|
|
169
213
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
214
|
+
cartObject.item_details = carts
|
|
215
|
+
cartObject.store_value = pointsAmount
|
|
216
|
+
cartObject.point_discount_amount = pointsAmount
|
|
217
|
+
cartObject.delivery_discount = deliveryDiscount;
|
|
218
|
+
cartObject.service_discount = serviceDiscount;
|
|
173
219
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
});
|
|
220
|
+
resolve(cartObject);
|
|
221
|
+
}
|
|
177
222
|
} else {
|
|
178
223
|
cartObject.item_details = carts
|
|
179
224
|
cartObject.store_value = pointsAmount
|
|
180
225
|
cartObject.point_discount_amount = pointsAmount
|
|
226
|
+
cartObject.delivery_discount = 0;
|
|
227
|
+
cartObject.service_discount = 0;
|
|
181
228
|
|
|
182
229
|
resolve(cartObject);
|
|
183
230
|
}
|
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
|
+
// let json = JSON.parse(fs.readFileSync('./sampleInput.json', 'utf8'));
|
|
364
364
|
// calculateTax(json).then(res=>{
|
|
365
|
-
//
|
|
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
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
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
|
+
}
|