foodbot-cart-calculations 1.0.21 → 1.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/calculations.js CHANGED
@@ -61,23 +61,29 @@ function applyDistribution(body) {
61
61
  taxData.total_after_tax = parseFloat(taxData.cartTotal) + parseFloat(taxData.tax_amount)
62
62
  taxData.total_after_tax = parseFloat(taxData.total_after_tax).toFixed(2)
63
63
  }
64
+ mainCart.order_items = taxData
65
+ mainCart.final_amount = taxData.cartTotal
66
+ mainCart.cash_expected = taxData.cartTotal
67
+
68
+ let delivery_cost = body.delivery_cost?body.delivery_cost:0;
69
+ let service_amount = body.service_amount?body.service_amount:0;
70
+
71
+ mainCart.final_amount = parseFloat(mainCart.final_amount) + parseFloat(delivery_cost) + parseFloat(service_amount);
72
+ mainCart.cash_expected = parseFloat(mainCart.cash_expected) + parseFloat(delivery_cost) + parseFloat(service_amount);
64
73
 
65
74
  let tipValue = body.tip_value?body.tip_value:0;
66
75
 
67
76
  if (body.tip_type && body.tip_type == 'percentage') {
68
- tipValue = (taxData.total_after_tax * parseInt(tipValue)) / 100
77
+ tipValue = (mainCart.final_amount * parseInt(tipValue)) / 100
69
78
  tipValue = parseFloat(tipValue).toFixed(2)
70
79
  }
71
80
 
72
81
  taxData.total_after_tax = parseFloat(taxData.total_after_tax) + parseFloat(tipValue);
73
82
  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
83
+
79
84
  mainCart.final_amount = parseFloat(mainCart.final_amount) + parseFloat(tipValue);
80
85
  mainCart.cash_expected = parseFloat(mainCart.cash_expected) + parseFloat(tipValue);
86
+
81
87
  taxData.final_amount = parseFloat(taxData.final_amount).toFixed(2);
82
88
  taxData.cash_expected = parseFloat(taxData.cash_expected).toFixed(2);
83
89
 
@@ -86,6 +92,8 @@ function applyDistribution(body) {
86
92
 
87
93
  mainCart.discount = mainCart.order_items.discount;
88
94
  mainCart.order_items.total=parseFloat(mainCart.order_items.total).toFixed(2)
95
+
96
+
89
97
  resolve(mainCart);
90
98
  }).catch(err => {
91
99
  reject(err);
@@ -31,6 +31,7 @@ function offerCalculation(carts, offer) {
31
31
  if (offer && offer.offer_discount_type && offer.offer_discount_type == 'buy_x_get_y') {
32
32
  getOfferDetails(carts, offer).then(res => {
33
33
  carts = res
34
+ console.log("res",res)
34
35
  if (offer && offer.oo_offer_type == 'percentage' && offer.discount_roundoff && offer.discount_roundoff == 1) {
35
36
 
36
37
  // offer.oo_offer_types = JSON.parse(JSON.stringify(offer.oo_offer_type))
@@ -438,9 +439,7 @@ function getOfferDetails(carts, offer = []) {
438
439
  const offerBuyProducts = offer.offer_products.offer_buy_products.map(Number);
439
440
  const offerGetProducts = offer.offer_products.offer_get_products.map(Number);
440
441
  addItemQuantity(carts.item_details, offer).then((data) => {
441
-
442
- const descending = data.sort((a, b) => (parseInt(b.amount) < parseInt(a.amount)) ? -1 : 1);
443
- // console.log("data where we sort based on amount",JSON.stringify(descending))
442
+ const descending = data.sort((a, b) => (parseInt(b.amount) > parseInt(a.amount)) ? -1 : 1);
444
443
  let total = 0
445
444
  let buyItemAmount=0;
446
445
  let buyItemss =[]
package/index.js CHANGED
@@ -72,757 +72,211 @@ async function calculateTax(inputJSON) {
72
72
  })
73
73
  }
74
74
 
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
- // "order_items": {
108
- // "order_type": "dinein",
109
- // "item_details": [
110
- // {
111
- // "item_id": 8595,
112
- // "category_id": 501550,
113
- // "item_price": 122,
114
- // "menu_name": "SIngle Menu",
115
- // "category_name": "Special Burgers",
116
- // "quantity": 1,
117
- // "item_display_text": "Cheese Burger 🍔",
118
- // "item_name": "Cheese Burger 🍔",
119
- // "tax_rate": 16,
120
- // "item_modifiers": [
121
- // {
122
- // "modifer_cat": 511432,
123
- // "modifier_caetgory_name": "Drinks ",
124
- // "modifier_item_id": 100911,
125
- // "modifier_sequence": 0,
126
- // "modifier_item_price": 20,
127
- // "modifier_item_name": "Sprite",
128
- // "is_tax_rate_same": 1,
129
- // "tax_rate": 0,
130
- // "quantity": 1,
131
- // "item_id": 8595,
132
- // "tax_id": [
133
- // {
134
- // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003"
135
- // }
136
- // ],
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"
168
- // }
169
- // ],
170
- // "modifier_trx_id": "ba8b-c9ed-2386",
171
- // "linked_product": "",
172
- // "tax_amount": "3.448276",
173
- // "tax_array": [
174
- // {
175
- // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003",
176
- // "tax_label": "16% IVA",
177
- // "tax_rate": 16,
178
- // "tax_sequence": 1,
179
- // "base_price_effected": 0,
180
- // "tax_amount": "3.448276",
181
- // "base_price": "21.551724",
182
- // "tax_rate_quantity": 0
183
- // }
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
227
- // },
228
- // {
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
- // "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",
265
- // "is_tax_rate_same": 1,
266
- // "tax_rate": 0,
267
- // "quantity": 1,
268
- // "item_id": 8595,
269
- // "tax_id": [
270
- // {
271
- // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003"
272
- // }
273
- // ],
274
- // "modifier_trx_id": "7ee0-bb85-9839",
275
- // "linked_product": "",
276
- // "tax_amount": "2.758621",
277
- // "tax_array": [
278
- // {
279
- // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003",
280
- // "tax_label": "16% IVA",
281
- // "tax_rate": 16,
282
- // "tax_sequence": 1,
283
- // "base_price_effected": 0,
284
- // "tax_amount": "2.758621",
285
- // "base_price": "17.241379",
286
- // "tax_rate_quantity": 0
287
- // }
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
331
- // },
332
- // {
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
- // "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",
369
- // "is_tax_rate_same": 1,
370
- // "tax_rate": 0,
371
- // "quantity": 1,
372
- // "item_id": 8595,
373
- // "tax_id": [
374
- // {
375
- // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003"
376
- // }
377
- // ],
378
- // "modifier_trx_id": "3196-0707-a583",
379
- // "linked_product": "",
380
- // "tax_amount": "2.758621",
381
- // "tax_array": [
382
- // {
383
- // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003",
384
- // "tax_label": "16% IVA",
385
- // "tax_rate": 16,
386
- // "tax_sequence": 1,
387
- // "base_price_effected": 0,
388
- // "tax_amount": "2.758621",
389
- // "base_price": "17.241379",
390
- // "tax_rate_quantity": 0
391
- // }
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
435
- // },
436
- // {
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
- // "modifer_cat": 511432,
468
- // "modifier_caetgory_name": "Drinks ",
469
- // "modifier_item_id": 100911,
470
- // "modifier_sequence": 0,
471
- // "modifier_item_price": 20,
472
- // "modifier_item_name": "Sprite",
473
- // "is_tax_rate_same": 1,
474
- // "tax_rate": 0,
475
- // "quantity": 1,
476
- // "item_id": 8595,
477
- // "tax_id": [
478
- // {
479
- // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003"
480
- // }
481
- // ],
482
- // "modifier_trx_id": "d8bc-ddcd-bfe5",
483
- // "linked_product": "",
484
- // "redeem_promotion_id": 5011767,
485
- // "tax_amount": "2.758621",
486
- // "tax_array": [
487
- // {
488
- // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003",
489
- // "tax_label": "16% IVA",
490
- // "tax_rate": 16,
491
- // "tax_sequence": 1,
492
- // "base_price_effected": 0,
493
- // "tax_amount": "2.758621",
494
- // "base_price": "17.241379",
495
- // "tax_rate_quantity": 0
496
- // }
497
- // ]
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
- // },
542
- // {
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
- // "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",
577
- // "is_tax_rate_same": 1,
578
- // "tax_rate": 0,
579
- // "quantity": 1,
580
- // "item_id": 8595,
581
- // "tax_id": [
582
- // {
583
- // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003"
584
- // }
585
- // ],
586
- // "modifier_trx_id": "c3b8-a367-4bbd",
587
- // "linked_product": "",
588
- // "redeem_promotion_id": 5011767,
589
- // "tax_amount": "2.758621",
590
- // "tax_array": [
591
- // {
592
- // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003",
593
- // "tax_label": "16% IVA",
594
- // "tax_rate": 16,
595
- // "tax_sequence": 1,
596
- // "base_price_effected": 0,
597
- // "tax_amount": "2.758621",
598
- // "base_price": "17.241379",
599
- // "tax_rate_quantity": 0
600
- // }
601
- // ]
602
- // }
603
- // ],
604
- // "isPackage": 0,
605
- // "price_list_id": "56e55ca6-d246-11ed-8811-0e2fd5e35c29",
606
- // "item_price_with_modifier": 142,
607
- // "package_items": [],
608
- // "item_event": "update",
609
- // "actual_price": 0,
610
- // "tax_id": [
611
- // {
612
- // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003"
613
- // }
614
- // ],
615
- // "menu_id": 210,
616
- // "item_trx_id": "3546-1fdf-8b16",
617
- // "special_instruction": "",
618
- // "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"
631
- // },
632
- // "redeem_promotion_id": 5011767,
633
- // "promotion_discount_modifier": "71.09",
634
- // "tax_amount": "21.827586",
635
- // "tax_array": [
636
- // {
637
- // "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003",
638
- // "tax_label": "16% IVA",
639
- // "tax_rate": 16,
640
- // "tax_sequence": 1,
641
- // "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
656
- // }
657
- // ],
658
- // "tax_amount_modifier": "24.586207",
659
- // "total_tax_amount": "24.586207",
660
- // "order_version": 5,
661
- // "promotion_discount": 0
662
- // }
663
- // ]
664
- // },
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"
717
- // },
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"
815
- // },
816
- // "promotion_id": 5011839,
817
- // "promotion_type": "user_specific"
818
- // }
819
- // }
820
-
821
- // calculateTax(json).then(res=>{
822
- // console.log(JSON.stringify(res))
823
- // }).catch(err=>{
824
- // console.log(err)
825
- // })
75
+ let json ={
76
+ "order_items": {
77
+ "item_details": [
78
+ {
79
+ "item_display_text": "Dairy Milk 3",
80
+ "item_price": 186,
81
+ "category_id": 501803,
82
+ "order_details_id": "de52399e-3166-40af-bf7a-34c0ce0d7021",
83
+ "order_id": 400524950,
84
+ "restaurant_id": 400,
85
+ "item_id": 9083,
86
+ "special_instruction": "",
87
+ "quantity": 2,
88
+ "is_package": 0,
89
+ "date_time": "2024-06-11 14:53:09",
90
+ "item_cost": 186,
91
+ "item_modifier_cost": 353,
92
+ "redeem_promotion_id": 0,
93
+ "promotion_discount": 0,
94
+ "points_discount": 19,
95
+ "net_cost": 353,
96
+ "net_tax": 97.38,
97
+ "tax_amount": 48.69,
98
+ "total_after_tax": 353,
99
+ "purchased_points": 0,
100
+ "package_items": null,
101
+ "status": 1,
102
+ "isPackage": 0,
103
+ "cetegoryModifier": [
104
+ [
105
+ {
106
+ "linked_menu_item": 0,
107
+ "modifier_item_name": "hfvjhfbv",
108
+ "modifier_caetgory_name": "ABCD",
109
+ "modifier_category_id": 510954,
110
+ "modifier_item_price": 0,
111
+ "modifier_details_id": 100018558,
112
+ "order_id": 400524950,
113
+ "order_details_id": "de52399e-3166-40af-bf7a-34c0ce0d7021",
114
+ "modifier_item_id": 100131,
115
+ "modifier_cost": 0,
116
+ "tax_amount": 0,
117
+ "total_after_tax": 0,
118
+ "quantity": 1,
119
+ "item_quantity": 2,
120
+ "item_id": 9083,
121
+ "date_time": "2024-06-11 14:53:09",
122
+ "status": 1,
123
+ "package_order_details_id": null,
124
+ "points_discount": 0,
125
+ "linked_product": ""
126
+ },
127
+ {
128
+ "linked_menu_item": 0,
129
+ "modifier_item_name": "fbvfbv",
130
+ "modifier_caetgory_name": "ABCD",
131
+ "modifier_category_id": 510954,
132
+ "modifier_item_price": 0,
133
+ "modifier_details_id": 100018559,
134
+ "order_id": 400524950,
135
+ "order_details_id": "de52399e-3166-40af-bf7a-34c0ce0d7021",
136
+ "modifier_item_id": 100132,
137
+ "modifier_cost": 0,
138
+ "tax_amount": 0,
139
+ "total_after_tax": 0,
140
+ "quantity": 1,
141
+ "item_quantity": 2,
142
+ "item_id": 9083,
143
+ "date_time": "2024-06-11 14:53:09",
144
+ "status": 1,
145
+ "package_order_details_id": null,
146
+ "points_discount": 0,
147
+ "linked_product": ""
148
+ }
149
+ ]
150
+ ],
151
+ "tax_id": [
152
+ {
153
+ "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003"
154
+ }
155
+ ],
156
+ "ieps_tax": {
157
+ "status": 0
158
+ },
159
+ "brand_id": "63011ad5-97bb-42c3-8ff7-484d706611ae",
160
+ "menu_id": 48,
161
+ "price_list_id": "56e55ca6-d246-11ed-8811-0e2fd5e35c29",
162
+ "item_price_with_modifier": "186.00",
163
+ "item_modifiers": [
164
+ {
165
+ "linked_menu_item": 0,
166
+ "modifier_item_name": "hfvjhfbv",
167
+ "modifier_caetgory_name": "ABCD",
168
+ "modifier_category_id": 510954,
169
+ "modifier_item_price": 0,
170
+ "modifier_details_id": 100018558,
171
+ "order_id": 400524950,
172
+ "order_details_id": "de52399e-3166-40af-bf7a-34c0ce0d7021",
173
+ "modifier_item_id": 100131,
174
+ "modifier_cost": 0,
175
+ "tax_amount": 0,
176
+ "total_after_tax": 0,
177
+ "quantity": 1,
178
+ "item_quantity": 2,
179
+ "item_id": 9083,
180
+ "date_time": "2024-06-11 14:53:09",
181
+ "status": 1,
182
+ "package_order_details_id": null,
183
+ "points_discount": 0,
184
+ "linked_product": "",
185
+ "tax_id": [],
186
+ "price_list_id": "",
187
+ "is_tax_rate_same": 1,
188
+ "modifer_cat": 510954
189
+ },
190
+ {
191
+ "linked_menu_item": 0,
192
+ "modifier_item_name": "fbvfbv",
193
+ "modifier_caetgory_name": "ABCD",
194
+ "modifier_category_id": 510954,
195
+ "modifier_item_price": 0,
196
+ "modifier_details_id": 100018559,
197
+ "order_id": 400524950,
198
+ "order_details_id": "de52399e-3166-40af-bf7a-34c0ce0d7021",
199
+ "modifier_item_id": 100132,
200
+ "modifier_cost": 0,
201
+ "tax_amount": 0,
202
+ "total_after_tax": 0,
203
+ "quantity": 1,
204
+ "item_quantity": 2,
205
+ "item_id": 9083,
206
+ "date_time": "2024-06-11 14:53:09",
207
+ "status": 1,
208
+ "package_order_details_id": null,
209
+ "points_discount": 0,
210
+ "linked_product": "",
211
+ "tax_id": [],
212
+ "price_list_id": "",
213
+ "is_tax_rate_same": 1,
214
+ "modifer_cat": 510954
215
+ }
216
+ ]
217
+ }
218
+ ]
219
+ },
220
+ "tax_settings": [
221
+ {
222
+ "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003",
223
+ "tax_label": "16% IVA",
224
+ "tax_rate": 16,
225
+ "tax_sequence": 1,
226
+ "base_price_effected": 0
227
+ },
228
+ {
229
+ "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120002",
230
+ "tax_label": "8% IVA",
231
+ "tax_rate": 8,
232
+ "tax_sequence": 1,
233
+ "base_price_effected": 0
234
+ },
235
+ {
236
+ "tax_id": "9dc9be72-ba23-11ec-8422-0242ac12000200",
237
+ "tax_label": "0% IVA",
238
+ "tax_rate": 0,
239
+ "tax_sequence": 3,
240
+ "base_price_effected": 0
241
+ },
242
+ {
243
+ "tax_id": "21036b00-bdb4-4485-aaba-d088a721a67f1",
244
+ "tax_label": "IEPS 8%",
245
+ "tax_rate": 8,
246
+ "tax_sequence": 2,
247
+ "base_price_effected": 0
248
+ }
249
+ ],
250
+ "tax_type": 2,
251
+ "store_value": 19,
252
+ "store_value_without_roundoff": 19,
253
+ "loyalty_points_details": {
254
+ "point_amount": 19,
255
+ "status": true,
256
+ "store_value": 19,
257
+ "redeem_categories": [
258
+ {
259
+ "category_id": "All"
260
+ }
261
+ ],
262
+ "points_redeemed": 19
263
+ },
264
+ "user_detais": {
265
+ "name": "Nikhil ",
266
+ "first_name": "Nikhil ",
267
+ "phone_number": "9816852375",
268
+ "mobile": "9816852375"
269
+ },
270
+ "tip_type": "percentage",
271
+ "tip_value": "10",
272
+ "delivery_cost": 40,
273
+ "service_amount": 0
274
+ }
275
+ calculateTax(json).then(res=>{
276
+ console.log(JSON.stringify(res))
277
+ }).catch(err=>{
278
+ console.log(err)
279
+ })
826
280
 
827
281
  module.exports = { calculateTax }
828
282
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foodbot-cart-calculations",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
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": {