foodbot-cart-calculations 1.0.22 → 1.0.24

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.
Files changed (3) hide show
  1. package/calculations.js +18 -11
  2. package/index.js +144 -604
  3. package/package.json +1 -1
package/calculations.js CHANGED
@@ -52,6 +52,8 @@ function applyDistribution(body) {
52
52
  }
53
53
  taxCalculation.calculateTax2(final, taxSettings, taxType).then(taxData => {
54
54
  taxData.sub_total = taxData.cartTotal;
55
+ mainCart.final_amount = parseFloat(taxData.cartTotal);
56
+ mainCart.cash_expected = parseFloat(taxData.cartTotal) ;
55
57
  taxData.total_after_tax = taxData.cartTotal
56
58
  if (body.tax_type == 2) {
57
59
  taxData.sub_total = taxData.cartTotal - taxData.tax_amount
@@ -59,25 +61,33 @@ function applyDistribution(body) {
59
61
  }
60
62
  else {
61
63
  taxData.total_after_tax = parseFloat(taxData.cartTotal) + parseFloat(taxData.tax_amount)
62
- taxData.total_after_tax = parseFloat(taxData.total_after_tax).toFixed(2)
64
+ taxData.total_after_tax = parseFloat(taxData.total_after_tax).toFixed(2);
65
+
66
+ mainCart.final_amount = parseFloat(taxData.cartTotal) + parseFloat(taxData.tax_amount);
67
+ mainCart.cash_expected = parseFloat(taxData.cartTotal) + parseFloat(taxData.tax_amount);
63
68
  }
69
+ mainCart.order_items = taxData
70
+
71
+
72
+ let delivery_cost = body.delivery_cost?body.delivery_cost:0;
73
+ let service_amount = body.service_amount?body.service_amount:0;
74
+
75
+ mainCart.final_amount = parseFloat(mainCart.final_amount) + parseFloat(delivery_cost) + parseFloat(service_amount);
76
+ mainCart.cash_expected = parseFloat(mainCart.cash_expected) + parseFloat(delivery_cost) + parseFloat(service_amount);
64
77
 
65
78
  let tipValue = body.tip_value?body.tip_value:0;
66
79
 
67
80
  if (body.tip_type && body.tip_type == 'percentage') {
68
- tipValue = (taxData.total_after_tax * parseInt(tipValue)) / 100
81
+ tipValue = (mainCart.final_amount * parseInt(tipValue)) / 100
69
82
  tipValue = parseFloat(tipValue).toFixed(2)
70
83
  }
71
84
 
72
85
  taxData.total_after_tax = parseFloat(taxData.total_after_tax) + parseFloat(tipValue);
73
86
  taxData.total_after_tax = parseFloat(taxData.total_after_tax).toFixed(2);
74
-
75
-
76
- mainCart.order_items = taxData
77
- mainCart.final_amount = taxData.cartTotal
78
- mainCart.cash_expected = taxData.cartTotal
87
+
79
88
  mainCart.final_amount = parseFloat(mainCart.final_amount) + parseFloat(tipValue);
80
89
  mainCart.cash_expected = parseFloat(mainCart.cash_expected) + parseFloat(tipValue);
90
+
81
91
  taxData.final_amount = parseFloat(taxData.final_amount).toFixed(2);
82
92
  taxData.cash_expected = parseFloat(taxData.cash_expected).toFixed(2);
83
93
 
@@ -87,10 +97,7 @@ function applyDistribution(body) {
87
97
  mainCart.discount = mainCart.order_items.discount;
88
98
  mainCart.order_items.total=parseFloat(mainCart.order_items.total).toFixed(2)
89
99
 
90
- let delivery_cost = body.delivery_cost?body.delivery_cost:0;
91
- let service_amount = body.service_amount?body.service_amount:0;
92
- mainCart.final_amount = parseFloat(mainCart.final_amount) + parseFloat(delivery_cost) + parseFloat(service_amount);
93
- mainCart.cash_expected = parseFloat(mainCart.cash_expected) + parseFloat(delivery_cost) + parseFloat(service_amount);
100
+
94
101
  resolve(mainCart);
95
102
  }).catch(err => {
96
103
  reject(err);
package/index.js CHANGED
@@ -73,103 +73,51 @@ async function calculateTax(inputJSON) {
73
73
  }
74
74
 
75
75
  // let json ={
76
- // "tax_settings": [
77
- // {
78
- // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003",
79
- // "tax_label": "16% IVA",
80
- // "tax_rate": 16,
81
- // "tax_sequence": 1,
82
- // "base_price_effected": 0
83
- // },
84
- // {
85
- // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120002",
86
- // "tax_label": "8% IVA",
87
- // "tax_rate": 8,
88
- // "tax_sequence": 1,
89
- // "base_price_effected": 0
90
- // },
91
- // {
92
- // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac12000200",
93
- // "tax_label": "0% IVA",
94
- // "tax_rate": 0,
95
- // "tax_sequence": 3,
96
- // "base_price_effected": 0
97
- // },
98
- // {
99
- // "tax_id": "21036b00-bdb4-4485-aaba-d088a721a67f1",
100
- // "tax_label": "IEPS 8%",
101
- // "tax_rate": 8,
102
- // "tax_sequence": 2,
103
- // "base_price_effected": 0
104
- // }
105
- // ],
106
- // "tax_type": 2,
107
76
  // "order_items": {
108
- // "order_type": "dinein",
109
77
  // "item_details": [
110
78
  // {
111
- // "item_id": 8595,
112
- // "category_id": 501550,
113
- // "item_price": 122,
114
- // "menu_name": "SIngle Menu",
115
- // "category_name": "Special Burgers",
79
+ // "menu_id": 320,
80
+ // "item_id": 9030,
81
+ // "category_id": 501768,
82
+ // "item_price": 80,
83
+ // "item_price_with_modifier": 215,
116
84
  // "quantity": 1,
117
- // "item_display_text": "Cheese Burger 🍔",
118
- // "item_name": "Cheese Burger 🍔",
85
+ // "item_display_text": "daal rice",
86
+ // "item_name": "daal rice",
119
87
  // "tax_rate": 16,
120
88
  // "item_modifiers": [
121
89
  // {
122
90
  // "modifer_cat": 511432,
123
- // "modifier_caetgory_name": "Drinks ",
124
- // "modifier_item_id": 100911,
125
- // "modifier_sequence": 0,
91
+ // "modifier_caetgory_name": "Bebidas sin alcohol",
92
+ // "modifier_item_id": 101383,
93
+ // "modifier_category_sequence": "0",
94
+ // "modifier_sequence": "01",
126
95
  // "modifier_item_price": 20,
127
- // "modifier_item_name": "Sprite",
96
+ // "modifier_item_name": "Fanta",
128
97
  // "is_tax_rate_same": 1,
129
98
  // "tax_rate": 0,
130
99
  // "quantity": 1,
131
- // "item_id": 8595,
100
+ // "item_id": 9030,
132
101
  // "tax_id": [
133
102
  // {
134
103
  // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003"
135
104
  // }
136
105
  // ],
137
- // "modifier_trx_id": "4317-1d15-7bf8",
138
- // "linked_product": "",
139
- // "tax_amount": "2.758621",
140
- // "tax_array": [
141
- // {
142
- // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003",
143
- // "tax_label": "16% IVA",
144
- // "tax_rate": 16,
145
- // "tax_sequence": 1,
146
- // "base_price_effected": 0,
147
- // "tax_amount": "2.758621",
148
- // "base_price": "17.241379",
149
- // "tax_rate_quantity": 0
150
- // }
151
- // ],
152
- // "redeem_promotion_id": 5011767
153
- // },
154
- // {
155
- // "modifer_cat": 511432,
156
- // "modifier_caetgory_name": "Drinks ",
157
- // "modifier_item_id": 100912,
158
- // "modifier_sequence": 0,
159
- // "modifier_item_price": 25,
160
- // "modifier_item_name": "Cocacola",
161
- // "is_tax_rate_same": 1,
162
- // "tax_rate": 0,
163
- // "quantity": 1,
164
- // "item_id": 8595,
165
- // "tax_id": [
166
- // {
167
- // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003"
106
+ // "modifier_trx_id": "ScrxcTSU",
107
+ // "linked_product": {
108
+ // "product_id": 9081,
109
+ // "product_tax_id": [
110
+ // {
111
+ // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003"
112
+ // }
113
+ // ],
114
+ // "product_name": "Dairy Milk",
115
+ // "category_id": 501803,
116
+ // "ieps_tax": {
117
+ // "status": 0
168
118
  // }
169
- // ],
170
- // "modifier_trx_id": "ba8b-c9ed-2386",
171
- // "linked_product": "",
172
- // "tax_amount": "3.448276",
119
+ // },
120
+ // "tax_amount": "6.400000",
173
121
  // "tax_array": [
174
122
  // {
175
123
  // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003",
@@ -177,103 +125,44 @@ async function calculateTax(inputJSON) {
177
125
  // "tax_rate": 16,
178
126
  // "tax_sequence": 1,
179
127
  // "base_price_effected": 0,
180
- // "tax_amount": "3.448276",
181
- // "base_price": "21.551724",
128
+ // "tax_amount": "6.400000",
129
+ // "base_price": 40,
182
130
  // "tax_rate_quantity": 0
183
131
  // }
184
- // ],
185
- // "redeem_promotion_id": 5011767
186
- // }
187
- // ],
188
- // "isPackage": 0,
189
- // "price_list_id": "56e55ca6-d246-11ed-8811-0e2fd5e35c29",
190
- // "item_price_with_modifier": 167,
191
- // "package_items": [],
192
- // "item_event": "update",
193
- // "actual_price": 0,
194
- // "tax_id": [
195
- // {
196
- // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003"
197
- // }
198
- // ],
199
- // "menu_id": 210,
200
- // "item_trx_id": "b1e3-96f1-2cd8",
201
- // "special_instruction": "",
202
- // "ieps_tax": {
203
- // "status": 1,
204
- // "ieps_details": {
205
- // "type": "2",
206
- // "tax_id": 5
207
- // }
208
- // },
209
- // "sync": true,
210
- // "wa_user_info": {
211
- // "user_id": 382,
212
- // "user_name": "Lee Jung-suk",
213
- // "version": 1,
214
- // "added_at": "2024-03-29 05:06:36"
215
- // },
216
- // "tax_amount": "21.827586",
217
- // "tax_array": [
218
- // {
219
- // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003",
220
- // "tax_label": "16% IVA",
221
- // "tax_rate": 16,
222
- // "tax_sequence": 1,
223
- // "base_price_effected": 0,
224
- // "tax_amount": "16.827586",
225
- // "base_price": "105.172414",
226
- // "tax_rate_quantity": 5
132
+ // ]
227
133
  // },
228
134
  // {
229
- // "base_price_effected": 0,
230
- // "tax_sequence": 2,
231
- // "tax_label": "IEPS",
232
- // "ieps_type": 2,
233
- // "tax_id": "absolute",
234
- // "tax_rate": 0.049914,
235
- // "tax_amount": "5.000000",
236
- // "base_price": 100.172414,
237
- // "tax_rate_quantity": 5
238
- // }
239
- // ],
240
- // "tax_amount_modifier": "28.034483",
241
- // "total_tax_amount": "28.034483",
242
- // "order_version": 1,
243
- // "redeem_promotion_id": 5011767,
244
- // "promotion_discount_modifier": "83.64",
245
- // "promotion_discount": 0
246
- // },
247
- // {
248
- // "item_id": 8595,
249
- // "category_id": 501550,
250
- // "item_price": 122,
251
- // "menu_name": "SIngle Menu",
252
- // "category_name": "Special Burgers",
253
- // "quantity": 1,
254
- // "item_display_text": "Cheese Burger 🍔",
255
- // "item_name": "Cheese Burger 🍔",
256
- // "tax_rate": 16,
257
- // "item_modifiers": [
258
- // {
259
135
  // "modifer_cat": 511432,
260
- // "modifier_caetgory_name": "Drinks ",
261
- // "modifier_item_id": 100911,
262
- // "modifier_sequence": 0,
263
- // "modifier_item_price": 20,
264
- // "modifier_item_name": "Sprite",
136
+ // "modifier_caetgory_name": "Bebidas sin alcohol",
137
+ // "modifier_item_id": 101384,
138
+ // "modifier_category_sequence": "0",
139
+ // "modifier_sequence": "02",
140
+ // "modifier_item_price": 35,
141
+ // "modifier_item_name": "Mountain Dew",
265
142
  // "is_tax_rate_same": 1,
266
143
  // "tax_rate": 0,
267
144
  // "quantity": 1,
268
- // "item_id": 8595,
145
+ // "item_id": 9030,
269
146
  // "tax_id": [
270
147
  // {
271
148
  // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003"
272
149
  // }
273
150
  // ],
274
- // "modifier_trx_id": "7ee0-bb85-9839",
275
- // "linked_product": "",
276
- // "tax_amount": "2.758621",
151
+ // "modifier_trx_id": "BGDqI7yI",
152
+ // "linked_product": {
153
+ // "product_id": 9081,
154
+ // "product_tax_id": [
155
+ // {
156
+ // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003"
157
+ // }
158
+ // ],
159
+ // "product_name": "Dairy Milk",
160
+ // "category_id": 501803,
161
+ // "ieps_tax": {
162
+ // "status": 0
163
+ // }
164
+ // },
165
+ // "tax_amount": "11.200000",
277
166
  // "tax_array": [
278
167
  // {
279
168
  // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003",
@@ -281,103 +170,44 @@ async function calculateTax(inputJSON) {
281
170
  // "tax_rate": 16,
282
171
  // "tax_sequence": 1,
283
172
  // "base_price_effected": 0,
284
- // "tax_amount": "2.758621",
285
- // "base_price": "17.241379",
173
+ // "tax_amount": "11.200000",
174
+ // "base_price": 70,
286
175
  // "tax_rate_quantity": 0
287
176
  // }
288
- // ],
289
- // "redeem_promotion_id": 5011767
290
- // }
291
- // ],
292
- // "isPackage": 0,
293
- // "price_list_id": "56e55ca6-d246-11ed-8811-0e2fd5e35c29",
294
- // "item_price_with_modifier": 142,
295
- // "package_items": [],
296
- // "item_event": "update",
297
- // "actual_price": 0,
298
- // "tax_id": [
299
- // {
300
- // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003"
301
- // }
302
- // ],
303
- // "menu_id": 210,
304
- // "item_trx_id": "8c6f-db9f-ad64",
305
- // "special_instruction": "",
306
- // "ieps_tax": {
307
- // "status": 1,
308
- // "ieps_details": {
309
- // "type": "2",
310
- // "tax_id": 5
311
- // }
312
- // },
313
- // "sync": true,
314
- // "wa_user_info": {
315
- // "user_id": 382,
316
- // "user_name": "Lee Jung-suk",
317
- // "version": 2,
318
- // "added_at": "2024-04-01 04:24:21"
319
- // },
320
- // "tax_amount": "21.827586",
321
- // "tax_array": [
322
- // {
323
- // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003",
324
- // "tax_label": "16% IVA",
325
- // "tax_rate": 16,
326
- // "tax_sequence": 1,
327
- // "base_price_effected": 0,
328
- // "tax_amount": "16.827586",
329
- // "base_price": "105.172414",
330
- // "tax_rate_quantity": 5
177
+ // ]
331
178
  // },
332
179
  // {
333
- // "base_price_effected": 0,
334
- // "tax_sequence": 2,
335
- // "tax_label": "IEPS",
336
- // "ieps_type": 2,
337
- // "tax_id": "absolute",
338
- // "tax_rate": 0.049914,
339
- // "tax_amount": "5.000000",
340
- // "base_price": 100.172414,
341
- // "tax_rate_quantity": 5
342
- // }
343
- // ],
344
- // "tax_amount_modifier": "24.586207",
345
- // "total_tax_amount": "24.586207",
346
- // "order_version": 2,
347
- // "redeem_promotion_id": 5011767,
348
- // "promotion_discount_modifier": "71.09",
349
- // "promotion_discount": 0
350
- // },
351
- // {
352
- // "item_id": 8595,
353
- // "category_id": 501550,
354
- // "item_price": 122,
355
- // "menu_name": "SIngle Menu",
356
- // "category_name": "Special Burgers",
357
- // "quantity": 1,
358
- // "item_display_text": "Cheese Burger 🍔",
359
- // "item_name": "Cheese Burger 🍔",
360
- // "tax_rate": 16,
361
- // "item_modifiers": [
362
- // {
363
180
  // "modifer_cat": 511432,
364
- // "modifier_caetgory_name": "Drinks ",
365
- // "modifier_item_id": 100911,
366
- // "modifier_sequence": 0,
367
- // "modifier_item_price": 20,
368
- // "modifier_item_name": "Sprite",
181
+ // "modifier_caetgory_name": "Bebidas sin alcohol",
182
+ // "modifier_item_id": 101385,
183
+ // "modifier_category_sequence": "0",
184
+ // "modifier_sequence": "03",
185
+ // "modifier_item_price": 30,
186
+ // "modifier_item_name": "Pepsi",
369
187
  // "is_tax_rate_same": 1,
370
188
  // "tax_rate": 0,
371
189
  // "quantity": 1,
372
- // "item_id": 8595,
190
+ // "item_id": 9030,
373
191
  // "tax_id": [
374
192
  // {
375
193
  // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003"
376
194
  // }
377
195
  // ],
378
- // "modifier_trx_id": "3196-0707-a583",
379
- // "linked_product": "",
380
- // "tax_amount": "2.758621",
196
+ // "modifier_trx_id": "hUiiwipa",
197
+ // "linked_product": {
198
+ // "product_id": 9081,
199
+ // "product_tax_id": [
200
+ // {
201
+ // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003"
202
+ // }
203
+ // ],
204
+ // "product_name": "Dairy Milk",
205
+ // "category_id": 501803,
206
+ // "ieps_tax": {
207
+ // "status": 0
208
+ // }
209
+ // },
210
+ // "tax_amount": "9.600000",
381
211
  // "tax_array": [
382
212
  // {
383
213
  // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003",
@@ -385,104 +215,32 @@ async function calculateTax(inputJSON) {
385
215
  // "tax_rate": 16,
386
216
  // "tax_sequence": 1,
387
217
  // "base_price_effected": 0,
388
- // "tax_amount": "2.758621",
389
- // "base_price": "17.241379",
218
+ // "tax_amount": "9.600000",
219
+ // "base_price": 60,
390
220
  // "tax_rate_quantity": 0
391
221
  // }
392
- // ],
393
- // "redeem_promotion_id": 5011767
394
- // }
395
- // ],
396
- // "isPackage": 0,
397
- // "price_list_id": "56e55ca6-d246-11ed-8811-0e2fd5e35c29",
398
- // "item_price_with_modifier": 142,
399
- // "package_items": [],
400
- // "item_event": "update",
401
- // "actual_price": 0,
402
- // "tax_id": [
403
- // {
404
- // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003"
405
- // }
406
- // ],
407
- // "menu_id": 210,
408
- // "item_trx_id": "fe42-3d45-8b3d",
409
- // "special_instruction": "",
410
- // "ieps_tax": {
411
- // "status": 1,
412
- // "ieps_details": {
413
- // "type": "2",
414
- // "tax_id": 5
415
- // }
416
- // },
417
- // "sync": true,
418
- // "wa_user_info": {
419
- // "user_id": 382,
420
- // "user_name": "Lee Jung-suk",
421
- // "version": 3,
422
- // "added_at": "2024-04-01 04:32:48"
423
- // },
424
- // "tax_amount": "21.827586",
425
- // "tax_array": [
426
- // {
427
- // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003",
428
- // "tax_label": "16% IVA",
429
- // "tax_rate": 16,
430
- // "tax_sequence": 1,
431
- // "base_price_effected": 0,
432
- // "tax_amount": "16.827586",
433
- // "base_price": "105.172414",
434
- // "tax_rate_quantity": 5
222
+ // ]
435
223
  // },
436
224
  // {
437
- // "base_price_effected": 0,
438
- // "tax_sequence": 2,
439
- // "tax_label": "IEPS",
440
- // "ieps_type": 2,
441
- // "tax_id": "absolute",
442
- // "tax_rate": 0.049914,
443
- // "tax_amount": "5.000000",
444
- // "base_price": 100.172414,
445
- // "tax_rate_quantity": 5
446
- // }
447
- // ],
448
- // "tax_amount_modifier": "24.586207",
449
- // "total_tax_amount": "24.586207",
450
- // "order_version": 3,
451
- // "redeem_promotion_id": 5011767,
452
- // "promotion_discount_modifier": "71.09",
453
- // "promotion_discount": 0
454
- // },
455
- // {
456
- // "item_id": 8595,
457
- // "category_id": 501550,
458
- // "item_price": 122,
459
- // "menu_name": "SIngle Menu",
460
- // "category_name": "Special Burgers",
461
- // "quantity": 1,
462
- // "item_display_text": "Cheese Burger 🍔",
463
- // "item_name": "Cheese Burger 🍔",
464
- // "tax_rate": 16,
465
- // "item_modifiers": [
466
- // {
467
225
  // "modifer_cat": 511432,
468
- // "modifier_caetgory_name": "Drinks ",
469
- // "modifier_item_id": 100911,
470
- // "modifier_sequence": 0,
226
+ // "modifier_caetgory_name": "Bebidas sin alcohol",
227
+ // "modifier_item_id": 101386,
228
+ // "modifier_category_sequence": "0",
229
+ // "modifier_sequence": "04",
471
230
  // "modifier_item_price": 20,
472
- // "modifier_item_name": "Sprite",
231
+ // "modifier_item_name": "Spirte",
473
232
  // "is_tax_rate_same": 1,
474
233
  // "tax_rate": 0,
475
234
  // "quantity": 1,
476
- // "item_id": 8595,
235
+ // "item_id": 9030,
477
236
  // "tax_id": [
478
237
  // {
479
238
  // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003"
480
239
  // }
481
240
  // ],
482
- // "modifier_trx_id": "d8bc-ddcd-bfe5",
241
+ // "modifier_trx_id": "TfPyHHK7",
483
242
  // "linked_product": "",
484
- // "redeem_promotion_id": 5011767,
485
- // "tax_amount": "2.758621",
243
+ // "tax_amount": "6.400000",
486
244
  // "tax_array": [
487
245
  // {
488
246
  // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003",
@@ -490,103 +248,32 @@ async function calculateTax(inputJSON) {
490
248
  // "tax_rate": 16,
491
249
  // "tax_sequence": 1,
492
250
  // "base_price_effected": 0,
493
- // "tax_amount": "2.758621",
494
- // "base_price": "17.241379",
251
+ // "tax_amount": "6.400000",
252
+ // "base_price": 40,
495
253
  // "tax_rate_quantity": 0
496
254
  // }
497
255
  // ]
498
- // }
499
- // ],
500
- // "isPackage": 0,
501
- // "price_list_id": "56e55ca6-d246-11ed-8811-0e2fd5e35c29",
502
- // "item_price_with_modifier": 142,
503
- // "package_items": [],
504
- // "item_event": "update",
505
- // "actual_price": 0,
506
- // "tax_id": [
507
- // {
508
- // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003"
509
- // }
510
- // ],
511
- // "menu_id": 210,
512
- // "item_trx_id": "d9ab-97e4-f606",
513
- // "special_instruction": "",
514
- // "ieps_tax": {
515
- // "status": 1,
516
- // "ieps_details": {
517
- // "type": "2",
518
- // "tax_id": 5
519
- // }
520
- // },
521
- // "sync": true,
522
- // "wa_user_info": {
523
- // "user_id": 382,
524
- // "user_name": "Lee Jung-suk",
525
- // "version": 4,
526
- // "added_at": "2024-04-01 04:46:07"
527
- // },
528
- // "redeem_promotion_id": 5011767,
529
- // "promotion_discount_modifier": "71.09",
530
- // "tax_amount": "21.827586",
531
- // "tax_array": [
532
- // {
533
- // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003",
534
- // "tax_label": "16% IVA",
535
- // "tax_rate": 16,
536
- // "tax_sequence": 1,
537
- // "base_price_effected": 0,
538
- // "tax_amount": "16.827586",
539
- // "base_price": "105.172414",
540
- // "tax_rate_quantity": 5
541
256
  // },
542
257
  // {
543
- // "base_price_effected": 0,
544
- // "tax_sequence": 2,
545
- // "tax_label": "IEPS",
546
- // "ieps_type": 2,
547
- // "tax_id": "absolute",
548
- // "tax_rate": 0.049914,
549
- // "tax_amount": "5.000000",
550
- // "base_price": 100.172414,
551
- // "tax_rate_quantity": 5
552
- // }
553
- // ],
554
- // "tax_amount_modifier": "24.586207",
555
- // "total_tax_amount": "24.586207",
556
- // "order_version": 4,
557
- // "promotion_discount": 0
558
- // },
559
- // {
560
- // "item_id": 8595,
561
- // "category_id": 501550,
562
- // "item_price": 122,
563
- // "menu_name": "SIngle Menu",
564
- // "category_name": "Special Burgers",
565
- // "quantity": 1,
566
- // "item_display_text": "Cheese Burger 🍔",
567
- // "item_name": "Cheese Burger 🍔",
568
- // "tax_rate": 16,
569
- // "item_modifiers": [
570
- // {
571
258
  // "modifer_cat": 511432,
572
- // "modifier_caetgory_name": "Drinks ",
573
- // "modifier_item_id": 100911,
574
- // "modifier_sequence": 0,
575
- // "modifier_item_price": 20,
576
- // "modifier_item_name": "Sprite",
259
+ // "modifier_caetgory_name": "Bebidas sin alcohol",
260
+ // "modifier_item_id": 101387,
261
+ // "modifier_category_sequence": "0",
262
+ // "modifier_sequence": "05",
263
+ // "modifier_item_price": 30,
264
+ // "modifier_item_name": "Thumbs Up",
577
265
  // "is_tax_rate_same": 1,
578
266
  // "tax_rate": 0,
579
267
  // "quantity": 1,
580
- // "item_id": 8595,
268
+ // "item_id": 9030,
581
269
  // "tax_id": [
582
270
  // {
583
271
  // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003"
584
272
  // }
585
273
  // ],
586
- // "modifier_trx_id": "c3b8-a367-4bbd",
274
+ // "modifier_trx_id": "5Yw17Q21",
587
275
  // "linked_product": "",
588
- // "redeem_promotion_id": 5011767,
589
- // "tax_amount": "2.758621",
276
+ // "tax_amount": "9.600000",
590
277
  // "tax_array": [
591
278
  // {
592
279
  // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003",
@@ -594,44 +281,28 @@ async function calculateTax(inputJSON) {
594
281
  // "tax_rate": 16,
595
282
  // "tax_sequence": 1,
596
283
  // "base_price_effected": 0,
597
- // "tax_amount": "2.758621",
598
- // "base_price": "17.241379",
284
+ // "tax_amount": "9.600000",
285
+ // "base_price": 60,
599
286
  // "tax_rate_quantity": 0
600
287
  // }
601
288
  // ]
602
289
  // }
603
290
  // ],
604
291
  // "isPackage": 0,
605
- // "price_list_id": "56e55ca6-d246-11ed-8811-0e2fd5e35c29",
606
- // "item_price_with_modifier": 142,
607
292
  // "package_items": [],
608
- // "item_event": "update",
609
293
  // "actual_price": 0,
294
+ // "item_event": "new",
610
295
  // "tax_id": [
611
296
  // {
612
297
  // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003"
613
298
  // }
614
299
  // ],
615
- // "menu_id": 210,
616
- // "item_trx_id": "3546-1fdf-8b16",
617
- // "special_instruction": "",
618
300
  // "ieps_tax": {
619
- // "status": 1,
620
- // "ieps_details": {
621
- // "type": "2",
622
- // "tax_id": 5
623
- // }
624
- // },
625
- // "sync": true,
626
- // "wa_user_info": {
627
- // "user_id": 382,
628
- // "user_name": "Lee Jung-suk",
629
- // "version": 5,
630
- // "added_at": "2024-04-01 04:53:04"
301
+ // "status": 0
631
302
  // },
632
- // "redeem_promotion_id": 5011767,
633
- // "promotion_discount_modifier": "71.09",
634
- // "tax_amount": "21.827586",
303
+ // "item_trx_id": "6nfb34q9",
304
+ // "special_instruction": "",
305
+ // "tax_amount": "25.600000",
635
306
  // "tax_array": [
636
307
  // {
637
308
  // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003",
@@ -639,183 +310,52 @@ async function calculateTax(inputJSON) {
639
310
  // "tax_rate": 16,
640
311
  // "tax_sequence": 1,
641
312
  // "base_price_effected": 0,
642
- // "tax_amount": "16.827586",
643
- // "base_price": "105.172414",
644
- // "tax_rate_quantity": 5
645
- // },
646
- // {
647
- // "base_price_effected": 0,
648
- // "tax_sequence": 2,
649
- // "tax_label": "IEPS",
650
- // "ieps_type": 2,
651
- // "tax_id": "absolute",
652
- // "tax_rate": 0.049914,
653
- // "tax_amount": "5.000000",
654
- // "base_price": 100.172414,
655
- // "tax_rate_quantity": 5
313
+ // "tax_amount": "25.600000",
314
+ // "base_price": 160,
315
+ // "tax_rate_quantity": 0
656
316
  // }
657
317
  // ],
658
- // "tax_amount_modifier": "24.586207",
659
- // "total_tax_amount": "24.586207",
660
- // "order_version": 5,
318
+ // "tax_amount_modifier": "68.800000",
319
+ // "total_tax_amount": "68.800000",
320
+ // "active": true,
661
321
  // "promotion_discount": 0
662
322
  // }
663
323
  // ]
664
324
  // },
665
- // "order_type": "dinein",
666
- // "request_id": "82ec2674b088fcaa",
667
- // "restaurant_id": 400,
668
- // "branch_id": 1803,
669
- // "loyalty_points_details": {
670
- // "points": 2997,
671
- // "redeemable": "yes",
672
- // "store_value": "2997.00",
673
- // "redeem_categories": [
674
- // {
675
- // "product_id": "All",
676
- // "category_id": "All"
677
- // }
678
- // ],
679
- // "status": false,
680
- // "points_redeemed": 0
681
- // },
682
- // "store_value": 2997,
683
- // "user_detais": {
684
- // "first_name": "Sahil Sharma",
685
- // "name": "Sahil Sharma",
686
- // "member_id": "e8556b91-c29f-4bd3-80e3-1fa1e7f8b7f8",
687
- // "phone_number": "9103180340",
688
- // "mobile": "9103180340",
689
- // "store_value": 2997,
690
- // "reward_plan_id": 22,
691
- // "reward_plan_name": "new plan"
692
- // },
693
- // "promotion_applied": {
694
- // "offer_id": 5011839,
695
- // "en_id": 26040,
696
- // "offer_type": "user_specific",
697
- // "validity_from": "1-Abr-2024",
698
- // "validity_to": "27-Mar-2025",
699
- // "description": "FOOD COMBO OFFERS",
700
- // "promotion_image": "https://res.cloudinary.com/dn2mchqlr/image/upload/f_auto,q_auto,fl_lossy/v1708081791/stage/spec.%20promo/file1708081791221sp_g0fnnf.jpg",
701
- // "titile": "FOOD COMBO OFFERS",
702
- // "subtitle": "valid untill",
703
- // "oo_min_amount": 1,
704
- // "oo_offer_type": "percentage",
705
- // "oo_offer_value": 75,
706
- // "offer_discount_type": "free_product",
707
- // "max_product": "1",
708
- // "modifier_category": [
709
- // "all"
710
- // ],
711
- // "valid_days": "Lun a Vie",
712
- // "popup_status": 1,
713
- // "oo_order_type": {
714
- // "dinein": "no",
715
- // "takeout": "yes",
716
- // "delivery": "yes"
325
+ // "tax_settings": [
326
+ // {
327
+ // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003",
328
+ // "tax_label": "16% IVA",
329
+ // "tax_rate": 16,
330
+ // "tax_sequence": 1,
331
+ // "base_price_effected": 0
332
+ // },
333
+ // {
334
+ // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120002",
335
+ // "tax_label": "8% IVA",
336
+ // "tax_rate": 8,
337
+ // "tax_sequence": 1,
338
+ // "base_price_effected": 0
717
339
  // },
718
- // "promotion_code": null,
719
- // "discount_roundoff": 1,
720
- // "oo_status": 3,
721
- // "redeem_description": null,
722
- // "redeem_timer": 0,
723
- // "redeemption_intiated_timestamp": null,
724
- // "redeem_source": null,
725
- // "status": 0,
726
- // "offer_products": {
727
- // "offer_discount_products": [
728
- // 24,
729
- // 641,
730
- // 643,
731
- // 645,
732
- // 646,
733
- // 647,
734
- // 648,
735
- // 650,
736
- // 653,
737
- // 654,
738
- // 656,
739
- // 691,
740
- // 898,
741
- // 921,
742
- // 927,
743
- // 3861,
744
- // 5565,
745
- // 5568,
746
- // 5572,
747
- // 5573,
748
- // 5587,
749
- // 5594,
750
- // 5595,
751
- // 5636,
752
- // 5717,
753
- // 8595,
754
- // 8596,
755
- // 8597,
756
- // 8607,
757
- // 8610,
758
- // 8612,
759
- // 8613,
760
- // 8614,
761
- // 8615,
762
- // 8616,
763
- // 8617,
764
- // 8618,
765
- // 8619,
766
- // 8620,
767
- // 8621,
768
- // 8622,
769
- // 8623,
770
- // 8625,
771
- // 8626,
772
- // 8629,
773
- // 8632,
774
- // 8633,
775
- // 8634,
776
- // 8635,
777
- // 8673,
778
- // 8711,
779
- // 8777,
780
- // 8780,
781
- // 8781,
782
- // 8782,
783
- // 8785,
784
- // 8811,
785
- // 8816,
786
- // 8817,
787
- // 8818,
788
- // 8833,
789
- // 8834,
790
- // 8835,
791
- // 8836,
792
- // 8837,
793
- // 8856,
794
- // 8857,
795
- // 8858,
796
- // 8859,
797
- // 8861,
798
- // 8862,
799
- // 8863,
800
- // 8864,
801
- // 8885,
802
- // 8901,
803
- // 8902,
804
- // 8906,
805
- // 8910,
806
- // 8911
807
- // ],
808
- // "package_items": [],
809
- // "order_multi_use": 1,
810
- // "order_modifiercost_use": 1,
811
- // "modifier_category": [
812
- // "all"
813
- // ],
814
- // "max_product": "1"
340
+ // {
341
+ // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac12000200",
342
+ // "tax_label": "0% IVA",
343
+ // "tax_rate": 0,
344
+ // "tax_sequence": 3,
345
+ // "base_price_effected": 0
815
346
  // },
816
- // "promotion_id": 5011839,
817
- // "promotion_type": "user_specific"
818
- // }
347
+ // {
348
+ // "tax_id": "21036b00-bdb4-4485-aaba-d088a721a67f1",
349
+ // "tax_label": "IEPS 8%",
350
+ // "tax_rate": 8,
351
+ // "tax_sequence": 2,
352
+ // "base_price_effected": 0
353
+ // }
354
+ // ],
355
+ // "tax_type": 1,
356
+ // "store_value": 0,
357
+ // "delivery_cost": 0,
358
+ // "service_amount": 0
819
359
  // }
820
360
 
821
361
  // calculateTax(json).then(res=>{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foodbot-cart-calculations",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "description": "Package for cart calculations in which it performs discount distribution and tax distribution on order",
5
5
  "main": "index.js",
6
6
  "scripts": {