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

Change how renewal works for existing external members #416

Merged
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: 2 additions & 2 deletions module/Checker/src/Mapper/Member.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function getMembersToCheck(int $limit): array
$qb->select('m')
->addSelect('CASE WHEN m.lastCheckedOn IS NULL THEN 0 ELSE 1 END AS HIDDEN fix_ordering')
->from('Database\Model\Member', 'm')
->where('m.type = \'ordinary\'')
->where('m.type = \'ordinary\' OR m.type = \'external\'')
->andWhere('m.tueUsername IS NOT NULL')
->andWhere('m.membershipEndsOn IS NULL')
->andWhere('m.lastCheckedOn IS NULL OR m.lastCheckedOn < CURRENT_DATE()')
Expand Down Expand Up @@ -86,7 +86,7 @@ public function getExpiringMembershipsWithNormalTypes(): array

$qb->select('m')
->from('Database\Model\Member', 'm')
->where('m.type = \'ordinary\'')
->where('m.type = \'ordinary\' OR m.type = \'external\'')
->andWhere('m.membershipEndsOn IS NULL')
->andWhere('m.expiration <= :endOfCurrentAssociationYear');

Expand Down
14 changes: 12 additions & 2 deletions module/Checker/src/Service/Checker.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,10 +430,15 @@ public function checkAtTUe(): void
echo '--> Member is still studying but not at the department of MCS' . PHP_EOL;
// The member does not study at WIN anymore, so we set the expiration date for the membership
$member->setChangedOn(new DateTime());
$member->setIsStudying(true);
$member->setMembershipEndsOn($exp);
} else {
echo '--> Member is still studying at the department of MCS' . PHP_EOL;
// The user is still studying at MCS, so don't change anything
// The member is still studying at MCS, so their membership does not end. If the member is currently
// external they will be converted to ordinary on July 1.
$member->setChangedOn(new DateTime());
$member->setIsStudying(true);
$member->setMembershipEndsOn(null);
}

// If we made it here, we have successfully checked the member
Expand Down Expand Up @@ -480,7 +485,10 @@ public function checkProperMembershipType(): void
echo 'Not an active member' . PHP_EOL;
// We only have to change the membership type for external or graduates depending on whether the
// member is still studying.
if ($member->getIsStudying()) {
if (
$member->getIsStudying()
&& $member->getLastCheckedOn() >= (new DateTime())->sub(new DateInterval('P1Y'))
) {
echo 'But is studying, so becoming EXTERNAL. Extending membership to ' .
$exp->format('Y-m-d') . PHP_EOL;
$member->setType(MembershipTypes::External);
Expand All @@ -491,6 +499,7 @@ public function checkProperMembershipType(): void
} else {
echo 'Nor studying, so becoming GRADUATE. Not extending membership' . PHP_EOL;
$member->setType(MembershipTypes::Graduate);
$member->setIsStudying(false);
}
}

Expand Down Expand Up @@ -527,6 +536,7 @@ public function checkNormalExpiration(): void
echo 'Expired, thus extending to ' . $exp->format('Y-m-d') . PHP_EOL;

$member->setChangedOn(new DateTime());
$member->setType(MembershipTypes::Ordinary);
$member->setExpiration($exp);

$this->memberService->getMemberMapper()->persist($member);
Expand Down
Loading