From 8d57846551a6a4d6780a9c10efe58d3046287ccf Mon Sep 17 00:00:00 2001 From: Aidan Saunders Date: Thu, 26 May 2022 15:14:23 +0100 Subject: [PATCH] Make this error message more informative. Update test --- CRM/Batch/BAO/EntityBatch.php | 2 +- tests/phpunit/api/v3/EntityBatchTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CRM/Batch/BAO/EntityBatch.php b/CRM/Batch/BAO/EntityBatch.php index f4c1e55a70..39db2ba2fc 100644 --- a/CRM/Batch/BAO/EntityBatch.php +++ b/CRM/Batch/BAO/EntityBatch.php @@ -45,7 +45,7 @@ class CRM_Batch_BAO_EntityBatch extends CRM_Batch_DAO_EntityBatch { ->execute() ->first(); if ($batchCurrency && $batchCurrency !== $trxn['currency']) { - throw new \CRM_Core_Exception(ts('You can not add items of two different currencies to a single contribution batch.')); + throw new \CRM_Core_Exception(ts('You cannot add items of two different currencies to a single contribution batch. Batch id %1 currency: %2. Entity id %3 currency: %4.', [1 => $batchId, 2 => $batchCurrency, 3 => $entityId, 4 => $trxn['currency']])); } if ($batchPID && $trxn && $batchPID !== $trxn['payment_instrument_id']) { $paymentInstrument = CRM_Core_PseudoConstant::getLabel('CRM_Batch_BAO_Batch', 'payment_instrument_id', $batchPID); diff --git a/tests/phpunit/api/v3/EntityBatchTest.php b/tests/phpunit/api/v3/EntityBatchTest.php index 8250199962..04402fe984 100644 --- a/tests/phpunit/api/v3/EntityBatchTest.php +++ b/tests/phpunit/api/v3/EntityBatchTest.php @@ -113,7 +113,7 @@ class api_v3_EntityBatchTest extends CiviUnitTestCase { 'entity_table' => 'civicrm_financial_trxn', ]; $result = $this->callAPIFailure($this->_entity, 'create', $secondEntityBatchParams); - $this->assertEquals('You can not add items of two different currencies to a single contribution batch.', $result['error_message']); + $this->assertEquals("You cannot add items of two different currencies to a single contribution batch. Batch id {$batchId} currency: USD. Entity id {$secondFinancialTrxnId} currency: CAD.", $result['error_message']); } } -- 2.25.1