Files

32 lines
760 B
JavaScript
Raw Permalink Normal View History

2022-08-04 17:12:39 -05:00
const { NUMBER } = require('sequelize');
2022-03-21 14:03:30 -06:00
const { validarNumeroEntero } = require('../../helper/validar');
2022-01-27 00:15:05 -06:00
const dbPath = '../../db/tablas';
const Inscripcion = require(`${dbPath}/Inscripcion`);
const inscripciones = async (body) => {
2022-03-21 14:03:30 -06:00
const idUsuario = validarNumeroEntero(body.idUsuario, 'Usuario', true);
2022-01-31 20:14:12 -06:00
return Inscripcion.findAll({
2022-03-21 14:03:30 -06:00
where: { idUsuario },
2022-01-27 00:15:05 -06:00
}).then((res) => {
2022-01-30 23:50:17 -06:00
if (!res) return [];
2022-01-27 00:15:05 -06:00
return Inscripcion.findAll({
2022-08-04 17:12:39 -05:00
where: {
idUsuario,
cancelacion: 0,
idPeriodo: Number(process.env.PERIODO),
},
2022-01-27 00:15:05 -06:00
attributes: [
'idInscripcion',
'validacion',
'folio',
'monto',
'idUsuario',
'idArea',
],
});
});
};
module.exports = inscripciones;