Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#154 - Can't edit related records when current employer has a… #12266

Merged
merged 1 commit into from
Jun 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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['status_id']) && $membershipValues['status_id'] == $pendingStatusId) {
$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