Skip to content

Commit

Permalink
Merge pull request #6950 from SalesforceFoundation/feature/falconMult…
Browse files Browse the repository at this point in the history
…iCurrencyError

 Work NPSP MultiCurrency Customers on the One-to-One Account Model May Receive Null Pointer Exceptions When Inserting a Contact on Hyperforce Instances
  • Loading branch information
davidmreed authored May 12, 2022
2 parents 7b48b4b + 60b7b17 commit aed15a9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
24 changes: 24 additions & 0 deletions force-app/main/default/classes/RLLP_OppRollup_TEST2.cls
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ public with sharing class RLLP_OppRollup_TEST2 {
npe01__Enable_Opportunity_Contact_Role_Trigger__c = true,
npe01__Opportunity_Contact_Role_Default_role__c = CAO_Constants.OCR_DONOR_ROLE
));

//exercise internal multicurrency helper methods, check currency conversion
decimal d = UTIL_CurrencyConversion.convertFromCorporateUsingStandardRates('USD', 55.00);
d = UTIL_CurrencyConversion.convertAmountUsingStandardRates('USD', 'USD', 55.00);
Expand Down Expand Up @@ -439,6 +440,29 @@ public with sharing class RLLP_OppRollup_TEST2 {

// UNDONE: THERE ARE NO ASSERTS!!!!
}

/*********************************************************************************************************
* @description For new Falcon instances, an aggregate query that returns no results is not returning an empty
* list but is returning a single record where the properties are null. This tests that scenario.
*/
@IsTest
static void getISOCodeWithNullRollupFieldSetDoesNotThrowException() {
if (!UTIL_Currency.getInstance().isMultiCurrencyOrganization()) {
return;
}

List<SObject> opportunitiesWithRollupFieldSets = [SELECT MAX(npo02__CombinedRollupFieldset__c) RollupFieldSet
FROM Opportunity
WHERE Id != NULL];
Exception findCurrencyISOException;
try {
RLLP_OppRollup_UTIL.rcfFindCurrency(opportunitiesWithRollupFieldSets);
} catch (Exception ex) {
findCurrencyISOException = ex;
}
System.assertEquals(null, findCurrencyISOException, 'Retrieving the ISO codes for opportunities with define ' +
'rollup field sets populated should not throw an exception when the rollup field set is null.');
}
/*********************************************************************************************************
* @description Runs testRollupAlls test method for the One to One account processor.
*/
Expand Down
7 changes: 4 additions & 3 deletions force-app/main/default/classes/RLLP_OppRollup_UTIL.cls
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,10 @@ public without sharing class RLLP_OppRollup_UTIL {
//iterate over objects provided to us
for (sobject r : objectList){
//pull Id from rollup field and add to set
string[] rcf = ((string)(r.get('RollupFieldset'))).split(';\\|;',-4);
if(rcf.size() > 1 && rcf[1] != '')
opptysForCurrency.add((Id)rcf[4]);
List<String> rollupFieldSet = ((String)(r.get('RollupFieldset')))?.split(';\\|;',-4);
if (rollupFieldSet?.size() > 1 && rollupFieldSet?.get(1) != '') {
opptysForCurrency.add((Id)rollupFieldSet[4]);
}
}

if (!objectlist.isEmpty()){
Expand Down

0 comments on commit aed15a9

Please sign in to comment.