Skip to content

Commit

Permalink
Merge pull request #7182 from SalesforceFoundation/feature/W-13635935…
Browse files Browse the repository at this point in the history
…-fix-elevate-validation

Updating Elevate Validation to ignore newly added Payments
  • Loading branch information
daniel-fuller committed Jul 6, 2023
2 parents 1386dd3 + 38e727a commit 3c532e3
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
6 changes: 5 additions & 1 deletion force-app/main/default/classes/PMT_ValidationService.cls
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,11 @@ public inherited sharing class PMT_ValidationService {
}

private void validateElevatePayments(npe01__OppPayment__c payment, npe01__OppPayment__c oldPayment) {
if (String.isBlank(payment.Elevate_Payment_ID__c) || !config.isIntegrationEnabled() || config.hasIntegrationPermissions()) {
if (String.isBlank(payment.Elevate_Payment_ID__c)
|| String.isBlank(oldPayment.Elevate_Payment_ID__c)
|| !config.isIntegrationEnabled()
|| config.hasIntegrationPermissions()
) {
return;
}

Expand Down
35 changes: 35 additions & 0 deletions force-app/main/default/classes/PMT_ValidationService_TEST.cls
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,41 @@ public with sharing class PMT_ValidationService_TEST {
'Cannot update Elevate payment without integrationPermission');
}

@IsTest
private static void verifyAddingPaymentToElevateWillNotRunValidation() {
npe01__OppPayment__c originalPayment = new npe01__OppPayment__c(
Id = UTIL_UnitTestData_TEST.mockId(npe01__OppPayment__c.SObjectType),
npe01__Payment_Amount__c = 10,
npe01__Paid__c = true
);

npe01__OppPayment__c updatedPayment = originalPayment.clone(true);
updatedPayment.Elevate_Payment_ID__c = 'Random';

PMT_ValidationService validationService = new PMT_ValidationService(
new List<npe01__OppPayment__c>{updatedPayment},
new List<npe01__OppPayment__c>{originalPayment},
TDTM_Runnable.Action.BeforeUpdate
);

validationService.isEnforceAccountingDataConsistency = false;
PS_IntegrationServiceConfig_TEST.Stub configStub = new PS_IntegrationServiceConfig_TEST.Stub()
.withIsIntegrationEnabled(true)
.withHasIntegrationPermissions(false);

PMT_ValidationService.config = (PS_IntegrationServiceConfig) Test.createStub(
PS_IntegrationServiceConfig.class,
configStub
);

Test.startTest();
List<ErrorRecord> errorRecords = validationService.validate().getErrors();
Test.stopTest();

System.assertEquals(0, errorRecords.size(),
'Expecting Elevate validation should not run against newly added Elevate payment.');
}

@IsTest
private static void verifyElevateRefundWillNotBeValidate() {
npe01__OppPayment__c originalPayment = new npe01__OppPayment__c(
Expand Down

0 comments on commit 3c532e3

Please sign in to comment.