Search in sources :

Example 1 with AppLeave

use of com.axelor.apps.base.db.AppLeave in project axelor-open-suite by axelor.

the class UserHrServiceImpl method createEmployee.

@Transactional
public void createEmployee(User user) {
    if (user.getPartner() == null) {
        Beans.get(UserService.class).createPartner(user);
    }
    AppBase appBase = appHumanResourceService.getAppBase();
    AppLeave appLeave = appHumanResourceService.getAppLeave();
    Employee employee = new Employee();
    employee.setContactPartner(user.getPartner());
    employee.setTimeLoggingPreferenceSelect(appBase.getTimeLoggingPreferenceSelect());
    employee.setDailyWorkHours(appBase.getDailyWorkHours());
    employee.setNegativeValueLeave(appLeave.getAllowNegativeLeaveEmployees());
    EventsPlanning planning = null;
    Company company = user.getActiveCompany();
    if (company != null) {
        HRConfig hrConfig = company.getHrConfig();
        if (hrConfig != null) {
            planning = hrConfig.getPublicHolidayEventsPlanning();
        }
    }
    employee.setPublicHolidayEventsPlanning(planning);
    employee.setUser(user);
    Beans.get(EmployeeRepository.class).save(employee);
    user.setEmployee(employee);
    userRepo.save(user);
}
Also used : EmployeeRepository(com.axelor.apps.hr.db.repo.EmployeeRepository) Company(com.axelor.apps.base.db.Company) Employee(com.axelor.apps.hr.db.Employee) HRConfig(com.axelor.apps.hr.db.HRConfig) UserService(com.axelor.apps.base.service.user.UserService) AppLeave(com.axelor.apps.base.db.AppLeave) EventsPlanning(com.axelor.apps.base.db.EventsPlanning) AppBase(com.axelor.apps.base.db.AppBase) Transactional(com.google.inject.persist.Transactional)

Aggregations

AppBase (com.axelor.apps.base.db.AppBase)1 AppLeave (com.axelor.apps.base.db.AppLeave)1 Company (com.axelor.apps.base.db.Company)1 EventsPlanning (com.axelor.apps.base.db.EventsPlanning)1 UserService (com.axelor.apps.base.service.user.UserService)1 Employee (com.axelor.apps.hr.db.Employee)1 HRConfig (com.axelor.apps.hr.db.HRConfig)1 EmployeeRepository (com.axelor.apps.hr.db.repo.EmployeeRepository)1 Transactional (com.google.inject.persist.Transactional)1