From: Monish Deb Date: Fri, 3 Feb 2017 05:54:23 +0000 (+0530) Subject: minor fixes X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=66a1e31f279137676e395ce60eda2cc14bcde5f1;p=civicrm-core.git minor fixes --- diff --git a/CRM/Activity/BAO/Activity.php b/CRM/Activity/BAO/Activity.php index c436d774bc..2300856904 100644 --- a/CRM/Activity/BAO/Activity.php +++ b/CRM/Activity/BAO/Activity.php @@ -2042,7 +2042,7 @@ WHERE activity.id IN ($activityIds)"; * For Membership Signup or Renewal. * @param int $targetContactID * @param array $params - * Activity params to override + * Activity params to override. * * @return bool|NULL */ @@ -2127,10 +2127,10 @@ WHERE activity.id IN ($activityIds)"; } /** - * Get activity subject on basis of component object + * Get activity subject on basis of component object. * * @param object $entityObj - * (reference) particular component object. + * particular component object. * * @return string */ diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index e8cc41e1d7..211c164cf9 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -1940,10 +1940,14 @@ LEFT JOIN civicrm_contribution contribution ON ( componentPayment.contribution_ 'source_record_id' => $membership->id, 'activity_type_id' => $activityType, 'status_id' => 'Scheduled', + 'options' => array( + 'limit' => 1, + 'sort' => 'id DESC', + ), ) ) ); - // 1. Update Schedule Membership Signup/Renwal activity to completed on successful payment of pending membership + // 1. Update Schedule Membership Signup/Renewal activity to completed on successful payment of pending membership // 2. OR Create renewal activity scheduled if its membership renewal will be paid later if ($scheduledActivityID) { CRM_Activity_BAO_Activity::addActivity($membership, $activityType, $membership->contact_id, array('id' => $scheduledActivityID)); @@ -1960,7 +1964,7 @@ LEFT JOIN civicrm_contribution contribution ON ( componentPayment.contribution_ array( 'subject' => "Status changed from {$allStatus[$oldStatus]} to {$allStatus[$membership->status_id]}", 'source_contact_id' => $membershipLog['modified_id'], - 'priority_id' => 2, + 'priority_id' => 'Normal', ) ); } diff --git a/CRM/Member/BAO/Membership.php b/CRM/Member/BAO/Membership.php index f04602158f..de95c516ae 100644 --- a/CRM/Member/BAO/Membership.php +++ b/CRM/Member/BAO/Membership.php @@ -139,11 +139,11 @@ class CRM_Member_BAO_Membership extends CRM_Member_DAO_Membership { // reset the group contact cache since smart groups might be affected due to this CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush(); - $activityParams = array(); $allStatus = CRM_Member_BAO_Membership::buildOptions('status_id', 'get'); - if (!empty($params['is_pay_later']) || - in_array($allStatus[$membership->status_id], array('Pending', 'Grace')) - ) { + $activityParams = array( + 'status_id' => CRM_Utils_Array::value('membership_activity_status', $params, 'Completed'), + ); + if (in_array($allStatus[$membership->status_id], array('Pending', 'Grace'))) { $activityParams['status_id'] = CRM_Core_OptionGroup::getValue('activity_status', 'Scheduled', 'name'); } @@ -159,7 +159,7 @@ class CRM_Member_BAO_Membership extends CRM_Member_DAO_Membership { array( 'subject' => "Status changed from {$allStatus[$oldStatus]} to {$allStatus[$membership->status_id]}", 'source_contact_id' => $membershipLog['modified_id'], - 'priority_id' => 2, + 'priority_id' => 'Normal', ) ); } @@ -171,7 +171,7 @@ class CRM_Member_BAO_Membership extends CRM_Member_DAO_Membership { array( 'subject' => "Type changed from {$membershipTypes[$oldType]} to {$membershipTypes[$membership->membership_type_id]}", 'source_contact_id' => $membershipLog['modified_id'], - 'priority_id' => 2, + 'priority_id' => 'Normal', ) ); } @@ -1853,7 +1853,7 @@ INNER JOIN civicrm_contact contact ON ( contact.id = membership.contact_id AND 'join_date' => $currentMembership['join_date'], 'membership_type_id' => $membershipTypeID, 'max_related' => !empty($membershipTypeDetails['max_related']) ? $membershipTypeDetails['max_related'] : NULL, - 'is_pay_later' => $isPayLater, + 'membership_activity_status' => $isPayLater ? 'Scheduled' : 'Completed', ); if ($contributionRecurID) { $memParams['contribution_recur_id'] = $contributionRecurID; diff --git a/tests/phpunit/api/v3/ContributionTest.php b/tests/phpunit/api/v3/ContributionTest.php index b287d815f5..64214fe1a6 100644 --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@ -2765,7 +2765,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase { ); $this->setUpPendingContribution($this->_ids['price_field_value'][0]); $this->callAPISuccess('membership', 'getsingle', array('id' => $this->_ids['membership'])); - // Case 1: Assert that Membership Signup Activity is created on Pending (Pay later) to Completed Contribution via backoffice + // Case 1: Assert that Membership Signup Activity is created on Pending to Completed Contribution via backoffice $activity = $this->callAPISuccess('Activity', 'get', array( 'activity_type_id' => 'Membership Signup', 'source_record_id' => $this->_ids['membership'], @@ -2813,7 +2813,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase { catch (Civi\Payment\Exception\PaymentProcessorException $e) { $error = TRUE; } - // Case 2: After successful payment for Pending (Pay later) backoffice there are three activities created + // Case 2: After successful payment for Pending backoffice there are three activities created // 2.a Update status of existing Scheduled Membership Signup (created in step 1) to Completed $activity = $this->callAPISuccess('Activity', 'get', array( 'activity_type_id' => 'Membership Signup',