@zauru-sdk/utils 2.0.13 → 2.0.16

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,7 +1,7 @@
1
- import { getHeaders, getSession, updateReceivedPurchaseOrder, } from "@zauru-sdk/services";
2
- import { updateQueueShipmentsFormHistory } from "./4pinos-shipments-form-history.utils.js";
1
+ import { getHeaders, getSession, insertBookings, updateReceivedPurchaseOrder, } from "@zauru-sdk/services";
2
+ import { deleteQueueShipmentsFormHistory, updateQueueShipmentsFormHistory, } from "./4pinos-shipments-form-history.utils.js";
3
3
  import { ESTADOS_COLA_RECEPCIONES } from "./4pinos-receptions-form-history.utils.js";
4
- export const register4pinosShipment = async ({ cookie, idWebAppTable, agency_id, values, }) => {
4
+ export const register4pinosShipment = async ({ cookie, idWebAppTable, values, }) => {
5
5
  const session = await getSession(cookie);
6
6
  const headers = await getHeaders(cookie, session);
7
7
  try {
@@ -16,6 +16,28 @@ export const register4pinosShipment = async ({ cookie, idWebAppTable, agency_id,
16
16
  throw new Error(`Error al actualizar la orden de compra ${purchaseOrder.id}: ${response.userMsg}`);
17
17
  }
18
18
  }
19
+ //PASO 2: CREAR EL ENVIO
20
+ const shipmentBody = {
21
+ reference: `Envío: ${values.shipment_number} realizado desde la aplicación web.`,
22
+ agency_from_id: values.agency_from,
23
+ agency_to_id: values.agency_to,
24
+ transporter_id: values.transporter_id,
25
+ planned_delivery: values.planned_delivery,
26
+ planned_shipping: values.planned_shipping,
27
+ movements: values.purchase_orders.map((purchaseOrder) => ({
28
+ lot_id: purchaseOrder.lot_id,
29
+ })),
30
+ };
31
+ console.log("========================================>");
32
+ console.log("Enviando: ", JSON.stringify(shipmentBody));
33
+ const createBookingResponse = await insertBookings(headers, shipmentBody);
34
+ if (createBookingResponse.error) {
35
+ throw new Error(`Error al crear el envío: ${createBookingResponse.userMsg} con el body: ${JSON.stringify(shipmentBody)}`);
36
+ }
37
+ console.log("========================================>");
38
+ console.log("paso 3: ELIMINAR EL REGISTRO DE LA COLA");
39
+ //ELIMINAR EL REGISTRO DE LA COLA
40
+ await deleteQueueShipmentsFormHistory(headers, session, idWebAppTable.toString());
19
41
  }
20
42
  catch (e) {
21
43
  console.log("========================================>");
@@ -46,7 +68,6 @@ export const retryShipmennt = async (register, session, headers, hostname, cooki
46
68
  values: register.data?.formSubmited,
47
69
  cookie: cookie || "",
48
70
  idWebAppTable: register.id,
49
- agency_id: register.data?.agency_id,
50
71
  });
51
72
  }
52
73
  else {
@@ -58,7 +79,6 @@ export const retryShipmennt = async (register, session, headers, hostname, cooki
58
79
  values: register.data?.formSubmited,
59
80
  cookie: cookie || "",
60
81
  idWebAppTable: register.id,
61
- agency_id: register.data?.agency_id,
62
82
  }),
63
83
  });
64
84
  }
@@ -1,5 +1,5 @@
1
- import { getDatePickerCurrentDate, handlePossibleAxiosErrors, reduceAdd } from "@zauru-sdk/common";
2
- import { getDeliveryByBooking, getMyAgencyLotStocks, getShipmentsByToAgencyLast100Id_booking, getVariablesByName, insertBookings } from "@zauru-sdk/services";
1
+ import { getDatePickerCurrentDate, handlePossibleAxiosErrors, reduceAdd, } from "@zauru-sdk/common";
2
+ import { getDeliveryByBooking, getMyAgencyLotStocks, getShipmentsByToAgencyLast100Id_booking, getVariablesByName, insertBookings, } from "@zauru-sdk/services";
3
3
  /**
4
4
  *
5
5
  * @param headers
@@ -1,14 +1,14 @@
1
1
  import { Session } from "@remix-run/node";
2
2
  import { QueueShipmentsForm } from "@zauru-sdk/types";
3
3
  import { WebAppRowGraphQL } from "@zauru-sdk/types";
4
- export declare const register4pinosShipment: ({ cookie, idWebAppTable, agency_id, values, }: {
4
+ export declare const register4pinosShipment: ({ cookie, idWebAppTable, values, }: {
5
5
  cookie: string;
6
6
  idWebAppTable: number;
7
- agency_id: number;
8
7
  values: {
9
8
  agency_from: number;
10
9
  transporter_id: number;
11
- date: string;
10
+ planned_shipping: string;
11
+ planned_delivery: string;
12
12
  shipment_number: string;
13
13
  agency_to: number;
14
14
  purchase_orders: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zauru-sdk/utils",
3
- "version": "2.0.13",
3
+ "version": "2.0.16",
4
4
  "description": "Utilidades, parseo de request y demás para desarrollo de webapps de Zauru",
5
5
  "main": "./dist/esm/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -24,11 +24,11 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@remix-run/node": "^2.8.1",
27
- "@zauru-sdk/common": "^2.0.13",
27
+ "@zauru-sdk/common": "^2.0.16",
28
28
  "@zauru-sdk/config": "^2.0.0",
29
29
  "@zauru-sdk/graphql": "^2.0.7",
30
- "@zauru-sdk/services": "^2.0.13",
31
- "@zauru-sdk/types": "^2.0.13"
30
+ "@zauru-sdk/services": "^2.0.16",
31
+ "@zauru-sdk/types": "^2.0.16"
32
32
  },
33
- "gitHead": "b3b6db7ab1d80167dc64315fdca7083ee649c484"
33
+ "gitHead": "fead735a2c2a1ddad189f67342abe2ea38f1d736"
34
34
  }