@zauru-sdk/utils 1.0.69 → 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.updatePurchaseOrder)(headers, updateBodyPurchase, purchaseOrder.id);
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,5 +1,5 @@
1
1
  import { getBasketsSchema, handlePossibleAxiosErrors, reduceAdd, toFixedIfNeeded, } from "@zauru-sdk/common";
2
- import { createNewReception, enablePurchase, getDeliveryByBooking, getLote, getLotesFiltered, getPurchase, getPurchaseOrder, getVariablesByName, insertBookings, saveMotivosDeRechazoByPurchase, updateLote, updatePurchaseOrder, } from "@zauru-sdk/services";
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 updatePurchaseOrder(headers, updateBodyPurchase, purchaseOrder.id);
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zauru-sdk/utils",
3
- "version": "1.0.69",
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.69",
28
+ "@zauru-sdk/common": "^1.0.71",
29
29
  "@zauru-sdk/config": "^1.0.60",
30
- "@zauru-sdk/graphql": "^1.0.69",
31
- "@zauru-sdk/services": "^1.0.69",
30
+ "@zauru-sdk/graphql": "^1.0.71",
31
+ "@zauru-sdk/services": "^1.0.71",
32
32
  "@zauru-sdk/types": "^1.0.69"
33
33
  },
34
- "gitHead": "46dd382e956e8b34c2a65ef078d8fddb2cdd434c"
34
+ "gitHead": "14735e4cb251cbbb8484920003e813b1da124663"
35
35
  }