From 6fb34fff624f508ef57a3aae05c112c49546a0dd Mon Sep 17 00:00:00 2001
From: Carolin Wimmer <c.wimmer@adito.de>
Date: Wed, 11 Nov 2020 13:22:01 +0100
Subject: [PATCH] =?UTF-8?q?[Projekt:=20Crowd-Development=20/=20Besuch=20vo?=
 =?UTF-8?q?r=20Ort][TicketNr.:=201066742][[aus=20Schmalz]=20Besuchsvorschl?=
 =?UTF-8?q?ags-Logik=20unter=20Ber=C3=BCcksichtigung=20bereits=20erfolgter?=
 =?UTF-8?q?=20Aktivit=C3=A4ten]?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../recordcontainers/jdito/contentProcess.js   | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/entity/VisitRecommendation_entity/recordcontainers/jdito/contentProcess.js b/entity/VisitRecommendation_entity/recordcontainers/jdito/contentProcess.js
index 81f33468c7c..d9bd763c592 100644
--- a/entity/VisitRecommendation_entity/recordcontainers/jdito/contentProcess.js
+++ b/entity/VisitRecommendation_entity/recordcontainers/jdito/contentProcess.js
@@ -192,12 +192,20 @@ if(idValues == false)
         .from("VISITPLANENTRY")
         .where(newWhere("VISITPLANENTRY.CONTACT_ID", tmpData[0])
             .or("VISITPLANENTRY.ORGANISATION_CONTACT_ID", tmpData[0]))
-        .and(newWhere("VISITPLANENTRY.ENTRYDATE", eMath.subInt(vars.get("$sys.today"), datetime.ONE_DAY * 7), SqlBuilder.LESS_OR_EQUAL())
-            .and("VISITPLANENTRY.STATUS", $KeywordRegistry.visitPlanEntryStatus$Visitreportcreated(), SqlBuilder.NOT_EQUAL()))
-            .cell();
         
-        if(!manualRec || visitEntry)
-            recommendationData.push(tmpData);
+       var visitEntryExists = visitEntry.cell();
+       
+       visitEntry = visitEntry.and(newWhere("VISITPLANENTRY.ENTRYDATE", eMath.subInt(vars.get("$sys.today"), datetime.ONE_DAY * 7), SqlBuilder.LESS_OR_EQUAL())
+            .and("VISITPLANENTRY.STATUS", $KeywordRegistry.visitPlanEntryStatus$Visitreportcreated(), SqlBuilder.NOT_EQUAL()))
+            .or("VISITPLANENTRY.STATUS", $KeywordRegistry.visitPlanEntryStatus$Visitreportcreated(), SqlBuilder.EQUAL()).cell()
+       
+       if(!manualRec)
+       {
+           if(!visitEntryExists || visitEntry)
+           {    
+               recommendationData.push(tmpData);
+           }
+       }
     }
 }
 
-- 
GitLab