pasar lsita listo
This commit is contained in:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user