Files

26 lines
723 B
JavaScript
Raw Permalink Normal View History

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