Skip to content

Commit

Permalink
Merge pull request #23599 from aydun/contriberror
Browse files Browse the repository at this point in the history
Make this error message more informative.
  • Loading branch information
eileenmcnaughton authored May 27, 2022
2 parents ba02783 + 8d57846 commit b070641
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CRM/Batch/BAO/EntityBatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static function create($params) {
->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);
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/api/v3/EntityBatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function testMultipleCurrencies(): void {
'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']);
}

}

0 comments on commit b070641

Please sign in to comment.