BP-817 fix wrong delete on bodies
diff --git a/oKBereitschaftsplanungBackend/src/main/java/org/eclipse/openk/sp/controller/planning/ArchiveController.java b/oKBereitschaftsplanungBackend/src/main/java/org/eclipse/openk/sp/controller/planning/ArchiveController.java
index f21b02c..e3ee197 100644
--- a/oKBereitschaftsplanungBackend/src/main/java/org/eclipse/openk/sp/controller/planning/ArchiveController.java
+++ b/oKBereitschaftsplanungBackend/src/main/java/org/eclipse/openk/sp/controller/planning/ArchiveController.java
@@ -238,8 +238,8 @@
 		List<PlanningMsgDto> msgWarning = new ArrayList<>();
 
 		StandbyScheduleFilterDto filter = plan.getFilter();
-		Date startDate = filter.getValidFrom();
-		Date endDate = filter.getValidTo();
+		Date startDate = DateHelper.getStartOfDay(filter.getValidFrom());
+		Date endDate = DateHelper.getEndOfDay(filter.getValidTo());
 
 		msg.add(createMsg(
 				"Importzeitraum ist von " + DateHelper.convertToLocalString(startDate, null) + " bis "
@@ -268,13 +268,23 @@
 			List<StandbyScheduleBody> oldBodyData = plannedDataController.matrixOfPlannedBodysByStatus(groupIds,
 					startDate, endDate, status.getId(), true);
 
-			msg.add(createMsg("Es werden " + oldBodyData.size() + " Bereitschaften in der Planebene gelöscht. ",
+			List<StandbyScheduleBody> oldBodyDataDelete = new ArrayList<>();
+
+			for (StandbyScheduleBody standbyScheduleBody : oldBodyData) {
+				Date indexDate = standbyScheduleBody.getValidFrom();
+				if (!DateHelper.isDateBefore(indexDate, startDate)) {
+					oldBodyDataDelete.add(standbyScheduleBody);
+				}
+			}
+
+			msg.add(createMsg("Es werden " + oldBodyDataDelete.size() + " Bereitschaften in der Planebene gelöscht. ",
 					PlanningMsgDto.INFO, PlanningMsgDto.CSS_INFO));
 
 			// delete
-			standbyScheduleBodyRepository.delete(oldBodyData);
+			standbyScheduleBodyRepository.delete(oldBodyDataDelete);
 
 			oldBodyData.clear();
+			oldBodyDataDelete.clear();
 
 			msg.add(createMsg("Bereitschaften in der Planebene gelöscht. ", PlanningMsgDto.INFO,
 					PlanningMsgDto.CSS_INFO));