From 29347f3d407cfcd5f51c1fbc77a55bb607c6691b Mon Sep 17 00:00:00 2001 From: CiviCRM Date: Wed, 16 Jul 2014 09:57:52 +0530 Subject: [PATCH] CRM-14951: no of terms should be calculated on contribution id rather than entity id/table --- CRM/Contribute/BAO/Contribution.php | 2 +- CRM/Core/Payment/BaseIPN.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index f2baaea939..7e9f372159 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -256,7 +256,7 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution { $numTerms = CRM_Core_DAO::singleValueQuery(" SELECT membership_num_terms FROM civicrm_line_item li LEFT JOIN civicrm_price_field_value v ON li.price_field_value_id = v.id - WHERE entity_id = %1 AND entity_table = 'civicrm_contribution' AND membership_type_id = %2", + WHERE contribution_id = %1 AND membership_type_id = %2", array(1 => array($this->id, 'Integer') , 2 => array($membershipTypeID, 'Integer')) ); // default of 1 is precautionary diff --git a/CRM/Core/Payment/BaseIPN.php b/CRM/Core/Payment/BaseIPN.php index f41531ea6e..3de497e666 100644 --- a/CRM/Core/Payment/BaseIPN.php +++ b/CRM/Core/Payment/BaseIPN.php @@ -401,6 +401,7 @@ LIMIT 1;"; // else fall back to using current membership type $dao->free(); + $num_terms = $contribution->getNumTermsByContributionAndMembershipType($membership->membership_type_id); if ($currentMembership) { /* * Fixed FOR CRM-4433 @@ -409,7 +410,6 @@ LIMIT 1;"; */ CRM_Member_BAO_Membership::fixMembershipStatusBeforeRenew($currentMembership, $changeToday); - $num_terms = $contribution->getNumTermsByContributionAndMembershipType($membership->membership_type_id); // @todo - we should pass membership_type_id instead of null here but not // adding as not sure of testing $dates = CRM_Member_BAO_MembershipType::getRenewalDatesForMembershipType($membership->id, @@ -419,7 +419,7 @@ LIMIT 1;"; $dates['join_date'] = CRM_Utils_Date::customFormat($currentMembership['join_date'], $format); } else { - $dates = CRM_Member_BAO_MembershipType::getDatesForMembershipType($membership->membership_type_id); + $dates = CRM_Member_BAO_MembershipType::getDatesForMembershipType($membership->membership_type_id, NULL, NULL, NULL, $num_terms); } //get the status for membership. -- 2.25.1