Search in sources :

Example 1 with ExtraHoursLine

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

the class ExtraHoursServiceImpl method compute.

@Override
public void compute(ExtraHours extraHours) {
    BigDecimal totalQty = BigDecimal.ZERO;
    List<ExtraHoursLine> extraHoursLines = extraHours.getExtraHoursLineList();
    for (ExtraHoursLine extraHoursLine : extraHoursLines) {
        totalQty = totalQty.add(extraHoursLine.getQty());
    }
    extraHours.setTotalQty(totalQty);
}
Also used : ExtraHoursLine(com.axelor.apps.hr.db.ExtraHoursLine) BigDecimal(java.math.BigDecimal)

Example 2 with ExtraHoursLine

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

the class PayrollPreparationService method computeExtraHoursNumber.

public BigDecimal computeExtraHoursNumber(PayrollPreparation payrollPreparation) {
    LocalDate fromDate = payrollPreparation.getPeriod().getFromDate();
    LocalDate toDate = payrollPreparation.getPeriod().getToDate();
    BigDecimal extraHoursNumber = BigDecimal.ZERO;
    for (ExtraHoursLine extraHoursLine : Beans.get(ExtraHoursLineRepository.class).all().filter("self.user.employee = ?1 AND self.extraHours.statusSelect = 3 AND self.date BETWEEN ?2 AND ?3 AND (self.payrollPreparation = null OR self.payrollPreparation.id = ?4)", payrollPreparation.getEmployee(), fromDate, toDate, payrollPreparation.getId()).fetch()) {
        payrollPreparation.addExtraHoursLineListItem(extraHoursLine);
        extraHoursNumber = extraHoursNumber.add(extraHoursLine.getQty());
    }
    return extraHoursNumber;
}
Also used : ExtraHoursLineRepository(com.axelor.apps.hr.db.repo.ExtraHoursLineRepository) ExtraHoursLine(com.axelor.apps.hr.db.ExtraHoursLine) LocalDate(java.time.LocalDate) BigDecimal(java.math.BigDecimal)

Example 3 with ExtraHoursLine

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

the class PayrollPreparationService method exportNibelis.

public void exportNibelis(PayrollPreparation payrollPreparation, List<String[]> list) throws AxelorException {
    HRConfig hrConfig = hrConfigService.getHRConfig(payrollPreparation.getCompany());
    // LEAVES
    if (payrollPreparation.getLeaveDuration().compareTo(BigDecimal.ZERO) > 0) {
        List<PayrollLeave> payrollLeaveList = fillInLeaves(payrollPreparation);
        for (PayrollLeave payrollLeave : payrollLeaveList) {
            if (payrollLeave.getLeaveReason().getPayrollPreprationExport()) {
                String[] leaveLine = createExportFileLine(payrollPreparation);
                leaveLine[3] = payrollLeave.getLeaveReason().getExportCode();
                leaveLine[4] = payrollLeave.getFromDate().format(DateTimeFormatter.ofPattern("dd/MM/yyyy"));
                leaveLine[5] = payrollLeave.getToDate().format(DateTimeFormatter.ofPattern("dd/MM/yyyy"));
                leaveLine[6] = payrollLeave.getDuration().toString();
                list.add(leaveLine);
            }
        }
    }
    // LUNCH VOUCHER MANAGEMENT
    if (payrollPreparation.getLunchVoucherNumber().compareTo(BigDecimal.ZERO) > 0) {
        String[] lunchVoucherLine = createExportFileLine(payrollPreparation);
        lunchVoucherLine[3] = hrConfig.getExportCodeForLunchVoucherManagement();
        lunchVoucherLine[6] = payrollPreparation.getLunchVoucherNumber().toString();
        list.add(lunchVoucherLine);
    }
    // EMPLOYEE BONUS MANAGEMENT
    if (payrollPreparation.getEmployeeBonusAmount().compareTo(BigDecimal.ZERO) > 0) {
        Map<String, BigDecimal> map = new HashMap<>();
        for (EmployeeBonusMgtLine bonus : payrollPreparation.getEmployeeBonusMgtLineList()) {
            if (bonus.getEmployeeBonusMgt().getEmployeeBonusType().getPayrollPreparationExport()) {
                if (map.containsKey(bonus.getEmployeeBonusMgt().getEmployeeBonusType().getExportCode())) {
                    map.put(bonus.getEmployeeBonusMgt().getEmployeeBonusType().getExportCode(), bonus.getAmount().add(map.get(bonus.getEmployeeBonusMgt().getEmployeeBonusType().getExportCode())));
                } else {
                    map.put(bonus.getEmployeeBonusMgt().getEmployeeBonusType().getExportCode(), bonus.getAmount());
                }
            }
        }
        for (Map.Entry<String, BigDecimal> entry : map.entrySet()) {
            String[] employeeBonusLine = createExportFileLine(payrollPreparation);
            employeeBonusLine[3] = entry.getKey();
            employeeBonusLine[6] = entry.getValue().toString();
            list.add(employeeBonusLine);
        }
    }
    // EXTRA HOURS
    if (payrollPreparation.getExtraHoursNumber().compareTo(BigDecimal.ZERO) > 0) {
        List<ExtraHoursLine> extraHourLineList = Beans.get(ExtraHoursLineRepository.class).all().filter("self.payrollPreparation.id = ?1" + " AND self.extraHoursType.payrollPreprationExport = ?2", payrollPreparation.getId(), true).fetch();
        Map<ExtraHoursType, BigDecimal> extraHourLineExportMap = extraHourLineList.stream().collect(Collectors.groupingBy(ExtraHoursLine::getExtraHoursType, Collectors.reducing(BigDecimal.ZERO, ExtraHoursLine::getQty, BigDecimal::add)));
        extraHourLineExportMap.forEach((extraHoursTypeGroup, totalHours) -> {
            String[] extraHourLine = createExportFileLine(payrollPreparation);
            extraHourLine[3] = extraHoursTypeGroup.getExportCode();
            extraHourLine[6] = totalHours.toString();
            list.add(extraHourLine);
        });
    }
}
Also used : HashMap(java.util.HashMap) ExtraHoursType(com.axelor.apps.hr.db.ExtraHoursType) ExtraHoursLine(com.axelor.apps.hr.db.ExtraHoursLine) BigDecimal(java.math.BigDecimal) HRConfig(com.axelor.apps.hr.db.HRConfig) EmployeeBonusMgtLine(com.axelor.apps.hr.db.EmployeeBonusMgtLine) ExtraHoursLineRepository(com.axelor.apps.hr.db.repo.ExtraHoursLineRepository) PayrollLeave(com.axelor.apps.hr.db.PayrollLeave) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ExtraHoursLine (com.axelor.apps.hr.db.ExtraHoursLine)3 BigDecimal (java.math.BigDecimal)3 ExtraHoursLineRepository (com.axelor.apps.hr.db.repo.ExtraHoursLineRepository)2 EmployeeBonusMgtLine (com.axelor.apps.hr.db.EmployeeBonusMgtLine)1 ExtraHoursType (com.axelor.apps.hr.db.ExtraHoursType)1 HRConfig (com.axelor.apps.hr.db.HRConfig)1 PayrollLeave (com.axelor.apps.hr.db.PayrollLeave)1 LocalDate (java.time.LocalDate)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1