foodbot-cart-calculations 1.0.23 → 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.
- package/calculations.js +7 -3
- package/index.js +291 -205
- 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,11 +61,13 @@ 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
|
}
|
|
64
69
|
mainCart.order_items = taxData
|
|
65
|
-
|
|
66
|
-
mainCart.cash_expected = taxData.cartTotal
|
|
70
|
+
|
|
67
71
|
|
|
68
72
|
let delivery_cost = body.delivery_cost?body.delivery_cost:0;
|
|
69
73
|
let service_amount = body.service_amount?body.service_amount:0;
|
package/index.js
CHANGED
|
@@ -72,211 +72,297 @@ async function calculateTax(inputJSON) {
|
|
|
72
72
|
})
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
let json ={
|
|
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
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
75
|
+
// let json ={
|
|
76
|
+
// "order_items": {
|
|
77
|
+
// "item_details": [
|
|
78
|
+
// {
|
|
79
|
+
// "menu_id": 320,
|
|
80
|
+
// "item_id": 9030,
|
|
81
|
+
// "category_id": 501768,
|
|
82
|
+
// "item_price": 80,
|
|
83
|
+
// "item_price_with_modifier": 215,
|
|
84
|
+
// "quantity": 1,
|
|
85
|
+
// "item_display_text": "daal rice",
|
|
86
|
+
// "item_name": "daal rice",
|
|
87
|
+
// "tax_rate": 16,
|
|
88
|
+
// "item_modifiers": [
|
|
89
|
+
// {
|
|
90
|
+
// "modifer_cat": 511432,
|
|
91
|
+
// "modifier_caetgory_name": "Bebidas sin alcohol",
|
|
92
|
+
// "modifier_item_id": 101383,
|
|
93
|
+
// "modifier_category_sequence": "0",
|
|
94
|
+
// "modifier_sequence": "01",
|
|
95
|
+
// "modifier_item_price": 20,
|
|
96
|
+
// "modifier_item_name": "Fanta",
|
|
97
|
+
// "is_tax_rate_same": 1,
|
|
98
|
+
// "tax_rate": 0,
|
|
99
|
+
// "quantity": 1,
|
|
100
|
+
// "item_id": 9030,
|
|
101
|
+
// "tax_id": [
|
|
102
|
+
// {
|
|
103
|
+
// "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003"
|
|
104
|
+
// }
|
|
105
|
+
// ],
|
|
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
|
|
118
|
+
// }
|
|
119
|
+
// },
|
|
120
|
+
// "tax_amount": "6.400000",
|
|
121
|
+
// "tax_array": [
|
|
122
|
+
// {
|
|
123
|
+
// "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003",
|
|
124
|
+
// "tax_label": "16% IVA",
|
|
125
|
+
// "tax_rate": 16,
|
|
126
|
+
// "tax_sequence": 1,
|
|
127
|
+
// "base_price_effected": 0,
|
|
128
|
+
// "tax_amount": "6.400000",
|
|
129
|
+
// "base_price": 40,
|
|
130
|
+
// "tax_rate_quantity": 0
|
|
131
|
+
// }
|
|
132
|
+
// ]
|
|
133
|
+
// },
|
|
134
|
+
// {
|
|
135
|
+
// "modifer_cat": 511432,
|
|
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",
|
|
142
|
+
// "is_tax_rate_same": 1,
|
|
143
|
+
// "tax_rate": 0,
|
|
144
|
+
// "quantity": 1,
|
|
145
|
+
// "item_id": 9030,
|
|
146
|
+
// "tax_id": [
|
|
147
|
+
// {
|
|
148
|
+
// "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003"
|
|
149
|
+
// }
|
|
150
|
+
// ],
|
|
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",
|
|
166
|
+
// "tax_array": [
|
|
167
|
+
// {
|
|
168
|
+
// "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003",
|
|
169
|
+
// "tax_label": "16% IVA",
|
|
170
|
+
// "tax_rate": 16,
|
|
171
|
+
// "tax_sequence": 1,
|
|
172
|
+
// "base_price_effected": 0,
|
|
173
|
+
// "tax_amount": "11.200000",
|
|
174
|
+
// "base_price": 70,
|
|
175
|
+
// "tax_rate_quantity": 0
|
|
176
|
+
// }
|
|
177
|
+
// ]
|
|
178
|
+
// },
|
|
179
|
+
// {
|
|
180
|
+
// "modifer_cat": 511432,
|
|
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",
|
|
187
|
+
// "is_tax_rate_same": 1,
|
|
188
|
+
// "tax_rate": 0,
|
|
189
|
+
// "quantity": 1,
|
|
190
|
+
// "item_id": 9030,
|
|
191
|
+
// "tax_id": [
|
|
192
|
+
// {
|
|
193
|
+
// "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003"
|
|
194
|
+
// }
|
|
195
|
+
// ],
|
|
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",
|
|
211
|
+
// "tax_array": [
|
|
212
|
+
// {
|
|
213
|
+
// "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003",
|
|
214
|
+
// "tax_label": "16% IVA",
|
|
215
|
+
// "tax_rate": 16,
|
|
216
|
+
// "tax_sequence": 1,
|
|
217
|
+
// "base_price_effected": 0,
|
|
218
|
+
// "tax_amount": "9.600000",
|
|
219
|
+
// "base_price": 60,
|
|
220
|
+
// "tax_rate_quantity": 0
|
|
221
|
+
// }
|
|
222
|
+
// ]
|
|
223
|
+
// },
|
|
224
|
+
// {
|
|
225
|
+
// "modifer_cat": 511432,
|
|
226
|
+
// "modifier_caetgory_name": "Bebidas sin alcohol",
|
|
227
|
+
// "modifier_item_id": 101386,
|
|
228
|
+
// "modifier_category_sequence": "0",
|
|
229
|
+
// "modifier_sequence": "04",
|
|
230
|
+
// "modifier_item_price": 20,
|
|
231
|
+
// "modifier_item_name": "Spirte",
|
|
232
|
+
// "is_tax_rate_same": 1,
|
|
233
|
+
// "tax_rate": 0,
|
|
234
|
+
// "quantity": 1,
|
|
235
|
+
// "item_id": 9030,
|
|
236
|
+
// "tax_id": [
|
|
237
|
+
// {
|
|
238
|
+
// "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003"
|
|
239
|
+
// }
|
|
240
|
+
// ],
|
|
241
|
+
// "modifier_trx_id": "TfPyHHK7",
|
|
242
|
+
// "linked_product": "",
|
|
243
|
+
// "tax_amount": "6.400000",
|
|
244
|
+
// "tax_array": [
|
|
245
|
+
// {
|
|
246
|
+
// "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003",
|
|
247
|
+
// "tax_label": "16% IVA",
|
|
248
|
+
// "tax_rate": 16,
|
|
249
|
+
// "tax_sequence": 1,
|
|
250
|
+
// "base_price_effected": 0,
|
|
251
|
+
// "tax_amount": "6.400000",
|
|
252
|
+
// "base_price": 40,
|
|
253
|
+
// "tax_rate_quantity": 0
|
|
254
|
+
// }
|
|
255
|
+
// ]
|
|
256
|
+
// },
|
|
257
|
+
// {
|
|
258
|
+
// "modifer_cat": 511432,
|
|
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",
|
|
265
|
+
// "is_tax_rate_same": 1,
|
|
266
|
+
// "tax_rate": 0,
|
|
267
|
+
// "quantity": 1,
|
|
268
|
+
// "item_id": 9030,
|
|
269
|
+
// "tax_id": [
|
|
270
|
+
// {
|
|
271
|
+
// "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003"
|
|
272
|
+
// }
|
|
273
|
+
// ],
|
|
274
|
+
// "modifier_trx_id": "5Yw17Q21",
|
|
275
|
+
// "linked_product": "",
|
|
276
|
+
// "tax_amount": "9.600000",
|
|
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": "9.600000",
|
|
285
|
+
// "base_price": 60,
|
|
286
|
+
// "tax_rate_quantity": 0
|
|
287
|
+
// }
|
|
288
|
+
// ]
|
|
289
|
+
// }
|
|
290
|
+
// ],
|
|
291
|
+
// "isPackage": 0,
|
|
292
|
+
// "package_items": [],
|
|
293
|
+
// "actual_price": 0,
|
|
294
|
+
// "item_event": "new",
|
|
295
|
+
// "tax_id": [
|
|
296
|
+
// {
|
|
297
|
+
// "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003"
|
|
298
|
+
// }
|
|
299
|
+
// ],
|
|
300
|
+
// "ieps_tax": {
|
|
301
|
+
// "status": 0
|
|
302
|
+
// },
|
|
303
|
+
// "item_trx_id": "6nfb34q9",
|
|
304
|
+
// "special_instruction": "",
|
|
305
|
+
// "tax_amount": "25.600000",
|
|
306
|
+
// "tax_array": [
|
|
307
|
+
// {
|
|
308
|
+
// "tax_id": "9dc9be72-ba23-11ec-8422-0242ac120003",
|
|
309
|
+
// "tax_label": "16% IVA",
|
|
310
|
+
// "tax_rate": 16,
|
|
311
|
+
// "tax_sequence": 1,
|
|
312
|
+
// "base_price_effected": 0,
|
|
313
|
+
// "tax_amount": "25.600000",
|
|
314
|
+
// "base_price": 160,
|
|
315
|
+
// "tax_rate_quantity": 0
|
|
316
|
+
// }
|
|
317
|
+
// ],
|
|
318
|
+
// "tax_amount_modifier": "68.800000",
|
|
319
|
+
// "total_tax_amount": "68.800000",
|
|
320
|
+
// "active": true,
|
|
321
|
+
// "promotion_discount": 0
|
|
322
|
+
// }
|
|
323
|
+
// ]
|
|
324
|
+
// },
|
|
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
|
|
339
|
+
// },
|
|
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
|
|
346
|
+
// },
|
|
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
|
|
359
|
+
// }
|
|
360
|
+
|
|
361
|
+
// calculateTax(json).then(res=>{
|
|
362
|
+
// console.log(JSON.stringify(res))
|
|
363
|
+
// }).catch(err=>{
|
|
364
|
+
// console.log(err)
|
|
365
|
+
// })
|
|
280
366
|
|
|
281
367
|
module.exports = { calculateTax }
|
|
282
368
|
|
package/package.json
CHANGED