Skip to content

Commit

Permalink
Merge pull request #3100 from DFE-Digital/fe-eligibility-fields
Browse files Browse the repository at this point in the history
LUPEYALPHA-862 copy session answers over to eligiblity model on submi…
  • Loading branch information
kenfodder authored Aug 16, 2024
2 parents e246920 + b17aea0 commit 6045556
Show file tree
Hide file tree
Showing 18 changed files with 324 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ class ClaimSubmissionForm < ::ClaimSubmissionBaseForm
private

def main_eligibility
@main_eligibility ||= Policies::FurtherEducationPayments::Eligibility.new(
teacher_reference_number: @journey_session.answers.teacher_reference_number
)
@main_eligibility ||= eligibilities.first
end

def calculate_award_amount(eligibility)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ module Journeys
module FurtherEducationPayments
class EligibleForm < Form
def save
true
journey_session.answers.assign_attributes(award_amount:)
journey_session.save!
end

def award_amount
journey_session.answers.award_amount
journey_session.answers.calculate_award_amount
end
end
end
Expand Down
6 changes: 5 additions & 1 deletion app/models/claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ class Claim < ApplicationRecord
dqt_teacher_status: false,
submitted_using_slc_data: false,
journeys_session_id: false,
column_to_remove_teacher_reference_number: true
column_to_remove_teacher_reference_number: true,
identity_confirmed_with_onelogin: false,
logged_in_with_onelogin: false,
onelogin_credentials: true,
onelogin_user_info: true
}.freeze
DECISION_DEADLINE = 12.weeks
DECISION_DEADLINE_WARNING_POINT = 2.weeks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class SessionAnswers < Journeys::SessionAnswers
attribute :subject_to_formal_performance_action, :boolean
attribute :subject_to_disciplinary_action, :boolean
attribute :half_teaching_hours, :boolean
attribute :award_amount, :decimal

def policy
Policies::FurtherEducationPayments
Expand Down Expand Up @@ -120,7 +121,7 @@ def less_than_half_hours_teaching_eligible_courses?
hours_teaching_eligible_subjects == false
end

def award_amount
def calculate_award_amount
case teaching_hours_per_week
when "more_than_12"
school.eligible_fe_provider.max_award_amount
Expand Down
6 changes: 6 additions & 0 deletions app/models/policies/further_education_payments/eligibility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ class Eligibility < ApplicationRecord

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

belongs_to :possible_school, optional: true, class_name: "School"
belongs_to :school, optional: true

# Claim#school expects this
alias_method :current_school, :school

def policy
Policies::FurtherEducationPayments
end
Expand Down
25 changes: 25 additions & 0 deletions config/analytics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ shared:
- qualifications_details_check
- submitted_using_slc_data
- journeys_session_id
- identity_confirmed_with_onelogin
- logged_in_with_onelogin
:decisions:
- id
- result
Expand Down Expand Up @@ -271,6 +273,29 @@ shared:
- created_at
- updated_at
- award_amount
- teaching_responsibilities
- provision_search
- possible_school_id
- school_id
- contract_type
- fixed_term_full_year
- taught_at_least_one_term
- teaching_hours_per_week
- teaching_hours_per_week_next_term
- further_education_teaching_start_year
- subjects_taught
- building_construction_courses
- chemistry_courses
- computing_courses
- early_years_courses
- engineering_manufacturing_courses
- maths_courses
- physics_courses
- hours_teaching_eligible_subjects
- teaching_qualification
- subject_to_formal_performance_action
- subject_to_disciplinary_action
- half_teaching_hours
:eligible_fe_providers:
- id
- ukprn
Expand Down
2 changes: 2 additions & 0 deletions config/analytics_blocklist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
- hmrc_bank_validation_responses
- dqt_teacher_status
- teacher_id_user_info
- onelogin_credentials
- onelogin_user_info
:claim_decisions:
- trn
- claimant_age
Expand Down
27 changes: 27 additions & 0 deletions db/migrate/20240814123634_add_answer_fields_to_fe_eligibilities.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class AddAnswerFieldsToFeEligibilities < ActiveRecord::Migration[7.0]
def change
add_column :further_education_payments_eligibilities, :teaching_responsibilities, :boolean
add_column :further_education_payments_eligibilities, :provision_search, :text
add_reference :further_education_payments_eligibilities, :possible_school, type: :uuid, foreign_key: {to_table: :schools}, index: {name: :index_fe_payments_eligibilities_on_possible_school_id}
add_reference :further_education_payments_eligibilities, :school, type: :uuid, foreign_key: {to_table: :schools}, index: {name: :index_fe_payments_eligibilities_on_school_id}
add_column :further_education_payments_eligibilities, :contract_type, :text
add_column :further_education_payments_eligibilities, :fixed_term_full_year, :boolean
add_column :further_education_payments_eligibilities, :taught_at_least_one_term, :boolean
add_column :further_education_payments_eligibilities, :teaching_hours_per_week, :text
add_column :further_education_payments_eligibilities, :teaching_hours_per_week_next_term, :text
add_column :further_education_payments_eligibilities, :further_education_teaching_start_year, :text
add_column :further_education_payments_eligibilities, :subjects_taught, :jsonb, default: []
add_column :further_education_payments_eligibilities, :building_construction_courses, :jsonb, default: []
add_column :further_education_payments_eligibilities, :chemistry_courses, :jsonb, default: []
add_column :further_education_payments_eligibilities, :computing_courses, :jsonb, default: []
add_column :further_education_payments_eligibilities, :early_years_courses, :jsonb, default: []
add_column :further_education_payments_eligibilities, :engineering_manufacturing_courses, :jsonb, default: []
add_column :further_education_payments_eligibilities, :maths_courses, :jsonb, default: []
add_column :further_education_payments_eligibilities, :physics_courses, :jsonb, default: []
add_column :further_education_payments_eligibilities, :hours_teaching_eligible_subjects, :boolean
add_column :further_education_payments_eligibilities, :teaching_qualification, :text
add_column :further_education_payments_eligibilities, :subject_to_formal_performance_action, :boolean
add_column :further_education_payments_eligibilities, :subject_to_disciplinary_action, :boolean
add_column :further_education_payments_eligibilities, :half_teaching_hours, :boolean
end
end
8 changes: 8 additions & 0 deletions db/migrate/20240816122950_add_onelogin_fields_to_claims.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class AddOneloginFieldsToClaims < ActiveRecord::Migration[7.0]
def change
add_column :claims, :identity_confirmed_with_onelogin, :boolean
add_column :claims, :logged_in_with_onelogin, :boolean
add_column :claims, :onelogin_credentials, :jsonb, default: {}
add_column :claims, :onelogin_user_info, :jsonb, default: {}
end
end
33 changes: 32 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2024_08_12_123209) do
ActiveRecord::Schema[7.0].define(version: 2024_08_16_122950) do
# These are extensions that must be enabled in order to support this database
enable_extension "citext"
enable_extension "pg_trgm"
Expand Down Expand Up @@ -98,6 +98,10 @@
t.boolean "submitted_using_slc_data", default: false
t.datetime "sent_one_time_password_at"
t.uuid "journeys_session_id"
t.boolean "identity_confirmed_with_onelogin"
t.boolean "logged_in_with_onelogin"
t.jsonb "onelogin_credentials", default: {}
t.jsonb "onelogin_user_info", default: {}
t.index ["academic_year"], name: "index_claims_on_academic_year"
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"
Expand Down Expand Up @@ -218,6 +222,31 @@
t.datetime "updated_at", null: false
t.decimal "award_amount", precision: 7, scale: 2
t.text "teacher_reference_number"
t.boolean "teaching_responsibilities"
t.text "provision_search"
t.uuid "possible_school_id"
t.uuid "school_id"
t.text "contract_type"
t.boolean "fixed_term_full_year"
t.boolean "taught_at_least_one_term"
t.text "teaching_hours_per_week"
t.text "teaching_hours_per_week_next_term"
t.text "further_education_teaching_start_year"
t.jsonb "subjects_taught", default: []
t.jsonb "building_construction_courses", default: []
t.jsonb "chemistry_courses", default: []
t.jsonb "computing_courses", default: []
t.jsonb "early_years_courses", default: []
t.jsonb "engineering_manufacturing_courses", default: []
t.jsonb "maths_courses", default: []
t.jsonb "physics_courses", default: []
t.boolean "hours_teaching_eligible_subjects"
t.text "teaching_qualification"
t.boolean "subject_to_formal_performance_action"
t.boolean "subject_to_disciplinary_action"
t.boolean "half_teaching_hours"
t.index ["possible_school_id"], name: "index_fe_payments_eligibilities_on_possible_school_id"
t.index ["school_id"], name: "index_fe_payments_eligibilities_on_school_id"
end

create_table "international_relocation_payments_eligibilities", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
Expand Down Expand Up @@ -520,6 +549,8 @@
add_foreign_key "decisions", "dfe_sign_in_users", column: "created_by_id"
add_foreign_key "early_career_payments_eligibilities", "schools", column: "current_school_id"
add_foreign_key "eligible_ey_providers", "local_authorities"
add_foreign_key "further_education_payments_eligibilities", "schools"
add_foreign_key "further_education_payments_eligibilities", "schools", column: "possible_school_id"
add_foreign_key "international_relocation_payments_eligibilities", "schools", column: "current_school_id"
add_foreign_key "levelling_up_premium_payments_eligibilities", "schools", column: "current_school_id"
add_foreign_key "notes", "claims"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,115 @@
FactoryBot.define do
factory :further_education_payments_answers, class: "Journeys::FurtherEducationPayments::SessionAnswers" do
trait :with_details_from_onelogin do
trait :with_name do
first_name { "Jo" }
surname { "Bloggs" }
onelogin_user_info { {email: "[email protected]"} }
end

trait :with_details_from_onelogin do
with_name
onelogin_user_info { {"email" => "[email protected]"} }
end

trait :with_onelogin_credentials do
onelogin_credentials { {"id_token" => "some_token"} }
end

trait :with_dob do
date_of_birth { 20.years.ago.to_date }
end

trait :with_nino do
national_insurance_number { generate(:national_insurance_number) }
end

trait :with_personal_details do
with_details_from_onelogin
with_dob
with_nino
end

trait :with_email_details do
email_address { generate(:email_address) }
email_verified { true }
end

trait :with_mobile_details do
mobile_number { "07474000123" }
provide_mobile_number { true }
mobile_verified { true }
end

trait :with_bank_details do
bank_or_building_society { :personal_bank_account }
banking_name { "Jo Bloggs" }
bank_sort_code { rand(100000..999999) }
bank_account_number { rand(10000000..99999999) }
end

trait :with_bank_details_validated do
hmrc_bank_validation_succeeded { true }
hmrc_bank_validation_responses do
[
{code: 200, body: "Test response"}
]
end
end

trait :with_payroll_gender do
payroll_gender { "female" }
end

trait :with_teacher_reference_number do
teacher_reference_number { generate(:teacher_reference_number) }
end

trait :permanent do
contract_type { "permanent" }
teaching_hours_per_week { "more_than_12" }
end

trait :with_academic_year do
academic_year { AcademicYear.current }
end

trait :eligible do
teaching_responsibilities { true }
school_id { create(:school, :further_education, :fe_eligible).id }
permanent
further_education_teaching_start_year { "2019" }
subjects_taught { ["maths", "physics"] }
maths_courses { ["approved_level_321_maths", "gcse_maths"] }
physics_courses { ["gcse_physics"] }
hours_teaching_eligible_subjects { true }
half_teaching_hours { true }
teaching_qualification { "yes" }
subject_to_formal_performance_action { false }
subject_to_disciplinary_action { false }
end

trait :with_award_amount do
award_amount { 4_000.0 }
end

trait :with_address do
address_line_1 { "1 Test Road" }
address_line_2 { "Some Second Line" }
address_line_3 { "Some Town" }
address_line_4 { "Some County" }
postcode { "WIA OAA" }
end

trait :submittable do
# FIXME implement this trait with the details required to submit a claim
with_academic_year
eligible
with_award_amount
with_personal_details
with_address
with_email_details
with_mobile_details
with_bank_details
with_bank_details_validated
with_payroll_gender
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
qualifications_details_check { true }
end

trait :with_acadmic_year do
trait :with_academic_year do
academic_year { AcademicYear.new(2019) }
end

Expand Down Expand Up @@ -105,7 +105,7 @@
with_leadership_position
with_qts_award_year
with_qualification_details_check
with_acadmic_year
with_academic_year
with_student_loan
with_student_loan_repayment_amount
end
Expand Down
Loading

0 comments on commit 6045556

Please sign in to comment.