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