@zauru-sdk/utils 1.0.117 → 1.0.119

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.
@@ -1,287 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getLoteDescription = exports.procesarLote = exports.getLotesFormated = void 0;
4
- const common_1 = require("@zauru-sdk/common");
5
- const services_1 = require("@zauru-sdk/services");
6
- const purchase_orders_utils_js_1 = require("./purchase-orders.utils.js");
7
- /**
8
- * Obtiene el listado de ordenes de compra, formateado especialmente para armar la tabla de edición de porcentajes de rechazo
9
- * @param headers
10
- * @param session
11
- * @returns
12
- */
13
- const getLotesFormated = async (headers, session) => {
14
- //PASO 1: Obtengo las variables, para buscar mi tag_id y mi basket_id
15
- const { recepciones_basket_item_id: basket_id, production_agency_id /**{5693: 5696} */, } = await (0, services_1.getVariablesByName)(headers, session, [
16
- "recepciones_basket_item_id",
17
- "production_agency_id",
18
- ]);
19
- const hashAgencyId = JSON.parse(production_agency_id ?? "{}");
20
- const agency_id = hashAgencyId[session.get("agency_id")];
21
- //PASO 2: Busco mis lotes
22
- if (agency_id) {
23
- return await (0, services_1.getLotesFiltered)(headers, agency_id, false, Number(basket_id));
24
- }
25
- return [];
26
- };
27
- exports.getLotesFormated = getLotesFormated;
28
- /**
29
- * procesarLote
30
- * @param headers
31
- * @param session
32
- * @param data
33
- * @param byPercent
34
- */
35
- const procesarLote = async (headers, session, data, poId) => {
36
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
37
- //=====================================================================================
38
- //=====================================================================================
39
- //PASO 1: OBTENER TODAS LAS VARIABLES QUE VAMOS A UTILIZAR EN EL FLUJO
40
- const { production_agency, operative_rejection_agency_id, recepciones_basket_item_id: basket_id, } = await (0, services_1.getVariablesByName)(headers, session, [
41
- "production_agency",
42
- "operative_rejection_agency_id",
43
- "recepciones_basket_item_id",
44
- ]);
45
- const session_agency_id = session.get("agency_id");
46
- const hashObject = JSON.parse(operative_rejection_agency_id);
47
- const op_rejection_agency_id = hashObject[session_agency_id];
48
- //PARSEO DE LA INFORMACIÓN QUE VIENE DEL SUBMIT
49
- const byPercent = data.byPercent === "true";
50
- const porcentajeRechazo = !byPercent
51
- ? (0, common_1.toFixedIfNeeded)((Number(data.lbRechazo ?? "0") /
52
- (Number(data?.lbRechazo ?? "0") + Number(data.lbBueno))) *
53
- 100)
54
- : data.porcentajeRechazo;
55
- const basket_keys = Object.keys(data).filter((x) => x.includes("basket-"));
56
- const baskets_regresadas = basket_keys.map((basket_key) => {
57
- //ejemplo de una key: basket-CONVENCIONAL-58281
58
- const splited = basket_key.split("-");
59
- return {
60
- id: splited[2] || 0,
61
- color: splited[1] || "",
62
- total: Number(data[basket_key]) || 0,
63
- };
64
- });
65
- //1.2 OBTENER LA INFORMACIÓN DEL LOTE A PROCESAR (LA TOMO DE LA QUE YA TENGO AL CARGAR LA INFO)
66
- const purchaseOrderResponse = await (0, services_1.getPurchaseOrder)(session, poId, {
67
- withLotStocksToMyAgency: true,
68
- });
69
- if (purchaseOrderResponse.error || !purchaseOrderResponse?.data) {
70
- throw new Error(`Error al intentar encontrar la órden de compra: ${purchaseOrderResponse.userMsg}`);
71
- }
72
- const purchaseOrder = purchaseOrderResponse.data;
73
- const lbsEsperadas = purchaseOrder.lots[0].lot_stocks[0].available;
74
- const lbsMalas = Number((0, common_1.toFixedIfNeeded)(lbsEsperadas * (Number(porcentajeRechazo) / 100)));
75
- const lbsBuenas = Number((0, common_1.toFixedIfNeeded)(lbsEsperadas - lbsMalas));
76
- const baskets_memo = (0, common_1.getBasketsSchema)(purchaseOrder.memo);
77
- const baskets_memo_quantity = baskets_memo
78
- .map((basket) => basket.total)
79
- .reduce(common_1.reduceAdd, 0);
80
- //SI SE INGRESA POR LIBRAS, ES QUE SE ESTÁ INGRESANDO CANASTAS A DEVOLVER ETC Y HAY QUE HACER LOS ENVÍOS CORRESPONDIENTES
81
- if (!byPercent) {
82
- console.log("=============> PROCESANDO DATA POR PESO...");
83
- //CUANDO NO ES POR PORCENTAJE DIRECTO HAY QUE HACER TODO EL FLUJO DE CREAR LOS ENVÍOS ETC...
84
- //1.3: SE CREA EL ENVÍO DE VEGETALES Y CANASTAS DEVUELTOS POR CONTROL DE CALIDAD, (LOS QUE ESTÁN BUENOS)
85
- //Las canastas vienen en data en campos como estos "basket-CONVENCIONAL-58281": "2",
86
- const bodyGoodToProduction = {
87
- booker_id: Number(session.get("employee_id")),
88
- needs_transport: false,
89
- payee_id: purchaseOrder.payee_id,
90
- memo: `${purchaseOrder.lots[0].id};${purchaseOrder.id_number};${purchaseOrder.purchase_order_details[0]?.item?.name};${purchaseOrder.purchase_order_details
91
- .map((purchase) => Number(purchase.booked_quantity))
92
- .reduce(common_1.reduceAdd, 0)};${baskets_memo_quantity};${porcentajeRechazo};${purchaseOrder.delivery_date}`,
93
- planned_delivery: `${data.date}`,
94
- agency_from_id: Number(session_agency_id), //agencia donde está loggeado mi usuario
95
- agency_to_id: purchaseOrder.agency_id, //de donde viene la orden de compra
96
- reference: "Vegetales buenos devueltos desde control de calidad.",
97
- movements: [
98
- {
99
- item_id: purchaseOrder.purchase_order_details[0].item_id,
100
- lot_id: purchaseOrder.lots[0].id,
101
- reference: "Vegetales devueltos de CC",
102
- booked_quantity: lbsBuenas,
103
- },
104
- ],
105
- };
106
- /**
107
- * Para las canastas
108
- * el item_id = 490533 = recepciones_basket_item_id
109
- * lot_id: código de la canasta,
110
- * booked_quantity = cantidad de canastas que ingresa el usuario que va a devolver
111
- */
112
- baskets_regresadas.forEach((basket) => {
113
- bodyGoodToProduction.movements.push({
114
- item_id: Number(basket_id),
115
- lot_id: basket.id,
116
- reference: `Canasta ${basket.color}-${basket.id} devuelta a CC`,
117
- booked_quantity: basket.total,
118
- });
119
- });
120
- console.log("-------- Insertando booking con canastas buenas devueltas");
121
- const goodVegetablesInserted = await (0, services_1.insertBookings)(headers, bodyGoodToProduction, `${purchaseOrder.id}`);
122
- if (!goodVegetablesInserted.error && goodVegetablesInserted.data) {
123
- //1.4 Recibir la reserva para que las cantidades se muevan correctamente a la bodega de destino
124
- console.log("recibiendo la reserva: ", goodVegetablesInserted.data?.id);
125
- await (0, services_1.getDeliveryByBooking)(headers, goodVegetablesInserted.data?.id);
126
- }
127
- if (lbsMalas && lbsMalas > 0) {
128
- //=====================================================================================
129
- //=====================================================================================
130
- //PASO 2: Envío con vegetales rechazados a bodega de PRODUCCIÓN desde la agencia del usuario loggeado
131
- const bodyOchToProduction = {
132
- booker_id: Number(session.get("employee_id")),
133
- needs_transport: false,
134
- memo: "",
135
- planned_delivery: `${data.date}`,
136
- agency_from_id: Number(session_agency_id), //agencia donde está loggeado mi usuario
137
- agency_to_id: Number(production_agency), //de donde viene la orden de compra
138
- reference: "Envío de vegetales rechazados a la bodega de producción.",
139
- movements: [
140
- {
141
- item_id: purchaseOrder.purchase_order_details[0].item_id,
142
- lot_id: purchaseOrder.lots[0].id,
143
- reference: "Vegetales rechazados de CC",
144
- booked_quantity: lbsMalas,
145
- },
146
- ],
147
- };
148
- console.log("--------- enviando a insertar booking de rechazo a la bodega de producción");
149
- const ochToProductionVegetablesInserted = await (0, services_1.insertBookings)(headers, bodyOchToProduction, `${purchaseOrder.id}`);
150
- if (!ochToProductionVegetablesInserted.error &&
151
- ochToProductionVegetablesInserted.data) {
152
- //2.1 Recibir la reserva para que las cantidades se muevan correctamente a la bodega de destino
153
- console.log("Recibiendo booking de rechazo...");
154
- await (0, services_1.getDeliveryByBooking)(headers, ochToProductionVegetablesInserted.data.id);
155
- }
156
- //=====================================================================================
157
- //=====================================================================================
158
- //PASO 3: Envío con vegetales rechazados a bodega de RECHAZO desde la bodega de PRODUCCIÓN
159
- //Sólo cambia el agency_from_id y el agency_to_id, de ahí lo demás lo mismo que PASO 2
160
- bodyOchToProduction.agency_from_id = Number(production_agency);
161
- bodyOchToProduction.agency_to_id = Number(op_rejection_agency_id);
162
- bodyOchToProduction.reference =
163
- "Envío de vegetales rechazados a la bodega de rechazo.";
164
- console.log("--------- enviando a insertar booking de rechazo a la bodega de rechazo");
165
- const ochToOchVegetablesInserted = await (0, services_1.insertBookings)(headers, bodyOchToProduction);
166
- if (!ochToOchVegetablesInserted.error &&
167
- ochToOchVegetablesInserted.data) {
168
- //3.1 Recibir la reserva para que las cantidades se muevan correctamente a la bodega de destino
169
- await (0, services_1.getDeliveryByBooking)(headers, ochToOchVegetablesInserted.data?.id);
170
- }
171
- }
172
- //=====================================================================================
173
- //=====================================================================================
174
- //PASO 5: Modificación de canastas en el lote de verdura
175
- //la misma description del detalle del lote pero modificando la cantidad de canastas que quedaron.
176
- //ejemplo: original: 27-53311-VERDE,1-53313-ROJA,1-53317-CELESTE,3-53312-AZUL,3-53314-AMARILLA
177
- //ahora: 27-53311-VERDE,1-53313-ROJA,1-53317-CELESTE,2-53312-AZUL,3-53314-AMARILLA // ahora sólo 2 azules porque no devolví una
178
- const newDescriptions = [];
179
- baskets_memo.forEach((basket) => {
180
- //Si existe una basket a regresar con el mismo id, pregunto cuantas va a regresar, para restarlas del total.
181
- const basket_regresada = baskets_regresadas.find((x) => x.id === basket.id);
182
- const resta = basket_regresada?.total ?? 0;
183
- newDescriptions.push(`${basket.total - resta}-${basket.id}-${basket.color}`);
184
- });
185
- await (0, services_1.updateLote)(headers, purchaseOrder.lots[0].id, {
186
- lot: {
187
- description: newDescriptions.join(","),
188
- },
189
- });
190
- }
191
- else {
192
- console.log("PROCESANDO DATA POR PORCENTAJE...");
193
- //CUANDO NO ES POR PORCENTAJE DIRECTO HAY QUE HACER TODO EL FLUJO DE CREAR LOS ENVÍOS ETC...
194
- //1.3: SE CREA EL ENVÍO DE VEGETALES Y CANASTAS DEVUELTOS POR CONTROL DE CALIDAD, (LOS QUE ESTÁN BUENOS)
195
- //Las canastas vienen en data en campos como estos "basket-CONVENCIONAL-58281": "2",
196
- const bodyGoodToProduction = {
197
- booker_id: Number(session.get("employee_id")),
198
- needs_transport: false,
199
- payee_id: purchaseOrder.payee_id,
200
- memo: `${purchaseOrder.lots[0].id};${purchaseOrder.lots[0].name};${purchaseOrder.purchase_order_details[0]?.item?.name};${purchaseOrder.purchase_order_details
201
- .map((detail) => Number(detail.booked_quantity))
202
- .reduce(common_1.reduceAdd, 0)};${baskets_memo_quantity};${porcentajeRechazo};${purchaseOrder.delivery_date}`,
203
- planned_delivery: `${data.date}`,
204
- agency_from_id: Number(session_agency_id), //agencia donde está loggeado mi usuario
205
- agency_to_id: purchaseOrder.agency_id, //de donde viene la orden de compra
206
- reference: "Regreando vegetales buenos desde control de calidad.",
207
- movements: [
208
- {
209
- item_id: purchaseOrder.purchase_order_details[0].item_id,
210
- lot_id: purchaseOrder.lots[0].id,
211
- reference: "Vegetales devueltos de CC",
212
- booked_quantity: lbsEsperadas, //devuelvo la misma cantidad que fue enviada
213
- },
214
- ],
215
- };
216
- /**
217
- * Para las canastas
218
- * el item_id = 490533 = recepciones_basket_item_id
219
- * lot_id: código de la canasta,
220
- * booked_quantity = cantidad de canastas que ingresa el usuario que va a devolver
221
- */
222
- //Todas las canastas que fueron enviadas originalmente
223
- baskets_memo.forEach((basket) => {
224
- bodyGoodToProduction.movements.push({
225
- item_id: Number(basket_id),
226
- lot_id: basket.id,
227
- reference: `Canasta ${basket.color}-${basket.id} devuelta a CC`,
228
- booked_quantity: basket.total,
229
- });
230
- });
231
- console.log("-------- Insertando booking con canastas buenas devueltas");
232
- const goodVegetablesInserted = await (0, services_1.insertBookings)(headers, bodyGoodToProduction, `${purchaseOrder.id}`);
233
- //1.4 Recibir la reserva para que las cantidades se muevan correctamente a la bodega de destino
234
- if (!goodVegetablesInserted.error && goodVegetablesInserted.data) {
235
- console.log("A RECIBIR BOOKING - POR PORCENTAJE");
236
- await (0, services_1.getDeliveryByBooking)(headers, goodVegetablesInserted.data.id);
237
- }
238
- }
239
- //=====================================================================================
240
- //=====================================================================================
241
- //PASO 4: Modificación de porcentaje de rechazo en la orden de compra
242
- //4.3 Editar porcentajes de rechazo
243
- const updateBodyPurchase = {
244
- purchase_order: { discount: porcentajeRechazo },
245
- };
246
- await (0, services_1.updateReceivedPurchaseOrder)(headers, updateBodyPurchase, purchaseOrder.id);
247
- //=====================================================================================
248
- //=====================================================================================
249
- //PASO 6: Guardar razones de rechazo en webapp table
250
- await (0, services_1.saveMotivosDeRechazoByPurchase)(headers, session, {
251
- Razon_primaria: `${data.razonPrincipal ?? ""}`,
252
- Razon_secundaria: `${data.razonSecundaria ?? ""}`,
253
- Razon_terciaria: `${data.razonTerciaria ?? ""}`,
254
- Canastas: `${data.ochBaskets ?? ""}`,
255
- }, {
256
- temp_purchase_order_id: `${purchaseOrder.id}`,
257
- });
258
- });
259
- };
260
- exports.procesarLote = procesarLote;
261
- /**
262
- * Obtiene toda la información de lote, con las canastas y razones de rechazo
263
- * @param headers
264
- * @param session
265
- * @returns
266
- */
267
- const getLoteDescription = async (headers, session, lote_id) => {
268
- //PASO 1: Obtengo las variables, para buscar mi basket_id
269
- const { production_agency_id /**{5693: 5696} */ } = await (0, services_1.getVariablesByName)(headers, session, ["production_agency_id"]);
270
- const hashAgencyId = JSON.parse(production_agency_id ?? "{}");
271
- const agency_id = hashAgencyId[session.get("agency_id")];
272
- //PASO 2: Busco mi lote
273
- const lote = await (0, services_1.getLote)(headers, lote_id, agency_id);
274
- //PASO 3: Obtener listado de canastas enviadas a bodega control de calidad
275
- //El primer paso es ubicar la orden de compra original, la cual permitirá ubicar el envío que se
276
- //realizó a la bodega de control de calidad
277
- const purchase_order = await (0, purchase_orders_utils_js_1.getPurchaseOrderDataTables)(headers, lote.name.replace("-RETENIDO", "") // por si trae la palabra RETENIDO,
278
- );
279
- //PASO 4: Obtener los envíos asociados a la orden de compra
280
- const purchaseResponse = await (0, services_1.getPurchase)(headers, purchase_order.no_orden);
281
- return {
282
- lote,
283
- purchase_order,
284
- purchase: purchaseResponse.data,
285
- };
286
- };
287
- exports.getLoteDescription = getLoteDescription;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.saveRechazoCanastas = exports.formatearMotivoDeRechazo = void 0;
4
- const common_1 = require("@zauru-sdk/common");
5
- const services_1 = require("@zauru-sdk/services");
6
- const formatearMotivoDeRechazo = (entity) => {
7
- return { id: entity.id, name: entity.data.Nombre };
8
- };
9
- exports.formatearMotivoDeRechazo = formatearMotivoDeRechazo;
10
- /**
11
- * Post saveBitacoraPOMassive 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
- const saveRechazoCanastas = (headers, session, body) => {
17
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
18
- const { recepciones_rejections_webapp_table_id } = await (0, services_1.getVariablesByName)(headers, session, ["recepciones_rejections_webapp_table_id"]);
19
- const response = await (0, services_1.createWebAppTableRegister)(headers, recepciones_rejections_webapp_table_id, { ...body });
20
- return response;
21
- });
22
- };
23
- exports.saveRechazoCanastas = saveRechazoCanastas;
@@ -1,136 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deleteLaboratoryClientCategoryPrice = exports.createNewLaboratoryClientCategoryPrice = exports.updateLaboratoryClientCategoryPrice = exports.createNewLaboratoryClient = exports.getClientesLaboratorio = exports.TEXT_PAYEE_CATEGORY_NAME_FOR_PRICE = exports.TEXT_PAYEE_CATEGORY_NOTES_FOR_PRICE = void 0;
4
- const common_1 = require("@zauru-sdk/common");
5
- const services_1 = require("@zauru-sdk/services");
6
- exports.TEXT_PAYEE_CATEGORY_NOTES_FOR_PRICE = "CATEGORIA_QUE_REPRESENTA_UN_PRECIO_DE_LABORATORIO (No borrar esto): ";
7
- exports.TEXT_PAYEE_CATEGORY_NAME_FOR_PRICE = "CAT-LABORATORIO: ";
8
- /**
9
- * getClientesLaboratorio
10
- * @param session
11
- * @param headers
12
- * @returns
13
- */
14
- const getClientesLaboratorio = (session) => {
15
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
16
- const clientesResponse = await (0, services_1.getPayeeCategoriesByNotesMatch)(session, exports.TEXT_PAYEE_CATEGORY_NOTES_FOR_PRICE);
17
- if (clientesResponse.error || !clientesResponse.data) {
18
- throw new Error(clientesResponse.userMsg);
19
- }
20
- const clientes = [];
21
- clientesResponse.data.forEach((x) => clientes.push(...x.payees));
22
- return clientes;
23
- });
24
- };
25
- exports.getClientesLaboratorio = getClientesLaboratorio;
26
- /**
27
- * createNewLaboratoryClient
28
- * @param session
29
- * @param headers
30
- * @param body
31
- * @returns
32
- */
33
- const createNewLaboratoryClient = (headers, body) => {
34
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
35
- const sendBody = {
36
- ...body,
37
- vendor: false,
38
- currency_id: 1,
39
- buyer: true,
40
- service_provider: true,
41
- };
42
- const createResponse = await (0, services_1.createPayee)(headers, sendBody);
43
- if (!createResponse.data) {
44
- throw new Error(`Ocurrió un error al intentar crear el cliente: ${createResponse.userMsg}`);
45
- }
46
- return true;
47
- });
48
- };
49
- exports.createNewLaboratoryClient = createNewLaboratoryClient;
50
- /**
51
- * createNewLaboratoryClientCategoryPrice
52
- * @param session
53
- * @param headers
54
- * @param body
55
- * @returns
56
- */
57
- const updateLaboratoryClientCategoryPrice = (headers, body) => {
58
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
59
- const sendBody = {
60
- ...body,
61
- name: `${exports.TEXT_PAYEE_CATEGORY_NAME_FOR_PRICE}${body.name ?? ""}`,
62
- notes: `${exports.TEXT_PAYEE_CATEGORY_NOTES_FOR_PRICE}${body.notes ?? ""}`,
63
- };
64
- const createResponse = await (0, services_1.updatePayeeCategory)(headers, sendBody);
65
- if (!createResponse.data || createResponse.error) {
66
- throw new Error(`Ocurrió un error al intentar editar la categoría de cliente: ${createResponse.userMsg}`);
67
- }
68
- return true;
69
- });
70
- };
71
- exports.updateLaboratoryClientCategoryPrice = updateLaboratoryClientCategoryPrice;
72
- /**
73
- * createNewLaboratoryClientCategoryPrice
74
- * @param session
75
- * @param headers
76
- * @param body
77
- * @returns
78
- */
79
- const createNewLaboratoryClientCategoryPrice = (headers, session, body) => {
80
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
81
- const sendBody = {
82
- ...body,
83
- name: `${exports.TEXT_PAYEE_CATEGORY_NAME_FOR_PRICE}${body.name ?? ""}`,
84
- notes: `${exports.TEXT_PAYEE_CATEGORY_NOTES_FOR_PRICE}${body.notes ?? ""}`,
85
- };
86
- const createResponse = await (0, services_1.createPayeeCategory)(headers, sendBody);
87
- if (!createResponse.data || createResponse.error) {
88
- throw new Error(`Ocurrió un error al intentar crear la categoría de cliente: ${createResponse.userMsg}`);
89
- }
90
- //Luego creo el listado de precios también
91
- const sendBodyPriceList = {
92
- client_exclusive: true,
93
- name: `PRECIO_LABORATORIO: ${body.name}`,
94
- description: `Listado de precio asociado a la categoría de cliente: ${body.name} id: ${createResponse.data?.id}`,
95
- payee_category_ids: [createResponse.data.id?.toString()],
96
- };
97
- const createPriceResponse = await (0, services_1.createPriceList)(headers, sendBodyPriceList);
98
- if (!createPriceResponse.data || createPriceResponse.error) {
99
- throw new Error(`Ocurrió un error al intentar crear el listado de precio: ${createPriceResponse.userMsg}`);
100
- }
101
- //Por último, asigno la categoría de empleados al término de pago de laboratorio
102
- const { lab_payment_term_default_id } = await (0, services_1.getVariablesByName)(headers, session, ["lab_payment_term_default_id"]);
103
- const paymentTermResponse = await (0, services_1.getPaymentTermById)(session, lab_payment_term_default_id);
104
- if (!paymentTermResponse.data || paymentTermResponse.error) {
105
- throw new Error(`Ocurrió un error al intentar encontrar el término de pago: ${paymentTermResponse.userMsg}`);
106
- }
107
- const updatePaymentTermResponse = await (0, services_1.updatePaymentTerm)(headers, {
108
- id: Number(lab_payment_term_default_id),
109
- payee_category_ids: [
110
- ...paymentTermResponse?.data?.allowed_payment_terms?.map((x) => x.payee_category_id.toString()),
111
- createResponse.data.id?.toString(),
112
- ],
113
- });
114
- if (!updatePaymentTermResponse.data || updatePaymentTermResponse.error) {
115
- throw new Error(`Ocurrió un error al intentar actualizar el término de pago: ${updatePaymentTermResponse.userMsg}`);
116
- }
117
- return true;
118
- });
119
- };
120
- exports.createNewLaboratoryClientCategoryPrice = createNewLaboratoryClientCategoryPrice;
121
- /**
122
- * deleteLaboratoryClientCategoryPrice
123
- * @param headers
124
- * @param body
125
- * @returns
126
- */
127
- const deleteLaboratoryClientCategoryPrice = (headers, body) => {
128
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
129
- //Elimino la categoría
130
- await (0, services_1.deletePayeeCategory)(headers, body.id ?? "");
131
- //Elimino la lista de precios
132
- await (0, services_1.deletePriceList)(headers, body.price_list_id ?? "");
133
- return true;
134
- });
135
- };
136
- exports.deleteLaboratoryClientCategoryPrice = deleteLaboratoryClientCategoryPrice;
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getInitialProfileInfo = void 0;
4
- /**
5
- *
6
- * @param profileInfoObject
7
- * @returns
8
- */
9
- function getInitialProfileInfo(profileInfoObject) {
10
- if (!Object.keys(profileInfoObject ?? {}).length || !profileInfoObject) {
11
- return {
12
- profileLabelInfo: [
13
- { label: "Nombre", value: "Cargando..." },
14
- { label: "E Mail", value: "Cargando..." },
15
- ],
16
- membershipsInfo: [
17
- {
18
- entity: "Cargando...",
19
- contractExpiration: "Cargando...",
20
- nextPay: "Cargando...",
21
- entityId: 0,
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
- ];
31
- const membershipsInfo = profileInfoObject.memberships.map((membership) => {
32
- return {
33
- entity: membership.entity.name,
34
- contractExpiration: membership.eternal ? "NUNCA" : "EXPIRA",
35
- nextPay: new Date(Date.parse(membership.expires)).toLocaleDateString(),
36
- entityId: membership.entity_id,
37
- };
38
- });
39
- return { profileLabelInfo, membershipsInfo };
40
- }
41
- exports.getInitialProfileInfo = getInitialProfileInfo;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getProvidersList = void 0;
4
- const common_1 = require("@zauru-sdk/common");
5
- const services_1 = require("@zauru-sdk/services");
6
- /**
7
- * getProvidersList
8
- * @param headers
9
- * @param session
10
- * @param byReceptions
11
- * @returns
12
- */
13
- const getProvidersList = async (headers, session, byReceptions = true) => {
14
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
15
- let tag_id = undefined;
16
- if (byReceptions) {
17
- const { recepciones_tag_id } = await (0, services_1.getVariablesByName)(headers, session, ["recepciones_tag_id"]);
18
- tag_id = recepciones_tag_id;
19
- }
20
- //Obtengo los proveedores, que vienen en el endpoint de órdenes de compra
21
- const body = {
22
- order: { "0": { column: "1", dir: "desc" } },
23
- start: 0,
24
- length: 1,
25
- search: { value: "", regex: false },
26
- tag: tag_id,
27
- agency: session.get("agency_id") ?? "",
28
- };
29
- //Voy por las ordenes y las ordeno por fecha de recepción
30
- const ordersDataTablesResponse = await (0, services_1.getPurchasesListDataTables)(headers, body);
31
- if (ordersDataTablesResponse.error)
32
- throw new Error(ordersDataTablesResponse.userMsg);
33
- const ordersDataTables = ordersDataTablesResponse.data;
34
- return {
35
- vendors: ordersDataTables?.vendors ?? [],
36
- vendors_categories: ordersDataTables?.vendor_categories ?? [],
37
- };
38
- });
39
- };
40
- exports.getProvidersList = getProvidersList;