#55 Perfil de Personal Administrativo - Añadir Vacaciones del Empleado (Configurar habilitacion categoria si previa solicitud expira)
This commit is contained in:
parent
cb3ed95c0c
commit
807555a2dd
@ -20,6 +20,7 @@ import com.vaadin.flow.spring.annotation.SpringComponent;
|
|||||||
import jakarta.annotation.security.PermitAll;
|
import jakarta.annotation.security.PermitAll;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.time.Year;
|
import java.time.Year;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -154,6 +155,14 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
|
|||||||
List<TimeOffRequest> filteredRequests = allFiltersAreNull(category, state)
|
List<TimeOffRequest> filteredRequests = allFiltersAreNull(category, state)
|
||||||
? requestService.findRequestsByEmployeeId(employeeId)
|
? requestService.findRequestsByEmployeeId(employeeId)
|
||||||
: fetchFilteredTimeOffRequests(category, state);
|
: fetchFilteredTimeOffRequests(category, state);
|
||||||
|
for (TimeOffRequest request : filteredRequests) {
|
||||||
|
if (request.getExpiration().isBefore(LocalDate.now())) {
|
||||||
|
request.setState(TimeOffRequestStatus.EXPIRED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (TimeOffRequest request : filteredRequests) {
|
||||||
|
requestService.saveTimeOffRequest(request);
|
||||||
|
}
|
||||||
requestGrid.setItems(filteredRequests);
|
requestGrid.setItems(filteredRequests);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +123,8 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
.map(TimeOffRequest::getCategory)
|
.map(TimeOffRequest::getCategory)
|
||||||
.toList();
|
.toList();
|
||||||
List<TimeOffRequestType> availableCategories = Arrays.stream(TimeOffRequestType.values())
|
List<TimeOffRequestType> availableCategories = Arrays.stream(TimeOffRequestType.values())
|
||||||
.filter(category -> !requestedCategories.contains(category))
|
.filter(category -> !requestedCategories.contains(category) ||
|
||||||
|
employeeRequests.stream().anyMatch(req -> req.getCategory() == category && req.getState() == TimeOffRequestStatus.EXPIRED))
|
||||||
.filter(category -> {
|
.filter(category -> {
|
||||||
if (employee.getGender() == Employee.Gender.MALE) {
|
if (employee.getGender() == Employee.Gender.MALE) {
|
||||||
return category != TimeOffRequestType.MATERNITY
|
return category != TimeOffRequestType.MATERNITY
|
||||||
@ -152,7 +153,7 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
vacation = vacationService.findVacationByCategory(selectedCategory);
|
vacation = vacationService.findVacationByCategory(selectedCategory);
|
||||||
List<TimeOffRequest> requests = requestService.findByEmployeeAndCategory(employeeComboBox.getValue().getId(), selectedCategory);
|
List<TimeOffRequest> requests = requestService.findByEmployeeAndCategory(employeeComboBox.getValue().getId(), selectedCategory);
|
||||||
if (vacation != null) {
|
if (vacation != null) {
|
||||||
if (!requests.isEmpty()) {
|
if (!requests.isEmpty() && requests.getFirst().getState() != TimeOffRequestStatus.EXPIRED) {
|
||||||
availableDaysField.setValue(requests.getFirst().getDaysBalance());
|
availableDaysField.setValue(requests.getFirst().getDaysBalance());
|
||||||
} else if (vacation.getCategory() == TimeOffRequestType.VACATION_CURRENT_MANAGEMENT) {
|
} else if (vacation.getCategory() == TimeOffRequestType.VACATION_CURRENT_MANAGEMENT) {
|
||||||
LocalDate dateOfEntry = employeeComboBox.getValue().getDateOfEntry();
|
LocalDate dateOfEntry = employeeComboBox.getValue().getDateOfEntry();
|
||||||
@ -165,7 +166,7 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
} else if (yearsOfService > 1) {
|
} else if (yearsOfService > 1) {
|
||||||
availableDaysField.setValue((double)15);
|
availableDaysField.setValue((double)15);
|
||||||
} else {
|
} else {
|
||||||
availableDaysField.setValue((double)0); // O asignar un valor predeterminado
|
availableDaysField.setValue((double)0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
availableDaysField.setValue(vacation.getDuration());
|
availableDaysField.setValue(vacation.getDuration());
|
||||||
|
Loading…
Reference in New Issue
Block a user