@zauru-sdk/utils 1.0.68 → 1.0.71
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.
|
@@ -71,8 +71,8 @@ const procesarLote = async (headers, session, data, poId) => {
|
|
|
71
71
|
}
|
|
72
72
|
const purchaseOrder = purchaseOrderResponse.data;
|
|
73
73
|
const lbsEsperadas = purchaseOrder.lots[0].lot_stocks[0].available;
|
|
74
|
-
const lbsMalas = lbsEsperadas * (Number(porcentajeRechazo) / 100);
|
|
75
|
-
const lbsBuenas = lbsEsperadas - lbsMalas;
|
|
74
|
+
const lbsMalas = Number((0, common_1.toFixedIfNeeded)(lbsEsperadas * (Number(porcentajeRechazo) / 100)));
|
|
75
|
+
const lbsBuenas = Number((0, common_1.toFixedIfNeeded)(lbsEsperadas - lbsMalas));
|
|
76
76
|
const baskets_memo = (0, common_1.getBasketsSchema)(purchaseOrder.memo);
|
|
77
77
|
const baskets_memo_quantity = baskets_memo
|
|
78
78
|
.map((basket) => basket.total)
|
|
@@ -239,39 +239,11 @@ const procesarLote = async (headers, session, data, poId) => {
|
|
|
239
239
|
//=====================================================================================
|
|
240
240
|
//=====================================================================================
|
|
241
241
|
//PASO 4: Modificación de porcentaje de rechazo en la orden de compra
|
|
242
|
-
//4.1 El primer paso es devolver la recepción recibida en la orden de compra.
|
|
243
|
-
//Primero se debe obtener el id de dicha recepción
|
|
244
|
-
const reception = purchaseOrder.receptions[0];
|
|
245
|
-
const reception_details = reception?.reception_details[0];
|
|
246
|
-
//4.2 Habilito la orden de compra
|
|
247
|
-
await (0, services_1.enablePurchase)(headers, purchaseOrder.id, reception?.id);
|
|
248
242
|
//4.3 Editar porcentajes de rechazo
|
|
249
243
|
const updateBodyPurchase = {
|
|
250
244
|
purchase_order: { discount: porcentajeRechazo },
|
|
251
245
|
};
|
|
252
|
-
await (0, services_1.
|
|
253
|
-
//4.4 Crear una nueva recepcion
|
|
254
|
-
const bodyReception = {
|
|
255
|
-
reception: {
|
|
256
|
-
agency_id: reception.agency_id,
|
|
257
|
-
entity_id: reception.entity_id,
|
|
258
|
-
needs_transit: false,
|
|
259
|
-
purchase_order_id: purchaseOrder.id,
|
|
260
|
-
received_at: new Date(Date.now() + 12096e5).toISOString().split("T")[0],
|
|
261
|
-
invoice_number: `${reception.invoice_number ?? ""}`,
|
|
262
|
-
reception_details_attributes: {
|
|
263
|
-
"0": {
|
|
264
|
-
item_id: `${reception_details?.item_id}`,
|
|
265
|
-
lot_delivered_quantity: [reception_details?.lot_delivered_quantity],
|
|
266
|
-
lot_description: [reception_details?.lot_description],
|
|
267
|
-
lot_expire: [reception_details?.lot_expire],
|
|
268
|
-
lot_name: [reception_details?.lot_name],
|
|
269
|
-
purchase_order_detail_id: `${reception_details?.purchase_order_detail_id}`,
|
|
270
|
-
},
|
|
271
|
-
},
|
|
272
|
-
},
|
|
273
|
-
};
|
|
274
|
-
await (0, services_1.createNewReception)(headers, bodyReception, purchaseOrder.id);
|
|
246
|
+
await (0, services_1.updateReceivedPurchaseOrder)(headers, updateBodyPurchase, purchaseOrder.id);
|
|
275
247
|
//=====================================================================================
|
|
276
248
|
//=====================================================================================
|
|
277
249
|
//PASO 6: Guardar razones de rechazo en webapp table
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createNewLabItemRequest = exports.deleteTask = exports.commitEndTask = exports.commitTask = exports.deletePurchaseOrderProcess = exports.getOrderIDS = exports.
|
|
3
|
+
exports.createNewLabItemRequest = exports.deleteTask = exports.commitEndTask = exports.commitTask = exports.deletePurchaseOrderProcess = exports.getOrderIDS = exports.updateOchAndDis = exports.updatePurchaseItemPrice = exports.getPurchaseOrderDataTables = exports.getPurchasesDataTableListFormated = void 0;
|
|
4
4
|
const common_1 = require("@zauru-sdk/common");
|
|
5
5
|
const services_1 = require("@zauru-sdk/services");
|
|
6
6
|
/**
|
|
@@ -198,26 +198,6 @@ const updateOchAndDis = async (headers, data, purchase_id) => {
|
|
|
198
198
|
});
|
|
199
199
|
};
|
|
200
200
|
exports.updateOchAndDis = updateOchAndDis;
|
|
201
|
-
/**
|
|
202
|
-
* updatePurchaseOrderReception
|
|
203
|
-
* @param headers
|
|
204
|
-
* @param data
|
|
205
|
-
* @param purchase_id
|
|
206
|
-
* @returns
|
|
207
|
-
*/
|
|
208
|
-
const updatePurchaseOrderReception = async (headers, data, purchase_id) => {
|
|
209
|
-
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
210
|
-
const body = {
|
|
211
|
-
purchase_order: {
|
|
212
|
-
payee_id: data.payee_id,
|
|
213
|
-
purchase_order_details_attributes: data.purchase_order_details_attributes,
|
|
214
|
-
},
|
|
215
|
-
};
|
|
216
|
-
await (0, services_1.updateReceivedPurchaseOrder)(headers, body, purchase_id);
|
|
217
|
-
return true;
|
|
218
|
-
});
|
|
219
|
-
};
|
|
220
|
-
exports.updatePurchaseOrderReception = updatePurchaseOrderReception;
|
|
221
201
|
/**
|
|
222
202
|
* Obtengo los id's de las órdenes de compra en un arreglo numérico
|
|
223
203
|
* @param headers
|
|
@@ -360,6 +340,7 @@ const createNewLabItemRequest = (headers, session, body) => {
|
|
|
360
340
|
"laboratory_proyect_id",
|
|
361
341
|
]);
|
|
362
342
|
const id_number = (0, services_1.generateDistinctCode)("POLAB");
|
|
343
|
+
const insumos = JSON.parse(body.insumos);
|
|
363
344
|
const sendBody = {
|
|
364
345
|
...body,
|
|
365
346
|
shipping_date: body.issue_date,
|
|
@@ -372,14 +353,14 @@ const createNewLabItemRequest = (headers, session, body) => {
|
|
|
372
353
|
id_number,
|
|
373
354
|
reference: "LABORATORIO - Solicitud de insumos desde WebApp",
|
|
374
355
|
origin: "LABORATORIO",
|
|
375
|
-
purchase_order_details:
|
|
376
|
-
{
|
|
377
|
-
booked_quantity:
|
|
378
|
-
item_id:
|
|
356
|
+
purchase_order_details: insumos.map((x) => {
|
|
357
|
+
return {
|
|
358
|
+
booked_quantity: x.booked_quantity,
|
|
359
|
+
item_id: x.item_id,
|
|
379
360
|
unit_cost: 1,
|
|
380
361
|
tag_id: Number(laboratory_proyect_id),
|
|
381
|
-
}
|
|
382
|
-
|
|
362
|
+
};
|
|
363
|
+
}),
|
|
383
364
|
taggings: [{ tag_id: Number(laboratory_proyect_id) }],
|
|
384
365
|
};
|
|
385
366
|
const response = await (0, services_1.createNewPurchaseOrder)(headers, sendBody);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getBasketsSchema, handlePossibleAxiosErrors, reduceAdd, toFixedIfNeeded, } from "@zauru-sdk/common";
|
|
2
|
-
import {
|
|
2
|
+
import { getDeliveryByBooking, getLote, getLotesFiltered, getPurchase, getPurchaseOrder, getVariablesByName, insertBookings, saveMotivosDeRechazoByPurchase, updateLote, updateReceivedPurchaseOrder, } from "@zauru-sdk/services";
|
|
3
3
|
import { getPurchaseOrderDataTables } from "./purchase-orders.utils.js";
|
|
4
4
|
/**
|
|
5
5
|
* Obtiene el listado de ordenes de compra, formateado especialmente para armar la tabla de edición de porcentajes de rechazo
|
|
@@ -67,8 +67,8 @@ export const procesarLote = async (headers, session, data, poId) => {
|
|
|
67
67
|
}
|
|
68
68
|
const purchaseOrder = purchaseOrderResponse.data;
|
|
69
69
|
const lbsEsperadas = purchaseOrder.lots[0].lot_stocks[0].available;
|
|
70
|
-
const lbsMalas = lbsEsperadas * (Number(porcentajeRechazo) / 100);
|
|
71
|
-
const lbsBuenas = lbsEsperadas - lbsMalas;
|
|
70
|
+
const lbsMalas = Number(toFixedIfNeeded(lbsEsperadas * (Number(porcentajeRechazo) / 100)));
|
|
71
|
+
const lbsBuenas = Number(toFixedIfNeeded(lbsEsperadas - lbsMalas));
|
|
72
72
|
const baskets_memo = getBasketsSchema(purchaseOrder.memo);
|
|
73
73
|
const baskets_memo_quantity = baskets_memo
|
|
74
74
|
.map((basket) => basket.total)
|
|
@@ -235,39 +235,11 @@ export const procesarLote = async (headers, session, data, poId) => {
|
|
|
235
235
|
//=====================================================================================
|
|
236
236
|
//=====================================================================================
|
|
237
237
|
//PASO 4: Modificación de porcentaje de rechazo en la orden de compra
|
|
238
|
-
//4.1 El primer paso es devolver la recepción recibida en la orden de compra.
|
|
239
|
-
//Primero se debe obtener el id de dicha recepción
|
|
240
|
-
const reception = purchaseOrder.receptions[0];
|
|
241
|
-
const reception_details = reception?.reception_details[0];
|
|
242
|
-
//4.2 Habilito la orden de compra
|
|
243
|
-
await enablePurchase(headers, purchaseOrder.id, reception?.id);
|
|
244
238
|
//4.3 Editar porcentajes de rechazo
|
|
245
239
|
const updateBodyPurchase = {
|
|
246
240
|
purchase_order: { discount: porcentajeRechazo },
|
|
247
241
|
};
|
|
248
|
-
await
|
|
249
|
-
//4.4 Crear una nueva recepcion
|
|
250
|
-
const bodyReception = {
|
|
251
|
-
reception: {
|
|
252
|
-
agency_id: reception.agency_id,
|
|
253
|
-
entity_id: reception.entity_id,
|
|
254
|
-
needs_transit: false,
|
|
255
|
-
purchase_order_id: purchaseOrder.id,
|
|
256
|
-
received_at: new Date(Date.now() + 12096e5).toISOString().split("T")[0],
|
|
257
|
-
invoice_number: `${reception.invoice_number ?? ""}`,
|
|
258
|
-
reception_details_attributes: {
|
|
259
|
-
"0": {
|
|
260
|
-
item_id: `${reception_details?.item_id}`,
|
|
261
|
-
lot_delivered_quantity: [reception_details?.lot_delivered_quantity],
|
|
262
|
-
lot_description: [reception_details?.lot_description],
|
|
263
|
-
lot_expire: [reception_details?.lot_expire],
|
|
264
|
-
lot_name: [reception_details?.lot_name],
|
|
265
|
-
purchase_order_detail_id: `${reception_details?.purchase_order_detail_id}`,
|
|
266
|
-
},
|
|
267
|
-
},
|
|
268
|
-
},
|
|
269
|
-
};
|
|
270
|
-
await createNewReception(headers, bodyReception, purchaseOrder.id);
|
|
242
|
+
await updateReceivedPurchaseOrder(headers, updateBodyPurchase, purchaseOrder.id);
|
|
271
243
|
//=====================================================================================
|
|
272
244
|
//=====================================================================================
|
|
273
245
|
//PASO 6: Guardar razones de rechazo en webapp table
|
|
@@ -191,25 +191,6 @@ export const updateOchAndDis = async (headers, data, purchase_id) => {
|
|
|
191
191
|
return true;
|
|
192
192
|
});
|
|
193
193
|
};
|
|
194
|
-
/**
|
|
195
|
-
* updatePurchaseOrderReception
|
|
196
|
-
* @param headers
|
|
197
|
-
* @param data
|
|
198
|
-
* @param purchase_id
|
|
199
|
-
* @returns
|
|
200
|
-
*/
|
|
201
|
-
export const updatePurchaseOrderReception = async (headers, data, purchase_id) => {
|
|
202
|
-
return handlePossibleAxiosErrors(async () => {
|
|
203
|
-
const body = {
|
|
204
|
-
purchase_order: {
|
|
205
|
-
payee_id: data.payee_id,
|
|
206
|
-
purchase_order_details_attributes: data.purchase_order_details_attributes,
|
|
207
|
-
},
|
|
208
|
-
};
|
|
209
|
-
await updateReceivedPurchaseOrder(headers, body, purchase_id);
|
|
210
|
-
return true;
|
|
211
|
-
});
|
|
212
|
-
};
|
|
213
194
|
/**
|
|
214
195
|
* Obtengo los id's de las órdenes de compra en un arreglo numérico
|
|
215
196
|
* @param headers
|
|
@@ -347,6 +328,7 @@ export const createNewLabItemRequest = (headers, session, body) => {
|
|
|
347
328
|
"laboratory_proyect_id",
|
|
348
329
|
]);
|
|
349
330
|
const id_number = generateDistinctCode("POLAB");
|
|
331
|
+
const insumos = JSON.parse(body.insumos);
|
|
350
332
|
const sendBody = {
|
|
351
333
|
...body,
|
|
352
334
|
shipping_date: body.issue_date,
|
|
@@ -359,14 +341,14 @@ export const createNewLabItemRequest = (headers, session, body) => {
|
|
|
359
341
|
id_number,
|
|
360
342
|
reference: "LABORATORIO - Solicitud de insumos desde WebApp",
|
|
361
343
|
origin: "LABORATORIO",
|
|
362
|
-
purchase_order_details:
|
|
363
|
-
{
|
|
364
|
-
booked_quantity:
|
|
365
|
-
item_id:
|
|
344
|
+
purchase_order_details: insumos.map((x) => {
|
|
345
|
+
return {
|
|
346
|
+
booked_quantity: x.booked_quantity,
|
|
347
|
+
item_id: x.item_id,
|
|
366
348
|
unit_cost: 1,
|
|
367
349
|
tag_id: Number(laboratory_proyect_id),
|
|
368
|
-
}
|
|
369
|
-
|
|
350
|
+
};
|
|
351
|
+
}),
|
|
370
352
|
taggings: [{ tag_id: Number(laboratory_proyect_id) }],
|
|
371
353
|
};
|
|
372
354
|
const response = await createNewPurchaseOrder(headers, sendBody);
|
|
@@ -44,20 +44,6 @@ export declare const updateOchAndDis: (headers: any, data: {
|
|
|
44
44
|
discount?: number | string;
|
|
45
45
|
other_charges?: number | string;
|
|
46
46
|
}, purchase_id: number) => Promise<AxiosUtilsResponse<boolean>>;
|
|
47
|
-
/**
|
|
48
|
-
* updatePurchaseOrderReception
|
|
49
|
-
* @param headers
|
|
50
|
-
* @param data
|
|
51
|
-
* @param purchase_id
|
|
52
|
-
* @returns
|
|
53
|
-
*/
|
|
54
|
-
export declare const updatePurchaseOrderReception: (headers: any, data: {
|
|
55
|
-
payee_id?: string;
|
|
56
|
-
purchase_order_details_attributes: Record<string, {
|
|
57
|
-
item_id: number;
|
|
58
|
-
id: number;
|
|
59
|
-
}>;
|
|
60
|
-
}, purchase_id: number) => Promise<AxiosUtilsResponse<boolean>>;
|
|
61
47
|
/**
|
|
62
48
|
* Obtengo los id's de las órdenes de compra en un arreglo numérico
|
|
63
49
|
* @param headers
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zauru-sdk/utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.71",
|
|
4
4
|
"description": "Utilidades, parseo de request y demás para desarrollo de webapps de Zauru",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@remix-run/node": "^2.8.1",
|
|
28
|
-
"@zauru-sdk/common": "^1.0.
|
|
28
|
+
"@zauru-sdk/common": "^1.0.71",
|
|
29
29
|
"@zauru-sdk/config": "^1.0.60",
|
|
30
|
-
"@zauru-sdk/graphql": "^1.0.
|
|
31
|
-
"@zauru-sdk/services": "^1.0.
|
|
32
|
-
"@zauru-sdk/types": "^1.0.
|
|
30
|
+
"@zauru-sdk/graphql": "^1.0.71",
|
|
31
|
+
"@zauru-sdk/services": "^1.0.71",
|
|
32
|
+
"@zauru-sdk/types": "^1.0.69"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "14735e4cb251cbbb8484920003e813b1da124663"
|
|
35
35
|
}
|