pasar lsita listo

This commit is contained in:
2021-10-24 14:41:03 -05:00
parent 12668d894c
commit 4822b68407
2 changed files with 19 additions and 2 deletions
+7 -2
View File
@@ -1,7 +1,7 @@
const moment = require('moment');
const dbHelper = '../../helper';
const gmail = require(`${dbHelper}/gmail`);
const { correoAsistencia } = require(`${dbHelper}/correoAlumno`);
const { correoAsistencia } = require(`${dbHelper}/correos`);
const { validarId } = require(`${dbHelper}/validar`);
const dbPath = '../../db/tablas';
const Alumno = require(`${dbPath}/Alumno`);
@@ -10,7 +10,8 @@ const ahora = moment();
const pasarLista = async (body) => {
const idAlumno = validarId(body.idAlumno);
const correo = {};
let correo = {};
let horario = moment();
return Alumno.findOne({
where: { idAlumno },
@@ -18,7 +19,11 @@ const pasarLista = async (body) => {
})
.then((res) => {
if (!res) throw new Error('No existe este alumno.');
horario = moment(res.Horario.horario);
if (res.asistio) throw new Error('Ya paso lista a este alumno.');
if (ahora < horario) throw new Error('Aun no es la hora del recorrido.');
horario.add(20, 'm');
if (ahora > horario) throw new Error('Ya paso la hora del recorrido.');
return Alumno.update({ asistio: true }, { where: { idAlumno } });
})
.then((res) => {