From b13247f00fec923b99baa8b0bf8402e057553009 Mon Sep 17 00:00:00 2001 From: Richard Lynch Date: Thu, 5 Dec 2024 12:36:55 +0000 Subject: [PATCH] wip running ci --- .../claim_submission_form.rb | 13 +++ app/models/concerns/eligibility_checkable.rb | 5 ++ app/models/policies/early_career_payments.rb | 4 + .../policies/levelling_up_premium_payments.rb | 4 + ...ineligibility_ecp_only_ecp_closed.html.erb | 17 ++++ lib/ineligibility_reason_checker.rb | 13 ++- .../combined_teacher_claim_journey_spec.rb | 86 ++++++++++++++++++- 7 files changed, 139 insertions(+), 3 deletions(-) create mode 100644 app/views/additional_payments/claims/_ineligibility_ecp_only_ecp_closed.html.erb diff --git a/app/forms/journeys/additional_payments_for_teaching/claim_submission_form.rb b/app/forms/journeys/additional_payments_for_teaching/claim_submission_form.rb index 71b5cef8df..99e7ed6d76 100644 --- a/app/forms/journeys/additional_payments_for_teaching/claim_submission_form.rb +++ b/app/forms/journeys/additional_payments_for_teaching/claim_submission_form.rb @@ -9,6 +9,17 @@ def eligible_now_or_later private + # not sure about these changess, could we potentially pick a policy + # that isn't actually eligible? + def eligibilities + eligibility_checker.potentially_still_eligible.map do |policy| + policy::Eligibility.new.tap do |eligibility| + set_eligibility_attributes(eligibility) + calculate_award_amount(eligibility) + end + end + end + def eligibility_checker @eligibility_checker ||= Journeys::EligibilityChecker.new(journey_session: journey_session) end @@ -20,6 +31,8 @@ def main_eligibility def main_policy if answers.selected_claim_policy.present? answers.selected_claim_policy + elsif eligibilities.one? + eligibilities.first.policy else Policies::EarlyCareerPayments end 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/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/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