Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
monishdeb authored and Jitendra Purohit committed May 10, 2017
1 parent 6150b2a commit 66a1e31
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
6 changes: 3 additions & 3 deletions CRM/Activity/BAO/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -2042,7 +2042,7 @@ public static function getContactActivity($contactId) {
* For Membership Signup or Renewal.
* @param int $targetContactID
* @param array $params
* Activity params to override
* Activity params to override.
*
* @return bool|NULL
*/
Expand Down Expand Up @@ -2127,10 +2127,10 @@ public static function addActivity(
}

/**
* 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
*/
Expand Down
8 changes: 6 additions & 2 deletions CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -1940,10 +1940,14 @@ public static function transitionComponents($params, $processContributionObject
'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));
Expand All @@ -1960,7 +1964,7 @@ public static function transitionComponents($params, $processContributionObject
array(
'subject' => "Status changed from {$allStatus[$oldStatus]} to {$allStatus[$membership->status_id]}",
'source_contact_id' => $membershipLog['modified_id'],
'priority_id' => 2,
'priority_id' => 'Normal',
)
);
}
Expand Down
14 changes: 7 additions & 7 deletions CRM/Member/BAO/Membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ public static function add(&$params, $ids = array()) {
// 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');
}

Expand All @@ -159,7 +159,7 @@ public static function add(&$params, $ids = array()) {
array(
'subject' => "Status changed from {$allStatus[$oldStatus]} to {$allStatus[$membership->status_id]}",
'source_contact_id' => $membershipLog['modified_id'],
'priority_id' => 2,
'priority_id' => 'Normal',
)
);
}
Expand All @@ -171,7 +171,7 @@ public static function add(&$params, $ids = array()) {
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',
)
);
}
Expand Down Expand Up @@ -1853,7 +1853,7 @@ public static function processMembership($contactID, $membershipTypeID, $is_test
'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;
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/api/v3/ContributionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2765,7 +2765,7 @@ public function testPendingToCompleteContribution() {
);
$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'],
Expand Down Expand Up @@ -2813,7 +2813,7 @@ public function testPendingToCompleteContribution() {
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',
Expand Down

0 comments on commit 66a1e31

Please sign in to comment.