From: eileen Date: Mon, 11 Feb 2019 04:35:56 +0000 (+1300) Subject: Remove unused variable from getPartialPaymentWithType X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=2fc731d5d7d36a05f202d7b8890c7bb9fbaca114;p=civicrm-core.git Remove unused variable from getPartialPaymentWithType --- diff --git a/CRM/Core/BAO/FinancialTrxn.php b/CRM/Core/BAO/FinancialTrxn.php index e6070ebfb1..b345477fb1 100644 --- a/CRM/Core/BAO/FinancialTrxn.php +++ b/CRM/Core/BAO/FinancialTrxn.php @@ -437,18 +437,21 @@ WHERE ceft.entity_id = %1"; } /** - * 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 @@ WHERE ceft.entity_id = %1"; 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 4f86263d98..6f2851a98a 100644 --- a/tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php +++ b/tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php @@ -371,7 +371,7 @@ class CRM_Financial_BAO_FinancialAccountTest extends CiviUnitTestCase { 'source' => 'SSF', 'contribution_status_id' => 1, )); - $balance = CRM_Core_BAO_FinancialTrxn::getPartialPaymentWithType($contribution['id'], 'contribution', FALSE, $totalAmount); + $balance = CRM_Contribute_BAO_Contribution::getContributionBalance($contribution['id'], $totalAmount); $this->assertEquals(0.0, $balance); Civi::settings()->revert('contribution_invoice_settings'); }