Files
inscripciones_api/server/controller/Admin/motivo.js
T
2022-03-21 15:17:20 -06:00

24 lines
654 B
JavaScript

const { validarNumeroEntero } = require('../../helper/validar');
const dbPath = '../../db/tablas';
const Inscripcion = require(`${dbPath}/Inscripcion`);
const motivo = async (body) => {
const folio = validarNumeroEntero(body.folio, 'folio', true);
return Inscripcion.findOne({
where: { folio },
})
.then((res) => {
if (!res) throw new Error('No pudimos encontrar este ticket.');
return Inscripcion.findOne({
where: { folio, validacion: 0 },
attributes: ['motivo'],
});
})
.catch((err) => {
throw new Error('No fue posible encontrar el ticket. ' + err);
});
};
module.exports = motivo;