fixed bugs
All checks were successful
Builder / Build-Project (push) Successful in 2m57s

This commit is contained in:
alex 2025-01-01 11:17:54 -05:00
parent 118813c8e4
commit 6e87c1795c
11 changed files with 266 additions and 247 deletions

Binary file not shown.

View File

@ -3,7 +3,6 @@ package com.primefactorsolutions.model;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.Year;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.time.temporal.IsoFields; import java.time.temporal.IsoFields;
import java.time.temporal.WeekFields; import java.time.temporal.WeekFields;
@ -40,7 +39,7 @@ public record Week(LocalDate from, LocalDate to) {
private static LocalDate getFirstDayOfWeek(final int weekNumber) { private static LocalDate getFirstDayOfWeek(final int weekNumber) {
return LocalDate return LocalDate
.of(Year.now().getValue(), 2, 1) .now()
.with(WeekFields.of(Locale.US).getFirstDayOfWeek()) .with(WeekFields.of(Locale.US).getFirstDayOfWeek())
.with(WeekFields.of(Locale.US).weekOfWeekBasedYear(), weekNumber); .with(WeekFields.of(Locale.US).weekOfWeekBasedYear(), weekNumber);
} }

View File

@ -9,12 +9,15 @@ import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.spring.security.AuthenticationContext; import com.vaadin.flow.spring.security.AuthenticationContext;
import org.vaadin.firitin.form.BeanValidationForm; import org.vaadin.firitin.form.BeanValidationForm;
import java.io.Serializable;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public abstract class BaseEntityForm<T> extends BeanValidationForm<T> { public abstract class BaseEntityForm<T> extends BeanValidationForm<T> {
private final AuthenticationContext authenticationContext; private final AuthenticationContext authenticationContext;
private Button editButton;
private EditHandler<T> editHandler;
public BaseEntityForm(final AuthenticationContext authenticationContext, final Class<T> entityType) { public BaseEntityForm(final AuthenticationContext authenticationContext, final Class<T> entityType) {
super(entityType); super(entityType);
@ -23,7 +26,26 @@ public abstract class BaseEntityForm<T> extends BeanValidationForm<T> {
@Override @Override
public HorizontalLayout getToolbar() { public HorizontalLayout getToolbar() {
return new HorizontalLayout(getCancelButton(), getSaveButton()); return new HorizontalLayout(getCancelButton(), getEditButton(), getSaveButton());
}
public Button getEditButton() {
if (editButton == null) {
editButton = new Button("Edit");
editButton.setEnabled(false);
editButton.addClickListener(__ -> {
if (editHandler != null) {
editHandler.onEdit(getEntity());
}
});
}
return editButton;
}
public void setEditHandler(final EditHandler<T> editHandler) {
this.editHandler = editHandler;
getEditButton().setEnabled(editHandler != null);
} }
protected Button getCancelButton() { protected Button getCancelButton() {
@ -41,4 +63,9 @@ public abstract class BaseEntityForm<T> extends BeanValidationForm<T> {
protected Optional<UUID> getEmployeeId() { protected Optional<UUID> getEmployeeId() {
return AuthUtils.getEmployeeId(this.authenticationContext); return AuthUtils.getEmployeeId(this.authenticationContext);
} }
public interface EditHandler<T> extends Serializable {
void onEdit(T entity);
}
} }

View File

@ -42,7 +42,7 @@ public class CandidatesListView extends BaseView {
hl.add(addCandidate); hl.add(addCandidate);
final VGrid<Candidate> grid = new VGrid<>(Candidate.class); final VGrid<Candidate> grid = new VGrid<>(Candidate.class);
grid.setColumns("id", "email"); grid.setColumns("email");
grid.setAllRowsVisible(true); grid.setAllRowsVisible(true);
grid.addComponentColumn(candidate -> grid.addComponentColumn(candidate ->
MenuBarUtils.menuBar(Map.of(Pair.of("Edit", VaadinIcon.PENCIL), menuItemClickEvent -> MenuBarUtils.menuBar(Map.of(Pair.of("Edit", VaadinIcon.PENCIL), menuItemClickEvent ->

View File

@ -38,7 +38,7 @@ public class QuestionsListView extends BaseView {
hl.add(addQuestion); hl.add(addQuestion);
final VGrid<Question> grid = new VGrid<>(Question.class); final VGrid<Question> grid = new VGrid<>(Question.class);
grid.setColumns("id", "title"); grid.setColumns("title", "description", "timeMinutes");
grid.addComponentColumn(question -> grid.addComponentColumn(question ->
MenuBarUtils.menuBar(Pair.of("Edit", __ -> MenuBarUtils.menuBar(Pair.of("Edit", __ ->
getUI().flatMap(ui -> ui.navigate(QuestionView.class, question.getId().toString()))))); getUI().flatMap(ui -> ui.navigate(QuestionView.class, question.getId().toString())))));

View File

@ -6,7 +6,6 @@ import com.primefactorsolutions.model.*;
import com.primefactorsolutions.service.EmployeeService; import com.primefactorsolutions.service.EmployeeService;
import com.primefactorsolutions.service.ReportService; import com.primefactorsolutions.service.ReportService;
import com.primefactorsolutions.service.TeamService; import com.primefactorsolutions.service.TeamService;
import com.primefactorsolutions.service.TimeOffRequestService;
import com.primefactorsolutions.views.BaseEntityForm; import com.primefactorsolutions.views.BaseEntityForm;
import com.primefactorsolutions.views.MainLayout; import com.primefactorsolutions.views.MainLayout;
import com.vaadin.componentfactory.pdfviewer.PdfViewer; import com.vaadin.componentfactory.pdfviewer.PdfViewer;
@ -57,30 +56,25 @@ import java.util.UUID;
public class EmployeeView extends BaseEntityForm<Employee> implements HasUrlParameter<String> { public class EmployeeView extends BaseEntityForm<Employee> implements HasUrlParameter<String> {
private final EmployeeService employeeService; private final EmployeeService employeeService;
private final ReportService reportService; private final ReportService reportService;
private final TimeOffRequestService requestService;
private final TeamService teamService; private final TeamService teamService;
// TODO: campo usado para registrar al empleado en LDAP. Este campo podria estar en otro form eventualmente. // TODO: campo usado para registrar al empleado en LDAP. Este campo podria estar en otro form eventualmente.
private final TextField username = createTextField("Username: ", 30, true); private final TextField username = createTextField("Username", 30, true);
private final TextField firstName = createTextField("Nombres: ", 30, true); private final TextField firstName = createTextField("Nombres", 30, true);
private final TextField lastName = createTextField("Apellidos", 30, true); private final TextField lastName = createTextField("Apellidos", 30, true);
private final ComboBox<Employee.Status> status = createStatusComboBox(); private final ComboBox<Employee.Status> status = createStatusComboBox();
private final ComboBox<Employee.Gender> gender = createGenderComboBox(); private final ComboBox<Employee.Gender> gender = createGenderComboBox();
private final VDatePicker birthday = new VDatePicker("Fecha de Nacimiento"); private final VDatePicker birthday = new VDatePicker("Fecha de Nacimiento");
private final TextField age = createTextField("Edad", 3, false); private final TextField age = createTextField("Edad", 3, false);
private final TextField birthCity = createTextField("Ciudad y País de Nacimiento ejemplo: (Ciudad, País) ", private final TextField birthCity = createTextField("Ciudad y País de Nacimiento", 30, false);
30, false);
private final TextField residenceAddress = createTextField("Dirección de Residencia", 50, false); private final TextField residenceAddress = createTextField("Dirección de Residencia", 50, false);
private final TextField localAddress = createTextField("Departamento y Provincia de Residencia " private final TextField localAddress = createTextField("Departamento y Provincia de Residencia", 30, false);
+ " ejemplo: (Departamento-Provincia)", 30, false);
private final ComboBox<Employee.MaritalStatus> maritalStatus = createMaritalStatusComboBox(); private final ComboBox<Employee.MaritalStatus> maritalStatus = createMaritalStatusComboBox();
private final TextField numberOfChildren = createTextField("Numero de Hijos", 1, false); private final TextField numberOfChildren = createTextField("Numero de Hijos", 1, false);
private final TextField ci = createTextField("CI", 10, false); private final TextField ci = createTextField("CI", 10, false);
private final TextField issuedIn = createTextField("Expedido en ", 10, false); private final TextField issuedIn = createTextField("Lugar de Expedicion", 10, false);
private final TextField phoneNumber = createTextField("Teléfono", 8, false); private final TextField phoneNumber = createTextField("Teléfono", 8, false);
private final EmailField personalEmail = createEmailField("E-mail ejemplo: (ejemplo@gmail.com)"); private final EmailField personalEmail = createEmailField("E-mail");
private final TextField phoneNumberProfesional = createTextField("Teléfono Laboral", 8, false); private final TextField phoneNumberProfesional = createTextField("Teléfono Laboral", 8, false);
private final EmailField profesionalEmail = createEmailField("E-mail Laboral ejemplo: "
+ "(ejemplo@primerfactorsolutions.com)");
private final TextField emergencyCName = createTextField("Nombres y Apellidos de Contacto", 50, false); private final TextField emergencyCName = createTextField("Nombres y Apellidos de Contacto", 50, false);
private final TextField emergencyCAddress = createTextField("Dirección de Contacto", 50, false); private final TextField emergencyCAddress = createTextField("Dirección de Contacto", 50, false);
private final TextField emergencyCPhone = createTextField("Teléfono de Contacto", 8, false); private final TextField emergencyCPhone = createTextField("Teléfono de Contacto", 8, false);
@ -148,12 +142,10 @@ public class EmployeeView extends BaseEntityForm<Employee> implements HasUrlPara
public EmployeeView(final AuthenticationContext authenticationContext, public EmployeeView(final AuthenticationContext authenticationContext,
final EmployeeService employeeService, final EmployeeService employeeService,
final ReportService reportService, final ReportService reportService,
final TeamService teamService, final TeamService teamService) {
final TimeOffRequestService requestService) {
super(authenticationContext, Employee.class); super(authenticationContext, Employee.class);
this.employeeService = employeeService; this.employeeService = employeeService;
this.reportService = reportService; this.reportService = reportService;
this.requestService = requestService;
this.teamService = teamService; this.teamService = teamService;
excelReportButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY); excelReportButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
configureComponents(); configureComponents();
@ -163,7 +155,7 @@ public class EmployeeView extends BaseEntityForm<Employee> implements HasUrlPara
ui.navigate(EmployeeReportView.class, getEntity().getId().toString()) ui.navigate(EmployeeReportView.class, getEntity().getId().toString())
) )
); );
setSavedHandler(e -> saveEmployee(e)); setSavedHandler(this::saveEmployee);
} }
private void makeUpperCase(final TextField textField) { private void makeUpperCase(final TextField textField) {
@ -415,7 +407,6 @@ public class EmployeeView extends BaseEntityForm<Employee> implements HasUrlPara
} }
} }
private VerticalLayout createContentLayout() { private VerticalLayout createContentLayout() {
VerticalLayout contentLayout = new VerticalLayout(); VerticalLayout contentLayout = new VerticalLayout();
contentLayout.setWidth("100%"); contentLayout.setWidth("100%");
@ -521,7 +512,7 @@ public class EmployeeView extends BaseEntityForm<Employee> implements HasUrlPara
profileImagePreview.setVisible(true); profileImagePreview.setVisible(true);
salaryTotal.setValue(BigDecimal.valueOf(0.0)); salaryTotal.setValue(BigDecimal.valueOf(0.0));
} else { } else {
Employee employee = null; final Employee employee;
if (s != null) { if (s != null) {
final UUID employeeId = UUID.fromString(s); final UUID employeeId = UUID.fromString(s);
@ -532,6 +523,7 @@ public class EmployeeView extends BaseEntityForm<Employee> implements HasUrlPara
if ("edit".equals(action)) { if ("edit".equals(action)) {
setEntityWithEnabledSave(employee); setEntityWithEnabledSave(employee);
setEditHandler(null);
status.setValue(employee.getStatus()); status.setValue(employee.getStatus());
setFieldsEditable(); setFieldsEditable();
upload.setVisible(true); upload.setVisible(true);
@ -540,6 +532,7 @@ public class EmployeeView extends BaseEntityForm<Employee> implements HasUrlPara
salaryTotal.setValue(employee.getSalaryTotal()); salaryTotal.setValue(employee.getSalaryTotal());
} else if ("view".equals(action) || "me".equals(action)) { } else if ("view".equals(action) || "me".equals(action)) {
setEntity(employee); setEntity(employee);
setEditHandler(__ -> getUI().ifPresent(ui -> ui.navigate("/employees/" + employee.getId() + "/edit")));
setFieldsReadOnly(); setFieldsReadOnly();
displayProfileImage(employee); displayProfileImage(employee);
salaryTotal.setValue(employee.getSalaryTotal()); salaryTotal.setValue(employee.getSalaryTotal());
@ -574,7 +567,6 @@ public class EmployeeView extends BaseEntityForm<Employee> implements HasUrlPara
phoneNumber.setReadOnly(true); phoneNumber.setReadOnly(true);
personalEmail.setReadOnly(true); personalEmail.setReadOnly(true);
phoneNumberProfesional.setReadOnly(true); phoneNumberProfesional.setReadOnly(true);
profesionalEmail.setReadOnly(true);
position.setReadOnly(true); position.setReadOnly(true);
team.setReadOnly(true); team.setReadOnly(true);
emergencyCName.setReadOnly(true); emergencyCName.setReadOnly(true);
@ -636,7 +628,6 @@ public class EmployeeView extends BaseEntityForm<Employee> implements HasUrlPara
phoneNumber.setReadOnly(false); phoneNumber.setReadOnly(false);
personalEmail.setReadOnly(false); personalEmail.setReadOnly(false);
phoneNumberProfesional.setReadOnly(false); phoneNumberProfesional.setReadOnly(false);
profesionalEmail.setReadOnly(false);
position.setReadOnly(false); position.setReadOnly(false);
team.setReadOnly(false); team.setReadOnly(false);
emergencyCName.setReadOnly(false); emergencyCName.setReadOnly(false);
@ -692,25 +683,73 @@ public class EmployeeView extends BaseEntityForm<Employee> implements HasUrlPara
infoPer, infoPer,
infoGenr, infoGenr,
imagenSub, imagenSub,
upload, profileImagePreview, upload,
firstName, lastName, profileImagePreview,
gender, status, firstName,
birthday, age, lastName,
birthCity, residenceAddress, localAddress, gender,
maritalStatus, ci, issuedIn, numberOfChildren, status,
phoneNumber, personalEmail, phoneNumberProfesional, profesionalEmail, birthday,
contEmerg, emergencyCName, emergencyCAddress, emergencyCPhone, emergencyCEmail, age,
birthCity,
residenceAddress,
localAddress,
maritalStatus,
ci,
issuedIn,
numberOfChildren,
phoneNumber,
personalEmail,
phoneNumberProfesional,
contEmerg,
emergencyCName,
emergencyCAddress,
emergencyCPhone,
emergencyCEmail,
infProf, infProf,
titulos, pTitle1, pTitle2, pTitle3, pStudy1, pStudy2, pStudy3, titulos,
certif, certification1, certification2, certification3, certification4, pTitle1,
logros, recognition, achievements, pTitle2,
idioma, language1, language1Level, language2, language2Level, pTitle3,
pStudy1,
pStudy2,
pStudy3,
certif,
certification1,
certification2,
certification3,
certification4,
logros,
recognition,
achievements,
idioma,
language1,
language1Level,
language2,
language2Level,
infoAdm, infoAdm,
cod, position, team, leadManager, cod,
infoCont, dateOfEntry, dateOfExit, seniority, contractType, customContractType, position,
salaryBasic, professionalBonus, tenureBonus, salaryTotal, team,
datBanc, bankName, accountNumber, leadManager,
datGest, gpss, sss, beneficiarie1, beneficiarie2, infoCont,
dateOfEntry,
dateOfExit,
seniority,
contractType,
customContractType,
salaryBasic,
professionalBonus,
tenureBonus,
salaryTotal,
datBanc,
bankName,
accountNumber,
datGest,
gpss,
sss,
beneficiarie1,
beneficiarie2,
dialog dialog
); );
} }

View File

@ -39,7 +39,7 @@ import java.util.List;
public class EmployeesListView extends BaseView { public class EmployeesListView extends BaseView {
private final EmployeeService employeeService; private final EmployeeService employeeService;
private final PagingGrid<Employee> table = new PagingGrid<>(Employee.class); private final PagingGrid<Employee> employeePagingGrid = new PagingGrid<>(Employee.class);
public EmployeesListView(final AuthenticationContext authenticationContext, final EmployeeService employeeService) { public EmployeesListView(final AuthenticationContext authenticationContext, final EmployeeService employeeService) {
super(authenticationContext); super(authenticationContext);
@ -52,18 +52,19 @@ public class EmployeesListView extends BaseView {
configureTable(); configureTable();
final HorizontalLayout hl = new HorizontalLayout(createAddEmployeeButton(), createExportButton()); final HorizontalLayout hl = new HorizontalLayout(createAddEmployeeButton(), createExportButton());
getCurrentPageLayout().add(hl); getCurrentPageLayout().add(hl);
getCurrentPageLayout().add(table); getCurrentPageLayout().add(employeePagingGrid);
} }
private Button createExportButton() { private Button createExportButton() {
StreamResource excelResource = new StreamResource("employees.xlsx", this::generateExcel); final StreamResource excelResource = new StreamResource("employees.xlsx", this::generateExcel);
Anchor downloadLink = new Anchor(excelResource, "Export Employees"); final Anchor downloadLink = new Anchor(excelResource, "Export Employees");
downloadLink.getElement().setAttribute("download", true); // Forzar descarga downloadLink.getElement().setAttribute("download", true); // Forzar descarga
return new Button("Exportar como Excel", e -> getCurrentPageLayout().add(downloadLink)); return new Button("Exportar como Excel", e -> getCurrentPageLayout().add(downloadLink));
} }
private ByteArrayInputStream generateExcel() { private ByteArrayInputStream generateExcel() {
List<Employee> employees = employeeService.findAllEmployees(); final List<Employee> employees = employeeService.findAllEmployees();
try (Workbook workbook = new XSSFWorkbook(); ByteArrayOutputStream out = new ByteArrayOutputStream()) { try (Workbook workbook = new XSSFWorkbook(); ByteArrayOutputStream out = new ByteArrayOutputStream()) {
Sheet sheet = workbook.createSheet("Employees"); Sheet sheet = workbook.createSheet("Employees");
Row headerRow = sheet.createRow(0); Row headerRow = sheet.createRow(0);
@ -139,17 +140,16 @@ public class EmployeesListView extends BaseView {
} }
} }
private void configureTable() { private void configureTable() {
table.setColumns("firstName", "lastName", "status"); employeePagingGrid.setColumns("username", "firstName", "lastName", "status");
table.addComponentColumn(employee -> MenuBarUtils.menuBar( employeePagingGrid.addComponentColumn(employee -> MenuBarUtils.menuBar(
Pair.of("View", __ -> navigateToEmployeeView(employee)), Pair.of("View", __ -> navigateToEmployeeView(employee)),
Pair.of("Edit", __ -> navigateToEditView(employee)))); Pair.of("Edit", __ -> navigateToEditView(employee))));
setupPagingGrid(); setupPagingGrid();
} }
private Button createButton(final String label, final Runnable onClickAction, final boolean isPrimary) { private Button createButton(final String label, final Runnable onClickAction, final boolean isPrimary) {
Button button = new Button(label); final Button button = new Button(label);
if (isPrimary) { if (isPrimary) {
button.addThemeVariants(ButtonVariant.LUMO_PRIMARY); button.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
@ -160,7 +160,6 @@ public class EmployeesListView extends BaseView {
} }
private Button createAddEmployeeButton() { private Button createAddEmployeeButton() {
return createButton("Add Employee", this::navigateToAddEmployeeView, true); return createButton("Add Employee", this::navigateToAddEmployeeView, true);
} }
@ -173,17 +172,16 @@ public class EmployeesListView extends BaseView {
} }
private void navigateToAddEmployeeView() { private void navigateToAddEmployeeView() {
getUI().ifPresent(ui -> ui.navigate(EmployeeView.class, "new")); getUI().ifPresent(ui -> ui.navigate(EmployeeView.class, "new"));
} }
private void setupPagingGrid() { private void setupPagingGrid() {
table.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM); employeePagingGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM);
table.setPageSize(Constants.PAGE_SIZE); employeePagingGrid.setPageSize(Constants.PAGE_SIZE);
} }
private void refreshGrid() { private void refreshGrid() {
table.setPagingDataProvider((page, pageSize) -> fetchEmployees((int) page, pageSize)); employeePagingGrid.setPagingDataProvider((page, pageSize) -> fetchEmployees((int) page, pageSize));
} }
private List<Employee> fetchEmployees(final int page, final int pageSize) { private List<Employee> fetchEmployees(final int page, final int pageSize) {
@ -195,18 +193,14 @@ public class EmployeesListView extends BaseView {
} }
private boolean hasSortOrder() { private boolean hasSortOrder() {
return !table.getSortOrder().isEmpty(); return !employeePagingGrid.getSortOrder().isEmpty();
} }
private List<Employee> fetchSortedEmployees(final int start, final int pageSize) { private List<Employee> fetchSortedEmployees(final int start, final int pageSize) {
GridSortOrder<Employee> sortOrder = table.getSortOrder().getFirst(); final GridSortOrder<Employee> sortOrder = employeePagingGrid.getSortOrder().getFirst();
return employeeService.findEmployees(start, pageSize, return employeeService.findEmployees(start, pageSize,
sortOrder.getSorted().getKey(), sortOrder.getSorted().getKey(),
sortOrder.getDirection() == SortDirection.ASCENDING); sortOrder.getDirection() == SortDirection.ASCENDING);
} }
@FunctionalInterface
private interface ButtonClickHandler {
void handle(Employee employee);
}
} }

View File

@ -105,6 +105,8 @@ public class TimeOffRequestsListView extends BaseView {
requestsGrid.addColumn(this::getEmployeeFullName).setHeader("Empleado"); requestsGrid.addColumn(this::getEmployeeFullName).setHeader("Empleado");
requestsGrid.addColumn(this::getTeamName).setHeader("Equipo"); requestsGrid.addColumn(this::getTeamName).setHeader("Equipo");
requestsGrid.addColumn(this::getCategory).setHeader("Categoría"); requestsGrid.addColumn(this::getCategory).setHeader("Categoría");
requestsGrid.addColumn(this::getDates).setHeader("Dias");
requestsGrid.addColumn(this::getState).setHeader("Estado");
requestsGrid.addComponentColumn((ValueProvider<TimeOffRequest, Component>) timeOffRequest -> { requestsGrid.addComponentColumn((ValueProvider<TimeOffRequest, Component>) timeOffRequest -> {
final MenuBar menuBar = new MenuBar(); final MenuBar menuBar = new MenuBar();
menuBar.addThemeVariants(MenuBarVariant.LUMO_TERTIARY_INLINE); menuBar.addThemeVariants(MenuBarVariant.LUMO_TERTIARY_INLINE);
@ -193,6 +195,14 @@ public class TimeOffRequestsListView extends BaseView {
return String.valueOf(request.getCategory()); return String.valueOf(request.getCategory());
} }
private String getDates(final TimeOffRequest request) {
return String.format("de %s a %s", request.getStartDate(), request.getEndDate());
}
private String getState(final TimeOffRequest request) {
return request.getState().name();
}
private ComboBox<Employee> createEmployeeFilter() { private ComboBox<Employee> createEmployeeFilter() {
employeeFilter.setClearButtonVisible(true); employeeFilter.setClearButtonVisible(true);
employeeFilter.setPlaceholder("Seleccionar ..."); employeeFilter.setPlaceholder("Seleccionar ...");

View File

@ -24,7 +24,6 @@ import java.time.YearMonth;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors;
@SpringComponent @SpringComponent
@PermitAll @PermitAll
@ -79,6 +78,12 @@ public class TimesheetEntryView extends BaseEntityForm<TimesheetEntry> implement
setEntityWithEnabledSave(timesheetEntry); setEntityWithEnabledSave(timesheetEntry);
} else if ("view".equals(action) && !s.isEmpty()) { } else if ("view".equals(action) && !s.isEmpty()) {
setEntity(timesheetEntry); setEntity(timesheetEntry);
setFormReadOnly();
}
}
}
private void setFormReadOnly() {
employee.setReadOnly(true); employee.setReadOnly(true);
team.setReadOnly(true); team.setReadOnly(true);
task.setReadOnly(true); task.setReadOnly(true);
@ -86,8 +91,6 @@ public class TimesheetEntryView extends BaseEntityForm<TimesheetEntry> implement
date.setReadOnly(true); date.setReadOnly(true);
hours.setReadOnly(true); hours.setReadOnly(true);
} }
}
}
@Override @Override
protected List<Component> getFormComponents() { protected List<Component> getFormComponents() {
@ -120,33 +123,29 @@ public class TimesheetEntryView extends BaseEntityForm<TimesheetEntry> implement
team.setWidthFull(); team.setWidthFull();
team.setItems(teamService.findAllTeams()); team.setItems(teamService.findAllTeams());
team.setItemLabelGenerator(Team::getName); team.setItemLabelGenerator(Team::getName);
team.setValue(null);
team.addValueChangeListener(event -> { team.addValueChangeListener(event -> {
Team selectedTeam = event.getValue(); if (event.getOldValue() != null) {
final Team selectedTeam = event.getValue();
updateEmployeeField(selectedTeam); updateEmployeeField(selectedTeam);
}
}); });
} }
private void updateEmployeeField(final Team selectedTeam) { private void updateEmployeeField(final Team selectedTeam) {
if (selectedTeam != null) { if (selectedTeam != null) {
List<Employee> employeesInTeam = employeeService.findAllEmployees().stream() final List<Employee> employeesInTeam = employeeService.findAllEmployees().stream()
.filter(employee -> employee.getTeam() != null && employee.getTeam().equals(selectedTeam)) .filter(employee -> employee.getTeam() != null && employee.getTeam().equals(selectedTeam))
.collect(Collectors.toList()); .toList();
employee.setItems(employeesInTeam); employee.setItems(employeesInTeam);
if (!employeesInTeam.isEmpty()) { employee.setValue(null);
employee.setValue(employeesInTeam.getFirst());
} else {
employee.clear();
}
} }
} }
private void initializeEmployeeField() { private void initializeEmployeeField() {
List<Employee> employees = new ArrayList<>(employeeService.findAllEmployees()); final List<Employee> employees = new ArrayList<>(employeeService.findAllEmployees());
employee.setWidthFull(); employee.setWidthFull();
employee.setItems(employees); employee.setItems(employees);
employee.setItemLabelGenerator(TimesheetEntryView::getEmployeeFullName); employee.setItemLabelGenerator(TimesheetEntryView::getEmployeeFullName);
employee.setValue(null);
employee.setRequired(true); employee.setRequired(true);
} }

View File

@ -2,6 +2,7 @@ package com.primefactorsolutions.views.timesheet;
import com.primefactorsolutions.model.TimesheetEntry; import com.primefactorsolutions.model.TimesheetEntry;
import com.primefactorsolutions.model.Team; import com.primefactorsolutions.model.Team;
import com.primefactorsolutions.model.Week;
import com.primefactorsolutions.service.TimesheetService; import com.primefactorsolutions.service.TimesheetService;
import com.primefactorsolutions.service.ReportService; import com.primefactorsolutions.service.ReportService;
import com.primefactorsolutions.service.TeamService; import com.primefactorsolutions.service.TeamService;
@ -11,81 +12,59 @@ 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.Anchor; import com.vaadin.flow.component.html.Anchor;
import com.vaadin.flow.component.html.H2;
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.PageTitle; import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route; import com.vaadin.flow.router.Route;
import com.vaadin.flow.server.StreamResource; import com.vaadin.flow.server.StreamResource;
import com.vaadin.flow.spring.security.AuthenticationContext; import com.vaadin.flow.spring.security.AuthenticationContext;
import jakarta.annotation.security.RolesAllowed; import jakarta.annotation.security.RolesAllowed;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import com.primefactorsolutions.service.EmployeeService;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.time.DayOfWeek;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.TextStyle; import java.time.temporal.IsoFields;
import java.time.temporal.WeekFields;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Route(value = "/timesheet/report", layout = MainLayout.class) @Route(value = "/timesheet/report", layout = MainLayout.class)
@PageTitle("Reporte de Horas Trabajadas") @PageTitle("Reporte de Horas Trabajadas")
@RolesAllowed("ROLE_ADMIN") @RolesAllowed("ROLE_ADMIN")
@Slf4j
public class TimesheetReportView extends BaseView { public class TimesheetReportView extends BaseView {
private final EmployeeService employeeService;
private final TimesheetService timesheetService; private final TimesheetService timesheetService;
private final ReportService reportService; private final ReportService reportService;
private final TeamService teamService; private final ComboBox<Team> teamComboBox = new ComboBox<>("Equipo");
private final ComboBox<Team> equipoComboBox = new ComboBox<>("Seleccionar Equipo"); private final ComboBox<Week> weekComboBox = new ComboBox<>("Semana");
private final ComboBox<String> semanaComboBox = new ComboBox<>("Seleccionar Semana");
private final Grid<Map<String, Object>> grid = new Grid<>(); private final Grid<Map<String, Object>> grid = new Grid<>();
private final VerticalLayout headerLayout = new VerticalLayout();
private Anchor downloadLink; private Anchor downloadLink;
private final Span semanaInfoSpan = new Span();
private final int currentYear = LocalDate.now().getYear(); private final int currentYear = LocalDate.now().getYear();
@Autowired @Autowired
public TimesheetReportView(final AuthenticationContext authenticationContext, public TimesheetReportView(final AuthenticationContext authenticationContext,
final TimesheetService timesheetService, final TimesheetService timesheetService,
final ReportService reportService, final ReportService reportService,
final TeamService teamService, final TeamService teamService) {
final EmployeeService employeeService) {
super(authenticationContext); super(authenticationContext);
this.timesheetService = timesheetService; this.timesheetService = timesheetService;
this.reportService = reportService; this.reportService = reportService;
this.teamService = teamService;
this.employeeService = employeeService;
final H2 title = new H2("Reporte de Horas Trabajadas");
getCurrentPageLayout().add(title);
final List<Team> teams = teamService.findAllTeams(); final List<Team> teams = teamService.findAllTeams();
equipoComboBox.setItems(teams); teamComboBox.setPlaceholder("Seleccionar ...");
equipoComboBox.setItemLabelGenerator(Team::getName); teamComboBox.setItems(teams);
teamComboBox.setItemLabelGenerator(Team::getName);
initializeWeekComboBox(); initializeWeekComboBox();
semanaComboBox.addValueChangeListener(event -> {
String selectedWeek = event.getValue();
semanaInfoSpan.setText(selectedWeek != null ? selectedWeek : "Selecciona una semana");
});
final Button reportButton = new Button("Generar Reporte de Horas Trabajadas", final Button reportButton = new Button("Generar Reporte de Horas Trabajadas",
event -> generateHoursWorkedReport()); event -> generateHoursWorkedReport());
getCurrentPageLayout().add(reportButton); getCurrentPageLayout().add(reportButton);
final HorizontalLayout filtersLayout = new HorizontalLayout(equipoComboBox, semanaComboBox); final HorizontalLayout filtersLayout = new HorizontalLayout(teamComboBox, weekComboBox);
getCurrentPageLayout().add(filtersLayout); getCurrentPageLayout().add(filtersLayout);
getCurrentPageLayout().add(headerLayout);
updateHeaderLayout(null, null);
grid.addColumn(map -> map.get("Empleado")).setHeader("Empleado"); grid.addColumn(map -> map.get("Empleado")).setHeader("Empleado");
grid.addColumn(map -> map.get("Horas Trabajadas")).setHeader("Horas Trabajadas"); grid.addColumn(map -> map.get("Horas Trabajadas")).setHeader("Horas Trabajadas");
grid.addColumn(map -> map.get("Horas Pendientes")).setHeader("Horas Pendientes"); grid.addColumn(map -> map.get("Horas Pendientes")).setHeader("Horas Pendientes");
@ -95,32 +74,13 @@ public class TimesheetReportView extends BaseView {
} }
private void initializeWeekComboBox() { private void initializeWeekComboBox() {
int year = LocalDate.now().getYear(); weekComboBox.setItems(Week.getLastWeeks(8));
final LocalDate startOfYear = LocalDate.of(year, 1, 5); weekComboBox.setPlaceholder("Seleccionar ...");
final List<String> weeks = startOfYear.datesUntil(LocalDate.of(year + 1, 1, 1),
java.time.Period.ofWeeks(1))
.map(date -> {
final int weekNumber = date.get(
WeekFields.of(DayOfWeek.MONDAY, 1).weekOfWeekBasedYear());
final LocalDate endOfWeek = date.plusDays(6);
return String.format("Semana %d: %s - %s",
weekNumber,
date.getDayOfMonth() + " de " + date.getMonth()
.getDisplayName(TextStyle.FULL, Locale.getDefault()),
endOfWeek.getDayOfMonth() + " de " + endOfWeek.getMonth()
.getDisplayName(TextStyle.FULL, Locale.getDefault())
);
})
.collect(Collectors.toList());
semanaComboBox.setItems(weeks);
semanaComboBox.setPlaceholder("Seleccione una semana");
} }
private void generateHoursWorkedReport() { private void generateHoursWorkedReport() {
final Team selectedTeam = equipoComboBox.getValue(); final Team selectedTeam = teamComboBox.getValue();
final String selectedWeek = semanaComboBox.getValue(); final Week selectedWeek = weekComboBox.getValue();
if (selectedTeam == null || selectedWeek == null) { if (selectedTeam == null || selectedWeek == null) {
Notification.show("Por favor, selecciona un equipo y una semana para generar el reporte.", Notification.show("Por favor, selecciona un equipo y una semana para generar el reporte.",
@ -128,82 +88,45 @@ public class TimesheetReportView extends BaseView {
return; return;
} }
final int weekNumber = Integer.parseInt(selectedWeek.split(" ")[1].replace(":", "")); final List<TimesheetEntry> timesheetEntryList =
final LocalDate selectedDate = LocalDate.now().with(WeekFields.of(DayOfWeek.FRIDAY, 1) timesheetService.findListHoursWorkedEmployee(selectedWeek.from(), selectedWeek.to()).stream()
.weekOfWeekBasedYear(), weekNumber); .filter(e -> e.getEmployee().getTeam().getId().equals(selectedTeam.getId()))
updateHeaderLayout(selectedTeam, selectedDate);
final List<TimesheetEntry> timesheetEntryList = timesheetService.findAll().stream()
.filter(hw -> hw.getEmployee().getTeam().getId().equals(selectedTeam
.getId()) && hw.getWeekNumber() == weekNumber)
.toList(); .toList();
if (timesheetEntryList.isEmpty()) { if (timesheetEntryList.isEmpty()) {
Notification.show("No hay horas trabajadas disponibles para generar el reporte.", Notification.show("No hay horas trabajadas disponibles para generar el reporte.",
3000, Notification.Position.MIDDLE); 3000, Notification.Position.MIDDLE);
return; return;
} }
List<Map<String, Object>> data = timesheetEntryList.stream() final List<Map<String, Object>> data = timesheetEntryList.stream()
.map(hoursWorked -> { .map(e -> {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("ID", hoursWorked.getId().toString()); map.put("ID", e.getId().toString());
map.put("Employee ID", hoursWorked.getEmployee().getId().toString()); map.put("Employee ID", e.getEmployee().getId().toString());
map.put("Empleado", hoursWorked.getEmployee().getFirstName() + " " map.put("Empleado", e.getEmployee().getFirstName() + " "
+ hoursWorked.getEmployee().getLastName()); + e.getEmployee().getLastName());
map.put("Horas Trabajadas", hoursWorked.getHours()); map.put("Horas Trabajadas", e.getHours());
map.put("Horas Pendientes", 40 - hoursWorked.getHours()); map.put("Horas Pendientes", 40 - e.getHours());
map.put("Observaciones", ""); map.put("Observaciones", "");
return map; return map;
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
grid.setItems(data); grid.setItems(data);
int weekNumber = weekComboBox.getValue().from().get(IsoFields.WEEK_OF_WEEK_BASED_YEAR);
generateExcelDownloadLink(data, weekNumber); generateExcelDownloadLink(data, weekNumber);
} }
private void updateHeaderLayout(final Team team, final LocalDate dateInWeek) {
headerLayout.removeAll();
if (team != null && dateInWeek != null) {
int weekNumber = getWeekOfYear(dateInWeek);
headerLayout.add(new Span("Informe "
+ String.format("%03d", weekNumber) + "/" + currentYear) {{
getStyle().set("font-size", "24px");
getStyle().set("font-weight", "bold");
}});
String teamLeadName = employeeService.getTeamLeadName(team.getId());
headerLayout.add(
new Span("Asunto: Informe Semanal de Horas Trabajadas") {{
getStyle().set("font-size", "18px");
}},
semanaInfoSpan,
new Span("Horas a cumplir: 40 horas") {{
getStyle().set("font-size", "18px");
}},
new Span("Equipo: " + team.getName()) {{
getStyle().set("font-size", "18px");
}},
new Span("Team Lead: " + teamLeadName) {{
getStyle().set("font-size", "18px");
}}
);
}
}
private void generateExcelDownloadLink(final List<Map<String, Object>> data, final int weekNumber) { private void generateExcelDownloadLink(final List<Map<String, Object>> data, final int weekNumber) {
try { try {
List<String> headers = List.of("Empleado", final List<String> headers = List.of("Empleado", "Horas Trabajadas", "Horas Pendientes", "Observaciones");
"Horas Trabajadas", "Horas Pendientes", "Observaciones"); final String selectedTeam = teamComboBox.getValue().getName();
String selectedTeam = equipoComboBox.getValue().getName(); final byte[] excelBytes = reportService.writeAsExcel(
byte[] excelBytes = reportService.writeAsExcel(
"hours_worked_report", headers, data, selectedTeam, weekNumber, currentYear); "hours_worked_report", headers, data, selectedTeam, weekNumber, currentYear);
final StreamResource excelResource = new StreamResource("hours_worked_report.xlsx",
StreamResource excelResource = new StreamResource("hours_worked_report.xlsx",
() -> new ByteArrayInputStream(excelBytes)); () -> new ByteArrayInputStream(excelBytes));
if (downloadLink == null) { if (downloadLink == null) {
downloadLink = new Anchor(excelResource, "Descargar Reporte en Excel"); downloadLink = new Anchor(excelResource, "Descargar Reporte en Excel");
downloadLink.getElement().setAttribute("download", true); downloadLink.getElement().setAttribute("download", true);
@ -214,11 +137,7 @@ public class TimesheetReportView extends BaseView {
} catch (Exception e) { } catch (Exception e) {
Notification.show("Error al generar el reporte de horas trabajadas en Excel.", Notification.show("Error al generar el reporte de horas trabajadas en Excel.",
3000, Notification.Position.MIDDLE); 3000, Notification.Position.MIDDLE);
log.error("Error generating report", e);
} }
} }
private int getWeekOfYear(final LocalDate date) {
return date.get(WeekFields.of(Locale.getDefault()).weekOfWeekBasedYear());
}
} }

View File

@ -8,58 +8,90 @@ insert into assessment(id, version, candidate_id) values ('46b153f4-23fd-462f-84
insert into assessment_questions (assessment_id, question_id) values ('46b153f4-23fd-462f-8430-fbe67b83caab', 'a7e00ff8-da41-4624-b31c-1b13c3f2e3ae'); insert into assessment_questions (assessment_id, question_id) values ('46b153f4-23fd-462f-8430-fbe67b83caab', 'a7e00ff8-da41-4624-b31c-1b13c3f2e3ae');
insert into assessment_questions (assessment_id, question_id) values ('46b153f4-23fd-462f-8430-fbe67b83caab', '8a4b213c-ca81-4c38-b56d-d7028c2dde88'); insert into assessment_questions (assessment_id, question_id) values ('46b153f4-23fd-462f-8430-fbe67b83caab', '8a4b213c-ca81-4c38-b56d-d7028c2dde88');
INSERT INTO team (id, version, name) VALUES ('b0e8f394-78c1-4d8a-9c57-dc6e8b36a5fa', 1, 'ABC'); insert into team (id, version, name) values ('b0e8f394-78c1-4d8a-9c57-dc6e8b36a5fa', 1, 'ABC');
INSERT INTO team (id, version, name) VALUES ('6d63bc15-3f8b-46f7-9cf1-7e9b0b9a2b28', 1, 'XYZ'); insert into team (id, version, name) values ('6d63bc15-3f8b-46f7-9cf1-7e9b0b9a2b28', 1, 'XYZ');
INSERT INTO team (id, version, name) VALUES ('c3a8a7b1-f2d9-48c0-86ea-f215c2e6b3a3', 1, 'DEF'); insert into team (id, version, name) values ('c3a8a7b1-f2d9-48c0-86ea-f215c2e6b3a3', 1, 'DEF');
INSERT INTO team (id, version, name) VALUES ('8f6b61e7-efb2-4de7-b8ed-7438c9d8babe', 1, 'GHI'); insert into team (id, version, name) values ('8f6b61e7-efb2-4de7-b8ed-7438c9d8babe', 1, 'GHI');
INSERT INTO time_off (id, version, category, date, duration, expiration, type) VALUES ('123e4567-e89b-12d3-a456-426614174000', 1, 'AÑO_NUEVO', '2024-1-1', 1, 1, 'FIXED'); insert into time_off (id, version, category, date, duration, expiration, type)
INSERT INTO time_off (id, version, category, date, duration, expiration, type) VALUES ('223e4567-e89b-12d3-a456-426614174001', 1, 'LUNES_CARNAVAL', '2024-2-12', 1, 1, 'FIXED'); values ('123e4567-e89b-12d3-a456-426614174000', 1, 'AÑO_NUEVO', '2024-1-1', 1, 1, 'FIXED');
INSERT INTO time_off (id, version, category, date, duration, expiration, type) VALUES ('323e4567-e89b-12d3-a456-426614174002', 1, 'MARTES_CARNAVAL', '2024-2-13', 1, 1, 'FIXED'); insert into time_off (id, version, category, date, duration, expiration, type)
INSERT INTO time_off (id, version, category, date, duration, expiration, type) VALUES ('423e4567-e89b-12d3-a456-426614174003', 1, 'VIERNES_SANTO', '2024-3-29', 1, 1, 'FIXED'); values ('223e4567-e89b-12d3-a456-426614174001', 1, 'LUNES_CARNAVAL', '2024-2-12', 1, 1, 'FIXED');
INSERT INTO time_off (id, version, category, date, duration, expiration, type) VALUES ('523e4567-e89b-12d3-a456-426614174004', 1, 'DIA_DEL_TRABAJADOR', '2024-5-1', 1, 1, 'FIXED'); insert into time_off (id, version, category, date, duration, expiration, type)
INSERT INTO time_off (id, version, category, date, duration, expiration, type) VALUES ('623e4567-e89b-12d3-a456-426614174005', 1, 'DIA_DE_LA_INDEPENDENCIA', '2024-8-6', 1, 1, 'FIXED'); values ('323e4567-e89b-12d3-a456-426614174002', 1, 'MARTES_CARNAVAL', '2024-2-13', 1, 1, 'FIXED');
INSERT INTO time_off (id, version, category, date, duration, expiration, type) VALUES ('723e4567-e89b-12d3-a456-426614174006', 1, 'NAVIDAD', '2024-12-25', 1, 1, 'FIXED'); insert into time_off (id, version, category, date, duration, expiration, type)
INSERT INTO time_off (id, version, category, date, duration, expiration, type) VALUES ('823e4567-e89b-12d3-a456-426614174007', 1, 'DIA_DEL_ESTADO_PLURINACIONAL', '2024-1-21', 1, 30, 'MOVABLE'); values ('423e4567-e89b-12d3-a456-426614174003', 1, 'VIERNES_SANTO', '2024-3-29', 1, 1, 'FIXED');
INSERT INTO time_off (id, version, category, date, duration, expiration, type) VALUES ('923e4567-e89b-12d3-a456-426614174008', 1, 'CORPUS_CHRISTI', '2024-5-30', 1, 30, 'MOVABLE'); insert into time_off (id, version, category, date, duration, expiration, type)
INSERT INTO time_off (id, version, category, date, duration, expiration, type) VALUES ('a23e4567-e89b-12d3-a456-426614174009', 1, 'AÑO_NUEVO_ANDINO', '2024-6-21', 1, 30, 'MOVABLE'); values ('523e4567-e89b-12d3-a456-426614174004', 1, 'DIA_DEL_TRABAJADOR', '2024-5-1', 1, 1, 'FIXED');
INSERT INTO time_off (id, version, category, date, duration, expiration, type) VALUES ('b23e4567-e89b-12d3-a456-42661417400a', 1, 'ANIVERSARIO_DEPARTAMENTAL', '2024-9-14', 1, 30, 'MOVABLE'); insert into time_off (id, version, category, date, duration, expiration, type)
INSERT INTO time_off (id, version, category, date, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417400b', 1, 'DIA_DE_TODOS_LOS_DIFUNTOS', '2024-11-2', 1, 30, 'MOVABLE'); values ('623e4567-e89b-12d3-a456-426614174005', 1, 'DIA_DE_LA_INDEPENDENCIA', '2024-8-6', 1, 1, 'FIXED');
INSERT INTO time_off (id, version, category, date, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417401a', 1, 'DIA_DEL_PADRE', '2024-3-19', 0.5, 30, 'OTHER'); insert into time_off (id, version, category, date, duration, expiration, type)
INSERT INTO time_off (id, version, category, date, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417401b', 1, 'DIA_DE_LA_MADRE', '2024-5-27', 0.5, 30, 'OTHER'); values ('723e4567-e89b-12d3-a456-426614174006', 1, 'NAVIDAD', '2024-12-25', 1, 1, 'FIXED');
INSERT INTO time_off (id, version, category, date, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417401c', 1, 'DIA_DE_LA_MUJER_INTERNACIONAL', '2024-3-8', 0.5, 30, 'OTHER'); insert into time_off (id, version, category, date, duration, expiration, type)
INSERT INTO time_off (id, version, category, date, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417401d', 1, 'DIA_DE_LA_MUJER_NACIONAL', '2024-10-11', 0.5, 30, 'OTHER'); values ('823e4567-e89b-12d3-a456-426614174007', 1, 'DIA_DEL_ESTADO_PLURINACIONAL', '2024-1-21', 1, 30, 'MOVABLE');
insert into time_off (id, version, category, date, duration, expiration, type)
values ('923e4567-e89b-12d3-a456-426614174008', 1, 'CORPUS_CHRISTI', '2024-5-30', 1, 30, 'MOVABLE');
insert into time_off (id, version, category, date, duration, expiration, type)
values ('a23e4567-e89b-12d3-a456-426614174009', 1, 'AÑO_NUEVO_ANDINO', '2024-6-21', 1, 30, 'MOVABLE');
insert into time_off (id, version, category, date, duration, expiration, type)
values ('b23e4567-e89b-12d3-a456-42661417400a', 1, 'ANIVERSARIO_DEPARTAMENTAL', '2024-9-14', 1, 30, 'MOVABLE');
insert into time_off (id, version, category, date, duration, expiration, type)
values ('c23e4567-e89b-12d3-a456-42661417400b', 1, 'DIA_DE_TODOS_LOS_DIFUNTOS', '2024-11-2', 1, 30, 'MOVABLE');
insert into time_off (id, version, category, date, duration, expiration, type)
values ('c23e4567-e89b-12d3-a456-42661417401a', 1, 'DIA_DEL_PADRE', '2024-3-19', 0.5, 30, 'OTHER');
insert into time_off (id, version, category, date, duration, expiration, type)
values ('c23e4567-e89b-12d3-a456-42661417401b', 1, 'DIA_DE_LA_MADRE', '2024-5-27', 0.5, 30, 'OTHER');
insert into time_off (id, version, category, date, duration, expiration, type)
values ('c23e4567-e89b-12d3-a456-42661417401c', 1, 'DIA_DE_LA_MUJER_INTERNACIONAL', '2024-3-8', 0.5, 30, 'OTHER');
insert into time_off (id, version, category, date, duration, expiration, type)
values ('c23e4567-e89b-12d3-a456-42661417401d', 1, 'DIA_DE_LA_MUJER_NACIONAL', '2024-10-11', 0.5, 30, 'OTHER');
INSERT INTO time_off (id, version, category, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417400c', 1, 'CUMPLEAÑOS', 0.5, 0.5, 'OTHER'); insert into time_off (id, version, category, duration, expiration, type) values ('c23e4567-e89b-12d3-a456-42661417400c', 1, 'CUMPLEAÑOS', 0.5, 0.5, 'OTHER');
INSERT INTO time_off (id, version, category, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417400d', 1, 'MATERNIDAD', 90, 90, 'OTHER'); insert into time_off (id, version, category, duration, expiration, type) values ('c23e4567-e89b-12d3-a456-42661417400d', 1, 'MATERNIDAD', 90, 90, 'OTHER');
INSERT INTO time_off (id, version, category, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417400e', 1, 'PATERNIDAD', 3, 3, 'OTHER'); insert into time_off (id, version, category, duration, expiration, type) values ('c23e4567-e89b-12d3-a456-42661417400e', 1, 'PATERNIDAD', 3, 3, 'OTHER');
INSERT INTO time_off (id, version, category, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417400f', 1, 'MATRIMONIO', 3, 3, 'OTHER'); insert into time_off (id, version, category, duration, expiration, type) values ('c23e4567-e89b-12d3-a456-42661417400f', 1, 'MATRIMONIO', 3, 3, 'OTHER');
INSERT INTO time_off (id, version, category, duration, expiration, type) VALUES ('550e8400-e29b-41d4-a716-446655440000', 1, 'DUELO_1ER_GRADO', 3, 3, 'OTHER'); insert into time_off (id, version, category, duration, expiration, type) values ('550e8400-e29b-41d4-a716-446655440000', 1, 'DUELO_1ER_GRADO', 3, 3, 'OTHER');
INSERT INTO time_off (id, version, category, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417400a', 1, 'DUELO_2ER_GRADO', 2, 2, 'OTHER'); insert into time_off (id, version, category, duration, expiration, type) values ('c23e4567-e89b-12d3-a456-42661417400a', 1, 'DUELO_2ER_GRADO', 2, 2, 'OTHER');
insert into time_off (id, version, category, duration, expiration, type) values ('c23e4567-e89b-12d3-a456-42661417401e', 1, 'PERMISOS_DE_SALUD', 2, 360, 'OTHER');
INSERT INTO time_off (id, version, category, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417401e', 1, 'PERMISOS_DE_SALUD', 2, 360, 'OTHER'); insert into time_off (id, version, category, expiration, type) values ('490e5fbe-895b-42f8-b914-95437f7b39c0', 1, 'VACACION_GESTION_ACTUAL', 360, 'OTHER');
INSERT INTO time_off (id, version, category, expiration, type) VALUES ('490e5fbe-895b-42f8-b914-95437f7b39c0', 1, 'VACACION_GESTION_ACTUAL', 360, 'OTHER'); insert into time_off (id, version, category, expiration, type) values ('c23e4567-e89b-12d3-a456-4266141740ff', 1, 'VACACION_GESTION_ANTERIOR', 360, 'OTHER');
INSERT INTO time_off (id, version, category, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-4266141740ff', 1, 'VACACION_GESTION_ANTERIOR', 360, 'OTHER');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender, birthday, date_of_entry, lead_manager, role) values ('5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 1, 'bob', 'Bob', 'Test', 'ACTIVE','b0e8f394-78c1-4d8a-9c57-dc6e8b36a5fa', 'MALE', '2024-02-20', '2013-10-22', 'ben', 'ADMIN');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender, date_of_entry, role) values ('cba3efb7-32bc-44be-9fdc-fc5e4f211254', 1, 'ben', 'Ben', 'Test', 'ACTIVE', '6d63bc15-3f8b-46f7-9cf1-7e9b0b9a2b28', 'MALE', '2016-10-23', 'USER');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender, date_of_entry) values ('e99b7af5-7d3a-4c0f-b8bc-e8d0388d8fc4', 1, 'jperez', 'Juan', 'Perez Condori', 'INACTIVE', 'c3a8a7b1-f2d9-48c0-86ea-f215c2e6b3a3', 'MALE', '2022-10-22');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender, date_of_entry) values ('f6ab3c6d-7078-45f6-9b22-4e37637bfec6', 1, 'agarcia', 'Ana', 'Garcia Rojas', 'ACTIVE', '8f6b61e7-efb2-4de7-b8ed-7438c9d8babe', 'FEMALE', '2024-10-24');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender) values ('2e2293b1-3f9a-4f3d-abc8-32639b0a5e15', 1, 'clopez', 'Carlos', 'Lopez Mendoza', 'INACTIVE', 'b0e8f394-78c1-4d8a-9c57-dc6e8b36a5fa', 'MALE');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender) values ('4b1c6c35-4627-4b35-b6e9-dc75c68b2c31', 1, 'mfernandez', 'Maria', 'Fernandez Villca', 'ACTIVE', '6d63bc15-3f8b-46f7-9cf1-7e9b0b9a2b28', 'FEMALE');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender) values ('afc5c741-f70a-4394-853b-39d51b118927', 1, 'lgutierrez', 'Luis', 'Gutierrez Mamani', 'ACTIVE', 'c3a8a7b1-f2d9-48c0-86ea-f215c2e6b3a3', 'MALE');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender) values ('b2436b82-7b9f-4f0d-9463-f2c3173a45c3', 1, 'lmartinez', 'Laura', 'Martinez Paredes', 'INACTIVE', '8f6b61e7-efb2-4de7-b8ed-7438c9d8babe', 'FEMALE');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender) values ('6e6a8a4e-9f6b-44eb-8c69-40acfdc86756', 1, 'rsantos', 'Roberto', 'Santos Escobar', 'ACTIVE','b0e8f394-78c1-4d8a-9c57-dc6e8b36a5fa', 'MALE');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender) values ('36b0d1c6-bdc0-4d98-94bb-08b9bce3f0d5', 1, 'vmorales', 'Valeria', 'Morales Ochoa', 'INACTIVE', '6d63bc15-3f8b-46f7-9cf1-7e9b0b9a2b28', 'FEMALE');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender) values ('5a1c6d80-58b3-43e3-a5a5-24b4a2d1d54a', 1, 'jramirez', 'Jorge', 'Ramirez Tapia', 'ACTIVE', 'c3a8a7b1-f2d9-48c0-86ea-f215c2e6b3a3', 'MALE');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender) values ('9d6a5b2e-6d0b-4b89-8d6a-d3f3d1bfc047', 1, 'storres', 'Sandra', 'Torres Huanca', 'ACTIVE', '8f6b61e7-efb2-4de7-b8ed-7438c9d8babe', 'FEMALE');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender) values ('f8b3e0c0-0d5a-4e5c-bf9d-207b9b5e8279', 1, 'fquispe', 'Felipe', 'Quispe Huanca', 'INACTIVE','b0e8f394-78c1-4d8a-9c57-dc6e8b36a5fa', 'MALE');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender) values ('cd80e1d0-9a08-44a6-bd63-2c63eaa003d4', 1, 'grivas', 'Gabriela', 'Rivas Arana', 'ACTIVE', '6d63bc15-3f8b-46f7-9cf1-7e9b0b9a2b28', 'FEMALE');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender) values ('62d3c1b7-815e-4e96-8d7e-f8c4236bca55', 1, 'oflores', 'Oscar', 'Flores Quiroga', 'INACTIVE', 'c3a8a7b1-f2d9-48c0-86ea-f215c2e6b3a3', 'MALE');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender) values ('f20b7c5a-5a67-44f0-9ec1-4c1b8e80de05', 1, 'mvargas', 'Marta', 'Vargas Soria', 'ACTIVE', '8f6b61e7-efb2-4de7-b8ed-7438c9d8babe', 'FEMALE');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender) values ('19b5a76e-d7b1-4b76-8b02-4d0748e85809', 1, 'aespinoza', 'Andres', 'Espinoza Chura', 'INACTIVE','b0e8f394-78c1-4d8a-9c57-dc6e8b36a5fa', 'MALE');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender) values ('5c1a7b82-832d-4f24-8377-54b77b91b6a8', 1, 'cvillanueva', 'Carla', 'Villanueva Arce', 'ACTIVE', '6d63bc15-3f8b-46f7-9cf1-7e9b0b9a2b28', 'FEMALE');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender, birthday, date_of_entry, lead_manager, role)
values ('5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 1, 'bob', 'Bob', 'Test', 'ACTIVE','b0e8f394-78c1-4d8a-9c57-dc6e8b36a5fa', 'MALE', '2024-02-20', '2013-10-22', 'ben', 'ADMIN');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender, date_of_entry, role)
values ('cba3efb7-32bc-44be-9fdc-fc5e4f211254', 1, 'ben', 'Ben', 'Test', 'ACTIVE', '6d63bc15-3f8b-46f7-9cf1-7e9b0b9a2b28', 'MALE', '2016-10-23', 'USER');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender, date_of_entry)
values ('e99b7af5-7d3a-4c0f-b8bc-e8d0388d8fc4', 1, 'jperez', 'Juan', 'Perez Condori', 'INACTIVE', 'c3a8a7b1-f2d9-48c0-86ea-f215c2e6b3a3', 'MALE', '2022-10-22');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender, date_of_entry)
values ('f6ab3c6d-7078-45f6-9b22-4e37637bfec6', 1, 'agarcia', 'Ana', 'Garcia Rojas', 'ACTIVE', '8f6b61e7-efb2-4de7-b8ed-7438c9d8babe', 'FEMALE', '2024-10-24');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender)
values ('2e2293b1-3f9a-4f3d-abc8-32639b0a5e15', 1, 'clopez', 'Carlos', 'Lopez Mendoza', 'INACTIVE', 'b0e8f394-78c1-4d8a-9c57-dc6e8b36a5fa', 'MALE');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender)
values ('4b1c6c35-4627-4b35-b6e9-dc75c68b2c31', 1, 'mfernandez', 'Maria', 'Fernandez Villca', 'ACTIVE', '6d63bc15-3f8b-46f7-9cf1-7e9b0b9a2b28', 'FEMALE');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender)
values ('afc5c741-f70a-4394-853b-39d51b118927', 1, 'lgutierrez', 'Luis', 'Gutierrez Mamani', 'ACTIVE', 'c3a8a7b1-f2d9-48c0-86ea-f215c2e6b3a3', 'MALE');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender)
values ('b2436b82-7b9f-4f0d-9463-f2c3173a45c3', 1, 'lmartinez', 'Laura', 'Martinez Paredes', 'INACTIVE', '8f6b61e7-efb2-4de7-b8ed-7438c9d8babe', 'FEMALE');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender)
values ('6e6a8a4e-9f6b-44eb-8c69-40acfdc86756', 1, 'rsantos', 'Roberto', 'Santos Escobar', 'ACTIVE','b0e8f394-78c1-4d8a-9c57-dc6e8b36a5fa', 'MALE');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender)
values ('36b0d1c6-bdc0-4d98-94bb-08b9bce3f0d5', 1, 'vmorales', 'Valeria', 'Morales Ochoa', 'INACTIVE', '6d63bc15-3f8b-46f7-9cf1-7e9b0b9a2b28', 'FEMALE');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender)
values ('5a1c6d80-58b3-43e3-a5a5-24b4a2d1d54a', 1, 'jramirez', 'Jorge', 'Ramirez Tapia', 'ACTIVE', 'c3a8a7b1-f2d9-48c0-86ea-f215c2e6b3a3', 'MALE');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender)
values ('9d6a5b2e-6d0b-4b89-8d6a-d3f3d1bfc047', 1, 'storres', 'Sandra', 'Torres Huanca', 'ACTIVE', '8f6b61e7-efb2-4de7-b8ed-7438c9d8babe', 'FEMALE');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender)
values ('f8b3e0c0-0d5a-4e5c-bf9d-207b9b5e8279', 1, 'fquispe', 'Felipe', 'Quispe Huanca', 'INACTIVE','b0e8f394-78c1-4d8a-9c57-dc6e8b36a5fa', 'MALE');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender)
values ('cd80e1d0-9a08-44a6-bd63-2c63eaa003d4', 1, 'grivas', 'Gabriela', 'Rivas Arana', 'ACTIVE', '6d63bc15-3f8b-46f7-9cf1-7e9b0b9a2b28', 'FEMALE');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender)
values ('62d3c1b7-815e-4e96-8d7e-f8c4236bca55', 1, 'oflores', 'Oscar', 'Flores Quiroga', 'INACTIVE', 'c3a8a7b1-f2d9-48c0-86ea-f215c2e6b3a3', 'MALE');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender)
values ('f20b7c5a-5a67-44f0-9ec1-4c1b8e80de05', 1, 'mvargas', 'Marta', 'Vargas Soria', 'ACTIVE', '8f6b61e7-efb2-4de7-b8ed-7438c9d8babe', 'FEMALE');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender)
values ('19b5a76e-d7b1-4b76-8b02-4d0748e85809', 1, 'aespinoza', 'Andres', 'Espinoza Chura', 'INACTIVE','b0e8f394-78c1-4d8a-9c57-dc6e8b36a5fa', 'MALE');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender)
values ('5c1a7b82-832d-4f24-8377-54b77b91b6a8', 1, 'cvillanueva', 'Carla', 'Villanueva Arce', 'ACTIVE', '6d63bc15-3f8b-46f7-9cf1-7e9b0b9a2b28', 'FEMALE');
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-e341-4e7a-b8a6-cab0982bd8c1', 1, '5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 'PATERNIDAD', 'APROBADO', 3, '2024-10-03', '2024-10-01', '2024-10-03', 3, 0); values ('9d6f12ba-e341-4e7a-b8a6-cab0982bd8c1', 1, '5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 'PATERNIDAD', 'APROBADO', 3, '2024-10-03', '2024-10-01', '2024-10-03', 3, 0);
@ -86,4 +118,4 @@ insert into time_off_request (id, version, employee_id, category, state, availab
values ('89bc4b2a-943f-487c-a9f3-bacf78145e67', 1, 'cba3efb7-32bc-44be-9fdc-fc5e4f211254', 'LUNES_CARNAVAL', 'APROBADO', 1, '2024-02-12', '2024-02-12', '2024-02-12', 1, 0); values ('89bc4b2a-943f-487c-a9f3-bacf78145e67', 1, 'cba3efb7-32bc-44be-9fdc-fc5e4f211254', 'LUNES_CARNAVAL', 'APROBADO', 1, '2024-02-12', '2024-02-12', '2024-02-12', 1, 0);
insert into timesheet_entry (id, version, task, details, date, hours, employee_id, team_id) insert into timesheet_entry (id, version, task, details, date, hours, employee_id, team_id)
values ('389389ce-7b2e-4f39-aa06-2a251a2b35ea', 0, 'coding', 'meet', '2024-11-27', 4, '5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 'b0e8f394-78c1-4d8a-9c57-dc6e8b36a5fa'); values ('389389ce-7b2e-4f39-aa06-2a251a2b35ea', 0, 'coding', 'meet', '2024-12-30', 4, '5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 'b0e8f394-78c1-4d8a-9c57-dc6e8b36a5fa');