Lista de Solicitudes de empleado - actualizar solicitudes permisos de salud
Some checks failed
PR Builder / Build-PR (pull_request) Failing after 22s

This commit is contained in:
jesus.pelaez 2024-11-13 19:54:36 -04:00
parent 9579b33acc
commit 8e1f0fdd7d
5 changed files with 23 additions and 9 deletions

View File

@ -57,7 +57,8 @@ public class TimeOffRequestService {
LocalDate now = LocalDate.now();
for (TimeOffRequest request : requests) {
if (request.getState() == TimeOffRequestStatus.APROBADO) {
if (request.getState() == TimeOffRequestStatus.APROBADO
|| request.getState() == TimeOffRequestStatus.EN_USO) {
LocalDate startDate = request.getStartDate();
LocalDate endDate = request.getEndDate();

View File

@ -217,15 +217,15 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
return requests.stream()
.filter(this::verificationIsHoliday)
.filter(req -> getStartDateYear(req) == year)
.mapToDouble(TimeOffRequest::getAvailableDays)
.mapToDouble(TimeOffRequest::getDaysToBeTake)
.sum();
}
private double calculateVacationUtilizedDays(final int year) {
return requests.stream()
.filter(req -> req.getCategory() == TimeOffRequestType.VACACION_GESTION_ACTUAL)
.filter(req -> getStartDateYear(req) == year)
.mapToDouble(TimeOffRequest::getAvailableDays)
.filter(req -> req.getCategory().name().startsWith("VACACION"))
.filter(req -> getStartDateYear(req) == year || getStartDateYear(req) == year - 1)
.mapToDouble(TimeOffRequest::getDaysToBeTake)
.sum();
}
@ -236,7 +236,7 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
.filter(req -> !(isMale && getMaleSpecificExclusions().contains(req.getCategory())))
.filter(req -> !req.getCategory().name().startsWith("VACACION"))
.filter(req -> getStartDateYear(req) == year)
.mapToDouble(TimeOffRequest::getAvailableDays)
.mapToDouble(TimeOffRequest::getDaysToBeTake)
.sum();
}

View File

@ -310,7 +310,7 @@ public class RequestRegisterView extends VerticalLayout {
}
private void setPickerValues(final Vacation vacation, final LocalDate startDate) {
startDatePicker.setValue(startDate)
startDatePicker.setValue(startDate);
if ((vacation.getDuration() != null && vacation.getDuration() == 0.5)
|| vacation.getCategory() == TimeOffRequestType.PERMISOS_DE_SALUD
@ -447,7 +447,15 @@ public class RequestRegisterView extends VerticalLayout {
List<TimeOffRequest> existingRequests =
requestService.findByEmployeeAndCategory(employee.getId(), request.getCategory());
int maxRequests = request.getCategory().name().startsWith("VACACION") ? 2 : 1;
int maxRequests;
if (request.getCategory() == TimeOffRequestType.PERMISOS_DE_SALUD) {
maxRequests = 4;
} else if (request.getCategory().name().startsWith("VACACION")) {
maxRequests = 2;
} else {
maxRequests = 1;
}
if (existingRequests.size() >= maxRequests) {
existingRequests.stream()

View File

@ -192,8 +192,13 @@ public class RequestsListView extends Main {
}
private double calculateTotalUtilized(final List<TimeOffRequest> employeeRequests) {
int currentYear = LocalDate.now().getYear();
return employeeRequests.stream()
.filter(Objects::nonNull)
.filter(request -> request.getStartDate() != null && (
request.getStartDate().getYear() == currentYear ||
(request.getCategory().name().startsWith("VACACION") && request.getStartDate().getYear() == currentYear - 1)
))
.mapToDouble(request -> request.getDaysToBeTake() != null ? request.getDaysToBeTake() : 0.0)
.sum();
}

View File

@ -78,7 +78,7 @@ values ('9c6f12ba-e333-4e7a-b8a6-caa0982bd8c3', 1, '5c6f11fe-c341-4be7-a9a6-bba0
insert into time_off_request (id, version, employee_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
values ('9d6f12ba-e444-4e7a-b8a6-caa0982bd8d4', 1, '5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 'VIERNES_SANTO', 'APROBADO', 1, '2024-03-29', '2024-03-29', '2024-03-29', 1, 0);
insert into time_off_request (id, version, employee_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
values ('9e6f12ba-e555-4e7a-b8a6-caa0982bd8e5', 1, '5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 'VACACION_GESTION_ACTUAL', 'APROBADO', 30, '2024-11-01', '2022-11-01', '2022-11-30', 30, 0);
values ('9e6f12ba-e555-4e7a-b8a6-caa0982bd8e5', 1, '5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 'VACACION_GESTION_ACTUAL', 'APROBADO', 30, '2025-11-01', '2023-11-01', '2023-11-30', 30, 0);
insert into time_off_request (id, version, employee_id, category, state, available_days, expiration, start_date, end_date, days_to_be_take, days_balance)
values ('8c653f2a-f9a3-4d67-b3b6-12ad98fe0983', 1, 'f6ab3c6d-7078-45f6-9b22-4e37637bfec6', 'DIA_DEL_TRABAJADOR', 'APROBADO', 1, '2024-05-01', '2024-05-01', '2024-05-01', 1, 0);