Search in sources :

Example 66 with Employee

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);
}
Also used : Employee(com.axelor.apps.hr.db.Employee)

Example 67 with Employee

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);
}
Also used : Employee(com.axelor.apps.hr.db.Employee) User(com.axelor.auth.db.User) Message(com.axelor.apps.message.db.Message) EmailAddress(com.axelor.apps.message.db.EmailAddress) Template(com.axelor.apps.message.db.Template) Transactional(com.google.inject.persist.Transactional)

Example 68 with Employee

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;
}
Also used : Employee(com.axelor.apps.hr.db.Employee) Transactional(com.google.inject.persist.Transactional)

Example 69 with 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("]", ")");
}
Also used : EmployeeRepository(com.axelor.apps.hr.db.repo.EmployeeRepository) Employee(com.axelor.apps.hr.db.Employee) TrainingSessionRepository(com.axelor.apps.talent.db.repo.TrainingSessionRepository) TrainingRegister(com.axelor.apps.talent.db.TrainingRegister) ArrayList(java.util.ArrayList) Event(com.axelor.apps.crm.db.Event) Transactional(com.google.inject.persist.Transactional)

Example 70 with Employee

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);
    }
}
Also used : Employee(com.axelor.apps.hr.db.Employee) BigDecimal(java.math.BigDecimal) AppProductionService(com.axelor.apps.production.service.app.AppProductionService)

Aggregations

Employee (com.axelor.apps.hr.db.Employee)71 AxelorException (com.axelor.exception.AxelorException)34 User (com.axelor.auth.db.User)28 Transactional (com.google.inject.persist.Transactional)21 BigDecimal (java.math.BigDecimal)18 ActionViewBuilder (com.axelor.meta.schema.actions.ActionView.ActionViewBuilder)14 LocalDate (java.time.LocalDate)13 TimesheetLine (com.axelor.apps.hr.db.TimesheetLine)9 EmployeeRepository (com.axelor.apps.hr.db.repo.EmployeeRepository)9 WeeklyPlanning (com.axelor.apps.base.db.WeeklyPlanning)8 Message (com.axelor.apps.message.db.Message)8 LeaveRequest (com.axelor.apps.hr.db.LeaveRequest)7 ArrayList (java.util.ArrayList)7 HashSet (java.util.HashSet)7 DayPlanning (com.axelor.apps.base.db.DayPlanning)6 LeaveLine (com.axelor.apps.hr.db.LeaveLine)6 LeaveService (com.axelor.apps.hr.service.leave.LeaveService)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 Company (com.axelor.apps.base.db.Company)5