diff --git a/app/models/journeys/additional_payments_for_teaching/slug_sequence.rb b/app/models/journeys/additional_payments_for_teaching/slug_sequence.rb index 730ef87c1d..500a5075a7 100644 --- a/app/models/journeys/additional_payments_for_teaching/slug_sequence.rb +++ b/app/models/journeys/additional_payments_for_teaching/slug_sequence.rb @@ -73,6 +73,15 @@ class SlugSequence RESULTS_SLUGS ).freeze + TRAINEE_TEACHER_SLUGS = %w[ + current-school + nqt-in-academic-year-after-itt + eligible-itt-subject + eligible-degree-subject + future-eligibility + ineligible + ] + attr_reader :journey_session delegate :answers, to: :journey_session @@ -81,9 +90,15 @@ def initialize(journey_session) @journey_session = journey_session end - # Even though we are inside the ECP namespace, this method can modify the - # slug sequence of both LUP and ECP claims def slugs + if answers.trainee_teacher? && Policies::LevellingUpPremiumPayments::SchoolEligibility.new(answers.current_school).eligible? + lup_trainee_journey_slugs + else + non_trainee_journey_slugs + end + end + + def non_trainee_journey_slugs SLUGS.dup.tap do |sequence| if !Journeys::AdditionalPaymentsForTeaching.configuration.teacher_id_enabled? sequence.delete("sign-in-or-continue") @@ -132,14 +147,9 @@ def slugs sequence.delete("mobile-verification") end - if answers.trainee_teacher? - trainee_teacher_slugs!(sequence) - sequence.delete("eligible-degree-subject") unless lup_eligibility_checker.indicated_ineligible_itt_subject? - else - sequence.delete("ineligible") unless [:ineligible, :eligible_later].include?(overall_eligibility_status) - sequence.delete("future-eligibility") - sequence.delete("eligible-degree-subject") unless ecp_eligibility_checker.status == :ineligible && lup_eligibility_checker.indicated_ineligible_itt_subject? - end + sequence.delete("ineligible") unless [:ineligible, :eligible_later].include?(overall_eligibility_status) + sequence.delete("future-eligibility") + sequence.delete("eligible-degree-subject") unless ecp_eligibility_checker.status == :ineligible && lup_eligibility_checker.indicated_ineligible_itt_subject? sequence.delete("induction-completed") unless induction_question_required? @@ -164,6 +174,14 @@ def slugs end end + def lup_trainee_journey_slugs + TRAINEE_TEACHER_SLUGS.dup.tap do |sequence| + if lup_eligibility_checker.status == :eligible_later && answers.eligible_degree_subject.nil? + sequence.delete("eligible-degree-subject") + end + end + end + def self.start_page_url Rails.application.routes.url_helpers.landing_page_path("additional-payments") end @@ -190,21 +208,6 @@ def replace_ecp_only_induction_not_completed_slugs(sequence) sequence.replace(slugs) end - # This method swaps out the entire slug sequence and replaces it with this tiny - # journey. - def trainee_teacher_slugs!(sequence) - trainee_slugs = %w[ - current-school - nqt-in-academic-year-after-itt - eligible-itt-subject - eligible-degree-subject - future-eligibility - ineligible - ] - - [sequence.dup - trainee_slugs].flatten.each { |slug| sequence.delete(slug) } - end - def induction_question_required? # Induction question is not required if an ECP-eligible school is not selected. return false unless ecp_school_selected? diff --git a/app/models/journeys/page_sequence.rb b/app/models/journeys/page_sequence.rb index 96a494ead3..6d1a85feee 100644 --- a/app/models/journeys/page_sequence.rb +++ b/app/models/journeys/page_sequence.rb @@ -22,10 +22,6 @@ def slugs def next_slug return "ineligible" if journey_ineligible? - if lup_policy_and_trainee_teacher_at_lup_school? - return handle_trainee_teacher - end - if claim_submittable? return "student-loan-amount" if updating_personal_details? && in_sequence?("student-loan-amount") return "check-your-answers" @@ -87,29 +83,6 @@ def can_skip_next_slug? true if current_slug == "select-home-address" && answers.postcode.present? end - def lup_policy_and_trainee_teacher_at_lup_school? - journey == Journeys::AdditionalPaymentsForTeaching && lup_trainee_at_lup_school - end - - def lup_trainee_at_lup_school - answers.nqt_in_academic_year_after_itt == false && Policies::LevellingUpPremiumPayments::SchoolEligibility.new(answers.current_school).eligible? - end - - def handle_trainee_teacher - case current_slug - when "nqt-in-academic-year-after-itt" - "eligible-itt-subject" - when "eligible-itt-subject" - if answers.eligible_itt_subject.to_sym.in? Policies::LevellingUpPremiumPayments.fixed_subject_symbols - "future-eligibility" - else - "eligible-degree-subject" - end - when "eligible-degree-subject" - "future-eligibility" - end - end - def current_slug_index slugs.index(current_slug) || 0 end