Commit f9e6db84 authored by kartik1000's avatar kartik1000

Deceased's Contact Membership's Status updated to Deceased via Inline

Signed-off-by: kartik1000's avatarKartik Kathuria <kathuriakartik0@gmail.com>
Signed-off-by: kartik1000's avatarKartik Kathuria <kathuriakartik0@gmail.com>
Signed-off-by: kartik1000's avatarKartik Kathuria <kathuriakartik0@gmail.com>
Signed-off-by: kartik1000's avatarKartik Kathuria <kathuriakartik0@gmail.com>
parent 31556325
......@@ -426,6 +426,14 @@ class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact {
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;
}
......
......@@ -136,6 +136,25 @@ class api_v3_MembershipStatusTest extends CiviUnitTestCase {
$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.
*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment