erp-pos-ecommerce-shared 0.0.1

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/dist/index.js ADDED
@@ -0,0 +1,1270 @@
1
+ import axios from 'axios';
2
+
3
+ // src/interfaces/form.interface.ts
4
+ var FieldTypes = {
5
+ TEXT: "text",
6
+ EMAIL: "email",
7
+ NUMBER: "number",
8
+ PASSWORD: "password",
9
+ SELECT: "select",
10
+ MULTISELECT: "multiselect",
11
+ DATE: "date",
12
+ HIDDEN: "hidden",
13
+ SWITCH: "switch",
14
+ FILE: "file",
15
+ TAG: "tag"
16
+ };
17
+ var ButtonTypes = {
18
+ SUBMIT: "submit",
19
+ BUTTON: "button",
20
+ RESET: "reset"
21
+ };
22
+
23
+ // src/interfaces/permission.interface.ts
24
+ var Permission = /* @__PURE__ */ ((Permission2) => {
25
+ Permission2["Crear"] = "Crear";
26
+ Permission2["Editar"] = "Editar";
27
+ Permission2["Eliminar"] = "Eliminar";
28
+ Permission2["Ver"] = "Ver";
29
+ return Permission2;
30
+ })(Permission || {});
31
+
32
+ // src/interfaces/promotion.interface.ts
33
+ var PromotionTypeEnum = /* @__PURE__ */ ((PromotionTypeEnum2) => {
34
+ PromotionTypeEnum2["NXM"] = "NXM";
35
+ PromotionTypeEnum2["PRODUCTO"] = "PRODUCTO";
36
+ PromotionTypeEnum2["TEMPORADA"] = "TEMPORADA";
37
+ PromotionTypeEnum2["PROVEEDOR"] = "PROVEEDOR";
38
+ PromotionTypeEnum2["LOTE"] = "LOTE";
39
+ return PromotionTypeEnum2;
40
+ })(PromotionTypeEnum || {});
41
+
42
+ // src/interfaces/report.interface.ts
43
+ var ComparisonBy = /* @__PURE__ */ ((ComparisonBy2) => {
44
+ ComparisonBy2["YEAR"] = "year";
45
+ ComparisonBy2["MONTH"] = "month";
46
+ ComparisonBy2["WEEK"] = "week";
47
+ ComparisonBy2["CUSTOM"] = "custom";
48
+ return ComparisonBy2;
49
+ })(ComparisonBy || {});
50
+ var ChartType = /* @__PURE__ */ ((ChartType2) => {
51
+ ChartType2["BAR"] = "bar";
52
+ ChartType2["LINE"] = "line";
53
+ ChartType2["PIE"] = "pie";
54
+ return ChartType2;
55
+ })(ChartType || {});
56
+ var api = axios.create({
57
+ baseURL: "",
58
+ headers: { "Content-Type": "application/json" }
59
+ });
60
+ function configureApi(config) {
61
+ const { baseURL, getToken, onTokenRefresh, onUnauthorized } = config;
62
+ const newApi = axios.create({
63
+ baseURL,
64
+ headers: {
65
+ "Content-Type": "application/json",
66
+ ...getToken() && { Authorization: `Bearer ${getToken()}` }
67
+ }
68
+ });
69
+ newApi.interceptors.request.use((reqConfig) => {
70
+ const token = getToken();
71
+ if (token) {
72
+ reqConfig.headers.Authorization = `Bearer ${token}`;
73
+ }
74
+ return reqConfig;
75
+ });
76
+ const refreshAxios = axios.create({ baseURL });
77
+ newApi.interceptors.response.use(
78
+ (response) => response,
79
+ async (error) => {
80
+ const originalRequest = error.config;
81
+ if (error.response?.status === 401 && !originalRequest._retry && onTokenRefresh && onUnauthorized) {
82
+ originalRequest._retry = true;
83
+ try {
84
+ const response = await refreshAxios.get("/auth/refresh", {
85
+ headers: getToken() ? { Authorization: `Bearer ${getToken()}` } : {}
86
+ });
87
+ const newToken = response.data?.token;
88
+ if (newToken) {
89
+ onTokenRefresh(newToken);
90
+ originalRequest.headers.Authorization = `Bearer ${newToken}`;
91
+ return newApi(originalRequest);
92
+ }
93
+ } catch {
94
+ onUnauthorized();
95
+ return Promise.reject(error);
96
+ }
97
+ }
98
+ return Promise.reject(error);
99
+ }
100
+ );
101
+ api = newApi;
102
+ return api;
103
+ }
104
+
105
+ // src/services/attributes.service.ts
106
+ var getAttributes = async ({
107
+ skip,
108
+ limit,
109
+ query
110
+ }) => {
111
+ const { data } = await api.get("/attribute/category", { params: { skip, limit, query } });
112
+ return data;
113
+ };
114
+ var getAttributesForSelect = async () => {
115
+ const { data } = await api.get("/attribute/select");
116
+ return data;
117
+ };
118
+ var getAttributeById = async (id) => {
119
+ const { data } = await api.get(`/attribute/${id}`);
120
+ return data;
121
+ };
122
+ var getAttributesByProductID = async ({
123
+ productID
124
+ }) => {
125
+ const { data } = await api.get(`/attribute/${productID}/product`);
126
+ return data;
127
+ };
128
+ var getAttributesByCategoryID = async ({
129
+ categoryID
130
+ }) => {
131
+ const { data } = await api.get(`/attribute/${categoryID}/category/`);
132
+ return data;
133
+ };
134
+ var getAttributeValues = async ({
135
+ attributeID
136
+ }) => {
137
+ const { data } = await api.get(`/attribute/${attributeID}/values`);
138
+ return data;
139
+ };
140
+ var createAttribute = async ({
141
+ attribute
142
+ }) => {
143
+ const { data } = await api.post("/attribute", attribute);
144
+ return data;
145
+ };
146
+ var createAttributesForCategory = async ({
147
+ attributes
148
+ }) => {
149
+ const { data } = await api.post(`/attribute/category/`, attributes);
150
+ return data;
151
+ };
152
+ var updateAttribute = async ({
153
+ id,
154
+ attribute
155
+ }) => {
156
+ const { data } = await api.put(`/attribute/${id}`, attribute);
157
+ return data;
158
+ };
159
+ var updateAttributesForCategory = async ({
160
+ id,
161
+ attributes
162
+ }) => {
163
+ const { data } = await api.put(`/attribute/category/${id}`, attributes);
164
+ return data;
165
+ };
166
+ var deleteAttribute = async ({ id }) => {
167
+ const { data } = await api.delete(`/attribute/${id}`);
168
+ return data;
169
+ };
170
+ var undeleteAttribute = async ({ id }) => {
171
+ const { data } = await api.patch(`/attribute/${id}`);
172
+ return data;
173
+ };
174
+ var createAttributeValue = async ({
175
+ attributeID,
176
+ value
177
+ }) => {
178
+ const { data } = await api.post(`/attribute/${attributeID}/values`, { attributeID, value });
179
+ return data;
180
+ };
181
+
182
+ // src/services/auth.service.ts
183
+ var login = async ({
184
+ email,
185
+ password
186
+ }) => {
187
+ const { data } = await api.post("auth/login", { email, password });
188
+ return data;
189
+ };
190
+
191
+ // src/services/bankTerminal.service.ts
192
+ var getBankTerminalsForSelect = async () => {
193
+ const { data } = await api.get("bank-terminals/bankTerminalsSelect");
194
+ return data;
195
+ };
196
+ var getAllBankTerminals = async () => {
197
+ const { data } = await api.get("bank-terminals/");
198
+ return data;
199
+ };
200
+ var getBankTerminals = async ({
201
+ skip = 0,
202
+ limit = 10,
203
+ query = ""
204
+ }) => {
205
+ const { data } = await api.get(
206
+ `bank-terminals/bankTerminalsTable/?skip=${skip}&limit=${limit}&query=${query}`
207
+ );
208
+ return data;
209
+ };
210
+ var getBankTerminalById = async (id) => {
211
+ const { data } = await api.get(`/bank-terminals/${id}`);
212
+ return data.data;
213
+ };
214
+ var updateBankTerminal = async ({
215
+ id,
216
+ terminal
217
+ }) => {
218
+ const { data } = await api.put(`/bank-terminals/${id}`, terminal);
219
+ return data;
220
+ };
221
+ var createBankTerminal = async ({
222
+ terminal
223
+ }) => {
224
+ const { data } = await api.post("bank-terminals/", terminal);
225
+ return data;
226
+ };
227
+ var deleteBankTerminal = async ({ terminalID }) => {
228
+ await api.delete(`/bank-terminals/${terminalID}`);
229
+ };
230
+ var restoreBankTerminal = async ({
231
+ terminalID
232
+ }) => {
233
+ await api.patch(`/bank-terminals/${terminalID}`);
234
+ };
235
+
236
+ // src/services/batch.service.ts
237
+ var getBatchesForSelect = async () => {
238
+ const { data } = await api.get("batch/batches-for-select");
239
+ return data;
240
+ };
241
+ var getBatches = async ({
242
+ skip = 0,
243
+ limit = 10,
244
+ query = "",
245
+ productID = 0
246
+ }) => {
247
+ const { data } = await api.get(
248
+ `batch?skip=${skip}&limit=${limit}&query=${query}&productID=${productID}`
249
+ );
250
+ return data;
251
+ };
252
+ var createBatch = async (batch) => {
253
+ const { data } = await api.post("batch/", batch);
254
+ return data;
255
+ };
256
+ var createBatchAndUpdateOtherBatches = async (batch) => {
257
+ const { data } = await api.post("batch/create-batch-and-update-other-batches", batch);
258
+ return data;
259
+ };
260
+ var getMatchedBatches = async ({
261
+ productDetailID
262
+ }) => {
263
+ const { data } = await api.get(
264
+ `batch/matched-batches?productDetailID=${productDetailID}`
265
+ );
266
+ return data;
267
+ };
268
+ var updateBatch = async ({
269
+ batchID,
270
+ batchData
271
+ }) => {
272
+ const { data } = await api.put(`batch/${batchID}`, batchData);
273
+ return data;
274
+ };
275
+
276
+ // src/services/category.service.ts
277
+ var getCategoriesForSelect = async () => {
278
+ const { data } = await api.get("category/categoriesSelect");
279
+ return data;
280
+ };
281
+ var getAllCategories = async () => {
282
+ const { data } = await api.get("category/");
283
+ return data;
284
+ };
285
+ var getCategories = async ({
286
+ skip = 0,
287
+ limit = 10,
288
+ query = ""
289
+ }) => {
290
+ const { data } = await api.get(
291
+ `category/categoriesTable?skip=${skip}&limit=${limit}&query=${query}`
292
+ );
293
+ return data;
294
+ };
295
+ var getCategoryById = async (id) => {
296
+ const { data } = await api.get(`/category/${id}`);
297
+ return data.data;
298
+ };
299
+ var updateCategory = async ({
300
+ id,
301
+ category
302
+ }) => {
303
+ const { data } = await api.put(`/category/${id}`, category);
304
+ return data;
305
+ };
306
+ var createCategory = async ({ category }) => {
307
+ const { data } = await api.post("category/", category);
308
+ return data;
309
+ };
310
+ var deleteCategory = async ({ categoryID }) => {
311
+ await api.delete(`/category/${categoryID}`);
312
+ };
313
+ var restoreCategory = async ({ categoryID }) => {
314
+ await api.patch(`/category/${categoryID}`);
315
+ };
316
+
317
+ // src/services/client.service.ts
318
+ var getAllClients = async ({
319
+ skip = 0,
320
+ limit = 10,
321
+ query = ""
322
+ }) => {
323
+ const { data } = await api.get(
324
+ `client/?skip=${skip}&limit=${limit}&query=${query}`
325
+ );
326
+ return data;
327
+ };
328
+ var getClientsForSelect = async () => {
329
+ const { data } = await api.get("client/select");
330
+ return data;
331
+ };
332
+ var getClientById = async (clientID) => {
333
+ const { data } = await api.get(`client/${clientID}`);
334
+ return data;
335
+ };
336
+ var createClient = async (client) => {
337
+ const { data } = await api.post("client/", client);
338
+ return data;
339
+ };
340
+ var updateClient = async ({
341
+ client,
342
+ id
343
+ }) => {
344
+ const { data } = await api.put(`client/${id}`, client);
345
+ return data;
346
+ };
347
+ var deleteClient = async ({
348
+ clientID
349
+ }) => {
350
+ const { data } = await api.delete(`client/${clientID}`);
351
+ return data;
352
+ };
353
+ var restoreClient = async ({
354
+ clientID
355
+ }) => {
356
+ const { data } = await api.patch(`client/${clientID}`);
357
+ return data;
358
+ };
359
+
360
+ // src/services/exchange.service.ts
361
+ var getPaymentTypes = async () => {
362
+ const { data } = await api.get("exchange/getPaymentTypes");
363
+ return data;
364
+ };
365
+ var getExchangeRates = async ({
366
+ skip = 0,
367
+ limit = 10,
368
+ query = ""
369
+ }) => {
370
+ const { data } = await api.get(
371
+ `exchange/exchangesTable?skip=${skip}&limit=${limit}&query=${query}`
372
+ );
373
+ return data;
374
+ };
375
+ var getExchangeRate = async () => {
376
+ const { data } = await api.get("exchange/getExchangeRate");
377
+ return data;
378
+ };
379
+ var createExchangeRate = async ({
380
+ exchangeRate
381
+ }) => {
382
+ const { data } = await api.post("exchange/", exchangeRate);
383
+ return data;
384
+ };
385
+
386
+ // src/services/gender.service.ts
387
+ var getAllGenders = async () => {
388
+ const { data } = await api.get("gender/");
389
+ return data;
390
+ };
391
+
392
+ // src/services/health.service.ts
393
+ var HEALTH_CHECK_TIMEOUT_MS = 1e4;
394
+ var healthService = {
395
+ async check() {
396
+ try {
397
+ const response = await api.get("/api/health", {
398
+ timeout: HEALTH_CHECK_TIMEOUT_MS
399
+ });
400
+ return response.data;
401
+ } catch (error) {
402
+ const isTimeoutError = error instanceof Error && (error.message.includes("timeout") || error.message.includes("Network Error"));
403
+ return {
404
+ status: "error",
405
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
406
+ services: {
407
+ backend: {
408
+ status: "error",
409
+ message: isTimeoutError ? "No se pudo conectar con el backend. Verifica que el servidor est\xE9 corriendo y la URL configurada." : error instanceof Error ? error.message : "Error de conexi\xF3n con el backend"
410
+ },
411
+ database: {
412
+ status: "unknown",
413
+ message: "No se puede verificar la base de datos porque el backend no responde"
414
+ }
415
+ }
416
+ };
417
+ }
418
+ }
419
+ };
420
+
421
+ // src/services/location.service.ts
422
+ var getAllLocations = async () => {
423
+ const { data } = await api.get("location/");
424
+ return data;
425
+ };
426
+ var getLocationsForSelect = async () => {
427
+ const { data } = await api.get("location/locationsForSelect");
428
+ return data;
429
+ };
430
+ var getLocations = async ({
431
+ skip = 0,
432
+ limit = 10,
433
+ query = ""
434
+ }) => {
435
+ const { data } = await api.get(
436
+ `location/locations?skip=${skip}&limit=${limit}&query=${query}`
437
+ );
438
+ return data;
439
+ };
440
+ var getLocationById = async (id) => {
441
+ const { data } = await api.get(`/location/${id}`);
442
+ return data.data;
443
+ };
444
+ var updateLocation = async ({
445
+ id,
446
+ location
447
+ }) => {
448
+ const { data } = await api.put(`/location/${id}`, location, {
449
+ headers: {
450
+ "Content-Type": "multipart/form-data"
451
+ }
452
+ });
453
+ return data;
454
+ };
455
+ var createLocation = async (location) => {
456
+ const { data } = await api.post("location/", location, {
457
+ headers: {
458
+ "Content-Type": "multipart/form-data"
459
+ }
460
+ });
461
+ return data;
462
+ };
463
+ var deleteLocation = async ({
464
+ physicalLocationID
465
+ }) => {
466
+ await api.delete(`/location/${physicalLocationID}`);
467
+ };
468
+ var restoreLocation = async ({
469
+ physicalLocationID
470
+ }) => {
471
+ await api.patch(`/location/${physicalLocationID}`);
472
+ };
473
+
474
+ // src/services/material.service.ts
475
+ var getAllMaterials = async () => {
476
+ const { data } = await api.get("material/");
477
+ return data;
478
+ };
479
+ var getMaterials = async ({
480
+ skip = 0,
481
+ limit = 10,
482
+ query = ""
483
+ }) => {
484
+ const { data } = await api.get(
485
+ `material/materialsTable?skip=${skip}&limit=${limit}&query=${query}`
486
+ );
487
+ return data;
488
+ };
489
+ var getMaterialById = async (materialID) => {
490
+ const { data } = await api.get(`material/${materialID}`);
491
+ return data.data;
492
+ };
493
+ var getMaterialsForSelect = async () => {
494
+ const { data } = await api.get("material/select");
495
+ return data;
496
+ };
497
+ var createMaterial = async ({ material }) => {
498
+ const { data } = await api.post("material/", material);
499
+ return data;
500
+ };
501
+ var updateMaterial = async ({
502
+ materialID,
503
+ material
504
+ }) => {
505
+ const { data } = await api.put(`material/${materialID}`, material);
506
+ return data;
507
+ };
508
+ var deleteMaterial = async ({ materialID }) => {
509
+ await api.delete(`material/${materialID}`);
510
+ };
511
+ var undeleteMaterial = async ({ materialID }) => {
512
+ await api.patch(`material/${materialID}`);
513
+ };
514
+
515
+ // src/services/module.service.ts
516
+ var getAllModules = async () => {
517
+ const { data } = await api.get("module/");
518
+ return data;
519
+ };
520
+
521
+ // src/services/order.service.ts
522
+ var getOrders = async ({
523
+ skip = 0,
524
+ limit = 10,
525
+ query = "",
526
+ commissionedBy = "",
527
+ orderStatus = [],
528
+ startDate = "",
529
+ endDate = "",
530
+ showOnlyReturns = false
531
+ }) => {
532
+ const { data } = await api.get("order", {
533
+ params: { skip, limit, query, commissionedBy, orderStatus, startDate, endDate, showOnlyReturns }
534
+ });
535
+ return data;
536
+ };
537
+ var getOrderById = async ({ orderID }) => {
538
+ const { data } = await api.get(`order/${orderID}`);
539
+ return data;
540
+ };
541
+ var getOrdersStatusForSelect = async () => {
542
+ const { data } = await api.get("order/status");
543
+ return data;
544
+ };
545
+ var changeOrderProduct = async (changeData) => {
546
+ const { data } = await api.post("order/change-product", changeData);
547
+ return data;
548
+ };
549
+
550
+ // src/services/payment.service.ts
551
+ var sendPaymentData = async ({ payment }) => {
552
+ const { data } = await api.post(
553
+ "payment/applypayment",
554
+ {
555
+ ...payment
556
+ },
557
+ {
558
+ headers: {
559
+ "Content-Type": "application/json"
560
+ }
561
+ }
562
+ );
563
+ return data;
564
+ };
565
+ var getPaymentMethods = async () => {
566
+ const { data } = await api.get("payment/getpaymentmethods");
567
+ return data;
568
+ };
569
+ var getPaymentMethodsWithAmountExpected = async () => {
570
+ const { data } = await api.get("payment/getpaymentmethodswithamountexpected");
571
+ return data;
572
+ };
573
+ var sendCreditPaymentData = async ({
574
+ payment,
575
+ orderID
576
+ }) => {
577
+ const { data } = await api.post(
578
+ "payment/applycreditpayment",
579
+ {
580
+ ...payment,
581
+ orderID
582
+ },
583
+ {
584
+ headers: {
585
+ "Content-Type": "application/json"
586
+ }
587
+ }
588
+ );
589
+ return data;
590
+ };
591
+
592
+ // src/services/permission.service.ts
593
+ var getAllPermissions = async () => {
594
+ const response = await api.get("/permission-role/");
595
+ return response.data;
596
+ };
597
+ var updatePermission = async (permission) => {
598
+ const response = await api.put("/permission-role", permission);
599
+ return response.data;
600
+ };
601
+ var getPermissionRoleByRoleID = async (roleID) => {
602
+ const { data } = await api.get(`permission-role/${roleID}`);
603
+ return data;
604
+ };
605
+
606
+ // src/services/pricePerGram.service.ts
607
+ var BASE_URL = "price-per-gram";
608
+ var pricePerGramService = {
609
+ // 1. Obtener precio con fallback
610
+ async getPrice(params) {
611
+ const queryParams = new URLSearchParams();
612
+ if (params.productDetailID)
613
+ queryParams.append("productDetailID", params.productDetailID.toString());
614
+ if (params.productID) queryParams.append("productID", params.productID.toString());
615
+ if (params.materialID) queryParams.append("materialID", params.materialID.toString());
616
+ const { data } = await api.get(
617
+ `${BASE_URL}/price?${queryParams.toString()}`
618
+ );
619
+ return data;
620
+ },
621
+ // 2. Actualizar precio (crea histórico automáticamente)
622
+ async updatePrice(request) {
623
+ await api.put(`${BASE_URL}/price`, request);
624
+ },
625
+ // 3. Ver histórico de precios
626
+ async getHistory(entityType, entityID, limit) {
627
+ const queryParams = new URLSearchParams();
628
+ if (limit) queryParams.append("limit", limit.toString());
629
+ const { data } = await api.get(
630
+ `${BASE_URL}/history/${entityType}/${entityID}?${queryParams.toString()}`
631
+ );
632
+ console.log("response data:", data);
633
+ return data.data || [];
634
+ },
635
+ // 4. Programar precio futuro
636
+ async schedulePrice(request) {
637
+ await api.post(`${BASE_URL}/scheduled`, request);
638
+ },
639
+ // 5. Calcular precio para venta
640
+ async calculatePrice(request) {
641
+ const { data } = await api.post(`${BASE_URL}/calculate`, request);
642
+ return data;
643
+ },
644
+ // 6. Eliminar precio programado
645
+ async deleteFuturePrice(historyID) {
646
+ await api.delete(`${BASE_URL}/scheduled/${historyID}`);
647
+ },
648
+ // 7. Actualizar precio programado
649
+ async updateFuturePrice(historyID, request) {
650
+ await api.put(`${BASE_URL}/scheduled/${historyID}`, request);
651
+ },
652
+ // Verificar si un producto se vende por peso
653
+ async isWeightBased(productDetailID) {
654
+ try {
655
+ const priceInfo = await this.getPrice({ productDetailID });
656
+ return priceInfo.pricePerGram !== null;
657
+ } catch (error) {
658
+ console.error("Error verificando si es por peso:", error);
659
+ return false;
660
+ }
661
+ }
662
+ };
663
+
664
+ // src/services/priceType.service.ts
665
+ var getPriceTypesForSelect = async () => {
666
+ const { data } = await api.get("price-type/select");
667
+ return data;
668
+ };
669
+ var getAllPriceTypes = async ({
670
+ skip = 0,
671
+ limit = 10,
672
+ query = ""
673
+ }) => {
674
+ const { data } = await api.get(
675
+ `price-type/?skip=${skip}&limit=${limit}&query=${query}`
676
+ );
677
+ return data;
678
+ };
679
+ var createPriceType = async ({
680
+ priceType
681
+ }) => {
682
+ const { data } = await api.post("price-type/", priceType);
683
+ return data;
684
+ };
685
+ var getPriceTypeById = async ({
686
+ priceTypeID
687
+ }) => {
688
+ const { data } = await api.get(`price-type/${priceTypeID}`);
689
+ return data;
690
+ };
691
+ var updatePriceType = async ({
692
+ priceTypeID,
693
+ priceType
694
+ }) => {
695
+ const { data } = await api.put(`price-type/${priceTypeID}`, priceType);
696
+ return data;
697
+ };
698
+ var deletePriceType = async ({ priceTypeID }) => {
699
+ const { data } = await api.delete(`price-type/${priceTypeID}`);
700
+ return data;
701
+ };
702
+ var undeletePriceType = async ({
703
+ priceTypeID
704
+ }) => {
705
+ const { data } = await api.patch(`price-type/${priceTypeID}`);
706
+ return data;
707
+ };
708
+
709
+ // src/services/product.service.ts
710
+ var getProductsForSelect = async () => {
711
+ const { data } = await api.get("/product/select");
712
+ return data;
713
+ };
714
+ var getProducts = async ({
715
+ skip = 0,
716
+ limit = 16,
717
+ filters
718
+ }) => {
719
+ const queryParams = new URLSearchParams({
720
+ skip: skip.toString(),
721
+ limit: limit.toString(),
722
+ ...filters?.query && { query: filters.query },
723
+ ...filters?.batchId && { batchId: filters.batchId },
724
+ ...filters?.categoryId && { categoryId: filters.categoryId.toString() },
725
+ ...filters?.supplierId && { supplierId: filters.supplierId.toString() },
726
+ ...filters?.warehouseId && { warehouseId: filters.warehouseId.toString() },
727
+ ...filters?.priceRangeMin && { minPrice: filters.priceRangeMin.toString() },
728
+ ...filters?.priceRangeMax && { maxPrice: filters.priceRangeMax.toString() }
729
+ });
730
+ const { data } = await api.get(`product?${queryParams}`);
731
+ return data;
732
+ };
733
+ var getProductsTable = async ({
734
+ skip = 0,
735
+ limit = 16,
736
+ filters
737
+ }) => {
738
+ const queryParams = new URLSearchParams({
739
+ skip: skip.toString(),
740
+ limit: limit.toString(),
741
+ ...filters?.query && { query: filters.query },
742
+ ...filters?.batchId && { batchId: filters.batchId },
743
+ ...filters?.categoryId && { categoryId: filters.categoryId.toString() },
744
+ ...filters?.supplierId && { supplierId: filters.supplierId.toString() },
745
+ ...filters?.warehouseId && { warehouseId: filters.warehouseId.toString() },
746
+ ...filters?.priceRangeMin && { minPrice: filters.priceRangeMin.toString() },
747
+ ...filters?.priceRangeMax && { maxPrice: filters.priceRangeMax.toString() }
748
+ });
749
+ const { data } = await api.get(`product/table?${queryParams}`);
750
+ return data;
751
+ };
752
+ var getProductById = async (id) => {
753
+ const { data } = await api.get(`product/${id}`);
754
+ return data.data;
755
+ };
756
+ var getProductVariants = async ({
757
+ productID,
758
+ skip = 0,
759
+ limit = 10,
760
+ query = ""
761
+ }) => {
762
+ const { data } = await api.get(`/product/variants/${productID}`, {
763
+ params: {
764
+ skip: skip.toString(),
765
+ limit: limit.toString(),
766
+ ...query && { query }
767
+ }
768
+ });
769
+ return data;
770
+ };
771
+ var getProductVariantsForSelect = async ({
772
+ productID
773
+ }) => {
774
+ const { data } = await api.get(`/product/variants/select/${productID}`);
775
+ return data;
776
+ };
777
+ var getProductVariantById = async ({ id }) => {
778
+ const { data } = await api.get(`/product/variants/variant/${id}`);
779
+ return data;
780
+ };
781
+ var createProductVariant = async (variant) => {
782
+ const { data } = await api.post("product/variants", variant, {
783
+ headers: {
784
+ "Content-Type": "multipart/form-data"
785
+ }
786
+ });
787
+ return data;
788
+ };
789
+ var updateProductVariant = async (data) => {
790
+ const { data: response } = await api.put(
791
+ `product/variants/update/${data.get("productDetailID")}`,
792
+ data,
793
+ {
794
+ headers: {
795
+ "Content-Type": "multipart/form-data"
796
+ }
797
+ }
798
+ );
799
+ return response;
800
+ };
801
+ var deleteProductVariant = async ({
802
+ productDetailID
803
+ }) => {
804
+ await api.delete(`/product/variants/${productDetailID}`);
805
+ };
806
+ var restoreProductVariant = async ({
807
+ productDetailID
808
+ }) => {
809
+ await api.patch(`/product/variants/${productDetailID}`);
810
+ };
811
+ var createProduct = async (product) => {
812
+ const { data } = await api.post("product/", product, {
813
+ headers: {
814
+ "Content-Type": "multipart/form-data"
815
+ }
816
+ });
817
+ return data;
818
+ };
819
+ var updateProduct = async ({
820
+ id,
821
+ product
822
+ }) => {
823
+ const { data } = await api.put(`/product/${id}`, product, {
824
+ headers: {
825
+ "Content-Type": "multipart/form-data"
826
+ }
827
+ });
828
+ return data;
829
+ };
830
+ var deleteImageFromProduct = async (imageId) => {
831
+ await api.delete(`/product/images/${imageId}`);
832
+ };
833
+ var deleteProduct = async ({ productID }) => {
834
+ await api.delete(`/product/${productID}`);
835
+ };
836
+ var restoreProduct = async ({ productID }) => {
837
+ await api.patch(`/product/${productID}`);
838
+ };
839
+ var getProductsByCategory = async ({
840
+ category,
841
+ skip = 0,
842
+ limit = 10,
843
+ filters
844
+ }) => {
845
+ const queryParams = new URLSearchParams({
846
+ skip: skip.toString(),
847
+ limit: limit.toString(),
848
+ ...filters?.query && { query: filters.query },
849
+ ...filters?.batchId && { batchId: filters.batchId },
850
+ ...filters?.supplierId && { supplierId: filters.supplierId.toString() },
851
+ ...filters?.warehouseId && { warehouseId: filters.warehouseId.toString() },
852
+ ...filters?.priceRangeMin && { minPrice: filters.priceRangeMin.toString() },
853
+ ...filters?.priceRangeMax && { maxPrice: filters.priceRangeMax.toString() }
854
+ });
855
+ const { data } = await api.get(`product/category/${category}?${queryParams}`);
856
+ return data;
857
+ };
858
+ var printProductTag = async ({
859
+ stockID,
860
+ productID,
861
+ isSmall
862
+ }) => {
863
+ const { data } = await api.post(`/product/printproducttag/`, {
864
+ stockID,
865
+ productID,
866
+ isSmall
867
+ });
868
+ return data;
869
+ };
870
+
871
+ // src/services/promotion.service.ts
872
+ var isAValidDiscountCode = async (discountCode) => {
873
+ const { data } = await api.post("promotion/discount-code", { discountCode });
874
+ return data.isValid;
875
+ };
876
+ var getPromotions = async ({
877
+ skip = 0,
878
+ limit = 10,
879
+ query = ""
880
+ }) => {
881
+ const queryParams = new URLSearchParams({
882
+ skip: skip.toString(),
883
+ limit: limit.toString(),
884
+ query
885
+ });
886
+ const { data } = await api.get(`promotion?${queryParams}`);
887
+ return data;
888
+ };
889
+ var getPromotionsTypeForSelect = async () => {
890
+ const { data } = await api.get("promotion/promotions-type/select");
891
+ return data;
892
+ };
893
+ var createPromotion = async (promotion) => {
894
+ const { data } = await api.post("promotion", promotion);
895
+ return data;
896
+ };
897
+ var getPromotionById = async ({ id }) => {
898
+ const { data } = await api.get(`promotion/${id}`);
899
+ return data;
900
+ };
901
+ var updatePromotion = async ({
902
+ id,
903
+ promotion
904
+ }) => {
905
+ const { data } = await api.put(`promotion/${id}`, promotion);
906
+ return data;
907
+ };
908
+
909
+ // src/services/provider.service.ts
910
+ var getAllProviders = async ({
911
+ skip = 0,
912
+ limit = 10,
913
+ query = ""
914
+ }) => {
915
+ const { data } = await api.get(
916
+ `provider/?skip=${skip}&limit=${limit}&query=${query}`
917
+ );
918
+ return data;
919
+ };
920
+ var getProviderById = async ({
921
+ providerID
922
+ }) => {
923
+ const { data } = await api.get(`provider/${providerID}`);
924
+ return data;
925
+ };
926
+ var getProvidersForSelect = async () => {
927
+ const { data } = await api.get("provider/providersForSelect");
928
+ return data;
929
+ };
930
+ var createProvider = async (provider) => {
931
+ const { data } = await api.post("provider/", provider);
932
+ return data;
933
+ };
934
+ var updateProvider = async ({
935
+ providerID,
936
+ provider
937
+ }) => {
938
+ const { data } = await api.put(`provider/${providerID}`, provider);
939
+ return data;
940
+ };
941
+ var deleteProvider = async ({
942
+ providerID
943
+ }) => {
944
+ const { data } = await api.delete(`provider/${providerID}`);
945
+ return data;
946
+ };
947
+ var restoreProvider = async ({
948
+ providerID
949
+ }) => {
950
+ const { data } = await api.patch(`provider/${providerID}`);
951
+ return data;
952
+ };
953
+
954
+ // src/services/qr.service.ts
955
+ var getQRBaseUrl = async () => {
956
+ const { data } = await api.get("/qr/base-url");
957
+ return data?.baseUrl ?? "";
958
+ };
959
+ var printQR = async ({
960
+ productDetailID,
961
+ printerName = "4BARCODE"
962
+ }) => {
963
+ const { data } = await api.post("/qr/print", {
964
+ productDetailID,
965
+ printerName
966
+ });
967
+ return data;
968
+ };
969
+
970
+ // src/services/report.service.ts
971
+ var getStockByWarehouseReport = async ({
972
+ limit = 2,
973
+ allWarehouses = false
974
+ }) => {
975
+ const response = await api.get(`/report?limit=${limit}&allWarehouses=${allWarehouses}`);
976
+ return response.data;
977
+ };
978
+ var getReportX = async ({
979
+ startDate,
980
+ sellerID,
981
+ isShiftChange = false
982
+ }) => {
983
+ const response = await api.get(
984
+ `/report/report-x?startDate=${startDate}&sellerID=${sellerID}&isShiftChange=${isShiftChange}`
985
+ );
986
+ return response.data;
987
+ };
988
+ var printReportX = async ({
989
+ startDate,
990
+ sellerID
991
+ }) => {
992
+ const response = await api.get(
993
+ `/report/printReport-x?startDate=${startDate}&sellerID=${sellerID}`
994
+ );
995
+ return response.data;
996
+ };
997
+ var getReportComparisonByTimeFrame = async ({
998
+ startDate,
999
+ endDate,
1000
+ comparisonBy,
1001
+ productIds
1002
+ }) => {
1003
+ const response = await api.get(
1004
+ `/report/comparison?startDate=${startDate.toISOString()}&endDate=${endDate.toISOString()}&comparisonBy=${comparisonBy}&productIds=${productIds}`
1005
+ );
1006
+ return response.data;
1007
+ };
1008
+ var getReportByInventory = async ({
1009
+ productIDs,
1010
+ categoryIDs,
1011
+ warehouseIDs,
1012
+ providerIDs
1013
+ }) => {
1014
+ const params = new URLSearchParams();
1015
+ if (productIDs && productIDs.length > 0) {
1016
+ params.append("productIDs", productIDs.join(","));
1017
+ }
1018
+ if (categoryIDs && categoryIDs.length > 0) {
1019
+ params.append("categoryIDs", categoryIDs.join(","));
1020
+ }
1021
+ if (warehouseIDs && warehouseIDs.length > 0) {
1022
+ params.append("warehouseIDs", warehouseIDs.join(","));
1023
+ }
1024
+ if (providerIDs && providerIDs.length > 0) {
1025
+ params.append("providerIDs", providerIDs.join(","));
1026
+ }
1027
+ const queryString = params.toString();
1028
+ const url = `/report/inventory${queryString ? `?${queryString}` : ""}`;
1029
+ const response = await api.get(url);
1030
+ return response.data;
1031
+ };
1032
+ var getReportZ = async ({
1033
+ startDate,
1034
+ sellerID,
1035
+ isShiftChange = false
1036
+ }) => {
1037
+ const response = await api.get(
1038
+ `/report/report-z?startDate=${startDate}&sellerID=${sellerID}&isShiftChange=${isShiftChange}`
1039
+ );
1040
+ return response.data;
1041
+ };
1042
+ var printReportZ = async ({
1043
+ startDate,
1044
+ sellerID
1045
+ }) => {
1046
+ const response = await api.get(
1047
+ `/report/printReport-z?startDate=${startDate}&sellerID=${sellerID}`
1048
+ );
1049
+ return response.data;
1050
+ };
1051
+ var checkPendingReportZ = async () => {
1052
+ const response = await api.get("/report/pending-report-z");
1053
+ return response.data;
1054
+ };
1055
+
1056
+ // src/services/return.service.ts
1057
+ var createReturn = async ({
1058
+ orderId,
1059
+ returnReason,
1060
+ orderDetails,
1061
+ warehouseDestinationID
1062
+ }) => {
1063
+ const response = await api.post(`/returns`, {
1064
+ orderId,
1065
+ returnReason,
1066
+ orderDetails,
1067
+ warehouseDestinationID
1068
+ });
1069
+ return response.data;
1070
+ };
1071
+ var getReturnsByOrderId = async (orderId) => {
1072
+ const response = await api.get(`/returns/order/${orderId}`);
1073
+ return response.data;
1074
+ };
1075
+
1076
+ // src/services/role.service.ts
1077
+ var getRoles = async () => {
1078
+ const response = await api.get("/role");
1079
+ return response.data;
1080
+ };
1081
+ var getRoleByID = async (id) => {
1082
+ const response = await api.get(`/role/${id}`);
1083
+ return response.data;
1084
+ };
1085
+ var createRole = async (role) => {
1086
+ const response = await api.post("/role", role);
1087
+ return response.data;
1088
+ };
1089
+ var updateRole = async (id, role) => {
1090
+ const response = await api.put(`/role/${id}`, role);
1091
+ return response.data;
1092
+ };
1093
+ var deleteRole = async (id) => {
1094
+ await api.delete(`/role/${id}`);
1095
+ };
1096
+
1097
+ // src/services/stockmovement.service.ts
1098
+ var createMovement = async (movement) => {
1099
+ const { data } = await api.post("movement/", movement, {
1100
+ headers: {
1101
+ "Content-Type": "multipart/form-data"
1102
+ }
1103
+ });
1104
+ return data;
1105
+ };
1106
+ var getMovements = async ({
1107
+ skip = 0,
1108
+ limit = 10,
1109
+ query = "",
1110
+ movementType = 1
1111
+ }) => {
1112
+ const { data } = await api.get(
1113
+ `movement/movements?skip=${skip}&limit=${limit}&query=${query}&movementTypeID=${movementType}`
1114
+ );
1115
+ return data;
1116
+ };
1117
+
1118
+ // src/services/shift.service.ts
1119
+ var closeShift = async (data) => {
1120
+ const response = await api.post("/shift/close", data, {
1121
+ headers: {
1122
+ "Content-Type": "application/json"
1123
+ }
1124
+ });
1125
+ return response.data;
1126
+ };
1127
+ var makeNewCashMovement = async ({
1128
+ userID,
1129
+ amount,
1130
+ comment,
1131
+ isWithdrawal
1132
+ }) => {
1133
+ const { data } = await api.post(
1134
+ "shift/cashmovement",
1135
+ {
1136
+ userID,
1137
+ amount,
1138
+ comment,
1139
+ isWithdrawal
1140
+ },
1141
+ {
1142
+ headers: {
1143
+ "Content-Type": "application/json"
1144
+ }
1145
+ }
1146
+ );
1147
+ return data;
1148
+ };
1149
+ var setNewShift = async ({
1150
+ userID,
1151
+ initialCash
1152
+ }) => {
1153
+ const { data } = await api.post(
1154
+ "shift/",
1155
+ {
1156
+ userID,
1157
+ initialCash
1158
+ },
1159
+ {
1160
+ headers: {
1161
+ "Content-Type": "application/json"
1162
+ }
1163
+ }
1164
+ );
1165
+ return data;
1166
+ };
1167
+
1168
+ // src/services/state.service.ts
1169
+ var getAllStates = async () => {
1170
+ const { data } = await api.get("state/");
1171
+ return data;
1172
+ };
1173
+
1174
+ // src/services/tax.service.ts
1175
+ var getTaxesForSelect = async () => {
1176
+ const { data } = await api.get("tax/taxesForSelect");
1177
+ return data;
1178
+ };
1179
+
1180
+ // src/services/user.service.ts
1181
+ var getSellersWithShift = async () => {
1182
+ const { data } = await api.get(`user/getSellersWithShift/`);
1183
+ return data;
1184
+ };
1185
+ var getSellersOfDayForSelect = async ({
1186
+ date
1187
+ }) => {
1188
+ const { data } = await api.get(`user/getSellersOfDayForSelect/${date}`);
1189
+ return data;
1190
+ };
1191
+ var getAllAgents = async () => {
1192
+ const { data } = await api.get("user/getallagents");
1193
+ return data;
1194
+ };
1195
+ var getUsers = async ({
1196
+ skip = 0,
1197
+ limit = 10,
1198
+ query = ""
1199
+ }) => {
1200
+ const { data } = await api.get(`user/?skip=${skip}&limit=${limit}&query=${query}`);
1201
+ return data;
1202
+ };
1203
+ var getUserById = async ({ userId }) => {
1204
+ const { data } = await api.get(`user/${userId}`);
1205
+ return data;
1206
+ };
1207
+ var createUser = async ({ user }) => {
1208
+ await api.post("user/", user);
1209
+ };
1210
+ var updateUser = async ({
1211
+ userId,
1212
+ user
1213
+ }) => {
1214
+ await api.put(`user/${userId}`, user);
1215
+ };
1216
+ var deleteUser = async ({ userId }) => {
1217
+ await api.delete(`user/${userId}`);
1218
+ };
1219
+ var restoreUser = async ({ userId }) => {
1220
+ await api.patch(`user/${userId}`);
1221
+ };
1222
+
1223
+ // src/services/warehouse.service.ts
1224
+ var getWarehousesForSelect = async () => {
1225
+ const { data } = await api.get("warehouse/warehousesForSelect");
1226
+ return data;
1227
+ };
1228
+ var getWarehouses = async ({
1229
+ skip = 0,
1230
+ limit = 10,
1231
+ query = ""
1232
+ }) => {
1233
+ const { data } = await api.get(
1234
+ `warehouse/warehouses?skip=${skip}&limit=${limit}&query=${query}`
1235
+ );
1236
+ return data;
1237
+ };
1238
+ var getWarehouseById = async (id) => {
1239
+ const { data } = await api.get(`/warehouse/${id}`);
1240
+ return data.data;
1241
+ };
1242
+ var updateWarehouse = async ({
1243
+ id,
1244
+ warehouse
1245
+ }) => {
1246
+ const { data } = await api.put(`/warehouse/${id}`, warehouse, {
1247
+ headers: {
1248
+ "Content-Type": "multipart/form-data"
1249
+ }
1250
+ });
1251
+ return data;
1252
+ };
1253
+ var createWareHouse = async (warehouse) => {
1254
+ const { data } = await api.post("warehouse/", warehouse, {
1255
+ headers: {
1256
+ "Content-Type": "multipart/form-data"
1257
+ }
1258
+ });
1259
+ return data;
1260
+ };
1261
+ var deleteWarehouse = async (warehouseID) => {
1262
+ await api.delete(`/warehouse/${warehouseID}`);
1263
+ };
1264
+ var restoreWarehouse = async (warehouseID) => {
1265
+ await api.patch(`/warehouse/${warehouseID}`);
1266
+ };
1267
+
1268
+ export { ButtonTypes, ChartType, ComparisonBy, FieldTypes, Permission, PromotionTypeEnum, api, changeOrderProduct, checkPendingReportZ, closeShift, configureApi, createAttribute, createAttributeValue, createAttributesForCategory, createBankTerminal, createBatch, createBatchAndUpdateOtherBatches, createCategory, createClient, createExchangeRate, createLocation, createMaterial, createMovement, createPriceType, createProduct, createProductVariant, createPromotion, createProvider, createReturn, createRole, createUser, createWareHouse, deleteAttribute, deleteBankTerminal, deleteCategory, deleteClient, deleteImageFromProduct, deleteLocation, deleteMaterial, deletePriceType, deleteProduct, deleteProductVariant, deleteProvider, deleteRole, deleteUser, deleteWarehouse, getAllAgents, getAllBankTerminals, getAllCategories, getAllClients, getAllGenders, getAllLocations, getAllMaterials, getAllModules, getAllPermissions, getAllPriceTypes, getAllProviders, getAllStates, getAttributeById, getAttributeValues, getAttributes, getAttributesByCategoryID, getAttributesByProductID, getAttributesForSelect, getBankTerminalById, getBankTerminals, getBankTerminalsForSelect, getBatches, getBatchesForSelect, getCategories, getCategoriesForSelect, getCategoryById, getClientById, getClientsForSelect, getExchangeRate, getExchangeRates, getLocationById, getLocations, getLocationsForSelect, getMatchedBatches, getMaterialById, getMaterials, getMaterialsForSelect, getMovements, getOrderById, getOrders, getOrdersStatusForSelect, getPaymentMethods, getPaymentMethodsWithAmountExpected, getPaymentTypes, getPermissionRoleByRoleID, getPriceTypeById, getPriceTypesForSelect, getProductById, getProductVariantById, getProductVariants, getProductVariantsForSelect, getProducts, getProductsByCategory, getProductsForSelect, getProductsTable, getPromotionById, getPromotions, getPromotionsTypeForSelect, getProviderById, getProvidersForSelect, getQRBaseUrl, getReportByInventory, getReportComparisonByTimeFrame, getReportX, getReportZ, getReturnsByOrderId, getRoleByID, getRoles, getSellersOfDayForSelect, getSellersWithShift, getStockByWarehouseReport, getTaxesForSelect, getUserById, getUsers, getWarehouseById, getWarehouses, getWarehousesForSelect, healthService, isAValidDiscountCode, login, makeNewCashMovement, pricePerGramService, printProductTag, printQR, printReportX, printReportZ, restoreBankTerminal, restoreCategory, restoreClient, restoreLocation, restoreProduct, restoreProductVariant, restoreProvider, restoreUser, restoreWarehouse, sendCreditPaymentData, sendPaymentData, setNewShift, undeleteAttribute, undeleteMaterial, undeletePriceType, updateAttribute, updateAttributesForCategory, updateBankTerminal, updateBatch, updateCategory, updateClient, updateLocation, updateMaterial, updatePermission, updatePriceType, updateProduct, updateProductVariant, updatePromotion, updateProvider, updateRole, updateUser, updateWarehouse };
1269
+ //# sourceMappingURL=index.js.map
1270
+ //# sourceMappingURL=index.js.map