Lista de Vacaciones - Calcular totales de vacaciones
This commit is contained in:
parent
3b085e835b
commit
34940ff794
@ -20,6 +20,7 @@ import com.vaadin.flow.spring.annotation.SpringComponent;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
|
||||
import java.time.Year;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@ -44,7 +45,6 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
|
||||
public RequestEmployeeView(final TimeOffRequestService requestService, final EmployeeService employeeService) {
|
||||
this.requestService = requestService;
|
||||
this.employeeService = employeeService;
|
||||
initializeView();
|
||||
}
|
||||
|
||||
private void initializeView() {
|
||||
@ -97,9 +97,17 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
|
||||
}
|
||||
|
||||
private VerticalLayout createSummaryLayout() {
|
||||
int totalVacations = 15;
|
||||
int totalTimeOff = 2;
|
||||
int totalAvailableDays = totalVacations + totalTimeOff;
|
||||
int currentYear = Year.now().getValue();
|
||||
String yearCategory = "YEAR_" + currentYear;
|
||||
double totalVacations = requests.stream()
|
||||
.filter(req -> req.getCategory().name().equals(yearCategory))
|
||||
.mapToDouble(TimeOffRequest::getAvailableDays)
|
||||
.sum();
|
||||
double totalTimeOff = requests.stream()
|
||||
.filter(req -> !req.getCategory().name().startsWith("YEAR"))
|
||||
.mapToDouble(TimeOffRequest::getDaysBalance)
|
||||
.sum();
|
||||
double totalAvailableDays = totalVacations + totalTimeOff;
|
||||
return new VerticalLayout(
|
||||
new Span("TOTAL HOLIDAYS: " + totalVacations),
|
||||
new Span("TOTAL TIME OFF: " + totalTimeOff),
|
||||
@ -176,6 +184,7 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
|
||||
requests = requestService.findRequestsByEmployeeId(employeeId);
|
||||
setViewTitle(employee.getFirstName() + " " + employee.getLastName(), employee.getTeam().getName());
|
||||
requestGrid.setItems(requests);
|
||||
initializeView();
|
||||
}
|
||||
|
||||
private void setViewTitle(final String employeeName, final String employeeTeam) {
|
||||
|
Loading…
Reference in New Issue
Block a user