validacion folio

This commit is contained in:
Andres2908
2022-03-21 15:17:20 -06:00
parent 2cd8c0810c
commit 3f1099b29b
6 changed files with 20 additions and 14 deletions
+8 -4
View File
@@ -1,16 +1,20 @@
const { validarNumeroEntero } = require('../../helper/validar');
const dbPath = '../../db/tablas';
const Inscripcion = require(`${dbPath}/Inscripcion`);
const validarTicket = async (body) => {
const validacion = validarNumeroEntero(body.validacion, 'validacion', true);
const folio = validarNumeroEntero(body.folio, 'folio', true);
return Inscripcion.findOne({
where: { folio: body.folio },
})
.then((res) => {
if (!res) throw new Error('Este folio no existe');
idUsuario = res.idUsuario;
if (body.validacion == 1) {
if (validacion == 1) {
return Inscripcion.findOne({
where: { folio: body.folio, validacion: 1 },
where: { folio, validacion: 1 },
});
}
})
@@ -18,11 +22,11 @@ const validarTicket = async (body) => {
if (res) throw new Error('Este folio ya fue validado');
return Inscripcion.update(
{
validacion: body.validacion,
validacion,
},
{
where: {
folio: body.folio,
folio,
},
}
);