cambios para visualizar data enviada
This commit is contained in:
@@ -57,20 +57,17 @@ const envioDte = async () => {
|
|||||||
include: [PedidosHeader]
|
include: [PedidosHeader]
|
||||||
});
|
});
|
||||||
|
|
||||||
// console.log(JSON.stringify(dataEstados, null, 2))
|
|
||||||
|
|
||||||
const skuShipping = dataInfracommerce.skuShipping;
|
const skuShipping = dataInfracommerce.skuShipping;
|
||||||
for (const element of dataEstados) {
|
for (const element of dataEstados) {
|
||||||
const omsId = `${element.pedidos_header.IdOrdenOMS_ph}`;
|
const omsId = `${element.pedidos_header.IdOrdenOMS_ph}`;
|
||||||
const url = dataInfracommerce.urlDte.replace(':oms_id', omsId);
|
const url = dataInfracommerce.urlDte.replace(':oms_id', omsId);
|
||||||
// console.log(url);
|
|
||||||
|
|
||||||
const urlDoc = element.pedidos_header.UrlDoc_ph;
|
const urlDoc = element.pedidos_header.UrlDoc_ph;
|
||||||
const pedido = element.pedido;
|
const pedido = element.pedido;
|
||||||
let fechaRegistro = element.pedidos_header.FECREG_PH;
|
let fechaRegistro = element.pedidos_header.FECREG_PH;
|
||||||
fechaRegistro = moment(fechaRegistro).format("YYYY-MM-DD HH:mm:ss");
|
fechaRegistro = moment(fechaRegistro).format("YYYY-MM-DD HH:mm:ss");
|
||||||
|
|
||||||
console.log(pedido)
|
|
||||||
const dataLvta = await Lvta.findOne({
|
const dataLvta = await Lvta.findOne({
|
||||||
where: {
|
where: {
|
||||||
// NROPED_LV: { [Op.gt]: 0 },
|
// NROPED_LV: { [Op.gt]: 0 },
|
||||||
@@ -85,8 +82,6 @@ const envioDte = async () => {
|
|||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
|
||||||
// console.log(JSON.stringify(dataLvta, null, 2))
|
|
||||||
// return;
|
|
||||||
|
|
||||||
let res;
|
let res;
|
||||||
// for (const elementLvta of dataLvta) {
|
// for (const elementLvta of dataLvta) {
|
||||||
@@ -152,17 +147,12 @@ const envioDte = async () => {
|
|||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log(JSON.stringify(payload, null, 2))
|
|
||||||
// return
|
|
||||||
res = await sendRequestInfracommerce(payload, url);
|
|
||||||
console.log(payload)
|
console.log(payload)
|
||||||
console.log(res)
|
res = await sendRequestInfracommerce(payload, url);
|
||||||
|
// console.log(payload)
|
||||||
|
|
||||||
Logger.info({ message: `Payload enviado: ${JSON.stringify(payload, null, 2)}`, proceso: 'cron' });
|
Logger.info({ message: `Payload enviado: ${JSON.stringify(payload, null, 2)}`, proceso: 'cron' });
|
||||||
Logger.info({ message: `Respuesta del documento ${NRODOC_LV}: ${JSON.stringify(res, null, 2)}`, proceso: 'cron' });
|
Logger.info({ message: `Respuesta del documento ${NRODOC_LV}: ${JSON.stringify(res, null, 2)}`, proceso: 'cron' });
|
||||||
// console.log(JSON.stringify(res, null, 2))
|
|
||||||
|
|
||||||
|
|
||||||
// if (res) {
|
// if (res) {
|
||||||
@@ -176,7 +166,7 @@ const envioDte = async () => {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
if (res.status) {
|
if (res.status) {
|
||||||
if (res.status == "error") {
|
if (res.status == "error") {
|
||||||
|
|||||||
@@ -132,14 +132,14 @@ const envioEstados = async () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(element.pedido, JSON.stringify(dataEstado, null, 2))
|
// console.log(element.pedido, JSON.stringify(dataEstado, null, 2))
|
||||||
|
|
||||||
if (dataEstado.pedido) {
|
if (dataEstado.pedido) {
|
||||||
if ((dataEstado.estado < estadoSial)) {
|
if ((dataEstado.estado < estadoSial)) {
|
||||||
if (estadoSial == 3 || estadoSial == 4 || estadoSial == 5) {
|
if (estadoSial == 3 || estadoSial == 4 || estadoSial == 5) {
|
||||||
const res = await sendRequestInfracommerce(payload, url);
|
const res = await sendRequestInfracommerce(payload, url);
|
||||||
|
|
||||||
console.log(res)
|
// console.log(res)
|
||||||
Logger.info({ message: `Estado de la orden ${omsId}: ${estadoEnvioUrbano}, resInfracommerce: ${JSON.stringify(res, null, 2)}`, proceso: 'cron' });
|
Logger.info({ message: `Estado de la orden ${omsId}: ${estadoEnvioUrbano}, resInfracommerce: ${JSON.stringify(res, null, 2)}`, proceso: 'cron' });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ const enviarGuias = async (idGuia) => {
|
|||||||
const url = dataUrbano.url;
|
const url = dataUrbano.url;
|
||||||
const idContrato = dataUrbano.id_contrato;
|
const idContrato = dataUrbano.id_contrato;
|
||||||
const linea = dataUrbano.linea;
|
const linea = dataUrbano.linea;
|
||||||
// console.log(url, idContrato);
|
|
||||||
|
|
||||||
const guias = await ParametrosGuia.findAll({
|
const guias = await ParametrosGuia.findAll({
|
||||||
where: {
|
where: {
|
||||||
@@ -122,7 +121,7 @@ const enviarGuias = async (idGuia) => {
|
|||||||
tipo_empaque: '',
|
tipo_empaque: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
guias.forEach(async entry => {
|
guias.forEach(async entry => {
|
||||||
entry.set({
|
entry.set({
|
||||||
estado: 1
|
estado: 1
|
||||||
@@ -132,8 +131,6 @@ const enviarGuias = async (idGuia) => {
|
|||||||
|
|
||||||
const payload = dataGuia;
|
const payload = dataGuia;
|
||||||
|
|
||||||
console.log(JSON.stringify(payload, null, 2))
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await sendData(url, null, payload);
|
const res = await sendData(url, null, payload);
|
||||||
await guardarRespuesta(idGuia, 1, res, payload);
|
await guardarRespuesta(idGuia, 1, res, payload);
|
||||||
@@ -155,8 +152,6 @@ const guardarRespuesta = async (idGuia, estado = 1, respuesta, payloadRequest) =
|
|||||||
|
|
||||||
let dataRespuesta;
|
let dataRespuesta;
|
||||||
if (respuesta.error >= 0) {
|
if (respuesta.error >= 0) {
|
||||||
console.log("aca")
|
|
||||||
console.log(respuesta)
|
|
||||||
dataRespuesta = {
|
dataRespuesta = {
|
||||||
numeroguia: respuesta.guia,
|
numeroguia: respuesta.guia,
|
||||||
id: idGuia,
|
id: idGuia,
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ const sendRequestInfracommerce = async (payload, url) => {
|
|||||||
// const url = dataEnvioEstados.url.replace(':oms_id', omsId);
|
// const url = dataEnvioEstados.url.replace(':oms_id', omsId);
|
||||||
const { AppKey, AppToken } = dataInfracommerce;
|
const { AppKey, AppToken } = dataInfracommerce;
|
||||||
|
|
||||||
console.log(AppKey, AppToken)
|
// console.log(AppKey, AppToken)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const headers = {
|
const headers = {
|
||||||
@@ -58,6 +58,7 @@ const sendRequestInfracommerce = async (payload, url) => {
|
|||||||
body: JSON.stringify(payload),
|
body: JSON.stringify(payload),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(response)
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
const res = await response.json();
|
const res = await response.json();
|
||||||
const data = JSON.stringify(res, null, 2);
|
const data = JSON.stringify(res, null, 2);
|
||||||
|
|||||||
Reference in New Issue
Block a user