Skip to content

Commit

Permalink
Use saved contribution's line items rather than the primaryContributi…
Browse files Browse the repository at this point in the history
…onID

By the time we reach this point in the code we know that
1) the contributon exists and it has an id
2) it has line items  - either those created in it's pending stage or those calculated in repeattransaction

Therefore we can reasonably assume these line items are accurate now and use them, rather than the confusing
primaryContributionID that we have doubts about the validity of
  • Loading branch information
eileenmcnaughton committed Aug 1, 2020
1 parent eae974d commit 5c3e5ab
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -4510,7 +4510,6 @@ public static function completeOrder($input, &$ids, $objects, $transaction = NUL
if ($contributionParams['contribution_status_id'] === $completedContributionStatusID) {
self::updateMembershipBasedOnCompletionOfContribution(
$contribution,
$primaryContributionID,
$changeDate
);
}
Expand Down Expand Up @@ -5210,13 +5209,12 @@ protected static function isPaymentInstrumentChange(&$params, $pendingStatuses)
* load them in this function. Code clean up would compensate for any minor performance implication.
*
* @param \CRM_Contribute_BAO_Contribution $contribution
* @param int $primaryContributionID
* @param string $changeDate
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public static function updateMembershipBasedOnCompletionOfContribution($contribution, $primaryContributionID, $changeDate) {
public static function updateMembershipBasedOnCompletionOfContribution($contribution, $changeDate) {
$memberships = self::getRelatedMemberships($contribution->id);
foreach ($memberships as $membership) {
$membershipParams = [
Expand Down Expand Up @@ -5256,7 +5254,7 @@ public static function updateMembershipBasedOnCompletionOfContribution($contribu
// @todo once apiv4 ships with core switch to that & find sanity.
$membershipParams['num_terms'] = $contribution->getNumTermsByContributionAndMembershipType(
$membershipParams['membership_type_id'],
$primaryContributionID
$contribution->id
);
}
// @todo remove all this stuff in favour of letting the api call further down handle in
Expand Down

0 comments on commit 5c3e5ab

Please sign in to comment.