Search in sources :

Example 46 with Period

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());
}
Also used : Employee(com.artezio.arttime.datamodel.Employee) Period(com.artezio.arttime.datamodel.Period) ArrayList(java.util.ArrayList) List(java.util.List) BigDecimal(java.math.BigDecimal)

Example 47 with Period

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;
}
Also used : Stateless(javax.ejb.Stateless) Arrays(java.util.Arrays) Filter(com.artezio.arttime.filter.Filter) Scope(com.artezio.arttime.admin_tool.cache.WebCached.Scope) Period(com.artezio.arttime.datamodel.Period) Date(java.util.Date) ProjectRepository(com.artezio.arttime.services.repositories.ProjectRepository) HashMap(java.util.HashMap) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Employee(com.artezio.arttime.datamodel.Employee) Inject(javax.inject.Inject) BigDecimal(java.math.BigDecimal) Project(com.artezio.arttime.datamodel.Project) List(java.util.List) WorkdaysCalendarRepository(com.artezio.arttime.services.repositories.WorkdaysCalendarRepository) EmployeeRepository(com.artezio.arttime.services.repositories.EmployeeRepository) TreeMap(java.util.TreeMap) HoursRepository(com.artezio.arttime.services.repositories.HoursRepository) Map(java.util.Map) WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Named(javax.inject.Named) Hours(com.artezio.arttime.datamodel.Hours) WebCached(com.artezio.arttime.admin_tool.cache.WebCached) WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Date(java.util.Date)

Example 48 with Period

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);
}
Also used : Employee(com.artezio.arttime.datamodel.Employee) ArrayList(java.util.ArrayList) Period(com.artezio.arttime.datamodel.Period) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 49 with Period

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);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) HourType(com.artezio.arttime.datamodel.HourType) Hours(com.artezio.arttime.datamodel.Hours) Period(com.artezio.arttime.datamodel.Period) CalendarUtils.createPeriod(com.artezio.arttime.test.utils.CalendarUtils.createPeriod) Date(java.util.Date) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 50 with Period

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);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) HourType(com.artezio.arttime.datamodel.HourType) Hours(com.artezio.arttime.datamodel.Hours) Period(com.artezio.arttime.datamodel.Period) CalendarUtils.createPeriod(com.artezio.arttime.test.utils.CalendarUtils.createPeriod) Date(java.util.Date) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

Period (com.artezio.arttime.datamodel.Period)93 Test (org.junit.Test)87 Employee (com.artezio.arttime.datamodel.Employee)59 Date (java.util.Date)56 CalendarUtils.getOffsetDate (com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate)44 HourType (com.artezio.arttime.datamodel.HourType)43 Project (com.artezio.arttime.datamodel.Project)42 Hours (com.artezio.arttime.datamodel.Hours)40 BigDecimal (java.math.BigDecimal)34 CalendarUtils.createPeriod (com.artezio.arttime.test.utils.CalendarUtils.createPeriod)22 Day (com.artezio.arttime.datamodel.Day)17 HashMap (java.util.HashMap)15 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)15 WorkdaysCalendar (com.artezio.arttime.datamodel.WorkdaysCalendar)13 List (java.util.List)13 Map (java.util.Map)11 ArrayList (java.util.ArrayList)8 GregorianCalendar (java.util.GregorianCalendar)8 HoursRepository (com.artezio.arttime.repositories.HoursRepository)7 Mail (com.artezio.arttime.services.mailing.Mail)7