Search in sources :

Example 1 with EmployeeConfigurationDO

use of org.projectforge.plugins.eed.model.EmployeeConfigurationDO in project projectforge by micromata.

the class EmployeeConfigurationServiceImpl method getSingleEmployeeConfigurationDO.

@Override
public EmployeeConfigurationDO getSingleEmployeeConfigurationDO() {
    employeeConfigurationDao.checkLoggedInUserSelectAccess();
    final List<EmployeeConfigurationDO> employeeConfigurationDOs = employeeConfigurationDao.internalLoadAll();
    if (employeeConfigurationDOs.isEmpty()) {
        final EmployeeConfigurationDO employeeConfigurationDO = employeeConfigurationDao.newInstance();
        employeeConfigurationDao.save(employeeConfigurationDO);
        return employeeConfigurationDO;
    } else if (employeeConfigurationDOs.size() != 1) {
        throw new RuntimeException("Expected One employeeConfigurationDO, but found " + employeeConfigurationDOs.size());
    }
    return employeeConfigurationDOs.get(0);
}
Also used : EmployeeConfigurationDO(org.projectforge.plugins.eed.model.EmployeeConfigurationDO)

Example 2 with EmployeeConfigurationDO

use of org.projectforge.plugins.eed.model.EmployeeConfigurationDO in project projectforge by micromata.

the class EmployeeSalaryExcelImporter method importEmployeeSalary.

private void importEmployeeSalary(final ExcelImport<EmployeeSalaryExcelRow> importer) {
    final ImportedSheet<EmployeeSalaryDO> importedSheet = new ImportedSheet<>(storage);
    storage.addSheet(importedSheet);
    importedSheet.setName(NAME_OF_EXCEL_SHEET);
    importer.setNameRowIndex(ROW_INDEX_OF_COLUMN_NAMES);
    importer.setStartingRowIndex(ROW_INDEX_OF_COLUMN_NAMES + 1);
    final List<String> columnNames = new ArrayList<>();
    EmployeeConfigurationDO emplConfigDO = emplConfigService.getSingleEmployeeConfigurationDO();
    Map<String, JpaTabAttrBaseDO<EmployeeConfigurationDO, Integer>> attrs = emplConfigDO.getAttrs();
    String staffNrColumnName = attrs.get(EmployeeConfigurationService.STAFFNR_COLUMN_NAME_ATTR) != null ? attrs.get(EmployeeConfigurationService.STAFFNR_COLUMN_NAME_ATTR).getStringData() : null;
    String salaryColumnName = attrs.get(EmployeeConfigurationService.SALARY_COLUMN_NAME_ATTR) != null ? attrs.get(EmployeeConfigurationService.SALARY_COLUMN_NAME_ATTR).getStringData() : null;
    String remarkColumnName = attrs.get(EmployeeConfigurationService.REMARK_COLUMN_NAME_ATTR) != null ? attrs.get(EmployeeConfigurationService.REMARK_COLUMN_NAME_ATTR).getStringData() : null;
    // mapping from excel column name to the bean field name
    final Map<String, String> map = new HashMap<>();
    if (StringUtils.isEmpty(staffNrColumnName) || StringUtils.isEmpty(salaryColumnName)) {
        throw new UserException("plugins.eed.salaryimport.validation.nocolumndefinition");
    } else {
        columnNames.add(staffNrColumnName);
        columnNames.add(salaryColumnName);
        map.put(staffNrColumnName, "staffnumber");
        map.put(salaryColumnName, "salary");
        if (!StringUtils.isEmpty(remarkColumnName)) {
            columnNames.add(remarkColumnName);
            map.put(remarkColumnName, "remark");
        }
    }
    if (!importer.getColumnNames().containsAll(columnNames)) {
        throw new UserException("plugins.eed.salaryimport.validation.columndefinitionnotfound", columnNames.get(0), columnNames.get(1));
    }
    importer.setColumnMapping(map);
    final EmployeeSalaryExcelRow[] rows = importer.convertToRows(EmployeeSalaryExcelRow.class);
    for (final EmployeeSalaryExcelRow row : rows) {
        if (row.getStaffnumber() != null) {
            final ImportedElement<EmployeeSalaryDO> element = convertRowToDo(importedSheet, row);
            importedSheet.addElement(element);
        }
    }
}
Also used : JpaTabAttrBaseDO(de.micromata.genome.db.jpa.tabattr.entities.JpaTabAttrBaseDO) EmployeeConfigurationDO(org.projectforge.plugins.eed.model.EmployeeConfigurationDO) EmployeeSalaryDO(org.projectforge.business.fibu.EmployeeSalaryDO) UserException(org.projectforge.common.i18n.UserException) ImportedSheet(de.micromata.merlin.excel.importer.ImportedSheet)

Example 3 with EmployeeConfigurationDO

use of org.projectforge.plugins.eed.model.EmployeeConfigurationDO in project projectforge by micromata.

the class LBExporterService method getExcel.

public byte[] getExcel(final List<EmployeeDO> employeeList, PFDateTime selectedDate) {
    if (employeeList.size() < 1) {
        return new byte[0];
    }
    ExportWorkbook workbook;
    ClassPathResource classPathResource = new ClassPathResource("LBExportTemplate.xls");
    try {
        workbook = new ExportWorkbook(classPathResource.getInputStream());
    } catch (IOException e) {
        Log.error("Something went wrong when loading xls template", e);
        return new byte[0];
    }
    ExportSheet sheetFulltimeEmployee = workbook.getSheet(0);
    int copyRowNrFulltime = START_ROW_NR_FULLTIME;
    ExportRow copyRowFulltime = sheetFulltimeEmployee.getRow(copyRowNrFulltime);
    final EmployeeConfigurationDO singleEmployeeConfigurationDO = employeeConfigurationService.getSingleEmployeeConfigurationDO();
    for (EmployeeDO employee : employeeList) {
        if (employeeService.isEmployeeActive(employee)) {
            if (employeeService.isFulltimeEmployee(employee, selectedDate)) {
                sheetFulltimeEmployee.copyRow(copyRowFulltime);
                copyRowNrFulltime++;
                final ExportRow currentRow = sheetFulltimeEmployee.getRow(copyRowNrFulltime - 1);
                // 0 -> Lastname
                currentRow.getCell(0).setValue(employee.getUser().getLastname());
                // 1 -> Firstname
                currentRow.getCell(1).setValue(employee.getUser().getFirstname());
                // 2 -> Arbeitsstunden
                currentRow.getCell(2).setValue(employee.getWeeklyWorkingHours());
                // 3 -> Personalnummer
                currentRow.getCell(3).setValue(employee.getStaffNumber());
                // 4 -> Gehalt
                currentRow.getCell(4).setValue(round(employeeService.getMonthlySalary(employee, selectedDate)));
                // 14 / 15 Essen
                final boolean hasFood = getAttrValueForMonthAsBoolean(employee, "food", "food", selectedDate);
                if (hasFood) {
                    BigDecimal oneDayValue = getAttrValueForMonthAsBigDecimal(singleEmployeeConfigurationDO, "food", "referencevalue", selectedDate);
                    if (oneDayValue != null) {
                        final BigDecimal fullValue = oneDayValue.multiply(FOOD_VOUCHER_DAYS_PER_MONTH);
                        currentRow.getCell(14).setValue(round(fullValue));
                    }
                    oneDayValue = getAttrValueForMonthAsBigDecimal(singleEmployeeConfigurationDO, "food", "contribution", selectedDate);
                    if (oneDayValue != null) {
                        final BigDecimal fullValue = oneDayValue.multiply(FOOD_VOUCHER_DAYS_PER_MONTH);
                        currentRow.getCell(15).setValue(round(fullValue));
                    }
                }
                // 16 Tankgutschein
                final boolean hasFuelVoucher = getAttrValueForMonthAsBoolean(employee, "fuelvoucher", "fuelvoucher", selectedDate);
                if (hasFuelVoucher) {
                    currentRow.getCell(16).setValue(round(getAttrValueForMonthAsBigDecimal(singleEmployeeConfigurationDO, "refuel", "voucher", selectedDate)));
                }
                // 22 -> Kita
                currentRow.getCell(22).setValue(round(getAttrValueForMonthAsBigDecimal(employee, "daycarecenter", "daycarecenter", selectedDate)));
                // 23 -> eBike
                currentRow.getCell(23).setValue(round(getAttrValueForMonthAsBigDecimal(employee, "ebikeleasing", "ebikeleasing", selectedDate)));
                // 24 -> RK
                currentRow.getCell(24).setValue(round(getAttrValueForMonthAsBigDecimal(employee, "costtravel", "costtravel", selectedDate)));
                // 25 -> Auslagen
                currentRow.getCell(25).setValue(round(getAttrValueForMonthAsBigDecimal(employee, "expenses", "expenses", selectedDate)));
                // 26 Überstunden
                currentRow.getCell(26).setValue(getAttrValueForMonthAsBigDecimal(employee, "overtime", "overtime", selectedDate));
                // 27 Prämie
                currentRow.getCell(27).setValue(round(getAttrValueForMonthAsBigDecimal(employee, "bonus", "bonus", selectedDate)));
                // 28 Sonderzahlung
                currentRow.getCell(28).setValue(round(getAttrValueForMonthAsBigDecimal(employee, "specialpayment", "specialpayment", selectedDate)));
                // 29 Zielvereinbarung
                currentRow.getCell(29).setValue(round(getAttrValueForMonthAsBigDecimal(employee, "targetagreements", "targetagreements", selectedDate)));
                // 30 Shop
                currentRow.getCell(30).setValue(round(getAttrValueForMonthAsBigDecimal(employee, "costshop", "costshop", selectedDate)));
                // 32 Samstagsarbeit TODO: convert hours to money and don't forget to call round()
                currentRow.getCell(32).setValue(getAttrValueForMonthAsBigDecimal(employee, "weekendwork", "workinghourssaturday", selectedDate));
                // 33 Sonntagarbeit TODO: convert hours to money and don't forget to call round()
                currentRow.getCell(33).setValue(getAttrValueForMonthAsBigDecimal(employee, "weekendwork", "workinghourssunday", selectedDate));
                // 34 Feiertagarbeit TODO: convert hours to money and don't forget to call round()
                currentRow.getCell(34).setValue(getAttrValueForMonthAsBigDecimal(employee, "weekendwork", "workinghoursholiday", selectedDate));
                // 35 Bemerkung
                currentRow.getCell(35).setValue(getAttrValueForMonthAsString(employee, "others", "others", selectedDate));
                copyRowFulltime = sheetFulltimeEmployee.getRow(copyRowNrFulltime);
            }
        }
    }
    return workbook.getAsByteArray();
}
Also used : ExportWorkbook(org.projectforge.business.excel.ExportWorkbook) EmployeeConfigurationDO(org.projectforge.plugins.eed.model.EmployeeConfigurationDO) ExportSheet(org.projectforge.business.excel.ExportSheet) ExportRow(org.projectforge.business.excel.ExportRow) IOException(java.io.IOException) EmployeeDO(org.projectforge.business.fibu.EmployeeDO) ClassPathResource(org.springframework.core.io.ClassPathResource) BigDecimal(java.math.BigDecimal)

Aggregations

EmployeeConfigurationDO (org.projectforge.plugins.eed.model.EmployeeConfigurationDO)3 JpaTabAttrBaseDO (de.micromata.genome.db.jpa.tabattr.entities.JpaTabAttrBaseDO)1 ImportedSheet (de.micromata.merlin.excel.importer.ImportedSheet)1 IOException (java.io.IOException)1 BigDecimal (java.math.BigDecimal)1 ExportRow (org.projectforge.business.excel.ExportRow)1 ExportSheet (org.projectforge.business.excel.ExportSheet)1 ExportWorkbook (org.projectforge.business.excel.ExportWorkbook)1 EmployeeDO (org.projectforge.business.fibu.EmployeeDO)1 EmployeeSalaryDO (org.projectforge.business.fibu.EmployeeSalaryDO)1 UserException (org.projectforge.common.i18n.UserException)1 ClassPathResource (org.springframework.core.io.ClassPathResource)1