use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class WorkTimeService method getEmployeesTimeProblems.
public List<Efforts> getEmployeesTimeProblems(Filter filter) {
Period period = filter.getPeriod();
List<Employee> employees = getEmployees(filter);
Map<Employee, BigDecimal> requiredWorkTime = getRequiredWorkTime(employees, period);
Map<Employee, List<Hours>> actualHours = hoursRepository.getActualHoursLists(employees, period, false);
Map<Employee, List<Project>> allProject = projectRepository.getAllProjectsByEmployees(employees, period);
return employees.parallelStream().filter(employee -> !employee.isFormer() && employee.getWorkLoad() != null).sorted(Employee.NAME_COMPARATOR).map(employee -> new Efforts(employee, requiredWorkTime, actualHours, allProject)).filter(Efforts::hasWorkTimeProblems).collect(Collectors.toList());
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class WorkTimeService method getWorkSchedule.
protected Map<Date, Boolean> getWorkSchedule(List<Project> activeProjects, Employee employee, Period period) {
Map<Date, Boolean> workSchedule = generateWorkScheduleTemplate(period);
WorkdaysCalendar calendar = employee.getCalendar();
if (isTeamMember(activeProjects, employee)) {
workdaysCalendarRepository.getDays(calendar, period).stream().filter(day -> !workSchedule.get(day.getDate())).forEach(day -> workSchedule.put(day.getDate(), day.isWorking()));
}
return workSchedule;
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class NotificationManagerTest method testNotificateAboutWorkTimeProblem.
@Test
public void testNotificateAboutWorkTimeProblem() throws MessagingException {
notificationManager = createMockBuilder(NotificationManager.class).addMockedMethod("notificateAboutOwnTimeProblems", List.class, Period.class, String.class).addMockedMethod("notificatePmAboutTimeProblems", List.class, Period.class, String.class).createMock();
List<Employee> employees = new ArrayList<Employee>();
Period period = new Period();
String comment = "";
notificationManager.notificateAboutOwnTimeProblems(employees, period, comment);
notificationManager.notificatePmAboutTimeProblems(employees, period, comment);
replay(notificationManager);
notificationManager.notificateAboutWorkTimeProblem(employees, period, comment);
verify(notificationManager);
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class HoursRepositoryTest method testGetApprovedActualHoursSum_ifHoursForFinishPeriod.
@Test
public void testGetApprovedActualHoursSum_ifHoursForFinishPeriod() throws NoSuchFieldException {
Date start = new Date();
Date finish = getOffsetDate(2);
Period period = new Period(start, finish);
Employee employee = new Employee("expected employee");
Project project = new Project();
HourType actualType = new HourType("actual type");
actualType.setActualTime(true);
BigDecimal quantity = new BigDecimal(8);
Hours hours = createHours(project, employee, finish, actualType, quantity);
hours.setApproved(true);
entityManager.persist(employee);
entityManager.persist(project);
entityManager.persist(actualType);
entityManager.persist(hours);
BigDecimal actual = hoursRepository.getApprovedActualHoursSum(employee, period);
assertEquals(new BigDecimal("8.00"), actual);
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class HoursRepositoryTest method testGetApprovedActualHoursSum_unexpectedEmployee.
@Test
public void testGetApprovedActualHoursSum_unexpectedEmployee() throws NoSuchFieldException {
Date start = new Date();
Date finish = getOffsetDate(2);
Period period = new Period(start, finish);
Employee expectedEmployee = new Employee("expected employee");
Employee unexpectedEmployee = new Employee("unexpected employee");
Project project = new Project();
HourType actualType = new HourType("actual type");
actualType.setActualTime(true);
BigDecimal quantity = new BigDecimal(8);
Hours hours = createHours(project, unexpectedEmployee, getOffsetDate(1), actualType, quantity);
entityManager.persist(expectedEmployee);
entityManager.persist(unexpectedEmployee);
entityManager.persist(project);
entityManager.persist(actualType);
entityManager.persist(hours);
BigDecimal actual = hoursRepository.getApprovedActualHoursSum(expectedEmployee, period);
assertEquals(BigDecimal.ZERO, actual);
}
Aggregations