Validacion del ticket
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
const dbPath = '../../db/tablas';
|
||||
const Inscripcion = require(`${dbPath}/Inscripcion`);
|
||||
|
||||
const validarTicket = async (body) => {
|
||||
console.log(body);
|
||||
return Inscripcion.findOne({
|
||||
where: { folio: body.folio },
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('Este folio no existe');
|
||||
return Inscripcion.update(
|
||||
{
|
||||
validacion: body.validacion,
|
||||
},
|
||||
{
|
||||
where: {
|
||||
folio: body.folio,
|
||||
},
|
||||
}
|
||||
);
|
||||
})
|
||||
.then((res) => {
|
||||
console.log(body.validacion);
|
||||
if (body.validacion === false)
|
||||
throw new Error('El administrador a declinado el ticket');
|
||||
})
|
||||
.then((res) => ({
|
||||
message: '¡ El ticket a sido validado de forma correcta !',
|
||||
}))
|
||||
.catch((err) => {
|
||||
throw new Error('No fue posible validar el ticekt. ' + err);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = validarTicket;
|
||||
Reference in New Issue
Block a user