Files

24 lines
654 B
JavaScript
Raw Permalink Normal View History

2022-03-21 15:17:20 -06:00
const { validarNumeroEntero } = require('../../helper/validar');
2022-03-18 01:29:10 -06:00
const dbPath = '../../db/tablas';
const Inscripcion = require(`${dbPath}/Inscripcion`);
const motivo = async (body) => {
2022-03-21 15:17:20 -06:00
const folio = validarNumeroEntero(body.folio, 'folio', true);
2022-03-18 01:29:10 -06:00
return Inscripcion.findOne({
2022-03-21 14:03:30 -06:00
where: { folio },
2022-03-18 01:29:10 -06:00
})
.then((res) => {
if (!res) throw new Error('No pudimos encontrar este ticket.');
return Inscripcion.findOne({
2022-03-21 14:03:30 -06:00
where: { folio, validacion: 0 },
2022-03-18 01:29:10 -06:00
attributes: ['motivo'],
});
})
.catch((err) => {
throw new Error('No fue posible encontrar el ticket. ' + err);
});
};
module.exports = motivo;