Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

W-7780834 BDI Donation Stage Defaults to "Opportunity Stage When Fully Paid" value #6810

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
9740c36
W-7780834 BDI Donation Stage Default
mldyang Jan 13, 2022
5e4004b
W-7780834 pr feedback
mldyang Jan 19, 2022
d9c8b99
Merge 067d1f83366d77a3ef2ee65561b9bc1ed09b90f4 into feature/238__myan…
salesforce-org-metaci[bot] Jan 20, 2022
3fed84b
Merge 4f3695f6ba6ca5fc6d36f3a901ff06bdb968d725 into feature/238__myan…
salesforce-org-metaci[bot] Jan 20, 2022
5a3bdc0
Merge 9faa774e14162eb7963fd1024ba2e9b54f3d2dee into feature/238__myan…
salesforce-org-metaci[bot] Jan 21, 2022
83cedd1
Merge 1f3bd684de27ea59d79c9aba0e180221620458c1 into feature/238__myan…
salesforce-org-metaci[bot] Jan 21, 2022
04b897e
Merge 23b22f382f4e5f33f21eacebc741341178c79594 into feature/238__myan…
salesforce-org-metaci[bot] Jan 25, 2022
8114bda
Merge 915fe5b7b861fddc82f2c947069c3ad30110a0ad into feature/238__myan…
salesforce-org-metaci[bot] Jan 25, 2022
0ca6c37
Merge cad03e1d8e759145137a37abc1fb65e9e1155904 into feature/238__myan…
salesforce-org-metaci[bot] Feb 1, 2022
8d4c8f5
Merge 3948f612afdefbc70d83c885944f915e88ad142a into feature/238__myan…
salesforce-org-metaci[bot] Feb 1, 2022
ed1dfcc
Merge ccc30fabc09ff794c3f6a906bb7b903244014118 into feature/238__myan…
salesforce-org-metaci[bot] Feb 1, 2022
0268ad7
Merge bdac8c032c893333486af8baa143b03aa98331ab into feature/238__myan…
salesforce-org-metaci[bot] Feb 4, 2022
8c4a47d
Merge cdecc0aaca314233f8d785fa1c137e745b6db599 into feature/238__myan…
salesforce-org-metaci[bot] Feb 5, 2022
0dad32d
Merge c5b86ff5dc6c4da7f2a3da42f75ed8299c8b62a7 into feature/238__myan…
salesforce-org-metaci[bot] Feb 6, 2022
88db835
Merge 93605273a3284e6fdb8dbc0baf1d9e9ecd05a547 into feature/238__myan…
salesforce-org-metaci[bot] Feb 7, 2022
8f90ada
Merge d561f09a52cef2c4e196005806a98bd4f24e50cd into feature/238__myan…
salesforce-org-metaci[bot] Feb 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 28 additions & 14 deletions force-app/main/default/classes/BDI_Donations.cls
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,37 @@ public class BDI_Donations {
*/
private Map<Id, npe01__OppPayment__c> paymentsByDataImportId = new Map<Id, npe01__OppPayment__c>();

/*******************************************************************************************************
* @description Contact Settings custom setting
*/
private static npe01__Contacts_And_Orgs_Settings__c contactSettings{
get {
if (contactSettings == null) {
contactSettings = UTIL_CustomSettingsFacade.getContactsSettings();
}
return contactSettings;
}
set;
}
/*******************************************************************************************************
* @description provides a valid Close Won Opportunity Stage
*/
private static String defaultClosedWonStage {
get {
if (defaultClosedWonStage == null){
List<OpportunityStage> stages = [
SELECT MasterLabel
FROM OpportunityStage
WHERE IsActive = true
AND IsWon = true
];
if (stages.size() > 0) {
defaultClosedWonStage = stages[0].MasterLabel;
get {
if (defaultClosedWonStage == null) {
// contact setting value takes priority
if (contactSettings.Payments_Auto_Close_Stage_Name__c != null) {
defaultClosedWonStage = contactSettings.Payments_Auto_Close_Stage_Name__c;
} else {
defaultClosedWonStage = '';
// if no stage name is specified in Contact Setting
// then query for the active isWon value and use that
List<OpportunityStage> stages = [
SELECT MasterLabel
FROM OpportunityStage
WHERE IsActive = TRUE
AND IsWon = TRUE
];
defaultClosedWonStage = stages.size()>0 ? stages[0].MasterLabel : '';
}
}
return defaultClosedWonStage;
Expand Down Expand Up @@ -255,9 +270,8 @@ public class BDI_Donations {
}

// when we mark Payments paid, ensure they will close our Opp.
npe01__Contacts_And_Orgs_Settings__c cs = UTIL_CustomSettingsFacade.getContactsSettings();
if (cs.Payments_Auto_Close_Stage_Name__c == null) {
cs.Payments_Auto_Close_Stage_Name__c = defaultClosedWonStage;
if (contactSettings.Payments_Auto_Close_Stage_Name__c == null) {
contactSettings.Payments_Auto_Close_Stage_Name__c = defaultClosedWonStage;
}

if (elevateDIs.size() > 0) {
Expand Down
45 changes: 45 additions & 0 deletions force-app/main/default/classes/BDI_Donations_TEST.cls
Original file line number Diff line number Diff line change
Expand Up @@ -3092,6 +3092,51 @@ public with sharing class BDI_Donations_TEST {
}
}

/**
* @description If DI.Donation_Stage__c field has a value, use it for donation status, otherwise use the status
* in Contact Setting Payments_Auto_Close_Stage_Name__c
*/
@IsTest
static void donationStageNameTests() {
String diClosedStatus = 'DIClosed';
String contactSettingClosedStatus = 'CSClosed';
// set Contact Setting Closed Status
npe01__Contacts_And_Orgs_Settings__c contactSettings = UTIL_CustomSettingsFacade.getContactsSettings();
contactSettings.Payments_Auto_Close_Stage_Name__c = contactSettingClosedStatus;

// create DI setting to be used for processing
Data_Import_Settings__c dis = UTIL_CustomSettingsFacade.getDataImportSettings();
dis.Field_Mapping_Method__c = BDI_DataImportService.FM_DATA_IMPORT_FIELD_MAPPING;
dis.Default_Data_Import_Field_Mapping_Set__c =
BDI_MappingServiceAdvanced.DEFAULT_DATA_IMPORT_FIELD_MAPPING_SET_NAME;
UTIL_CustomSettingsFacade.setDataImportSettings(dis);

// create a DI to test for Opportunity Stage should be value from Contact Setting
DataImport__c testDI1 = new DataImport__c(Contact1_Firstname__c = 'Jane',
Contact1_Lastname__c = 'Smith',
Contact1_Personal_Email__c = '[email protected]',
Donation_Amount__c = 100,
Donation_Stage__c = null);

// create a DI to test for Opportunity Stage should be value from DI
DataImport__c testDI2 = new DataImport__c(Contact1_Firstname__c = 'John',
Contact1_Lastname__c = 'Doe',
Contact1_Personal_Email__c = '[email protected]',
Donation_Amount__c = 100,
Donation_Stage__c = diClosedStatus);

DataImport__c[] testDIs = new DataImport__c[]{testDI1,testDI2};
insert testDIs;

Test.startTest();
BDI_DataImport_API.processDataImportRecords(dis, testDIs,false);
Test.stopTest();

List<Opportunity> opps = [SELECT Name, Amount, StageName, IsWon FROM Opportunity];
System.assertEquals(2, opps.size());
System.assertEquals(contactSettingClosedStatus, opps[0].StageName); // confirm status is the one in CS
System.assertEquals(diClosedStatus, opps[1].StageName); // confirm status is the one in DI
}
private static Opportunity getOpportunityWithPayments(Id oppId) {
// requery the Opportunity for all fields that we need.
return [SELECT Id, IsWon, IsClosed, Amount, npe01__Amount_Outstanding__c,
Expand Down