2021-10-22 23:46:31 -05:00
|
|
|
const { validarNumeroCuenta } = require('../../helper/validar');
|
|
|
|
|
const dbPath = '../../db/tablas';
|
2021-10-23 06:14:30 -05:00
|
|
|
const Alumno = require(`${dbPath}/Alumno`);
|
2021-10-23 06:42:04 -05:00
|
|
|
const Carrera = require(`${dbPath}/Carrera`);
|
2021-10-22 23:46:31 -05:00
|
|
|
|
|
|
|
|
const get = async (body) => {
|
2021-10-23 06:14:30 -05:00
|
|
|
const numeroCuenta = validarNumeroCuenta(body.numeroCuenta);
|
|
|
|
|
|
|
|
|
|
return Alumno.findOne({
|
|
|
|
|
where: { numeroCuenta },
|
|
|
|
|
include: [{ model: Carrera }],
|
|
|
|
|
}).then((res) => {
|
|
|
|
|
if (!res) throw new Error('No existe este número de cuenta.');
|
2021-10-24 20:20:04 -05:00
|
|
|
if (res.idHorario)
|
|
|
|
|
throw new Error('Este alumno ya cuenta con un horario asignado.');
|
2021-10-23 06:42:04 -05:00
|
|
|
delete res.dataValues.idCarrera;
|
2021-10-23 06:14:30 -05:00
|
|
|
return res;
|
|
|
|
|
});
|
2021-10-22 23:46:31 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
module.exports = get;
|