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-10874727] - Elevate NonElevate Filter #6988

Merged
merged 26 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c2937b1
Elevate NonElevate Filter
gerardorodriguezsf Jun 17, 2022
c26a46d
Merge 611c24908801e16d299e9ecefa8fed44ec332718 into feature/240__filt…
salesforce-org-metaci[bot] Jun 17, 2022
ada2c3d
Merge branch 'feature/240' into feature/240__filter_rd_elevate_nonele…
gerardorodriguezsf Jun 21, 2022
ad1c544
Fixed Merge Conflicts
gerardorodriguezsf Jun 21, 2022
1d5f650
Victor feedback Updates
gerardorodriguezsf Jun 21, 2022
173486e
Merge branch 'feature/240__filter_rd_elevate_nonelevate' of https://g…
gerardorodriguezsf Jun 21, 2022
825f81c
Merge branch 'feature/240' into feature/240__filter_rd_elevate_nonele…
gerardorodriguezsf Jun 21, 2022
df79fd5
Merge branch 'feature/240' into feature/240__filter_rd_elevate_nonele…
gerardorodriguezsf Jun 21, 2022
f58bb6d
Merge 521c3d222b6ec5dfea7c04d40ba5780757b45347 into feature/240__filt…
salesforce-org-metaci[bot] Jun 22, 2022
aee3e65
fixed indentations 4spaces
gerardorodriguezsf Jun 22, 2022
dad969a
Merge fb220dfc250920165d1cca3e4482ba2c43be72f0 into feature/240__filt…
salesforce-org-metaci[bot] Jun 22, 2022
f3a4090
fixed indentation issues
gerardorodriguezsf Jun 23, 2022
43a1615
Merge branch 'feature/240' into feature/240__filter_rd_elevate_nonele…
gerardorodriguezsf Jun 23, 2022
2083620
fixed indentation issues
gerardorodriguezsf Jun 23, 2022
e6b38fa
Merge c24fed424ca3be2b1041a8adc50f34bc695ec740 into feature/240__filt…
salesforce-org-metaci[bot] Jun 23, 2022
f3403da
Merge branch 'feature/240' into feature/240__filter_rd_elevate_nonele…
gerardorodriguezsf Jun 24, 2022
c0e0bc9
removed type condition
gerardorodriguezsf Jun 24, 2022
0634348
fix build issue
gerardorodriguezsf Jun 24, 2022
c0934d2
Merge ff7d8fd64047bacdf0d6a64040ea1327bb8b2b30 into feature/240__filt…
salesforce-org-metaci[bot] Jun 25, 2022
860566f
Merge branch 'feature/240' into feature/240__filter_rd_elevate_nonele…
gerardorodriguezsf Jun 27, 2022
77d9ec4
fix build issue
gerardorodriguezsf Jun 27, 2022
2259804
fixed build issues
gerardorodriguezsf Jun 27, 2022
b2dc16b
Merge 38b63d9d22b27e3c6bc6f90e4d1f53945d116f1f into feature/240__filt…
salesforce-org-metaci[bot] Jun 27, 2022
1194a29
Fixed string query
gerardorodriguezsf Jun 28, 2022
71c92dc
Merge branch 'feature/240' into feature/240__filter_rd_elevate_nonele…
gerardorodriguezsf Jun 29, 2022
d7a877d
fixed merge conflicts issue
gerardorodriguezsf Jun 29, 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
50 changes: 31 additions & 19 deletions force-app/main/default/classes/RD2_ERecurringDonationsSelector.cls
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
*/
public inherited sharing class RD2_ERecurringDonationsSelector {

private final String ELEVATE_RD = 'Elevate Recurring Donations';
private final String NONELEVATE_RD = 'Non-Elevate Recurring Donations';
gerardorodriguezsf marked this conversation as resolved.
Show resolved Hide resolved

@TestVisible
private Id currentContactId {
get {
Expand All @@ -50,29 +53,38 @@ public inherited sharing class RD2_ERecurringDonationsSelector {
* @description Returns the Recurring Donation records related to the Experience Site user.
* @return List<npe03__Recurring_Donation__c>
*/
public List<npe03__Recurring_Donation__c> getRecurringDonations() {
public List<npe03__Recurring_Donation__c> getRecurringDonations(String elevateFilter) {
gerardorodriguezsf marked this conversation as resolved.
Show resolved Hide resolved

Id currentContactId = this.currentContactId;
List<npe03__Recurring_Donation__c> recurringDonations = new List<npe03__Recurring_Donation__c>();
if(currentContactId != NULL) {
recurringDonations = [ SELECT npe03__Amount__c,
npe03__Installment_Period__c,
InstallmentFrequency__c,
Day_of_Month__c,
Status__c,
CommitmentId__c,
PaymentMethod__c,
CardLast4__c,
CardExpirationYear__c,
CardExpirationMonth__c,
ACH_Last_4__c,
npe03__Last_Payment_Date__c,
npe03__Next_Payment_Date__c
FROM npe03__Recurring_Donation__c
WHERE npe03__Contact__c = :currentContactId
AND RecurringType__c IN (:RD2_Constants.RECURRING_TYPE_OPEN, :RD2_Constants.RECURRING_TYPE_FIXED)
WITH SECURITY_ENFORCED
ORDER BY npe03__Next_Payment_Date__c DESC NULLS LAST];
String queryString = 'SELECT npe03__Amount__c, '
gerardorodriguezsf marked this conversation as resolved.
Show resolved Hide resolved
+ 'npe03__Installment_Period__c, '
+ 'InstallmentFrequency__c, '
+ 'Day_of_Month__c, '
+ 'Status__c, '
+ 'CommitmentId__c, '
+ 'PaymentMethod__c, '
+ 'CardLast4__c, '
+ 'CardExpirationYear__c, '
+ 'CardExpirationMonth__c, '
+ 'ACH_Last_4__c, '
+ 'npe03__Last_Payment_Date__c, '
+ 'npe03__Next_Payment_Date__c '
+ 'FROM npe03__Recurring_Donation__c '
+ 'WHERE npe03__Contact__c = \'' + currentContactId + '\' '
+ 'AND RecurringType__c IN (\''+RD2_Constants.RECURRING_TYPE_OPEN+'\',\''+RD2_Constants.RECURRING_TYPE_FIXED+'\') ';

if(elevateFilter == ELEVATE_RD) {
queryString += 'AND CommitmentId__c != NULL ';
} else if (elevateFilter == NONELEVATE_RD) {
queryString += 'AND CommitmentId__c = NULL ';
}

queryString += 'WITH SECURITY_ENFORCED ';
queryString += 'ORDER BY npe03__Next_Payment_Date__c DESC NULLS LAST';

recurringDonations = Database.query(queryString);
}

return recurringDonations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,17 @@
public class RD2_ERecurringDonationsSelector_TEST {

private static final TEST_SObjectGateway.RecurringDonationGateway rdGateway = new TEST_SObjectGateway.RecurringDonationGateway();
private static final String ALL_RD = 'All Recurring Donations';
private static final String ELEVATE_RD = 'Elevate Recurring Donations';
private static final String NONELEVATE_RD = 'Non-Elevate Recurring Donations';

/**
* @author Salesforce.org
* @date 2022
* @description Method to test that the results are returned correctly
*/
@IsTest
private static void testGetRecurringDonations() {
private static void testGetRecurringDonationsAll() {

RD2_EnablementService_TEST.setRecurringDonations2Enabled();

Expand All @@ -65,7 +68,72 @@ public class RD2_ERecurringDonationsSelector_TEST {
Test.startTest();
RD2_ERecurringDonationsSelector selector = new RD2_ERecurringDonationsSelector();
selector.currentContactId = con.Id;
List<npe03__Recurring_Donation__c> result = selector.getRecurringDonations();
List<npe03__Recurring_Donation__c> result = selector.getRecurringDonations(RD2_ERecurringDonationsSelector_TEST.ALL_RD);
Test.stopTest();

System.assertNotEquals(null, result, 'Recurring Donations should not be null');
}

/**
* @author Salesforce.org
* @date 2022
* @description Method to test that the results are returned correctly
*/
@IsTest
private static void testGetRecurringDonationsElevate() {

RD2_EnablementService_TEST.setRecurringDonations2Enabled();

Contact con = UTIL_UnitTestData_TEST.getContact();
insert con;

npe03__Recurring_Donation__c rDonation01 = TEST_RecurringDonationBuilder.constructEnhancedBuilder()
.withContact(con.Id)
.withAmount(100)
.withDefaultValues()
.withInstallmentPeriodMonthly()
.withDayOfMonth('23')
.withInstallmentFrequency(1)
.build();
rDonation01.CommitmentId__c = '123';
insert rDonation01;

Test.startTest();
RD2_ERecurringDonationsSelector selector = new RD2_ERecurringDonationsSelector();
selector.currentContactId = con.Id;
List<npe03__Recurring_Donation__c> result = selector.getRecurringDonations(RD2_ERecurringDonationsSelector_TEST.ELEVATE_RD);
Test.stopTest();

System.assertNotEquals(null, result, 'Recurring Donations should not be null');
}

/**
* @author Salesforce.org
* @date 2022
* @description Method to test that the results are returned correctly
*/
@IsTest
private static void testGetRecurringDonationsNonElevate() {

RD2_EnablementService_TEST.setRecurringDonations2Enabled();

Contact con = UTIL_UnitTestData_TEST.getContact();
insert con;

npe03__Recurring_Donation__c rDonation01 = TEST_RecurringDonationBuilder.constructEnhancedBuilder()
.withContact(con.Id)
.withAmount(100)
.withDefaultValues()
.withInstallmentPeriodMonthly()
.withDayOfMonth('23')
.withInstallmentFrequency(1)
.build();
insert rDonation01;

Test.startTest();
RD2_ERecurringDonationsSelector selector = new RD2_ERecurringDonationsSelector();
selector.currentContactId = con.Id;
List<npe03__Recurring_Donation__c> result = selector.getRecurringDonations(RD2_ERecurringDonationsSelector_TEST.NONELEVATE_RD);
Test.stopTest();

System.assertNotEquals(null, result, 'Recurring Donations should not be null');
Expand Down
10 changes: 5 additions & 5 deletions force-app/main/default/classes/RD2_ETableController.cls
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ public with sharing class RD2_ETableController {
* @description returns a list of processed recurring donations
* @return List<TableView> List of processed recurring donation records
*/
@AuraEnabled
public static List<TableView> retrieveTableView() {
@AuraEnabled(cacheable=true)
public static List<TableView> retrieveTableView(String elevateFilter) {
try {
return controller.getTableViews();
return controller.getTableViews(elevateFilter);
} catch (Exception ex) {
throw new AuraHandledException(ex.getMessage());
}
Expand Down Expand Up @@ -128,11 +128,11 @@ public with sharing class RD2_ETableController {
* @description method to return Recurring Donation list.
* @return List<RD2_ETableController.TableView> returns processed Recurring Donations.
*/
private List<RD2_ETableController.TableView> getTableViews() {
private List<RD2_ETableController.TableView> getTableViews(String elevateFilter) {
List<RD2_ETableController.TableView> recurringDonations = new List<RD2_ETableController.TableView>();
if(RD2_EnablementService.isRecurringDonations2Enabled) {
if(controller.hasAccessToRecurringDonation()) {
for(npe03__Recurring_Donation__c recDonation : selector.getRecurringDonations()) {
for(npe03__Recurring_Donation__c recDonation : selector.getRecurringDonations(elevateFilter)) {
recurringDonations.add( new RD2_ETableController.TableView( recDonation,
controller.getFrequency(recDonation),
controller.getStatus(recDonation),
Expand Down
13 changes: 8 additions & 5 deletions force-app/main/default/classes/RD2_ETableController_TEST.cls
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
public class RD2_ETableController_TEST {

private static final TEST_SObjectGateway.RecurringDonationGateway rdGateway = new TEST_SObjectGateway.RecurringDonationGateway();

private static final String ALL_RD = 'All Recurring Donations';

/**
* @author Salesforce.org
* @date 2022
Expand All @@ -57,7 +58,7 @@ public class RD2_ETableController_TEST {
.withAmount(100)
.withDefaultValues()
.withInstallmentPeriodMonthly()
.withDayOfMonth('23')
.withDayOfMonth('21')
.withInstallmentFrequency(1)
.build();

Expand All @@ -66,7 +67,7 @@ public class RD2_ETableController_TEST {
.withAmount(100)
.withDefaultValues()
.withInstallmentPeriodYearly()
.withDayOfMonth('23')
.withDayOfMonth('22')
.withInstallmentFrequency(1)
.build();

Expand All @@ -84,8 +85,9 @@ public class RD2_ETableController_TEST {
.withAmount(100)
.withDefaultValues()
.withInstallmentPeriodMonthly()
.withDayOfMonth('23')
.withDayOfMonth('24')
.withInstallmentFrequency(2)
.withStatus(RD2_Constants.STATUS_PAUSED)
.build();

npe03__Recurring_Donation__c rDonation05 = TEST_RecurringDonationBuilder.constructEnhancedBuilder()
Expand All @@ -95,6 +97,7 @@ public class RD2_ETableController_TEST {
.withInstallmentPeriodYearly()
.withDayOfMonth('23')
.withInstallmentFrequency(2)
.withStatus(RD2_Constants.STATUS_CLOSED)
.build();

npe03__Recurring_Donation__c rDonation06 = TEST_RecurringDonationBuilder.constructEnhancedBuilder()
Expand All @@ -111,7 +114,7 @@ public class RD2_ETableController_TEST {
RD2_ETableController.selector = (RD2_ERecurringDonationsSelector) Test.createStub(RD2_ERecurringDonationsSelector.class, mock);

Test.startTest();
List<RD2_ETableController.TableView> result = RD2_ETableController.retrieveTableView();
List<RD2_ETableController.TableView> result = RD2_ETableController.retrieveTableView(RD2_ETableController_TEST.ALL_RD);
Test.stopTest();

System.assertNotEquals(null, result, 'Recurring Donations should not be null');
gerardorodriguezsf marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export default class RecurringDonationTable extends LightningElement {
}

getRecurringDonationFields() {
retrieveTableView()
retrieveTableView({ elevateFilter : this.donationTypeFilter })
.then((data) => {
if (data) {
this.data = data.map((el) => {
Expand Down