Compare commits

..

4 Commits

Author SHA1 Message Date
439eab3541 Merge pull request 'correcciones' (#73) from En-desarrollo into main
All checks were successful
Builder / Build-Project (push) Successful in 2m46s
Reviewed-on: #73
Reviewed-by: alex <alex@primefactorsolutions.com>
2024-11-15 02:52:45 +00:00
005f0235fa correcciones vacacion gestion anterior
All checks were successful
PR Builder / Build-PR (pull_request) Successful in 2m42s
2024-11-14 22:42:42 -04:00
305a5c53f3 correcciones
All checks were successful
PR Builder / Build-PR (pull_request) Successful in 2m38s
2024-11-14 22:31:29 -04:00
97b9e515bf correcciones
All checks were successful
PR Builder / Build-PR (pull_request) Successful in 2m38s
2024-11-14 22:19:43 -04:00
5 changed files with 29 additions and 12 deletions

View File

@ -14,4 +14,5 @@ public interface TimeOffRequestRepository extends JpaRepository<TimeOffRequest,
Optional<TimeOffRequest> findByEmployeeIdAndState(UUID employeeId, TimeOffRequestStatus state); Optional<TimeOffRequest> findByEmployeeIdAndState(UUID employeeId, TimeOffRequestStatus state);
List<TimeOffRequest> findByEmployeeIdAndCategory(UUID employeeId, TimeOffRequestType category); List<TimeOffRequest> findByEmployeeIdAndCategory(UUID employeeId, TimeOffRequestType category);
List<TimeOffRequest> findByState(TimeOffRequestStatus state); List<TimeOffRequest> findByState(TimeOffRequestStatus state);
void deleteByEmployeeIdAndCategory(UUID employeeId, TimeOffRequestType category);
} }

View File

@ -19,6 +19,10 @@ public class TimeOffRequestService {
timeOffRequestRepository.save(newTimeOffRequest); timeOffRequestRepository.save(newTimeOffRequest);
} }
public void deleteTimeOffRequestByEmployeeAndCategory(final UUID employeeId, final TimeOffRequestType category) {
timeOffRequestRepository.deleteByEmployeeIdAndCategory(employeeId, category);
}
public void saveAll(final List<TimeOffRequest> requests) { public void saveAll(final List<TimeOffRequest> requests) {
timeOffRequestRepository.saveAll(requests); timeOffRequestRepository.saveAll(requests);
} }
@ -57,10 +61,12 @@ public class TimeOffRequestService {
LocalDate now = LocalDate.now(); LocalDate now = LocalDate.now();
LocalDate startOfYear = LocalDate.of(now.getYear(), 1, 1); LocalDate startOfYear = LocalDate.of(now.getYear(), 1, 1);
requests.removeIf(request -> request.getCategory() == TimeOffRequestType.VACACION_GESTION_ANTERIOR);
for (TimeOffRequest request : requests) { for (TimeOffRequest request : requests) {
if (request.getCategory() == TimeOffRequestType.VACACION_GESTION_ACTUAL && now.isEqual(startOfYear)) { if (request.getCategory() == TimeOffRequestType.VACACION_GESTION_ACTUAL && now.isEqual(startOfYear)) {
deleteTimeOffRequestByEmployeeAndCategory(
request.getEmployee().getId(),
TimeOffRequestType.VACACION_GESTION_ANTERIOR
);
request.setCategory(TimeOffRequestType.VACACION_GESTION_ANTERIOR); request.setCategory(TimeOffRequestType.VACACION_GESTION_ANTERIOR);
} }

View File

@ -244,22 +244,21 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
private double calculateHolidayUtilizedDays(final int year) { private double calculateHolidayUtilizedDays(final int year) {
return requests.stream() return requests.stream()
.filter(this::verificationIsHoliday) .filter(this::verificationIsHoliday)
.filter(this::verificationIsHoliday)
.filter(req -> req.getState() == TimeOffRequestStatus.APROBADO)
.filter(req -> req.getState() == TimeOffRequestStatus.EN_USO)
.filter(req -> req.getState() == TimeOffRequestStatus.TOMADO)
.filter(req -> getStartDateYear(req) == year) .filter(req -> getStartDateYear(req) == year)
.mapToDouble(TimeOffRequest::getDaysToBeTake) .mapToDouble(TimeOffRequest::getDaysToBeTake)
.sum(); .sum();
} }
private double calculateVacationUtilizedDays(final int year) {
return requests.stream()
.filter(req -> req.getCategory().name().startsWith("VACACION"))
.filter(req -> getStartDateYear(req) == year || getStartDateYear(req) == year - 1)
.mapToDouble(TimeOffRequest::getDaysBalance)
.sum();
}
private double calculatePersonalDaysUtilized(final boolean isMale, final int year) { private double calculatePersonalDaysUtilized(final boolean isMale, final int year) {
return requests.stream() return requests.stream()
.filter(req -> !verificationIsHoliday(req)) .filter(req -> !verificationIsHoliday(req))
.filter(req -> req.getState() == TimeOffRequestStatus.APROBADO)
.filter(req -> req.getState() == TimeOffRequestStatus.EN_USO)
.filter(req -> req.getState() == TimeOffRequestStatus.TOMADO)
.filter(req -> !getStandardExclusions().contains(req.getCategory())) .filter(req -> !getStandardExclusions().contains(req.getCategory()))
.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"))

View File

@ -136,7 +136,8 @@ public class RequestRegisterView extends VerticalLayout {
.filter(category -> isCategoryAvailable(employeeRequests, category)) .filter(category -> isCategoryAvailable(employeeRequests, category))
.filter(category -> isCategoryAllowedByGender(category, employee.getGender())) .filter(category -> isCategoryAllowedByGender(category, employee.getGender()))
.filter(category -> category != TimeOffRequestType.TODOS) .filter(category -> category != TimeOffRequestType.TODOS)
.filter(category -> shouldIncludeVacationGestionActual(employeeRequests, category)) // Nueva condición .filter(category -> shouldIncludeVacationGestionActual(employeeRequests, category))
.filter(category -> shouldIncludeVacationGestionAnterior(employeeRequests, category))
.toList(); .toList();
categoryComboBox.setItems(availableCategories); categoryComboBox.setItems(availableCategories);
@ -154,6 +155,16 @@ public class RequestRegisterView extends VerticalLayout {
&& request.getState() == TimeOffRequestStatus.TOMADO); && request.getState() == TimeOffRequestStatus.TOMADO);
} }
private boolean shouldIncludeVacationGestionAnterior(final List<TimeOffRequest> employeeRequests,
final TimeOffRequestType category) {
if (category != TimeOffRequestType.VACACION_GESTION_ANTERIOR) {
return true;
}
return employeeRequests.stream()
.noneMatch(request -> request.getCategory() == TimeOffRequestType.VACACION_GESTION_ANTERIOR
&& request.getDaysBalance() == 0);
}
private void onCategoryChange(final TimeOffRequestType selectedCategory) { private void onCategoryChange(final TimeOffRequestType selectedCategory) {
if (selectedCategory == TimeOffRequestType.VACACION_GESTION_ACTUAL if (selectedCategory == TimeOffRequestType.VACACION_GESTION_ACTUAL
|| selectedCategory == TimeOffRequestType.VACACION_GESTION_ANTERIOR) { || selectedCategory == TimeOffRequestType.VACACION_GESTION_ANTERIOR) {

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_ANTERIOR', '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_ANTERIOR', 'APROBADO', 20, '2024-11-01', '2022-11-01', '2022-11-30', 20, 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);