From d27d71f69fe8a681fc13416bbec0979579d132c5 Mon Sep 17 00:00:00 2001 From: ricardo051199 Date: Thu, 21 Nov 2024 18:52:08 -0400 Subject: [PATCH] No permitir solicitudes de vacaciones con anticimacion de 3 meses maximo a 15 dias minimo. --- .../views/RequestRegisterView.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/primefactorsolutions/views/RequestRegisterView.java b/src/main/java/com/primefactorsolutions/views/RequestRegisterView.java index e32feba..9b0c562 100644 --- a/src/main/java/com/primefactorsolutions/views/RequestRegisterView.java +++ b/src/main/java/com/primefactorsolutions/views/RequestRegisterView.java @@ -500,9 +500,14 @@ public class RequestRegisterView extends VerticalLayout { handleExistingRequests(request); } - requestService.saveTimeOffRequest(request); - Notification.show("Solicitud guardada correctamente."); - closeForm(); + long differentDays = ChronoUnit.DAYS.between(LocalDate.now(), request.getStartDate()); + if (differentDays >= -15 && differentDays <= 90) { + requestService.saveTimeOffRequest(request); + Notification.show("Solicitud guardada correctamente."); + closeForm(); + } else { + Notification.show("La fecha de inicio debe encontrarse dentro del rango de 15 días a 3 meses de anticipación."); + } } private TimeOffRequest prepareRequest() {