use of com.axelor.apps.hr.db.Employee in project axelor-open-suite by axelor.
the class EmployeeHRRepository method populate.
@Override
public Map<String, Object> populate(Map<String, Object> json, Map<String, Object> context) {
if (json != null && json.get("id") != null) {
Long id = (Long) json.get("id");
if (id != null) {
Employee employee = super.find(id);
AppBaseService appBaseService = Beans.get(AppBaseService.class);
LocalDate today = appBaseService.getTodayDate(employee.getUser() != null ? employee.getUser().getActiveCompany() : AuthUtils.getUser().getActiveCompany());
if (employee.getLeavingDate() == null && employee.getHireDate() != null && employee.getHireDate().compareTo(today.minusDays(30)) > 0) {
json.put("$employeeStatus", "new");
} else if (employee.getLeavingDate() != null && employee.getLeavingDate().compareTo(today) < 0) {
json.put("$employeeStatus", "former");
} else {
json.put("$employeeStatus", "active");
}
}
}
return super.populate(json, context);
}
use of com.axelor.apps.hr.db.Employee in project axelor-open-suite by axelor.
the class AppraisalServiceImpl method createAppraisals.
@Transactional(rollbackOn = { Exception.class })
@Override
public Set<Long> createAppraisals(Appraisal appraisalTemplate, Set<Employee> employees, Boolean send) throws ClassNotFoundException, InstantiationException, IllegalAccessException, AxelorException, IOException, MessagingException {
Set<Long> appraisalIds = new HashSet<Long>();
if (appraisalTemplate == null) {
return appraisalIds;
}
for (Employee employee : employees.stream().filter(Objects::nonNull).collect(Collectors.toList())) {
if (EmployeeHRRepository.isEmployeeFormerNewOrArchived(employee)) {
continue;
}
Appraisal appraisal = appraisalRepo.copy(appraisalTemplate, false);
appraisal.setEmployee(employee);
if (appraisal.getCompany() == null) {
EmploymentContract employmentContract = employee.getMainEmploymentContract();
if (employmentContract != null) {
appraisal.setCompany(employmentContract.getPayCompany());
}
}
appraisal.setIsTemplate(false);
appraisal = appraisalRepo.save(appraisal);
if (send != null && send) {
send(appraisal);
}
appraisalIds.add(appraisal.getId());
}
return appraisalIds;
}
use of com.axelor.apps.hr.db.Employee in project axelor-open-suite by axelor.
the class JobApplicationServiceImpl method createEmployee.
protected Employee createEmployee(JobApplication jobApplication) {
Employee employee = new Employee();
employee.setHireDate(appBaseService.getTodayDate(jobApplication.getJobPosition().getCompany()));
employee.setContactPartner(createContact(jobApplication));
Set<Skill> tagSkillSet = new HashSet<Skill>();
tagSkillSet.addAll(jobApplication.getSkillSet());
employee.setSkillSet(tagSkillSet);
if (employee.getMainEmploymentContract() != null)
employee.getMainEmploymentContract().setCompanyDepartment(jobApplication.getJobPosition().getCompanyDepartment());
employee.setName(employee.getContactPartner().getName());
return employee;
}
use of com.axelor.apps.hr.db.Employee in project axelor-open-suite by axelor.
the class TimesheetReportServiceImpl method getUserToBeReminded.
@Override
public Set<User> getUserToBeReminded(TimesheetReport timesheetReport) {
Set<User> userSet = new HashSet<>();
BigDecimal worksHour = BigDecimal.ZERO, workedHour = BigDecimal.ZERO;
List<User> users = getUsers(timesheetReport);
LocalDate fromDate = timesheetReport.getFromDate();
LocalDate toDate = timesheetReport.getToDate();
for (User user : users) {
Employee employee = user.getEmployee();
try {
worksHour = workedHour = BigDecimal.ZERO;
BigDecimal publicHolidays = publicHolidayService.computePublicHolidayDays(fromDate, toDate, employee.getWeeklyPlanning(), employee.getPublicHolidayEventsPlanning());
worksHour = getTotalWeekWorksHours(user, fromDate, toDate, publicHolidays);
workedHour = getTotalWeekWorkedHours(user, fromDate, toDate, publicHolidays);
if (worksHour.compareTo(workedHour) != 0) {
userSet.add(user);
}
} catch (Exception e) {
TraceBackService.trace(e);
}
}
return userSet;
}
use of com.axelor.apps.hr.db.Employee in project axelor-open-suite by axelor.
the class TimesheetReportServiceImpl method addTimesheetReminder.
private void addTimesheetReminder(TimesheetReport timesheetReport, List<User> users, List<TimesheetReminder> timesheetReminders) throws AxelorException {
BigDecimal worksHour = BigDecimal.ZERO, workedHour = BigDecimal.ZERO, missingHour = BigDecimal.ZERO, extraHour = BigDecimal.ZERO;
LocalDate fromDate = timesheetReport.getFromDate();
LocalDate toDate = null;
do {
toDate = fromDate.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY));
if (toDate.until(timesheetReport.getToDate()).getDays() < 0) {
toDate = timesheetReport.getToDate();
}
for (User user : users) {
Employee employee = user.getEmployee();
missingHour = BigDecimal.ZERO;
extraHour = BigDecimal.ZERO;
BigDecimal publicHolidays = publicHolidayService.computePublicHolidayDays(fromDate, toDate, employee.getWeeklyPlanning(), employee.getPublicHolidayEventsPlanning());
worksHour = getTotalWeekWorksHours(user, fromDate, toDate, publicHolidays);
workedHour = getTotalWeekWorkedHours(user, fromDate, toDate, publicHolidays);
if (worksHour.compareTo(workedHour) == 1) {
missingHour = worksHour.subtract(workedHour);
} else if (worksHour.compareTo(workedHour) == -1) {
extraHour = workedHour.subtract(worksHour);
}
if (missingHour.compareTo(BigDecimal.ZERO) == 0 && extraHour.compareTo(BigDecimal.ZERO) == 0) {
continue;
}
Optional<TimesheetReminder> optReminder = timesheetReminders.stream().filter(reminder -> reminder.getEmployee().getId().compareTo(employee.getId()) == 0).findFirst();
TimesheetReminder timesheetReminder = null;
if (optReminder.isPresent()) {
timesheetReminder = optReminder.get();
timesheetReminder.addTimesheetReminderLineListItem(createTimesheetReminderLine(fromDate, toDate, worksHour, missingHour, extraHour));
} else {
List<TimesheetReminderLine> timesheetReminderLines = new ArrayList<>();
timesheetReminder = new TimesheetReminder();
timesheetReminder.setEmployee(employee);
timesheetReminder.setTimesheetReminderLineList(timesheetReminderLines);
timesheetReminder.addTimesheetReminderLineListItem(createTimesheetReminderLine(fromDate, toDate, worksHour, missingHour, extraHour));
timesheetReminders.add(timesheetReminder);
}
timesheetReminderRepo.save(timesheetReminder);
}
fromDate = fromDate.with(TemporalAdjusters.next(DayOfWeek.MONDAY));
} while (toDate.until(timesheetReport.getToDate()).getDays() > 0);
}
Aggregations