use of com.axelor.apps.hr.db.Employee in project axelor-open-suite by axelor.
the class BatchTimesheetReminder method sendReminderUsingEmployees.
protected void sendReminderUsingEmployees(Template template) throws AxelorException, MessagingException, IOException, ClassNotFoundException, InstantiationException, IllegalAccessException {
for (Employee employee : getEmployeesWithoutRecentTimesheet(Optional.ofNullable(AuthUtils.getUser()).map(User::getActiveCompany).orElse(null)).stream().filter(Objects::nonNull).collect(Collectors.toList())) {
Message message = templateMessageService.generateMessage(employee, template);
messageService.sendByEmail(message);
incrementDone();
}
}
use of com.axelor.apps.hr.db.Employee in project axelor-open-suite by axelor.
the class BatchTimesheetReminder method sendReminderUsingTimesheets.
protected void sendReminderUsingTimesheets(Template template) throws AxelorException, MessagingException, IOException, ClassNotFoundException, InstantiationException, IllegalAccessException {
for (Employee employee : getEmployeesWithoutRecentTimesheet(Optional.ofNullable(AuthUtils.getUser()).map(User::getActiveCompany).orElse(null)).stream().filter(Objects::nonNull).collect(Collectors.toList())) {
if (employee == null || EmployeeHRRepository.isEmployeeFormerNewOrArchived(employee)) {
continue;
}
Timesheet timeSheet = getRecentEmployeeTimesheet(employee);
if (timeSheet != null) {
Message message = templateMessageService.generateMessage(timeSheet, template);
messageService.sendByEmail(message);
} else {
throw new AxelorException(Timesheet.class, TraceBackRepository.CATEGORY_NO_VALUE, I18n.get(IExceptionMessage.NO_TIMESHEET_FOUND_FOR_EMPLOYEE), employee.getName());
}
incrementDone();
}
}
use of com.axelor.apps.hr.db.Employee in project axelor-open-suite by axelor.
the class BatchTimesheetValidationReminder method generateEmail.
public void generateEmail() {
List<Timesheet> timesheetList = Beans.get(CompanyRepository.class).all().count() > 1 ? Beans.get(TimesheetRepository.class).all().filter("self.company.id = ?1 AND self.statusSelect = 1 AND self.user.employee.timesheetReminder = true", batch.getMailBatch().getCompany().getId()).fetch() : Beans.get(TimesheetRepository.class).all().filter("self.statusSelect = 1 AND self.user.employee.timesheetReminder = true").fetch();
for (Timesheet timesheet : timesheetList) {
try {
Employee employee = timesheet.getUser().getEmployee();
if (employee == null || EmployeeHRRepository.isEmployeeFormerNewOrArchived(employee)) {
continue;
}
generateAndSendMessage(employee);
incrementDone();
} catch (Exception e) {
incrementAnomaly();
TraceBackService.trace(new Exception(e), ExceptionOriginRepository.INVOICE_ORIGIN, batch.getId());
}
}
}
use of com.axelor.apps.hr.db.Employee in project axelor-open-suite by axelor.
the class BatchTimesheetValidationReminder method generateAllEmail.
public void generateAllEmail() {
List<Employee> employeeList = Beans.get(EmployeeRepository.class).all().filter("self.timesheetReminder = true").fetch();
for (Employee employee : employeeList) {
if (employee == null || EmployeeHRRepository.isEmployeeFormerNewOrArchived(employee)) {
continue;
}
try {
generateAndSendMessage(employee);
incrementDone();
} catch (Exception e) {
incrementAnomaly();
TraceBackService.trace(new Exception(e), ExceptionOriginRepository.INVOICE_ORIGIN, batch.getId());
}
}
}
use of com.axelor.apps.hr.db.Employee in project axelor-open-suite by axelor.
the class PayrollPreparationService method fillInLeaves.
public List<PayrollLeave> fillInLeaves(PayrollPreparation payrollPreparation) throws AxelorException {
List<PayrollLeave> payrollLeaveList = new ArrayList<>();
LocalDate fromDate = payrollPreparation.getPeriod().getFromDate();
LocalDate toDate = payrollPreparation.getPeriod().getToDate();
Employee employee = payrollPreparation.getEmployee();
if (employee.getWeeklyPlanning() == null) {
throw new AxelorException(payrollPreparation, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.EMPLOYEE_PLANNING), employee.getName());
}
List<LeaveRequest> leaveRequestList = leaveRequestRepo.all().filter("self.statusSelect = ?4 AND self.user.employee = ?3 AND ((self.fromDateT BETWEEN ?2 AND ?1 OR self.toDateT BETWEEN ?2 AND ?1) OR (?1 BETWEEN self.fromDateT AND self.toDateT OR ?2 BETWEEN self.fromDateT AND self.toDateT))", toDate, fromDate, employee, LeaveRequestRepository.STATUS_VALIDATED).fetch();
for (LeaveRequest leaveRequest : leaveRequestList) {
PayrollLeave payrollLeave = new PayrollLeave();
if (leaveRequest.getFromDateT().toLocalDate().isBefore(fromDate)) {
payrollLeave.setFromDate(fromDate);
} else {
payrollLeave.setFromDate(leaveRequest.getFromDateT().toLocalDate());
}
if (leaveRequest.getToDateT().toLocalDate().isAfter(toDate)) {
payrollLeave.setToDate(toDate);
} else {
payrollLeave.setToDate(leaveRequest.getToDateT().toLocalDate());
}
payrollLeave.setDuration(leaveService.computeLeaveDaysByLeaveRequest(fromDate, toDate, leaveRequest, employee));
payrollLeave.setLeaveReason(leaveRequest.getLeaveReason());
payrollLeave.setLeaveRequest(leaveRequest);
payrollLeaveList.add(payrollLeave);
}
return payrollLeaveList;
}
Aggregations