Skip to content

Commit

Permalink
enable reminders for LUP
Browse files Browse the repository at this point in the history
  • Loading branch information
alkesh committed Oct 4, 2024
1 parent 235a5aa commit e1f0646
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 87 deletions.
1 change: 1 addition & 0 deletions app/models/concerns/eligibility_checkable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 10 additions & 2 deletions app/models/journeys/additional_payments_for_teaching.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/views/additional_payments/submissions/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>

Expand Down
120 changes: 36 additions & 84 deletions spec/models/journeys/additional_payments_for_teaching_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e1f0646

Please sign in to comment.