Search in sources :

Example 1 with DPAE

use of com.axelor.apps.hr.db.DPAE in project axelor-open-suite by axelor.

the class EmployeeController method generateNewDPAE.

public void generateNewDPAE(ActionRequest request, ActionResponse response) {
    Employee employee = request.getContext().asType(Employee.class);
    employee = Beans.get(EmployeeRepository.class).find(employee.getId());
    try {
        Long dpaeId = Beans.get(EmployeeService.class).generateNewDPAE(employee);
        ActionViewBuilder builder = ActionView.define(I18n.get("DPAE")).model(DPAE.class.getName()).add("grid", "dpae-grid").add("form", "dpae-form").param("search-filters", "dpae-filters").context("_showRecord", dpaeId);
        response.setView(builder.map());
    } catch (AxelorException e) {
        TraceBackService.trace(response, e);
    }
    response.setReload(true);
}
Also used : DPAE(com.axelor.apps.hr.db.DPAE) AxelorException(com.axelor.exception.AxelorException) Employee(com.axelor.apps.hr.db.Employee) EmployeeService(com.axelor.apps.hr.service.employee.EmployeeService) ActionViewBuilder(com.axelor.meta.schema.actions.ActionView.ActionViewBuilder)

Example 2 with DPAE

use of com.axelor.apps.hr.db.DPAE in project axelor-open-suite by axelor.

the class EmployeeServiceImpl method generateNewDPAE.

@Override
@Transactional(rollbackOn = { Exception.class })
public Long generateNewDPAE(Employee employee) throws AxelorException {
    EmploymentContract mainEmploymentContract = employee.getMainEmploymentContract();
    if (mainEmploymentContract == null) {
        throw new AxelorException(TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.EMPLOYEE_CONTRACT_OF_EMPLOYMENT), employee.getName());
    }
    Company payCompany = mainEmploymentContract.getPayCompany();
    Partner employer = payCompany.getPartner();
    DPAE newDPAE = new DPAE();
    // Employer
    newDPAE.setRegistrationCode(employer.getRegistrationCode());
    if (employer.getMainActivity() != null && employer.getMainActivity().getFullName() != null) {
        newDPAE.setMainActivityCode(employer.getMainActivity().getFullName());
    }
    newDPAE.setCompany(payCompany);
    newDPAE.setCompanyAddress(employer.getMainAddress());
    newDPAE.setCompanyFixedPhone(employer.getFixedPhone());
    if (payCompany.getHrConfig() != null) {
        newDPAE.setHealthService(payCompany.getHrConfig().getHealthService());
        newDPAE.setHealthServiceAddress(payCompany.getHrConfig().getHealthServiceAddress());
    }
    // Employee
    newDPAE.setLastName(employee.getContactPartner().getName());
    newDPAE.setFirstName(employee.getContactPartner().getFirstName());
    newDPAE.setSocialSecurityNumber(employee.getSocialSecurityNumber());
    newDPAE.setSexSelect(employee.getSexSelect());
    newDPAE.setBirthDate(employee.getBirthDate());
    newDPAE.setDepartmentOfBirth(employee.getDepartmentOfBirth());
    newDPAE.setCityOfBirth(employee.getCityOfBirth());
    newDPAE.setCountryOfBirth(employee.getCountryOfBirth());
    // Contract
    newDPAE.setHireDate(mainEmploymentContract.getStartDate());
    newDPAE.setHireTime(mainEmploymentContract.getStartTime());
    newDPAE.setTrialPeriodDuration(mainEmploymentContract.getTrialPeriodDuration());
    newDPAE.setContractType(mainEmploymentContract.getContractType());
    newDPAE.setContractEndDate(mainEmploymentContract.getEndDate());
    employee.addDpaeListItem(newDPAE);
    Beans.get(EmployeeRepository.class).save(employee);
    return newDPAE.getId();
}
Also used : EmploymentContract(com.axelor.apps.hr.db.EmploymentContract) DPAE(com.axelor.apps.hr.db.DPAE) AxelorException(com.axelor.exception.AxelorException) EmployeeRepository(com.axelor.apps.hr.db.repo.EmployeeRepository) Company(com.axelor.apps.base.db.Company) Partner(com.axelor.apps.base.db.Partner) Transactional(com.google.inject.persist.Transactional)

Aggregations

DPAE (com.axelor.apps.hr.db.DPAE)2 AxelorException (com.axelor.exception.AxelorException)2 Company (com.axelor.apps.base.db.Company)1 Partner (com.axelor.apps.base.db.Partner)1 Employee (com.axelor.apps.hr.db.Employee)1 EmploymentContract (com.axelor.apps.hr.db.EmploymentContract)1 EmployeeRepository (com.axelor.apps.hr.db.repo.EmployeeRepository)1 EmployeeService (com.axelor.apps.hr.service.employee.EmployeeService)1 ActionViewBuilder (com.axelor.meta.schema.actions.ActionView.ActionViewBuilder)1 Transactional (com.google.inject.persist.Transactional)1