From eacde273bc52ccd934490659acfe76c28573f767 Mon Sep 17 00:00:00 2001 From: lemuel Date: Thu, 29 Sep 2022 18:22:37 -0500 Subject: [PATCH] tonterias mias --- src/prestamo/prestamo.service.ts | 54 ++++++++++++++++---------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/prestamo/prestamo.service.ts b/src/prestamo/prestamo.service.ts index 769f21a..b84de34 100644 --- a/src/prestamo/prestamo.service.ts +++ b/src/prestamo/prestamo.service.ts @@ -152,34 +152,34 @@ export class PrestamoService { ) : null; - // if (ahora.weekday() === 0) - // throw new ConflictException('No hay servicio los días domingo.'); - // this.validarInstitucionUsuario(usuario.instituciones, modulo); - // if (!institucionDia.activo) - // throw new ConflictException( - // 'El día de hoy no hay servicio de préstamo de equipos.', - // ); - // if (ahora < horaMin) - // throw new ConflictException( - // `El servicio inicia a las ${institucionDia.hora_inicio} el día de hoy.`, - // ); - // if (ahora >= horaExtra) - // throw new ConflictException( - // `El servicio terminó a las ${institucionDia.hora_extra} el día de hoy.`, - // ); - // for (let i = 0; i < institucionDia.horasExcepcion.length; i++) { - // const horaFin = moment( - // `${ahoraStr} ${institucionDia.horasExcepcion[i].hora_fin}`, - // ); - // const horaInicio = moment( - // `${ahoraStr} ${institucionDia.horasExcepcion[i].hora_inicio}`, - // ); + if (ahora.weekday() === 0) + throw new ConflictException('No hay servicio los días domingo.'); + this.validarInstitucionUsuario(usuario.instituciones, modulo); + if (!institucionDia.activo) + throw new ConflictException( + 'El día de hoy no hay servicio de préstamo de equipos.', + ); + if (ahora < horaMin) + throw new ConflictException( + `El servicio inicia a las ${institucionDia.hora_inicio} el día de hoy.`, + ); + if (ahora >= horaExtra) + throw new ConflictException( + `El servicio terminó a las ${institucionDia.hora_extra} el día de hoy.`, + ); + for (let i = 0; i < institucionDia.horasExcepcion.length; i++) { + const horaFin = moment( + `${ahoraStr} ${institucionDia.horasExcepcion[i].hora_fin}`, + ); + const horaInicio = moment( + `${ahoraStr} ${institucionDia.horasExcepcion[i].hora_inicio}`, + ); - // if (ahora > horaInicio && ahora < horaFin) - // throw new ConflictException( - // `Se suspendió temporalmente el servicio de ${institucionDia.horasExcepcion[i].hora_inicio} a ${institucionDia.horasExcepcion[i].hora_fin}.`, - // ); - // } + if (ahora > horaInicio && ahora < horaFin) + throw new ConflictException( + `Se suspendió temporalmente el servicio de ${institucionDia.horasExcepcion[i].hora_inicio} a ${institucionDia.horasExcepcion[i].hora_fin}.`, + ); + } return this.repository .findOne({ where: { activo: true, usuario } }) .then((existePrestamo) => {