diff --git a/app/controllers/claims_form_callbacks.rb b/app/controllers/claims_form_callbacks.rb index 356a54218c..36bf4a7e0f 100644 --- a/app/controllers/claims_form_callbacks.rb +++ b/app/controllers/claims_form_callbacks.rb @@ -121,7 +121,7 @@ def on_tid_route? end def journey_requires_student_loan_details? - student_loans_journey? || additional_payments_journey? || get_a_teacher_relocation_payment_journey? || further_education_payments_journey? + student_loans_journey? || additional_payments_journey? || get_a_teacher_relocation_payment_journey? || further_education_payments_journey? || early_years_payments_practitioner_journey? end def student_loans_journey? @@ -139,4 +139,8 @@ def get_a_teacher_relocation_payment_journey? def further_education_payments_journey? current_journey_routing_name == "further-education-payments" end + + def early_years_payments_practitioner_journey? + current_journey_routing_name == "early-years-payment-practitioner" + end end diff --git a/app/jobs/student_loan_plan_check_job.rb b/app/jobs/student_loan_plan_check_job.rb index 7289e33700..8c69e01f9b 100644 --- a/app/jobs/student_loan_plan_check_job.rb +++ b/app/jobs/student_loan_plan_check_job.rb @@ -2,7 +2,8 @@ class StudentLoanPlanCheckJob < ApplicationJob APPLICABLE_POLICIES = [ Policies::EarlyCareerPayments, Policies::LevellingUpPremiumPayments, - Policies::FurtherEducationPayments + Policies::FurtherEducationPayments, + Policies::EarlyYearsPayments ].freeze def perform diff --git a/app/models/claim_checking_tasks.rb b/app/models/claim_checking_tasks.rb index 04e6d9ee51..c7c74fae94 100644 --- a/app/models/claim_checking_tasks.rb +++ b/app/models/claim_checking_tasks.rb @@ -30,6 +30,10 @@ def applicable_task_names Policies::InternationalRelocationPayments::ClaimCheckingTasks .new(claim) .applicable_task_names + when Policies::EarlyYearsPayments + Policies::EarlyYearsPayments::ClaimCheckingTasks + .new(claim) + .applicable_task_names else Task::NAMES.dup.tap do |task_names| task_names.delete("previous_payment") diff --git a/app/models/journeys/early_years_payment/practitioner/answers_student_loans_details_updater.rb b/app/models/journeys/early_years_payment/practitioner/answers_student_loans_details_updater.rb new file mode 100644 index 0000000000..2a4bdc7c84 --- /dev/null +++ b/app/models/journeys/early_years_payment/practitioner/answers_student_loans_details_updater.rb @@ -0,0 +1,8 @@ +module Journeys + module EarlyYearsPayment + module Practitioner + class AnswersStudentLoansDetailsUpdater < Journeys::AnswersStudentLoansDetailsUpdater + end + end + end +end diff --git a/app/models/policies/early_years_payments.rb b/app/models/policies/early_years_payments.rb index 13624c2577..5092975df9 100644 --- a/app/models/policies/early_years_payments.rb +++ b/app/models/policies/early_years_payments.rb @@ -7,7 +7,7 @@ module EarlyYearsPayments MIN_QA_THRESHOLD = 10 VERIFIERS = [ - AutomatedChecks::ClaimVerifiers::StudentLoanPlan # TODO - spec + AutomatedChecks::ClaimVerifiers::StudentLoanPlan ] # Attributes to delete from claims submitted before the current academic @@ -56,8 +56,6 @@ module EarlyYearsPayments LevellingUpPremiumPayments ] - VERIFIERS = [] - # TODO: This is needed once the reply-to email address has been added to Gov Notify def notify_reply_to_id nil @@ -66,5 +64,9 @@ def notify_reply_to_id def award_amount 1_000 end + + def auto_check_student_loan_plan_task? + true + end end end diff --git a/app/models/policies/early_years_payments/admin_tasks_presenter.rb b/app/models/policies/early_years_payments/admin_tasks_presenter.rb index f45a049c0a..c98989650b 100644 --- a/app/models/policies/early_years_payments/admin_tasks_presenter.rb +++ b/app/models/policies/early_years_payments/admin_tasks_presenter.rb @@ -15,6 +15,12 @@ def employment ["Start date", l(claim.eligibility.start_date)] ] end + + def student_loan_plan + [ + ["Student loan plan", claim.student_loan_plan&.humanize] + ] + end end end end diff --git a/app/models/policies/early_years_payments/claim_checking_tasks.rb b/app/models/policies/early_years_payments/claim_checking_tasks.rb new file mode 100644 index 0000000000..48e68f199e --- /dev/null +++ b/app/models/policies/early_years_payments/claim_checking_tasks.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +module Policies + module EarlyYearsPayments + class ClaimCheckingTasks + attr_reader :claim + + def initialize(claim) + @claim = claim + end + + delegate :policy, to: :claim + + def applicable_task_names + tasks = [] + + tasks << "student_loan_plan" if claim.submitted_without_slc_data? + tasks << "matching_details" if matching_claims.exists? + + tasks + end + + private + + def matching_claims + @matching_claims ||= Claim::MatchingAttributeFinder.new(claim).matching_claims + end + end + end +end diff --git a/spec/features/admin/upload_slc_data_spec.rb b/spec/features/admin/upload_slc_data_spec.rb index 782cb8a366..c8582bf408 100644 --- a/spec/features/admin/upload_slc_data_spec.rb +++ b/spec/features/admin/upload_slc_data_spec.rb @@ -5,6 +5,7 @@ create(:journey_configuration, :student_loans) # used by StudentLoanAmountCheckJob create(:journey_configuration, :early_career_payments) create(:journey_configuration, :further_education_payments) + create(:journey_configuration, :early_years_payment_provider_start) sign_in_as_service_operator end diff --git a/spec/features/early_years_payment/practitioner/email_address_spec.rb b/spec/features/early_years_payment/practitioner/email_address_spec.rb index d28fbc1da6..54f2f8129c 100644 --- a/spec/features/early_years_payment/practitioner/email_address_spec.rb +++ b/spec/features/early_years_payment/practitioner/email_address_spec.rb @@ -6,7 +6,7 @@ :claim, policy: Policies::EarlyYearsPayments, reference: "foo", - practitioner_email_address: "user@example.com" + practitioner_email_address: "practitioner@example.com" ) end let(:otp_code) { "123456" } diff --git a/spec/features/early_years_payment/practitioner/happy_path_spec.rb b/spec/features/early_years_payment/practitioner/happy_path_spec.rb index bcefb28287..28541dc192 100644 --- a/spec/features/early_years_payment/practitioner/happy_path_spec.rb +++ b/spec/features/early_years_payment/practitioner/happy_path_spec.rb @@ -9,6 +9,7 @@ let(:claim) { Claim.last } scenario "Happy path" do + when_student_loan_data_exists when_early_years_payment_provider_authenticated_journey_submitted when_early_years_payment_practitioner_journey_configuration_exists @@ -83,6 +84,7 @@ expect(claim.eligibility.practitioner_claim_started_at).to be_present expect(claim.reload.submitted_at).to be_present + expect(claim.student_loan_plan).to eq "plan_1" # check answers were saved on the claim expect(claim.reload.national_insurance_number).to eq "PX321499A" diff --git a/spec/features/early_years_payment/practitioner/mobile_number_spec.rb b/spec/features/early_years_payment/practitioner/mobile_number_spec.rb index 7b0473700d..0786f3120c 100644 --- a/spec/features/early_years_payment/practitioner/mobile_number_spec.rb +++ b/spec/features/early_years_payment/practitioner/mobile_number_spec.rb @@ -6,7 +6,7 @@ :claim, policy: Policies::EarlyYearsPayments, reference: "foo", - practitioner_email_address: "user@example.com" + practitioner_email_address: "practitioner@example.com" ) end let(:otp_code) { "123456" } diff --git a/spec/features/early_years_payment/practitioner/student_loan_spec.rb b/spec/features/early_years_payment/practitioner/student_loan_spec.rb new file mode 100644 index 0000000000..1f2c483e8e --- /dev/null +++ b/spec/features/early_years_payment/practitioner/student_loan_spec.rb @@ -0,0 +1,36 @@ +require "rails_helper" + +RSpec.feature "Early Years Payments Student Loan Plan" do + include ActionView::Helpers::NumberHelper + + let(:claim) { Claim.last } + let(:magic_link) { mail[:personalisation].unparsed_value[:magic_link] } + let(:mail) { ActionMailer::Base.deliveries.last } + + scenario "student loan data does not exist on submission" do + when_early_years_practitioner_claim_submitted + + expect(claim.reload.submitted_using_slc_data).to be false + expect(claim.tasks.where(name: "student_loan_plan")).to be_empty + + sign_in_as_service_operator + + visit admin_claim_tasks_path(claim) + within "li.student_loan_plan" do + expect(page).to have_content "Incomplete" + end + end + + scenario "student loan data does exist on submission" do + when_student_loan_data_exists + when_early_years_practitioner_claim_submitted + + expect(claim.reload.submitted_using_slc_data).to be true + expect(claim.reload.student_loan_plan).to eq "plan_1" + + sign_in_as_service_operator + + visit admin_claim_tasks_path(claim) + expect(page).not_to have_content "Student loan plan" + end +end diff --git a/spec/jobs/student_loan_plan_check_job_spec.rb b/spec/jobs/student_loan_plan_check_job_spec.rb index 4055bd74ee..4e6fe5ed43 100644 --- a/spec/jobs/student_loan_plan_check_job_spec.rb +++ b/spec/jobs/student_loan_plan_check_job_spec.rb @@ -5,6 +5,7 @@ before do create(:journey_configuration, :further_education_payments) + create(:journey_configuration, :early_years_payment_provider_start) end let!(:claim) { create(:claim, claim_status, academic_year:, policy: Policies::LevellingUpPremiumPayments) } @@ -23,6 +24,15 @@ end end + it "includes all applicable policies" do + expect(StudentLoanPlanCheckJob::APPLICABLE_POLICIES).to eq [ + Policies::EarlyCareerPayments, + Policies::LevellingUpPremiumPayments, + Policies::FurtherEducationPayments, + Policies::EarlyYearsPayments + ] + end + context "when the previous student loan plan check was run manually" do # not sure it's possible to do this any more let!(:previous_task) { create(:task, claim: claim, name: "student_loan_plan", claim_verifier_match: nil, manual: true) } diff --git a/spec/requests/admin/admin_student_loans_data_upload_spec.rb b/spec/requests/admin/admin_student_loans_data_upload_spec.rb index f3a7645682..2760a97fa6 100644 --- a/spec/requests/admin/admin_student_loans_data_upload_spec.rb +++ b/spec/requests/admin/admin_student_loans_data_upload_spec.rb @@ -4,6 +4,7 @@ let!(:journey_configuration_tslr) { create(:journey_configuration, :student_loans) } let!(:journey_configuration_ecp_lupp) { create(:journey_configuration, :additional_payments) } let!(:journey_configuration_fe) { create(:journey_configuration, :further_education_payments) } + let!(:journey_configuration_ey) { create(:journey_configuration, :early_years_payment_provider_start) } before { @signed_in_user = sign_in_as_service_operator } diff --git a/spec/support/admin_view_claim_feature_shared_examples.rb b/spec/support/admin_view_claim_feature_shared_examples.rb index 7f07e8bf40..d18b84f57c 100644 --- a/spec/support/admin_view_claim_feature_shared_examples.rb +++ b/spec/support/admin_view_claim_feature_shared_examples.rb @@ -163,7 +163,7 @@ def expect_page_to_have_policy_sections(policy) when Policies::FurtherEducationPayments ["Identity confirmation", "Provider verification", "Student loan plan", "Decision"] when Policies::EarlyYearsPayments - ["Identity confirmation", "Qualifications", "Census subjects taught", "Employment", "Decision"] + ["Student loan plan", "Decision"] else raise "Unimplemented policy: #{policy}" end diff --git a/spec/support/steps/early_years_practitioner_journey.rb b/spec/support/steps/early_years_practitioner_journey.rb index ce4ab3047a..372d6295c4 100644 --- a/spec/support/steps/early_years_practitioner_journey.rb +++ b/spec/support/steps/early_years_practitioner_journey.rb @@ -1,5 +1,5 @@ def when_personal_details_entered_up_to_address - visit "/early-years-payment-practitioner/find-reference?skip_landing_page=true&email=user@example.com" + visit "/early-years-payment-practitioner/find-reference?skip_landing_page=true&email=practitioner@example.com" fill_in "Claim reference number", with: claim.reference click_button "Submit" @@ -35,3 +35,22 @@ def when_personal_details_entered_up_to_email_address fill_in "claim-one-time-password-field", with: otp_in_mail_sent click_on "Confirm" end + +def when_early_years_practitioner_claim_submitted + when_early_years_payment_practitioner_journey_configuration_exists + when_early_years_payment_provider_authenticated_journey_submitted + when_personal_details_entered_up_to_email_address + + choose "No" + click_on "Continue" + + fill_in "Name on your account", with: "Jo Bloggs" + fill_in "Sort code", with: "123456" + fill_in "Account number", with: "87654321" + click_on "Continue" + + choose "Female" + click_on "Continue" + + perform_enqueued_jobs { click_on "Accept and send" } +end diff --git a/spec/support/steps/early_years_provider_journey_authenticated.rb b/spec/support/steps/early_years_provider_journey_authenticated.rb index 9a021d3785..1169c3010e 100644 --- a/spec/support/steps/early_years_provider_journey_authenticated.rb +++ b/spec/support/steps/early_years_provider_journey_authenticated.rb @@ -1,4 +1,6 @@ def when_early_years_payment_provider_authenticated_journey_ready_to_submit + nursery = EligibleEyProvider.last || create(:eligible_ey_provider, primary_key_contact_email_address: "johndoe@example.com") + visit magic_link check "I confirm that I have obtained consent from my employee and have provided them with the relevant privacy notice." click_button "Continue" diff --git a/spec/support/steps/eligible_ey_providers.rb b/spec/support/steps/eligible_ey_providers.rb index dbae816c4f..6feae8447d 100644 --- a/spec/support/steps/eligible_ey_providers.rb +++ b/spec/support/steps/eligible_ey_providers.rb @@ -1,3 +1,3 @@ def when_eligible_ey_provider_exists - create(:eligible_ey_provider, primary_key_contact_email_address: "johndoe@example.com", secondary_contact_email_address: "janedoe@example.com") + create(:eligible_ey_provider, primary_key_contact_email_address: "johndoe@example.com", secondary_contact_email_address: "janedoe@example.com") unless EligibleEyProvider.any? end