Compare commits

...

11 Commits

Author SHA1 Message Date
4f6935341d Merge pull request 'Vacaciones' (#61) from Vacaciones into En-desarrollo
All checks were successful
PR Builder / Build-PR (pull_request) Successful in 2m32s
Reviewed-on: #61
2024-10-30 18:31:55 +00:00
98ed64dfda Listado Solicitudes de Empleado - Calcular totales
All checks were successful
PR Builder / Build-PR (pull_request) Successful in 0s
2024-10-29 15:28:20 -04:00
476884408a #37 Perfil de Personal Administrativo - Listado General de Vacaciones (Agregar total general) 2024-10-28 19:12:24 -04:00
f0c0811f0d #55 Perfil de Personal Administrativo - Añadir Vacaciones del Empleado (Verificacion obtencion de datos) 2024-10-28 18:16:44 -04:00
7d20703a7d #55 Perfil de Personal Administrativo - Añadir Vacaciones del Empleado (Verificacion de validaciones) 2024-10-28 00:55:41 -04:00
73915b1364 #55 Perfil de Personal Administrativo - Añadir Vacaciones del Empleado (Correccion) 2024-10-27 20:05:31 -04:00
6a1d3e70c6 #37 Perfil de Personal Administrativo - Listado General de Vacaciones (Correcciones) 2024-10-27 00:19:56 -04:00
807555a2dd #55 Perfil de Personal Administrativo - Añadir Vacaciones del Empleado (Configurar habilitacion categoria si previa solicitud expira) 2024-10-23 15:09:36 -04:00
cb3ed95c0c #55 Perfil de Personal Administrativo - Añadir Vacaciones del Empleado (Configurar vacacion por antiguedad del empleado) 2024-10-23 08:02:12 -04:00
52bed61ae8 #55 Perfil de Personal Administrativo - Añadir Vacaciones del Empleado (Configurar categoria Permiso de Salud) 2024-10-23 07:28:15 -04:00
0117915b9d #55 Perfil de Personal Administrativo - Añadir Vacaciones del Empleado (Configurar si DaysBalance sea mayor a cero) 2024-10-22 00:20:13 -04:00
8 changed files with 296 additions and 173 deletions

View File

@ -8,8 +8,6 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.time.LocalDate;
@Data @Data
@Entity @Entity
@AllArgsConstructor @AllArgsConstructor
@ -18,7 +16,8 @@ import java.time.LocalDate;
public class Vacation extends BaseEntity { public class Vacation extends BaseEntity {
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
private TimeOffRequestType category; private TimeOffRequestType category;
private LocalDate vacationDate; private Integer monthOfYear;
private Integer dayOfMonth;
private Double duration; private Double duration;
private Double expiration; private Double expiration;
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)

View File

@ -2,6 +2,7 @@ package com.primefactorsolutions.repositories;
import com.primefactorsolutions.model.TimeOffRequest; import com.primefactorsolutions.model.TimeOffRequest;
import com.primefactorsolutions.model.TimeOffRequestStatus; import com.primefactorsolutions.model.TimeOffRequestStatus;
import com.primefactorsolutions.model.TimeOffRequestType;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List; import java.util.List;
@ -11,4 +12,5 @@ import java.util.UUID;
public interface TimeOffRequestRepository extends JpaRepository<TimeOffRequest, UUID> { public interface TimeOffRequestRepository extends JpaRepository<TimeOffRequest, UUID> {
List<TimeOffRequest> findByEmployeeId(UUID idEmployee); List<TimeOffRequest> findByEmployeeId(UUID idEmployee);
Optional<TimeOffRequest> findByEmployeeIdAndState(UUID employeeId, TimeOffRequestStatus state); Optional<TimeOffRequest> findByEmployeeIdAndState(UUID employeeId, TimeOffRequestStatus state);
List<TimeOffRequest> findByEmployeeIdAndCategory(UUID employeeId, TimeOffRequestType category);
} }

View File

@ -38,4 +38,8 @@ public class TimeOffRequestService {
public Optional<TimeOffRequest> findByEmployeeAndState(final UUID employeeId, final TimeOffRequestStatus state) { public Optional<TimeOffRequest> findByEmployeeAndState(final UUID employeeId, final TimeOffRequestStatus state) {
return timeOffRequestRepository.findByEmployeeIdAndState(employeeId, state); return timeOffRequestRepository.findByEmployeeIdAndState(employeeId, state);
} }
public List<TimeOffRequest> findByEmployeeAndCategory(final UUID employeeId, final TimeOffRequestType category) {
return timeOffRequestRepository.findByEmployeeIdAndCategory(employeeId, category);
}
} }

View File

@ -6,6 +6,8 @@ import com.primefactorsolutions.repositories.VacationRepository;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
@Service @Service
@AllArgsConstructor @AllArgsConstructor
public class VacationService { public class VacationService {
@ -15,4 +17,7 @@ public class VacationService {
return vacationRepository.findByCategory(category); return vacationRepository.findByCategory(category);
} }
} public List<Vacation> findVacations() {
return vacationRepository.findAll();
}
}

View File

@ -3,6 +3,7 @@ package com.primefactorsolutions.views;
import com.primefactorsolutions.model.*; import com.primefactorsolutions.model.*;
import com.primefactorsolutions.service.EmployeeService; import com.primefactorsolutions.service.EmployeeService;
import com.primefactorsolutions.service.TimeOffRequestService; import com.primefactorsolutions.service.TimeOffRequestService;
import com.primefactorsolutions.service.VacationService;
import com.vaadin.flow.component.button.Button; import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.combobox.ComboBox; import com.vaadin.flow.component.combobox.ComboBox;
import com.vaadin.flow.component.grid.Grid; import com.vaadin.flow.component.grid.Grid;
@ -20,7 +21,7 @@ import com.vaadin.flow.spring.annotation.SpringComponent;
import jakarta.annotation.security.PermitAll; import jakarta.annotation.security.PermitAll;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import java.time.Year; import java.time.LocalDate;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -35,6 +36,7 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
private final TimeOffRequestService requestService; private final TimeOffRequestService requestService;
private final EmployeeService employeeService; private final EmployeeService employeeService;
private final VacationService vacationService;
private final Grid<TimeOffRequest> requestGrid = new Grid<>(TimeOffRequest.class); private final Grid<TimeOffRequest> requestGrid = new Grid<>(TimeOffRequest.class);
private List<TimeOffRequest> requests = Collections.emptyList(); private List<TimeOffRequest> requests = Collections.emptyList();
private ComboBox<TimeOffRequestType> categoryFilter; private ComboBox<TimeOffRequestType> categoryFilter;
@ -42,15 +44,18 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
private UUID employeeId; private UUID employeeId;
private TimeOffRequest request; private TimeOffRequest request;
public RequestEmployeeView(final TimeOffRequestService requestService, final EmployeeService employeeService) { public RequestEmployeeView(final TimeOffRequestService requestService,
final EmployeeService employeeService,
final VacationService vacationService) {
this.requestService = requestService; this.requestService = requestService;
this.employeeService = employeeService; this.employeeService = employeeService;
this.vacationService = vacationService;
} }
private void initializeView() { private void initializeView() {
setupFilters(); setupFilters();
setupGrid(); setupGrid();
add(requestGrid, createSummaryLayout(), createActionButtons()); add(requestGrid, createActionButtons(), createSummaryLayout());
refreshRequestGrid(null, null); refreshRequestGrid(null, null);
} }
@ -80,8 +85,6 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
requestGrid.setColumns( requestGrid.setColumns(
"category", "category",
"state", "state",
"availableDays",
"expiration",
"startDate", "startDate",
"endDate", "endDate",
"daysToBeTake", "daysToBeTake",
@ -97,24 +100,33 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
} }
private VerticalLayout createSummaryLayout() { private VerticalLayout createSummaryLayout() {
int currentYear = Year.now().getValue(); double totalHoliday = requests.stream()
String yearCategory = "YEAR_" + currentYear; .filter(this::verificationIsHoliday)
double totalVacations = requests.stream()
.filter(req -> req.getCategory().name().equals(yearCategory))
.mapToDouble(TimeOffRequest::getAvailableDays) .mapToDouble(TimeOffRequest::getAvailableDays)
.sum(); .sum();
double totalTimeOff = requests.stream() double totalVacations = requests.stream()
.filter(req -> !req.getCategory().name().startsWith("YEAR")) .filter(req -> req.getCategory().toString().startsWith("VACATION"))
.mapToDouble(TimeOffRequest::getDaysBalance) .mapToDouble(TimeOffRequest::getAvailableDays)
.sum(); .sum();
double totalAvailableDays = totalVacations + totalTimeOff; double totalPersonalDays = requests.stream()
.filter(req -> !verificationIsHoliday(req)) // Solo los de tipo OTHER
.mapToDouble(TimeOffRequest::getAvailableDays)
.sum();
double totalAvailableDays = totalHoliday + totalVacations + totalPersonalDays;
return new VerticalLayout( return new VerticalLayout(
new Span("TOTAL HOLIDAYS: " + totalVacations), new Span("TOTAL HOLIDAYS: " + totalHoliday),
new Span("TOTAL TIME OFF: " + totalTimeOff), new Span("TOTAL VACATIONS: " + totalVacations),
new Span("TOTAL AVAILABLE DAYS: " + totalAvailableDays) new Span("TOTAL PERSONAL DAYS: " + totalPersonalDays),
new Span("TOTAL GENERAL: " + totalAvailableDays)
); );
} }
private Boolean verificationIsHoliday(final TimeOffRequest request) {
Vacation vacation = vacationService.findVacationByCategory(request.getCategory());
return vacation.getType() != Vacation.Type.OTHER;
}
private HorizontalLayout createActionButtons() { private HorizontalLayout createActionButtons() {
Button viewButton = new Button("View", event -> { Button viewButton = new Button("View", event -> {
if (request != null) { if (request != null) {
@ -154,6 +166,14 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
List<TimeOffRequest> filteredRequests = allFiltersAreNull(category, state) List<TimeOffRequest> filteredRequests = allFiltersAreNull(category, state)
? requestService.findRequestsByEmployeeId(employeeId) ? requestService.findRequestsByEmployeeId(employeeId)
: fetchFilteredTimeOffRequests(category, state); : fetchFilteredTimeOffRequests(category, state);
for (TimeOffRequest request : filteredRequests) {
if (request.getExpiration().isBefore(LocalDate.now())) {
request.setState(TimeOffRequestStatus.EXPIRED);
}
}
for (TimeOffRequest request : filteredRequests) {
requestService.saveTimeOffRequest(request);
}
requestGrid.setItems(filteredRequests); requestGrid.setItems(filteredRequests);
} }

View File

@ -19,8 +19,11 @@ import jakarta.annotation.security.PermitAll;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.UUID;
@SpringComponent @SpringComponent
@PermitAll @PermitAll
@ -43,6 +46,7 @@ public class RequestRegisterView extends VerticalLayout {
private final Binder<TimeOffRequest> binder; private final Binder<TimeOffRequest> binder;
private Vacation vacation; private Vacation vacation;
private Employee employee;
private LocalDate endDate; private LocalDate endDate;
private Button saveButton; private Button saveButton;
@ -65,8 +69,13 @@ public class RequestRegisterView extends VerticalLayout {
private void configureFormFields() { private void configureFormFields() {
employeeComboBox.setItems(employeeService.findAllEmployees()); employeeComboBox.setItems(employeeService.findAllEmployees());
employeeComboBox.setItemLabelGenerator(emp -> emp.getFirstName() + " " + emp.getLastName()); employeeComboBox.setItemLabelGenerator(emp -> emp.getFirstName() + " " + emp.getLastName());
employeeComboBox.addValueChangeListener(event -> handleEmployeeSelection(event.getValue())); employeeComboBox.addValueChangeListener(event -> {
employee = event.getValue();
handleEmployeeSelection(employee);
});
categoryComboBox.setEnabled(false); categoryComboBox.setEnabled(false);
startDatePicker.setEnabled(false);
endDatePicker.setEnabled(false);
categoryComboBox.addValueChangeListener(event -> handleCategorySelection(event.getValue())); categoryComboBox.addValueChangeListener(event -> handleCategorySelection(event.getValue()));
startDatePicker.addValueChangeListener(event -> updateDatePickerMinValues()); startDatePicker.addValueChangeListener(event -> updateDatePickerMinValues());
endDatePicker.addValueChangeListener(event -> calculateDays()); endDatePicker.addValueChangeListener(event -> calculateDays());
@ -114,72 +123,165 @@ public class RequestRegisterView extends VerticalLayout {
private void filterCategories(final Employee employee) { private void filterCategories(final Employee employee) {
List<TimeOffRequest> employeeRequests = requestService.findRequestsByEmployeeId(employee.getId()); List<TimeOffRequest> employeeRequests = requestService.findRequestsByEmployeeId(employee.getId());
List<TimeOffRequestType> requestedCategories = employeeRequests.stream() List<TimeOffRequestType> allCategories = Arrays.asList(TimeOffRequestType.values());
.map(TimeOffRequest::getCategory) List<TimeOffRequestType> availableCategories = allCategories.stream()
.toList(); .filter(category -> isCategoryAvailable(employeeRequests, category))
List<TimeOffRequestType> availableCategories = Arrays.stream(TimeOffRequestType.values()) .filter(category -> isCategoryAllowedByGender(category, employee.getGender()))
.filter(category -> !requestedCategories.contains(category))
.filter(category -> {
if (employee.getGender() == Employee.Gender.MALE) {
return category != TimeOffRequestType.MATERNITY
&& category != TimeOffRequestType.MOTHERS_DAY
&& category != TimeOffRequestType.INTERNATIONAL_WOMENS_DAY
&& category != TimeOffRequestType.NATIONAL_WOMENS_DAY;
} else {
return category != TimeOffRequestType.FATHERS_DAY
&& category != TimeOffRequestType.PATERNITY;
}
})
.toList(); .toList();
categoryComboBox.setItems(availableCategories); categoryComboBox.setItems(availableCategories);
} }
private boolean isCategoryAvailable(final List<TimeOffRequest> employeeRequests,
final TimeOffRequestType category) {
List<TimeOffRequest> requestsByCategory = employeeRequests.stream()
.filter(request -> request.getCategory() == category)
.toList();
if (requestsByCategory.isEmpty()) {
return true;
}
TimeOffRequest latestRequest = requestsByCategory.stream()
.max(Comparator.comparing(TimeOffRequest::getStartDate))
.orElse(null);
if (category == TimeOffRequestType.HEALTH_PERMIT
|| category == TimeOffRequestType.VACATION_CURRENT_MANAGEMENT
|| category == TimeOffRequestType.VACATION_PREVIOUS_MANAGEMENT) {
return latestRequest.getState() == TimeOffRequestStatus.EXPIRED
|| (latestRequest.getState() == TimeOffRequestStatus.TAKEN && latestRequest.getDaysBalance() > 0);
} else {
return latestRequest.getState() == TimeOffRequestStatus.EXPIRED;
}
}
private boolean isCategoryAllowedByGender(final TimeOffRequestType category, final Employee.Gender gender) {
if (gender == Employee.Gender.MALE) {
return category != TimeOffRequestType.MATERNITY
&& category != TimeOffRequestType.MOTHERS_DAY
&& category != TimeOffRequestType.INTERNATIONAL_WOMENS_DAY
&& category != TimeOffRequestType.NATIONAL_WOMENS_DAY;
} else {
return category != TimeOffRequestType.FATHERS_DAY
&& category != TimeOffRequestType.PATERNITY;
}
}
private void handleCategorySelection(final TimeOffRequestType selectedCategory) { private void handleCategorySelection(final TimeOffRequestType selectedCategory) {
clearForm();
if (selectedCategory != null) { if (selectedCategory != null) {
updateAvailableDays(selectedCategory); updateAvailableDays(selectedCategory);
startDatePicker.setEnabled(true);
} }
} }
private void updateAvailableDays(final TimeOffRequestType selectedCategory) { private void updateAvailableDays(final TimeOffRequestType selectedCategory) {
vacation = vacationService.findVacationByCategory(selectedCategory); vacation = vacationService.findVacationByCategory(selectedCategory);
UUID employeeId = employeeComboBox.getValue().getId();
List<TimeOffRequest> requests = requestService.findByEmployeeAndCategory(employeeId, selectedCategory);
if (vacation != null) { if (vacation != null) {
availableDaysField.setValue(vacation.getDuration()); TimeOffRequest requestWithBalance = requests.stream()
.filter(request -> request.getDaysBalance() > 0
&& request.getState() != TimeOffRequestStatus.EXPIRED)
.max(Comparator.comparing(TimeOffRequest::getStartDate))
.orElse(null);
if (requestWithBalance != null) {
if (requestWithBalance.getState() == TimeOffRequestStatus.TAKEN) {
availableDaysField.setValue(requestWithBalance.getDaysBalance());
} else if (requestWithBalance.getState() == TimeOffRequestStatus.EXPIRED) {
availableDaysField.setValue(vacation.getDuration());
}
} else if (vacation.getCategory() == TimeOffRequestType.VACATION_CURRENT_MANAGEMENT) {
LocalDate dateOfEntry = employeeComboBox.getValue().getDateOfEntry();
LocalDate currentDate = LocalDate.now();
long yearsOfService = ChronoUnit.YEARS.between(dateOfEntry, currentDate);
if (yearsOfService > 10) {
availableDaysField.setValue((double) 30);
} else if (yearsOfService > 5) {
availableDaysField.setValue((double) 20);
} else if (yearsOfService > 1) {
availableDaysField.setValue((double) 15);
} else {
availableDaysField.setValue((double) 0);
}
} else {
availableDaysField.setValue(vacation.getDuration());
}
setDatePickerLimits(vacation); setDatePickerLimits(vacation);
} }
} }
private void setDatePickerLimits(final Vacation vacation) { private void setDatePickerLimits(final Vacation vacation) {
LocalDate startDate; LocalDate startDate;
if (vacation.getVacationDate() != null) { endDate = null;
startDate = vacation.getVacationDate();
UUID employeeId = employee.getId();
List<TimeOffRequest> previousRequests
= requestService.findByEmployeeAndCategory(employeeId, vacation.getCategory());
int startYear;
if (previousRequests.isEmpty()) {
startYear = LocalDate.now().getYear();
} else {
int lastRequestYear = previousRequests.stream()
.max(Comparator.comparing(TimeOffRequest::getStartDate))
.map(request -> request.getStartDate().getYear())
.orElse(LocalDate.now().getYear());
int proposedYear = lastRequestYear + 1;
int currentYear = LocalDate.now().getYear();
if (proposedYear < currentYear) {
startYear = currentYear;
} else {
startYear = proposedYear;
}
}
if (vacation.getMonthOfYear() != null && vacation.getDayOfMonth() != null) {
startDate = LocalDate.of(
startYear,
vacation.getMonthOfYear().intValue(),
vacation.getDayOfMonth().intValue());
endDate = startDate.plusDays(vacation.getExpiration().intValue() - 1); endDate = startDate.plusDays(vacation.getExpiration().intValue() - 1);
} else { } else {
startDate = LocalDate.now(); if (vacation.getCategory() == TimeOffRequestType.BIRTHDAY && employee.getBirthday() != null) {
endDate = null; startDate = LocalDate.of(
startYear,
employee.getBirthday().getMonth(),
employee.getBirthday().getDayOfMonth());
endDate = startDate.plusDays(vacation.getExpiration().intValue() - 1);
} else if (vacation.getCategory() == TimeOffRequestType.HEALTH_PERMIT) {
startDate = LocalDate.now();
endDate = LocalDate.of(startYear, 12, 31);
} else {
startDate = LocalDate.now();
}
} }
startDatePicker.setValue(startDate);
if ((vacation.getDuration() != null && vacation.getDuration() == 0.5)
|| vacation.getCategory() == TimeOffRequestType.HEALTH_PERMIT) {
endDatePicker.setValue(startDate);
} else {
int durationDays = (vacation.getDuration() != null ? vacation.getDuration().intValue() - 1 : 0);
endDatePicker.setValue(startDate.plusDays(durationDays));
}
startDatePicker.setMin(startDate); startDatePicker.setMin(startDate);
startDatePicker.setMax(endDate); startDatePicker.setMax(endDate);
endDatePicker.setMin(startDate); endDatePicker.setMin(startDate);
endDatePicker.setMax(endDate); endDatePicker.setMax(endDate);
} }
private void updateDatePickerMinValues() { private void updateDatePickerMinValues() {
LocalDate startDate = startDatePicker.getValue(); LocalDate startDate = startDatePicker.getValue();
if (vacation.getVacationDate() == null) { if (vacation.getDuration() == 0.5) {
endDate = startDate.plusDays(vacation.getExpiration().intValue() - 1); endDatePicker.setValue(startDate.plusDays(0));
} } else {
if (startDate != null) { endDatePicker.setValue(startDate.plusDays(vacation.getDuration().intValue() - 1));
endDatePicker.setMin(startDate);
endDatePicker.setMax(startDate.plusDays(vacation.getExpiration().intValue() - 1));
if (vacation.getDuration() == 0.5) {
endDatePicker.setValue(startDate.plusDays(0));
} else {
endDatePicker.setValue(startDate.plusDays(vacation.getDuration().intValue() - 1));
}
calculateDays();
} }
calculateDays();
} }
private void calculateDays() { private void calculateDays() {
@ -188,25 +290,14 @@ public class RequestRegisterView extends VerticalLayout {
Double availableDays = availableDaysField.getValue(); Double availableDays = availableDaysField.getValue();
if (startDate != null && endDate != null) { if (startDate != null && endDate != null) {
if (startDate.isAfter(endDate)) {
endDatePicker.clear();
return;
}
double daysToBeTaken = java.time.temporal.ChronoUnit.DAYS.between(startDate, endDate) + 1; double daysToBeTaken = java.time.temporal.ChronoUnit.DAYS.between(startDate, endDate) + 1;
if (daysToBeTaken == 1 && vacation.getDuration() == 0.5) { if (vacation.getCategory() == TimeOffRequestType.HEALTH_PERMIT || vacation.getDuration() == 0.5) {
daysToBeTaken = 0.5; daysToBeTakenField.setValue(0.5);
}
daysToBeTakenField.setValue(daysToBeTaken);
double balanceDays = availableDays - daysToBeTaken;
if (balanceDays < 0) {
endDatePicker.clear();
daysToBeTakenField.clear();
balanceDaysField.clear();
} else { } else {
balanceDaysField.setValue(balanceDays); daysToBeTakenField.setValue(daysToBeTaken);
} }
double balanceDays = availableDays - daysToBeTakenField.getValue();
balanceDaysField.setValue(balanceDays);
} }
} }
@ -232,8 +323,26 @@ public class RequestRegisterView extends VerticalLayout {
private void saveRequest() { private void saveRequest() {
if (binder.validate().isOk()) { if (binder.validate().isOk()) {
TimeOffRequest request = binder.getBean(); TimeOffRequest request = binder.getBean();
request.setExpiration(endDate); request.setStartDate(startDatePicker.getValue());
request.setAvailableDays(availableDaysField.getValue());
if (endDate == null) {
request.setExpiration(endDatePicker.getValue());
} else {
request.setExpiration(endDate);
}
request.setState(TimeOffRequestStatus.REQUESTED); request.setState(TimeOffRequestStatus.REQUESTED);
List<TimeOffRequest> existingRequests =
requestService.findByEmployeeAndCategory(employee.getId(), request.getCategory());
int maxRequests = request.getCategory() == TimeOffRequestType.HEALTH_PERMIT ? 4 : 2;
if (existingRequests.size() >= maxRequests) {
existingRequests.stream()
.min(Comparator.comparing(TimeOffRequest::getStartDate))
.ifPresent(oldestRequest -> requestService.deleteTimeOffRequest(oldestRequest.getId()));
}
requestService.saveTimeOffRequest(request); requestService.saveTimeOffRequest(request);
Notification.show("Request saved successfully."); Notification.show("Request saved successfully.");
closeForm(); closeForm();
@ -242,6 +351,20 @@ public class RequestRegisterView extends VerticalLayout {
} }
} }
private void updateBalanceForCategory(final TimeOffRequest newRequest) {
List<TimeOffRequest> requests = requestService.findByEmployeeAndCategory(
newRequest.getEmployee().getId(), newRequest.getCategory());
if (vacation.getCategory() == TimeOffRequestType.HEALTH_PERMIT
&& vacation.getCategory() == TimeOffRequestType.VACATION_CURRENT_MANAGEMENT) {
for (TimeOffRequest request : requests) {
double newBalance = request.getDaysBalance() - newRequest.getDaysToBeTake();
request.setDaysBalance(newBalance);
requestService.saveTimeOffRequest(request);
}
}
}
private void closeForm() { private void closeForm() {
getUI().ifPresent(ui -> ui.navigate(RequestsListView.class)); getUI().ifPresent(ui -> ui.navigate(RequestsListView.class));
} }

View File

@ -4,6 +4,7 @@ import com.primefactorsolutions.model.*;
import com.primefactorsolutions.service.EmployeeService; import com.primefactorsolutions.service.EmployeeService;
import com.primefactorsolutions.service.TeamService; import com.primefactorsolutions.service.TeamService;
import com.primefactorsolutions.service.TimeOffRequestService; import com.primefactorsolutions.service.TimeOffRequestService;
import com.primefactorsolutions.service.VacationService;
import com.vaadin.flow.component.button.Button; import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.combobox.ComboBox; import com.vaadin.flow.component.combobox.ComboBox;
import com.vaadin.flow.component.html.Main; import com.vaadin.flow.component.html.Main;
@ -29,6 +30,7 @@ public class RequestsListView extends Main {
private final TimeOffRequestService requestService; private final TimeOffRequestService requestService;
private final EmployeeService employeeService; private final EmployeeService employeeService;
private final TeamService teamService; private final TeamService teamService;
private final VacationService vacationService;
private final PagingGrid<Employee> requestGrid = new PagingGrid<>(); private final PagingGrid<Employee> requestGrid = new PagingGrid<>();
private List<Employee> employees = Collections.emptyList(); private List<Employee> employees = Collections.emptyList();
@ -41,10 +43,12 @@ public class RequestsListView extends Main {
public RequestsListView(final TimeOffRequestService requestService, public RequestsListView(final TimeOffRequestService requestService,
final EmployeeService employeeService, final EmployeeService employeeService,
final TeamService teamService) { final TeamService teamService,
final VacationService vacationService) {
this.requestService = requestService; this.requestService = requestService;
this.employeeService = employeeService; this.employeeService = employeeService;
this.teamService = teamService; this.teamService = teamService;
this.vacationService = vacationService;
this.employees = employeeService.findAllEmployees(); this.employees = employeeService.findAllEmployees();
initializeView(); initializeView();
refreshGeneralRequestGrid(null, null, null, null); refreshGeneralRequestGrid(null, null, null, null);
@ -60,18 +64,14 @@ public class RequestsListView extends Main {
private void setupFilters() { private void setupFilters() {
add(createEmployeeFilter()); add(createEmployeeFilter());
add(createTeamFilter()); add(createTeamFilter());
add(createCategoryFilter());
add(createStateFilter()); add(createStateFilter());
} }
private void setupRequestGrid() { private void setupRequestGrid() {
requestGrid.addColumn(this::getEmployeeFullName).setHeader("Employee"); requestGrid.addColumn(this::getEmployeeFullName).setHeader("Employee");
requestGrid.addColumn(this::getTeamName).setHeader("Team"); requestGrid.addColumn(this::getTeamName).setHeader("Team");
requestGrid.addColumn(this::getEmployeeStatus).setHeader("State"); requestGrid.addColumn(this::getEmployeeStatus).setHeader("Employee State");
requestGrid.addColumn(this::getCategory).setHeader("Category"); requestGrid.addColumn(this::getGeneralTotal).setHeader("General Total");
requestGrid.addColumn(this::getStartDate).setHeader("Start Date");
requestGrid.addColumn(this::getEndDate).setHeader("End Date");
requestGrid.addColumn(this::getDaysBalance).setHeader("Days Balance");
requestGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM); requestGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM);
requestGrid.setPageSize(5); requestGrid.setPageSize(5);
@ -101,7 +101,7 @@ public class RequestsListView extends Main {
final Status state) { final Status state) {
requestGrid.setPagingDataProvider((page, pageSize) -> { requestGrid.setPagingDataProvider((page, pageSize) -> {
int start = (int) (page * requestGrid.getPageSize()); int start = (int) (page * requestGrid.getPageSize());
return fetchFilteredEmployees(start, pageSize, employee, team, category, state); return fetchFilteredEmployees(start, pageSize, employee, team, state);
}); });
requestGrid.getDataProvider().refreshAll(); requestGrid.getDataProvider().refreshAll();
} }
@ -110,8 +110,7 @@ public class RequestsListView extends Main {
final int pageSize, final int pageSize,
final Employee employee, final Employee employee,
final Team team, final Team team,
final TimeOffRequestType category, final Status employeeState) {
final Status state) {
List<Employee> filteredEmployees = employeeService.findAllEmployees(); List<Employee> filteredEmployees = employeeService.findAllEmployees();
if (employee != null && !"ALL".equals(employee.getFirstName())) { if (employee != null && !"ALL".equals(employee.getFirstName())) {
@ -126,22 +125,12 @@ public class RequestsListView extends Main {
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
if (category != null && category != TimeOffRequestType.values()[0]) { if (employeeState != null && employeeState != Status.ALL) {
filteredEmployees = filteredEmployees.stream() filteredEmployees = filteredEmployees.stream()
.filter(emp -> { .filter(emp -> {
Optional<TimeOffRequest> request = requestService Optional<TimeOffRequest> request = requestService
.findByEmployeeAndState(emp.getId(), TimeOffRequestStatus.TAKEN); .findByEmployeeAndState(emp.getId(), TimeOffRequestStatus.TAKEN);
return request.isPresent() && request.get().getCategory() == category; return employeeState == Status.IDLE ? request.isPresent() : request.isEmpty();
})
.collect(Collectors.toList());
}
if (state != null && state != Status.ALL) {
filteredEmployees = filteredEmployees.stream()
.filter(emp -> {
Optional<TimeOffRequest> request = requestService
.findByEmployeeAndState(emp.getId(), TimeOffRequestStatus.TAKEN);
return state == Status.IDLE ? request.isPresent() : request.isEmpty();
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@ -163,35 +152,38 @@ public class RequestsListView extends Main {
return "ALL".equals(team.getName()) ? "ALL" : team.getName(); return "ALL".equals(team.getName()) ? "ALL" : team.getName();
} }
private String getEmployeeStatus(final Employee employee) { private String getEmployeeStatus(final Employee employee) {
Optional<TimeOffRequest> activeRequest = requestService Optional<TimeOffRequest> activeRequest = requestService
.findByEmployeeAndState(employee.getId(), TimeOffRequestStatus.TAKEN); .findByEmployeeAndState(employee.getId(), TimeOffRequestStatus.TAKEN);
return activeRequest.isPresent() ? "IDLE" : "ACTIVE"; return activeRequest.isPresent() ? "IDLE" : "ACTIVE";
} }
private String getCategory(final Employee employee) { private String getGeneralTotal(final Employee employee) {
Optional<TimeOffRequest> activeRequest = requestService List<TimeOffRequest> employeeRequests = requestService.findRequestsByEmployeeId(employee.getId());
.findByEmployeeAndState(employee.getId(), TimeOffRequestStatus.TAKEN); List<Vacation> vacations = vacationService.findVacations();
return activeRequest.map(request -> request.getCategory().toString()).orElse(""); double totalUtilized = employeeRequests.stream()
} .filter(Objects::nonNull)
.mapToDouble(request -> {
private String getStartDate(final Employee employee) { Double daysBalance = request.getAvailableDays();
Optional<TimeOffRequest> activeRequest = requestService return daysBalance != null ? daysBalance : 0.0;
.findByEmployeeAndState(employee.getId(), TimeOffRequestStatus.TAKEN); })
return activeRequest.map(request -> request.getStartDate().toString()).orElse(""); .sum();
} double totalUnused = employeeRequests.stream()
.filter(Objects::nonNull)
private String getEndDate(final Employee employee) { .mapToDouble(request -> {
Optional<TimeOffRequest> activeRequest = requestService Double daysBalance = request.getDaysBalance();
.findByEmployeeAndState(employee.getId(), TimeOffRequestStatus.TAKEN); return daysBalance != null ? daysBalance : 0.0;
return activeRequest.map(request -> request.getEndDate().toString()).orElse(""); })
} .sum();
double totalAvailable = vacations.stream()
private String getDaysBalance(final Employee employee) { .filter(Objects::nonNull)
Optional<TimeOffRequest> activeRequest = requestService .mapToDouble(request -> {
.findByEmployeeAndState(employee.getId(), TimeOffRequestStatus.TAKEN); Double daysBalance = request.getDuration();
return activeRequest.map(request -> request.getDaysBalance().toString()).orElse(""); return daysBalance != null ? daysBalance : 0.0;
})
.sum();
double generalTotal = (totalAvailable - totalUtilized) + totalUnused;
return String.valueOf(generalTotal);
} }
private ComboBox<Employee> createEmployeeFilter() { private ComboBox<Employee> createEmployeeFilter() {
@ -230,23 +222,8 @@ public class RequestsListView extends Main {
return teamFilter; return teamFilter;
} }
private ComboBox<TimeOffRequestType> createCategoryFilter() {
categoryFilter = new ComboBox<>("Category");
categoryFilter.setItems(TimeOffRequestType.values());
categoryFilter.setValue(TimeOffRequestType.values()[0]);
categoryFilter.addValueChangeListener(event ->
refreshGeneralRequestGrid(
employeeFilter.getValue(),
teamFilter.getValue(),
event.getValue(),
stateFilter.getValue()
)
);
return categoryFilter;
}
private ComboBox<Status> createStateFilter() { private ComboBox<Status> createStateFilter() {
stateFilter = new ComboBox<>("State"); stateFilter = new ComboBox<>("Employee State");
stateFilter.setItems(Status.values()); stateFilter.setItems(Status.values());
stateFilter.setValue(Status.values()[0]); stateFilter.setValue(Status.values()[0]);
stateFilter.addValueChangeListener(event -> stateFilter.addValueChangeListener(event ->

View File

@ -16,39 +16,39 @@ INSERT INTO team (id, version, name) VALUES ('c3a8a7b1-f2d9-48c0-86ea-f215c2e6b3
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 vacation (id, version, category, vacation_date, duration, expiration, type) VALUES ('123e4567-e89b-12d3-a456-426614174000', 1, 'NEW_YEAR', '2024-01-01', 1, 1, 'FIXED'); INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('123e4567-e89b-12d3-a456-426614174000', 1, 'NEW_YEAR', 1, 1, 1, 1, 'FIXED');
INSERT INTO vacation (id, version, category, vacation_date, duration, expiration, type) VALUES ('223e4567-e89b-12d3-a456-426614174001', 1, 'MONDAY_CARNIVAL', '2024-02-12', 1, 1, 'FIXED'); INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('223e4567-e89b-12d3-a456-426614174001', 1, 'MONDAY_CARNIVAL', 2, 12, 1, 1, 'FIXED');
INSERT INTO vacation (id, version, category, vacation_date, duration, expiration, type) VALUES ('323e4567-e89b-12d3-a456-426614174002', 1, 'TUESDAY_CARNIVAL', '2024-02-13', 1, 1, 'FIXED'); INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('323e4567-e89b-12d3-a456-426614174002', 1, 'TUESDAY_CARNIVAL', 2, 13, 1, 1, 'FIXED');
INSERT INTO vacation (id, version, category, vacation_date, duration, expiration, type) VALUES ('423e4567-e89b-12d3-a456-426614174003', 1, 'GOOD_FRIDAY', '2024-03-29', 1, 1, 'FIXED'); INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('423e4567-e89b-12d3-a456-426614174003', 1, 'GOOD_FRIDAY', 3, 29, 1, 1, 'FIXED');
INSERT INTO vacation (id, version, category, vacation_date, duration, expiration, type) VALUES ('523e4567-e89b-12d3-a456-426614174004', 1, 'LABOR_DAY', '2024-05-01', 1, 1, 'FIXED'); INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('523e4567-e89b-12d3-a456-426614174004', 1, 'LABOR_DAY', 5, 1, 1, 1, 'FIXED');
INSERT INTO vacation (id, version, category, vacation_date, duration, expiration, type) VALUES ('623e4567-e89b-12d3-a456-426614174005', 1, 'INDEPENDENCE_DAY', '2024-08-06', 1, 1, 'FIXED'); INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('623e4567-e89b-12d3-a456-426614174005', 1, 'INDEPENDENCE_DAY', 8, 6, 1, 1, 'FIXED');
INSERT INTO vacation (id, version, category, vacation_date, duration, expiration, type) VALUES ('723e4567-e89b-12d3-a456-426614174006', 1, 'CHRISTMAS', '2024-12-25', 1, 1, 'FIXED'); INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('723e4567-e89b-12d3-a456-426614174006', 1, 'CHRISTMAS', 12, 25, 1, 1, 'FIXED');
INSERT INTO vacation (id, version, category, vacation_date, duration, expiration, type) VALUES ('823e4567-e89b-12d3-a456-426614174007', 1, 'PRURINATIONAL_STATE_DAY', '2024-01-21', 3, 30, 'MOVABLE'); INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('823e4567-e89b-12d3-a456-426614174007', 1, 'PRURINATIONAL_STATE_DAY', 1, 21, 1, 30, 'MOVABLE');
INSERT INTO vacation (id, version, category, vacation_date, duration, expiration, type) VALUES ('923e4567-e89b-12d3-a456-426614174008', 1, 'CORPUS_CHRISTI', '2024-05-30', 1, 30, 'MOVABLE'); INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('923e4567-e89b-12d3-a456-426614174008', 1, 'CORPUS_CHRISTI', 5, 30, 1, 30, 'MOVABLE');
INSERT INTO vacation (id, version, category, vacation_date, duration, expiration, type) VALUES ('a23e4567-e89b-12d3-a456-426614174009', 1, 'ANDEAN_NEW_YEAR', '2024-06-21', 1, 30, 'MOVABLE'); INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('a23e4567-e89b-12d3-a456-426614174009', 1, 'ANDEAN_NEW_YEAR', 6, 21, 1, 30, 'MOVABLE');
INSERT INTO vacation (id, version, category, vacation_date, duration, expiration, type) VALUES ('b23e4567-e89b-12d3-a456-42661417400a', 1, 'DEPARTMENTAL_ANNIVERSARY', '2024-09-14', 1, 30, 'MOVABLE'); INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('b23e4567-e89b-12d3-a456-42661417400a', 1, 'DEPARTMENTAL_ANNIVERSARY', 9, 14, 1, 30, 'MOVABLE');
INSERT INTO vacation (id, version, category, vacation_date, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417400b', 1, 'ALL_SOULS_DAY', '2024-11-02', 1, 30, 'MOVABLE'); INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417400b', 1, 'ALL_SOULS_DAY', 11, 2, 1, 30, 'MOVABLE');
INSERT INTO vacation (id, version, category, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417400c', 1, 'BIRTHDAY', 0.5, 365, 'OTHER'); INSERT INTO vacation (id, version, category, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417400c', 1, 'BIRTHDAY', 0.5, 365, 'OTHER');
INSERT INTO vacation (id, version, category, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417400d', 1, 'MATERNITY', 90, 90, 'OTHER'); INSERT INTO vacation (id, version, category, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417400d', 1, 'MATERNITY', 90, 90, 'OTHER');
INSERT INTO vacation (id, version, category, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417400e', 1, 'PATERNITY', 3, 3, 'OTHER'); INSERT INTO vacation (id, version, category, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417400e', 1, 'PATERNITY', 3, 3, 'OTHER');
INSERT INTO vacation (id, version, category, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417400f', 1, 'MARRIAGE', 3, 3, 'OTHER'); INSERT INTO vacation (id, version, category, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417400f', 1, 'MARRIAGE', 3, 3, 'OTHER');
INSERT INTO vacation (id, version, category, vacation_date, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417401a', 1, 'FATHERS_DAY', '2024-03-19', 0.5, 30, 'OTHER'); INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417401a', 1, 'FATHERS_DAY', 3, 19, 0.5, 30, 'OTHER');
INSERT INTO vacation (id, version, category, vacation_date, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417401b', 1, 'MOTHERS_DAY', '2024-05-27', 0.5, 30, 'OTHER'); INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417401b', 1, 'MOTHERS_DAY', 5, 27, 0.5, 30, 'OTHER');
INSERT INTO vacation (id, version, category, vacation_date, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417401c', 1, 'INTERNATIONAL_WOMENS_DAY', '2024-03-08', 0.5, 30, 'OTHER'); INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417401c', 1, 'INTERNATIONAL_WOMENS_DAY', 3, 8, 0.5, 30, 'OTHER');
INSERT INTO vacation (id, version, category, vacation_date, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417401d', 1, 'NATIONAL_WOMENS_DAY', '2024-10-11', 0.5, 30, 'OTHER'); INSERT INTO vacation (id, version, category, month_of_year, day_of_month, duration, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417401d', 1, 'NATIONAL_WOMENS_DAY', 10, 11, 0.5, 30, 'OTHER');
INSERT INTO vacation (id, version, category, duration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417401e', 1, 'HEALTH_PERMIT', 2, 'OTHER'); INSERT INTO vacation (id, version, category, duration, type) VALUES ('c23e4567-e89b-12d3-a456-42661417401e', 1, 'HEALTH_PERMIT', 2, 'OTHER');
INSERT INTO vacation (id, version, category, expiration, type) VALUES ('490e5fbe-895b-42f8-b914-95437f7b39c0', 1, 'VACATION_CURRENT_MANAGEMENT', 730, 'OTHER'); INSERT INTO vacation (id, version, category, expiration, type) VALUES ('490e5fbe-895b-42f8-b914-95437f7b39c0', 1, 'VACATION_CURRENT_MANAGEMENT', 730, 'OTHER');
INSERT INTO vacation (id, version, category, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-4266141740ff', 1, 'VACATION_PREVIOUS_MANAGEMENT', 730, 'OTHER'); INSERT INTO vacation (id, version, category, expiration, type) VALUES ('c23e4567-e89b-12d3-a456-4266141740ff', 1, 'VACATION_PREVIOUS_MANAGEMENT', 730, 'OTHER');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender) values ('5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 1, 'bob', 'Bob', 'Test', 'ACTIVE','b0e8f394-78c1-4d8a-9c57-dc6e8b36a5fa', 'MALE'); insert into employee (id, version, username, first_name, last_name, status, team_id, gender, birthday, date_of_entry) values ('5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 1, 'bob', 'Bob', 'Test', 'ACTIVE','b0e8f394-78c1-4d8a-9c57-dc6e8b36a5fa', 'MALE', '2024-02-20', '2013-10-22');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender) values ('cba3efb7-32bc-44be-9fdc-fc5e4f211254', 1, 'ben', 'Ben', 'Test', 'ACTIVE', '6d63bc15-3f8b-46f7-9cf1-7e9b0b9a2b28', 'MALE'); insert into employee (id, version, username, first_name, last_name, status, team_id, gender, date_of_entry) values ('cba3efb7-32bc-44be-9fdc-fc5e4f211254', 1, 'ben', 'Ben', 'Test', 'ACTIVE', '6d63bc15-3f8b-46f7-9cf1-7e9b0b9a2b28', 'MALE', '2016-10-23');
insert into employee (id, version, username, first_name, last_name, status, team_id, gender) values ('e99b7af5-7d3a-4c0f-b8bc-e8d0388d8fc4', 1, 'jperez', 'Juan', 'Perez Condori', 'INACTIVE', 'c3a8a7b1-f2d9-48c0-86ea-f215c2e6b3a3', 'MALE'); 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) values ('f6ab3c6d-7078-45f6-9b22-4e37637bfec6', 1, 'agarcia', 'Ana', 'Garcia Rojas', 'ACTIVE', '8f6b61e7-efb2-4de7-b8ed-7438c9d8babe', 'FEMALE'); 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 ('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 ('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 ('afc5c741-f70a-4394-853b-39d51b118927', 1, 'lgutierrez', 'Luis', 'Gutierrez Mamani', 'ACTIVE', 'c3a8a7b1-f2d9-48c0-86ea-f215c2e6b3a3', 'MALE');
@ -66,32 +66,25 @@ insert into employee (id, version, username, first_name, last_name, status, team
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', 'PATERNITY', 'TAKEN', 15, '2025-12-31', '2024-10-01', '2024-10-10', 5, 10); values ('9d6f12ba-e341-4e7a-b8a6-cab0982bd8c1', 1, '5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 'PATERNITY', 'TAKEN', 3, '2024-10-03', '2024-10-01', '2024-10-03', 3, 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 ('2fa314bc-f547-4b12-a8b6-bb789feabc12', 1, '19b5a76e-d7b1-4b76-8b02-4d0748e85809', 'BIRTHDAY', 'APPROVED', 15, '2025-12-31', '2024-12-01', '2024-12-15', 7, 8); values ('9a6f12ba-e111-4e7a-b8a6-caa0982bd8a1', 1, '5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 'NEW_YEAR', 'EXPIRED', 1, '2024-01-01', '2024-01-01', '2024-01-01', 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 ('d5f6341a-913d-4e7f-a0b2-cfe0786acd34', 1, 'cba3efb7-32bc-44be-9fdc-fc5e4f211254', 'HEALTH_PERMIT', 'IN_USE', 20, '2025-11-30', '2024-11-10', '2024-11-20', 10, 10); values ('9b6f12ba-e222-4e7a-b8a6-caa0982bd8b2', 1, '5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 'MONDAY_CARNIVAL', 'APPROVED', 1, '2025-02-12', '2025-02-12', '2025-02-12', 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 ('4f913b23-ff23-4527-bcd6-adfe01234567', 1, 'e99b7af5-7d3a-4c0f-b8bc-e8d0388d8fc4', 'MATERNITY', 'IN_USE', 18, '2025-06-30', '2024-07-01', '2024-07-15', 10, 8); values ('9c6f12ba-e333-4e7a-b8a6-caa0982bd8c3', 1, '5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 'TUESDAY_CARNIVAL', 'UNDER_REVIEW', 1, '2025-02-13', '2025-02-13', '2025-02-13', 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 ('8c653f2a-f9a3-4d67-b3b6-12ad98fe0983', 1, 'f6ab3c6d-7078-45f6-9b22-4e37637bfec6', 'LABOR_DAY', 'REQUESTED', 10, '2025-10-31', '2024-09-15', '2024-09-20', 5, 5); values ('9d6f12ba-e444-4e7a-b8a6-caa0982bd8d4', 1, '5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 'GOOD_FRIDAY', 'COMPLETED', 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 ('fb9d9d75-b2ab-4ea4-b8b3-0a8f89e5c123', 1, '2e2293b1-3f9a-4f3d-abc8-32639b0a5e15', 'INDEPENDENCE_DAY', 'IN_USE', 12, '2025-08-31', '2024-08-05', '2024-08-15', 6, 6); values ('9e6f12ba-e555-4e7a-b8a6-caa0982bd8e5', 1, '5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 'LABOR_DAY', 'REJECTED', 1, '2025-05-01', '2024-05-01', '2024-05-01', 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 ('1c913a12-46e9-47b7-9e31-ab903fedc789', 1, '4b1c6c35-4627-4b35-b6e9-dc75c68b2c31', 'BIRTHDAY', 'APPROVED', 14, '2025-12-31', '2024-10-20', '2024-10-25', 5, 9); values ('8c653f2a-f9a3-4d67-b3b6-12ad98fe0983', 1, 'f6ab3c6d-7078-45f6-9b22-4e37637bfec6', 'LABOR_DAY', 'REQUESTED', 1, '2025-05-01', '2024-05-01', '2024-05-01', 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 ('b1249d3a-cc34-4954-88d9-1e4f67fe2436', 1, 'afc5c741-f70a-4394-853b-39d51b118927', 'MATERNITY', 'APPROVED', 20, '2025-11-30', '2024-11-05', '2024-11-12', 7, 13); values ('fb9d9d75-b2ab-4ea4-b8b3-0a8f89e5c123', 1, '2e2293b1-3f9a-4f3d-abc8-32639b0a5e15', 'INDEPENDENCE_DAY', 'IN_USE', 1, '2025-08-06', '2024-08-06', '2024-08-06', 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 ('6fdc47a8-127b-41c4-8d12-7fc12098ab12', 1, 'b2436b82-7b9f-4f0d-9463-f2c3173a45c3', 'ALL_SOULS_DAY', 'PENDING', 18, '2025-06-30', '2024-07-10', '2024-07-20', 8, 10); values ('6fdc47a8-127b-41c4-8d12-7fc12098ab12', 1, 'b2436b82-7b9f-4f0d-9463-f2c3173a45c3', 'ALL_SOULS_DAY', 'PENDING', 1, '2025-12-01', '2025-11-02', '2025-11-02', 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 ('12ec8b74-983d-4a17-b67e-134f45ae904c', 1, '5c1a7b82-832d-4f24-8377-54b77b91b6a8', 'NEW_YEAR', 'PENDING', 15, '2025-12-31', '2024-09-01', '2024-09-05', 4, 11); values ('12ec8b74-983d-4a17-b67e-134f45ae904c', 1, '5c1a7b82-832d-4f24-8377-54b77b91b6a8', 'NEW_YEAR', 'PENDING', 1, '2025-01-01', '2025-01-01', '2025-01-01', 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 ('89bc4b2a-943f-487c-a9f3-bacf78145e67', 1, 'cba3efb7-32bc-44be-9fdc-fc5e4f211254', 'MONDAY_CARNIVAL', 'APPROVED', 20, '2025-11-30', '2024-10-25', '2024-11-05', 9, 11); values ('89bc4b2a-943f-487c-a9f3-bacf78145e67', 1, 'cba3efb7-32bc-44be-9fdc-fc5e4f211254', 'MONDAY_CARNIVAL', 'APPROVED', 1, '2025-02-12', '2024-02-12', '2024-02-12', 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)
values ('37adfc2a-7463-4b2d-a7c1-fae04567cdef', 1, 'e99b7af5-7d3a-4c0f-b8bc-e8d0388d8fc4', 'BIRTHDAY', 'REQUESTED', 18, '2025-06-30', '2024-06-01', '2024-06-10', 6, 12);
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 ('2bc138ea-12db-4b89-a0b4-78e045e34b4e', 1, 'f6ab3c6d-7078-45f6-9b22-4e37637bfec6', 'MATERNITY', 'REQUESTED', 10, '2025-10-31', '2024-10-01', '2024-10-10', 3, 7);
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 ('14de1a56-6893-4e12-90f3-4faec457f002', 1, 'cd80e1d0-9a08-44a6-bd63-2c63eaa003d4', 'HEALTH_PERMIT', 'PENDING', 22, '2025-08-31', '2024-07-15', '2024-07-25', 8, 14);
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 ('fb08a6c9-cd17-42e8-b9e2-734ec834cae2', 1, '4b1c6c35-4627-4b35-b6e9-dc75c68b2c31', 'HEALTH_PERMIT', 'PENDING', 16, '2025-12-31', '2024-09-30', '2024-10-05', 4, 12);