You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "mbrohl (via GitHub)" <gi...@apache.org> on 2023/03/27 05:58:14 UTC

[GitHub] [ofbiz-framework] mbrohl commented on a diff in pull request #592: Improved: Improvement to createPartyRelationship service (OFBIZ-12765)

mbrohl commented on code in PR #592:
URL: https://github.com/apache/ofbiz-framework/pull/592#discussion_r1148817365


##########
applications/party/groovyScripts/party/PartyServices.groovy:
##########
@@ -427,13 +427,49 @@ def createPartyRelationship() {
                partyIdTo: parameters.partyIdTo,
                roleTypeIdFrom: parameters.roleTypeIdFrom,
                roleTypeIdTo: parameters.roleTypeIdTo)
-        .filterByDate()
         .queryList()
-    if (!partyRels) {
-        GenericValue partyRelationship = makeValue('PartyRelationship', parameters)
-        partyRelationship.create()
+
+    if (partyRels) {
+        // checks for conflicts with existing unlimited valid entries
+        for (GenericValue partyRel : partyRels) {
+            if (!partyRel.thruDate) {
+                if (parameters.fromDate.after(partyRel.fromDate))
+                    return success()
+            }
+        }
+
+        // checks if there are any conflicts with the time periods of the entries
+        if (!parameters.thruDate) {
+            for(GenericValue partyRel : partyRels) {
+                if ((parameters.fromDate.before(partyRel.fromDate)) || (parameters.fromDate.before(partyRel.thruDate))) {
+                    return success()
+                }
+            }
+        } else {
+            EntityCondition partyCond =

Review Comment:
   Hi Deepak, this change is explixitely provided to enhance the business logic on this central point so that code using it does not have to deal with it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ofbiz.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org