private void prepareSickNoteList(Person person, int year, Model model) {

    List<SickNote> sickNotes =
        sickNoteService.getByPersonAndPeriod(
            person, DateUtil.getFirstDayOfYear(year), DateUtil.getLastDayOfYear(year));

    List<ExtendedSickNote> extendedSickNotes =
        FluentIterable.from(sickNotes)
            .transform(input -> new ExtendedSickNote(input, calendarService))
            .toSortedList(
                (o1, o2) -> {
                  // show latest sick notes at first
                  return o2.getStartDate().compareTo(o1.getStartDate());
                });

    BigDecimal sickDays = BigDecimal.ZERO;
    BigDecimal sickDaysWithAUB = BigDecimal.ZERO;
    BigDecimal childSickDays = BigDecimal.ZERO;
    BigDecimal childSickDaysWithAUB = BigDecimal.ZERO;

    for (SickNote sickNote : sickNotes) {
      if (!sickNote.isActive()) {
        continue;
      }

      if (sickNote.getType().equals(SickNoteType.SICK_NOTE_CHILD)) {
        childSickDays =
            childSickDays.add(
                calendarService.getWorkDays(
                    DayLength.FULL, sickNote.getStartDate(), sickNote.getEndDate(), person));

        if (sickNote.isAubPresent()) {
          BigDecimal workDays =
              calendarService.getWorkDays(
                  DayLength.FULL, sickNote.getAubStartDate(), sickNote.getAubEndDate(), person);
          childSickDaysWithAUB = childSickDaysWithAUB.add(workDays);
        }
      } else {
        sickDays =
            sickDays.add(
                calendarService.getWorkDays(
                    DayLength.FULL, sickNote.getStartDate(), sickNote.getEndDate(), person));

        if (sickNote.isAubPresent()) {
          BigDecimal workDays =
              calendarService.getWorkDays(
                  DayLength.FULL, sickNote.getAubStartDate(), sickNote.getAubEndDate(), person);
          sickDaysWithAUB = sickDaysWithAUB.add(workDays);
        }
      }
    }

    model.addAttribute("sickDays", sickDays);
    model.addAttribute("sickDaysWithAUB", sickDaysWithAUB);
    model.addAttribute("childSickDays", childSickDays);
    model.addAttribute("childSickDaysWithAUB", childSickDaysWithAUB);
    model.addAttribute("sickNotes", extendedSickNotes);
  }
  private void fillModel(Model model, List<SickNote> sickNotes, FilterPeriod period) {

    model.addAttribute("today", DateMidnight.now());
    model.addAttribute("from", period.getStartDate());
    model.addAttribute("to", period.getEndDate());
    model.addAttribute("period", period);

    List<Person> persons = personService.getActivePersons();

    List<SickNote> sickNotesOfActivePersons =
        sickNotes
            .stream()
            .filter(sickNote -> persons.contains(sickNote.getPerson()) && sickNote.isActive())
            .collect(Collectors.toList());

    Map<Person, SickDays> sickDays = new HashMap<>();
    Map<Person, SickDays> childSickDays = new HashMap<>();

    for (Person person : persons) {
      sickDays.put(person, new SickDays());
      childSickDays.put(person, new SickDays());
    }

    for (SickNote sickNote : sickNotesOfActivePersons) {
      Person person = sickNote.getPerson();
      BigDecimal workDays =
          calendarService.getWorkDays(
              sickNote.getDayLength(), sickNote.getStartDate(), sickNote.getEndDate(), person);

      if (sickNote.getSickNoteType().isOfCategory(SickNoteCategory.SICK_NOTE_CHILD)) {
        childSickDays.get(person).addDays(SickDays.SickDayType.TOTAL, workDays);

        if (sickNote.isAubPresent()) {
          BigDecimal workDaysWithAUB =
              calendarService.getWorkDays(
                  sickNote.getDayLength(),
                  sickNote.getAubStartDate(),
                  sickNote.getAubEndDate(),
                  person);

          childSickDays.get(person).addDays(SickDays.SickDayType.WITH_AUB, workDaysWithAUB);
        }
      } else {
        sickDays.get(person).addDays(SickDays.SickDayType.TOTAL, workDays);

        if (sickNote.isAubPresent()) {
          BigDecimal workDaysWithAUB =
              calendarService.getWorkDays(
                  sickNote.getDayLength(),
                  sickNote.getAubStartDate(),
                  sickNote.getAubEndDate(),
                  person);

          sickDays.get(person).addDays(SickDays.SickDayType.WITH_AUB, workDaysWithAUB);
        }
      }
    }

    model.addAttribute("sickDays", sickDays);
    model.addAttribute("childSickDays", childSickDays);

    model.addAttribute(PersonConstants.PERSONS_ATTRIBUTE, persons);
  }