Search in sources :

Example 1 with PayrollLeave

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());
}
Also used : PayrollPreparationService(com.axelor.apps.hr.service.PayrollPreparationService) PayrollLeave(com.axelor.apps.hr.db.PayrollLeave) PayrollPreparation(com.axelor.apps.hr.db.PayrollPreparation)

Example 2 with PayrollLeave

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;
}
Also used : HRConfig(com.axelor.apps.hr.db.HRConfig) PayrollLeave(com.axelor.apps.hr.db.PayrollLeave)

Example 3 with PayrollLeave

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;
}
Also used : AxelorException(com.axelor.exception.AxelorException) Employee(com.axelor.apps.hr.db.Employee) ArrayList(java.util.ArrayList) PayrollLeave(com.axelor.apps.hr.db.PayrollLeave) LeaveRequest(com.axelor.apps.hr.db.LeaveRequest) LocalDate(java.time.LocalDate)

Example 4 with PayrollLeave

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);
}
Also used : PayrollPreparationService(com.axelor.apps.hr.service.PayrollPreparationService) PayrollLeave(com.axelor.apps.hr.db.PayrollLeave) PayrollPreparation(com.axelor.apps.hr.db.PayrollPreparation)

Example 5 with PayrollLeave

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;
}
Also used : PayrollLeave(com.axelor.apps.hr.db.PayrollLeave) LocalDate(java.time.LocalDate) BigDecimal(java.math.BigDecimal)

Aggregations

PayrollLeave (com.axelor.apps.hr.db.PayrollLeave)6 HRConfig (com.axelor.apps.hr.db.HRConfig)2 PayrollPreparation (com.axelor.apps.hr.db.PayrollPreparation)2 PayrollPreparationService (com.axelor.apps.hr.service.PayrollPreparationService)2 BigDecimal (java.math.BigDecimal)2 LocalDate (java.time.LocalDate)2 Employee (com.axelor.apps.hr.db.Employee)1 EmployeeBonusMgtLine (com.axelor.apps.hr.db.EmployeeBonusMgtLine)1 ExtraHoursLine (com.axelor.apps.hr.db.ExtraHoursLine)1 ExtraHoursType (com.axelor.apps.hr.db.ExtraHoursType)1 LeaveRequest (com.axelor.apps.hr.db.LeaveRequest)1 ExtraHoursLineRepository (com.axelor.apps.hr.db.repo.ExtraHoursLineRepository)1 AxelorException (com.axelor.exception.AxelorException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1