Merge pull request 'Observaciones' (#86) from Observaciones into Detalles
Reviewed-on: #86
This commit is contained in:
commit
8616cd0f28
@ -62,6 +62,7 @@ public class EmployeeService {
|
|||||||
public List<Employee> findEmployees(
|
public List<Employee> findEmployees(
|
||||||
final int start, final int pageSize, final String sortProperty, final boolean asc) {
|
final int start, final int pageSize, final String sortProperty, final boolean asc) {
|
||||||
List<Employee> employees = employeeRepository.findAll();
|
List<Employee> employees = employeeRepository.findAll();
|
||||||
|
Collections.reverse(employees);
|
||||||
|
|
||||||
int end = Math.min(start + pageSize, employees.size());
|
int end = Math.min(start + pageSize, employees.size());
|
||||||
employees.sort(new BeanComparator<>(sortProperty));
|
employees.sort(new BeanComparator<>(sortProperty));
|
||||||
@ -75,6 +76,7 @@ public class EmployeeService {
|
|||||||
|
|
||||||
public List<Employee> findEmployees(final int start, final int pageSize) {
|
public List<Employee> findEmployees(final int start, final int pageSize) {
|
||||||
List<Employee> employees = employeeRepository.findAll();
|
List<Employee> employees = employeeRepository.findAll();
|
||||||
|
Collections.reverse(employees);
|
||||||
|
|
||||||
int end = Math.min(start + pageSize, employees.size());
|
int end = Math.min(start + pageSize, employees.size());
|
||||||
return employees.subList(start, end);
|
return employees.subList(start, end);
|
||||||
@ -124,7 +126,9 @@ public class EmployeeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<Employee> findAllEmployees() {
|
public List<Employee> findAllEmployees() {
|
||||||
return employeeRepository.findAll();
|
List<Employee> employees = employeeRepository.findAll();
|
||||||
|
Collections.reverse(employees);
|
||||||
|
return employees;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Employee> findEmployeesByTeam(final String teamName) {
|
public List<Employee> findEmployeesByTeam(final String teamName) {
|
||||||
|
@ -8,6 +8,7 @@ import com.primefactorsolutions.service.EmployeeService;
|
|||||||
import com.vaadin.flow.component.Component;
|
import com.vaadin.flow.component.Component;
|
||||||
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.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.textfield.TextField;
|
import com.vaadin.flow.component.textfield.TextField;
|
||||||
@ -42,6 +43,7 @@ public class DocumentView extends BeanValidationForm<Document> implements HasUrl
|
|||||||
private final TextField fileName = new TextField("Nombre del documento");
|
private final TextField fileName = new TextField("Nombre del documento");
|
||||||
private final ComboBox<DocumentType> documentType = new ComboBox<>("Tipo de documento");
|
private final ComboBox<DocumentType> documentType = new ComboBox<>("Tipo de documento");
|
||||||
private final ComboBox<Employee> employeeComboBox = new ComboBox<>("Empleado");
|
private final ComboBox<Employee> employeeComboBox = new ComboBox<>("Empleado");
|
||||||
|
private final Span pdfOnlyMessage = new Span("Únicamente se permite la carga de archivos en formato PDF.");
|
||||||
private final MemoryBuffer buffer = new MemoryBuffer();
|
private final MemoryBuffer buffer = new MemoryBuffer();
|
||||||
private final Upload uploadButton = new Upload(buffer);
|
private final Upload uploadButton = new Upload(buffer);
|
||||||
private final DocumentService documentService;
|
private final DocumentService documentService;
|
||||||
@ -51,7 +53,6 @@ public class DocumentView extends BeanValidationForm<Document> implements HasUrl
|
|||||||
private Button saveButton;
|
private Button saveButton;
|
||||||
private Button viewDocumentButton;
|
private Button viewDocumentButton;
|
||||||
|
|
||||||
|
|
||||||
public DocumentView(final DocumentService documentService,
|
public DocumentView(final DocumentService documentService,
|
||||||
final EmployeeService employeeService,
|
final EmployeeService employeeService,
|
||||||
final AuthenticationContext authContext) {
|
final AuthenticationContext authContext) {
|
||||||
@ -268,6 +269,6 @@ public class DocumentView extends BeanValidationForm<Document> implements HasUrl
|
|||||||
HorizontalLayout buttonLayout = new HorizontalLayout();
|
HorizontalLayout buttonLayout = new HorizontalLayout();
|
||||||
buttonLayout.add(uploadButton, createViewDocumentButton());
|
buttonLayout.add(uploadButton, createViewDocumentButton());
|
||||||
buttonLayout.setSpacing(true);
|
buttonLayout.setSpacing(true);
|
||||||
return List.of(fileName, documentType, employeeComboBox, buttonLayout, createCloseButton());
|
return List.of(fileName, documentType, employeeComboBox, pdfOnlyMessage, buttonLayout, createCloseButton());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,8 @@ import com.primefactorsolutions.views.util.MenuBarUtils;
|
|||||||
import com.vaadin.flow.component.ClickEvent;
|
import com.vaadin.flow.component.ClickEvent;
|
||||||
import com.vaadin.flow.component.Component;
|
import com.vaadin.flow.component.Component;
|
||||||
import com.vaadin.flow.component.ComponentEventListener;
|
import com.vaadin.flow.component.ComponentEventListener;
|
||||||
|
import com.vaadin.flow.component.UI;
|
||||||
|
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.contextmenu.MenuItem;
|
import com.vaadin.flow.component.contextmenu.MenuItem;
|
||||||
import com.vaadin.flow.component.icon.VaadinIcon;
|
import com.vaadin.flow.component.icon.VaadinIcon;
|
||||||
@ -17,11 +19,23 @@ import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
|||||||
import com.vaadin.flow.function.ValueProvider;
|
import com.vaadin.flow.function.ValueProvider;
|
||||||
import com.vaadin.flow.router.PageTitle;
|
import com.vaadin.flow.router.PageTitle;
|
||||||
import com.vaadin.flow.router.Route;
|
import com.vaadin.flow.router.Route;
|
||||||
|
import com.vaadin.flow.server.StreamRegistration;
|
||||||
|
import com.vaadin.flow.server.StreamResource;
|
||||||
import com.vaadin.flow.spring.annotation.SpringComponent;
|
import com.vaadin.flow.spring.annotation.SpringComponent;
|
||||||
import jakarta.annotation.security.PermitAll;
|
import jakarta.annotation.security.PermitAll;
|
||||||
|
import org.apache.poi.ss.usermodel.Cell;
|
||||||
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
|
import org.apache.poi.ss.usermodel.Sheet;
|
||||||
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.vaadin.firitin.components.grid.PagingGrid;
|
import org.vaadin.firitin.components.grid.PagingGrid;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.UncheckedIOException;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -54,6 +68,8 @@ public class PendingRequestsListView extends BaseView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initializeView() {
|
private void initializeView() {
|
||||||
|
Button downloadButton = new Button("Descargar reporte de rechazos", event -> downloadReport());
|
||||||
|
getCurrentPageLayout().add(downloadButton);
|
||||||
setupFilters();
|
setupFilters();
|
||||||
setupPendingRequestsGrid();
|
setupPendingRequestsGrid();
|
||||||
}
|
}
|
||||||
@ -221,4 +237,50 @@ public class PendingRequestsListView extends BaseView {
|
|||||||
allTeamsOption.setName("TODOS");
|
allTeamsOption.setName("TODOS");
|
||||||
return allTeamsOption;
|
return allTeamsOption;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void downloadReport() {
|
||||||
|
StreamResource resource = generateGeneralVacationReport();
|
||||||
|
getUI().ifPresent(ui -> openDocumentStream(resource, ui));
|
||||||
|
}
|
||||||
|
|
||||||
|
private StreamResource generateGeneralVacationReport() {
|
||||||
|
List<TimeOffRequest> requests = requestService.findAllTimeOffRequests().stream()
|
||||||
|
.filter(request -> request.getState() == TimeOffRequestStatus.RECHAZADO)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
ByteArrayInputStream excelStream = generateExcelReport(requests);
|
||||||
|
return new StreamResource("reporte_de_solicitudes_rechazadas_" + LocalDate.now() + ".xlsx",
|
||||||
|
() -> excelStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openDocumentStream(final StreamResource resource, final UI ui) {
|
||||||
|
StreamRegistration registration = ui.getSession().getResourceRegistry().registerResource(resource);
|
||||||
|
ui.getPage().open(registration.getResourceUri().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private ByteArrayInputStream generateExcelReport(final List<TimeOffRequest> requests) {
|
||||||
|
try (Workbook workbook = new XSSFWorkbook()) {
|
||||||
|
Sheet sheet = workbook.createSheet("REPORTE_DE_SOLICITUDES_DE_VACACIONES_RECHAZADAS");
|
||||||
|
Row headerRow = sheet.createRow(0);
|
||||||
|
|
||||||
|
String[] headers = {"Empleado", "Categoria", "Observaciones"};
|
||||||
|
for (int i = 0; i < headers.length; i++) {
|
||||||
|
Cell cell = headerRow.createCell(i);
|
||||||
|
cell.setCellValue(headers[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
int rowIndex = 1;
|
||||||
|
for (TimeOffRequest request : requests) {
|
||||||
|
Row row = sheet.createRow(rowIndex++);
|
||||||
|
row.createCell(0).setCellValue(getEmployeeFullName(request));
|
||||||
|
row.createCell(1).setCellValue(getCategory(request));
|
||||||
|
}
|
||||||
|
|
||||||
|
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
|
||||||
|
workbook.write(out);
|
||||||
|
return new ByteArrayInputStream(out.toByteArray());
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new UncheckedIOException("Error al generar el archivo Excel", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -40,6 +40,7 @@ import java.io.IOException;
|
|||||||
import java.io.UncheckedIOException;
|
import java.io.UncheckedIOException;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.Period;
|
import java.time.Period;
|
||||||
|
import java.time.Year;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -61,6 +62,10 @@ public class RequestEmployeeView extends BaseView implements HasUrlParameter<Str
|
|||||||
private ComboBox<TimeOffRequestType> categoryFilter;
|
private ComboBox<TimeOffRequestType> categoryFilter;
|
||||||
private ComboBox<TimeOffRequestStatus> stateFilter;
|
private ComboBox<TimeOffRequestStatus> stateFilter;
|
||||||
private UUID employeeId;
|
private UUID employeeId;
|
||||||
|
private double remainingHolidayDays;
|
||||||
|
private double remainingPersonalDays;
|
||||||
|
private double remainingVacationDays;
|
||||||
|
|
||||||
|
|
||||||
public RequestEmployeeView(final TimeOffRequestService requestService,
|
public RequestEmployeeView(final TimeOffRequestService requestService,
|
||||||
final EmployeeService employeeService,
|
final EmployeeService employeeService,
|
||||||
@ -177,20 +182,20 @@ public class RequestEmployeeView extends BaseView implements HasUrlParameter<Str
|
|||||||
double utilizedFixedAndMovableHolidays = calculateHolidayUtilizedDays(currentYear);
|
double utilizedFixedAndMovableHolidays = calculateHolidayUtilizedDays(currentYear);
|
||||||
double utilizedPersonalDays = calculatePersonalDaysUtilized(isMale, currentYear);
|
double utilizedPersonalDays = calculatePersonalDaysUtilized(isMale, currentYear);
|
||||||
|
|
||||||
double remainingHolidayDays = calculateRemainingHolidayDays(
|
remainingHolidayDays = calculateRemainingHolidayDays(
|
||||||
totalFixedAndMovableHolidays,
|
totalFixedAndMovableHolidays,
|
||||||
utilizedFixedAndMovableHolidays,
|
utilizedFixedAndMovableHolidays,
|
||||||
employee.getDateOfExit(),
|
employee.getDateOfExit(),
|
||||||
currentDate
|
currentDate
|
||||||
);
|
);
|
||||||
double remainingPersonalDays = calculateRemainingPersonalDays(
|
remainingPersonalDays = calculateRemainingPersonalDays(
|
||||||
totalPersonalDays,
|
totalPersonalDays,
|
||||||
utilizedPersonalDays,
|
utilizedPersonalDays,
|
||||||
healthLicence,
|
healthLicence,
|
||||||
employee.getDateOfExit(),
|
employee.getDateOfExit(),
|
||||||
currentDate
|
currentDate
|
||||||
);
|
);
|
||||||
double remainingVacationDays = calculateRemainingVacationDays(
|
remainingVacationDays = calculateRemainingVacationDays(
|
||||||
totalVacationCurrentDays,
|
totalVacationCurrentDays,
|
||||||
totalVacationPreviousDays,
|
totalVacationPreviousDays,
|
||||||
employee.getDateOfExit(),
|
employee.getDateOfExit(),
|
||||||
@ -468,7 +473,14 @@ public class RequestEmployeeView extends BaseView implements HasUrlParameter<Str
|
|||||||
try (PDDocument document = new PDDocument(); ByteArrayOutputStream out = new ByteArrayOutputStream()) {
|
try (PDDocument document = new PDDocument(); ByteArrayOutputStream out = new ByteArrayOutputStream()) {
|
||||||
PDPage page = new PDPage();
|
PDPage page = new PDPage();
|
||||||
document.addPage(page);
|
document.addPage(page);
|
||||||
|
|
||||||
Employee employee = employeeService.getEmployee(employeeId);
|
Employee employee = employeeService.getEmployee(employeeId);
|
||||||
|
List<TimeOffRequest> filteredRequests = requests.stream()
|
||||||
|
.filter(request ->
|
||||||
|
(request.getStartDate() == null || Year.from(request.getStartDate()).equals(Year.now())) ||
|
||||||
|
request.getCategory() == TimeOffRequestType.VACACION_GESTION_ACTUAL ||
|
||||||
|
request.getCategory() == TimeOffRequestType.VACACION_GESTION_ANTERIOR)
|
||||||
|
.toList();
|
||||||
|
|
||||||
PDPageContentStream contentStream = null;
|
PDPageContentStream contentStream = null;
|
||||||
try {
|
try {
|
||||||
@ -513,7 +525,7 @@ public class RequestEmployeeView extends BaseView implements HasUrlParameter<Str
|
|||||||
|
|
||||||
contentStream.setFont(PDType1Font.TIMES_ROMAN, 10);
|
contentStream.setFont(PDType1Font.TIMES_ROMAN, 10);
|
||||||
float currentY = tableTopY - cellHeight;
|
float currentY = tableTopY - cellHeight;
|
||||||
for (TimeOffRequest request : requests) {
|
for (TimeOffRequest request : filteredRequests) {
|
||||||
String startDate = getDateString(request.getStartDate());
|
String startDate = getDateString(request.getStartDate());
|
||||||
String endDate = getDateString(request.getEndDate());
|
String endDate = getDateString(request.getEndDate());
|
||||||
|
|
||||||
@ -545,6 +557,30 @@ public class RequestEmployeeView extends BaseView implements HasUrlParameter<Str
|
|||||||
currentY = 750;
|
currentY = 750;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentY -= 30;
|
||||||
|
|
||||||
|
if (currentY < 80) {
|
||||||
|
contentStream.close();
|
||||||
|
page = new PDPage();
|
||||||
|
document.addPage(page);
|
||||||
|
contentStream = new PDPageContentStream(document, page);
|
||||||
|
currentY = 750;
|
||||||
|
}
|
||||||
|
|
||||||
|
contentStream.setFont(PDType1Font.TIMES_ROMAN, 14);
|
||||||
|
contentStream.beginText();
|
||||||
|
contentStream.newLineAtOffset(50, currentY - 20);
|
||||||
|
contentStream.showText("Total feriados fijos y movibles: " + remainingHolidayDays);
|
||||||
|
contentStream.newLineAtOffset(0, -20);
|
||||||
|
contentStream.showText("Total días libres personales: " + remainingPersonalDays);
|
||||||
|
contentStream.newLineAtOffset(0, -20);
|
||||||
|
contentStream.showText("Total vacaciones pendientes de uso: " + remainingVacationDays);
|
||||||
|
contentStream.newLineAtOffset(0, -20);
|
||||||
|
contentStream.showText("TOTAL GENERAL DE DÍAS DISPONIBLES: " +
|
||||||
|
(remainingHolidayDays + remainingPersonalDays + remainingVacationDays));
|
||||||
|
contentStream.endText();
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
if (contentStream != null) {
|
if (contentStream != null) {
|
||||||
contentStream.close();
|
contentStream.close();
|
||||||
@ -617,7 +653,7 @@ public class RequestEmployeeView extends BaseView implements HasUrlParameter<Str
|
|||||||
addComponentAsFirst(new H3("Nombre del empleado: " + employeeName));
|
addComponentAsFirst(new H3("Nombre del empleado: " + employeeName));
|
||||||
addComponentAtIndex(1, new H3("Equipo: " + employeeTeam));
|
addComponentAtIndex(1, new H3("Equipo: " + employeeTeam));
|
||||||
if (dateOfExit != null) {
|
if (dateOfExit != null) {
|
||||||
addComponentAtIndex(2, new H3("Descontado a cero en fecha " + dateOfExit + " por pago de finiquito."));
|
addComponentAtIndex(2, new H3("Descontado a cero en fecha " + dateOfExit + " por pago de finiquito incluidas duodecima."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@ public class RequestsListView extends BaseView {
|
|||||||
|
|
||||||
private ComboBox<Employee> employeeFilter;
|
private ComboBox<Employee> employeeFilter;
|
||||||
private ComboBox<Team> teamFilter;
|
private ComboBox<Team> teamFilter;
|
||||||
|
private ComboBox<TimeOffRequestType> categoryFilter;
|
||||||
private ComboBox<Status> stateFilter;
|
private ComboBox<Status> stateFilter;
|
||||||
|
|
||||||
public RequestsListView(final TimeOffRequestService requestService,
|
public RequestsListView(final TimeOffRequestService requestService,
|
||||||
@ -66,7 +67,7 @@ public class RequestsListView extends BaseView {
|
|||||||
this.teamService = teamService;
|
this.teamService = teamService;
|
||||||
this.vacationService = vacationService;
|
this.vacationService = vacationService;
|
||||||
initializeView();
|
initializeView();
|
||||||
refreshGeneralRequestGrid(null, null, null);
|
refreshGeneralRequestGrid(null, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeView() {
|
private void initializeView() {
|
||||||
@ -82,6 +83,7 @@ public class RequestsListView extends BaseView {
|
|||||||
final HorizontalLayout hl = new HorizontalLayout();
|
final HorizontalLayout hl = new HorizontalLayout();
|
||||||
hl.add(createEmployeeFilter());
|
hl.add(createEmployeeFilter());
|
||||||
hl.add(createTeamFilter());
|
hl.add(createTeamFilter());
|
||||||
|
hl.add(createCategoryFilter());
|
||||||
hl.add(createStateFilter());
|
hl.add(createStateFilter());
|
||||||
getCurrentPageLayout().add(hl);
|
getCurrentPageLayout().add(hl);
|
||||||
}
|
}
|
||||||
@ -90,6 +92,7 @@ public class RequestsListView extends BaseView {
|
|||||||
requestGrid.addColumn(this::getEmployeeFullName).setHeader("Empleado");
|
requestGrid.addColumn(this::getEmployeeFullName).setHeader("Empleado");
|
||||||
requestGrid.addColumn(this::getTeamName).setHeader("Equipo");
|
requestGrid.addColumn(this::getTeamName).setHeader("Equipo");
|
||||||
requestGrid.addColumn(this::getEmployeeStatus).setHeader("Estado del empleado");
|
requestGrid.addColumn(this::getEmployeeStatus).setHeader("Estado del empleado");
|
||||||
|
requestGrid.addColumn(this::getCategory).setHeader("Categoria");
|
||||||
requestGrid.addColumn(this::getGeneralTotal).setHeader("Total general");
|
requestGrid.addColumn(this::getGeneralTotal).setHeader("Total general");
|
||||||
requestGrid.addComponentColumn((ValueProvider<Employee, Component>) employee -> {
|
requestGrid.addComponentColumn((ValueProvider<Employee, Component>) employee -> {
|
||||||
final MenuBar menuBar = new MenuBar();
|
final MenuBar menuBar = new MenuBar();
|
||||||
@ -107,10 +110,11 @@ public class RequestsListView extends BaseView {
|
|||||||
|
|
||||||
private void refreshGeneralRequestGrid(final Employee employee,
|
private void refreshGeneralRequestGrid(final Employee employee,
|
||||||
final Team team,
|
final Team team,
|
||||||
|
final TimeOffRequestType category,
|
||||||
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();
|
||||||
}
|
}
|
||||||
@ -119,6 +123,7 @@ public class RequestsListView extends BaseView {
|
|||||||
final int pageSize,
|
final int pageSize,
|
||||||
final Employee employee,
|
final Employee employee,
|
||||||
final Team team,
|
final Team team,
|
||||||
|
final TimeOffRequestType category,
|
||||||
final Status state) {
|
final Status state) {
|
||||||
List<Employee> filteredEmployees = employeeService.findAllEmployees();
|
List<Employee> filteredEmployees = employeeService.findAllEmployees();
|
||||||
|
|
||||||
@ -134,6 +139,16 @@ public class RequestsListView extends BaseView {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (category != null && category != TimeOffRequestType.values()[0]) {
|
||||||
|
filteredEmployees = filteredEmployees.stream()
|
||||||
|
.filter(emp -> {
|
||||||
|
Optional<TimeOffRequest> request = requestService
|
||||||
|
.findByEmployeeAndState(emp.getId(), TimeOffRequestStatus.EN_USO);
|
||||||
|
return request.isPresent() && request.get().getCategory() == category;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
if (state != null && state != Status.TODOS) {
|
if (state != null && state != Status.TODOS) {
|
||||||
filteredEmployees = filteredEmployees.stream()
|
filteredEmployees = filteredEmployees.stream()
|
||||||
.filter(emp -> {
|
.filter(emp -> {
|
||||||
@ -168,6 +183,12 @@ public class RequestsListView extends BaseView {
|
|||||||
return activeRequest.isPresent() ? "EN_DESCANSO" : "EN_FUNCIONES";
|
return activeRequest.isPresent() ? "EN_DESCANSO" : "EN_FUNCIONES";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getCategory(final Employee employee) {
|
||||||
|
Optional<TimeOffRequest> activeRequest = requestService
|
||||||
|
.findByEmployeeAndState(employee.getId(), TimeOffRequestStatus.EN_USO);
|
||||||
|
return activeRequest.map(request -> request.getCategory().toString()).orElse("");
|
||||||
|
}
|
||||||
|
|
||||||
private String getGeneralTotal(final Employee employee) {
|
private String getGeneralTotal(final Employee employee) {
|
||||||
List<TimeOffRequest> employeeRequests = requestService.findRequestsByEmployeeId(employee.getId());
|
List<TimeOffRequest> employeeRequests = requestService.findRequestsByEmployeeId(employee.getId());
|
||||||
List<Vacation> vacations = vacationService.findVacations();
|
List<Vacation> vacations = vacationService.findVacations();
|
||||||
@ -363,6 +384,7 @@ public class RequestsListView extends BaseView {
|
|||||||
refreshGeneralRequestGrid(
|
refreshGeneralRequestGrid(
|
||||||
event.getValue(),
|
event.getValue(),
|
||||||
teamFilter.getValue(),
|
teamFilter.getValue(),
|
||||||
|
categoryFilter.getValue(),
|
||||||
stateFilter.getValue()
|
stateFilter.getValue()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -380,12 +402,28 @@ public class RequestsListView extends BaseView {
|
|||||||
refreshGeneralRequestGrid(
|
refreshGeneralRequestGrid(
|
||||||
employeeFilter.getValue(),
|
employeeFilter.getValue(),
|
||||||
event.getValue(),
|
event.getValue(),
|
||||||
|
categoryFilter.getValue(),
|
||||||
stateFilter.getValue()
|
stateFilter.getValue()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
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<>("Estado del empleado");
|
stateFilter = new ComboBox<>("Estado del empleado");
|
||||||
stateFilter.setItems(Status.values());
|
stateFilter.setItems(Status.values());
|
||||||
@ -394,6 +432,7 @@ public class RequestsListView extends BaseView {
|
|||||||
refreshGeneralRequestGrid(
|
refreshGeneralRequestGrid(
|
||||||
employeeFilter.getValue(),
|
employeeFilter.getValue(),
|
||||||
teamFilter.getValue(),
|
teamFilter.getValue(),
|
||||||
|
categoryFilter.getValue(),
|
||||||
event.getValue()
|
event.getValue()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -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', 20, '2024-11-01', '2022-11-01', '2022-11-30', 20, 0);
|
values ('9e6f12ba-e555-4e7a-b8a6-caa0982bd8e5', 1, '5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 'VACACION_GESTION_ANTERIOR', 'APROBADO', 20, '2024-11-01', '2023-11-01', '2023-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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user