This commit is contained in:
Lemuel Marquez
2021-07-11 23:58:16 -05:00
parent ff462be168
commit ac944e5070
5 changed files with 40 additions and 8 deletions
+1 -2
View File
@@ -1,4 +1,3 @@
const { Op, json } = require('sequelize');
const { validarId } = require('../../helper/validar');
const dbPath = '../../db/tablas';
const Carrera = require(`${dbPath}/Carrera`);
@@ -25,7 +24,7 @@ const get = async (body) => {
where: { idHorario: res[i].Horario.idHorario },
}).then((res) => res.length);
if (lugaresOcupados < 50)
if (lugaresOcupados <= 50)
data.push({ Horario: res[i].Horario, lugares: 50 - lugaresOcupados });
}
return data;
+20 -5
View File
@@ -2,7 +2,7 @@ const validar = require('../../helper/validar');
const dbPath = '../../db/tablas';
const Carrera = require(`${dbPath}/Carrera`);
const CarreraHorario = require(`${dbPath}/CarreraHorario`);
const DiaHora = require(`${dbPath}/DiaHora`);
const Horario = require(`${dbPath}/Horario`);
const Grupo = require(`${dbPath}/Grupo`);
const PrimerSemestre = require(`${dbPath}/PrimerSemestre`);
@@ -18,7 +18,6 @@ const get = async (body) => {
Falta
Enviar correo con qr de confirmación de su registro a su
email
Verificar que Dia Hora pertenezca a CarreraHorario
*/
return Carrera.findOne({ where: { idCarrera } })
@@ -35,14 +34,29 @@ const get = async (body) => {
.then((res) => {
if (!res)
throw new Error('Este grupo no pertenece a la carrera indicada.');
return DiaHora.findOne({ where: { idHorario } });
if (res.grupo[0] === '2' && res.grupo[1] === '2')
throw new Error(
'Este grupo es de segundo semestre, no es valido para este registro.'
);
return Horario.findOne({ where: { idHorario } });
})
.then((res) => {
if (!res) throw new Error('Ese horario no existe.');
if (!res) throw new Error('No existe este horario.');
return CarreraHorario.findOne({ where: { idCarrera, idHorario } });
})
.then((res) => {
if (!res) throw new Error('Esta carrera no tiene asignado este horario.');
return PrimerSemestre.findOne({ where: { numeroCuenta } });
})
.then((res) => {
if (res) throw new Error('Ya se registro a este alumno al recorrido.');
return PrimerSemestre.findAll({
where: { idHorario },
});
})
.then((res) => {
if (res.length >= 50)
throw new Error('Este horario ya esta lleno, elige otro.');
return PrimerSemestre.create({
numeroCuenta,
nombre,
@@ -52,7 +66,8 @@ const get = async (body) => {
});
})
.then((res) => ({
message: 'Se ha registrado correctamente al alumno al recorrido.',
message:
'Te haz registrado correctamente al recorrido. Te hemos mandado un mail a tu correo electrónico con tu comprobante de registro.',
}));
};
-1
View File
@@ -1,4 +1,3 @@
const moment = require('moment');
const { validarNumeroCuenta } = require('../../helper/validar');
const dbPath = '../../db/tablas';
const Carrera = require(`${dbPath}/Carrera`);