@zauru-sdk/utils 2.0.12 → 2.0.13
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,6 +1,71 @@
|
|
|
1
|
-
import { getHeaders, getSession } from "@zauru-sdk/services";
|
|
1
|
+
import { getHeaders, getSession, updateReceivedPurchaseOrder, } from "@zauru-sdk/services";
|
|
2
|
+
import { updateQueueShipmentsFormHistory } from "./4pinos-shipments-form-history.utils.js";
|
|
3
|
+
import { ESTADOS_COLA_RECEPCIONES } from "./4pinos-receptions-form-history.utils.js";
|
|
2
4
|
export const register4pinosShipment = async ({ cookie, idWebAppTable, agency_id, values, }) => {
|
|
3
5
|
const session = await getSession(cookie);
|
|
4
6
|
const headers = await getHeaders(cookie, session);
|
|
5
|
-
|
|
7
|
+
try {
|
|
8
|
+
//PASO 1: COLOCO EL NUMERO DE ENVIO EN TODAS LAS ORDENES DE COMPRA
|
|
9
|
+
for (const purchaseOrder of values.purchase_orders) {
|
|
10
|
+
const response = await updateReceivedPurchaseOrder(headers, {
|
|
11
|
+
purchase_order: {
|
|
12
|
+
shipment_number: values.shipment_number,
|
|
13
|
+
},
|
|
14
|
+
}, purchaseOrder.id);
|
|
15
|
+
if (response.error) {
|
|
16
|
+
throw new Error(`Error al actualizar la orden de compra ${purchaseOrder.id}: ${response.userMsg}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
console.log("========================================>");
|
|
22
|
+
console.log("paso -1: ACTUALIZAR EL REGISTRO DE LA COLA A ERROR");
|
|
23
|
+
console.error(`Error: ${e?.toString()}, idWebAppTable: ${idWebAppTable}`);
|
|
24
|
+
await updateQueueShipmentsFormHistory(headers, session, {
|
|
25
|
+
estado: ESTADOS_COLA_RECEPCIONES.ERROR,
|
|
26
|
+
description: e?.toString(),
|
|
27
|
+
}, idWebAppTable);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
export const retryShipmennt = async (register, session, headers, hostname, cookie) => {
|
|
31
|
+
console.log("REINTENTO DE REGISTRO DE ENVÍO =======================>");
|
|
32
|
+
const queueResponse = await updateQueueShipmentsFormHistory(headers, session, {
|
|
33
|
+
estado: ESTADOS_COLA_RECEPCIONES.REINTENTANDO,
|
|
34
|
+
}, register.id);
|
|
35
|
+
if (queueResponse.error || !queueResponse.data?.id) {
|
|
36
|
+
return {
|
|
37
|
+
error: true,
|
|
38
|
+
title: "No se logró comunicar con la red.",
|
|
39
|
+
type: "error",
|
|
40
|
+
description: `No hay comunicación con la red para el reintento: ${queueResponse?.userMsg}`,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
if (hostname.includes("localhost")) {
|
|
44
|
+
console.log("------- EJECUTANDO LOCALMENTE", ` para ${register.data?.formSubmited?.shipment_number}`);
|
|
45
|
+
register4pinosShipment({
|
|
46
|
+
values: register.data?.formSubmited,
|
|
47
|
+
cookie: cookie || "",
|
|
48
|
+
idWebAppTable: register.id,
|
|
49
|
+
agency_id: register.data?.agency_id,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
console.log("------- ENVIANDO A EJECUTAR NETLIFY FUNCTION: 4pinosNewShipment-background", ` para ${register.data?.formSubmited?.shipment_number}`);
|
|
54
|
+
fetch(`https://${hostname}/.netlify/functions/4pinosNewShipment-background`, {
|
|
55
|
+
method: "post",
|
|
56
|
+
headers: { "Content-type": "application/json" },
|
|
57
|
+
body: JSON.stringify({
|
|
58
|
+
values: register.data?.formSubmited,
|
|
59
|
+
cookie: cookie || "",
|
|
60
|
+
idWebAppTable: register.id,
|
|
61
|
+
agency_id: register.data?.agency_id,
|
|
62
|
+
}),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
error: false,
|
|
67
|
+
title: "Reintento iniciado con éxito.",
|
|
68
|
+
type: "success",
|
|
69
|
+
description: `Se está procesando el reintento de ingreso de recepción!.`,
|
|
70
|
+
};
|
|
6
71
|
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { Session } from "@remix-run/node";
|
|
2
|
+
import { QueueShipmentsForm } from "@zauru-sdk/types";
|
|
3
|
+
import { WebAppRowGraphQL } from "@zauru-sdk/types";
|
|
1
4
|
export declare const register4pinosShipment: ({ cookie, idWebAppTable, agency_id, values, }: {
|
|
2
5
|
cookie: string;
|
|
3
6
|
idWebAppTable: number;
|
|
@@ -14,3 +17,9 @@ export declare const register4pinosShipment: ({ cookie, idWebAppTable, agency_id
|
|
|
14
17
|
}[];
|
|
15
18
|
};
|
|
16
19
|
}) => Promise<void>;
|
|
20
|
+
export declare const retryShipmennt: (register: WebAppRowGraphQL<QueueShipmentsForm>, session: Session, headers: any, hostname: string, cookie: string | null) => Promise<{
|
|
21
|
+
error: boolean;
|
|
22
|
+
title: string;
|
|
23
|
+
type: string;
|
|
24
|
+
description: string;
|
|
25
|
+
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zauru-sdk/utils",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.13",
|
|
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.
|
|
27
|
+
"@zauru-sdk/common": "^2.0.13",
|
|
28
28
|
"@zauru-sdk/config": "^2.0.0",
|
|
29
29
|
"@zauru-sdk/graphql": "^2.0.7",
|
|
30
|
-
"@zauru-sdk/services": "^2.0.
|
|
31
|
-
"@zauru-sdk/types": "^2.0.
|
|
30
|
+
"@zauru-sdk/services": "^2.0.13",
|
|
31
|
+
"@zauru-sdk/types": "^2.0.13"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "b3b6db7ab1d80167dc64315fdca7083ee649c484"
|
|
34
34
|
}
|