use of com.axelor.apps.hr.db.EmploymentContract 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();
}
use of com.axelor.apps.hr.db.EmploymentContract in project axelor-open-suite by axelor.
the class EmployeeHRRepository method save.
@Override
public Employee save(Employee entity) {
Partner partner = entity.getContactPartner();
if (!partner.getIsContact() && partner.getPartnerTypeSelect() == 0) {
partner.setIsContact(true);
partner.setIsEmployee(true);
Beans.get(PartnerHRRepository.class).save(partner);
} else {
Beans.get(PartnerService.class).setPartnerFullName(partner);
}
EmploymentContract employmentContract = entity.getMainEmploymentContract();
if (employmentContract != null && employmentContract.getEmployee() == null) {
employmentContract.setEmployee(entity);
}
return super.save(entity);
}
use of com.axelor.apps.hr.db.EmploymentContract in project axelor-open-suite by axelor.
the class AppraisalServiceImpl method createAppraisals.
@Transactional(rollbackOn = { Exception.class })
@Override
public Set<Long> createAppraisals(Appraisal appraisalTemplate, Set<Employee> employees, Boolean send) throws ClassNotFoundException, InstantiationException, IllegalAccessException, AxelorException, IOException, MessagingException {
Set<Long> appraisalIds = new HashSet<Long>();
if (appraisalTemplate == null) {
return appraisalIds;
}
for (Employee employee : employees.stream().filter(Objects::nonNull).collect(Collectors.toList())) {
if (EmployeeHRRepository.isEmployeeFormerNewOrArchived(employee)) {
continue;
}
Appraisal appraisal = appraisalRepo.copy(appraisalTemplate, false);
appraisal.setEmployee(employee);
if (appraisal.getCompany() == null) {
EmploymentContract employmentContract = employee.getMainEmploymentContract();
if (employmentContract != null) {
appraisal.setCompany(employmentContract.getPayCompany());
}
}
appraisal.setIsTemplate(false);
appraisal = appraisalRepo.save(appraisal);
if (send != null && send) {
send(appraisal);
}
appraisalIds.add(appraisal.getId());
}
return appraisalIds;
}
use of com.axelor.apps.hr.db.EmploymentContract in project axelor-open-suite by axelor.
the class EmploymentContractController method exportEmploymentContract.
public void exportEmploymentContract(ActionRequest request, ActionResponse response) throws IOException {
EmploymentContract employmentContract = Beans.get(EmploymentContractRepository.class).find(request.getContext().asType(EmploymentContract.class).getId());
Beans.get(EmploymentContractService.class).exportEmploymentContract(employmentContract);
response.setReload(true);
}
use of com.axelor.apps.hr.db.EmploymentContract in project axelor-open-suite by axelor.
the class PayrollPreparationController method generateFromEmploymentContract.
public void generateFromEmploymentContract(ActionRequest request, ActionResponse response) {
PayrollPreparation payrollPreparation = request.getContext().asType(PayrollPreparation.class);
EmploymentContract employmentContract = Beans.get(EmploymentContractRepository.class).find(new Long(request.getContext().get("_idEmploymentContract").toString()));
response.setValues(Beans.get(PayrollPreparationService.class).generateFromEmploymentContract(payrollPreparation, employmentContract));
}
Aggregations