const { validarNumeroCuenta } = require('../../helper/validar'); const dbPath = '../../db/tablas'; const Alumno = require(`${dbPath}/Alumno`); const Carrera = require(`${dbPath}/Carrera`); const get = async (body) => { 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.'); if (res.idHorario) throw new Error('Este alumno ya cuenta con un horario asignado.'); delete res.dataValues.idCarrera; return res; }); }; module.exports = get;