-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #951 from bcgov/feature-ALR-134
ALR-134
- Loading branch information
Showing
13 changed files
with
654 additions
and
2 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
Archive/ALR/listview/Case/Requests_Inquiries_Case.listView-meta.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ListView xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<fullName>Requests_Inquiries_Case</fullName> | ||
<columns>CASES.CASE_NUMBER</columns> | ||
<columns>NAME</columns> | ||
<columns>CASES.SUBJECT</columns> | ||
<columns>CASES.STATUS</columns> | ||
<columns>CASES.PRIORITY</columns> | ||
<columns>CASES.CREATED_DATE</columns> | ||
<columns>CORE.USERS.ALIAS</columns> | ||
<filterScope>Everything</filterScope> | ||
<filters> | ||
<field>CASES.RECORDTYPE</field> | ||
<operation>equals</operation> | ||
<value>Case.Requests_Inquiries</value> | ||
</filters> | ||
<label>Requests & Inquiries Case</label> | ||
</ListView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/** | ||
* @Name : AccountContactRelationController | ||
* @Description : This class transfer Account and related records Owners. | ||
* @Author : Keerthana (Accenture) | ||
* @StoryNo : ALR-134 | ||
**/ | ||
|
||
public with sharing class ChangeAccountOwner { | ||
|
||
public class FlowInputs { | ||
@InvocableVariable | ||
public Id newOwnerId; | ||
|
||
@InvocableVariable | ||
public List<Id> accountId; | ||
|
||
@InvocableVariable | ||
public Boolean isBlaChecked; | ||
|
||
@InvocableVariable | ||
public Boolean isPublicChecked; | ||
|
||
@InvocableVariable | ||
public Boolean isCaseChecked; | ||
|
||
@InvocableVariable | ||
public Boolean isInspectionChecked; | ||
} | ||
@InvocableMethod(label='Transfer Account Ownership' description='Transfers ownership of Accounts and related records.') | ||
public static void transferAccountOwnership(List<FlowInputs> inputs) { | ||
try { | ||
FlowInputs input = inputs[0]; | ||
|
||
Id newOwnerId = input.newOwnerId; | ||
List<Id> accountId = input.accountId; | ||
Boolean isBlaChecked = input.isBlaChecked; | ||
Boolean isPublicChecked = input.isPublicChecked; | ||
Boolean isCaseChecked = input.isCaseChecked; | ||
Boolean isInspectionChecked = input.isInspectionChecked; | ||
|
||
|
||
if (newOwnerId == null || accountId.isEmpty()) { | ||
return; | ||
} | ||
|
||
|
||
List<Account> accList = [SELECT Id, OwnerId FROM Account WHERE Id = :accountId]; | ||
List<BusinessLicenseApplication> blaRec; | ||
List<PublicComplaint> pubCompList; | ||
List<Case> caseList; | ||
List<Visit> visitList; | ||
|
||
for(Account acc : accList){ | ||
Id oldOwnerId = acc.OwnerId; | ||
|
||
{ | ||
acc.OwnerId = newOwnerId; | ||
} | ||
|
||
if(isBlaChecked == True){ | ||
blaRec = getRelatedBlaRecords(acc.Id,oldOwnerId); | ||
for(BusinessLicenseApplication bla : blaRec){ | ||
bla.OwnerId = newOwnerId; | ||
} | ||
} | ||
|
||
if(isPublicChecked == True){ | ||
pubCompList = getRelatedPublicCompRecords(acc.Id,oldOwnerId); | ||
for(PublicComplaint pubComp : pubCompList){ | ||
pubComp.OwnerId = newOwnerId; | ||
} | ||
|
||
} | ||
|
||
if(isCaseChecked == True){ | ||
caseList = getRelatedCaseRecords(acc.Id,oldOwnerId); | ||
for(Case caseRec : caseList){ | ||
caseRec.OwnerId = newOwnerId; | ||
} | ||
} | ||
|
||
if(isInspectionChecked == True){ | ||
visitList = getRelatedVisitRecords(acc.Id,oldOwnerId); | ||
for(Visit visit : visitList){ | ||
visit.OwnerId = newOwnerId; | ||
} | ||
|
||
} | ||
} | ||
update blaRec; | ||
update pubCompList; | ||
update caseList; | ||
update visitList; | ||
update accList; | ||
} | ||
catch (Exception e) { | ||
System.debug('Exception occurred: ' + e.getMessage()); | ||
|
||
} | ||
} | ||
|
||
|
||
|
||
public static List<BusinessLicenseApplication> getRelatedBlaRecords(Id accountId, Id oldOwnerId){ | ||
return [Select Id, OwnerId from BusinessLicenseApplication where AccountId =:accountId AND OwnerId=: oldOwnerId AND RecordType.Name='New License' AND Status !='Closed']; | ||
} | ||
|
||
public static List<PublicComplaint> getRelatedPublicCompRecords(Id accountId, Id oldOwnerId){ | ||
return [Select Id, OwnerId from PublicComplaint where AccountId =:accountId AND OwnerId=: oldOwnerId AND Status =: 'Needs Review']; | ||
} | ||
|
||
public static List<Case> getRelatedCaseRecords(Id accountId, Id oldOwnerId){ | ||
return [Select Id, OwnerId from Case where AccountId =:accountId AND OwnerId =: oldOwnerId AND Status != 'Closed']; | ||
} | ||
|
||
public static List<Visit> getRelatedVisitRecords(Id accountId, Id oldOwnerId){ | ||
return [Select Id, OwnerId from Visit where AccountId =:accountId AND OwnerId=: oldOwnerId AND Status != 'Completed']; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>61.0</apiVersion> | ||
<status>Active</status> | ||
</ApexClass> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/** | ||
* @Name : AccountContactRelationController | ||
* @Description : This Test class transfer Account and related records Owners. | ||
* @Author : Keerthana (Accenture) | ||
* @StoryNo : ALR-134 | ||
**/ | ||
|
||
@isTest | ||
private class ChangeAccountOwnerTest { | ||
|
||
@isTest | ||
static void testTransferAccountOwnership() { | ||
|
||
|
||
Id adminId =[Select Id From Profile where Name='System Administrator'].Id; | ||
|
||
User oldUser = new User( | ||
FirstName = 'oldUser', | ||
LastName = 'User', | ||
Username = '[email protected]', | ||
Email = '[email protected]', | ||
Alias = 'ouser', | ||
ProfileId = adminId, | ||
CommunityNickname = 'old987user', | ||
TimeZoneSidKey = 'GMT', | ||
LocaleSidKey = 'en_US', | ||
EmailEncodingKey = 'UTF-8', | ||
LanguageLocaleKey = 'en_US' | ||
); | ||
insert oldUser; | ||
|
||
|
||
User newUser = new User( | ||
FirstName = 'Test', | ||
LastName = 'User1', | ||
Username = '[email protected]', | ||
Email = '[email protected]', | ||
Alias = 'tuser', | ||
ProfileId = adminId, | ||
CommunityNickname = 'test123user', | ||
TimeZoneSidKey = 'GMT', | ||
LocaleSidKey = 'en_US', | ||
EmailEncodingKey = 'UTF-8', | ||
LanguageLocaleKey = 'en_US' | ||
); | ||
insert newUser; | ||
|
||
Schema.Location loc = new Schema.Location(); | ||
loc.Name = 'U.S. 101N'; | ||
loc.Longitude = 28.635308; | ||
loc.Latitude = 28.635308; | ||
insert loc; | ||
|
||
RegulatoryAuthorizationType regAuth = TestDataFactory.createRegAuth('Mental Helath', 'License', 'MH', 1, 2, 3, 4, true); | ||
Account acc = TestDataFactory.createResidence('Residence', 'Test Residence', regAuth.Id, true); | ||
|
||
|
||
Case caseRec = new Case(AccountId=acc.Id, Status='Under Inspection',OwnerId=oldUser.Id); | ||
insert caseRec; | ||
|
||
BusinessLicenseApplication bla = TestDataFactory.createRenewalBla(acc.LicenseType__c, acc.Id, true); | ||
|
||
ChangeAccountOwner.FlowInputs flowInputs = new ChangeAccountOwner.FlowInputs(); | ||
flowInputs.newOwnerId = newUser.Id; | ||
flowInputs.accountId = new List<Id>{ acc.Id }; | ||
flowInputs.isBlaChecked = true; | ||
flowInputs.isPublicChecked = true; | ||
flowInputs.isCaseChecked = true; | ||
flowInputs.isInspectionChecked = true; | ||
|
||
List<ChangeAccountOwner.FlowInputs> inputs = new List<ChangeAccountOwner.FlowInputs>{ flowInputs }; | ||
|
||
Test.startTest(); | ||
ChangeAccountOwner.transferAccountOwnership(inputs); | ||
Test.stopTest(); | ||
|
||
List<Account> updatedAccount = [SELECT Id FROM Account]; | ||
Assert.isNotNull(updatedAccount.size()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>61.0</apiVersion> | ||
<status>Active</status> | ||
</ApexClass> |
Oops, something went wrong.