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

CAPT 1995/remove ecp #3415

Merged
merged 17 commits into from
Dec 11, 2024
Merged

CAPT 1995/remove ecp #3415

merged 17 commits into from
Dec 11, 2024

Conversation

rjlynch
Copy link
Contributor

@rjlynch rjlynch commented Nov 19, 2024

This PR introduces some refactors to separate the LUP and ECP logic as part of the move to splitting LUP into it's own journey and deprecating ECP.
This will be a lot easier to review looking at the individual commits!

At a high level this PR

  • Updates the LUP end date
  • Moves policy specific logic into the respective policies
  • Removes lib/journey_subject_eligibility_checker.rb
  • Removes journey specific logic from the page sequence

We'll introduce the LUP only journey in a separate PR.

@rjlynch rjlynch force-pushed the CAPT-1995/remove-ecp branch 6 times, most recently from ca6b041 to 47236ce Compare November 20, 2024 16:50
@rjlynch rjlynch added the deploy Deploy a review app for this PR label Nov 21, 2024
@rjlynch rjlynch marked this pull request as ready for review November 22, 2024 14:08
@@ -63,6 +63,14 @@ def policies_eligible_now_and_sorted
policies_eligible_now_with_award_amount_and_sorted.map { |policy_with_award_amount| policy_with_award_amount.policy }
end

def potentially_still_eligible
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe rename to potentially_still_eligible_policies?

Copy link
Contributor

@asmega asmega left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine, nice one on removing more stuff! probably worth getting another review and pair of eyes tbh

@rjlynch
Copy link
Contributor Author

rjlynch commented Nov 27, 2024

Looks fine, nice one on removing more stuff! probably worth getting another review and pair of eyes tbh

Thanks, there's still one big piece I want to remove lib/ineligibility_reason_checker it reimplements all the ineligible logic, separate from the policy, to determine the reason a claim is ineligible for the ineligible screen. I'm surprised this doesn't get out of sync more. I think we want to just pass the ineligible reason as a param to the ineligible screen, something like redirect_to ineligible_path(reason: :some_reason), rather than using the ineligiblity_reason_checker in the view

@kenfodder
Copy link
Contributor

I'll have a look today!

@kenfodder
Copy link
Contributor

All LGTM so far 👍

@rjlynch
Copy link
Contributor Author

rjlynch commented Dec 9, 2024

@kenfodder thanks for the review. When you have a minute, would you mind taking a second look as I've pushed some commits since you last review (rebased it on master and added this new functionality.

@slorek would be good to get your eyes on this too before merging!

Copy link
Contributor

@kenfodder kenfodder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine 👍

Copy link
Contributor

@slorek slorek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, and good refactoring to remove JourneySubjectEligibilityChecker.

eligible_itt_years.include?(itt_academic_year)
end

def requires_student_loan_details?
true
end

def selectable_subject_symbols(journey_session)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: this could probably live in the EligibleIttSubjectForm class.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 that's nicer, will do this as a separate pr though

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of refactoring to remove ECP.
These concerns are only used in these classes, inlining them to make
tracking the difference between ECP and LUP easier.
This was the only method EligibilityCheckable was being pulled in for.
While we're duplicating the definition of a trainee teacher, inlining
the method here will make splitting up the EligibilityCheckable policy
easier.
FINAL_LUP_POLICY_YEAR is a dupe of Lup::POLICY_END_YEAR. We should have
updated Lup::POLICY_END_YEAR to 2025 as part of capt-1832
This method is only used in the specs. Inline the method to where it's
used and remove the method and it's tests. One less thing to keep track
off!
Splits this method by policy so it's easier to break out LUP into it's
own journey.
There was a lot of duplicated business rules in this method.
We were explicity checking for `nqt_in_academic_year_after_itt`, and if
it was absent we were falling back to only the lup subjects. The ECP
policy is ineligible for non `nqt_in_academic_year_after_itt` claims so
it will be filtered out when we check for
`potentially_still_eligible_policies`.
We returned an empty array if the `current_academic_year` was outside
the lup policy dates, however the LUP#subject_symbols method already
returns an empty array of available subjects for years outside the
policy.

There's some weirdness in the
`AdditionalPaymentsForTeaching.selectable_subject_symbols` method. If
we're dealing with a trainee teacher, we return a hard coded list of
subjects, however trainee teachers won't be eligible as the
`EligibilityCheckable#common_ineligible_attributes?` checks if the
claimant is a trainee teacher, and is thus ineligible. It seems weird to
return a list of subjects if the claimant is ineligible. This was the
existing behaviour so I've kept it in place but this likely needs
revisiting.
As part of the refactor to remove ECP we want to move the policy
specific functionality into the respective polices. This commit moves
the `selectable_itt_years_for_claim_year` out of the lib class and into
each policy, with the journey delegating this method to any
potentially_still_eligible policies.
Move fixed_lup_subject_symbols of off JourneySubjectEligibilityChecker
and onto LevellingUpPremiumPayments policy as this method is policy
specific.
This class is no longer needed
Just making the code a little easier to follow
This branch can't get hit as this method is only called when the
claimant is a trainee teacher, ie `nqt_in_academic_year_after_itt` is
`false`.
ECP `specific_ineligible_attributes?` already checks if
`trainee_teacher?` is set. For LUP trainee teachers can still be
eligible later, so we want to make sure we don't return ineligible in
that case.
This previously hasn't surfaced as an issue due to how the code was
called (a short circut specific to trainee teachers in the page
sequence) but we want to move some of the code around which exposes this
bug.
Removes the ineligiblity branches from the special case trainee teacher
journey. We want all eligibility checking to happen in one place (the
policy eligibility checker). This commit updates the mini trainee
journey to not check eligibility. This also surfaced a bug in the policy
eligiblity checker, a trainee teacher with an ineligible itt subject is
not yet ineligible, they may still be eligible later, we don't know
until they've entered their degree subject (at least according to the
logic in
`spec/features/trainee_teacher_subjourney_for_lup_schools_spec.rb:59`)
Previously the page sequence contained specific logic for handling an
additional payments sub journey (traniee teacher), and rather than
modifying the slug sequence just overwrote what is returned.
Additionally there was a condition in the slug sequence that caused the
whole thing to be swapped out if we were dealing with a trainee teacher.
This commit removes the additional payments specific handling from the
page sequence, leaving it journey agnostic, and updates the additional
payments slug sequence to move the trainee teacher sub journey branching
to the top level.
LUP will extend past ECP, so we can't use the combined end date when
deciding what subjects to show for nqts who haven't entered an itt,
otherwise we render an empty list on the itt subject screen.
Previously the hint text was showing all subjects to claimants, even if
they were not eligible for those subjects, instead only show subjects
the claimant is eligible for. If the claimant is not eligible for any
subjects they will have been kicked out of the journey prior to this
screen.
This is additional functionality, so may want splitting out into a
separate PR, but it was requested as part of this ticket.
If the current acadmic year is after the ECP policy close date, then
selecting an ECP only school should show the claimant the ineligible
screen.
There's a slight bit of trickyness, the ECP::Eligibility model has an
enum for itt academic year, that only allows values for dates within
the ECP policy, or nil, adding a date outside this range throws an
error. The page sequences calls the claim submission form which
constructs an eligibility to check if the journey is completed, if the
user chooses an itt date that's outside the ECP policy range (possible
for future academic years) constructing the ecp eligibility throws an
error. To avoid this we're using the new `validate` option on enum, so
rather than throw an error when adding a date out side the range it now
generates a validation error. Some of the tests needed updating to add a
valid itt academic year as now ecp eligibility isn't valid if it's
missing the itt year.
@rjlynch rjlynch force-pushed the CAPT-1995/remove-ecp branch from 6a5e368 to 5650863 Compare December 11, 2024 10:39
@rjlynch rjlynch merged commit 7da4806 into master Dec 11, 2024
15 checks passed
@rjlynch rjlynch deleted the CAPT-1995/remove-ecp branch December 11, 2024 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deploy Deploy a review app for this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants