diff --git a/src/main/java/ch/zhaw/gartenverwaltung/models/GardenSchedule.java b/src/main/java/ch/zhaw/gartenverwaltung/models/GardenSchedule.java index 6f63f11..34c7237 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/models/GardenSchedule.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/models/GardenSchedule.java @@ -146,8 +146,11 @@ public class GardenSchedule { dayTaskList.add(new ArrayList<>()); final int finalI = i; weekTasks.forEach(task -> { - LocalDate checkDate = task.getNextExecution(); - if (checkDate != null) { + if (task.getNextExecution() == null) { + task.isDone(); + } else { + LocalDate checkDate = task.getNextExecution(); + do { if (date.equals(checkDate) && !date.isAfter(task.getEndDate().orElse(LocalDate.MIN))) { dayTaskList.get(finalI).add(task); @@ -189,6 +192,6 @@ public class GardenSchedule { * @return a sorted coppy of the given Tasklist */ private List getSortedTaskList(List taskList, Comparator comparator) { - return taskList.stream().sorted(comparator).collect(Collectors.toList()); + return taskList.stream().filter(task -> task.getNextExecution() != null).sorted(comparator).collect(Collectors.toList()); } }