@Override public EmployeeSalaryDO getEmployeeSalaryByDate(EmployeeDO employee, Calendar selectedDate) { List<EmployeeSalaryDO> findByEmployee = employeeSalaryDao.findByEmployee(employee); for (EmployeeSalaryDO sal : findByEmployee) { if (sal.getYear().equals(selectedDate.get(Calendar.YEAR)) && sal.getMonth().equals(selectedDate.get(Calendar.MONTH))) { return sal; } } return null; }
@Override public EmployeeSalaryDO getLatestSalaryForEmployee(EmployeeDO employee) { List<EmployeeSalaryDO> findByEmployee = employeeSalaryDao.findByEmployee(employee); return findByEmployee .stream() .sorted((sal1, sal2) -> { Calendar c1 = new GregorianCalendar(sal1.getYear(), sal1.getMonth(), 1); Calendar c2 = new GregorianCalendar(sal2.getYear(), sal2.getMonth(), 1); return c2.compareTo(c1); }) .findFirst() .orElse(null); }
@Override protected void onSaveOrModify(EmployeeSalaryDO obj) { if (obj.getId() == null) { List<EmployeeSalaryDO> list = pfEmgrFactory.runRoTrans(emgr -> { return emgr.select(EmployeeSalaryDO.class, "SELECT s FROM EmployeeSalaryDO s WHERE s.year = :year and s.month = :month and s.employee.id = :employeeid", "year", obj.getYear(), "month", obj.getMonth(), "employeeid", obj.getEmployeeId()); }); if (CollectionUtils.isNotEmpty(list)) { log.info("Insert of EmployeeSalaryDO not possible. There is a existing one for employee with id: " + obj.getEmployeeId() + " and year: " + obj.getYear() + " and month: " + obj.getMonth() + " . Existing one: " + list.get(0).toString()); throw new UserException("fibu.employee.salary.error.salaryAlreadyExist"); } } else { List<EmployeeSalaryDO> list = pfEmgrFactory.runRoTrans(emgr -> { return emgr .select(EmployeeSalaryDO.class, "SELECT s FROM EmployeeSalaryDO s WHERE s.year = :year and s.month = :month and s.employee.id = :employeeid and s.id <> :id", "year", obj.getYear(), "month", obj.getMonth(), "employeeid", obj.getEmployeeId(), "id", obj.getId()); }); if (CollectionUtils.isNotEmpty(list)) { log.info("Update of EmployeeSalaryDO not possible. There is a existing one for employee with id: " + obj.getEmployeeId() + " and year: " + obj.getYear() + " and month: " + obj.getMonth() + " and ID: " + obj.getId() + " . Existing one: " + list.get(0).toString()); throw new UserException("fibu.employee.salary.error.salaryAlreadyExist"); } } }
@Override public AbstractSecuredBasePage afterSaveOrUpdate() { recent = getRecent(); if (getData().getYear() != null) { recent.setYear(getData().getYear()); } if (getData().getMonth() != null) { recent.setMonth(getData().getMonth()); } if (getData().getType() != null) { recent.setType(getData().getType()); } return null; }
@Override protected void addColumns(final RepeatingView cellRepeater, final ImportedElement<?> element, final String style) { final String s = "white-space: nowrap; text-align: right;"; final String styleRightAlign = (style == null) ? s : style + " " + s; final EmployeeSalaryDO employeeSalary = (EmployeeSalaryDO) element.getValue(); final EmployeeDO employee = employeeSalary != null ? employeeSalary.getEmployee() : null; addCell(cellRepeater, employee != null ? employee.getStaffNumber() : "", styleRightAlign); addCell(cellRepeater, employee != null ? employee.getUser().getFullname() : "", styleRightAlign); addCell(cellRepeater, employeeSalary != null ? employeeSalary.getYear() : null, styleRightAlign); addCell(cellRepeater, employeeSalary != null ? employeeSalary.getMonth() : null, styleRightAlign); addCell(cellRepeater, employeeSalary != null && employeeSalary.getBruttoMitAgAnteil() != null ? employeeSalary.getBruttoMitAgAnteil().toString() : "", styleRightAlign); addCell(cellRepeater, employeeSalary != null ? employeeSalary.getComment() : "", styleRightAlign); }
final int year = first.getYear(); final int month = first.getMonth(); final DayHolder buchungsdatum = new DayHolder(); final PropertyMapping mapping = new PropertyMapping(); final PFUserDO user = getUserGroupCache().getUser(salary.getEmployee().getUserId()); Validate.isTrue(year == salary.getYear()); Validate.isTrue(month == salary.getMonth()); final MonthlyEmployeeReport report = monthlyEmployeeReportDao.getReport(year, month, user);