Esempio n. 1
0
  private Integer getVacationDaysCountForPeriod(
      String beginDateString, Integer employeeId, Integer vacationTypeId) {
    Employee employee = employeeService.find(employeeId);
    final Timestamp beginDate =
        DateTimeUtil.stringToTimestamp(beginDateString, CreateVacationForm.DATE_FORMAT);
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(employee.getStartDate());
    Integer beginDay = calendar.get(Calendar.DAY_OF_MONTH);

    calendar.setTime(beginDate);
    Integer vacDay = calendar.get(Calendar.DAY_OF_MONTH);
    Integer month = calendar.get(Calendar.MONTH);
    Integer year = calendar.get(Calendar.YEAR);
    //  Если день начала отпуска меньше даты устройства на работу
    //  то оставляем месяц без изменений т.к. calendar.get(Calendar.MONTH) дает -1 один месяц
    if (vacDay > beginDay) {
      ++month;
    }
    Integer count = null;
    if (vacationTypeId.equals(VacationTypesEnum.WITH_PAY.getId())) {
      count = getFactVacationDaysCount(employee, year, month);
    } else {
      count = getPlanVacationDaysCount(employee, year, month);
    }
    return count;
  }
Esempio n. 2
0
  public String getVacActualizationDate(Employee employee, Integer year, Integer month) {
    Calendar calendarAct = Calendar.getInstance();
    calendarAct.setTime(employee.getStartDate());

    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.MONTH, --month);
    calendar.set(Calendar.YEAR, year);
    calendar.set(Calendar.DAY_OF_MONTH, calendarAct.get(Calendar.DAY_OF_MONTH));
    return DateTimeUtil.formatDateIntoViewFormat(calendar.getTime());
  }
Esempio n. 3
0
  public Integer getVacationDaysCount(
      Employee employee, Integer year, Integer month, Boolean fact) {
    VacationDays vacationDays = vacationDaysService.findByEmployee(employee);
    if (vacationDays != null) {
      Calendar calendarAct = Calendar.getInstance();
      calendarAct.setTime(employee.getStartDate());

      Calendar calendar = Calendar.getInstance();
      calendar.set(Calendar.MONTH, --month);
      calendar.set(Calendar.YEAR, year);
      calendar.set(Calendar.DAY_OF_MONTH, calendarAct.get(Calendar.DAY_OF_MONTH));

      Date start = vacationDays.getActualizationDate();
      Date end = calendar.getTime();

      if (start.after(end)) {
        return 0;
      }

      int months = DateTimeUtil.getDiffInMonths(start, end);
      int vacDays = (int) (++months * VACATION_KOEF);
      vacDays += vacationDays.getCountDays();
      Integer vacationsCountByPeriod;
      if (!fact) {
        vacationsCountByPeriod =
            getPlannedVacationsCountByPeriod(employee, vacationDays.getActualizationDate());
      } else {
        vacationsCountByPeriod =
            getFactVacationsCountByPeriod(employee, vacationDays.getActualizationDate());
      }
      if (vacDays > 0) {
        vacDays -= vacationsCountByPeriod;
        return vacDays;
      } else {
        return vacDays;
      }
    }
    return null;
  }