2022-02-10 00:44:23 -06:00
|
|
|
const { Op } = require('sequelize');
|
2022-02-02 19:31:16 -06:00
|
|
|
const dbPath = '../../db/tablas';
|
|
|
|
|
const Usuario = require(`${dbPath}/Usuario`);
|
|
|
|
|
const Inscripcion = require(`${dbPath}/Inscripcion`);
|
2022-03-21 23:29:29 -06:00
|
|
|
const { validarNumeroEntero } = require('../../helper/validar');
|
2022-02-02 19:31:16 -06:00
|
|
|
|
|
|
|
|
const todasInscripciones = async (body) => {
|
2022-03-21 14:03:30 -06:00
|
|
|
const validacion = validarNumeroEntero(body.validacion, 'validacion', true);
|
2022-09-08 13:32:28 -05:00
|
|
|
const order = validacion === 2 ? [['idInscripcion', 'ASC']] : [['idInscripcion', 'DESC']];
|
|
|
|
|
console.log(order)
|
2022-02-02 19:31:16 -06:00
|
|
|
return Inscripcion.findAll({
|
2022-08-08 11:28:42 -05:00
|
|
|
where: {
|
|
|
|
|
validacion,
|
|
|
|
|
cancelacion: 0,
|
|
|
|
|
idPeriodo: Number(process.env.PERIODO),
|
|
|
|
|
},
|
2022-09-08 13:32:28 -05:00
|
|
|
order: order,
|
2022-02-02 19:31:16 -06:00
|
|
|
include: [
|
|
|
|
|
{
|
|
|
|
|
model: Usuario,
|
2022-02-16 00:11:35 -06:00
|
|
|
where: { numeroCuenta: { [Op.like]: `%${body.numeroCuenta}%` } },
|
2022-02-03 23:09:40 -06:00
|
|
|
attributes: ['idUsuario', 'numeroCuenta'],
|
2022-02-02 19:31:16 -06:00
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
module.exports = todasInscripciones;
|