minor fixes
authorMonish Deb <monish.deb@jmaconsulting.biz>
Fri, 3 Feb 2017 05:54:23 +0000 (11:24 +0530)
committerJitendra Purohit <jitendra@fuzion.co.nz>
Wed, 10 May 2017 10:48:08 +0000 (16:18 +0530)
CRM/Activity/BAO/Activity.php
CRM/Contribute/BAO/Contribution.php
CRM/Member/BAO/Membership.php
tests/phpunit/api/v3/ContributionTest.php

index c436d774bca751b445edce51f22ab609672dad68..2300856904e8f08700e15cdae220df718c8c2dd9 100644 (file)
@@ -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
    */
index e8cc41e1d704c1ccdd6d12c3fde5d947c9cbf0b5..211c164cf91918300b1217794cf10316ff3eb942 100644 (file)
@@ -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',
                 )
               );
             }
index f04602158f4218e06ab6dea4bedb245f79557167..de95c516ae5d69e0bfcbb04c6f32f85a8573785a 100644 (file)
@@ -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;
index b287d815f514d4980fb080b9eef2c38e9dcc43d5..64214fe1a6fd3502fdc7b69943742a4a2433ce7c 100644 (file)
@@ -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',