Search in sources :

Example 6 with PayrollPreparation

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

the class PayrollPreparationController method exportPayrollPreparation.

public void exportPayrollPreparation(ActionRequest request, ActionResponse response) throws IOException, AxelorException {
    PayrollPreparationService payrollPreparationService = Beans.get(PayrollPreparationService.class);
    PayrollPreparation payrollPreparation = Beans.get(PayrollPreparationRepository.class).find(request.getContext().asType(PayrollPreparation.class).getId());
    String file = payrollPreparationService.exportPayrollPreparation(payrollPreparation);
    if (file != null) {
        String[] filePath = file.split("/");
        response.setExportFile(filePath[filePath.length - 1]);
    }
    payrollPreparationService.closePayPeriodIfExported(payrollPreparation);
    response.setReload(true);
}
Also used : PayrollPreparationRepository(com.axelor.apps.hr.db.repo.PayrollPreparationRepository) PayrollPreparationService(com.axelor.apps.hr.service.PayrollPreparationService) PayrollPreparation(com.axelor.apps.hr.db.PayrollPreparation)

Example 7 with PayrollPreparation

use of com.axelor.apps.hr.db.PayrollPreparation 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)

Example 8 with PayrollPreparation

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

the class BatchPayrollPreparationGeneration method createPayrollPreparation.

@Transactional(rollbackOn = { Exception.class })
public void createPayrollPreparation(Employee employee) throws AxelorException {
    if (employee == null || EmployeeHRRepository.isEmployeeFormerNewOrArchived(employee)) {
        return;
    }
    String filter = "self.period = ?1 AND self.employee = ?2";
    String companyFilter = filter + " AND self.company = ?3";
    List<PayrollPreparation> payrollPreparationList = payrollPreparationRepository.all().filter((company != null) ? companyFilter : filter, hrBatch.getPeriod(), employee, company).fetch();
    log.debug("list : " + payrollPreparationList);
    if (!payrollPreparationList.isEmpty()) {
        throw new AxelorException(employee, TraceBackRepository.CATEGORY_NO_UNIQUE_KEY, I18n.get(IExceptionMessage.PAYROLL_PREPARATION_DUPLICATE), employee.getName(), (company != null) ? hrBatch.getCompany().getName() : null, hrBatch.getPeriod().getName());
    }
    PayrollPreparation payrollPreparation = new PayrollPreparation();
    if (company != null) {
        Company currentCompany = companyRepository.find(company.getId());
        payrollPreparation.setCompany(currentCompany);
    } else {
        payrollPreparation.setCompany(employee.getMainEmploymentContract().getPayCompany());
    }
    Period period = periodRepository.find(hrBatch.getPeriod().getId());
    payrollPreparation.setEmployee(employee);
    payrollPreparation.setEmploymentContract(employee.getMainEmploymentContract());
    payrollPreparation.setPeriod(period);
    payrollPreparationService.fillInPayrollPreparation(payrollPreparation);
    payrollPreparationRepository.save(payrollPreparation);
    updateEmployee(employee);
}
Also used : AxelorException(com.axelor.exception.AxelorException) Company(com.axelor.apps.base.db.Company) Period(com.axelor.apps.base.db.Period) PayrollPreparation(com.axelor.apps.hr.db.PayrollPreparation) Transactional(com.google.inject.persist.Transactional)

Aggregations

PayrollPreparation (com.axelor.apps.hr.db.PayrollPreparation)8 PayrollPreparationService (com.axelor.apps.hr.service.PayrollPreparationService)5 Transactional (com.google.inject.persist.Transactional)4 MetaFiles (com.axelor.meta.MetaFiles)3 MetaFile (com.axelor.meta.db.MetaFile)3 File (java.io.File)3 FileInputStream (java.io.FileInputStream)3 ArrayList (java.util.ArrayList)3 PayrollLeave (com.axelor.apps.hr.db.PayrollLeave)2 Company (com.axelor.apps.base.db.Company)1 Period (com.axelor.apps.base.db.Period)1 AppBaseService (com.axelor.apps.base.service.app.AppBaseService)1 EmploymentContract (com.axelor.apps.hr.db.EmploymentContract)1 EmploymentContractRepository (com.axelor.apps.hr.db.repo.EmploymentContractRepository)1 PayrollPreparationRepository (com.axelor.apps.hr.db.repo.PayrollPreparationRepository)1 AxelorException (com.axelor.exception.AxelorException)1 LocalDate (java.time.LocalDate)1