Search in sources :

Example 66 with Project

use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.

the class HoursRepositoryTest method testGetApprovedActualHoursSum_ifHoursForStartPeriod.

@Test
public void testGetApprovedActualHoursSum_ifHoursForStartPeriod() 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, start, 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 67 with Project

use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.

the class HoursRepositoryTest method testGetDailyApprovedHoursSum.

@Test
public void testGetDailyApprovedHoursSum() {
    Employee employee = new Employee("employee");
    Project project = new Project();
    HourType actualTime = new HourType("actual");
    actualTime.setActualTime(true);
    Date date = getOffsetDate(-1);
    Hours hours1 = new Hours(project, date, employee, actualTime);
    hours1.setQuantity(new BigDecimal(1));
    Hours hours2 = new Hours(project, getOffsetDate(0), employee, actualTime);
    hours2.setQuantity(new BigDecimal(2));
    Hours hours3 = new Hours(project, getOffsetDate(1), employee, actualTime);
    hours3.setQuantity(new BigDecimal(3));
    Hours hours4 = new Hours(project, getOffsetDate(2), employee, actualTime);
    hours4.setQuantity(new BigDecimal(4));
    List<Hours> hours = asList(hours1, hours2, hours3, hours4);
    BigDecimal actual = hoursRepository.getDailyApprovedHoursSum(hours, date);
    assertEquals(new BigDecimal(1), 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) Date(java.util.Date) CalendarUtils.getOffsetDate(com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 68 with Project

use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.

the class WorkdaysCalendarRepositoryTest method testRemoveWorkdaysCalendar_RemoveForbidden.

@Test(expected = PersistenceException.class)
public void testRemoveWorkdaysCalendar_RemoveForbidden() {
    WorkdaysCalendar workdaysCalendar = new WorkdaysCalendar("calendar");
    Project project = new Project();
    Employee employee = new Employee("employee");
    employee.setCalendar(workdaysCalendar);
    project.addTeamMember(employee);
    entityManager.persist(workdaysCalendar);
    entityManager.persist(employee);
    entityManager.persist(project);
    workdaysCalendarRepository.remove(workdaysCalendar);
    entityManager.flush();
}
Also used : WorkdaysCalendar(com.artezio.arttime.datamodel.WorkdaysCalendar) Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) Test(org.junit.Test)

Example 69 with Project

use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.

the class NotificationManager method notifyProjectManagers.

protected void notifyProjectManagers(List<Employee> employees, Period period, String comment) {
    List<Project> projects = getProjects(employees);
    List<Employee> projectManagers = getProjectManagers(projects);
    Map<Employee, Map<Date, BigDecimal>> timeProblems = workTimeService.getWorkTimeDeviations(period, employees);
    HourType actualTime = hourTypeService.findActualTime();
    TimeProblemsForPmMailBuilder mailTemplateBuilder = new TimeProblemsForPmMailBuilder(mailTemplateManager);
    mailTemplateBuilder.setSenderEmailAddress(settings.getSmtpSender()).setHourType(actualTime).setPeriod(period).setComment(comment).setAppHost(settings.getApplicationBaseUrl());
    projectManagers.forEach(projectManager -> {
        Set<WorkTimeProblems> worktimeProblems = getEmployeeWorktimeProblems(projectManager, projects, timeProblems);
        Mail mail = mailTemplateBuilder.setRecipientEmailAddress(projectManager.getEmail()).setRecipient(projectManager).setEmployeeWorkTimeProblems(worktimeProblems).setUserNames(getEmployeesAsString(worktimeProblems)).build();
        mailingEngine.send(mail);
    });
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) HourType(com.artezio.arttime.datamodel.HourType)

Example 70 with Project

use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.

the class ReportsBean method getSelectedProjectIds.

protected Long[] getSelectedProjectIds() {
    Filter filter = getFilter();
    List<Hours> reportedHours = hoursService.getHours(getFilter());
    Set<Project> projectsWithReportedHours = reportedHours.parallelStream().map(Hours::getProject).collect(Collectors.toSet());
    Set<Project> projects = new HashSet<>(projectService.getEffortsProjects(filter));
    projects = Sets.union(projects, projectsWithReportedHours).stream().filter(project -> project.getStatus() == ACTIVE || projectsWithReportedHours.contains(project) || (nonNull(filter.getName()) && filter.getProjects().contains(project))).collect(Collectors.toSet());
    return projects.stream().map(Project::getId).toArray(Long[]::new);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Filter(com.artezio.arttime.filter.Filter) Hours(com.artezio.arttime.datamodel.Hours)

Aggregations

Project (com.artezio.arttime.datamodel.Project)310 Test (org.junit.Test)278 Employee (com.artezio.arttime.datamodel.Employee)195 HourType (com.artezio.arttime.datamodel.HourType)119 Hours (com.artezio.arttime.datamodel.Hours)108 Date (java.util.Date)61 CalendarUtils.getOffsetDate (com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate)56 Period (com.artezio.arttime.datamodel.Period)43 BigDecimal (java.math.BigDecimal)39 Filter (com.artezio.arttime.filter.Filter)33 TeamFilter (com.artezio.arttime.datamodel.TeamFilter)26 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)25 CalendarUtils.createPeriod (com.artezio.arttime.test.utils.CalendarUtils.createPeriod)21 ArrayList (java.util.ArrayList)18 Arrays.asList (java.util.Arrays.asList)18 ProjectRepository (com.artezio.arttime.repositories.ProjectRepository)17 List (java.util.List)17 HoursRepository (com.artezio.arttime.repositories.HoursRepository)13 HashMap (java.util.HashMap)13 Map (java.util.Map)11