Compare commits
No commits in common. "98ed64dfda50e85272411deed7a34cc02afba69a" and "f0c0811f0ddc7c055f693edcbc8317b8136483b3" have entirely different histories.
98ed64dfda
...
f0c0811f0d
@ -6,8 +6,6 @@ import com.primefactorsolutions.repositories.VacationRepository;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class VacationService {
|
public class VacationService {
|
||||||
@ -17,7 +15,4 @@ public class VacationService {
|
|||||||
return vacationRepository.findByCategory(category);
|
return vacationRepository.findByCategory(category);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Vacation> findVacations() {
|
|
||||||
return vacationRepository.findAll();
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -3,16 +3,13 @@ package com.primefactorsolutions.views;
|
|||||||
import com.primefactorsolutions.model.*;
|
import com.primefactorsolutions.model.*;
|
||||||
import com.primefactorsolutions.service.EmployeeService;
|
import com.primefactorsolutions.service.EmployeeService;
|
||||||
import com.primefactorsolutions.service.TimeOffRequestService;
|
import com.primefactorsolutions.service.TimeOffRequestService;
|
||||||
import com.primefactorsolutions.service.VacationService;
|
|
||||||
import com.vaadin.flow.component.button.Button;
|
import com.vaadin.flow.component.button.Button;
|
||||||
import com.vaadin.flow.component.combobox.ComboBox;
|
import com.vaadin.flow.component.combobox.ComboBox;
|
||||||
import com.vaadin.flow.component.grid.Grid;
|
import com.vaadin.flow.component.grid.Grid;
|
||||||
import com.vaadin.flow.component.html.Div;
|
import com.vaadin.flow.component.html.Div;
|
||||||
import com.vaadin.flow.component.html.H3;
|
import com.vaadin.flow.component.html.H3;
|
||||||
import com.vaadin.flow.component.html.Span;
|
|
||||||
import com.vaadin.flow.component.notification.Notification;
|
import com.vaadin.flow.component.notification.Notification;
|
||||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||||
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
|
||||||
import com.vaadin.flow.router.BeforeEvent;
|
import com.vaadin.flow.router.BeforeEvent;
|
||||||
import com.vaadin.flow.router.HasUrlParameter;
|
import com.vaadin.flow.router.HasUrlParameter;
|
||||||
import com.vaadin.flow.router.PageTitle;
|
import com.vaadin.flow.router.PageTitle;
|
||||||
@ -36,7 +33,6 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
|
|||||||
|
|
||||||
private final TimeOffRequestService requestService;
|
private final TimeOffRequestService requestService;
|
||||||
private final EmployeeService employeeService;
|
private final EmployeeService employeeService;
|
||||||
private final VacationService vacationService;
|
|
||||||
private final Grid<TimeOffRequest> requestGrid = new Grid<>(TimeOffRequest.class);
|
private final Grid<TimeOffRequest> requestGrid = new Grid<>(TimeOffRequest.class);
|
||||||
private List<TimeOffRequest> requests = Collections.emptyList();
|
private List<TimeOffRequest> requests = Collections.emptyList();
|
||||||
private ComboBox<TimeOffRequestType> categoryFilter;
|
private ComboBox<TimeOffRequestType> categoryFilter;
|
||||||
@ -44,18 +40,15 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
|
|||||||
private UUID employeeId;
|
private UUID employeeId;
|
||||||
private TimeOffRequest request;
|
private TimeOffRequest request;
|
||||||
|
|
||||||
public RequestEmployeeView(final TimeOffRequestService requestService,
|
public RequestEmployeeView(final TimeOffRequestService requestService, final EmployeeService employeeService) {
|
||||||
final EmployeeService employeeService,
|
|
||||||
final VacationService vacationService) {
|
|
||||||
this.requestService = requestService;
|
this.requestService = requestService;
|
||||||
this.employeeService = employeeService;
|
this.employeeService = employeeService;
|
||||||
this.vacationService = vacationService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeView() {
|
private void initializeView() {
|
||||||
setupFilters();
|
setupFilters();
|
||||||
setupGrid();
|
setupGrid();
|
||||||
add(requestGrid, createActionButtons(), createSummaryLayout());
|
add(requestGrid, createActionButtons());
|
||||||
refreshRequestGrid(null, null);
|
refreshRequestGrid(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,34 +92,6 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private VerticalLayout createSummaryLayout() {
|
|
||||||
double totalHoliday = requests.stream()
|
|
||||||
.filter(this::verificationIsHoliday)
|
|
||||||
.mapToDouble(TimeOffRequest::getAvailableDays)
|
|
||||||
.sum();
|
|
||||||
double totalVacations = requests.stream()
|
|
||||||
.filter(req -> req.getCategory().toString().startsWith("VACATION"))
|
|
||||||
.mapToDouble(TimeOffRequest::getAvailableDays)
|
|
||||||
.sum();
|
|
||||||
double totalPersonalDays = requests.stream()
|
|
||||||
.filter(req -> !verificationIsHoliday(req)) // Solo los de tipo OTHER
|
|
||||||
.mapToDouble(TimeOffRequest::getAvailableDays)
|
|
||||||
.sum();
|
|
||||||
double totalAvailableDays = totalHoliday + totalVacations + totalPersonalDays;
|
|
||||||
|
|
||||||
return new VerticalLayout(
|
|
||||||
new Span("TOTAL HOLIDAYS: " + totalHoliday),
|
|
||||||
new Span("TOTAL VACATIONS: " + totalVacations),
|
|
||||||
new Span("TOTAL PERSONAL DAYS: " + totalPersonalDays),
|
|
||||||
new Span("TOTAL GENERAL: " + totalAvailableDays)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Boolean verificationIsHoliday(final TimeOffRequest request) {
|
|
||||||
Vacation vacation = vacationService.findVacationByCategory(request.getCategory());
|
|
||||||
return vacation.getType() != Vacation.Type.OTHER;
|
|
||||||
}
|
|
||||||
|
|
||||||
private HorizontalLayout createActionButtons() {
|
private HorizontalLayout createActionButtons() {
|
||||||
Button viewButton = new Button("View", event -> {
|
Button viewButton = new Button("View", event -> {
|
||||||
if (request != null) {
|
if (request != null) {
|
||||||
|
@ -148,8 +148,8 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
if (category == TimeOffRequestType.HEALTH_PERMIT
|
if (category == TimeOffRequestType.HEALTH_PERMIT
|
||||||
|| category == TimeOffRequestType.VACATION_CURRENT_MANAGEMENT
|
|| category == TimeOffRequestType.VACATION_CURRENT_MANAGEMENT
|
||||||
|| category == TimeOffRequestType.VACATION_PREVIOUS_MANAGEMENT) {
|
|| category == TimeOffRequestType.VACATION_PREVIOUS_MANAGEMENT) {
|
||||||
return latestRequest.getState() == TimeOffRequestStatus.EXPIRED
|
return latestRequest.getState() == TimeOffRequestStatus.EXPIRED ||
|
||||||
|| (latestRequest.getState() == TimeOffRequestStatus.TAKEN && latestRequest.getDaysBalance() > 0);
|
(latestRequest.getState() == TimeOffRequestStatus.TAKEN && latestRequest.getDaysBalance() > 0);
|
||||||
} else {
|
} else {
|
||||||
return latestRequest.getState() == TimeOffRequestStatus.EXPIRED;
|
return latestRequest.getState() == TimeOffRequestStatus.EXPIRED;
|
||||||
}
|
}
|
||||||
@ -180,8 +180,7 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
List<TimeOffRequest> requests = requestService.findByEmployeeAndCategory(employeeId, selectedCategory);
|
List<TimeOffRequest> requests = requestService.findByEmployeeAndCategory(employeeId, selectedCategory);
|
||||||
if (vacation != null) {
|
if (vacation != null) {
|
||||||
TimeOffRequest requestWithBalance = requests.stream()
|
TimeOffRequest requestWithBalance = requests.stream()
|
||||||
.filter(request -> request.getDaysBalance() > 0
|
.filter(request -> request.getDaysBalance() > 0 && request.getState() != TimeOffRequestStatus.EXPIRED)
|
||||||
&& request.getState() != TimeOffRequestStatus.EXPIRED)
|
|
||||||
.max(Comparator.comparing(TimeOffRequest::getStartDate))
|
.max(Comparator.comparing(TimeOffRequest::getStartDate))
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
if (requestWithBalance != null) {
|
if (requestWithBalance != null) {
|
||||||
@ -215,8 +214,7 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
endDate = null;
|
endDate = null;
|
||||||
|
|
||||||
UUID employeeId = employee.getId();
|
UUID employeeId = employee.getId();
|
||||||
List<TimeOffRequest> previousRequests
|
List<TimeOffRequest> previousRequests = requestService.findByEmployeeAndCategory(employeeId, vacation.getCategory());
|
||||||
= requestService.findByEmployeeAndCategory(employeeId, vacation.getCategory());
|
|
||||||
|
|
||||||
int startYear;
|
int startYear;
|
||||||
if (previousRequests.isEmpty()) {
|
if (previousRequests.isEmpty()) {
|
||||||
@ -238,17 +236,11 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (vacation.getMonthOfYear() != null && vacation.getDayOfMonth() != null) {
|
if (vacation.getMonthOfYear() != null && vacation.getDayOfMonth() != null) {
|
||||||
startDate = LocalDate.of(
|
startDate = LocalDate.of(startYear, vacation.getMonthOfYear().intValue(), vacation.getDayOfMonth().intValue());
|
||||||
startYear,
|
|
||||||
vacation.getMonthOfYear().intValue(),
|
|
||||||
vacation.getDayOfMonth().intValue());
|
|
||||||
endDate = startDate.plusDays(vacation.getExpiration().intValue() - 1);
|
endDate = startDate.plusDays(vacation.getExpiration().intValue() - 1);
|
||||||
} else {
|
} else {
|
||||||
if (vacation.getCategory() == TimeOffRequestType.BIRTHDAY && employee.getBirthday() != null) {
|
if (vacation.getCategory() == TimeOffRequestType.BIRTHDAY && employee.getBirthday() != null) {
|
||||||
startDate = LocalDate.of(
|
startDate = LocalDate.of(startYear, employee.getBirthday().getMonth(), employee.getBirthday().getDayOfMonth());
|
||||||
startYear,
|
|
||||||
employee.getBirthday().getMonth(),
|
|
||||||
employee.getBirthday().getDayOfMonth());
|
|
||||||
endDate = startDate.plusDays(vacation.getExpiration().intValue() - 1);
|
endDate = startDate.plusDays(vacation.getExpiration().intValue() - 1);
|
||||||
} else if (vacation.getCategory() == TimeOffRequestType.HEALTH_PERMIT) {
|
} else if (vacation.getCategory() == TimeOffRequestType.HEALTH_PERMIT) {
|
||||||
startDate = LocalDate.now();
|
startDate = LocalDate.now();
|
||||||
|
@ -4,7 +4,6 @@ import com.primefactorsolutions.model.*;
|
|||||||
import com.primefactorsolutions.service.EmployeeService;
|
import com.primefactorsolutions.service.EmployeeService;
|
||||||
import com.primefactorsolutions.service.TeamService;
|
import com.primefactorsolutions.service.TeamService;
|
||||||
import com.primefactorsolutions.service.TimeOffRequestService;
|
import com.primefactorsolutions.service.TimeOffRequestService;
|
||||||
import com.primefactorsolutions.service.VacationService;
|
|
||||||
import com.vaadin.flow.component.button.Button;
|
import com.vaadin.flow.component.button.Button;
|
||||||
import com.vaadin.flow.component.combobox.ComboBox;
|
import com.vaadin.flow.component.combobox.ComboBox;
|
||||||
import com.vaadin.flow.component.html.Main;
|
import com.vaadin.flow.component.html.Main;
|
||||||
@ -30,8 +29,7 @@ public class RequestsListView extends Main {
|
|||||||
private final TimeOffRequestService requestService;
|
private final TimeOffRequestService requestService;
|
||||||
private final EmployeeService employeeService;
|
private final EmployeeService employeeService;
|
||||||
private final TeamService teamService;
|
private final TeamService teamService;
|
||||||
private final VacationService vacationService;
|
private final PagingGrid<TimeOffRequest> requestGrid = new PagingGrid<>();
|
||||||
private final PagingGrid<Employee> requestGrid = new PagingGrid<>();
|
|
||||||
|
|
||||||
private List<Employee> employees = Collections.emptyList();
|
private List<Employee> employees = Collections.emptyList();
|
||||||
private ComboBox<Employee> employeeFilter;
|
private ComboBox<Employee> employeeFilter;
|
||||||
@ -43,12 +41,10 @@ public class RequestsListView extends Main {
|
|||||||
|
|
||||||
public RequestsListView(final TimeOffRequestService requestService,
|
public RequestsListView(final TimeOffRequestService requestService,
|
||||||
final EmployeeService employeeService,
|
final EmployeeService employeeService,
|
||||||
final TeamService teamService,
|
final TeamService teamService) {
|
||||||
final VacationService vacationService) {
|
|
||||||
this.requestService = requestService;
|
this.requestService = requestService;
|
||||||
this.employeeService = employeeService;
|
this.employeeService = employeeService;
|
||||||
this.teamService = teamService;
|
this.teamService = teamService;
|
||||||
this.vacationService = vacationService;
|
|
||||||
this.employees = employeeService.findAllEmployees();
|
this.employees = employeeService.findAllEmployees();
|
||||||
initializeView();
|
initializeView();
|
||||||
refreshGeneralRequestGrid(null, null, null, null);
|
refreshGeneralRequestGrid(null, null, null, null);
|
||||||
@ -64,6 +60,7 @@ public class RequestsListView extends Main {
|
|||||||
private void setupFilters() {
|
private void setupFilters() {
|
||||||
add(createEmployeeFilter());
|
add(createEmployeeFilter());
|
||||||
add(createTeamFilter());
|
add(createTeamFilter());
|
||||||
|
add(createCategoryFilter());
|
||||||
add(createStateFilter());
|
add(createStateFilter());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,14 +68,16 @@ public class RequestsListView extends Main {
|
|||||||
requestGrid.addColumn(this::getEmployeeFullName).setHeader("Employee");
|
requestGrid.addColumn(this::getEmployeeFullName).setHeader("Employee");
|
||||||
requestGrid.addColumn(this::getTeamName).setHeader("Team");
|
requestGrid.addColumn(this::getTeamName).setHeader("Team");
|
||||||
requestGrid.addColumn(this::getEmployeeStatus).setHeader("Employee State");
|
requestGrid.addColumn(this::getEmployeeStatus).setHeader("Employee State");
|
||||||
requestGrid.addColumn(this::getGeneralTotal).setHeader("General Total");
|
requestGrid.addColumn(this::getCategory).setHeader("Category");
|
||||||
|
requestGrid.addColumn(this::getState).setHeader("Request Status");
|
||||||
|
requestGrid.addColumn(this::getDaysBalance).setHeader("Balance");
|
||||||
|
|
||||||
requestGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM);
|
requestGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM);
|
||||||
requestGrid.setPageSize(5);
|
requestGrid.setPageSize(5);
|
||||||
requestGrid.asSingleSelect().addValueChangeListener(event -> {
|
requestGrid.asSingleSelect().addValueChangeListener(event -> {
|
||||||
Employee selectedRequest = event.getValue();
|
TimeOffRequest selectedRequest = event.getValue();
|
||||||
if (selectedRequest != null) {
|
if (selectedRequest != null) {
|
||||||
selectedEmployeeId = selectedRequest.getId();
|
selectedEmployeeId = selectedRequest.getEmployee().getId();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -101,50 +100,63 @@ public class RequestsListView extends Main {
|
|||||||
final Status state) {
|
final Status state) {
|
||||||
requestGrid.setPagingDataProvider((page, pageSize) -> {
|
requestGrid.setPagingDataProvider((page, pageSize) -> {
|
||||||
int start = (int) (page * requestGrid.getPageSize());
|
int start = (int) (page * requestGrid.getPageSize());
|
||||||
return fetchFilteredEmployees(start, pageSize, employee, team, state);
|
return fetchFilteredEmployees(start, pageSize, employee, team, category, state);
|
||||||
});
|
});
|
||||||
requestGrid.getDataProvider().refreshAll();
|
requestGrid.getDataProvider().refreshAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Employee> fetchFilteredEmployees(final int start,
|
private List<TimeOffRequest> fetchFilteredEmployees(final int start,
|
||||||
final int pageSize,
|
final int pageSize,
|
||||||
final Employee employee,
|
final Employee employee,
|
||||||
final Team team,
|
final Team team,
|
||||||
|
final TimeOffRequestType category,
|
||||||
final Status employeeState) {
|
final Status employeeState) {
|
||||||
List<Employee> filteredEmployees = employeeService.findAllEmployees();
|
List<TimeOffRequest> filteredRequests = requestService.findAllTimeOffRequests();
|
||||||
|
|
||||||
if (employee != null && !"ALL".equals(employee.getFirstName())) {
|
if (employee != null && !"ALL".equals(employee.getFirstName())) {
|
||||||
filteredEmployees = filteredEmployees.stream()
|
filteredRequests = filteredRequests.stream()
|
||||||
.filter(emp -> emp.getId().equals(employee.getId()))
|
.filter(emp -> emp.getEmployee().getId().equals(employee.getId()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (team != null && !"ALL".equals(team.getName())) {
|
if (team != null && !"ALL".equals(team.getName())) {
|
||||||
filteredEmployees = filteredEmployees.stream()
|
filteredRequests = filteredRequests.stream()
|
||||||
.filter(emp -> emp.getTeam() != null && emp.getTeam().getId().equals(team.getId()))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (employeeState != null && employeeState != Status.ALL) {
|
|
||||||
filteredEmployees = filteredEmployees.stream()
|
|
||||||
.filter(emp -> {
|
.filter(emp -> {
|
||||||
Optional<TimeOffRequest> request = requestService
|
Team empTeam = emp.getEmployee().getTeam();
|
||||||
.findByEmployeeAndState(emp.getId(), TimeOffRequestStatus.TAKEN);
|
return empTeam != null && empTeam.getId().equals(team.getId());
|
||||||
return employeeState == Status.IDLE ? request.isPresent() : request.isEmpty();
|
|
||||||
})
|
})
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
int end = Math.min(start + pageSize, filteredEmployees.size());
|
if (category != null && category != TimeOffRequestType.values()[0]) {
|
||||||
return filteredEmployees.subList(start, end);
|
filteredRequests = filteredRequests.stream()
|
||||||
|
.filter(emp -> emp.getCategory().equals(category))
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getEmployeeFullName(final Employee employee) {
|
if (employeeState != null && employeeState != Status.ALL) {
|
||||||
|
filteredRequests = filteredRequests.stream()
|
||||||
|
.filter(emp -> employeeState == Status.IDLE
|
||||||
|
? emp.getState().equals(TimeOffRequestStatus.IN_USE)
|
||||||
|
: !emp.getState().equals(TimeOffRequestStatus.IN_USE))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
int end = Math.min(start + pageSize, filteredRequests.size());
|
||||||
|
return filteredRequests.subList(start, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getEmployeeFullName(final TimeOffRequest request) {
|
||||||
|
Employee employee = request.getEmployee();
|
||||||
|
return getEmployeeFullNameLabel(employee);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getEmployeeFullNameLabel(final Employee employee) {
|
||||||
return "ALL".equals(employee.getFirstName()) ? "ALL" : employee.getFirstName() + " " + employee.getLastName();
|
return "ALL".equals(employee.getFirstName()) ? "ALL" : employee.getFirstName() + " " + employee.getLastName();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTeamName(final Employee employee) {
|
private String getTeamName(final TimeOffRequest request) {
|
||||||
Team team = employee.getTeam();
|
Team team = request.getEmployee().getTeam();
|
||||||
return team != null ? team.getName() : "Unassigned";
|
return team != null ? team.getName() : "Unassigned";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,38 +164,21 @@ public class RequestsListView extends Main {
|
|||||||
return "ALL".equals(team.getName()) ? "ALL" : team.getName();
|
return "ALL".equals(team.getName()) ? "ALL" : team.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getEmployeeStatus(final Employee employee) {
|
|
||||||
Optional<TimeOffRequest> activeRequest = requestService
|
private String getEmployeeStatus(final TimeOffRequest request) {
|
||||||
.findByEmployeeAndState(employee.getId(), TimeOffRequestStatus.TAKEN);
|
return request.getState() == TimeOffRequestStatus.IN_USE ? "IDLE" : "ACTIVE";
|
||||||
return activeRequest.isPresent() ? "IDLE" : "ACTIVE";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getGeneralTotal(final Employee employee) {
|
private String getCategory(final TimeOffRequest request) {
|
||||||
List<TimeOffRequest> employeeRequests = requestService.findRequestsByEmployeeId(employee.getId());
|
return request.getCategory().toString();
|
||||||
List<Vacation> vacations = vacationService.findVacations();
|
}
|
||||||
double totalUtilized = employeeRequests.stream()
|
|
||||||
.filter(Objects::nonNull)
|
private String getState(final TimeOffRequest request) {
|
||||||
.mapToDouble(request -> {
|
return request.getState().toString();
|
||||||
Double daysBalance = request.getAvailableDays();
|
}
|
||||||
return daysBalance != null ? daysBalance : 0.0;
|
|
||||||
})
|
private String getDaysBalance(final TimeOffRequest request) {
|
||||||
.sum();
|
return request.getDaysBalance().toString();
|
||||||
double totalUnused = employeeRequests.stream()
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.mapToDouble(request -> {
|
|
||||||
Double daysBalance = request.getDaysBalance();
|
|
||||||
return daysBalance != null ? daysBalance : 0.0;
|
|
||||||
})
|
|
||||||
.sum();
|
|
||||||
double totalAvailable = vacations.stream()
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.mapToDouble(request -> {
|
|
||||||
Double daysBalance = request.getDuration();
|
|
||||||
return daysBalance != null ? daysBalance : 0.0;
|
|
||||||
})
|
|
||||||
.sum();
|
|
||||||
double generalTotal = (totalAvailable - totalUtilized) + totalUnused;
|
|
||||||
return String.valueOf(generalTotal);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ComboBox<Employee> createEmployeeFilter() {
|
private ComboBox<Employee> createEmployeeFilter() {
|
||||||
@ -191,7 +186,7 @@ public class RequestsListView extends Main {
|
|||||||
List<Employee> employees = new ArrayList<>(employeeService.findAllEmployees());
|
List<Employee> employees = new ArrayList<>(employeeService.findAllEmployees());
|
||||||
employees.addFirst(createAllEmployeesOption());
|
employees.addFirst(createAllEmployeesOption());
|
||||||
employeeFilter.setItems(employees);
|
employeeFilter.setItems(employees);
|
||||||
employeeFilter.setItemLabelGenerator(this::getEmployeeFullName);
|
employeeFilter.setItemLabelGenerator(this::getEmployeeFullNameLabel);
|
||||||
employeeFilter.setValue(employees.getFirst());
|
employeeFilter.setValue(employees.getFirst());
|
||||||
employeeFilter.addValueChangeListener(event ->
|
employeeFilter.addValueChangeListener(event ->
|
||||||
refreshGeneralRequestGrid(
|
refreshGeneralRequestGrid(
|
||||||
@ -222,6 +217,21 @@ public class RequestsListView extends Main {
|
|||||||
return teamFilter;
|
return teamFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ComboBox<TimeOffRequestType> createCategoryFilter() {
|
||||||
|
categoryFilter = new ComboBox<>("Category");
|
||||||
|
categoryFilter.setItems(TimeOffRequestType.values());
|
||||||
|
categoryFilter.setValue(TimeOffRequestType.values()[0]);
|
||||||
|
categoryFilter.addValueChangeListener(event ->
|
||||||
|
refreshGeneralRequestGrid(
|
||||||
|
employeeFilter.getValue(),
|
||||||
|
teamFilter.getValue(),
|
||||||
|
event.getValue(),
|
||||||
|
stateFilter.getValue()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return categoryFilter;
|
||||||
|
}
|
||||||
|
|
||||||
private ComboBox<Status> createStateFilter() {
|
private ComboBox<Status> createStateFilter() {
|
||||||
stateFilter = new ComboBox<>("Employee State");
|
stateFilter = new ComboBox<>("Employee State");
|
||||||
stateFilter.setItems(Status.values());
|
stateFilter.setItems(Status.values());
|
||||||
|
Loading…
Reference in New Issue
Block a user