Agregar resumen al reporte de vacaciones del empleado

This commit is contained in:
jesus.pelaez 2024-11-26 23:52:49 -04:00
parent c93b309f43
commit f2b24a26a4

View File

@ -62,6 +62,10 @@ public class RequestEmployeeView extends BaseView implements HasUrlParameter<Str
private ComboBox<TimeOffRequestType> categoryFilter;
private ComboBox<TimeOffRequestStatus> stateFilter;
private UUID employeeId;
private double remainingHolidayDays;
private double remainingPersonalDays;
private double remainingVacationDays;
public RequestEmployeeView(final TimeOffRequestService requestService,
final EmployeeService employeeService,
@ -178,20 +182,20 @@ public class RequestEmployeeView extends BaseView implements HasUrlParameter<Str
double utilizedFixedAndMovableHolidays = calculateHolidayUtilizedDays(currentYear);
double utilizedPersonalDays = calculatePersonalDaysUtilized(isMale, currentYear);
double remainingHolidayDays = calculateRemainingHolidayDays(
remainingHolidayDays = calculateRemainingHolidayDays(
totalFixedAndMovableHolidays,
utilizedFixedAndMovableHolidays,
employee.getDateOfExit(),
currentDate
);
double remainingPersonalDays = calculateRemainingPersonalDays(
remainingPersonalDays = calculateRemainingPersonalDays(
totalPersonalDays,
utilizedPersonalDays,
healthLicence,
employee.getDateOfExit(),
currentDate
);
double remainingVacationDays = calculateRemainingVacationDays(
remainingVacationDays = calculateRemainingVacationDays(
totalVacationCurrentDays,
totalVacationPreviousDays,
employee.getDateOfExit(),
@ -469,7 +473,14 @@ public class RequestEmployeeView extends BaseView implements HasUrlParameter<Str
try (PDDocument document = new PDDocument(); ByteArrayOutputStream out = new ByteArrayOutputStream()) {
PDPage page = new PDPage();
document.addPage(page);
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;
try {
@ -512,13 +523,6 @@ public class RequestEmployeeView extends BaseView implements HasUrlParameter<Str
}
contentStream.stroke();
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();
contentStream.setFont(PDType1Font.TIMES_ROMAN, 10);
float currentY = tableTopY - cellHeight;
for (TimeOffRequest request : filteredRequests) {
@ -553,6 +557,30 @@ public class RequestEmployeeView extends BaseView implements HasUrlParameter<Str
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 {
if (contentStream != null) {
contentStream.close();
@ -625,7 +653,7 @@ public class RequestEmployeeView extends BaseView implements HasUrlParameter<Str
addComponentAsFirst(new H3("Nombre del empleado: " + employeeName));
addComponentAtIndex(1, new H3("Equipo: " + employeeTeam));
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."));
}
}
}