Skip to content

Commit

Permalink
Merge pull request #7132 from SalesforceFoundation/feature/242__rd2Ba…
Browse files Browse the repository at this point in the history
…tchUpdateBGE

Update Elevate Recurring Gifts When Info Is Updated in Batch Gift Entry
  • Loading branch information
andrewyu-salesforce committed Nov 10, 2022
2 parents d357dcc + 980bcf1 commit 3127098
Show file tree
Hide file tree
Showing 23 changed files with 457 additions and 198 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ robot/Cumulus/results/
datasets/dev_org/test_data.db
*.db
.cci

.sfdx
.sf
# LWC
force-app/main/default/lwc/.eslintrc.json
/node_modules
Expand Down
15 changes: 7 additions & 8 deletions force-app/main/default/labels/CustomLabels.labels-meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5844,6 +5844,13 @@ To check your GAU Allocation settings, go to Donations | GAU Allocations.</value
<shortDescription>Button to process a batch and payments through {0}</shortDescription>
<value>Process Batch &amp; Payments</value>
</labels>
<labels>
<fullName>bgeEditPaymentInformation</fullName>
<language>en_US</language>
<protected>true</protected>
<shortDescription>Warns users to re-enter payment information when editing Elevate-connected gifts</shortDescription>
<value>You can&apos;t edit this Elevate-connected gift until you re-enter the payment information. Select Edit Payment Information.</value>
</labels>
<labels>
<fullName>bgeRetirementWarningBody</fullName>
<categories>Batch Data Entry</categories>
Expand Down Expand Up @@ -9810,14 +9817,6 @@ If preferred, you can disable Gift Entry and instead use older Batch Gift Entry
<shortDescription>Warning about processing batch when authorizations have expired</shortDescription>
<value>One or more card authorizations expired. To ensure these payments are charged when processing the batch, reenter the payment information for donations with an Elevate Payment Status of Expired Authorization.</value>
</labels>
<labels>
<fullName>gePaymentProcessedWarning</fullName>
<categories>Gift Entry</categories>
<language>en_US</language>
<protected>true</protected>
<shortDescription>Warning about editing fields when transaction already processed</shortDescription>
<value>{0} successfully processed the payment. Changing the donor, date, amount, or payment method will result in inconsistent records for the same transaction in {0} and NPSP.</value>
</labels>
<labels>
<fullName>gePaymentProcessError</fullName>
<categories>Gift Entry</categories>
Expand Down
8 changes: 2 additions & 6 deletions force-app/main/default/lwc/geElevateBatch/geElevateBatch.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import apexAddToElevateBatch from '@salesforce/apex/GE_GiftEntryController.addToElevateBatch';
import apexCreateElevateBatch from '@salesforce/apex/GE_GiftEntryController.createElevateBatch';
import apexRemoveFromElevateBatch from '@salesforce/apex/GE_GiftEntryController.removeFromElevateBatch';
import PAYMENT_ELEVATE_ID from '@salesforce/schema/DataImport__c.Payment_Elevate_ID__c';
import RECURRING_DONATION_ID from '@salesforce/schema/DataImport__c.Recurring_Donation_Elevate_Recurring_ID__c';
import PAYMENT_ELEVATE_ELEVATE_BATCH_ID from '@salesforce/schema/DataImport__c.Payment_Elevate_Batch_Id__c';
import GeGatewaySettings from 'c/geGatewaySettings';

class ElevateBatch {

Expand Down Expand Up @@ -43,9 +40,8 @@ class ElevateBatch {
async remove(batchItem) {
return await apexRemoveFromElevateBatch({
batchItem: {
elevateBatchId: batchItem[PAYMENT_ELEVATE_ELEVATE_BATCH_ID.fieldApiName],
id: batchItem[PAYMENT_ELEVATE_ID.fieldApiName] ? batchItem[PAYMENT_ELEVATE_ID.fieldApiName] :
batchItem[RECURRING_DONATION_ID.fieldApiName]
elevateBatchId: batchItem.getFieldValue(PAYMENT_ELEVATE_ELEVATE_BATCH_ID.fieldApiName),
id: batchItem.idToRemove()
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { mockCheckComboboxValidity } from 'lightning/combobox';
import { mockGetIframeReply } from 'c/psElevateTokenHandler';

import donationImported from '@salesforce/schema/DataImport__c.DonationImported__c';
import { DEFAULT_FORM_FIELDS } from '../../utilTemplateBuilder/utilTemplateBuilder';

const mockWrapperWithNoNames = require('../../../../../../tests/__mocks__/apex/data/retrieveDefaultSGERenderWrapper.json');
const getRecordContact1Imported = require('./data/getRecordContact1Imported.json');
Expand Down Expand Up @@ -47,10 +48,38 @@ describe('c-ge-form-renderer', () => {
return config.recordId === DUMMY_BATCH_ID;
});

await flushPromises();

const button = element.shadowRoot.querySelectorAll('[data-id="recurringButton"]');
expect(button).toHaveLength(1);
});

it('make recurring button is disabled when imported gift is loaded into the form', async() => {
retrieveDefaultSGERenderWrapper.mockResolvedValue(mockWrapperWithNoNames);
getAllocationsSettings.mockResolvedValue(allocationsSettingsNoDefaultGAU);
const element = createElement('c-ge-form-renderer', {is: GeFormRenderer });

const DUMMY_BATCH_ID = 'a0T11000007F8WQEA0';

element.batchId = DUMMY_BATCH_ID;
document.body.appendChild(element);
await flushPromises();

// simulate getting back data for DUMMY_CONTACT_ID
getRecord.emit(dataImportBatchRecord, config => {
return config.recordId === DUMMY_BATCH_ID;
});

await flushPromises();

const button = element.shadowRoot.querySelectorAll('[data-id="recurringButton"]');
expect(button).toHaveLength(1);

element.isMakeRecurringButtonDisabled = true;
await flushPromises();

const disabledButton = element.shadowRoot.querySelectorAll('[data-id="recurringButton"]');
expect(disabledButton[0].disabled).toBe(true);
});

it('when a form is saved with a possible validation rule error then processing of the donation should be halted',
Expand Down Expand Up @@ -187,39 +216,6 @@ describe('c-ge-form-renderer', () => {
expect(componentName).toBe('geModalRecurringDonation');
});

it('dispatches an event to display a warning modal when adding schedule for gift matched to existing opportunity', async () => {
retrieveDefaultSGERenderWrapper.mockResolvedValue(mockWrapperWithNoNames);
getAllocationsSettings.mockResolvedValue(allocationsSettingsNoDefaultGAU);
const element = createElement('c-ge-form-renderer', {is: GeFormRenderer });
const DUMMY_BATCH_ID = 'a0T11000007F8WQEA0';

element.batchId = DUMMY_BATCH_ID;

document.body.appendChild(element);

await flushPromises();

// simulate getting back data for DUMMY_CONTACT_ID
getRecord.emit(dataImportBatchRecord, config => {
return config.recordId === DUMMY_BATCH_ID;
});
element.giftInView = {
fields: { [donationImported.fieldApiName]: 'dummy_opportunity_id' }
};

await flushPromises();

const dispatchEventSpy = jest.spyOn(element, 'dispatchEvent');
const button = element.shadowRoot.querySelector('[data-id="recurringButton"]');
button.click();

await flushPromises();

expect(dispatchEventSpy).toHaveBeenCalledTimes(1);
const componentName = dispatchEventSpy.mock.calls[0][0].detail.modalProperties.componentName;
expect(componentName).toBe('geModalPrompt');
});

it('dispatches an event to display a warning modal when adding schedule for gift with net new soft credits', async () => {
retrieveDefaultSGERenderWrapper.mockResolvedValue(mockWrapperWithNoNames);
getAllocationsSettings.mockResolvedValue(allocationsSettingsNoDefaultGAU);
Expand Down Expand Up @@ -256,43 +252,6 @@ describe('c-ge-form-renderer', () => {
const componentName = dispatchEventSpy.mock.calls[0][0].detail.modalProperties.componentName;
expect(componentName).toBe('geModalPrompt');
});

it('dispatches an event to display a warning modal when adding schedule for gift with elevate authorization', async () => {
retrieveDefaultSGERenderWrapper.mockResolvedValue(mockWrapperWithNoNames);
getAllocationsSettings.mockResolvedValue(allocationsSettingsNoDefaultGAU);
const element = createElement('c-ge-form-renderer', {is: GeFormRenderer });
const DUMMY_BATCH_ID = 'a0T11000007F8WQEA0';

element.batchId = DUMMY_BATCH_ID;

document.body.appendChild(element);

await flushPromises();

// simulate getting back data for DUMMY_CONTACT_ID
getRecord.emit(dataImportBatchRecord, config => {
return config.recordId === DUMMY_BATCH_ID;
});
element.giftInView = {
fields: {
'Payment_Method__c': 'Credit Card',
'Donation_Amount__c': '0.01',
'Payment_Status__c': 'AUTHORIZED'
}
};

await flushPromises();

const dispatchEventSpy = jest.spyOn(element, 'dispatchEvent');
const button = element.shadowRoot.querySelector('[data-id="recurringButton"]');
button.click();

await flushPromises();

expect(dispatchEventSpy).toHaveBeenCalledTimes(1);
const componentName = dispatchEventSpy.mock.calls[0][0].detail.modalProperties.componentName;
expect(componentName).toBe('geModalPrompt');
});
});

it('loads a template with four sections', async () => {
Expand Down
44 changes: 24 additions & 20 deletions force-app/main/default/lwc/geFormRenderer/geFormRenderer.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,6 @@
</c-util-illustration>
</div>
</template>
<template if:true={showElevateTransactionWarning}>
<div class="slds-notify slds-notify_alert payment-warn" role="alert">
<span class="slds-assistive-text">{CUSTOM_LABELS.commonWarning}</span>
<span class="slds-icon_container slds-icon-utility-warning slds-m-right_x-small">
<lightning-icon
variant="warning"
icon-name="utility:warning"
size="small">
</lightning-icon>
</span>
<div class="slds-text-heading_small">{elevateTransactionWarning}</div>
</div>
</template>
<template if:true={isSingleGiftEntry}>
<template if:false={isPermissionError}
for:each={sections}
Expand Down Expand Up @@ -169,20 +156,36 @@
</lightning-layout>
</template>
<template if:false={isSingleGiftEntry}>
<template if:false={hasSchedule}>
<lightning-layout horizontal-align="end">
<lightning-layout-item>
<lightning-layout>
<lightning-layout-item size="10">
<template if:true={shouldShowElevateTransactionWarning}>
<div class="slds-notify slds-notify_alert payment-warn" role="alert">
<span class="slds-assistive-text">{CUSTOM_LABELS.commonWarning}</span>
<span class="slds-icon_container slds-icon-utility-warning slds-m-right_x-small">
<lightning-icon
variant="warning"
icon-name="utility:warning"
size="small">
</lightning-icon>
</span>
<div class="slds-text-heading_small" data-id="elevateTrnxWarning">{elevateTransactionWarning}</div>
</div>
</template>
</lightning-layout-item>
<lightning-layout-item class="slds-text-align_right" size="2">
<template if:false={hasSchedule}>
<lightning-button
if:true={isRecurringGiftsEnabled}
icon-name="utility:refresh"
label={CUSTOM_LABELS.geMakeRecurring}
data-id='recurringButton'
onclick={handleMakeGiftRecurring}
disabled={isMakeRecurringButtonDisabled}
>
</lightning-button>
</lightning-layout-item>
</lightning-layout>
</template>
</template>
</lightning-layout-item>
</lightning-layout>
<c-util-expandable-section class='slds-card slds-card_extension slds-m-bottom_large'
id={expandableContainerId}
is-collapsed={isFormCollapsed}
Expand Down Expand Up @@ -243,7 +246,8 @@
onclick={handleSave}
class='slds-m-left_x-small'
disabled={isUpdateActionDisabled}
data-qa-locator={qaLocatorSaveButton}>
data-qa-locator={qaLocatorSaveButton}
data-id="formSaveButton">
</lightning-button>
</div>
</lightning-layout-item>
Expand Down

0 comments on commit 3127098

Please sign in to comment.