use of com.axelor.apps.hr.db.PayrollLeave in project axelor-open-suite by axelor.
the class PayrollPreparationController method fillInPayrollPreparation.
public void fillInPayrollPreparation(ActionRequest request, ActionResponse response) throws AxelorException {
PayrollPreparation payrollPreparation = request.getContext().asType(PayrollPreparation.class);
List<PayrollLeave> payrollLeaveList = Beans.get(PayrollPreparationService.class).fillInPayrollPreparation(payrollPreparation);
response.setValue("extraHoursLineList", payrollPreparation.getExtraHoursLineList());
response.setValue("$payrollLeavesList", payrollLeaveList);
response.setValue("duration", payrollPreparation.getDuration());
response.setValue("leaveDuration", payrollPreparation.getLeaveDuration());
response.setValue("expenseAmount", payrollPreparation.getExpenseAmount());
response.setValue("expenseList", payrollPreparation.getExpenseList());
response.setValue("otherCostsEmployeeSet", payrollPreparation.getEmploymentContract().getOtherCostsEmployeeSet());
response.setValue("annualGrossSalary", payrollPreparation.getEmploymentContract().getAnnualGrossSalary());
response.setValue("employeeBonusMgtLineList", payrollPreparation.getEmployeeBonusMgtLineList());
response.setValue("lunchVoucherNumber", payrollPreparation.getLunchVoucherNumber());
response.setValue("lunchVoucherMgtLineList", payrollPreparation.getLunchVoucherMgtLineList());
response.setValue("employeeBonusAmount", payrollPreparation.getEmployeeBonusAmount());
response.setValue("extraHoursNumber", payrollPreparation.getExtraHoursNumber());
}
use of com.axelor.apps.hr.db.PayrollLeave in project axelor-open-suite by axelor.
the class PayrollPreparationService method exportSilae.
public List<String[]> exportSilae(PayrollPreparation payrollPrep, List<String[]> exportLineList) throws AxelorException {
HRConfig hrConfig = hrConfigService.getHRConfig(payrollPrep.getCompany());
// Payroll leaves
if (payrollPrep.getLeaveDuration().compareTo(BigDecimal.ZERO) > 0) {
List<PayrollLeave> payrollLeaveList = this.fillInLeaves(payrollPrep);
for (PayrollLeave payrollLeave : payrollLeaveList) {
if (payrollLeave.getLeaveReason().getPayrollPreprationExport()) {
String[] leaveLine = createSilaeExportFileLine(payrollPrep);
leaveLine[1] = payrollLeave.getLeaveReason().getExportCode();
leaveLine[2] = String.valueOf(payrollLeave.getDuration());
leaveLine[3] = payrollLeave.getFromDate().format(DateTimeFormatter.ofPattern("dd/MM/yyyy"));
leaveLine[4] = payrollLeave.getToDate().format(DateTimeFormatter.ofPattern("dd/MM/yyyy"));
exportLineList.add(leaveLine);
}
}
}
// Payroll duration
String[] durationLine = createSilaeExportFileLine(payrollPrep);
durationLine[1] = hrConfig.getExportCodeForDuration();
durationLine[2] = String.valueOf(payrollPrep.getDuration());
exportLineList.add(durationLine);
// Payroll extraHoursNumber
String[] extraHoursLine = createSilaeExportFileLine(payrollPrep);
extraHoursLine[1] = hrConfig.getExportCodeForExtraHours();
extraHoursLine[2] = String.valueOf(payrollPrep.getExtraHoursNumber());
exportLineList.add(extraHoursLine);
return exportLineList;
}
use of com.axelor.apps.hr.db.PayrollLeave in project axelor-open-suite by axelor.
the class PayrollPreparationService method fillInLeaves.
public List<PayrollLeave> fillInLeaves(PayrollPreparation payrollPreparation) throws AxelorException {
List<PayrollLeave> payrollLeaveList = new ArrayList<>();
LocalDate fromDate = payrollPreparation.getPeriod().getFromDate();
LocalDate toDate = payrollPreparation.getPeriod().getToDate();
Employee employee = payrollPreparation.getEmployee();
if (employee.getWeeklyPlanning() == null) {
throw new AxelorException(payrollPreparation, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.EMPLOYEE_PLANNING), employee.getName());
}
List<LeaveRequest> leaveRequestList = leaveRequestRepo.all().filter("self.statusSelect = ?4 AND self.user.employee = ?3 AND ((self.fromDateT BETWEEN ?2 AND ?1 OR self.toDateT BETWEEN ?2 AND ?1) OR (?1 BETWEEN self.fromDateT AND self.toDateT OR ?2 BETWEEN self.fromDateT AND self.toDateT))", toDate, fromDate, employee, LeaveRequestRepository.STATUS_VALIDATED).fetch();
for (LeaveRequest leaveRequest : leaveRequestList) {
PayrollLeave payrollLeave = new PayrollLeave();
if (leaveRequest.getFromDateT().toLocalDate().isBefore(fromDate)) {
payrollLeave.setFromDate(fromDate);
} else {
payrollLeave.setFromDate(leaveRequest.getFromDateT().toLocalDate());
}
if (leaveRequest.getToDateT().toLocalDate().isAfter(toDate)) {
payrollLeave.setToDate(toDate);
} else {
payrollLeave.setToDate(leaveRequest.getToDateT().toLocalDate());
}
payrollLeave.setDuration(leaveService.computeLeaveDaysByLeaveRequest(fromDate, toDate, leaveRequest, employee));
payrollLeave.setLeaveReason(leaveRequest.getLeaveReason());
payrollLeave.setLeaveRequest(leaveRequest);
payrollLeaveList.add(payrollLeave);
}
return payrollLeaveList;
}
use of com.axelor.apps.hr.db.PayrollLeave in project axelor-open-suite by axelor.
the class PayrollPreparationController method fillInPayrollPreparationLeaves.
public void fillInPayrollPreparationLeaves(ActionRequest request, ActionResponse response) throws AxelorException {
PayrollPreparation payrollPreparation = request.getContext().asType(PayrollPreparation.class);
List<PayrollLeave> payrollLeaveList = Beans.get(PayrollPreparationService.class).fillInLeaves(payrollPreparation);
response.setValue("$payrollLeavesList", payrollLeaveList);
}
use of com.axelor.apps.hr.db.PayrollLeave in project axelor-open-suite by axelor.
the class PayrollPreparationService method computeWorkingDaysNumber.
public BigDecimal computeWorkingDaysNumber(PayrollPreparation payrollPreparation, List<PayrollLeave> payrollLeaveList) {
LocalDate fromDate = payrollPreparation.getPeriod().getFromDate();
LocalDate toDate = payrollPreparation.getPeriod().getToDate();
LocalDate itDate = LocalDate.parse(fromDate.toString(), DateTimeFormatter.ISO_DATE);
BigDecimal workingDays = BigDecimal.ZERO;
BigDecimal leaveDays = BigDecimal.ZERO;
while (!itDate.isAfter(toDate)) {
workingDays = workingDays.add(BigDecimal.valueOf(weeklyPlanningService.getWorkingDayValueInDays(payrollPreparation.getEmployee().getWeeklyPlanning(), itDate)));
itDate = itDate.plusDays(1);
}
if (payrollLeaveList != null) {
for (PayrollLeave payrollLeave : payrollLeaveList) {
workingDays = workingDays.subtract(payrollLeave.getDuration());
leaveDays = leaveDays.add(payrollLeave.getDuration());
}
}
payrollPreparation.setLeaveDuration(leaveDays);
return workingDays;
}
Aggregations