Skip to content

Commit

Permalink
Split subject symbols by policy
Browse files Browse the repository at this point in the history
Splits this method by policy so it's easier to break out LUP into it's
own journey.
  • Loading branch information
rjlynch committed Dec 11, 2024
1 parent 5bec77a commit 2afe1bf
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 40 deletions.
6 changes: 6 additions & 0 deletions app/models/academic_year.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ def for(date)
new(date.year)
end
end

def wrap(value)
return value if value.is_a? AcademicYear

new(value)
end
end

def initialize(year_or_academic_year_or_string = nil)
Expand Down
25 changes: 25 additions & 0 deletions app/models/policies/early_career_payments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,30 @@ def payment_and_deductions_info_url
def auto_check_student_loan_plan_task?
true
end

def subject_symbols(claim_year:, itt_year:)
case AcademicYear.wrap(claim_year)
when AcademicYear.new(2022), AcademicYear.new(2024)
case AcademicYear.wrap(itt_year)
when AcademicYear.new(2019)
[:mathematics]
when AcademicYear.new(2020)
[:chemistry, :foreign_languages, :mathematics, :physics]
else
[]
end
when AcademicYear.new(2023)
case AcademicYear.wrap(itt_year)
when AcademicYear.new(2018)
[:mathematics]
when AcademicYear.new(2020)
[:chemistry, :foreign_languages, :mathematics, :physics]
else
[]
end
else
[]
end
end
end
end
12 changes: 12 additions & 0 deletions app/models/policies/levelling_up_premium_payments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,17 @@ def payroll_file_name
def auto_check_student_loan_plan_task?
true
end

def subject_symbols(claim_year:, itt_year:)
return [] unless (POLICY_START_YEAR..POLICY_END_YEAR).cover?(claim_year)

previous_five_years = (claim_year - 5)...claim_year

if previous_five_years.cover?(itt_year)
[:chemistry, :computing, :mathematics, :physics]
else
[]
end
end
end
end
41 changes: 1 addition & 40 deletions lib/journey_subject_eligibility_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,45 +115,6 @@ def none_of_the_above?(itt_year)
def subject_symbols(policy:, claim_year:, itt_year:)
raise "Unsupported policy: #{policy}" unless policy.in?(Journeys::AdditionalPaymentsForTeaching::POLICIES)

case policy
when Policies::EarlyCareerPayments
year = claim_year.is_a?(AcademicYear) ? claim_year : AcademicYear.new(claim_year)
case year
when AcademicYear.new(2022), AcademicYear.new(2024)
case itt_year
when AcademicYear.new(2019)
[:mathematics]
when AcademicYear.new(2020)
[:chemistry, :foreign_languages, :mathematics, :physics]
else
[]
end
when AcademicYear.new(2023)
case itt_year
when AcademicYear.new(2018)
[:mathematics]
when AcademicYear.new(2020)
[:chemistry, :foreign_languages, :mathematics, :physics]
else
[]
end
else
[]
end
when Policies::LevellingUpPremiumPayments
case claim_year
when EligibilityCheckable::COMBINED_ECP_AND_LUP_POLICY_YEARS
year = itt_year.is_a?(AcademicYear) ? itt_year : AcademicYear.new(itt_year)

case year
when (claim_year - 5)...claim_year
[:chemistry, :computing, :mathematics, :physics]
else
[]
end
else
[]
end
end
policy.subject_symbols(claim_year: claim_year, itt_year: itt_year)
end
end

0 comments on commit 2afe1bf

Please sign in to comment.