Skip to content

Commit

Permalink
Merge 35ad740 into feature/238
Browse files Browse the repository at this point in the history
  • Loading branch information
salesforce-org-metaci[bot] authored Jul 18, 2024
2 parents 34ace95 + 35ad740 commit 3ec8f74
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@
<lightning:layout horizontalAlign="spread" multipleRows="true" class="slds-hide" aura:id="enablementDisabled">
<lightning:layoutItem padding="horizontal-large" size="10">
<div class="slds-illustration slds-illustration_large">
<br /><br />
<img src="/img/chatter/OpenRoad.svg" class="slds-illustration__svg" alt="OpenRoad" />
<div class="slds-m-vertical_medium">
<img src="/img/chatter/OpenRoad.svg" class="slds-illustration__svg" alt="OpenRoad" />
</div>
<div class="slds-text-longform">
<h3 class="slds-text-heading_medium">{!$Label.c.RD2_EnablementDisabledHeader}</h3>
<p>
Expand All @@ -77,7 +78,9 @@

<lightning:layoutItem padding="horizontal-large" class="slds-p-top_large" size="12">
<lightning:layout multipleRows="true">
<h2 class="title slds-text-heading_small">{!$Label.c.RD2_EnablementPrepTitle}</h2>
<lightning:layoutItem size="12">
<h2 class="title slds-text-heading_small">{!$Label.c.RD2_EnablementPrepTitle}</h2>
</lightning:layoutItem>
<lightning:layoutItem class="slds-p-top_small" size="12">
<lightning:formattedRichText class="slds-text-longform"
value="{!$Label.c.RD2_EnablementPrepIntro}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@
helper.handleBatchEvent(component, event, 'v.dryRunBatch');
helper.refreshDryRun(component);
helper.refreshEnable(component);
var status = event.Hp.batchProgress.status;
var dryRunJob = component.find("dryRunJob");
if (["Completed", "Aborted"].includes(status)) {
if(dryRunJob){
helper.setFocus(component, 'dryRunJob');
}
else{
helper.setFocus(component, 'dryRun2Job');
}
}
},
handleDryRunError: function (component, event, helper) {
helper.handleBatchError(component, event, 'dryRun');
Expand All @@ -44,6 +54,10 @@
handleMigrationStatusChange: function (component, event, helper) {
helper.handleBatchEvent(component, event, 'v.migrationBatch');
helper.refreshMigration(component);
var status = event.Hp.batchProgress.status;
if (["Completed", "Aborted"].includes(status)) {
helper.setFocus(component, 'migrationJob');
}
},
handleMigrationError: function (component, event, helper) {
helper.handleBatchError(component, event, 'migration');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,5 +599,22 @@
hideSpinner: function (component, element) {
var spinner = component.find(element);
$A.util.addClass(spinner, 'slds-hide');
}
},
/**
* @description: Autofocus
*/
setFocus: function (component, elementId) {
window.setTimeout(() => {
try { var element = component.find(elementId);
if (element) {
element.getElement().setAttribute('tabindex', '0');
element.getElement().focus();
element.getElement().setAttribute('tabindex', '-1');
}
} catch (error) {
console.error('Error setting focus on element:', error);

}
}, 0);
}
})
25 changes: 24 additions & 1 deletion force-app/main/default/classes/BDI_DataImportService.cls
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,13 @@ global with sharing class BDI_DataImportService {
'Status__c != \'' + BDI_DataImport_API.bdiImported + '\'',
'Id =: dataImportIds'
};
List<String> selectClause = new List<String>{
String.join(listStrDataImportFields, ','),
DATAIMPORT_BATCH_NUMBER_FIELD
};

return new UTIL_Query()
.withSelectFields(listStrDataImportFields)
.withSelectFields(selectClause)
.withFrom(DataImport__c.SObjectType)
.withWhere(whereClauses)
// this ensures consistency for our test code, but also should
Expand Down Expand Up @@ -619,6 +623,25 @@ global with sharing class BDI_DataImportService {

this.listDI = checkRDFields(listDI);

if (apexJobId != null && listDI.size() > 0) {
List<DataImportBatch__c> listBatch = [SELECT Name, Batch_Number__c, Batch_Status__c, Batch_Defaults__c,
Form_Template__c, RequireTotalMatch__c, Expected_Count_of_Gifts__c,
Expected_Total_Batch_Amount__c, Batch_Table_Columns__c, LastModifiedDate
FROM DataImportBatch__c WHERE Id= :listDI[0].NPSP_Data_Import_Batch__c LIMIT 1];
if (listBatch.size() > 0 ) {
GiftBatch giftBatch = new GiftBatch(listBatch[0]);
Boolean firstInstallmentPaid = giftBatch.shouldPayFirstInstallment();

for (DataImport__c dataImport : listDI) {
if(dataImport.Recurring_Donation_Recurring_Type__c != null) {
dataImport.Donation_Date__c = null;
if (!firstInstallmentPaid) {
dataImport.Donation_Amount__c = null;
}
}
}
}
}
// do any performance optimizations to avoid unnecessary code
disableAllOppRollups();

Expand Down
22 changes: 22 additions & 0 deletions force-app/main/default/classes/BDI_DataImport_API.cls
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,28 @@ global with sharing class BDI_DataImport_API {
return apexJobId;
}

global static Id processDataImportRecords(Data_Import_Settings__c diSettings,
List<Id> dataImportIds,
Boolean isDryRun, Id batchId) {
Id apexJobId;
if (dataImportIds != null && dataImportIds.size() > 0) {
// Use configured data import settings if none provided.
if (diSettings == null) {
diSettings = UTIL_CustomSettingsFacade.getDataImportSettings();
}
Savepoint sp = Database.setSavepoint();
try {
BDI_DataImport_BATCH batch = new BDI_DataImport_BATCH(batchId, dataImportIds, new BDI_DataImportService(isDryRun, BDI_DataImportService.getDefaultMappingService()));
apexJobId = Database.executeBatch(batch, integer.valueOf(diSettings.Batch_Size__c));
} catch (Exception ex) {
Database.rollback(sp);
ex.setMessage(System.label.bdiAPISelectedError + ' ' + ex.getMessage());
throw ex;
}
}
return apexJobId;
}

/*******************************************************************************************************
* @description The return result object for each batch that is provided to processDataImportBatches()
*/
Expand Down
9 changes: 8 additions & 1 deletion force-app/main/default/classes/GiftBatchForQueueable.cls
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,17 @@ public inherited sharing class GiftBatchForQueueable {

public void processChunk() {
List<DataImport__c> dataImports = gifts.asDataImports();
BDI_DataImport_API.processDataImportRecords(dataImportSettings, dataImports, false);
List<Id> lstDataImportIds = new List<Id>(new Map<Id, DataImport__c>(dataImports).keySet());
BDI_DataImport_API.processDataImportRecords(dataImportSettings, lstDataImportIds, false);
chunkedIds.remove(0);
}

public void processChunk(Id batchId) {
List<DataImport__c> dataImports = gifts.asDataImports();
List<Id> lstDataImportIds = new List<Id>(new Map<Id, DataImport__c>(dataImports).keySet());
BDI_DataImport_API.processDataImportRecords(dataImportSettings, lstDataImportIds, false, batchId);
chunkedIds.remove(0);
}
public void chunkGiftsThatCanBeProcessed() {
List<SObject> results = giftsSelector.getGiftsReadyToMoveToProcessing(giftBatchId);
if (results.size() > 0) {
Expand Down
4 changes: 3 additions & 1 deletion force-app/main/default/classes/GiftBatchService_TEST.cls
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ private class GiftBatchService_TEST {
Test.stopTest();

// Assert
Integer jobsCount = [SELECT count() FROM AsyncApexJob];
Integer jobsCount = [SELECT count() FROM AsyncApexJob WHERE JobType = 'Queueable'];
System.assertEquals(1, jobsCount, 'Should have enqueued a job');
Integer batchjobsCount = [SELECT count() FROM AsyncApexJob WHERE JobType = 'BatchApex'];
System.assertEquals(1, batchjobsCount, 'Should have one batch apex job');

Integer opportunitiesCount = [SELECT count() FROM Opportunity];
System.assertEquals(10, opportunitiesCount, 'Should have created 10 opportunities');
Expand Down
7 changes: 6 additions & 1 deletion force-app/main/default/classes/GiftEntryProcessorQueue.cls
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public with sharing class GiftEntryProcessorQueue implements Queueable, Database
private final String ABORTED = 'ABORTED';
private GiftBatchForQueueable queueableGiftBatch;
private AsyncApexJobId queueableId;
private GiftBatchId giftBatchId;

@TestVisible
private GiftBatchService giftBatchService {
Expand All @@ -52,6 +53,7 @@ public with sharing class GiftEntryProcessorQueue implements Queueable, Database

public GiftEntryProcessorQueue(GiftBatchForQueueable giftBatchForProcessing) {
this.queueableGiftBatch = giftBatchForProcessing;
this.giftBatchId = giftBatchForProcessing.id();
}

public void execute(QueueableContext queueableContext) {
Expand All @@ -64,7 +66,10 @@ public with sharing class GiftEntryProcessorQueue implements Queueable, Database
queueableGiftBatch.captureElevateBatches();
queueableGiftBatch.updateGiftsInChunk();
queueableGiftBatch.preprocessRecurringGifts();
queueableGiftBatch.processChunk();
queueableGiftBatch.processChunk(giftBatchId.value());
} else {
BDI_DataImport_BATCH batch = new BDI_DataImport_BATCH(giftBatchId.value(), false);
String jobId = Database.executeBatch(batch, Integer.valueOf(batch.diSettings.Batch_Size__c));
}

if (queueableGiftBatch.hasChunksToProcess()) {
Expand Down
8 changes: 4 additions & 4 deletions force-app/main/default/labels/CustomLabels.labels-meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2152,15 +2152,15 @@
<language>en_US</language>
<protected>true</protected>
<shortDescription>Message displayed on a successful migration</shortDescription>
<value>&lt;b&gt;Upgrade process complete!&lt;/b&gt;&lt;br/&gt;
&lt;br/&gt;Before your organization starts using Enhanced Recurring Donations:&lt;br/&gt;
&lt;ul&gt;&lt;li&gt;Turn on workflows, processes, validation rules and triggers that you disabled prior to upgrade.&lt;/li&gt;
<value>&lt;h4&gt;Upgrade process complete!&lt;/h4&gt;
&lt;p&gt;Before your organization starts using Enhanced Recurring Donations:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Turn on workflows, processes, validation rules, and triggers that you disabled prior to upgrade.&lt;/li&gt;
&lt;li&gt;Assign the Enhanced Recurring Donations page layout to all user profiles and remove the old Recurring Donations page layout.&lt;/li&gt;
&lt;li&gt;Assign the NPSP Recurring Donation Lightning record page as the Org Default.&lt;/li&gt;
&lt;li&gt;Assign the RD2_VisualizeScheduleController Apex class to your custom profiles.&lt;/li&gt;
&lt;li&gt;Adjust field-level security for Recurring Donations fields as necessary for your profiles and permission sets.&lt;/li&gt;
&lt;li&gt;Adjust Recurring Donations reports to work with Enhanced Recurring Donations.&lt;/li&gt;
&lt;li&gt;Educate your staff about Enhanced Recurring Donations.&lt;/li&gt;</value>
&lt;li&gt;Educate your staff about Enhanced Recurring Donations.&lt;/li&gt;&lt;/ul&gt;</value>
</labels>
<labels>
<fullName>RD2_EnablementMigrationErrorMessage</fullName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<lightning-layout-item size="8">
<div title={title}>
<span class="slds-truncate"><strong>{title}</strong></span>
<span class="slds-truncate"><h2><strong>{title}</strong></h2></span>
</div>
</lightning-layout-item>

Expand Down

0 comments on commit 3ec8f74

Please sign in to comment.