validacion asistencia dia correcto
This commit is contained in:
@@ -7,6 +7,7 @@ const PrimerSemestre = require(`${dbPath}/PrimerSemestre`);
|
||||
|
||||
const asistencia = async (body) => {
|
||||
const idPrimerSemestre = validar.validarId(body.idPrimerSemestre);
|
||||
const hoy = moment();
|
||||
|
||||
return PrimerSemestre.findOne({
|
||||
where: { idPrimerSemestre },
|
||||
@@ -16,9 +17,8 @@ const asistencia = async (body) => {
|
||||
if (!res) throw new Error('No existe este alumno.');
|
||||
if (res.asistio)
|
||||
throw new Error('Ya fue registrada la asistencia de este alumno.');
|
||||
/*
|
||||
Validar que sea el dia del recorrido
|
||||
*/
|
||||
if (hoy.dayOfYear() != moment(res.Horario.horario).dayOfYear())
|
||||
throw new Error('Este alumno no tiene una cita para el día de hoy.');
|
||||
return PrimerSemestre.update(
|
||||
{ asistio: true },
|
||||
{ where: { idPrimerSemestre } }
|
||||
|
||||
@@ -10,7 +10,7 @@ const GrupoHorario = require(`${dbPath}/GrupoHorario`);
|
||||
const Horario = require(`${dbPath}/Horario`);
|
||||
const TercerSemestre = require(`${dbPath}/TercerSemestre`);
|
||||
|
||||
const get = async (body) => {
|
||||
const csv = async (body) => {
|
||||
const path = `server/uploads/tercer_semestre.csv`;
|
||||
const data = [];
|
||||
|
||||
@@ -56,4 +56,4 @@ const get = async (body) => {
|
||||
.then((res) => path);
|
||||
};
|
||||
|
||||
module.exports = get;
|
||||
module.exports = csv;
|
||||
|
||||
@@ -9,7 +9,7 @@ const GrupoHorario = require(`${dbPath}/GrupoHorario`);
|
||||
const Horario = require(`${dbPath}/Horario`);
|
||||
const TercerSemestre = require(`${dbPath}/TercerSemestre`);
|
||||
|
||||
const get = async (body) => {
|
||||
const registrar = async (body) => {
|
||||
const idTercerSemestre = validarId(body.idTercerSemestre);
|
||||
let alumno = {};
|
||||
let mail = {};
|
||||
@@ -54,4 +54,4 @@ const get = async (body) => {
|
||||
}));
|
||||
};
|
||||
|
||||
module.exports = get;
|
||||
module.exports = registrar;
|
||||
|
||||
@@ -40,7 +40,7 @@ app.put(`${route}/asistencia`, (req, res) => {
|
||||
});
|
||||
|
||||
// GET
|
||||
app.put(`${route}/asistentes`, (req, res) => {
|
||||
app.get(`${route}/asistentes`, (req, res) => {
|
||||
return asistentes(req.query)
|
||||
.then((data) => {
|
||||
res.status(200).json(data);
|
||||
|
||||
Reference in New Issue
Block a user