@zauru-sdk/utils 1.0.50 → 1.0.60

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 (79) hide show
  1. package/LICENCE.md +11 -11
  2. package/dist/cjs/index.js +40 -0
  3. package/dist/cjs/zauru/4pinos-receptions-form-history.utils.js +80 -0
  4. package/dist/cjs/zauru/automatic-number.utils.js +28 -0
  5. package/dist/cjs/zauru/bitacora-edicion-masiva.utils.js +56 -0
  6. package/dist/cjs/zauru/bundles.utils.js +168 -0
  7. package/dist/cjs/zauru/cases.utils.js +21 -0
  8. package/dist/cjs/zauru/consolidated-history.utils.js +58 -0
  9. package/dist/cjs/zauru/costos-items.utils.js +617 -0
  10. package/dist/cjs/zauru/deliveries.utils.js +50 -0
  11. package/dist/cjs/zauru/discharges-histsory.utils.js +52 -0
  12. package/dist/cjs/zauru/employees.utils.js +44 -0
  13. package/dist/cjs/zauru/form.utils.js +160 -0
  14. package/dist/cjs/zauru/invoices.utils.js +85 -0
  15. package/dist/cjs/zauru/items.utils.js +126 -0
  16. package/dist/cjs/zauru/lotes.utils.js +313 -0
  17. package/dist/cjs/zauru/motivos-rechazo.utils.js +23 -0
  18. package/dist/cjs/zauru/payees.utils.js +136 -0
  19. package/dist/cjs/zauru/profiles.utils.js +41 -0
  20. package/dist/cjs/zauru/providers.utils.js +40 -0
  21. package/dist/cjs/zauru/purchase-orders.utils.js +390 -0
  22. package/dist/cjs/zauru/shipments.utils.js +95 -0
  23. package/dist/cjs/zauru/specialItem.utils.js +69 -0
  24. package/dist/cjs/zauru/templates.utils.js +102 -0
  25. package/dist/cjs/zauru/tiposMuestra.utils.js +69 -0
  26. package/dist/cjs/zauru/webapp-tables.utils.js +20 -0
  27. package/package.json +16 -13
  28. package/CHANGELOG.md +0 -256
  29. package/src/index.ts +0 -24
  30. package/src/zauru/4pinos-receptions-form-history.utils.ts +0 -142
  31. package/src/zauru/automatic-number.utils.ts +0 -38
  32. package/src/zauru/bitacora-edicion-masiva.utils.ts +0 -99
  33. package/src/zauru/bundles.utils.ts +0 -251
  34. package/src/zauru/cases.utils.ts +0 -31
  35. package/src/zauru/consolidated-history.utils.ts +0 -102
  36. package/src/zauru/costos-items.utils.ts +0 -871
  37. package/src/zauru/deliveries.utils.ts +0 -77
  38. package/src/zauru/discharges-histsory.utils.ts +0 -105
  39. package/src/zauru/employees.utils.ts +0 -59
  40. package/src/zauru/form.utils.ts +0 -243
  41. package/src/zauru/invoices.utils.ts +0 -114
  42. package/src/zauru/items.utils.ts +0 -221
  43. package/src/zauru/lotes.utils.ts +0 -411
  44. package/src/zauru/motivos-rechazo.utils.ts +0 -47
  45. package/src/zauru/payees.utils.ts +0 -213
  46. package/src/zauru/profiles.utils.ts +0 -44
  47. package/src/zauru/providers.utils.ts +0 -67
  48. package/src/zauru/purchase-orders.utils.ts +0 -594
  49. package/src/zauru/shipments.utils.ts +0 -139
  50. package/src/zauru/specialItem.utils.ts +0 -136
  51. package/src/zauru/templates.utils.ts +0 -199
  52. package/src/zauru/tiposMuestra.utils.ts +0 -136
  53. package/src/zauru/webapp-tables.utils.ts +0 -36
  54. package/tsconfig.json +0 -24
  55. /package/dist/{index.js → esm/index.js} +0 -0
  56. /package/dist/{zauru → esm/zauru}/4pinos-receptions-form-history.utils.js +0 -0
  57. /package/dist/{zauru → esm/zauru}/automatic-number.utils.js +0 -0
  58. /package/dist/{zauru → esm/zauru}/bitacora-edicion-masiva.utils.js +0 -0
  59. /package/dist/{zauru → esm/zauru}/bundles.utils.js +0 -0
  60. /package/dist/{zauru → esm/zauru}/cases.utils.js +0 -0
  61. /package/dist/{zauru → esm/zauru}/consolidated-history.utils.js +0 -0
  62. /package/dist/{zauru → esm/zauru}/costos-items.utils.js +0 -0
  63. /package/dist/{zauru → esm/zauru}/deliveries.utils.js +0 -0
  64. /package/dist/{zauru → esm/zauru}/discharges-histsory.utils.js +0 -0
  65. /package/dist/{zauru → esm/zauru}/employees.utils.js +0 -0
  66. /package/dist/{zauru → esm/zauru}/form.utils.js +0 -0
  67. /package/dist/{zauru → esm/zauru}/invoices.utils.js +0 -0
  68. /package/dist/{zauru → esm/zauru}/items.utils.js +0 -0
  69. /package/dist/{zauru → esm/zauru}/lotes.utils.js +0 -0
  70. /package/dist/{zauru → esm/zauru}/motivos-rechazo.utils.js +0 -0
  71. /package/dist/{zauru → esm/zauru}/payees.utils.js +0 -0
  72. /package/dist/{zauru → esm/zauru}/profiles.utils.js +0 -0
  73. /package/dist/{zauru → esm/zauru}/providers.utils.js +0 -0
  74. /package/dist/{zauru → esm/zauru}/purchase-orders.utils.js +0 -0
  75. /package/dist/{zauru → esm/zauru}/shipments.utils.js +0 -0
  76. /package/dist/{zauru → esm/zauru}/specialItem.utils.js +0 -0
  77. /package/dist/{zauru → esm/zauru}/templates.utils.js +0 -0
  78. /package/dist/{zauru → esm/zauru}/tiposMuestra.utils.js +0 -0
  79. /package/dist/{zauru → esm/zauru}/webapp-tables.utils.js +0 -0
package/LICENCE.md CHANGED
@@ -1,11 +1,11 @@
1
- # Released under MIT License
2
-
3
- Copyright (c) 2013 Mark Otto.
4
-
5
- Copyright (c) 2017 Andrew Fong.
6
-
7
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
-
9
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
-
11
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ # Released under MIT License
2
+
3
+ Copyright (c) 2013 Mark Otto.
4
+
5
+ Copyright (c) 2017 Andrew Fong.
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
+
9
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./zauru/4pinos-receptions-form-history.utils.js"), exports);
18
+ __exportStar(require("./zauru/automatic-number.utils.js"), exports);
19
+ __exportStar(require("./zauru/bitacora-edicion-masiva.utils.js"), exports);
20
+ __exportStar(require("./zauru/bundles.utils.js"), exports);
21
+ __exportStar(require("./zauru/cases.utils.js"), exports);
22
+ __exportStar(require("./zauru/consolidated-history.utils.js"), exports);
23
+ __exportStar(require("./zauru/costos-items.utils.js"), exports);
24
+ __exportStar(require("./zauru/deliveries.utils.js"), exports);
25
+ __exportStar(require("./zauru/discharges-histsory.utils.js"), exports);
26
+ __exportStar(require("./zauru/employees.utils.js"), exports);
27
+ __exportStar(require("./zauru/form.utils.js"), exports);
28
+ __exportStar(require("./zauru/invoices.utils.js"), exports);
29
+ __exportStar(require("./zauru/items.utils.js"), exports);
30
+ __exportStar(require("./zauru/lotes.utils.js"), exports);
31
+ __exportStar(require("./zauru/motivos-rechazo.utils.js"), exports);
32
+ __exportStar(require("./zauru/payees.utils.js"), exports);
33
+ __exportStar(require("./zauru/profiles.utils.js"), exports);
34
+ __exportStar(require("./zauru/providers.utils.js"), exports);
35
+ __exportStar(require("./zauru/purchase-orders.utils.js"), exports);
36
+ __exportStar(require("./zauru/shipments.utils.js"), exports);
37
+ __exportStar(require("./zauru/specialItem.utils.js"), exports);
38
+ __exportStar(require("./zauru/templates.utils.js"), exports);
39
+ __exportStar(require("./zauru/tiposMuestra.utils.js"), exports);
40
+ __exportStar(require("./zauru/webapp-tables.utils.js"), exports);
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteQueueFormReceptionHistory = exports.updateQueueFormReceptionHistory = exports.createQueueFormReceptionHistory = exports.getQueueFormReceptionHistories = exports.ESTADOS_COLA_RECEPCIONES = void 0;
4
+ const common_1 = require("@zauru-sdk/common");
5
+ const services_1 = require("@zauru-sdk/services");
6
+ exports.ESTADOS_COLA_RECEPCIONES = {
7
+ EN_PROCESO: "En proceso",
8
+ ERROR: "Con error",
9
+ REINTENTANDO: "Reintentando",
10
+ OFFLINE: "Registro local",
11
+ };
12
+ /**
13
+ * Get getQueueFormReceptionHistories from the web app table.
14
+ * @param headers Request headers.
15
+ * @param session Session object.
16
+ * @returns A Promise of AxiosUtilsResponse<QueueFormReceptionWebAppTable[]>.
17
+ */
18
+ const getQueueFormReceptionHistories = (headers, session) => {
19
+ return (0, common_1.handlePossibleAxiosErrors)(async () => {
20
+ const { queue_form_recepcion_submited_web_app_table_id } = await (0, services_1.getVariablesByName)(headers, session, [
21
+ "queue_form_recepcion_submited_web_app_table_id",
22
+ ]);
23
+ const response = await (0, services_1.getWebAppTableRegisters)(session, queue_form_recepcion_submited_web_app_table_id);
24
+ if (response.error) {
25
+ throw new Error(`Ocurrió un error al consultar el historial de colas: ${response.userMsg}`);
26
+ }
27
+ const history = response?.data ?? [];
28
+ return history;
29
+ });
30
+ };
31
+ exports.getQueueFormReceptionHistories = getQueueFormReceptionHistories;
32
+ /**
33
+ * Create a template in the web app table.
34
+ * @param headers Request headers.
35
+ * @param session Session object.
36
+ * @param body QueueFormReceptionWebAppTable data to be created.
37
+ * @returns A Promise of AxiosUtilsResponse<QueueFormReceptionWebAppTable>.
38
+ */
39
+ const createQueueFormReceptionHistory = (headers, session, body) => {
40
+ return (0, common_1.handlePossibleAxiosErrors)(async () => {
41
+ const { queue_form_recepcion_submited_web_app_table_id } = await (0, services_1.getVariablesByName)(headers, session, [
42
+ "queue_form_recepcion_submited_web_app_table_id",
43
+ ]);
44
+ const response = await (0, services_1.createWebAppTableRegister)(headers, queue_form_recepcion_submited_web_app_table_id, body);
45
+ return response;
46
+ });
47
+ };
48
+ exports.createQueueFormReceptionHistory = createQueueFormReceptionHistory;
49
+ /**
50
+ * Put updateQueueFormReception from the web app table.
51
+ * @param headers Request headers.
52
+ * @param session Session object.
53
+ * @returns A Promise of AxiosUtilsResponse<QueueFormReceptionWebAppTable[]>.
54
+ */
55
+ const updateQueueFormReceptionHistory = (headers, session, body, id_registro) => {
56
+ return (0, common_1.handlePossibleAxiosErrors)(async () => {
57
+ const { queue_form_recepcion_submited_web_app_table_id } = await (0, services_1.getVariablesByName)(headers, session, [
58
+ "queue_form_recepcion_submited_web_app_table_id",
59
+ ]);
60
+ const response = await (0, services_1.updateWebAppTableRegister)(headers, queue_form_recepcion_submited_web_app_table_id, id_registro, { ...body });
61
+ return response;
62
+ });
63
+ };
64
+ exports.updateQueueFormReceptionHistory = updateQueueFormReceptionHistory;
65
+ /**
66
+ * Delete QueueFormReceptionHistory from the web app table.
67
+ * @param headers Request headers.
68
+ * @param session Session object.
69
+ * @returns A Promise of AxiosUtilsResponse<QueueFormReceptionWebAppTable[]>.
70
+ */
71
+ const deleteQueueFormReceptionHistory = (headers, session, id) => {
72
+ return (0, common_1.handlePossibleAxiosErrors)(async () => {
73
+ const { queue_form_recepcion_submited_web_app_table_id } = await (0, services_1.getVariablesByName)(headers, session, [
74
+ "queue_form_recepcion_submited_web_app_table_id",
75
+ ]);
76
+ const response = await (0, services_1.deleteWebAppTableRegister)(headers, queue_form_recepcion_submited_web_app_table_id, Number(id));
77
+ return response;
78
+ });
79
+ };
80
+ exports.deleteQueueFormReceptionHistory = deleteQueueFormReceptionHistory;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateMuestraAutomaticNumber = void 0;
4
+ const services_1 = require("@zauru-sdk/services");
5
+ const common_1 = require("@zauru-sdk/common");
6
+ /**
7
+ * updateMuestraAutomaticNumber
8
+ * @param headers
9
+ * @param session
10
+ * @returns
11
+ */
12
+ const updateMuestraAutomaticNumber = async (headers, session, current_number) => {
13
+ return (0, common_1.handlePossibleAxiosErrors)(async () => {
14
+ let msg = "";
15
+ const { lab_muestra_automatic_number_id } = await (0, services_1.getVariablesByName)(headers, session, ["lab_muestra_automatic_number_id"]);
16
+ const response = await (0, services_1.updateAutomaticNumber)(headers, {
17
+ id: Number(lab_muestra_automatic_number_id),
18
+ variable_doc_number: current_number,
19
+ });
20
+ if (response.error) {
21
+ msg = `Ocurrió un error al intentar actualizar el número automático de muestras: ${response.userMsg}`;
22
+ console.error(msg);
23
+ throw new Error(msg);
24
+ }
25
+ return true;
26
+ });
27
+ };
28
+ exports.updateMuestraAutomaticNumber = updateMuestraAutomaticNumber;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateBitacorasPOMassive = exports.getBitacorasPOMassive = exports.saveBitacoraPOMassive = void 0;
4
+ const common_1 = require("@zauru-sdk/common");
5
+ const services_1 = require("@zauru-sdk/services");
6
+ /**
7
+ * Get saveBitacoraPOMassive from the web app table.
8
+ * @param headers Request headers.
9
+ * @param session Session object.
10
+ * @returns A Promise of AxiosUtilsResponse<WebAppRowGraphQL<BitacoraPOMassive>[]>.
11
+ */
12
+ const saveBitacoraPOMassive = (headers, session, body) => {
13
+ return (0, common_1.handlePossibleAxiosErrors)(async () => {
14
+ const { bitacora_ediciones_masivas_web_app_table_id } = await (0, services_1.getVariablesByName)(headers, session, [
15
+ "bitacora_ediciones_masivas_web_app_table_id",
16
+ ]);
17
+ const response = await (0, services_1.createWebAppTableRegister)(headers, bitacora_ediciones_masivas_web_app_table_id, { ...body, modificadoPor: session.get("name") });
18
+ return response;
19
+ });
20
+ };
21
+ exports.saveBitacoraPOMassive = saveBitacoraPOMassive;
22
+ /**
23
+ * Get getBitacorasPOMassive from the web app table.
24
+ * @param headers Request headers.
25
+ * @param session Session object.
26
+ * @returns A Promise of AxiosUtilsResponse<WebAppRowGraphQL<BitacoraPOMassive>[]>.
27
+ */
28
+ const getBitacorasPOMassive = (headers, session) => {
29
+ return (0, common_1.handlePossibleAxiosErrors)(async () => {
30
+ const { bitacora_ediciones_masivas_web_app_table_id } = await (0, services_1.getVariablesByName)(headers, session, [
31
+ "bitacora_ediciones_masivas_web_app_table_id",
32
+ ]);
33
+ const response = await (0, services_1.getWebAppTableRegisters)(session, bitacora_ediciones_masivas_web_app_table_id);
34
+ if (response.error || !response.data) {
35
+ throw new Error(response.userMsg);
36
+ }
37
+ return response.data;
38
+ });
39
+ };
40
+ exports.getBitacorasPOMassive = getBitacorasPOMassive;
41
+ /**
42
+ * Put updateBitacorasPOMassive from the web app table.
43
+ * @param headers Request headers.
44
+ * @param session Session object.
45
+ * @returns A Promise of AxiosUtilsResponse<BitacorasPOMassiveWebAppTable[]>.
46
+ */
47
+ const updateBitacorasPOMassive = (headers, session, body, id_registro) => {
48
+ return (0, common_1.handlePossibleAxiosErrors)(async () => {
49
+ const { bitacora_ediciones_masivas_web_app_table_id } = await (0, services_1.getVariablesByName)(headers, session, [
50
+ "bitacora_ediciones_masivas_web_app_table_id",
51
+ ]);
52
+ const response = await (0, services_1.updateWebAppTableRegister)(headers, bitacora_ediciones_masivas_web_app_table_id, id_registro, { ...body, modificadoPor: session.get("name") });
53
+ return response;
54
+ });
55
+ };
56
+ exports.updateBitacorasPOMassive = updateBitacorasPOMassive;
@@ -0,0 +1,168 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteLabBundle = exports.createNewLabEnsayo = exports.createNewLabPaquete = exports.getBundlesByLabCategory = exports.getBundlesRecipByLabCategory = exports.LAB_BUNDLE_NAME = void 0;
4
+ const common_1 = require("@zauru-sdk/common");
5
+ const services_1 = require("@zauru-sdk/services");
6
+ const items_utils_js_1 = require("./items.utils.js");
7
+ exports.LAB_BUNDLE_NAME = "LAB_BUNDLE_RECIP_";
8
+ /**
9
+ *
10
+ * @param headers
11
+ * @param session
12
+ * @returns
13
+ */
14
+ const getBundlesRecipByLabCategory = async (headers, session) => {
15
+ return (0, common_1.handlePossibleAxiosErrors)(async () => {
16
+ const { lab_bundles_recip_item_category_id } = await (0, services_1.getVariablesByName)(headers, session, ["lab_bundles_recip_item_category_id"]);
17
+ const response = await (0, services_1.getBundlesByItemCategoryId)(session, lab_bundles_recip_item_category_id);
18
+ if (response.error) {
19
+ throw new Error(`Ocurrió un error al consultar los paquetes por categoría de laboratorio: ${response.userMsg}`);
20
+ }
21
+ return response?.data ?? [];
22
+ });
23
+ };
24
+ exports.getBundlesRecipByLabCategory = getBundlesRecipByLabCategory;
25
+ /**
26
+ *
27
+ * @param headers
28
+ * @param session
29
+ * @returns
30
+ */
31
+ const getBundlesByLabCategory = async (headers, session) => {
32
+ return (0, common_1.handlePossibleAxiosErrors)(async () => {
33
+ const { lab_bundles_item_category_id } = await (0, services_1.getVariablesByName)(headers, session, ["lab_bundles_item_category_id"]);
34
+ const response = await (0, services_1.getBundlesByItemCategoryId)(session, lab_bundles_item_category_id);
35
+ if (response.error) {
36
+ throw new Error(`Ocurrió un error al consultar los paquetes por categoría de laboratorio: ${response.userMsg}`);
37
+ }
38
+ return response?.data ?? [];
39
+ });
40
+ };
41
+ exports.getBundlesByLabCategory = getBundlesByLabCategory;
42
+ /**
43
+ * createNewLabPaquete
44
+ * @param headers
45
+ * @param session
46
+ * @returns
47
+ */
48
+ const createNewLabPaquete = async (headers, session, body) => {
49
+ return (0, common_1.handlePossibleAxiosErrors)(async () => {
50
+ let msg = "";
51
+ const { lab_bundles_item_category_id } = await (0, services_1.getVariablesByName)(headers, session, ["lab_bundles_item_category_id"]);
52
+ const sendBody = {
53
+ ...body,
54
+ bundle_details: body?.bundle_details?.map((x) => {
55
+ x._destroy = false;
56
+ return x;
57
+ }),
58
+ item_category_id: Number(lab_bundles_item_category_id),
59
+ force_as_service_for_document_external_storage_service: true,
60
+ };
61
+ const bundleResponse = await (0, services_1.createBundle)(headers, sendBody);
62
+ if (bundleResponse.error) {
63
+ msg = `Ocurrió un error al intentar crear el paquete: ${bundleResponse.userMsg}`;
64
+ console.error(msg);
65
+ throw new Error(msg);
66
+ }
67
+ return true;
68
+ });
69
+ };
70
+ exports.createNewLabPaquete = createNewLabPaquete;
71
+ /**
72
+ * createNewLabEnsayo
73
+ * @param headers
74
+ * @param session
75
+ * @returns
76
+ */
77
+ const createNewLabEnsayo = async (headers, session, body) => {
78
+ return (0, common_1.handlePossibleAxiosErrors)(async () => {
79
+ let msg = "";
80
+ const { lab_bundles_recip_item_category_id, lab_services_item_category_id, } = await (0, services_1.getVariablesByName)(headers, session, [
81
+ "lab_bundles_recip_item_category_id",
82
+ "lab_services_item_category_id",
83
+ ]);
84
+ //PASO 1
85
+ //Creamos el bundle -> Paquete, donde va la receta
86
+ const sendBody = {
87
+ ...body,
88
+ item_category_id: Number(lab_bundles_recip_item_category_id),
89
+ name: `${exports.LAB_BUNDLE_NAME}${body.name}`,
90
+ };
91
+ const bundleResponse = await (0, services_1.createBundle)(headers, sendBody);
92
+ if (bundleResponse.error) {
93
+ msg = `Ocurrió un error al intentar crear el paquete: ${bundleResponse.userMsg}`;
94
+ console.error(msg);
95
+ throw new Error(msg);
96
+ }
97
+ console.log("-------------- BUNDLE CREADO ! ---------------");
98
+ //PASO 2
99
+ //Creamos el item
100
+ const itemSendBody = {
101
+ name: `LAB_SERVICE_${bundleResponse?.data?.id}; ${body.name}`,
102
+ code: `LAB_SERVICE_${bundleResponse?.data?.id}`,
103
+ stockable: false, //Esto lo vuelve servicio
104
+ purchasable: false,
105
+ sellable: true,
106
+ pays_vat: true,
107
+ item_category_id: Number(lab_services_item_category_id),
108
+ description: `Item creado desde la webapp de laboratorio, para representar el servicio del ensayo creado. Ensayo: ${bundleResponse?.data?.id}`,
109
+ };
110
+ const itemResponse = await (0, items_utils_js_1.createNewLaboratoryItem)(headers, itemSendBody);
111
+ if (itemResponse.error) {
112
+ msg = `Ocurrió un error al intentar crear el item asociado al paquete: ${itemResponse.userMsg}`;
113
+ console.error(msg);
114
+ throw new Error(msg);
115
+ }
116
+ console.log("-------------- ITEM CREADO ! ---------------");
117
+ //PASO 3
118
+ //Creo el formulario
119
+ const formSendBody = {
120
+ active: true,
121
+ name: `LAB_FORM_${itemResponse?.data?.id}; ${body.name}`,
122
+ description: `Formulario creado desde la webapp, que representa el formulario con las preguntas que se llenan en el ensayo al que hace referencia el mismo. Ensayo: ${itemResponse?.data?.id}`,
123
+ document_type: "invoice",
124
+ settings_form_fields: [
125
+ {
126
+ position: 1,
127
+ name: "Pregunta 1",
128
+ field_type: "text",
129
+ default_value: "",
130
+ print_var_name: "pregunta_1",
131
+ },
132
+ ],
133
+ };
134
+ const formResponse = await (0, services_1.createForm)(headers, formSendBody);
135
+ if (formResponse.error) {
136
+ msg = `Ocurrió un error al intentar crear el formulario asociado al paquete: ${formResponse.userMsg}`;
137
+ console.error(msg);
138
+ throw new Error(msg);
139
+ }
140
+ console.log("-------------- FORM CREADO ! ---------------");
141
+ return true;
142
+ });
143
+ };
144
+ exports.createNewLabEnsayo = createNewLabEnsayo;
145
+ /**
146
+ * deleteLabBundle
147
+ * @param headers
148
+ * @param session
149
+ * @param bundle
150
+ * @returns
151
+ */
152
+ const deleteLabBundle = async (headers, session, bundle) => {
153
+ return (0, common_1.handlePossibleAxiosErrors)(async () => {
154
+ await (0, services_1.deleteBundle)(headers, bundle.id);
155
+ //busco el item-servicio para eliminarlo
156
+ const responseItem = await (0, services_1.getItemByName)(session, `LAB_SERVICE_${bundle.id}; ${bundle.name}`);
157
+ if (responseItem.data && !responseItem.error) {
158
+ await (0, services_1.deleteItem)(headers, responseItem.data.id);
159
+ }
160
+ //busco el formulario para eliminarlo
161
+ const responseForm = await (0, services_1.getFormByName)(session, `LAB_FORM_${bundle.id}; ${bundle.name}`);
162
+ if (responseForm.data && !responseForm.error) {
163
+ await (0, services_1.deleteForm)(headers, responseForm.data.id);
164
+ }
165
+ return true;
166
+ });
167
+ };
168
+ exports.deleteLabBundle = deleteLabBundle;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMyCases = void 0;
4
+ const common_1 = require("@zauru-sdk/common");
5
+ const services_1 = require("@zauru-sdk/services");
6
+ /**
7
+ *
8
+ * @param headers
9
+ * @param session
10
+ * @returns
11
+ */
12
+ const getMyCases = async (session, wheres = []) => {
13
+ return (0, common_1.handlePossibleAxiosErrors)(async () => {
14
+ const response = await (0, services_1.getCasesByResponsibleId)(session, session.get("employee_id"), wheres);
15
+ if (response.error) {
16
+ throw new Error(`Ocurrió un error al consultar los casos asignados a este usuario: ${response.userMsg}`);
17
+ }
18
+ return response?.data ?? [];
19
+ });
20
+ };
21
+ exports.getMyCases = getMyCases;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateConsolidatedHistory = exports.createConsolidatedHistory = exports.getConsolidatedHistories = void 0;
4
+ const common_1 = require("@zauru-sdk/common");
5
+ const services_1 = require("@zauru-sdk/services");
6
+ /**
7
+ * Get getConsolidatedHistories from the web app table.
8
+ * @param headers Request headers.
9
+ * @param session Session object.
10
+ * @returns A Promise of AxiosUtilsResponse<ConsolidatedHistory[]>.
11
+ */
12
+ const getConsolidatedHistories = (headers, session) => {
13
+ return (0, common_1.handlePossibleAxiosErrors)(async () => {
14
+ const { purchase_order_consolidates_web_app_table_id } = await (0, services_1.getVariablesByName)(headers, session, [
15
+ "purchase_order_consolidates_web_app_table_id",
16
+ ]);
17
+ const response = await (0, services_1.getWebAppTableRegisters)(session, purchase_order_consolidates_web_app_table_id);
18
+ if (response.error) {
19
+ throw new Error(`Ocurrió un error al consultar el historial de consolidados: ${response.userMsg}`);
20
+ }
21
+ const history = response?.data ?? [];
22
+ return history;
23
+ });
24
+ };
25
+ exports.getConsolidatedHistories = getConsolidatedHistories;
26
+ /**
27
+ * Create a template in the web app table.
28
+ * @param headers Request headers.
29
+ * @param session Session object.
30
+ * @param body ConsolidatedHistory data to be created.
31
+ * @returns A Promise of AxiosUtilsResponse<ConsolidatedHistory>.
32
+ */
33
+ const createConsolidatedHistory = (headers, session, body) => {
34
+ return (0, common_1.handlePossibleAxiosErrors)(async () => {
35
+ const { purchase_order_consolidates_web_app_table_id } = await (0, services_1.getVariablesByName)(headers, session, [
36
+ "purchase_order_consolidates_web_app_table_id",
37
+ ]);
38
+ const response = await (0, services_1.createWebAppTableRegister)(headers, purchase_order_consolidates_web_app_table_id, body);
39
+ return response;
40
+ });
41
+ };
42
+ exports.createConsolidatedHistory = createConsolidatedHistory;
43
+ /**
44
+ * Put updateConsolidatedHistory from the web app table.
45
+ * @param headers Request headers.
46
+ * @param session Session object.
47
+ * @returns A Promise of AxiosUtilsResponse<ConsolidatedHistory[]>.
48
+ */
49
+ const updateConsolidatedHistory = (headers, session, body, id_registro) => {
50
+ return (0, common_1.handlePossibleAxiosErrors)(async () => {
51
+ const { purchase_order_consolidates_web_app_table_id } = await (0, services_1.getVariablesByName)(headers, session, [
52
+ "purchase_order_consolidates_web_app_table_id",
53
+ ]);
54
+ const response = await (0, services_1.updateWebAppTableRegister)(headers, purchase_order_consolidates_web_app_table_id, id_registro, { ...body });
55
+ return response;
56
+ });
57
+ };
58
+ exports.updateConsolidatedHistory = updateConsolidatedHistory;