From d23722f9667ef26127cebf57f081a84c9dfedede Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 11 Feb 2019 17:35:56 +1300 Subject: [PATCH] Remove unused variable from getPartialPaymentWithType --- CRM/Core/BAO/FinancialTrxn.php | 33 +++++++++---------- .../Financial/BAO/FinancialAccountTest.php | 2 +- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/CRM/Core/BAO/FinancialTrxn.php b/CRM/Core/BAO/FinancialTrxn.php index e6070ebfb1f4..b345477fb1ee 100644 --- a/CRM/Core/BAO/FinancialTrxn.php +++ b/CRM/Core/BAO/FinancialTrxn.php @@ -437,18 +437,21 @@ public static function recordFees($params) { } /** - * get partial payment amount and type of it. + * get partial payment amount. + * + * @deprecated + * + * This function basically calls CRM_Contribute_BAO_Contribution::getContributionBalance + * - just do that. If need be we could have a fn to get the contribution id but + * chances are the calling functions already know it anyway. * * @param int $entityId * @param string $entityName - * @param bool $returnType * @param int $lineItemTotal * - * @return array|int|NULL|string - * [payment type => amount] - * payment type: 'amount_owed' or 'refund_due' + * @return array */ - public static function getPartialPaymentWithType($entityId, $entityName = 'participant', $returnType = TRUE, $lineItemTotal = NULL) { + public static function getPartialPaymentWithType($entityId, $entityName = 'participant', $lineItemTotal = NULL) { $value = NULL; if (empty($entityName)) { return $value; @@ -467,17 +470,13 @@ public static function getPartialPaymentWithType($entityId, $entityName = 'parti if ($contributionId && $financialTypeId) { - $value = CRM_Contribute_BAO_Contribution::getContributionBalance($contributionId, $lineItemTotal); - - $paymentVal = $value; - if ($returnType) { - $value = array(); - if ($paymentVal < 0) { - $value['refund_due'] = $paymentVal; - } - elseif ($paymentVal > 0) { - $value['amount_owed'] = $paymentVal; - } + $paymentVal = CRM_Contribute_BAO_Contribution::getContributionBalance($contributionId, $lineItemTotal); + $value = []; + if ($paymentVal < 0) { + $value['refund_due'] = $paymentVal; + } + elseif ($paymentVal > 0) { + $value['amount_owed'] = $paymentVal; } } return $value; diff --git a/tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php b/tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php index 4f86263d98e6..5a042d0ccb45 100644 --- a/tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php +++ b/tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php @@ -371,7 +371,7 @@ public function testBalanceDueIfDeferredRevenueEnabled() { 'source' => 'SSF', 'contribution_status_id' => 1, )); - $balance = CRM_Core_BAO_FinancialTrxn::getPartialPaymentWithType($contribution['id'], 'contribution', FALSE, $totalAmount); + $balance = CRM_Core_BAO_FinancialTrxn::getPartialPaymentWithType($contribution['id'], 'contribution', $totalAmount); $this->assertEquals(0.0, $balance); Civi::settings()->revert('contribution_invoice_settings'); }