Skip to content
Snippets Groups Projects
Commit 40a352dd authored by Benjamin Ulrich's avatar Benjamin Ulrich :speech_balloon: Committed by Sebastian Pongratz
Browse files

[Projekt: xRM-Sales][TicketNr.: 1086776][Zuordnung Betreuer - Status in...

[Projekt: xRM-Sales][TicketNr.: 1086776][Zuordnung Betreuer - Status in Betreuer wird von zur Prüfung auf aktiv gesetzt, wenn bei verantwortlcihen was geändert und gebiet neu gesetzt wird]
parent 82159be7
No related branches found
No related tags found
No related merge requests found
......@@ -139,15 +139,23 @@ DistrictUtils.assignDistrict = function (pDistrictId, pAppliedFilter, pContactId
.where("DISTRICTRESPONSIBLE.DISTRICT_ID", pDistrictId)
.table();
var arrOrgContactIds = new SqlBuilder()
.selectDistinct("CONTACT.CONTACTID")
var arrOrgContactIdsAndStatus = new SqlBuilder()
.selectDistinct("CONTACT.CONTACTID, CONTACT.STATUS")
.from("ORGANISATION")
.join("CONTACT", newWhere("ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID").and("CONTACT.PERSON_ID is null"))
.leftJoin("ADDRESS", "ADDRESS.ADDRESSID = CONTACT.ADDRESS_ID")
.leftJoin("CLASSIFICATIONSTORAGE", "CLASSIFICATIONSTORAGE.OBJECT_ROWID = CONTACT.CONTACTID")
.whereIfSet(sqlCondition)
.andIfSet("CONTACT.CONTACTID", pContactId)
.arrayColumn();
.table();
var arrOrgContactIds = [];
var orgContactStatusObj = {};
for (let i = 0; i < arrOrgContactIdsAndStatus.length; i++)
{
arrOrgContactIds.push(arrOrgContactIdsAndStatus[i][0]);
orgContactStatusObj[arrOrgContactIdsAndStatus[i][0]] = arrOrgContactIdsAndStatus[i][1];
}
var colsInsert = [
"DISTRICTCONTACTID",
......@@ -190,6 +198,7 @@ DistrictUtils.assignDistrict = function (pDistrictId, pAppliedFilter, pContactId
.from("DISTRICTCONTACT")
.where("DISTRICTCONTACT.DISTRICT_ID", pDistrictId)
.and("DISTRICTCONTACT.ADVISER_CONTACT_ID", resContactId)
.and("DISTRICTCONTACT.ORIGIN", $KeywordRegistry.districtOrigin$auto())
.table();
}
......@@ -206,6 +215,8 @@ DistrictUtils.assignDistrict = function (pDistrictId, pAppliedFilter, pContactId
for (var i = 0; i < arrOrgContactIds.length; i++)
{
resStatus = orgContactStatusObj[arrOrgContactIds[i]] == $KeywordRegistry.contactStatus$inactive() ? $KeywordRegistry.contactStatus$inReview() : resStatus;//set to in review if org is inactive
//insert new assignments
var valsInsert = [
util.getNewUUID(),
......@@ -225,19 +236,18 @@ DistrictUtils.assignDistrict = function (pDistrictId, pAppliedFilter, pContactId
//association = DISTRICT_ID + CONTACT_ID + ADVISER_CONTACT_ID
var existingEntryAssoz = pDistrictId + arrOrgContactIds[i] + arrResponsibleIds[j][0];
var checkexistingEntry = existingEnriesObject[existingEntryAssoz]; //existingEnriesObject[pDistrictId + arrOrgContactIds[i] + arrResponsibleIds[j][0]]
//check associative Array
if (checkexistingEntry == undefined) { //insert missing entries
newAssigned++
insertArray.push(["DISTRICTCONTACT", colsInsert, null, valsInsert]);
}
else if (checkexistingEntry != undefined &&
else if (checkexistingEntry != undefined && checkexistingEntry["status"] != $KeywordRegistry.contactStatus$inReview() &&
(checkexistingEntry["status"] != resStatus || checkexistingEntry["role"] != resRole
|| checkexistingEntry["validFrom"] != resValidFrom || checkexistingEntry["validUntil"] != resValidUntil
|| checkexistingEntry["visitFrequency"] != resVisitFrequency))// value changed -> update this dataset
{
updated++;
updateStatements.push(newWhere("DISTRICTCONTACT.DISTRICTCONTACTID", checkexistingEntry["districtContactId"]).buildUpdateStatement({
"ADVISER_ROLE": resRole,
"STATUS": resStatus,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment