Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make this error message more informative. #23599

Merged
merged 1 commit into from
May 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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']);
}

}