@zauru-sdk/utils 1.0.7 → 1.0.8

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 (74) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/index.d.ts +23 -2
  3. package/dist/index.js +23 -2
  4. package/dist/zauru/automatic-number.utils.d.ts +9 -0
  5. package/dist/zauru/automatic-number.utils.js +24 -0
  6. package/dist/zauru/bitacora-edicion-masiva.utils.d.ts +23 -0
  7. package/dist/zauru/bitacora-edicion-masiva.utils.js +50 -0
  8. package/dist/zauru/bundles.utils.d.ts +39 -0
  9. package/dist/zauru/bundles.utils.js +160 -0
  10. package/dist/zauru/cases.utils.d.ts +9 -0
  11. package/dist/zauru/cases.utils.js +17 -0
  12. package/dist/zauru/consolidated-history.utils.d.ts +24 -0
  13. package/dist/zauru/consolidated-history.utils.js +52 -0
  14. package/dist/zauru/costos-items.utils.d.ts +87 -0
  15. package/dist/zauru/costos-items.utils.js +601 -0
  16. package/dist/zauru/deliveries.utils.d.ts +17 -0
  17. package/dist/zauru/deliveries.utils.js +46 -0
  18. package/dist/zauru/discharges-histsory.utils.d.ts +24 -0
  19. package/dist/zauru/discharges-histsory.utils.js +46 -0
  20. package/dist/zauru/employees.utils.d.ts +16 -0
  21. package/dist/zauru/employees.utils.js +39 -0
  22. package/dist/zauru/form.utils.d.ts +34 -0
  23. package/dist/zauru/form.utils.js +152 -0
  24. package/dist/zauru/invoices.utils.d.ts +22 -0
  25. package/dist/zauru/invoices.utils.js +79 -0
  26. package/dist/zauru/items.utils.d.ts +52 -0
  27. package/dist/zauru/items.utils.js +152 -0
  28. package/dist/zauru/lotes.utils.d.ts +31 -0
  29. package/dist/zauru/lotes.utils.js +307 -0
  30. package/dist/zauru/motivos-rechazo.utils.d.ts +10 -0
  31. package/dist/zauru/motivos-rechazo.utils.js +18 -0
  32. package/dist/zauru/payees.utils.d.ts +42 -0
  33. package/dist/zauru/payees.utils.js +128 -0
  34. package/dist/zauru/profiles.utils.d.ts +15 -0
  35. package/dist/zauru/profiles.utils.js +37 -0
  36. package/dist/zauru/providers.utils.d.ts +13 -0
  37. package/dist/zauru/providers.utils.js +36 -0
  38. package/dist/zauru/purchase-orders.utils.d.ts +114 -0
  39. package/dist/zauru/purchase-orders.utils.js +376 -0
  40. package/dist/zauru/shipments.utils.d.ts +21 -0
  41. package/dist/zauru/shipments.utils.js +90 -0
  42. package/dist/zauru/specialItem.utils.d.ts +34 -0
  43. package/dist/zauru/specialItem.utils.js +62 -0
  44. package/dist/zauru/templates.utils.d.ts +49 -0
  45. package/dist/zauru/templates.utils.js +93 -0
  46. package/dist/zauru/tiposMuestra.utils.d.ts +34 -0
  47. package/dist/zauru/tiposMuestra.utils.js +62 -0
  48. package/dist/zauru/webapp-tables.utils.d.ts +16 -0
  49. package/dist/zauru/webapp-tables.utils.js +51 -0
  50. package/package.json +5 -5
  51. package/src/index.ts +23 -0
  52. package/src/zauru/bitacora-edicion-masiva.utils.ts +99 -0
  53. package/src/zauru/bundles.utils.ts +251 -0
  54. package/src/zauru/cases.utils.ts +31 -0
  55. package/src/zauru/consolidated-history.utils.ts +102 -0
  56. package/src/zauru/costos-items.utils.ts +865 -0
  57. package/src/zauru/deliveries.utils.ts +77 -0
  58. package/src/zauru/discharges-histsory.utils.ts +105 -0
  59. package/src/zauru/employees.utils.ts +59 -0
  60. package/src/zauru/form.utils.ts +243 -0
  61. package/src/zauru/invoices.utils.ts +114 -0
  62. package/src/zauru/items.utils.ts +269 -0
  63. package/src/zauru/lotes.utils.ts +411 -0
  64. package/src/zauru/motivos-rechazo.utils.ts +47 -0
  65. package/src/zauru/payees.utils.ts +213 -0
  66. package/src/zauru/profiles.utils.ts +44 -0
  67. package/src/zauru/providers.utils.ts +67 -0
  68. package/src/zauru/purchase-orders.utils.ts +594 -0
  69. package/src/zauru/shipments.utils.ts +139 -0
  70. package/src/zauru/specialItem.utils.ts +126 -0
  71. package/src/zauru/templates.utils.ts +199 -0
  72. package/src/zauru/tiposMuestra.utils.ts +136 -0
  73. package/src/zauru/webapp-tables.utils.ts +94 -0
  74. /package/src/{automatic-number.utils.ts → zauru/automatic-number.utils.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.0.8](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.7...v1.0.8) (2024-03-16)
7
+
8
+ **Note:** Version bump only for package @zauru-sdk/utils
9
+
10
+
11
+
12
+
13
+
6
14
  ## [1.0.7](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.6...v1.0.7) (2024-03-16)
7
15
 
8
16
  **Note:** Version bump only for package @zauru-sdk/utils
package/dist/index.d.ts CHANGED
@@ -1,2 +1,23 @@
1
- export * from "./common.js";
2
- export * from "./gtZones.js";
1
+ export * from "./zauru/automatic-number.utils.js";
2
+ export * from "./zauru/bitacora-edicion-masiva.utils.js";
3
+ export * from "./zauru/bundles.utils.js";
4
+ export * from "./zauru/cases.utils.js";
5
+ export * from "./zauru/consolidated-history.utils.js";
6
+ export * from "./zauru/costos-items.utils.js";
7
+ export * from "./zauru/deliveries.utils.js";
8
+ export * from "./zauru/discharges-histsory.utils.js";
9
+ export * from "./zauru/employees.utils.js";
10
+ export * from "./zauru/form.utils.js";
11
+ export * from "./zauru/invoices.utils.js";
12
+ export * from "./zauru/items.utils.js";
13
+ export * from "./zauru/lotes.utils.js";
14
+ export * from "./zauru/motivos-rechazo.utils.js";
15
+ export * from "./zauru/payees.utils.js";
16
+ export * from "./zauru/profiles.utils.js";
17
+ export * from "./zauru/providers.utils.js";
18
+ export * from "./zauru/purchase-orders.utils.js";
19
+ export * from "./zauru/shipments.utils.js";
20
+ export * from "./zauru/specialItem.utils.js";
21
+ export * from "./zauru/templates.utils.js";
22
+ export * from "./zauru/tiposMuestra.utils.js";
23
+ export * from "./zauru/webapp-tables.utils.js";
package/dist/index.js CHANGED
@@ -1,2 +1,23 @@
1
- export * from "./common.js";
2
- export * from "./gtZones.js";
1
+ export * from "./zauru/automatic-number.utils.js";
2
+ export * from "./zauru/bitacora-edicion-masiva.utils.js";
3
+ export * from "./zauru/bundles.utils.js";
4
+ export * from "./zauru/cases.utils.js";
5
+ export * from "./zauru/consolidated-history.utils.js";
6
+ export * from "./zauru/costos-items.utils.js";
7
+ export * from "./zauru/deliveries.utils.js";
8
+ export * from "./zauru/discharges-histsory.utils.js";
9
+ export * from "./zauru/employees.utils.js";
10
+ export * from "./zauru/form.utils.js";
11
+ export * from "./zauru/invoices.utils.js";
12
+ export * from "./zauru/items.utils.js";
13
+ export * from "./zauru/lotes.utils.js";
14
+ export * from "./zauru/motivos-rechazo.utils.js";
15
+ export * from "./zauru/payees.utils.js";
16
+ export * from "./zauru/profiles.utils.js";
17
+ export * from "./zauru/providers.utils.js";
18
+ export * from "./zauru/purchase-orders.utils.js";
19
+ export * from "./zauru/shipments.utils.js";
20
+ export * from "./zauru/specialItem.utils.js";
21
+ export * from "./zauru/templates.utils.js";
22
+ export * from "./zauru/tiposMuestra.utils.js";
23
+ export * from "./zauru/webapp-tables.utils.js";
@@ -0,0 +1,9 @@
1
+ import type { Session } from "@remix-run/node";
2
+ import { AxiosUtilsResponse } from "@zauru-sdk/types";
3
+ /**
4
+ * updateMuestraAutomaticNumber
5
+ * @param headers
6
+ * @param session
7
+ * @returns
8
+ */
9
+ export declare const updateMuestraAutomaticNumber: (headers: any, session: Session, current_number: number) => Promise<AxiosUtilsResponse<boolean>>;
@@ -0,0 +1,24 @@
1
+ import { updateAutomaticNumber, getVariablesByName } from "@zauru-sdk/services";
2
+ import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
3
+ /**
4
+ * updateMuestraAutomaticNumber
5
+ * @param headers
6
+ * @param session
7
+ * @returns
8
+ */
9
+ export const updateMuestraAutomaticNumber = async (headers, session, current_number) => {
10
+ return handlePossibleAxiosErrors(async () => {
11
+ let msg = "";
12
+ const { lab_muestra_automatic_number_id } = await getVariablesByName(headers, session, ["lab_muestra_automatic_number_id"]);
13
+ const response = await updateAutomaticNumber(headers, {
14
+ id: Number(lab_muestra_automatic_number_id),
15
+ variable_doc_number: current_number,
16
+ });
17
+ if (response.error) {
18
+ msg = `Ocurrió un error al intentar actualizar el número automático de muestras: ${response.userMsg}`;
19
+ console.error(msg);
20
+ throw new Error(msg);
21
+ }
22
+ return true;
23
+ });
24
+ };
@@ -0,0 +1,23 @@
1
+ import type { Session } from "@remix-run/node";
2
+ import { AxiosUtilsResponse, WebAppTableUpdateResponse, BitacoraPOMassive, WebAppRowGraphQL } from "@zauru-sdk/types";
3
+ /**
4
+ * Get saveBitacoraPOMassive from the web app table.
5
+ * @param headers Request headers.
6
+ * @param session Session object.
7
+ * @returns A Promise of AxiosUtilsResponse<WebAppRowGraphQL<BitacoraPOMassive>[]>.
8
+ */
9
+ export declare function saveBitacoraPOMassive(headers: any, session: Session, body: BitacoraPOMassive): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>>;
10
+ /**
11
+ * Get getBitacorasPOMassive from the web app table.
12
+ * @param headers Request headers.
13
+ * @param session Session object.
14
+ * @returns A Promise of AxiosUtilsResponse<WebAppRowGraphQL<BitacoraPOMassive>[]>.
15
+ */
16
+ export declare function getBitacorasPOMassive(headers: any, session: Session): Promise<AxiosUtilsResponse<WebAppRowGraphQL<BitacoraPOMassive>[]>>;
17
+ /**
18
+ * Put updateBitacorasPOMassive from the web app table.
19
+ * @param headers Request headers.
20
+ * @param session Session object.
21
+ * @returns A Promise of AxiosUtilsResponse<BitacorasPOMassiveWebAppTable[]>.
22
+ */
23
+ export declare function updateBitacorasPOMassive(headers: any, session: Session, body: BitacoraPOMassive, id_registro: string | number): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>>;
@@ -0,0 +1,50 @@
1
+ import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
2
+ import { createWebAppTableRegister, getVariablesByName, getWebAppTableRegisters, updateWebAppTableRegister, } from "@zauru-sdk/services";
3
+ /**
4
+ * Get saveBitacoraPOMassive from the web app table.
5
+ * @param headers Request headers.
6
+ * @param session Session object.
7
+ * @returns A Promise of AxiosUtilsResponse<WebAppRowGraphQL<BitacoraPOMassive>[]>.
8
+ */
9
+ export async function saveBitacoraPOMassive(headers, session, body) {
10
+ return handlePossibleAxiosErrors(async () => {
11
+ const { bitacora_ediciones_masivas_web_app_table_id } = await getVariablesByName(headers, session, [
12
+ "bitacora_ediciones_masivas_web_app_table_id",
13
+ ]);
14
+ const response = await createWebAppTableRegister(headers, bitacora_ediciones_masivas_web_app_table_id, { ...body, modificadoPor: session.get("name") });
15
+ return response;
16
+ });
17
+ }
18
+ /**
19
+ * Get getBitacorasPOMassive from the web app table.
20
+ * @param headers Request headers.
21
+ * @param session Session object.
22
+ * @returns A Promise of AxiosUtilsResponse<WebAppRowGraphQL<BitacoraPOMassive>[]>.
23
+ */
24
+ export async function getBitacorasPOMassive(headers, session) {
25
+ return handlePossibleAxiosErrors(async () => {
26
+ const { bitacora_ediciones_masivas_web_app_table_id } = await getVariablesByName(headers, session, [
27
+ "bitacora_ediciones_masivas_web_app_table_id",
28
+ ]);
29
+ const response = await getWebAppTableRegisters(session, bitacora_ediciones_masivas_web_app_table_id);
30
+ if (response.error || !response.data) {
31
+ throw new Error(response.userMsg);
32
+ }
33
+ return response.data;
34
+ });
35
+ }
36
+ /**
37
+ * Put updateBitacorasPOMassive from the web app table.
38
+ * @param headers Request headers.
39
+ * @param session Session object.
40
+ * @returns A Promise of AxiosUtilsResponse<BitacorasPOMassiveWebAppTable[]>.
41
+ */
42
+ export async function updateBitacorasPOMassive(headers, session, body, id_registro) {
43
+ return handlePossibleAxiosErrors(async () => {
44
+ const { bitacora_ediciones_masivas_web_app_table_id } = await getVariablesByName(headers, session, [
45
+ "bitacora_ediciones_masivas_web_app_table_id",
46
+ ]);
47
+ const response = await updateWebAppTableRegister(headers, bitacora_ediciones_masivas_web_app_table_id, id_registro, { ...body, modificadoPor: session.get("name") });
48
+ return response;
49
+ });
50
+ }
@@ -0,0 +1,39 @@
1
+ import type { Session } from "@remix-run/node";
2
+ import { AxiosUtilsResponse, BundleGraphQL } from "@zauru-sdk/types";
3
+ export declare const LAB_BUNDLE_NAME = "LAB_BUNDLE_RECIP_";
4
+ /**
5
+ *
6
+ * @param headers
7
+ * @param session
8
+ * @returns
9
+ */
10
+ export declare const getBundlesRecipByLabCategory: (headers: any, session: Session) => Promise<AxiosUtilsResponse<BundleGraphQL[]>>;
11
+ /**
12
+ *
13
+ * @param headers
14
+ * @param session
15
+ * @returns
16
+ */
17
+ export declare const getBundlesByLabCategory: (headers: any, session: Session) => Promise<AxiosUtilsResponse<BundleGraphQL[]>>;
18
+ /**
19
+ * createNewLabPaquete
20
+ * @param headers
21
+ * @param session
22
+ * @returns
23
+ */
24
+ export declare const createNewLabPaquete: (headers: any, session: Session, body: Partial<BundleGraphQL>) => Promise<AxiosUtilsResponse<boolean>>;
25
+ /**
26
+ * createNewLabEnsayo
27
+ * @param headers
28
+ * @param session
29
+ * @returns
30
+ */
31
+ export declare const createNewLabEnsayo: (headers: any, session: Session, body: Partial<BundleGraphQL>) => Promise<AxiosUtilsResponse<boolean>>;
32
+ /**
33
+ * deleteLabBundle
34
+ * @param headers
35
+ * @param session
36
+ * @param bundle
37
+ * @returns
38
+ */
39
+ export declare const deleteLabBundle: (headers: any, session: Session, bundle: BundleGraphQL) => Promise<AxiosUtilsResponse<boolean>>;
@@ -0,0 +1,160 @@
1
+ import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
2
+ import { getVariablesByName, getBundlesByItemCategoryId, createBundle, createForm, deleteBundle, getItemByName, deleteItem, getFormByName, deleteForm, } from "@zauru-sdk/services";
3
+ import { createNewLaboratoryItem } from "./items.utils.js";
4
+ export const LAB_BUNDLE_NAME = "LAB_BUNDLE_RECIP_";
5
+ /**
6
+ *
7
+ * @param headers
8
+ * @param session
9
+ * @returns
10
+ */
11
+ export const getBundlesRecipByLabCategory = async (headers, session) => {
12
+ return handlePossibleAxiosErrors(async () => {
13
+ const { lab_bundles_recip_item_category_id } = await getVariablesByName(headers, session, ["lab_bundles_recip_item_category_id"]);
14
+ const response = await getBundlesByItemCategoryId(session, lab_bundles_recip_item_category_id);
15
+ if (response.error) {
16
+ throw new Error(`Ocurrió un error al consultar los paquetes por categoría de laboratorio: ${response.userMsg}`);
17
+ }
18
+ return response?.data ?? [];
19
+ });
20
+ };
21
+ /**
22
+ *
23
+ * @param headers
24
+ * @param session
25
+ * @returns
26
+ */
27
+ export const getBundlesByLabCategory = async (headers, session) => {
28
+ return handlePossibleAxiosErrors(async () => {
29
+ const { lab_bundles_item_category_id } = await getVariablesByName(headers, session, ["lab_bundles_item_category_id"]);
30
+ const response = await getBundlesByItemCategoryId(session, lab_bundles_item_category_id);
31
+ if (response.error) {
32
+ throw new Error(`Ocurrió un error al consultar los paquetes por categoría de laboratorio: ${response.userMsg}`);
33
+ }
34
+ return response?.data ?? [];
35
+ });
36
+ };
37
+ /**
38
+ * createNewLabPaquete
39
+ * @param headers
40
+ * @param session
41
+ * @returns
42
+ */
43
+ export const createNewLabPaquete = async (headers, session, body) => {
44
+ return handlePossibleAxiosErrors(async () => {
45
+ let msg = "";
46
+ const { lab_bundles_item_category_id } = await getVariablesByName(headers, session, ["lab_bundles_item_category_id"]);
47
+ const sendBody = {
48
+ ...body,
49
+ bundle_details: body?.bundle_details?.map((x) => {
50
+ x._destroy = false;
51
+ return x;
52
+ }),
53
+ item_category_id: Number(lab_bundles_item_category_id),
54
+ force_as_service_for_document_external_storage_service: true,
55
+ };
56
+ const bundleResponse = await createBundle(headers, sendBody);
57
+ if (bundleResponse.error) {
58
+ msg = `Ocurrió un error al intentar crear el paquete: ${bundleResponse.userMsg}`;
59
+ console.error(msg);
60
+ throw new Error(msg);
61
+ }
62
+ return true;
63
+ });
64
+ };
65
+ /**
66
+ * createNewLabEnsayo
67
+ * @param headers
68
+ * @param session
69
+ * @returns
70
+ */
71
+ export const createNewLabEnsayo = async (headers, session, body) => {
72
+ return handlePossibleAxiosErrors(async () => {
73
+ let msg = "";
74
+ const { lab_bundles_recip_item_category_id, lab_services_item_category_id, } = await getVariablesByName(headers, session, [
75
+ "lab_bundles_recip_item_category_id",
76
+ "lab_services_item_category_id",
77
+ ]);
78
+ //PASO 1
79
+ //Creamos el bundle -> Paquete, donde va la receta
80
+ const sendBody = {
81
+ ...body,
82
+ item_category_id: Number(lab_bundles_recip_item_category_id),
83
+ name: `${LAB_BUNDLE_NAME}${body.name}`,
84
+ };
85
+ const bundleResponse = await createBundle(headers, sendBody);
86
+ if (bundleResponse.error) {
87
+ msg = `Ocurrió un error al intentar crear el paquete: ${bundleResponse.userMsg}`;
88
+ console.error(msg);
89
+ throw new Error(msg);
90
+ }
91
+ console.log("-------------- BUNDLE CREADO ! ---------------");
92
+ //PASO 2
93
+ //Creamos el item
94
+ const itemSendBody = {
95
+ name: `LAB_SERVICE_${bundleResponse?.data?.id}; ${body.name}`,
96
+ code: `LAB_SERVICE_${bundleResponse?.data?.id}`,
97
+ stockable: false, //Esto lo vuelve servicio
98
+ purchasable: false,
99
+ sellable: true,
100
+ pays_vat: true,
101
+ item_category_id: Number(lab_services_item_category_id),
102
+ description: `Item creado desde la webapp de laboratorio, para representar el servicio del ensayo creado. Ensayo: ${bundleResponse?.data?.id}`,
103
+ };
104
+ const itemResponse = await createNewLaboratoryItem(headers, itemSendBody);
105
+ if (itemResponse.error) {
106
+ msg = `Ocurrió un error al intentar crear el item asociado al paquete: ${itemResponse.userMsg}`;
107
+ console.error(msg);
108
+ throw new Error(msg);
109
+ }
110
+ console.log("-------------- ITEM CREADO ! ---------------");
111
+ //PASO 3
112
+ //Creo el formulario
113
+ const formSendBody = {
114
+ active: true,
115
+ name: `LAB_FORM_${itemResponse?.data?.id}; ${body.name}`,
116
+ 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}`,
117
+ document_type: "invoice",
118
+ settings_form_fields: [
119
+ {
120
+ position: 1,
121
+ name: "Pregunta 1",
122
+ field_type: "text",
123
+ default_value: "",
124
+ print_var_name: "pregunta_1",
125
+ },
126
+ ],
127
+ };
128
+ const formResponse = await createForm(headers, formSendBody);
129
+ if (formResponse.error) {
130
+ msg = `Ocurrió un error al intentar crear el formulario asociado al paquete: ${formResponse.userMsg}`;
131
+ console.error(msg);
132
+ throw new Error(msg);
133
+ }
134
+ console.log("-------------- FORM CREADO ! ---------------");
135
+ return true;
136
+ });
137
+ };
138
+ /**
139
+ * deleteLabBundle
140
+ * @param headers
141
+ * @param session
142
+ * @param bundle
143
+ * @returns
144
+ */
145
+ export const deleteLabBundle = async (headers, session, bundle) => {
146
+ return handlePossibleAxiosErrors(async () => {
147
+ await deleteBundle(headers, bundle.id);
148
+ //busco el item-servicio para eliminarlo
149
+ const responseItem = await getItemByName(session, `LAB_SERVICE_${bundle.id}; ${bundle.name}`);
150
+ if (responseItem.data && !responseItem.error) {
151
+ await deleteItem(headers, responseItem.data.id);
152
+ }
153
+ //busco el formulario para eliminarlo
154
+ const responseForm = await getFormByName(session, `LAB_FORM_${bundle.id}; ${bundle.name}`);
155
+ if (responseForm.data && !responseForm.error) {
156
+ await deleteForm(headers, responseForm.data.id);
157
+ }
158
+ return true;
159
+ });
160
+ };
@@ -0,0 +1,9 @@
1
+ import type { Session } from "@remix-run/node";
2
+ import { AxiosUtilsResponse, CaseGraphQL } from "@zauru-sdk/types";
3
+ /**
4
+ *
5
+ * @param headers
6
+ * @param session
7
+ * @returns
8
+ */
9
+ export declare const getMyCases: (session: Session, wheres?: string[]) => Promise<AxiosUtilsResponse<CaseGraphQL[]>>;
@@ -0,0 +1,17 @@
1
+ import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
2
+ import { getCasesByResponsibleId } from "@zauru-sdk/services";
3
+ /**
4
+ *
5
+ * @param headers
6
+ * @param session
7
+ * @returns
8
+ */
9
+ export const getMyCases = async (session, wheres = []) => {
10
+ return handlePossibleAxiosErrors(async () => {
11
+ const response = await getCasesByResponsibleId(session, session.get("employee_id"), wheres);
12
+ if (response.error) {
13
+ throw new Error(`Ocurrió un error al consultar los casos asignados a este usuario: ${response.userMsg}`);
14
+ }
15
+ return response?.data ?? [];
16
+ });
17
+ };
@@ -0,0 +1,24 @@
1
+ import type { Session } from "@remix-run/node";
2
+ import { AxiosUtilsResponse, WebAppRowGraphQL, ConsolidatedHistory, WebAppTableUpdateResponse } from "@zauru-sdk/types";
3
+ /**
4
+ * Get getConsolidatedHistories from the web app table.
5
+ * @param headers Request headers.
6
+ * @param session Session object.
7
+ * @returns A Promise of AxiosUtilsResponse<ConsolidatedHistory[]>.
8
+ */
9
+ export declare function getConsolidatedHistories(headers: any, session: Session): Promise<AxiosUtilsResponse<WebAppRowGraphQL<ConsolidatedHistory>[]>>;
10
+ /**
11
+ * Create a template in the web app table.
12
+ * @param headers Request headers.
13
+ * @param session Session object.
14
+ * @param body ConsolidatedHistory data to be created.
15
+ * @returns A Promise of AxiosUtilsResponse<ConsolidatedHistory>.
16
+ */
17
+ export declare function createConsolidatedHistory(headers: any, session: Session, body: ConsolidatedHistory): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>>;
18
+ /**
19
+ * Put updateConsolidatedHistory from the web app table.
20
+ * @param headers Request headers.
21
+ * @param session Session object.
22
+ * @returns A Promise of AxiosUtilsResponse<ConsolidatedHistory[]>.
23
+ */
24
+ export declare function updateConsolidatedHistory(headers: any, session: Session, body: ConsolidatedHistory, id_registro: string | number): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>>;
@@ -0,0 +1,52 @@
1
+ import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
2
+ import { createWebAppTableRegister, getVariablesByName, getWebAppTableRegisters, updateWebAppTableRegister, } from "@zauru-sdk/services";
3
+ /**
4
+ * Get getConsolidatedHistories from the web app table.
5
+ * @param headers Request headers.
6
+ * @param session Session object.
7
+ * @returns A Promise of AxiosUtilsResponse<ConsolidatedHistory[]>.
8
+ */
9
+ export async function getConsolidatedHistories(headers, session) {
10
+ return handlePossibleAxiosErrors(async () => {
11
+ const { purchase_order_consolidates_web_app_table_id } = await getVariablesByName(headers, session, [
12
+ "purchase_order_consolidates_web_app_table_id",
13
+ ]);
14
+ const response = await getWebAppTableRegisters(session, purchase_order_consolidates_web_app_table_id);
15
+ if (response.error) {
16
+ throw new Error(`Ocurrió un error al consultar el historial de consolidados: ${response.userMsg}`);
17
+ }
18
+ const history = response?.data ?? [];
19
+ return history;
20
+ });
21
+ }
22
+ /**
23
+ * Create a template in the web app table.
24
+ * @param headers Request headers.
25
+ * @param session Session object.
26
+ * @param body ConsolidatedHistory data to be created.
27
+ * @returns A Promise of AxiosUtilsResponse<ConsolidatedHistory>.
28
+ */
29
+ export async function createConsolidatedHistory(headers, session, body) {
30
+ return handlePossibleAxiosErrors(async () => {
31
+ const { purchase_order_consolidates_web_app_table_id } = await getVariablesByName(headers, session, [
32
+ "purchase_order_consolidates_web_app_table_id",
33
+ ]);
34
+ const response = await createWebAppTableRegister(headers, purchase_order_consolidates_web_app_table_id, body);
35
+ return response;
36
+ });
37
+ }
38
+ /**
39
+ * Put updateConsolidatedHistory from the web app table.
40
+ * @param headers Request headers.
41
+ * @param session Session object.
42
+ * @returns A Promise of AxiosUtilsResponse<ConsolidatedHistory[]>.
43
+ */
44
+ export async function updateConsolidatedHistory(headers, session, body, id_registro) {
45
+ return handlePossibleAxiosErrors(async () => {
46
+ const { purchase_order_consolidates_web_app_table_id } = await getVariablesByName(headers, session, [
47
+ "purchase_order_consolidates_web_app_table_id",
48
+ ]);
49
+ const response = await updateWebAppTableRegister(headers, purchase_order_consolidates_web_app_table_id, id_registro, { ...body });
50
+ return response;
51
+ });
52
+ }
@@ -0,0 +1,87 @@
1
+ import type { Session } from "@remix-run/node";
2
+ import { SpecialItem, WebAppRowGraphQL, RowDataType, AxiosUtilsResponse, PurchaseOrderCosto, BitacoraCostosItems, WebAppTableUpdateResponse } from "@zauru-sdk/types";
3
+ /**
4
+ *
5
+ * @param headers
6
+ * @param session
7
+ * @param configuration
8
+ * @param specialItems
9
+ */
10
+ export declare const guardarConfiguracionProductosEspeciales: (headers: any, session: Session, configuration: (RowDataType & SpecialItem)[], specialItems?: WebAppRowGraphQL<SpecialItem>[]) => Promise<AxiosUtilsResponse<boolean>>;
11
+ /**
12
+ *
13
+ * @returns
14
+ */
15
+ export declare const obtenerSemanaAnterior: () => {
16
+ fechaInicio: string;
17
+ fechaFin: string;
18
+ label: string;
19
+ getDay: (dayIndex: number) => string;
20
+ };
21
+ /**
22
+ * updateOneItemPrice
23
+ * @param headers
24
+ * @param session
25
+ * @param body
26
+ * @returns
27
+ */
28
+ export declare function updateOneItemPrice(headers: any, session: Session, body: {
29
+ fechaInicio: string;
30
+ fechaFin: string;
31
+ item: number;
32
+ price: number;
33
+ }): Promise<AxiosUtilsResponse<any>>;
34
+ /**
35
+ * changePricesInit
36
+ * @param headers
37
+ * @param session
38
+ * @param specialItems
39
+ * @param body
40
+ * @returns
41
+ */
42
+ export declare function changePricesInit(headers: any, session: Session, specialItems: WebAppRowGraphQL<SpecialItem>[], body: BitacoraCostosItems): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>>;
43
+ /**
44
+ * changePrice
45
+ * @param headers
46
+ * @param session
47
+ * @param body
48
+ * @returns
49
+ */
50
+ export declare function changePrice(headers: any, costo: PurchaseOrderCosto): Promise<PurchaseOrderCosto>;
51
+ /**
52
+ * changePrices
53
+ * @param headers
54
+ * @param session
55
+ * @param body
56
+ * @returns
57
+ */
58
+ export declare function changePrices(headers: any, session: Session, bitacora: BitacoraCostosItems, id_bitacora: string): Promise<AxiosUtilsResponse<any>>;
59
+ /**
60
+ * corregirCostos
61
+ * @param headers
62
+ * @param session
63
+ * @param costos
64
+ * @returns
65
+ */
66
+ export declare function corregirCostos(headers: any, session: Session, costos: PurchaseOrderCosto[], costosEspeciales: PurchaseOrderCosto[]): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>>;
67
+ /**
68
+ * Get saveBitacoraCostos from the web app table.
69
+ * @param headers Request headers.
70
+ * @param session Session object.
71
+ * @returns A Promise of AxiosUtilsResponse<WebAppRowGraphQL<BitacoraCostosItems>[]>.
72
+ */
73
+ export declare function saveBitacoraCostos(headers: any, session: Session, body: BitacoraCostosItems): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>>;
74
+ /**
75
+ * Put updateBitacoraCostos from the web app table.
76
+ * @param headers Request headers.
77
+ * @param session Session object.
78
+ * @returns A Promise of AxiosUtilsResponse<WebAppRowGraphQL<BitacoraCostosItems>[]>.
79
+ */
80
+ export declare function updateBitacoraCostos(headers: any, session: Session, body: BitacoraCostosItems, id_registro: string | number): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>>;
81
+ /**
82
+ * Get getCostosBitacora from the web app table.
83
+ * @param headers Request headers.
84
+ * @param session Session object.
85
+ * @returns A Promise of AxiosUtilsResponse<WebAppRowGraphQL<BitacoraCostosItems>[]>.
86
+ */
87
+ export declare function getCostosBitacora(headers: any, session: Session): Promise<AxiosUtilsResponse<WebAppRowGraphQL<BitacoraCostosItems>[]>>;