@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
@@ -1,213 +0,0 @@
1
- import type { Session } from "@remix-run/node";
2
- import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
3
- import {
4
- createPayee,
5
- createPayeeCategory,
6
- createPriceList,
7
- deletePayeeCategory,
8
- deletePriceList,
9
- getPayeeCategoriesByNotesMatch,
10
- getPaymentTermById,
11
- getVariablesByName,
12
- updatePayeeCategory,
13
- updatePaymentTerm,
14
- } from "@zauru-sdk/services";
15
- import {
16
- AxiosUtilsResponse,
17
- CreatePriceListBody,
18
- PayeeCategoryGraphQL,
19
- PayeeGraphQL,
20
- } from "@zauru-sdk/types";
21
-
22
- export const TEXT_PAYEE_CATEGORY_NOTES_FOR_PRICE =
23
- "CATEGORIA_QUE_REPRESENTA_UN_PRECIO_DE_LABORATORIO (No borrar esto): ";
24
-
25
- export const TEXT_PAYEE_CATEGORY_NAME_FOR_PRICE = "CAT-LABORATORIO: ";
26
-
27
- /**
28
- * getClientesLaboratorio
29
- * @param session
30
- * @param headers
31
- * @returns
32
- */
33
- export const getClientesLaboratorio = (
34
- session: Session
35
- ): Promise<AxiosUtilsResponse<PayeeGraphQL[]>> => {
36
- return handlePossibleAxiosErrors(async () => {
37
- const clientesResponse = await getPayeeCategoriesByNotesMatch(
38
- session,
39
- TEXT_PAYEE_CATEGORY_NOTES_FOR_PRICE
40
- );
41
-
42
- if (clientesResponse.error || !clientesResponse.data) {
43
- throw new Error(clientesResponse.userMsg);
44
- }
45
-
46
- const clientes: PayeeGraphQL[] = [];
47
- clientesResponse.data.forEach((x) => clientes.push(...x.payees));
48
-
49
- return clientes;
50
- });
51
- };
52
-
53
- /**
54
- * createNewLaboratoryClient
55
- * @param session
56
- * @param headers
57
- * @param body
58
- * @returns
59
- */
60
- export const createNewLaboratoryClient = (
61
- headers: any,
62
- body: Partial<PayeeGraphQL>
63
- ): Promise<AxiosUtilsResponse<boolean>> => {
64
- return handlePossibleAxiosErrors(async () => {
65
- const sendBody = {
66
- ...body,
67
- vendor: false,
68
- currency_id: 1,
69
- buyer: true,
70
- service_provider: true,
71
- } as PayeeGraphQL;
72
-
73
- const createResponse = await createPayee(headers, sendBody);
74
-
75
- if (!createResponse.data) {
76
- throw new Error(
77
- `Ocurrió un error al intentar crear el cliente: ${createResponse.userMsg}`
78
- );
79
- }
80
-
81
- return true;
82
- });
83
- };
84
-
85
- /**
86
- * createNewLaboratoryClientCategoryPrice
87
- * @param session
88
- * @param headers
89
- * @param body
90
- * @returns
91
- */
92
- export const updateLaboratoryClientCategoryPrice = (
93
- headers: any,
94
- body: Partial<PayeeCategoryGraphQL>
95
- ): Promise<AxiosUtilsResponse<boolean>> => {
96
- return handlePossibleAxiosErrors(async () => {
97
- const sendBody: Partial<PayeeCategoryGraphQL> = {
98
- ...body,
99
- name: `${TEXT_PAYEE_CATEGORY_NAME_FOR_PRICE}${body.name ?? ""}`,
100
- notes: `${TEXT_PAYEE_CATEGORY_NOTES_FOR_PRICE}${body.notes ?? ""}`,
101
- };
102
-
103
- const createResponse = await updatePayeeCategory(headers, sendBody);
104
-
105
- if (!createResponse.data || createResponse.error) {
106
- throw new Error(
107
- `Ocurrió un error al intentar editar la categoría de cliente: ${createResponse.userMsg}`
108
- );
109
- }
110
-
111
- return true;
112
- });
113
- };
114
-
115
- /**
116
- * createNewLaboratoryClientCategoryPrice
117
- * @param session
118
- * @param headers
119
- * @param body
120
- * @returns
121
- */
122
- export const createNewLaboratoryClientCategoryPrice = (
123
- headers: any,
124
- session: Session,
125
- body: Partial<PayeeCategoryGraphQL>
126
- ): Promise<AxiosUtilsResponse<boolean>> => {
127
- return handlePossibleAxiosErrors(async () => {
128
- const sendBody: Partial<PayeeCategoryGraphQL> = {
129
- ...body,
130
- name: `${TEXT_PAYEE_CATEGORY_NAME_FOR_PRICE}${body.name ?? ""}`,
131
- notes: `${TEXT_PAYEE_CATEGORY_NOTES_FOR_PRICE}${body.notes ?? ""}`,
132
- };
133
-
134
- const createResponse = await createPayeeCategory(headers, sendBody);
135
-
136
- if (!createResponse.data || createResponse.error) {
137
- throw new Error(
138
- `Ocurrió un error al intentar crear la categoría de cliente: ${createResponse.userMsg}`
139
- );
140
- }
141
-
142
- //Luego creo el listado de precios también
143
- const sendBodyPriceList: CreatePriceListBody = {
144
- client_exclusive: true,
145
- name: `PRECIO_LABORATORIO: ${body.name}`,
146
- description: `Listado de precio asociado a la categoría de cliente: ${body.name} id: ${createResponse.data?.id}`,
147
- payee_category_ids: [createResponse.data.id?.toString()],
148
- };
149
-
150
- const createPriceResponse = await createPriceList(
151
- headers,
152
- sendBodyPriceList
153
- );
154
-
155
- if (!createPriceResponse.data || createPriceResponse.error) {
156
- throw new Error(
157
- `Ocurrió un error al intentar crear el listado de precio: ${createPriceResponse.userMsg}`
158
- );
159
- }
160
-
161
- //Por último, asigno la categoría de empleados al término de pago de laboratorio
162
- const { lab_payment_term_default_id } = await getVariablesByName(
163
- headers,
164
- session,
165
- ["lab_payment_term_default_id"]
166
- );
167
- const paymentTermResponse = await getPaymentTermById(
168
- session,
169
- lab_payment_term_default_id
170
- );
171
- if (!paymentTermResponse.data || paymentTermResponse.error) {
172
- throw new Error(
173
- `Ocurrió un error al intentar encontrar el término de pago: ${paymentTermResponse.userMsg}`
174
- );
175
- }
176
-
177
- const updatePaymentTermResponse = await updatePaymentTerm(headers, {
178
- id: Number(lab_payment_term_default_id),
179
- payee_category_ids: [
180
- ...paymentTermResponse?.data?.allowed_payment_terms?.map((x) =>
181
- x.payee_category_id.toString()
182
- ),
183
- createResponse.data.id?.toString(),
184
- ],
185
- });
186
-
187
- if (!updatePaymentTermResponse.data || updatePaymentTermResponse.error) {
188
- throw new Error(
189
- `Ocurrió un error al intentar actualizar el término de pago: ${updatePaymentTermResponse.userMsg}`
190
- );
191
- }
192
- return true;
193
- });
194
- };
195
-
196
- /**
197
- * deleteLaboratoryClientCategoryPrice
198
- * @param headers
199
- * @param body
200
- * @returns
201
- */
202
- export const deleteLaboratoryClientCategoryPrice = (
203
- headers: any,
204
- body: Partial<PayeeCategoryGraphQL>
205
- ): Promise<AxiosUtilsResponse<boolean>> => {
206
- return handlePossibleAxiosErrors(async () => {
207
- //Elimino la categoría
208
- await deletePayeeCategory(headers, body.id ?? "");
209
- //Elimino la lista de precios
210
- await deletePriceList(headers, body.price_list_id ?? "");
211
- return true;
212
- });
213
- };
@@ -1,44 +0,0 @@
1
- import { ProfileResponse, SelectFieldOption } from "@zauru-sdk/types";
2
-
3
- /**
4
- *
5
- * @param profileInfoObject
6
- * @returns
7
- */
8
- export function getInitialProfileInfo(profileInfoObject?: ProfileResponse) {
9
- if (!Object.keys(profileInfoObject ?? {}).length || !profileInfoObject) {
10
- return {
11
- profileLabelInfo: [
12
- { label: "Nombre", value: "Cargando..." },
13
- { label: "E Mail", value: "Cargando..." },
14
- ] as SelectFieldOption[],
15
- membershipsInfo: [
16
- {
17
- entity: "Cargando...",
18
- contractExpiration: "Cargando...",
19
- nextPay: "Cargando...",
20
- entityId: 0,
21
- },
22
- ],
23
- };
24
- }
25
-
26
- const profile = profileInfoObject.profile;
27
- const profileLabelInfo = [
28
- { label: "Nombre", value: profile.name },
29
- { label: "E Mail", value: profile.email },
30
- ] as SelectFieldOption[];
31
-
32
- const membershipsInfo = profileInfoObject.memberships.map(
33
- (membership: any) => {
34
- return {
35
- entity: membership.entity.name,
36
- contractExpiration: membership.eternal ? "NUNCA" : "EXPIRA",
37
- nextPay: new Date(Date.parse(membership.expires)).toLocaleDateString(),
38
- entityId: membership.entity_id,
39
- };
40
- }
41
- );
42
-
43
- return { profileLabelInfo, membershipsInfo };
44
- }
@@ -1,67 +0,0 @@
1
- import type { Session } from "@remix-run/node";
2
- import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
3
- import {
4
- getPurchasesListDataTables,
5
- getVariablesByName,
6
- } from "@zauru-sdk/services";
7
- import {
8
- AxiosUtilsResponse,
9
- BasicIdNameSchema,
10
- DataTablesFilterBody,
11
- } from "@zauru-sdk/types";
12
-
13
- /**
14
- * getProvidersList
15
- * @param headers
16
- * @param session
17
- * @param byReceptions
18
- * @returns
19
- */
20
- export const getProvidersList = async (
21
- headers: any,
22
- session: Session,
23
- byReceptions: boolean = true
24
- ): Promise<
25
- AxiosUtilsResponse<{
26
- vendors: BasicIdNameSchema[];
27
- vendors_categories: BasicIdNameSchema[];
28
- }>
29
- > => {
30
- return handlePossibleAxiosErrors(async () => {
31
- let tag_id = undefined;
32
- if (byReceptions) {
33
- const { recepciones_tag_id } = await getVariablesByName(
34
- headers,
35
- session,
36
- ["recepciones_tag_id"]
37
- );
38
- tag_id = recepciones_tag_id;
39
- }
40
-
41
- //Obtengo los proveedores, que vienen en el endpoint de órdenes de compra
42
- const body: DataTablesFilterBody = {
43
- order: { "0": { column: "1", dir: "desc" } },
44
- start: 0,
45
- length: 1,
46
- search: { value: "", regex: false },
47
- tag: tag_id,
48
- agency: session.get("agency_id") ?? "",
49
- };
50
-
51
- //Voy por las ordenes y las ordeno por fecha de recepción
52
- const ordersDataTablesResponse = await getPurchasesListDataTables(
53
- headers,
54
- body
55
- );
56
-
57
- if (ordersDataTablesResponse.error)
58
- throw new Error(ordersDataTablesResponse.userMsg);
59
-
60
- const ordersDataTables = ordersDataTablesResponse.data;
61
-
62
- return {
63
- vendors: ordersDataTables?.vendors ?? [],
64
- vendors_categories: ordersDataTables?.vendor_categories ?? [],
65
- };
66
- });
67
- };