use of com.axelor.apps.hr.db.Employee in project axelor-open-suite by axelor.
the class UserHRRepository method remove.
@Override
public void remove(User user) {
if (user.getEmployee() != null) {
EmployeeHRRepository employeeRepo = Beans.get(EmployeeHRRepository.class);
Employee employee = employeeRepo.find(user.getEmployee().getId());
if (employee != null) {
employee.setUser(null);
employeeRepo.save(employee);
}
}
super.remove(user);
}
use of com.axelor.apps.hr.db.Employee in project axelor-open-suite by axelor.
the class AppraisalServiceImpl method send.
@Transactional(rollbackOn = { Exception.class })
@Override
public void send(Appraisal appraisal) throws ClassNotFoundException, InstantiationException, IllegalAccessException, AxelorException, IOException, MessagingException {
Employee employee = appraisal.getEmployee();
User user = employee.getUser();
if (user != null) {
mailFollowerRepo.follow(appraisal, user);
}
Template template = templateRepo.all().filter("self.metaModel.fullName = ?1", Appraisal.class.getName()).fetchOne();
EmailAddress email = null;
if (employee.getContactPartner() != null) {
email = employee.getContactPartner().getEmailAddress();
}
if (template != null && email != null) {
Message message = templateMessageService.generateMessage(appraisal, template);
message.addToEmailAddressSetItem(email);
messageService.sendByEmail(message);
}
appraisal.setStatusSelect(AppraisalRepository.STATUS_SENT);
appraisalRepo.save(appraisal);
}
use of com.axelor.apps.hr.db.Employee in project axelor-open-suite by axelor.
the class JobApplicationServiceImpl method hire.
@Transactional
@Override
public Employee hire(JobApplication jobApplication) {
Employee employee = createEmployee(jobApplication);
jobApplication.setStatusSelect(JobApplicationRepository.STATUS_HIRED);
jobApplication.setEmployee(employee);
if (jobApplication.getJobPosition() != null) {
int nbPeopleHired = jobApplication.getJobPosition().getNbPeopleHired();
nbPeopleHired += 1;
jobApplication.getJobPosition().setNbPeopleHired(nbPeopleHired);
}
jobApplicationRepo.save(jobApplication);
return employee;
}
use of com.axelor.apps.hr.db.Employee in project axelor-open-suite by axelor.
the class TrainingRegisterServiceImpl method massTrainingRegisterCreation.
@Override
@Transactional
public String massTrainingRegisterCreation(ArrayList<LinkedHashMap<String, Object>> employeeList, TrainingSession trainingSession) {
List<Long> eventsIds = new ArrayList<>();
for (LinkedHashMap<String, Object> employeeMap : employeeList) {
Employee employee = Beans.get(EmployeeRepository.class).find(Long.parseLong(employeeMap.get("id").toString()));
if (employee.getUser() == null) {
continue;
}
TrainingRegister trainingRegister = new TrainingRegister();
trainingRegister.setTraining(trainingSession.getTraining());
trainingRegister.setFromDate(trainingSession.getFromDate());
trainingRegister.setToDate(trainingSession.getToDate());
trainingRegister.setTrainingSession(trainingSession);
trainingRegister.setEmployee(employee);
trainingRegister.setRating(trainingSession.getOverallRatingToApply());
Event event = this.plan(trainingRegister);
trainingRegister.getEventList().add(event);
eventsIds.add(event.getId());
trainingSession.getTrainingRegisterList().add(trainingRegister);
}
Beans.get(TrainingSessionRepository.class).save(trainingSession);
return eventsIds.toString().replace("[", "(").replace("]", ")");
}
use of com.axelor.apps.hr.db.Employee in project axelor-open-suite by axelor.
the class CostSheetServiceBusinessImpl method _computeHumanResourceCost.
@Override
protected void _computeHumanResourceCost(ProdHumanResource prodHumanResource, int priority, int bomLevel, CostSheetLine parentCostSheetLine) throws AxelorException {
Employee employee = prodHumanResource.getEmployee();
AppProductionService appProductionService = Beans.get(AppProductionService.class);
if (appProductionService.isApp("production") && appProductionService.getAppProduction().getManageBusinessProduction() && employee != null && !EmployeeHRRepository.isEmployeeFormerNewOrArchived(employee)) {
BigDecimal durationHours = new BigDecimal(prodHumanResource.getDuration()).divide(BigDecimal.valueOf(3600), appProductionService.getNbDecimalDigitForUnitPrice(), BigDecimal.ROUND_HALF_UP);
costSheet.addCostSheetLineListItem(costSheetLineService.createWorkCenterHRCostSheetLine(prodHumanResource.getWorkCenter(), prodHumanResource, priority, bomLevel, parentCostSheetLine, durationHours, employee.getHourlyRate().multiply(durationHours), hourUnit));
} else {
super._computeHumanResourceCost(prodHumanResource, priority, bomLevel, parentCostSheetLine);
}
}
Aggregations