Skip to content

Commit

Permalink
Merge pull request #962 from bcgov/Sprint-6-Hot-Fix
Browse files Browse the repository at this point in the history
Reverting ESA -2107
  • Loading branch information
vasanthid23 authored Nov 1, 2023
2 parents 6e9cfd3 + 22f3f57 commit 58ff623
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 19 deletions.
11 changes: 4 additions & 7 deletions force-app/main/default/classes/ESA_cls_caseTriggerHandler.cls
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@ public with sharing class ESA_cls_caseTriggerHandler {
public static void populateTerminationDate(List<Case> newCases, Map<id,Case> oldCaseMap, Map<id,Case> newCaseMap){
for(Case caseObj:newCases){
Boolean isInputsChange = trigger.isUpdate && (oldCaseMap.get(caseObj.id).ESA_Approval_Time__c != newCaseMap.get(caseObj.id).ESA_Approval_Time__c ||
oldCaseMap.get(caseObj.id).ESA_Approval_Time_Unit__c != newCaseMap.get(caseObj.id).ESA_Approval_Time_Unit__c ||
oldCaseMap.get(caseObj.id).Effective_Date__c != newCaseMap.get(caseObj.id).Effective_Date__c);
oldCaseMap.get(caseObj.id).ESA_Approval_Time_Unit__c != newCaseMap.get(caseObj.id).ESA_Approval_Time_Unit__c);
if((trigger.isInsert && caseObj.Termination_Date__c == NULL) || isInputsChange){
Date currentEffectiveDate = caseObj.Effective_Date__c!=NULL ? caseObj.Effective_Date__c : System.Today() ;
if(caseObj.ESA_Approval_Time__c != NULL && caseObj.ESA_Approval_Time_Unit__c != NULL){
caseObj.Termination_Date__c = ESA_cls_constants.CASE_APPROVAL_TIME_UNIT_WEEK.containsIgnoreCase(caseObj.ESA_Approval_Time_Unit__c) ? currentEffectiveDate.addDays((Integer.valueOf(caseObj.ESA_Approval_Time__c)*7)+1)
: ESA_cls_constants.CASE_APPROVAL_TIME_UNIT_MONTH.containsIgnoreCase(caseObj.ESA_Approval_Time_Unit__c) ? currentEffectiveDate.addMonths(Integer.valueOf(caseObj.ESA_Approval_Time__c)).addDays(1)
: ESA_cls_constants.CASE_APPROVAL_TIME_UNIT_DAYS.containsIgnoreCase(caseObj.ESA_Approval_Time_Unit__c) ? currentEffectiveDate.addDays((Integer.valueOf(caseObj.ESA_Approval_Time__c))+1)
: ESA_cls_constants.CASE_APPROVAL_TIME_UNIT_YEARS.containsIgnoreCase(caseObj.ESA_Approval_Time_Unit__c) ? currentEffectiveDate.addYears(Integer.valueOf(caseObj.ESA_Approval_Time__c)).addDays(1)
caseObj.Termination_Date__c = ESA_cls_constants.CASE_APPROVAL_TIME_UNIT_WEEK.containsIgnoreCase(caseObj.ESA_Approval_Time_Unit__c) ? System.Today().addDays((Integer.valueOf(caseObj.ESA_Approval_Time__c)*7)+1)
: ESA_cls_constants.CASE_APPROVAL_TIME_UNIT_MONTH.containsIgnoreCase(caseObj.ESA_Approval_Time_Unit__c) ? System.Today().addMonths(Integer.valueOf(caseObj.ESA_Approval_Time__c)).addDays(1)
: ESA_cls_constants.CASE_APPROVAL_TIME_UNIT_DAYS.containsIgnoreCase(caseObj.ESA_Approval_Time_Unit__c) ? System.Today().addDays((Integer.valueOf(caseObj.ESA_Approval_Time__c))+1)
: NULL;

}
Expand Down
1 change: 0 additions & 1 deletion force-app/main/default/classes/ESA_cls_constants.cls
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ public class ESA_cls_constants {
public static final String CASE_APPROVAL_TIME_UNIT_WEEK = 'Weeks';
public static final String CASE_APPROVAL_TIME_UNIT_MONTH = 'Months';
public static final String CASE_APPROVAL_TIME_UNIT_DAYS = 'Days';
public static final String CASE_APPROVAL_TIME_UNIT_YEARS = 'Years';
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<value>
<fullName>Years</fullName>
<default>false</default>
<isActive>false</isActive>
<label>Years</label>
</value>
</valueSetDefinition>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<fullName>ESA_Approval_Time__c</fullName>
<externalId>false</externalId>
<label>Approval Time</label>
<precision>4</precision>
<precision>3</precision>
<required>false</required>
<scale>0</scale>
<trackFeedHistory>false</trackFeedHistory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,6 @@
<fullName>Weeks</fullName>
<default>false</default>
</values>
<values>
<fullName>Years</fullName>
<default>false</default>
</values>
</picklistValues>
<picklistValues>
<picklist>HIBC_Error_Report_Picklist__c</picklist>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@
<active>true</active>
<description>This validation rule is invoked, When the approval time exceeds the suitable time frame for a given approval time unit.</description>
<errorConditionFormula>OR (
AND(ISPICKVAL(ESA_Approval_Time_Unit__c, &apos;Days&apos;), OR(ESA_Approval_Time__c &gt; 1830 || ESA_Approval_Time__c &lt; 1)),
AND(ISPICKVAL(ESA_Approval_Time_Unit__c, &apos;Weeks&apos;), OR(ESA_Approval_Time__c &gt; 260 || ESA_Approval_Time__c &lt; 1)),
AND(ISPICKVAL(ESA_Approval_Time_Unit__c, &apos;Months&apos;), OR(ESA_Approval_Time__c &gt; 60|| ESA_Approval_Time__c &lt; 1)),
AND(ISPICKVAL(ESA_Approval_Time_Unit__c, &apos;Years&apos;), OR(ESA_Approval_Time__c &gt; 5 || ESA_Approval_Time__c &lt; 1)),
AND(ISPICKVAL(ESA_Approval_Time_Unit__c, &apos;Days&apos;), OR(ESA_Approval_Time__c &gt; 366 || ESA_Approval_Time__c &lt; 1)),
AND(ISPICKVAL(ESA_Approval_Time_Unit__c, &apos;Weeks&apos;), OR(ESA_Approval_Time__c &gt; 52 || ESA_Approval_Time__c &lt; 1)),
AND(ISPICKVAL(ESA_Approval_Time_Unit__c, &apos;Months&apos;), OR(ESA_Approval_Time__c &gt; 12 || ESA_Approval_Time__c &lt; 1)),
AND(ISPICKVAL(ESA_Approval_Time_Unit__c, &apos;Days&apos;)&amp;&amp; ISBLANK(ESA_Approval_Time__c)),
AND(ISPICKVAL(ESA_Approval_Time_Unit__c, &apos;Weeks&apos;)&amp;&amp; ISBLANK(ESA_Approval_Time__c)),
AND(ISPICKVAL(ESA_Approval_Time_Unit__c, &apos;Months&apos;)&amp;&amp; ISBLANK(ESA_Approval_Time__c)),
AND(ISPICKVAL(ESA_Approval_Time_Unit__c, &apos;Years&apos;)&amp;&amp; ISBLANK(ESA_Approval_Time__c)),
AND(ISBLANK(TEXT(ESA_Approval_Time_Unit__c))&amp;&amp; NOT(ISBLANK(ESA_Approval_Time__c))),
CONTAINS(TEXT(ESA_Approval_Time__c), &apos;.&apos;)
)</errorConditionFormula>
<errorDisplayField>ESA_Approval_Time__c</errorDisplayField>
<errorMessage>Cannot be blank/negative/decimal/ Must be a positive whole integer and Termination Date cannot exceed more than 5 Years.</errorMessage>
<errorMessage>Cannot be blank/negative/decimal/ Must be a positive whole integer and Termination Date cannot exceed more than a Year.</errorMessage>
</ValidationRule>

0 comments on commit 58ff623

Please sign in to comment.