comentarios oscar
This commit is contained in:
@@ -23,62 +23,66 @@ const validarTicket = async (body) => {
|
||||
let correo = {};
|
||||
let email = '';
|
||||
|
||||
return Inscripcion.findOne({
|
||||
where: { folio },
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('Este folio no existe');
|
||||
idUsuario = res.idUsuario;
|
||||
if (body.validacion == 1) {
|
||||
return Inscripcion.findOne({
|
||||
where: { folio, validacion: 1 },
|
||||
});
|
||||
}
|
||||
return (
|
||||
Inscripcion.findOne({
|
||||
where: { folio },
|
||||
})
|
||||
.then((res) => {
|
||||
if (res) throw new Error('Este folio ya fue validado');
|
||||
return Inscripcion.update(
|
||||
{
|
||||
validacion: body.validacion,
|
||||
},
|
||||
{
|
||||
where: {
|
||||
folio,
|
||||
cancelacion: 0,
|
||||
},
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('Este folio no existe');
|
||||
idUsuario = res.idUsuario;
|
||||
if (body.validacion == 1) {
|
||||
return Inscripcion.findOne({
|
||||
where: { folio, validacion: 1 },
|
||||
});
|
||||
}
|
||||
);
|
||||
})
|
||||
.then((res) => {
|
||||
if (body.validacion === 0) {
|
||||
email = `${numeroCuenta}@pcpuma.acatlan.unam.mx`;
|
||||
correoDeclinar = correoInscripciones();
|
||||
borrarInscripcion(numeroCuenta);
|
||||
borrarRecibo(folio);
|
||||
borrarDetalleServicio(numeroCuenta);
|
||||
})
|
||||
.then((res) => {
|
||||
if (res) throw new Error('Este folio ya fue validado');
|
||||
return Inscripcion.update(
|
||||
{ motivo: body.motivo },
|
||||
{
|
||||
validacion: body.validacion,
|
||||
},
|
||||
{
|
||||
where: {
|
||||
folio,
|
||||
cancelacion: 0,
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
})
|
||||
.then((res) => {
|
||||
if (body.validacion === 1)
|
||||
return {
|
||||
message: '¡El ticket a sido validado de forma correcta!',
|
||||
};
|
||||
else
|
||||
return {
|
||||
message: '¡El ticket a sido declinado',
|
||||
};
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new Error('No fue posible validar el ticket. ' + err);
|
||||
});
|
||||
})
|
||||
//el ticket ya fue validado
|
||||
.then((res) => {
|
||||
if (body.validacion === 0) {
|
||||
email = `${numeroCuenta}@pcpuma.acatlan.unam.mx`;
|
||||
correoDeclinar = correoInscripciones();
|
||||
borrarInscripcion(numeroCuenta);
|
||||
borrarRecibo(folio);
|
||||
borrarDetalleServicio(numeroCuenta);
|
||||
return Inscripcion.update(
|
||||
{ motivo: body.motivo },
|
||||
{
|
||||
where: {
|
||||
folio,
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
})
|
||||
.then((res) => {
|
||||
if (body.validacion === 1) {
|
||||
//Insertar en AD
|
||||
return {
|
||||
message: '¡El ticket a sido validado de forma correcta!',
|
||||
};
|
||||
} else
|
||||
return {
|
||||
message: '¡El ticket a sido declinado',
|
||||
};
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new Error('No fue posible validar el ticket. ' + err);
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
module.exports = validarTicket;
|
||||
|
||||
Reference in New Issue
Block a user