}
}
- /**
- * Get the amount for the main contribution.
- *
- * The goal is to expand this function so that all the argy-bargy of figuring out the amount
- * winds up here as the main spaghetti shrinks.
- *
- * If there is a separate membership contribution this is the 'other one'. Otherwise there
- * is only one.
- *
- * @todo - move this to the parent, replace existing (some tests to fight).
- *
- * @param $params
- *
- * @return float
- *
- * @throws \CRM_Core_Exception
- */
- protected function getMainContributionAmount($params = []) {
- $amount = 0;
- foreach ($this->getMainContributionLineItems() as $lineItem) {
- // Line total inclusive should really be always set but this is a safe fall back.
- $amount += $lineItem['line_total_inclusive'] ?? ($lineItem['line_total'] + $lineItem['tax_amount']);
- }
- return $amount;
- }
-
/**
* Complete transaction if payment has been processed.
*
$params['separate_amount'] = $params['amount'];
// @todo - stepping through the code indicates that amount is always set before this point so it never matters.
// Move more of the above into this function...
- $params['amount'] = $this->getMainContributionAmount($params);
+ $params['amount'] = $this->getMainContributionAmount();
//If the membership & contribution is used in contribution page & not separate payment
$memPresent = $membershipLabel = $fieldOption = NULL;
$proceFieldAmount = 0;
/**
* Get the amount for the main contribution.
*
- * The goal is to expand this function so that all the argy-bargy of figuring out the amount
- * winds up here as the main spaghetti shrinks.
- *
* If there is a separate membership contribution this is the 'other one'. Otherwise there
* is only one.
*
- * @param $params
- *
* @return float
*
* @throws \CRM_Core_Exception
*/
- protected function getMainContributionAmount($params) {
- if (!empty($params['selectMembership'])) {
- if (empty($params['amount']) && !$this->_separateMembershipPayment) {
- return CRM_Member_BAO_MembershipType::getMembershipType($params['selectMembership'])['minimum_fee'] ?? 0;
- }
+ protected function getMainContributionAmount(): float {
+ $amount = 0;
+ foreach ($this->getMainContributionLineItems() as $lineItem) {
+ // Line total inclusive should really be always set but this is a safe fall back.
+ $amount += $lineItem['line_total_inclusive'] ?? ($lineItem['line_total'] + $lineItem['tax_amount']);
}
- return $params['amount'] ?? 0;
+ return $amount;
}
/**