From 9ecf66d8c95851bb7fc5ccb38ba827d0b9454a35 Mon Sep 17 00:00:00 2001 From: nicolasarana <90768149+nicolasarana@users.noreply.github.com> Date: Tue, 14 Jul 2026 16:52:18 -0300 Subject: [PATCH] MAT - Restrigir las fechas para turnos web --- modules/matriculaciones/routes/turno.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/matriculaciones/routes/turno.ts b/modules/matriculaciones/routes/turno.ts index aeef4f4683..50e0ec4ff7 100644 --- a/modules/matriculaciones/routes/turno.ts +++ b/modules/matriculaciones/routes/turno.ts @@ -28,6 +28,18 @@ router.post('/turnos/:tipo/:profesionalId/', async (req, res, next) => { // Convert date to user datetime. try { const fechaTurno = new Date(req.body.turno.fecha); + + // Validar que no se pueda sacar turno para mañana si es posterior a las 15:00 + const ahora = new Date(); + const manana = new Date(); + manana.setDate(manana.getDate() + 1); + manana.setHours(0, 0, 0, 0); + const fechaTurnoInicio = new Date(fechaTurno); + fechaTurnoInicio.setHours(0, 0, 0, 0); + if (ahora.getHours() >= 15 && fechaTurnoInicio.getTime() === manana.getTime()) { + return next('No es posible sacar turnos para el día siguiente después de las 15:00 hs.'); + } + const busquedaTurno = { $and: [ { anulado: { $exists: false } },