Skip to content

Commit

Permalink
dev/core#154 - Can't edit related records when current employer has a…
Browse files Browse the repository at this point in the history
… pending membership
  • Loading branch information
Jitendra Purohit committed Jun 5, 2018
1 parent bc99a11 commit 3c0ae94
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CRM/Contact/BAO/Relationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -1736,6 +1736,10 @@ public static function relatedMemberships($contactId, &$params, $ids, $action =
//contact before creating new membership record.
CRM_Member_BAO_Membership::deleteRelatedMemberships($membershipId, $relatedContactId);
}
//skip status calculation for pay later memberships.
if (!empty($membershipValues['is_pay_later']) && !empty($membershipValues['status_id'])) {
$membershipValues['skipStatusCal'] = TRUE;
}

// check whether we have some related memberships still available
$query = "
Expand Down
22 changes: 22 additions & 0 deletions tests/phpunit/api/v3/MembershipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,28 @@ public function testCreateWithRelationship() {
$result = $this->callAPISuccess('membership', 'get', $params);
$this->assertEquals(0, $result['count']);

//Create pay_later membership for organization.
$employerId[2] = $this->organizationCreate(array(), 1);
$params = array(
'contact_id' => $employerId[2],
'membership_type_id' => $membershipTypeId,
'source' => 'Test pay later suite',
'is_pay_later' => 1,
'status_id' => 5,
);
$organizationMembership = CRM_Member_BAO_Membership::add($params);
$organizationMembershipID = $organizationMembership->id;
$memberContactId[3] = $this->individualCreate(array('employer_id' => $employerId[2]), 0);
// Check that the employee inherited the membership
$params = array(
'contact_id' => $memberContactId[3],
'membership_type_id' => $membershipTypeId,
);
$result = $this->callAPISuccess('membership', 'get', $params);
$this->assertEquals(1, $result['count']);
$result = $result['values'][$result['id']];
$this->assertEquals($organizationMembershipID, $result['owner_membership_id']);

// Set up params for enable/disable checks
$relationship1 = $this->callAPISuccess('relationship', 'get', array('contact_id_a' => $memberContactId[1]));
$params = array(
Expand Down

0 comments on commit 3c0ae94

Please sign in to comment.