Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup the admin to display IRP claims #2931

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ GEM
validate_url
webfinger (~> 1.2)
os (1.1.4)
pagy (8.4.5)
pagy (8.5.0)
parallel (1.25.1)
parallel_tests (4.7.1)
parallel
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
module Journeys
module GetATeacherRelocationPayment
class EmploymentDetailsForm < Form
attribute :school_headteacher_name, :string
attribute :school_name, :string
attribute :school_address_line_1, :string
attribute :school_address_line_2, :string
attribute :school_city, :string
attribute :school_postcode, :string

validates :school_headteacher_name,
presence: {
message: i18n_error_message(:school_headteacher_name)
}

validates :school_name,
presence: {
message: i18n_error_message(:school_name)
}

validates :school_address_line_1,
presence: {
message: i18n_error_message(:school_address_line_1)
}

validates :school_city,
presence: {
message: i18n_error_message(:school_city)
}

validates :school_postcode,
presence: {
message: i18n_error_message(:school_postcode)
}

validate :school_postcode_is_valid, if: -> { school_postcode.present? }

def save
return false unless valid?

journey_session.answers.assign_attributes(
school_headteacher_name: school_headteacher_name,
school_name: school_name,
school_address_line_1: school_address_line_1,
school_address_line_2: school_address_line_2,
school_city: school_city,
school_postcode: school_postcode
)

journey_session.save!
end

private

def school_postcode_is_valid
unless UKPostcode.parse(school_postcode).full_valid?
errors.add(:school_postcode, i18n_errors_path(:school_postcode))
end
end
end
end
end
4 changes: 4 additions & 0 deletions app/models/base_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,8 @@ def searchable_eligibility_attributes

self::SEARCHABLE_ELIGIBILITY_ATTRIBUTES
end

def international_relocation_payments?
to_s == "InternationalRelocationPayments"
end
end
4 changes: 4 additions & 0 deletions app/models/claim_checking_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ def initialize(claim)
@claim = claim
end

delegate :policy, to: :claim

def applicable_task_names
return [] if policy.international_relocation_payments?

@applicable_task_names ||= Task::NAMES.dup.tap do |task_names|
task_names.delete("induction_confirmation") unless claim.policy == Policies::EarlyCareerPayments
task_names.delete("student_loan_amount") unless claim.policy == Policies::StudentLoans
Expand Down
10 changes: 9 additions & 1 deletion app/models/concerns/eligibility_checkable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,18 @@ def sufficient_teaching?
end

def common_eligible_later_attributes?
any_future_policy_years? && indicated_eligible_school?
any_future_combined_policy_years? && indicated_eligible_school?
end

def policy_end_year
policy::POLICY_END_YEAR
end

def any_future_policy_years?
claim_year < policy_end_year
end

def any_future_combined_policy_years?
claim_year < FINAL_COMBINED_ECP_AND_LUP_POLICY_YEAR
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def itt_subject_eligible_now?
end

def specific_ineligible_attributes?
trainee_teacher? || (induction_not_completed? && !ecp_only_school?) || itt_subject_ineligible_now_and_in_the_future?
trainee_teacher? || (induction_not_completed? && !any_future_policy_years?) || itt_subject_ineligible_now_and_in_the_future?
end

def itt_subject_ineligible_now_and_in_the_future?
Expand All @@ -55,7 +55,7 @@ def itt_subject_ineligible_now_and_in_the_future?
end

def specific_eligible_later_attributes?
newly_qualified_teacher? && ((induction_not_completed? && ecp_only_school?) || (!itt_subject_eligible_now? && itt_subject_eligible_later?))
newly_qualified_teacher? && ((induction_not_completed? && any_future_policy_years?) || (!itt_subject_eligible_now? && itt_subject_eligible_later?))
end

def itt_subject_eligible_later?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,13 @@ def personal_details_form
end

def replace_ecp_only_induction_not_completed_slugs(sequence)
dead_end_slug = (ecp_eligibility_checker.status == :eligible_later) ? "eligible-later" : "ineligible"

slugs = %w[
current-school
nqt-in-academic-year-after-itt
induction-completed
eligible-later
]
] << dead_end_slug

sequence.replace(slugs)
end
Expand Down
3 changes: 2 additions & 1 deletion app/models/journeys/get_a_teacher_relocation_payment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ module GetATeacherRelocationPayment
"visa" => VisaForm,
"entry-date" => EntryDateForm,
"nationality" => NationalityForm,
"passport-number" => PassportNumberForm
"passport-number" => PassportNumberForm,
"employment-details" => EmploymentDetailsForm
}
}
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ def identity_answers
end
end

def employment_answers
[].tap do |a|
a << school_headteacher_name
a << school_name
a << school_address_line_1
a << school_address_line_2 if answers.school_address_line_2.present?
a << school_city
a << school_postcode
end
end

private

def application_route
Expand Down Expand Up @@ -95,6 +106,54 @@ def passport_number
"passport-number"
]
end

def school_headteacher_name
[
t("get_a_teacher_relocation_payment.forms.employment_details.questions.school_headteacher_name"),
answers.school_headteacher_name,
"employment-details"
]
end

def school_name
[
t("get_a_teacher_relocation_payment.forms.employment_details.questions.school_name"),
answers.school_name,
"employment-details"
]
end

def school_address_line_1
[
t("get_a_teacher_relocation_payment.forms.employment_details.questions.school_address_line_1"),
answers.school_address_line_1,
"employment-details"
]
end

def school_address_line_2
[
t("get_a_teacher_relocation_payment.forms.employment_details.questions.school_address_line_2"),
answers.school_address_line_2,
"employment-details"
]
end

def school_city
[
t("get_a_teacher_relocation_payment.forms.employment_details.questions.school_city"),
answers.school_city,
"employment-details"
]
end

def school_postcode
[
t("get_a_teacher_relocation_payment.forms.employment_details.questions.school_postcode"),
answers.school_postcode,
"employment-details"
]
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ class SessionAnswers < Journeys::SessionAnswers
attribute :date_of_entry, :date
attribute :nationality, :string
attribute :passport_number, :string
attribute :school_headteacher_name, :string
attribute :school_name, :string
attribute :school_address_line_1, :string
attribute :school_address_line_2, :string
attribute :school_city, :string
attribute :school_postcode, :string

def policy
Policies::InternationalRelocationPayments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class SlugSequence
PERSONAL_DETAILS_SLUGS = [
"nationality",
"passport-number",
"employment-details",
"personal-details",
"postcode-search",
"select-home-address",
Expand Down
3 changes: 2 additions & 1 deletion app/models/policies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ module Policies
POLICIES = [
StudentLoans,
EarlyCareerPayments,
LevellingUpPremiumPayments
LevellingUpPremiumPayments,
InternationalRelocationPayments
].freeze

AMENDABLE_ELIGIBILITY_ATTRIBUTES = POLICIES.map do |policy|
Expand Down
9 changes: 1 addition & 8 deletions app/models/policies/early_career_payments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module EarlyCareerPayments
].freeze

POLICY_START_YEAR = AcademicYear.new(2021).freeze
POLICY_END_YEAR = AcademicYear.new(2024).freeze

# Used in
# - checking payments with multiple policies: ClaimsPreventingPaymentFinder
Expand All @@ -48,14 +49,6 @@ def notify_reply_to_id
"3f85a1f7-9400-4b48-9a31-eaa643d6b977"
end

def first_eligible_qts_award_year(claim_year = nil)
POLICY_START_YEAR
end

def last_ineligible_qts_award_year
first_eligible_qts_award_year - 1
end

def student_loan_balance_url
"https://www.gov.uk/sign-in-to-manage-your-student-loan-balance"
end
Expand Down
3 changes: 1 addition & 2 deletions app/models/policies/early_career_payments/eligibility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def policy
self.table_name = "early_career_payments_eligibilities"

FIRST_ITT_AY = "2016/2017"
LAST_POLICY_YEAR = "2024/2025"

# Generates an object similar to
# {
Expand All @@ -31,7 +30,7 @@ def policy
# and the enums would be stale until after a server restart.
# Make all valid ITT values based on the last known policy year.
ITT_ACADEMIC_YEARS =
(AcademicYear.new(FIRST_ITT_AY)...AcademicYear.new(LAST_POLICY_YEAR)).each_with_object({}) do |year, hsh|
(AcademicYear.new(FIRST_ITT_AY)...POLICY_END_YEAR).each_with_object({}) do |year, hsh|
hsh[year] = AcademicYear::Type.new.serialize(year)
end.merge({AcademicYear.new => AcademicYear::Type.new.serialize(AcademicYear.new)})

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Policies
module InternationalRelocationPayments
class AdminTasksPresenter
include Admin::PresenterMethods

attr_reader :claim

def initialize(claim)
@claim = claim
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,21 @@ module InternationalRelocationPayments
class Eligibility < ApplicationRecord
self.table_name = "international_relocation_payments_eligibilities"

AMENDABLE_ATTRIBUTES = %i[].freeze

has_one :claim, as: :eligibility, inverse_of: :eligibility

attr_accessor :teacher_reference_number

def award_amount
0
end

# No current_school attribute on the model. This method is for compatibility with the admin UI.
def current_school
nil
end

def ineligible?
false
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module Policies
module InternationalRelocationPayments
class EligibilityAdminAnswersPresenter
include Admin::PresenterMethods

attr_reader :eligibility

def initialize(eligibility)
@eligibility = eligibility
end

def answers
[].tap do |a|
a << current_school
end
end

private

def current_school
[
translate("admin.current_school"),
eligibility.current_school.present? ? display_school(eligibility.current_school) : "No"
]
end
end
end
end
5 changes: 4 additions & 1 deletion app/models/policies/levelling_up_premium_payments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ module LevellingUpPremiumPayments

SEARCHABLE_ELIGIBILITY_ATTRIBUTES = %w[teacher_reference_number].freeze

POLICY_START_YEAR = AcademicYear.new(2022).freeze
POLICY_END_YEAR = AcademicYear.new(2024).freeze

def notify_reply_to_id
"03ece7eb-2a5b-461b-9c91-6630d0051aa6"
end
Expand All @@ -33,7 +36,7 @@ def eligibility_page_url
end

def eligibility_criteria_url
eligibility_page_url + "#eligibility-criteria-for-teachers"
eligibility_page_url + "#eligibility-criteria"
end

def payment_and_deductions_info_url
Expand Down
Loading
Loading