From f36ab38fce0313f759733e7ec5d510d4328854dc Mon Sep 17 00:00:00 2001 From: ufundo Date: Thu, 9 Jun 2022 16:29:32 +0000 Subject: [PATCH] only check batch currency match when adding a financial_trxn --- CRM/Batch/BAO/EntityBatch.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CRM/Batch/BAO/EntityBatch.php b/CRM/Batch/BAO/EntityBatch.php index 39db2ba2fc..3f64e75b33 100644 --- a/CRM/Batch/BAO/EntityBatch.php +++ b/CRM/Batch/BAO/EntityBatch.php @@ -26,6 +26,7 @@ class CRM_Batch_BAO_EntityBatch extends CRM_Batch_DAO_EntityBatch { // Only write the EntityBatch record if the financial trxn and batch match on currency and payment instrument. $batchId = $params['batch_id'] ?? NULL; $entityId = $params['entity_id'] ?? NULL; + $entityTable = $params['entity_table'] ?? 'civicrm_financial_trxn'; // Not having a batch ID and entity ID is only acceptable on an update. if (!$batchId) { $existingEntityBatch = \Civi\Api4\EntityBatch::get(FALSE) @@ -36,7 +37,7 @@ class CRM_Batch_BAO_EntityBatch extends CRM_Batch_DAO_EntityBatch { $entityId = $existingEntityBatch['entity_id'] ?? NULL; } // There should never be a legitimate case where a record has an ID but no batch ID but SyntaxConformanceTest says otherwise. - if ($batchId) { + if ($batchId && $entityTable === 'civicrm_financial_trxn') { $batchCurrency = self::getBatchCurrency($batchId); $batchPID = (int) CRM_Core_DAO::getFieldValue('CRM_Batch_DAO_Batch', $batchId, 'payment_instrument_id'); $trxn = \Civi\Api4\FinancialTrxn::get(FALSE) -- 2.25.1