From: Eileen McNaughton Date: Thu, 10 Feb 2022 01:40:16 +0000 (+1300) Subject: Tidy up getContributionPaymentLinks X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f1b5e606d70ba25944ad194d7a2dd21e3c0e4ec3;p=civicrm-core.git Tidy up getContributionPaymentLinks - removes an unused variable. - fixes to not show 'record Refund' for pending contributions (is displayed on the expand payments section of a contribution --- diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 126527ebf9..5434ee955f 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -3634,7 +3634,7 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac $info['transaction'] = self::getContributionTransactionInformation($contributionId, $contribution['financial_type_id']); } - $info['payment_links'] = self::getContributionPaymentLinks($id, $paymentBalance, $info['contribution_status']); + $info['payment_links'] = self::getContributionPaymentLinks($id, $info['contribution_status']); return $info; } @@ -4275,7 +4275,6 @@ LIMIT 1;"; * then a refund link. * * @param int $id - * @param float $balance * @param string $contributionStatus * * @return array @@ -4283,7 +4282,7 @@ LIMIT 1;"; * -url * -title */ - protected static function getContributionPaymentLinks($id, $balance, $contributionStatus) { + protected static function getContributionPaymentLinks(int $id, string $contributionStatus): array { if ($contributionStatus === 'Failed' || !CRM_Core_Permission::check('edit contributions')) { // In general the balance is the best way to determine if a payment can be added or not, // but not for Failed contributions, where we don't accept additional payments at the moment. @@ -4314,15 +4313,17 @@ LIMIT 1;"; 'title' => ts('Submit Credit Card payment'), ]; } - $actionLinks[] = [ - 'url' => CRM_Utils_System::url('civicrm/payment', [ - 'action' => 'add', - 'reset' => 1, - 'id' => $id, - 'is_refund' => 1, - ]), - 'title' => ts('Record Refund'), - ]; + if ($contributionStatus !== 'Pending') { + $actionLinks[] = [ + 'url' => CRM_Utils_System::url('civicrm/payment', [ + 'action' => 'add', + 'reset' => 1, + 'id' => $id, + 'is_refund' => 1, + ]), + 'title' => ts('Record Refund'), + ]; + } return $actionLinks; }