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);
}
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();
}
Aggregations