Search in sources :

Example 6 with EmploymentContract

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

Example 7 with EmploymentContract

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);
}
Also used : EmploymentContract(com.axelor.apps.hr.db.EmploymentContract) PartnerService(com.axelor.apps.base.service.PartnerService) Partner(com.axelor.apps.base.db.Partner)

Example 8 with EmploymentContract

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

Example 9 with EmploymentContract

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);
}
Also used : EmploymentContract(com.axelor.apps.hr.db.EmploymentContract) EmploymentContractService(com.axelor.apps.hr.service.EmploymentContractService) EmploymentContractRepository(com.axelor.apps.hr.db.repo.EmploymentContractRepository)

Example 10 with EmploymentContract

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

Aggregations

EmploymentContract (com.axelor.apps.hr.db.EmploymentContract)10 Transactional (com.google.inject.persist.Transactional)5 EmploymentContractService (com.axelor.apps.hr.service.EmploymentContractService)3 AxelorException (com.axelor.exception.AxelorException)3 Company (com.axelor.apps.base.db.Company)2 Partner (com.axelor.apps.base.db.Partner)2 Employee (com.axelor.apps.hr.db.Employee)2 EmployeeRepository (com.axelor.apps.hr.db.repo.EmployeeRepository)2 EmploymentContractRepository (com.axelor.apps.hr.db.repo.EmploymentContractRepository)2 BigDecimal (java.math.BigDecimal)2 ArrayList (java.util.ArrayList)2 PartnerService (com.axelor.apps.base.service.PartnerService)1 UserService (com.axelor.apps.base.service.user.UserService)1 DPAE (com.axelor.apps.hr.db.DPAE)1 KilometricAllowanceRate (com.axelor.apps.hr.db.KilometricAllowanceRate)1 KilometricAllowanceRule (com.axelor.apps.hr.db.KilometricAllowanceRule)1 KilometricLog (com.axelor.apps.hr.db.KilometricLog)1 LeaveLine (com.axelor.apps.hr.db.LeaveLine)1 LeaveManagement (com.axelor.apps.hr.db.LeaveManagement)1 LeaveManagementBatchRule (com.axelor.apps.hr.db.LeaveManagementBatchRule)1