Remove unused function
authorEileen McNaughton <emcnaughton@wikimedia.org>
Wed, 27 Oct 2021 19:59:11 +0000 (08:59 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Wed, 27 Oct 2021 19:59:42 +0000 (08:59 +1300)
Note we don't slow the removal down by adding deprecation notices for internal financial functions as they have
never been stable / supported for external use

CRM/Contribute/BAO/Contribution.php
tests/phpunit/CRM/Contribute/BAO/ContributionTest.php

index a600f1812d04ea4b7788a0a5af4ba1012155d615..89917d0a16ab62c464ee9e7dfe1a864259ff44ad 100644 (file)
@@ -4645,37 +4645,6 @@ LIMIT 1;";
     return $flag;
   }
 
-  /**
-   * Calculate financial item amount when contribution is updated.
-   *
-   * @param array $params
-   *   contribution params
-   * @param array $amountParams
-   *
-   * @param string $context
-   *
-   * @return float
-   */
-  public static function calculateFinancialItemAmount($params, $amountParams, $context) {
-    if (!empty($params['is_quick_config'])) {
-      $amount = $amountParams['item_amount'];
-      if (!$amount) {
-        $amount = $params['total_amount'];
-        if ($context === NULL) {
-          $amount -= CRM_Utils_Array::value('tax_amount', $params, 0);
-        }
-      }
-    }
-    else {
-      $amount = $amountParams['line_total'];
-      if ($context == 'changedAmount') {
-        $amount -= $amountParams['previous_line_total'];
-      }
-      $amount *= $amountParams['diff'];
-    }
-    return $amount;
-  }
-
   /**
    * Retrieve Sales Tax Financial Accounts.
    *
index 744f552a784a2ae90151a4a55ad8b6e1be462102..e32f8620b1c1a8d784da115fec9dcec16d10d912 100644 (file)
@@ -931,75 +931,6 @@ WHERE eft.entity_id = %1 AND ft.to_financial_account_id <> %2";
     $this->assertFalse($allowUpdate);
   }
 
-  /**
-   * Test calculateFinancialItemAmount().
-   */
-  public function testcalculateFinancialItemAmount() {
-    $testParams = [
-      [
-        'params' => [],
-        'amountParams' => [
-          'line_total' => 100,
-          'previous_line_total' => 300,
-          'diff' => 1,
-        ],
-        'context' => 'changedAmount',
-        'expectedItemAmount' => -200,
-      ],
-      [
-        'params' => [],
-        'amountParams' => [
-          'line_total' => 100,
-          'previous_line_total' => 100,
-          'diff' => -1,
-        ],
-        // Most contexts are ignored. Removing refs to change payment instrument so placeholder.
-        'context' => 'not null',
-        'expectedItemAmount' => -100,
-      ],
-      [
-        'params' => [
-          'is_quick_config' => TRUE,
-          'total_amount' => 110,
-          'tax_amount' => 10,
-        ],
-        'amountParams' => [
-          'item_amount' => 100,
-        ],
-        'context' => 'changedAmount',
-        'expectedItemAmount' => 100,
-      ],
-      [
-        'params' => [
-          'is_quick_config' => TRUE,
-          'total_amount' => 110,
-          'tax_amount' => 10,
-        ],
-        'amountParams' => [
-          'item_amount' => NULL,
-        ],
-        'context' => 'changedAmount',
-        'expectedItemAmount' => 110,
-      ],
-      [
-        'params' => [
-          'is_quick_config' => TRUE,
-          'total_amount' => 110,
-          'tax_amount' => 10,
-        ],
-        'amountParams' => [
-          'item_amount' => NULL,
-        ],
-        'context' => NULL,
-        'expectedItemAmount' => 100,
-      ],
-    ];
-    foreach ($testParams as $params) {
-      $itemAmount = CRM_Contribute_BAO_Contribution::calculateFinancialItemAmount($params['params'], $params['amountParams'], $params['context']);
-      $this->assertEquals($itemAmount, $params['expectedItemAmount'], 'Invalid Financial Item amount.');
-    }
-  }
-
   /**
    * Test recording of amount with comma separator.
    *