use of com.artezio.arttime.datamodel.HourType 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);
}
use of com.artezio.arttime.datamodel.HourType 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);
}
use of com.artezio.arttime.datamodel.HourType in project ART-TIME by Artezio.
the class NotificationManager method notifyAboutIncorrectTimesheet.
protected void notifyAboutIncorrectTimesheet(Employee employee, Period period) {
HourType actualTime = hourTypeService.findActualTime();
Mail mail = new IncorrectTimesheetMailBuilder(mailTemplateManager).setHourType(actualTime).setPeriod(period).setRecipientEmailAddress(employee.getEmail()).setAppHost(settings.getApplicationBaseUrl()).setSenderEmailAddress(settings.getSmtpSender()).build();
mailingEngine.send(mail);
}
use of com.artezio.arttime.datamodel.HourType 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);
});
}
use of com.artezio.arttime.datamodel.HourType in project ART-TIME by Artezio.
the class HourTypeRepository method remove.
@FacesMessage(onCompleteMessageKey = "message.hourTypeIsDeleted")
@WebCached(resetCache = true)
@Log(logParams = true)
public void remove(@DetailedLogged HourType hourType) throws ActualTimeRemovalException {
if (hourType.isActualTime()) {
throw new ActualTimeRemovalException("Attempt to delete an actual time.");
}
HourType type = entityManager.find(HourType.class, hourType.getId());
entityManager.remove(type);
}
Aggregations