En-desarrollo #71

Merged
alex merged 10 commits from En-desarrollo into main 2024-11-15 00:24:15 +00:00
5 changed files with 23 additions and 9 deletions
Showing only changes of commit 8e1f0fdd7d - Show all commits

View File

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

View File

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

View File

@ -310,7 +310,7 @@ public class RequestRegisterView extends VerticalLayout {
} }
private void setPickerValues(final Vacation vacation, final LocalDate startDate) { private void setPickerValues(final Vacation vacation, final LocalDate startDate) {
startDatePicker.setValue(startDate) startDatePicker.setValue(startDate);
if ((vacation.getDuration() != null && vacation.getDuration() == 0.5) if ((vacation.getDuration() != null && vacation.getDuration() == 0.5)
|| vacation.getCategory() == TimeOffRequestType.PERMISOS_DE_SALUD || vacation.getCategory() == TimeOffRequestType.PERMISOS_DE_SALUD
@ -447,7 +447,15 @@ public class RequestRegisterView extends VerticalLayout {
List<TimeOffRequest> existingRequests = List<TimeOffRequest> existingRequests =
requestService.findByEmployeeAndCategory(employee.getId(), request.getCategory()); 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) { if (existingRequests.size() >= maxRequests) {
existingRequests.stream() existingRequests.stream()

View File

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