error merge

This commit is contained in:
xXpuma99Xx
2021-12-31 19:35:03 -06:00
3 changed files with 66 additions and 6 deletions
+2 -1
View File
@@ -16,12 +16,13 @@ const admin = async (body) => {
{ model: Usuario, include: [{ model: TipoUsuario }] },
{ model: Carrera },
{ model: Status },
{ model: Programa },
{ model: Programa, include: [{ model: Usuario }] },
],
}).then((res) => {
if (!res) throw new Error('No existe este servicio social.');
delete res.dataValues.Usuario.dataValues.password;
delete res.dataValues.Programa.dataValues.idUsuario;
delete res.dataValues.Programa.dataValues.Usuario.dataValues.password;
delete res.dataValues.idUsuario;
delete res.dataValues.idCarrera;
delete res.dataValues.idStatus;
+40 -5
View File
@@ -4,6 +4,33 @@ const { validarNumeroCuenta } = require('../../helper/validar');
const dbPath = '../../db/tablas';
const Usuario = require(`${dbPath}/Usuario`);
const Carrera = require(`${dbPath}/Carrera`);
const creditosCarreras = [
{ carrera: 'LIC. EN ACTUARIA', creditos: 70 },
{ carrera: 'LIC. EN ARQUITECTURA', creditos: 70 },
{ carrera: 'LIC. EN CIENCIAS POLITICAS Y ADMON PUB', creditos: 70 },
{ carrera: 'LIC. EN CIENCIAS POLITICAS Y ADMON.PUBL.', creditos: 70 },
{ carrera: 'LIC. EN COMUNICACION', creditos: 67 },
{ carrera: 'LIC. EN DERECHO', creditos: 70 },
{ carrera: 'LIC. EN DERECHO (SUA)', creditos: 70 },
{ carrera: 'LIC. EN DISEÑO GRAFICO', creditos: 70 },
{ carrera: 'LIC. EN ECONOMIA', creditos: 70 },
{ carrera: 'LIC. EN ENSEÑANZA DE INGLES', creditos: 70 },
{ carrera: 'LIC. EN FILOSOFIA', creditos: 70 },
{ carrera: 'LIC. EN HISTORIA', creditos: 70 },
{ carrera: 'LIC. EN INGENIERIA CIVIL', creditos: 70 },
{ carrera: 'LIC. EN LENGUA Y LITERATURA HISPANICAS', creditos: 70 },
{ carrera: 'LIC. EN MAT. APLICADAS Y COMPUTACION', creditos: 68 },
{ carrera: 'LIC. EN MATEMATICAS APLICADAS Y COMP.', creditos: 68 },
{ carrera: 'LIC. EN PEDAGOGÍA', creditos: 70 },
{ carrera: 'LIC. EN PERIODISMO Y COMUNICACION COL.', creditos: 70 },
{ carrera: 'LIC. EN RELACIONES INTERNACIONALES', creditos: 70 },
{ carrera: 'LIC. EN RELACIONES INTERNACIONALES (SUA)', creditos: 70 },
{ carrera: 'LIC. EN SOCIOLOGIA', creditos: 70 },
{ carrera: 'LIC. ENSEÑANZA DE ALEMÁN (LENG. EXTRANJS', creditos: 70 },
{ carrera: 'LIC. ENSEÑANZA DE ESPAÑOL(LENG. EXTRANJ)', creditos: 70 },
{ carrera: 'LIC. ENSEÑANZA DE INGLÉS(LENG. EXTRANJE)', creditos: 70 },
{ carrera: 'LIC. ENSEÑANZA DE ITALIANO(LENG. EXTRANJ', creditos: 70 },
];
const escolares = async (body) => {
const numeroCuenta = validarNumeroCuenta(body.numeroCuenta);
@@ -17,18 +44,26 @@ const escolares = async (body) => {
.then((res) => {
if (!res.data.nombre || !res.data.carrconst || !res.data.avance)
throw new Error(
'El alumno no cumple con los requisitos para realizar el Servicio Social. Si cree que esto es erroneo comunicate con COESI.'
'El alumno no cumple con los requisitos para realizar el Servicio Social. Si cree que esto es erróneo comunícate al Departamento de Servicio Social y Bolsa de Trabajo.'
);
alumno = {
nombre: res.data.nombre.trim(),
creditos: res.data.avance,
carrera: res.data.carrconst.trim(),
};
while (alumno.nombre.search('‘') != -1)
alumno.nombre = alumno.nombre.replace('‘', '');
while (alumno.nombre.search('Ã') != -1)
for (let i = 0; i < creditosCarreras.length; i++)
if (
alumno.carrera === creditosCarreras[i].carrera &&
Number(alumno.creditos) < creditosCarreras[i].creditos
)
throw new Error('Este alumno no cuenta con los créditos necesarios.');
while (
alumno.nombre.search('‘') != -1 &&
alumno.nombre.search('Ã') != -1
) {
alumno.nombre = alumno.nombre.replace('Ã', 'Ñ');
alumno.nombre = alumno.nombre.replace('‘', '');
}
return Carrera.findOne({ where: { carrera: alumno.carrera } });
})
.then((res) => {