Skip to content

Commit

Permalink
feat(enrollment): outline new scenarios that consider expiration
Browse files Browse the repository at this point in the history
  • Loading branch information
angela-tran committed Mar 27, 2024
1 parent 6578a1b commit a2d1dfe
Showing 1 changed file with 47 additions and 8 deletions.
55 changes: 47 additions & 8 deletions benefits/enrollment/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,43 @@ def index(request):
)

already_enrolled = group_funding_source is not None

if not already_enrolled:
# enroll user with no expiration date, return success
client.link_concession_group_funding_source(group_id=group_id, funding_source_id=funding_source.id)
return _success(request, group_id)
else:
# no action, return success
return _success(request, group_id)
has_no_expiration_date = already_enrolled and group_funding_source.concession_expiry is None
has_expiration_date = already_enrolled and group_funding_source.concession_expiry is not None

if has_expiration_date:
# set expiry on session
session.update(enrollment_expiry=group_funding_source.concession_expiry)

if eligibility.supports_expiration:
if not already_enrolled:
# enroll user with an expiration date, return success
pass
else:
if has_no_expiration_date:
# update expiration of existing enrollment, return success
pass
else:
is_expired = _is_expired(group_funding_source.concession_expiry, eligibility.expiration_days)
is_within_reenrollment_window = _is_within_reenrollment_window(session.enrollment_reenrollment())

if is_expired or is_within_reenrollment_window:
# update expiration of existing enrollment, return success
pass
else:
# re-enrollment error, return enrollment error with expiration and reenrollment_date
pass
else: # eligibility does not support expiration
if not already_enrolled:
# enroll user with no expiration date, return success
client.link_concession_group_funding_source(group_id=group_id, funding_source_id=funding_source.id)
return _success(request, group_id)
else:
if has_no_expiration_date:
# no action, return success
return _success(request, group_id)
else:
# remove expiration date, return success
pass

except HTTPError as e:
analytics.returned_error(request, str(e))
Expand Down Expand Up @@ -145,6 +174,16 @@ def _get_group_funding_source(client: Client, group_id, funding_source_id):
return matching_group_funding_source


def _is_expired(concession_expiry, expiration_days):
"""Returns whether the passed in datetime is expired or not."""
pass


def _is_within_reenrollment_window(concession_expiry, enrollment_reenrollment_date):
"""Returns whether the passed in datetime is within the reenrollment window."""
pass


@decorator_from_middleware(EligibleSessionRequired)
def retry(request):
"""View handler for a recoverable failure condition."""
Expand Down

0 comments on commit a2d1dfe

Please sign in to comment.