Remove unused variable from getPartialPaymentWithType
authoreileen <emcnaughton@wikimedia.org>
Mon, 11 Feb 2019 04:35:56 +0000 (17:35 +1300)
committereileen <emcnaughton@wikimedia.org>
Tue, 12 Feb 2019 02:50:54 +0000 (15:50 +1300)
CRM/Core/BAO/FinancialTrxn.php
tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php

index e6070ebfb1f454d8f74ca7421710c4b327154201..b345477fb1ee1ada17d5b3cb36c44781515ce20e 100644 (file)
@@ -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;
index 4f86263d98e68b3c12253f20c5ab9770fc82d576..6f2851a98af33ed15ace64f4c4167757cf772a09 100644 (file)
@@ -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');
   }