diff --git a/app/models/concerns/eligibility_checkable.rb b/app/models/concerns/eligibility_checkable.rb index 2e1d12cbc6..f2b769667f 100644 --- a/app/models/concerns/eligibility_checkable.rb +++ b/app/models/concerns/eligibility_checkable.rb @@ -50,6 +50,7 @@ def trainee_teacher? def common_ineligible_attributes? [ + policy_closed?, indicated_ineligible_school?, supply_teacher_lacking_either_long_contract_or_direct_employment?, poor_performance?, @@ -59,6 +60,10 @@ def common_ineligible_attributes? ].any? end + def policy_closed? + policy.closed?(claim_year) + end + def indicated_ineligible_school? current_school.present? && !policy::SchoolEligibility.new(current_school).eligible? end diff --git a/app/models/policies/early_career_payments.rb b/app/models/policies/early_career_payments.rb index a0289b1ffd..bc5f165769 100644 --- a/app/models/policies/early_career_payments.rb +++ b/app/models/policies/early_career_payments.rb @@ -173,5 +173,9 @@ def future_years(year) def selectable_itt_years_for_claim_year(claim_year) (AcademicYear.new(claim_year - 5)...AcademicYear.new(claim_year)).to_a end + + def closed?(claim_year) + claim_year > POLICY_END_YEAR + end end end diff --git a/app/models/policies/early_career_payments/eligibility.rb b/app/models/policies/early_career_payments/eligibility.rb index 43e768c20d..eb182254de 100644 --- a/app/models/policies/early_career_payments/eligibility.rb +++ b/app/models/policies/early_career_payments/eligibility.rb @@ -34,7 +34,7 @@ def policy hsh[year] = AcademicYear::Type.new.serialize(year) end.merge({AcademicYear.new => AcademicYear::Type.new.serialize(AcademicYear.new)}) - enum :itt_academic_year, ITT_ACADEMIC_YEARS + enum :itt_academic_year, ITT_ACADEMIC_YEARS, validate: true enum :qualification, { postgraduate_itt: 0, diff --git a/app/models/policies/levelling_up_premium_payments.rb b/app/models/policies/levelling_up_premium_payments.rb index 9a3ab6331e..e2a41761a7 100644 --- a/app/models/policies/levelling_up_premium_payments.rb +++ b/app/models/policies/levelling_up_premium_payments.rb @@ -158,5 +158,9 @@ def future_years(year) def selectable_itt_years_for_claim_year(claim_year) (AcademicYear.new(claim_year - 5)...AcademicYear.new(claim_year)).to_a end + + def closed?(claim_year) + claim_year > POLICY_END_YEAR + end end end diff --git a/app/views/additional_payments/claims/_ineligibility_ecp_only_ecp_closed.html.erb b/app/views/additional_payments/claims/_ineligibility_ecp_only_ecp_closed.html.erb new file mode 100644 index 0000000000..7931af3f8b --- /dev/null +++ b/app/views/additional_payments/claims/_ineligibility_ecp_only_ecp_closed.html.erb @@ -0,0 +1,17 @@ +
+ You are not eligible for the + <%= link_to("early-career payment (opens in new tab)", Policies::EarlyCareerPayments.eligibility_criteria_url, class: "govuk-link", target: "_blank") %> + because the policy has now closed. +
++ You are not eligible for the + <%= link_to("#{I18n.t("levelling_up_premium_payments.policy_short_name").downcase} (opens in new tab)", Policies::LevellingUpPremiumPayments.eligibility_criteria_url, class: "govuk-link", target: "_blank") %> + because the school you teach in is not eligible. <%= I18n.t("levelling_up_premium_payments.policy_short_name").capitalize.pluralize %> are offered in schools identified as having a higher need for teachers. +
+ ++ For more information, check the eligibility criteria for + <%= link_to("early-career payments", Policies::EarlyCareerPayments.eligibility_criteria_url, class: "govuk-link") %> + and + <%= link_to(I18n.t("levelling_up_premium_payments.policy_short_name").downcase.pluralize, Policies::LevellingUpPremiumPayments.eligibility_criteria_url, class: "govuk-link") %>. +
diff --git a/db/schema.rb b/db/schema.rb index ff5c7e9cb2..3fb5778de0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 2024_11_26_105650) do +ActiveRecord::Schema[8.0].define(version: 2024_11_29_103823) do # These are extensions that must be enabled in order to support this database enable_extension "citext" enable_extension "pg_catalog.plpgsql" @@ -113,7 +113,11 @@ t.date "onelogin_idv_date_of_birth" t.datetime "started_at", precision: nil, null: false t.datetime "verified_at" + t.index "lower((email_address)::text)", name: "index_claims_on_lower_email_address" + t.index "lower((first_name)::text), lower((surname)::text), date_of_birth", name: "index_claims_on_personal_details" + t.index "lower((national_insurance_number)::text)", name: "index_claims_on_lower_national_insurance_number" t.index ["academic_year"], name: "index_claims_on_academic_year" + t.index ["bank_account_number", "bank_sort_code"], name: "index_claims_on_bank_details" t.index ["created_at"], name: "index_claims_on_created_at" t.index ["eligibility_type", "eligibility_id"], name: "index_claims_on_eligibility_type_and_eligibility_id" t.index ["held"], name: "index_claims_on_held" diff --git a/lib/ineligibility_reason_checker.rb b/lib/ineligibility_reason_checker.rb index 20b34c42ea..e2889067e1 100644 --- a/lib/ineligibility_reason_checker.rb +++ b/lib/ineligibility_reason_checker.rb @@ -4,7 +4,9 @@ def initialize(answers) end def reason - if current_school? + if ecp_only_and_ecp_closed? + :ecp_only_ecp_closed + elsif current_school? :current_school elsif dqt_data_ineligible? :dqt_data_ineligible @@ -41,6 +43,15 @@ def reason private + def ecp_only_and_ecp_closed? + school = @answers.current_school + + [ + Policies::EarlyCareerPayments::SchoolEligibility.new(school).eligible?, + !Policies::LevellingUpPremiumPayments::SchoolEligibility.new(school).eligible? + ].all? && Policies::EarlyCareerPayments.closed?(@answers.policy_year) + end + def current_school? school = @answers.current_school diff --git a/spec/features/combined_teacher_claim_journey_spec.rb b/spec/features/combined_teacher_claim_journey_spec.rb index 42e6229cf1..53c08457d7 100644 --- a/spec/features/combined_teacher_claim_journey_spec.rb +++ b/spec/features/combined_teacher_claim_journey_spec.rb @@ -6,9 +6,9 @@ end let(:eligibility) { claim.eligibility } - before { create(:journey_configuration, :additional_payments, current_academic_year: AcademicYear.new(2023)) } - scenario "Eligible for both" do + create(:journey_configuration, :additional_payments, current_academic_year: AcademicYear.new(2023)) + school = create(:school, :combined_journey_eligibile_for_all) visit new_claim_path(Journeys::AdditionalPaymentsForTeaching::ROUTING_NAME) @@ -243,6 +243,8 @@ end scenario "Eligible for only one" do + create(:journey_configuration, :additional_payments, current_academic_year: AcademicYear.new(2023)) + school = create(:school, :early_career_payments_uplifted) visit new_claim_path(Journeys::AdditionalPaymentsForTeaching::ROUTING_NAME) @@ -323,4 +325,84 @@ expect(page).not_to have_selector('input[type="radio"]') expect(page).to have_button("Apply now") end + + context "when ECP is closed" do + before do + create( + :journey_configuration, + :additional_payments, + current_academic_year: AcademicYear.new(2025) + ) + end + + scenario "choosing an ecp only school is ineligible" do + school = create(:school, :early_career_payments_eligible) + + visit new_claim_path(Journeys::AdditionalPaymentsForTeaching::ROUTING_NAME) + + click_on "Continue without signing" + + choose_school school + + expect(page).to have_content "You are not eligible" + expect(page).to have_content "the policy has now closed" + end + + scenario "choosing a lup eligible school allows completing the journey" do + school = create(:school, :combined_journey_eligibile_for_all) + + visit new_claim_path(Journeys::AdditionalPaymentsForTeaching::ROUTING_NAME) + + click_on "Continue without signing" + + choose_school school + click_on "Continue" + + # - Have you started your first year as a newly qualified teacher? + choose "Yes" + click_on "Continue" + + # - Have you completed your induction as an early-career teacher? + choose "Yes" + click_on "Continue" + + # - Are you currently employed as a supply teacher + choose "No" + click_on "Continue" + + # - Poor performance + within all(".govuk-fieldset")[0] do + choose("No") + end + within all(".govuk-fieldset")[1] do + choose("No") + end + click_on "Continue" + + # - What route into teaching did you take? + choose("Undergraduate initial teacher training (ITT)") + click_on "Continue" + + # - In which academic year did you complete your undergraduate ITT? + choose("2024 to 2025") + click_on "Continue" + + # - Which subject did you do your undergraduate ITT in + choose "Mathematics" + click_on "Continue" + + # Do you spend at least half of your contracted hours teaching eligible + # subjects? + choose "Yes" + click_on "Continue" + + # Check your answers + click_on "Continue" + + expect(page).to have_content("You’re eligible for an additional payment") + expect(page).to have_content( + "you can apply for a school targeted retention incentive" + ) + end + end end