From 1ff3fb0fae3276697a0ccad8b3decacb27fff57f Mon Sep 17 00:00:00 2001
From: enzigma-pratishtha-upadhyay
Date: Fri, 29 Mar 2024 14:13:33 +0530
Subject: [PATCH 01/17] Commit -- BDI_DataImport_BATCH is queued on GE
Processor Queue
Executing the BDI_DataImport_BATCH batch on GiftEntryProcessorQueue to update the NPSP Data Import batch record fields.
---
force-app/main/default/classes/GiftBatchForQueueable.cls | 3 ++-
force-app/main/default/classes/GiftEntryProcessorQueue.cls | 4 ++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/force-app/main/default/classes/GiftBatchForQueueable.cls b/force-app/main/default/classes/GiftBatchForQueueable.cls
index 02055ffab66..a36b748373f 100644
--- a/force-app/main/default/classes/GiftBatchForQueueable.cls
+++ b/force-app/main/default/classes/GiftBatchForQueueable.cls
@@ -149,7 +149,8 @@ public inherited sharing class GiftBatchForQueueable {
public void processChunk() {
List dataImports = gifts.asDataImports();
- BDI_DataImport_API.processDataImportRecords(dataImportSettings, dataImports, false);
+ List lstDataImportIds = new List(new Map(dataImports).keySet());
+ BDI_DataImport_API.processDataImportRecords(dataImportSettings, lstDataImportIds, false);
chunkedIds.remove(0);
}
diff --git a/force-app/main/default/classes/GiftEntryProcessorQueue.cls b/force-app/main/default/classes/GiftEntryProcessorQueue.cls
index c470c44ae3d..310c09550be 100644
--- a/force-app/main/default/classes/GiftEntryProcessorQueue.cls
+++ b/force-app/main/default/classes/GiftEntryProcessorQueue.cls
@@ -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 {
@@ -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) {
@@ -67,6 +69,8 @@ public with sharing class GiftEntryProcessorQueue implements Queueable, Database
queueableGiftBatch.processChunk();
}
+ 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()) {
chainNextQueueable();
} else {
From 7d9107c27c36c7d6ac458ae49fa144b2ed1f091a Mon Sep 17 00:00:00 2001
From: enzigma-pratishtha-upadhyay
Date: Thu, 4 Apr 2024 17:52:22 +0530
Subject: [PATCH 02/17] commit -- Gift Entry - process - batch- fixes
Removed BDI_DataImport_BATCH batch call from GiftEntryProcessorQueue and added overloaded processChunk method.
---
.../default/classes/BDI_DataImport_API.cls | 22 +++++++++++++++++++
.../default/classes/GiftBatchForQueueable.cls | 6 +++++
.../classes/GiftEntryProcessorQueue.cls | 4 +---
3 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/force-app/main/default/classes/BDI_DataImport_API.cls b/force-app/main/default/classes/BDI_DataImport_API.cls
index 3435df5d6c4..e373744b0d3 100644
--- a/force-app/main/default/classes/BDI_DataImport_API.cls
+++ b/force-app/main/default/classes/BDI_DataImport_API.cls
@@ -158,6 +158,28 @@ global with sharing class BDI_DataImport_API {
return apexJobId;
}
+ global static Id processDataImportRecords(Data_Import_Settings__c diSettings,
+ List 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()
*/
diff --git a/force-app/main/default/classes/GiftBatchForQueueable.cls b/force-app/main/default/classes/GiftBatchForQueueable.cls
index a36b748373f..d11d68bc266 100644
--- a/force-app/main/default/classes/GiftBatchForQueueable.cls
+++ b/force-app/main/default/classes/GiftBatchForQueueable.cls
@@ -154,6 +154,12 @@ public inherited sharing class GiftBatchForQueueable {
chunkedIds.remove(0);
}
+ public void processChunk(Id batchId) {
+ List dataImports = gifts.asDataImports();
+ List lstDataImportIds = new List(new Map(dataImports).keySet());
+ BDI_DataImport_API.processDataImportRecords(dataImportSettings, lstDataImportIds, false, batchId);
+ chunkedIds.remove(0);
+ }
public void chunkGiftsThatCanBeProcessed() {
List results = giftsSelector.getGiftsReadyToMoveToProcessing(giftBatchId);
if (results.size() > 0) {
diff --git a/force-app/main/default/classes/GiftEntryProcessorQueue.cls b/force-app/main/default/classes/GiftEntryProcessorQueue.cls
index 310c09550be..26530e96d77 100644
--- a/force-app/main/default/classes/GiftEntryProcessorQueue.cls
+++ b/force-app/main/default/classes/GiftEntryProcessorQueue.cls
@@ -66,11 +66,9 @@ public with sharing class GiftEntryProcessorQueue implements Queueable, Database
queueableGiftBatch.captureElevateBatches();
queueableGiftBatch.updateGiftsInChunk();
queueableGiftBatch.preprocessRecurringGifts();
- queueableGiftBatch.processChunk();
+ queueableGiftBatch.processChunk(giftBatchId.value());
}
- 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()) {
chainNextQueueable();
} else {
From c79af4e713bf986e539f52d17c63c5848c5db61e Mon Sep 17 00:00:00 2001
From: enzigma-pratishtha-upadhyay
Date: Mon, 8 Apr 2024 18:37:01 +0530
Subject: [PATCH 03/17] Update BDI_DataImportService.cls
---
force-app/main/default/classes/BDI_DataImportService.cls | 3 +++
1 file changed, 3 insertions(+)
diff --git a/force-app/main/default/classes/BDI_DataImportService.cls b/force-app/main/default/classes/BDI_DataImportService.cls
index a7b46310d30..82370e60c70 100644
--- a/force-app/main/default/classes/BDI_DataImportService.cls
+++ b/force-app/main/default/classes/BDI_DataImportService.cls
@@ -974,6 +974,9 @@ global with sharing class BDI_DataImportService {
Map mapS = Schema.SObjectType.DataImport__c.fields.getMap();
listStrDataImportFields = new List();
listStrDataImportFields.addAll(mapS.keySet());
+ listStrDataImportFields.add('NPSP_Data_Import_Batch__r.Name');
+ listStrDataImportFields.add('NPSP_Data_Import_Batch__r.Batch_Number__c');
+
}
return listStrDataImportFields;
}
From 743fd0893f562b973eab617d88c6a628e0b8d266 Mon Sep 17 00:00:00 2001
From: enzigma-pratishtha-upadhyay
Date: Mon, 8 Apr 2024 20:53:24 +0530
Subject: [PATCH 04/17] Revert "Update BDI_DataImportService.cls"
This reverts commit c79af4e713bf986e539f52d17c63c5848c5db61e.
---
force-app/main/default/classes/BDI_DataImportService.cls | 3 ---
1 file changed, 3 deletions(-)
diff --git a/force-app/main/default/classes/BDI_DataImportService.cls b/force-app/main/default/classes/BDI_DataImportService.cls
index 82370e60c70..a7b46310d30 100644
--- a/force-app/main/default/classes/BDI_DataImportService.cls
+++ b/force-app/main/default/classes/BDI_DataImportService.cls
@@ -974,9 +974,6 @@ global with sharing class BDI_DataImportService {
Map mapS = Schema.SObjectType.DataImport__c.fields.getMap();
listStrDataImportFields = new List();
listStrDataImportFields.addAll(mapS.keySet());
- listStrDataImportFields.add('NPSP_Data_Import_Batch__r.Name');
- listStrDataImportFields.add('NPSP_Data_Import_Batch__r.Batch_Number__c');
-
}
return listStrDataImportFields;
}
From 4585e8d78d6e731502126bafd3beb7846e09b623 Mon Sep 17 00:00:00 2001
From: enzigma-pratishtha-upadhyay
Date: Wed, 10 Apr 2024 16:06:43 +0530
Subject: [PATCH 05/17] Update BDI_DataImportService.cls
---
force-app/main/default/classes/BDI_DataImportService.cls | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/force-app/main/default/classes/BDI_DataImportService.cls b/force-app/main/default/classes/BDI_DataImportService.cls
index a7b46310d30..85c15249f2f 100644
--- a/force-app/main/default/classes/BDI_DataImportService.cls
+++ b/force-app/main/default/classes/BDI_DataImportService.cls
@@ -52,6 +52,7 @@ global with sharing class BDI_DataImportService {
public static final String ACH_PAYMENT_METHOD = 'ACH';
public static final String DI_WITH_RD_FIELDS_NO_RD2 = System.label.RD2_DisabledRD2Error;
public static final String DI_WITH_RD_FIELDS_NO_ADV_MAPPING = System.label.RD2_DisabledAdvancedMappingError;
+ public static boolean isForBatchProcess = true;
public BDI_MappingService mappingService;
@@ -90,6 +91,7 @@ global with sharing class BDI_DataImportService {
* @return String the soql String
*/
public static String strSoqlForDataImportProcess(List dataImportIds) {
+ isForBatchProcess = false;
List whereClauses = new List{
'Status__c != \'' + BDI_DataImport_API.bdiImported + '\'',
'Id =: dataImportIds'
@@ -111,6 +113,7 @@ global with sharing class BDI_DataImportService {
* @return String the soql String
*/
public static String strSoqlForBatchProcess(Id batchId) {
+ isForBatchProcess = true;
List selectClause = new List{
String.join(listStrDataImportFields, ','),
DATAIMPORT_BATCH_NUMBER_FIELD
@@ -974,6 +977,10 @@ global with sharing class BDI_DataImportService {
Map mapS = Schema.SObjectType.DataImport__c.fields.getMap();
listStrDataImportFields = new List();
listStrDataImportFields.addAll(mapS.keySet());
+ if (isForBatchProcess == false) {
+ listStrDataImportFields.add('NPSP_Data_Import_Batch__r.Name');
+ listStrDataImportFields.add('NPSP_Data_Import_Batch__r.Batch_Number__c');
+ }
}
return listStrDataImportFields;
}
From ac63dcb8efc8a9cafbc8550dd6bf0afb33c2fe25 Mon Sep 17 00:00:00 2001
From: enzigma-pratishtha-upadhyay
Date: Wed, 10 Apr 2024 19:29:25 +0530
Subject: [PATCH 06/17] Update BDI_DataImportService.cls
---
.../default/classes/BDI_DataImportService.cls | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/force-app/main/default/classes/BDI_DataImportService.cls b/force-app/main/default/classes/BDI_DataImportService.cls
index 85c15249f2f..1e8a081246c 100644
--- a/force-app/main/default/classes/BDI_DataImportService.cls
+++ b/force-app/main/default/classes/BDI_DataImportService.cls
@@ -52,7 +52,6 @@ global with sharing class BDI_DataImportService {
public static final String ACH_PAYMENT_METHOD = 'ACH';
public static final String DI_WITH_RD_FIELDS_NO_RD2 = System.label.RD2_DisabledRD2Error;
public static final String DI_WITH_RD_FIELDS_NO_ADV_MAPPING = System.label.RD2_DisabledAdvancedMappingError;
- public static boolean isForBatchProcess = true;
public BDI_MappingService mappingService;
@@ -91,14 +90,17 @@ global with sharing class BDI_DataImportService {
* @return String the soql String
*/
public static String strSoqlForDataImportProcess(List dataImportIds) {
- isForBatchProcess = false;
List whereClauses = new List{
'Status__c != \'' + BDI_DataImport_API.bdiImported + '\'',
'Id =: dataImportIds'
};
-
+ List selectClause = new List{
+ 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
@@ -113,7 +115,6 @@ global with sharing class BDI_DataImportService {
* @return String the soql String
*/
public static String strSoqlForBatchProcess(Id batchId) {
- isForBatchProcess = true;
List selectClause = new List{
String.join(listStrDataImportFields, ','),
DATAIMPORT_BATCH_NUMBER_FIELD
@@ -977,10 +978,6 @@ global with sharing class BDI_DataImportService {
Map mapS = Schema.SObjectType.DataImport__c.fields.getMap();
listStrDataImportFields = new List();
listStrDataImportFields.addAll(mapS.keySet());
- if (isForBatchProcess == false) {
- listStrDataImportFields.add('NPSP_Data_Import_Batch__r.Name');
- listStrDataImportFields.add('NPSP_Data_Import_Batch__r.Batch_Number__c');
- }
}
return listStrDataImportFields;
}
From 1d43b5885660a415f897706e8390b53a6b22e3b1 Mon Sep 17 00:00:00 2001
From: enzigma-pratishtha-upadhyay
Date: Thu, 11 Apr 2024 19:48:22 +0530
Subject: [PATCH 07/17] Update GiftBatchService_TEST.cls
---
force-app/main/default/classes/GiftBatchService_TEST.cls | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/force-app/main/default/classes/GiftBatchService_TEST.cls b/force-app/main/default/classes/GiftBatchService_TEST.cls
index 3a2ee3c6271..cb1ea23c175 100644
--- a/force-app/main/default/classes/GiftBatchService_TEST.cls
+++ b/force-app/main/default/classes/GiftBatchService_TEST.cls
@@ -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');
From 073ae355e64314601c613b04e684119ddba548cf Mon Sep 17 00:00:00 2001
From: enzigma-pratishtha-upadhyay
Date: Mon, 15 Apr 2024 17:10:05 +0530
Subject: [PATCH 08/17] Update GiftEntryProcessorQueue.cls
---
force-app/main/default/classes/GiftEntryProcessorQueue.cls | 3 +++
1 file changed, 3 insertions(+)
diff --git a/force-app/main/default/classes/GiftEntryProcessorQueue.cls b/force-app/main/default/classes/GiftEntryProcessorQueue.cls
index 26530e96d77..6599551d381 100644
--- a/force-app/main/default/classes/GiftEntryProcessorQueue.cls
+++ b/force-app/main/default/classes/GiftEntryProcessorQueue.cls
@@ -67,6 +67,9 @@ public with sharing class GiftEntryProcessorQueue implements Queueable, Database
queueableGiftBatch.updateGiftsInChunk();
queueableGiftBatch.preprocessRecurringGifts();
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()) {
From 1caa6ed198d3b7f456a4c880d94cccfccc19a247 Mon Sep 17 00:00:00 2001
From: p-upadhyay_sfemu
Date: Thu, 25 Apr 2024 20:13:46 +0530
Subject: [PATCH 09/17] Update BDI_DataImportService.cls
---
force-app/main/default/classes/BDI_DataImportService.cls | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/force-app/main/default/classes/BDI_DataImportService.cls b/force-app/main/default/classes/BDI_DataImportService.cls
index 1e8a081246c..0c9da69c8b0 100644
--- a/force-app/main/default/classes/BDI_DataImportService.cls
+++ b/force-app/main/default/classes/BDI_DataImportService.cls
@@ -622,7 +622,12 @@ global with sharing class BDI_DataImportService {
this.listDI = flsService.getValidRecords();
this.listDI = checkRDFields(listDI);
-
+ for(DataImport__c dataImport : listDI){
+ if(apexJobId!= null && dataImport.Recurring_Donation_Recurring_Type__c !=null) {
+ dataImport.Donation_Date__c = null;
+ dataImport.Donation_Amount__c = null;
+ }
+ }
// do any performance optimizations to avoid unnecessary code
disableAllOppRollups();
From a76bdfa1d8e40fdcb0495ee0abb24b1bca6e63bb Mon Sep 17 00:00:00 2001
From: enzigma-pratishtha-upadhyay
Date: Fri, 26 Apr 2024 12:38:38 +0530
Subject: [PATCH 10/17] Update BDI_DataImportService.cls
---
force-app/main/default/classes/BDI_DataImportService.cls | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/force-app/main/default/classes/BDI_DataImportService.cls b/force-app/main/default/classes/BDI_DataImportService.cls
index 0c9da69c8b0..9abd48fc60b 100644
--- a/force-app/main/default/classes/BDI_DataImportService.cls
+++ b/force-app/main/default/classes/BDI_DataImportService.cls
@@ -622,12 +622,14 @@ global with sharing class BDI_DataImportService {
this.listDI = flsService.getValidRecords();
this.listDI = checkRDFields(listDI);
+ if(apexJobId != null) {
for(DataImport__c dataImport : listDI){
- if(apexJobId!= null && dataImport.Recurring_Donation_Recurring_Type__c !=null) {
+ if(dataImport.Recurring_Donation_Recurring_Type__c !=null) {
dataImport.Donation_Date__c = null;
dataImport.Donation_Amount__c = null;
}
}
+ }
// do any performance optimizations to avoid unnecessary code
disableAllOppRollups();
From cb3e71c2ef09beff300301f3ee722d153f015523 Mon Sep 17 00:00:00 2001
From: p-upadhyay_sfemu
Date: Thu, 2 May 2024 17:40:12 +0530
Subject: [PATCH 11/17] Update BDI_DataImportService.cls
---
force-app/main/default/classes/BDI_DataImportService.cls | 1 -
1 file changed, 1 deletion(-)
diff --git a/force-app/main/default/classes/BDI_DataImportService.cls b/force-app/main/default/classes/BDI_DataImportService.cls
index 9abd48fc60b..0e48407696f 100644
--- a/force-app/main/default/classes/BDI_DataImportService.cls
+++ b/force-app/main/default/classes/BDI_DataImportService.cls
@@ -626,7 +626,6 @@ global with sharing class BDI_DataImportService {
for(DataImport__c dataImport : listDI){
if(dataImport.Recurring_Donation_Recurring_Type__c !=null) {
dataImport.Donation_Date__c = null;
- dataImport.Donation_Amount__c = null;
}
}
}
From fc047037cb03502b917ab0991d038d6d838b2577 Mon Sep 17 00:00:00 2001
From: p-upadhyay_sfemu
Date: Wed, 8 May 2024 18:18:16 +0530
Subject: [PATCH 12/17] Update BDI_DataImportService.cls
---
.../default/classes/BDI_DataImportService.cls | 20 ++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/force-app/main/default/classes/BDI_DataImportService.cls b/force-app/main/default/classes/BDI_DataImportService.cls
index 0e48407696f..d42c5d2c10e 100644
--- a/force-app/main/default/classes/BDI_DataImportService.cls
+++ b/force-app/main/default/classes/BDI_DataImportService.cls
@@ -622,13 +622,23 @@ global with sharing class BDI_DataImportService {
this.listDI = flsService.getValidRecords();
this.listDI = checkRDFields(listDI);
- if(apexJobId != null) {
- for(DataImport__c dataImport : listDI){
- if(dataImport.Recurring_Donation_Recurring_Type__c !=null) {
- dataImport.Donation_Date__c = null;
+
+ DataImportBatch__c batch = [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];
+ GiftBatch giftBatch = new GiftBatch(batch);
+ Boolean firstInstallmentPaid = giftBatch.shouldPayFirstInstallment();
+ if(apexJobId != null) {
+ 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();
From 34c33d52e9b09860106b536c61b0fe1839843446 Mon Sep 17 00:00:00 2001
From: p-upadhyay_sfemu
Date: Thu, 9 May 2024 15:37:46 +0530
Subject: [PATCH 13/17] Update BDI_DataImportService.cls
---
force-app/main/default/classes/BDI_DataImportService.cls | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/force-app/main/default/classes/BDI_DataImportService.cls b/force-app/main/default/classes/BDI_DataImportService.cls
index d42c5d2c10e..d74c71ff653 100644
--- a/force-app/main/default/classes/BDI_DataImportService.cls
+++ b/force-app/main/default/classes/BDI_DataImportService.cls
@@ -623,13 +623,14 @@ global with sharing class BDI_DataImportService {
this.listDI = checkRDFields(listDI);
+ if(apexJobId != null && listDI.size() > 0) {
DataImportBatch__c batch = [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];
GiftBatch giftBatch = new GiftBatch(batch);
Boolean firstInstallmentPaid = giftBatch.shouldPayFirstInstallment();
- if(apexJobId != null) {
+
for (DataImport__c dataImport : listDI) {
if(dataImport.Recurring_Donation_Recurring_Type__c != null) {
dataImport.Donation_Date__c = null;
From 10e76c638d5d40c96b8188a345f851ed57959ccc Mon Sep 17 00:00:00 2001
From: p-upadhyay_sfemu
Date: Thu, 9 May 2024 15:58:07 +0530
Subject: [PATCH 14/17] Update GiftEntryProcessorQueue_TEST.cls
---
.../classes/GiftEntryProcessorQueue_TEST.cls | 53 +++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/force-app/main/default/classes/GiftEntryProcessorQueue_TEST.cls b/force-app/main/default/classes/GiftEntryProcessorQueue_TEST.cls
index 16c86f1e588..41745d68f87 100644
--- a/force-app/main/default/classes/GiftEntryProcessorQueue_TEST.cls
+++ b/force-app/main/default/classes/GiftEntryProcessorQueue_TEST.cls
@@ -197,6 +197,59 @@ private class GiftEntryProcessorQueue_TEST {
System.assertEquals(true, mockService.failGiftsInProcessingWasCalled);
}
+ @IsTest
+ static void shouldUpdateDataImportBatchFieldsOnGiftBatchProcess() {
+ DataImportBatch__c giftBatch = new DataImportBatch__c();
+ insert giftBatch;
+
+ List giftsToInsert = new List();
+ giftsToInsert.addAll(buildGifts(2, BDI_DataImport_API.bdiImported, giftBatch.Id, false));
+ giftsToInsert.addAll(buildGifts(5, BDI_DataImport_API.bdiDryRunValidated, giftBatch.Id, false));
+ insert giftsToInsert;
+
+ GiftBatchForQueueable giftBatchForProcessing = new GiftBatchForQueueable(new GiftBatchId(giftBatch.Id), new GiftBatchSelector());
+ giftBatchForProcessing.chunkGiftsThatCanBeProcessed();
+ GiftEntryProcessorQueue processorQueue = new GiftEntryProcessorQueue(giftBatchForProcessing);
+ GiftBatchServiceMock mockService = new GiftBatchServiceMock();
+ processorQueue.giftBatchService = stubFor(mockService);
+
+ Test.startTest();
+ processorQueue.execute(null);
+ Test.stopTest();
+
+ DataImportBatch__c processedGiftBatch = [SELECT Name, Batch_Status__c, Last_Processed_On__c,
+ Records_Successfully_Processed__c, Records_Failed__c
+ FROM DataImportBatch__c WHERE Id = :giftBatch.Id LIMIT 1];
+ System.assertEquals(5, processedGiftBatch.Records_Successfully_Processed__c, '5 gifts should be processed in this batch.');
+ System.assertEquals(0, processedGiftBatch.Records_Failed__c, '0 gifts should be failed in this batch.');
+ }
+
+ @IsTest
+ static void shouldOverrideDataImportBatchFieldsOnEmptyGiftBatchProcess() {
+ DataImportBatch__c giftBatch = new DataImportBatch__c();
+ insert giftBatch;
+
+ List giftsToInsert = new List();
+ giftsToInsert.addAll(buildGifts(2, BDI_DataImport_API.bdiImported, giftBatch.Id, false));
+ insert giftsToInsert;
+
+ GiftBatchForQueueable giftBatchForProcessing = new GiftBatchForQueueable(new GiftBatchId(giftBatch.Id), new GiftBatchSelector());
+ giftBatchForProcessing.chunkGiftsThatCanBeProcessed();
+ GiftEntryProcessorQueue processorQueue = new GiftEntryProcessorQueue(giftBatchForProcessing);
+ GiftBatchServiceMock mockService = new GiftBatchServiceMock();
+ processorQueue.giftBatchService = stubFor(mockService);
+
+ Test.startTest();
+ processorQueue.execute(null);
+ Test.stopTest();
+
+ DataImportBatch__c processedGiftBatch = [SELECT Name, Batch_Status__c, Last_Processed_On__c,
+ Records_Successfully_Processed__c, Records_Failed__c
+ FROM DataImportBatch__c WHERE Id = :giftBatch.Id LIMIT 1];
+ System.assertEquals(0, processedGiftBatch.Records_Successfully_Processed__c, '0 gifts should be processed in this batch.');
+ System.assertEquals(0, processedGiftBatch.Records_Failed__c, '0 gifts should be failed in this batch.');
+ }
+
public class GiftBatchServiceMock implements StubProvider {
public String asyncApexJobStatus = 'COMPLETED';
public Boolean clearLatestJobIdFromWasCalled = false;
From b4779d9f18fb6a78f3f996ab7d872c611f512b20 Mon Sep 17 00:00:00 2001
From: p-upadhyay_sfemu
Date: Fri, 10 May 2024 14:02:18 +0530
Subject: [PATCH 15/17] Update GiftEntryProcessorQueue_TEST.cls
---
.../classes/GiftEntryProcessorQueue_TEST.cls | 53 -------------------
1 file changed, 53 deletions(-)
diff --git a/force-app/main/default/classes/GiftEntryProcessorQueue_TEST.cls b/force-app/main/default/classes/GiftEntryProcessorQueue_TEST.cls
index 41745d68f87..16c86f1e588 100644
--- a/force-app/main/default/classes/GiftEntryProcessorQueue_TEST.cls
+++ b/force-app/main/default/classes/GiftEntryProcessorQueue_TEST.cls
@@ -197,59 +197,6 @@ private class GiftEntryProcessorQueue_TEST {
System.assertEquals(true, mockService.failGiftsInProcessingWasCalled);
}
- @IsTest
- static void shouldUpdateDataImportBatchFieldsOnGiftBatchProcess() {
- DataImportBatch__c giftBatch = new DataImportBatch__c();
- insert giftBatch;
-
- List giftsToInsert = new List();
- giftsToInsert.addAll(buildGifts(2, BDI_DataImport_API.bdiImported, giftBatch.Id, false));
- giftsToInsert.addAll(buildGifts(5, BDI_DataImport_API.bdiDryRunValidated, giftBatch.Id, false));
- insert giftsToInsert;
-
- GiftBatchForQueueable giftBatchForProcessing = new GiftBatchForQueueable(new GiftBatchId(giftBatch.Id), new GiftBatchSelector());
- giftBatchForProcessing.chunkGiftsThatCanBeProcessed();
- GiftEntryProcessorQueue processorQueue = new GiftEntryProcessorQueue(giftBatchForProcessing);
- GiftBatchServiceMock mockService = new GiftBatchServiceMock();
- processorQueue.giftBatchService = stubFor(mockService);
-
- Test.startTest();
- processorQueue.execute(null);
- Test.stopTest();
-
- DataImportBatch__c processedGiftBatch = [SELECT Name, Batch_Status__c, Last_Processed_On__c,
- Records_Successfully_Processed__c, Records_Failed__c
- FROM DataImportBatch__c WHERE Id = :giftBatch.Id LIMIT 1];
- System.assertEquals(5, processedGiftBatch.Records_Successfully_Processed__c, '5 gifts should be processed in this batch.');
- System.assertEquals(0, processedGiftBatch.Records_Failed__c, '0 gifts should be failed in this batch.');
- }
-
- @IsTest
- static void shouldOverrideDataImportBatchFieldsOnEmptyGiftBatchProcess() {
- DataImportBatch__c giftBatch = new DataImportBatch__c();
- insert giftBatch;
-
- List giftsToInsert = new List();
- giftsToInsert.addAll(buildGifts(2, BDI_DataImport_API.bdiImported, giftBatch.Id, false));
- insert giftsToInsert;
-
- GiftBatchForQueueable giftBatchForProcessing = new GiftBatchForQueueable(new GiftBatchId(giftBatch.Id), new GiftBatchSelector());
- giftBatchForProcessing.chunkGiftsThatCanBeProcessed();
- GiftEntryProcessorQueue processorQueue = new GiftEntryProcessorQueue(giftBatchForProcessing);
- GiftBatchServiceMock mockService = new GiftBatchServiceMock();
- processorQueue.giftBatchService = stubFor(mockService);
-
- Test.startTest();
- processorQueue.execute(null);
- Test.stopTest();
-
- DataImportBatch__c processedGiftBatch = [SELECT Name, Batch_Status__c, Last_Processed_On__c,
- Records_Successfully_Processed__c, Records_Failed__c
- FROM DataImportBatch__c WHERE Id = :giftBatch.Id LIMIT 1];
- System.assertEquals(0, processedGiftBatch.Records_Successfully_Processed__c, '0 gifts should be processed in this batch.');
- System.assertEquals(0, processedGiftBatch.Records_Failed__c, '0 gifts should be failed in this batch.');
- }
-
public class GiftBatchServiceMock implements StubProvider {
public String asyncApexJobStatus = 'COMPLETED';
public Boolean clearLatestJobIdFromWasCalled = false;
From afdd2b59d25f409159bf7b787e50c4c6a617a080 Mon Sep 17 00:00:00 2001
From: p-upadhyay_sfemu
Date: Fri, 10 May 2024 16:56:36 +0530
Subject: [PATCH 16/17] Update BDI_DataImportService.cls
---
force-app/main/default/classes/BDI_DataImportService.cls | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/force-app/main/default/classes/BDI_DataImportService.cls b/force-app/main/default/classes/BDI_DataImportService.cls
index d74c71ff653..3963becd7d8 100644
--- a/force-app/main/default/classes/BDI_DataImportService.cls
+++ b/force-app/main/default/classes/BDI_DataImportService.cls
@@ -624,11 +624,12 @@ global with sharing class BDI_DataImportService {
this.listDI = checkRDFields(listDI);
if(apexJobId != null && listDI.size() > 0) {
- DataImportBatch__c batch = [SELECT Name, Batch_Number__c, Batch_Status__c, Batch_Defaults__c,
+ List 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];
- GiftBatch giftBatch = new GiftBatch(batch);
+ if(listBatch.size() > 0 ){
+ GiftBatch giftBatch = new GiftBatch(listBatch[0]);
Boolean firstInstallmentPaid = giftBatch.shouldPayFirstInstallment();
for (DataImport__c dataImport : listDI) {
@@ -640,6 +641,7 @@ global with sharing class BDI_DataImportService {
}
}
}
+ }
// do any performance optimizations to avoid unnecessary code
disableAllOppRollups();
From 594f62c1294204653e04963ee5300f5a69f8b39e Mon Sep 17 00:00:00 2001
From: Luke Parrott
Date: Mon, 13 May 2024 11:58:26 -0500
Subject: [PATCH 17/17] Minor formating fixes
---
.../default/classes/BDI_DataImportService.cls | 34 +++++++++----------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/force-app/main/default/classes/BDI_DataImportService.cls b/force-app/main/default/classes/BDI_DataImportService.cls
index 3963becd7d8..46dffa4d66c 100644
--- a/force-app/main/default/classes/BDI_DataImportService.cls
+++ b/force-app/main/default/classes/BDI_DataImportService.cls
@@ -98,7 +98,7 @@ global with sharing class BDI_DataImportService {
String.join(listStrDataImportFields, ','),
DATAIMPORT_BATCH_NUMBER_FIELD
};
-
+
return new UTIL_Query()
.withSelectFields(selectClause)
.withFrom(DataImport__c.SObjectType)
@@ -623,25 +623,25 @@ global with sharing class BDI_DataImportService {
this.listDI = checkRDFields(listDI);
- if(apexJobId != null && listDI.size() > 0) {
- List 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;
+ if (apexJobId != null && listDI.size() > 0) {
+ List 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();