Skip to content

Commit

Permalink
Additional fixes related to creation of activities on membership sign…
Browse files Browse the repository at this point in the history
…up/renewal
  • Loading branch information
Jitendra Purohit committed May 10, 2017
1 parent 66a1e31 commit ca7cb93
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CRM/Activity/BAO/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -2067,6 +2067,7 @@ public static function addActivity(
if ($activity->contribution_status_id != 1) {
return NULL;
}
$activityType = $component = 'Contribution';

// retrieve existing activity based on source_record_id and activity_type
if (empty($params['id'])) {
Expand All @@ -2081,7 +2082,6 @@ public static function addActivity(
}

$date = CRM_Utils_Date::isoToMysql($activity->receive_date);
$activityType = $component = 'Contribution';
}

$activityParams = array(
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -1868,6 +1868,7 @@ public static function transitionComponents($params, $processContributionObject

// CRM-15735-to update the membership status as per the contribution receive date
$joinDate = NULL;
$oldStatus = $membership->status_id;
if (!empty($params['receive_date'])) {
$joinDate = $params['receive_date'];
$status = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($membership->start_date,
Expand All @@ -1883,7 +1884,6 @@ public static function transitionComponents($params, $processContributionObject
}

if ($currentMembership) {
$oldStatus = $currentMembership['status_id'];
CRM_Member_BAO_Membership::fixMembershipStatusBeforeRenew($currentMembership, NULL);
$dates = CRM_Member_BAO_MembershipType::getRenewalDatesForMembershipType($membership->id, NULL, NULL, $numterms);
$dates['join_date'] = CRM_Utils_Date::customFormat($currentMembership['join_date'], $format);
Expand Down
5 changes: 3 additions & 2 deletions CRM/Member/BAO/Membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,9 @@ public static function add(&$params, $ids = 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');
$activityParams['status_id'] = 'Scheduled';
}
$activityParams['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', $activityParams['status_id']);

$targetContactID = $membership->contact_id;
if (!empty($params['is_for_organization'])) {
Expand Down Expand Up @@ -1853,7 +1854,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,
'membership_activity_status' => $isPayLater ? 'Scheduled' : 'Completed',
'membership_activity_status' => ($pending || $isPayLater) ? 'Scheduled' : 'Completed',
);
if ($contributionRecurID) {
$memParams['contribution_recur_id'] = $contributionRecurID;
Expand Down
11 changes: 9 additions & 2 deletions tests/phpunit/api/v3/ContributionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2751,6 +2751,13 @@ public function testCompleteTransactionMembershipPriceSet() {
));
$this->assertEquals(2, $logs['count']);
$this->assertNotEquals($stateOfGrace, $logs['values'][2]['status_id']);
//Assert only three activities are created.
$activities = CRM_Activity_BAO_Activity::getContactActivity($this->_ids['contact']);
$this->assertEquals(3, count($activities));
$activityNames = array_flip(CRM_Utils_Array::collect('activity_name', $activities));
$this->assertArrayHasKey('Contribution', $activityNames);
$this->assertArrayHasKey('Membership Signup', $activityNames);
$this->assertArrayHasKey('Change Membership Status', $activityNames);
$this->cleanUpAfterPriceSets();
}

Expand Down Expand Up @@ -2877,8 +2884,8 @@ public function setUpPendingContribution($priceFieldValueID, $contriParams = arr
'financial_type_id' => 1,
'payment_instrument_id' => 'Credit Card',
'non_deductible_amount' => 10.00,
'trxn_id' => 'jdhfi88',
'invoice_id' => 'djfhiewuyr',
'trxn_id' => 'jdhfi' . rand(1, 100),
'invoice_id' => 'djfhiew' . rand(5, 100),
'source' => 'SSF',
'contribution_status_id' => 2,
'contribution_page_id' => $this->_ids['contribution_page'],
Expand Down

0 comments on commit ca7cb93

Please sign in to comment.