Añadir correcion de formato
Some checks failed
PR Builder / Build-PR (pull_request) Failing after 2m40s

This commit is contained in:
Melina Gutierrez 2024-11-15 12:26:47 -04:00
parent e8612aa5df
commit 03146b1b9b
6 changed files with 21 additions and 16 deletions

View File

@ -34,13 +34,13 @@ public class HoursWorked extends BaseEntity {
private double horaspendientes;
private double totalHours;
public static double calculateTotalHours(List<HoursWorked> activities) {
public static double calculateTotalHours(final List<HoursWorked> activities) {
return activities.stream()
.mapToDouble(activity -> activity.hours + activity.horasTareasEspecificas)
.sum();
}
public static double calculatePendingHours(List<HoursWorked> activities) {
public static double calculatePendingHours(final List<HoursWorked> activities) {
double totalHoursWorked = calculateTotalHours(activities);
return Math.max(0, 40 - totalHoursWorked);
}

View File

@ -11,7 +11,7 @@ public interface EmployeeRepository extends JpaRepository<Employee, UUID> {
Optional<Employee> findByUsername(String username);
Optional<Employee> findByPersonalEmail(String personalEmail);
Optional<Employee> findByTeamIdAndLeadManagerTrue(UUID teamId);
Optional<Employee> findByTeamIdAndLeadManager(UUID teamId);
List<Employee> findByTeamName(String teamName);
}

View File

@ -50,7 +50,7 @@ public class EmployeeService {
public String getTeamLeadName(final UUID teamId) {
// Encuentra al empleado con el rol de lead_manager en el equipo especificado
Optional<Employee> leadManager = employeeRepository.findByTeamIdAndLeadManagerTrue(teamId);
Optional<Employee> leadManager = employeeRepository.findByTeamIdAndLeadManager(teamId);
return leadManager.map(employee -> employee.getFirstName() + " " + employee.getLastName())
.orElse("No asignado");

View File

@ -22,7 +22,7 @@ public class HoursWorkedService {
return hoursWorkedRepository.findAll();
}
public double getTotalHoursWorkedByEmployeeForWeek(UUID employeeId, int weekNumber) {
public double getTotalHoursWorkedByEmployeeForWeek(final UUID employeeId, final int weekNumber) {
List<HoursWorked> hoursWorkedList = hoursWorkedRepository.findByWeekNumber(weekNumber);
return hoursWorkedList.stream()
.filter(hw -> hw.getEmployee().getId().equals(employeeId))
@ -44,12 +44,12 @@ public class HoursWorkedService {
return hoursWorkedRepository.save(hoursWorked);
}
public double getTotalHoursForEmployee(UUID employeeId, int weekNumber) {
public double getTotalHoursForEmployee(final UUID employeeId, final int weekNumber) {
List<HoursWorked> activities = hoursWorkedRepository.findByEmployeeIdAndWeekNumber(employeeId, weekNumber);
return HoursWorked.calculateTotalHours(activities);
}
public double getPendingHoursForEmployee(UUID employeeId, int weekNumber) {
public double getPendingHoursForEmployee(final UUID employeeId, final int weekNumber) {
List<HoursWorked> activities = hoursWorkedRepository.findByEmployeeIdAndWeekNumber(employeeId, weekNumber);
return HoursWorked.calculatePendingHours(activities);
}

View File

@ -172,5 +172,6 @@ public class ReportService {
cfg.setFallbackOnNullLoopVariable(false);
cfg.setSQLDateAndTimeTimeZone(TimeZone.getDefault());
return cfg;}
return cfg;
}
}

View File

@ -15,7 +15,6 @@ import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.spring.annotation.SpringComponent;
import jakarta.annotation.security.PermitAll;
import org.joda.time.Hours;
import org.springframework.context.annotation.Scope;
import org.vaadin.firitin.components.grid.PagingGrid;
@ -63,7 +62,8 @@ public class HoursWorkedListView extends Main {
.mapToDouble(HoursWorked::getTotalHours)
.sum();
Notification.show("Total de horas trabajadas: " + totalHours, 3000, Notification.Position.BOTTOM_CENTER);
Notification.show("Total de horas trabajadas: " + totalHours,
3000, Notification.Position.BOTTOM_CENTER);
return hoursWorkedList;
});
@ -84,7 +84,8 @@ public class HoursWorkedListView extends Main {
if (team != null && !"TODOS".equals(team.getName())) {
filteredHoursWorked = filteredHoursWorked.stream()
.filter(hw -> hw.getEmployee().getTeam() != null && hw.getEmployee().getTeam().getId().equals(team.getId()))
.filter(hw -> hw.getEmployee().getTeam() != null
&& hw.getEmployee().getTeam().getId().equals(team.getId()))
.collect(Collectors.toList());
}
@ -94,7 +95,8 @@ public class HoursWorkedListView extends Main {
int currentWeek = date.get(IsoFields.WEEK_OF_WEEK_BASED_YEAR);
double totalWorkedInSameWeek = filteredHoursWorked.stream()
.filter(hw -> hw.getEmployee().getId().equals(employee.getId()) &&
.filter(hw -> hw.getEmployee().getId().equals(employee.getId())
&&
hw.getDate().get(IsoFields.WEEK_OF_WEEK_BASED_YEAR) == currentWeek)
.mapToDouble(HoursWorked::getHours)
.sum();
@ -130,11 +132,13 @@ public class HoursWorkedListView extends Main {
.setSortable(true);
hoursWorkedGrid.addColumn(hw -> hw.getEmployee().getFirstName() + " " + hw.getEmployee().getLastName())
.setHeader("Empleado");
hoursWorkedGrid.addColumn(hw -> hw.getEmployee().getTeam() != null ? hw.getEmployee().getTeam().getName() : "Sin asignar")
hoursWorkedGrid.addColumn(hw -> hw.getEmployee().getTeam() != null ? hw.getEmployee().getTeam()
.getName() : "Sin asignar")
.setHeader("Equipo");
hoursWorkedGrid.addColumn(HoursWorked::getActividad).setHeader("Actividad");
hoursWorkedGrid.addColumn(hw -> hw.getHours() ).setHeader("Total Horas").setSortable(true);
hoursWorkedGrid.addColumn(hw -> hw.getHoraspendientes() - calcularTotal(hw)).setHeader("Horas Pendientes").setSortable(true);
hoursWorkedGrid.addColumn(hw -> hw.getHours()).setHeader("Total Horas").setSortable(true);
hoursWorkedGrid.addColumn(hw -> hw.getHoraspendientes() - calcularTotal(hw)).setHeader("Horas Pendientes")
.setSortable(true);
hoursWorkedGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM);
hoursWorkedGrid.setPageSize(5);
@ -146,7 +150,7 @@ public class HoursWorkedListView extends Main {
});
}
private double calcularTotal(HoursWorked hoursWorked){
private double calcularTotal(final HoursWorked hoursWorked) {
List<HoursWorked> listHoursworkedemploye = hoursWorkedService.findListHoursWorkedEmployee(
hoursWorked.getEmployee().getId(), hoursWorked.getWeekNumber());
return calculateTotalUtilized(listHoursworkedemploye);