From 6a7d79fc66898f9214afb025dd2fbfcdcced2ba8 Mon Sep 17 00:00:00 2001 From: Alkesh Vaghmaria Date: Wed, 2 Oct 2024 16:32:57 +0100 Subject: [PATCH] enable reminders for LUP --- app/models/concerns/eligibility_checkable.rb | 1 + .../additional_payments_for_teaching.rb | 12 +- .../submissions/show.html.erb | 2 +- .../additional_payments_for_teaching_spec.rb | 120 ++++++------------ 4 files changed, 48 insertions(+), 87 deletions(-) diff --git a/app/models/concerns/eligibility_checkable.rb b/app/models/concerns/eligibility_checkable.rb index 77cd0f2dda..b5decfc117 100644 --- a/app/models/concerns/eligibility_checkable.rb +++ b/app/models/concerns/eligibility_checkable.rb @@ -3,6 +3,7 @@ module EligibilityCheckable FIRST_COMBINED_ECP_AND_LUP_POLICY_YEAR = AcademicYear.new(2022) FINAL_COMBINED_ECP_AND_LUP_POLICY_YEAR = AcademicYear.new(2024) + FINAL_LUP_POLICY_YEAR = AcademicYear.new(2025) COMBINED_ECP_AND_LUP_POLICY_YEARS = FIRST_COMBINED_ECP_AND_LUP_POLICY_YEAR..FINAL_COMBINED_ECP_AND_LUP_POLICY_YEAR COMBINED_ECP_AND_LUP_POLICY_YEARS_BEFORE_FINAL_YEAR = FIRST_COMBINED_ECP_AND_LUP_POLICY_YEAR...FINAL_COMBINED_ECP_AND_LUP_POLICY_YEAR diff --git a/app/models/journeys/additional_payments_for_teaching.rb b/app/models/journeys/additional_payments_for_teaching.rb index 046939829f..92fa5619b8 100644 --- a/app/models/journeys/additional_payments_for_teaching.rb +++ b/app/models/journeys/additional_payments_for_teaching.rb @@ -34,8 +34,16 @@ module AdditionalPaymentsForTeaching } }.freeze - def set_a_reminder?(itt_academic_year:, policy_year: configuration.current_academic_year) - return false if policy_year >= EligibilityCheckable::FINAL_COMBINED_ECP_AND_LUP_POLICY_YEAR + def final_policy_year(policy) + { + Policies::EarlyCareerPayments => EligibilityCheckable::FINAL_COMBINED_ECP_AND_LUP_POLICY_YEAR, + Policies::LevellingUpPremiumPayments => EligibilityCheckable::FINAL_LUP_POLICY_YEAR + }[policy] + end + + def set_a_reminder?(itt_academic_year:, policy:) + policy_year = configuration.current_academic_year + return false if policy_year >= final_policy_year(policy) next_year = policy_year + 1 eligible_itt_years = JourneySubjectEligibilityChecker.selectable_itt_years_for_claim_year(next_year) diff --git a/app/views/additional_payments/submissions/show.html.erb b/app/views/additional_payments/submissions/show.html.erb index 4ba72df2b7..e816ab749f 100644 --- a/app/views/additional_payments/submissions/show.html.erb +++ b/app/views/additional_payments/submissions/show.html.erb @@ -24,7 +24,7 @@ <%= render partial: "submissions/confirmation" %> - <% if journey.set_a_reminder?(itt_academic_year: submitted_claim.eligibility.itt_academic_year) %> + <% if journey.set_a_reminder?(itt_academic_year: submitted_claim.eligibility.itt_academic_year, policy: submitted_claim.policy) %> <%= render partial: "submissions/reminder" %> <% end %> diff --git a/spec/models/journeys/additional_payments_for_teaching_spec.rb b/spec/models/journeys/additional_payments_for_teaching_spec.rb index a2e8276cd1..f9be210508 100644 --- a/spec/models/journeys/additional_payments_for_teaching_spec.rb +++ b/spec/models/journeys/additional_payments_for_teaching_spec.rb @@ -67,112 +67,64 @@ it { is_expected.to eq(Journeys::AdditionalPaymentsForTeaching::AnswersPresenter) } end - describe ".set_a_reminder?" do - subject { described_class.set_a_reminder?(itt_academic_year: itt_academic_year, policy_year: policy_year) } - let(:itt_academic_year) { AcademicYear.new(year) } - - context "Claim year: 22/23" do - let(:policy_year) { AcademicYear.new(2022) } - - # Eligible now - but falls out of 5 year window next year so don't set a reminder - context "ITT year: 17/18" do - let(:year) { 2017 } + shared_examples "true for years" do |start_years_range, policy_year| + JourneySubjectEligibilityChecker.selectable_itt_years_for_claim_year(policy_year).each do |itt_academic_year| + context "ITT year #{itt_academic_year}" do + let(:itt_academic_year) { itt_academic_year } - specify { expect(subject).to be false } - end - - context "ITT year: 18/19" do - let(:year) { 2018 } - - specify { expect(subject).to be true } + if start_years_range.include?(itt_academic_year.start_year) + it { is_expected.to be true } + else + it { is_expected.to be false } + end end + end + end - context "ITT year: 19/20" do - let(:year) { 2019 } + shared_examples "false for all years" do |policy_year| + JourneySubjectEligibilityChecker.selectable_itt_years_for_claim_year(policy_year).each do |itt_academic_year| + context "ITT year #{itt_academic_year}" do + let(:itt_academic_year) { itt_academic_year } - specify { expect(subject).to be true } + it { is_expected.to be false } end + end + end - context "ITT year: 20/21" do - let(:year) { 2020 } - - specify { expect(subject).to be true } - end + describe ".set_a_reminder?" do + subject { described_class.set_a_reminder?(itt_academic_year: itt_academic_year, policy: policy) } + let(:policy) { Policies::EarlyCareerPayments } + let!(:configuration) { create(:journey_configuration, :additional_payments, current_academic_year: policy_year) } - context "ITT year: 21/22" do - let(:year) { 2021 } + context "Claim year: 22/23" do + let(:policy_year) { AcademicYear.new(2022) } - specify { expect(subject).to be true } - end + # 2017 is eligible now - but falls out of the 5 year window next year + it_behaves_like "true for years", 2018..2021, AcademicYear.new(2022) end context "Claim year: 23/24" do let(:policy_year) { AcademicYear.new(2023) } - # Eligible now - but falls out of 5 year window next year so don't set a reminder - context "ITT year: 18/19" do - let(:year) { 2018 } - - specify { expect(subject).to be false } - end - - context "ITT year: 19/20" do - let(:year) { 2019 } - - specify { expect(subject).to be true } - end - - context "ITT year: 20/21" do - let(:year) { 2020 } - - specify { expect(subject).to be true } - end - - context "ITT year: 21/22" do - let(:year) { 2021 } - - specify { expect(subject).to be true } - end - - context "ITT year: 22/23" do - let(:year) { 2022 } - - specify { expect(subject).to be true } - end + # 2018 is eligible now - but falls out of the 5 year window next year + it_behaves_like "true for years", 2019..2022, AcademicYear.new(2023) end - # Last policy year - no reminders to set context "Claim year: 24/25" do let(:policy_year) { AcademicYear.new(2024) } - context "ITT year: 19/20" do - let(:year) { 2019 } - - specify { expect(subject).to be false } - end - - context "ITT year: 20/21" do - let(:year) { 2020 } - - specify { expect(subject).to be false } - end - - context "ITT year: 21/22" do - let(:year) { 2021 } - - specify { expect(subject).to be false } - end - - context "ITT year: 22/23" do - let(:year) { 2022 } + context "Last year of the policy - ECP policy" do + let(:policy) { Policies::EarlyCareerPayments } - specify { expect(subject).to be false } + # ECP will be removed after 2024/2025 academic year + it_behaves_like "false for all years", AcademicYear.new(2024) end - context "ITT year: 23/24" do - let(:year) { 2023 } + context "LUP policy" do + let(:policy) { Policies::LevellingUpPremiumPayments } - specify { expect(subject).to be false } + # 2019 is eligible now - but falls out of the 5 year window next year + it_behaves_like "true for years", 2020..2023, AcademicYear.new(2024) end end end