Skip to content

Commit

Permalink
Remove unused variable from getPartialPaymentWithType
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Feb 11, 2019
1 parent abafc4c commit d23722f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
33 changes: 16 additions & 17 deletions CRM/Core/BAO/FinancialTrxn.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down

0 comments on commit d23722f

Please sign in to comment.