Skip to content

Commit

Permalink
Merge pull request #16724 from kartik1000/core-1599
Browse files Browse the repository at this point in the history
dev/core#1599/Deceased Contact's Membership Marked to Deceased via Inline
  • Loading branch information
eileenmcnaughton authored Mar 15, 2020
2 parents 33e84f4 + f9e6db8 commit 12d5ca9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CRM/Contact/BAO/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,14 @@ public static function &create(&$params, $fixAddress = TRUE, $invokeHooks = TRUE
self::unsetProtectedFields($contacts);
}

// Edit Membership Status
$deceasedParams = [
'contact_id' => CRM_Utils_Array::value('contact_id', $params),
'is_deceased' => CRM_Utils_Array::value('is_deceased', $params, FALSE),
'deceased_date' => CRM_Utils_Array::value('deceased_date', $params, NULL),
];
CRM_Member_BAO_Membership::updateMembershipStatus($deceasedParams, $params['contact_type']);

return $contact;
}

Expand Down
19 changes: 19 additions & 0 deletions tests/phpunit/api/v3/MembershipStatusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,25 @@ public function testDelete() {
$result = $this->callAPISuccess('membership_status', 'delete', $params);
}

/**
* Test that after checking the person as 'Deceased', the Membership is also 'Deceased' both through inline and normal edit.
*/
public function testDeceasedMembershipInline() {
$contactID = $this->individualCreate();
$params = [
'contact_id' => $contactID,
'membership_type_id' => $this->_membershipTypeID,
'join_date' => '2006-01-21',
'start_date' => '2006-01-21',
'end_date' => '2006-12-21',
'status_id' => $this->_membershipStatusID,
];
$this->callApiSuccess('membership', 'create', $params);
$this->callApiSuccess('contact', 'create', ['id' => $contactID, 'is_deceased' => 1]);
$membership = $this->callApiSuccessGetSingle('membership', ['contact_id' => $contactID]);
$this->assertEquals(CRM_Core_PseudoConstant::getKey('CRM_Member_BAO_Membership', 'status_id', 'Deceased'), $membership['status_id']);
}

/**
* Test that trying to delete membership status while membership still exists creates error.
*/
Expand Down

0 comments on commit 12d5ca9

Please sign in to comment.