From 982a62310a1fb338651fda746bd1e4e9232deb53 Mon Sep 17 00:00:00 2001 From: Alkesh Vaghmaria Date: Wed, 11 Sep 2024 09:33:49 +0100 Subject: [PATCH] Set student loan plan for claim when it exists in student loan data for FE --- app/controllers/claims_form_callbacks.rb | 6 +- app/jobs/student_loan_plan_check_job.rb | 22 ++- app/models/claim.rb | 3 +- .../claim/claims_awaiting_decision_finder.rb | 31 +++ .../answers_student_loans_details_updater.rb | 6 + .../claim_checking_tasks.rb | 2 +- spec/features/admin/upload_slc_data_spec.rb | 184 ++++++++++-------- .../happy_path_spec.rb | 2 + spec/jobs/student_loan_plan_check_job_spec.rb | 37 +++- .../claims_awaiting_decision_finder_spec.rb | 34 ++++ spec/models/claim_checking_tasks_spec.rb | 4 +- spec/models/claim_spec.rb | 3 +- .../admin_student_loans_data_upload_spec.rb | 1 + spec/support/steps/student_loan_data.rb | 3 + 14 files changed, 243 insertions(+), 95 deletions(-) create mode 100644 app/models/claim/claims_awaiting_decision_finder.rb create mode 100644 app/models/journeys/further_education_payments/answers_student_loans_details_updater.rb create mode 100644 spec/models/claim/claims_awaiting_decision_finder_spec.rb create mode 100644 spec/support/steps/student_loan_data.rb diff --git a/app/controllers/claims_form_callbacks.rb b/app/controllers/claims_form_callbacks.rb index 3afc56eef0..49ac10bdb6 100644 --- a/app/controllers/claims_form_callbacks.rb +++ b/app/controllers/claims_form_callbacks.rb @@ -125,7 +125,7 @@ def on_tid_route? end def journey_requires_student_loan_details? - student_loans_journey? || additional_payments_journey? || get_a_teacher_relocation_payment_journey? + student_loans_journey? || additional_payments_journey? || get_a_teacher_relocation_payment_journey? || further_education_payments_journey? end def student_loans_journey? @@ -139,4 +139,8 @@ def additional_payments_journey? def get_a_teacher_relocation_payment_journey? current_journey_routing_name == "get-a-teacher-relocation-payment" end + + def further_education_payments_journey? + current_journey_routing_name == "further-education-payments" + end end diff --git a/app/jobs/student_loan_plan_check_job.rb b/app/jobs/student_loan_plan_check_job.rb index c283cc2a2d..7289e33700 100644 --- a/app/jobs/student_loan_plan_check_job.rb +++ b/app/jobs/student_loan_plan_check_job.rb @@ -1,7 +1,13 @@ class StudentLoanPlanCheckJob < ApplicationJob + APPLICABLE_POLICIES = [ + Policies::EarlyCareerPayments, + Policies::LevellingUpPremiumPayments, + Policies::FurtherEducationPayments + ].freeze + def perform delete_no_data_student_loan_plan_tasks - claims = current_year_ecp_lup_fe_claims_awaiting_decision.awaiting_task("student_loan_plan") + claims = current_year_claims_awaiting_decision.awaiting_task("student_loan_plan") claims.each do |claim| ClaimStudentLoanDetailsUpdater.call(claim) AutomatedChecks::ClaimVerifiers::StudentLoanPlan.new(claim:).perform @@ -11,22 +17,18 @@ def perform private def delete_no_data_student_loan_plan_tasks - claim_ids = current_year_ecp_lup_claims_with_no_data_tasks.pluck(:id) + claim_ids = current_year_claims_with_no_data_tasks.pluck(:id) claim_ids.each_slice(500) do |ids| Task.where(claim_id: ids, name: "student_loan_plan", claim_verifier_match: nil, manual: false).delete_all end end - def current_year_ecp_lup_claims_with_no_data_tasks - current_year_ecp_lup_fe_claims_awaiting_decision.joins(:tasks).where(tasks: {name: "student_loan_plan", claim_verifier_match: nil, manual: false}) - end - - def current_year_ecp_lup_fe_claims_awaiting_decision - Claim.by_academic_year(current_academic_year).by_policies([Policies::EarlyCareerPayments, Policies::LevellingUpPremiumPayments, Policies::FurtherEducationPayments]).awaiting_decision.where(submitted_using_slc_data: false) + def current_year_claims_with_no_data_tasks + current_year_claims_awaiting_decision.joins(:tasks).where(tasks: {name: "student_loan_plan", claim_verifier_match: nil, manual: false}) end - def current_academic_year - Journeys.for_policy(Policies::EarlyCareerPayments).configuration.current_academic_year + def current_year_claims_awaiting_decision + Claim::ClaimsAwaitingDecisionFinder.new(policies: APPLICABLE_POLICIES).claims_submitted_without_slc_data end end diff --git a/app/models/claim.rb b/app/models/claim.rb index 85334cca6b..14f8ad26d4 100644 --- a/app/models/claim.rb +++ b/app/models/claim.rb @@ -418,7 +418,8 @@ def must_manually_validate_bank_details? end def submitted_without_slc_data? - submitted_using_slc_data == false + # FE claims prior to the deployment of LUPEYALPHA-1010 have submitted_using_slc_data = nil + submitted_using_slc_data != true end def has_dqt_record? diff --git a/app/models/claim/claims_awaiting_decision_finder.rb b/app/models/claim/claims_awaiting_decision_finder.rb new file mode 100644 index 0000000000..22c92f7ad6 --- /dev/null +++ b/app/models/claim/claims_awaiting_decision_finder.rb @@ -0,0 +1,31 @@ +class Claim + class ClaimsAwaitingDecisionFinder + def initialize(policies:) + @policies = policies + end + + attr_reader :policies + + def claims_submitted_without_slc_data + policies.map do |policy| + journey_configuration = Journeys.for_policy(policy).configuration + Claim + .by_academic_year(journey_configuration.current_academic_year) + .by_policy(policy) + .awaiting_decision + .where(submitted_using_slc_data: submitted_using_slc_data(policy)) + end.reduce(&:or) + end + + private + + def submitted_using_slc_data(policy) + if policy == Policies::FurtherEducationPayments + # For 2024/2025 academic year onwards, only FE claims prior to the deployment of LUPEYALPHA-1010 have submitted_using_slc_data = nil + [false, nil] + else + false + end + end + end +end diff --git a/app/models/journeys/further_education_payments/answers_student_loans_details_updater.rb b/app/models/journeys/further_education_payments/answers_student_loans_details_updater.rb new file mode 100644 index 0000000000..7f5fd8b70b --- /dev/null +++ b/app/models/journeys/further_education_payments/answers_student_loans_details_updater.rb @@ -0,0 +1,6 @@ +module Journeys + module FurtherEducationPayments + class AnswersStudentLoansDetailsUpdater < Journeys::AnswersStudentLoansDetailsUpdater + end + end +end diff --git a/app/models/policies/further_education_payments/claim_checking_tasks.rb b/app/models/policies/further_education_payments/claim_checking_tasks.rb index 92418c97eb..f6159a4ff5 100644 --- a/app/models/policies/further_education_payments/claim_checking_tasks.rb +++ b/app/models/policies/further_education_payments/claim_checking_tasks.rb @@ -17,7 +17,7 @@ def applicable_task_names tasks << "identity_confirmation" tasks << "provider_verification" tasks << "employment" if claim.eligibility.teacher_reference_number.present? - tasks << "student_loan_plan" + tasks << "student_loan_plan" if claim.submitted_without_slc_data? tasks << "payroll_details" if claim.must_manually_validate_bank_details? tasks << "matching_details" if matching_claims.exists? tasks << "payroll_gender" if claim.payroll_gender_missing? diff --git a/spec/features/admin/upload_slc_data_spec.rb b/spec/features/admin/upload_slc_data_spec.rb index 1b5c750288..3bb76ee5fe 100644 --- a/spec/features/admin/upload_slc_data_spec.rb +++ b/spec/features/admin/upload_slc_data_spec.rb @@ -39,14 +39,36 @@ eligibility: build(:early_career_payments_eligibility, :eligible), has_student_loan: false, student_loan_plan: "not_applicable", submitted_using_slc_data: false) } - let!(:fe_claim_no_student_loan_plan_no_slc_data) { - create(:claim, :submitted, policy: Policies::FurtherEducationPayments, eligibility: build(:further_education_payments_eligibility, :eligible), has_student_loan: nil, student_loan_plan: nil) + + let!(:fe_claim_with_slc_data_no_student_loan_nil_submitted_using_slc_data) { + create(:claim, :submitted, policy: Policies::FurtherEducationPayments, + eligibility: build(:further_education_payments_eligibility, :eligible), + has_student_loan: nil, student_loan_plan: nil, submitted_using_slc_data: nil) # having nil submitted_using_slc_data won't happen after LUPEYALPHA-1010 merged + } + let!(:fe_claim_with_slc_data_with_student_loan_nil_submitted_using_slc_data) { + create(:claim, :submitted, policy: Policies::FurtherEducationPayments, + eligibility: build(:further_education_payments_eligibility, :eligible), + has_student_loan: nil, student_loan_plan: nil, submitted_using_slc_data: nil) # having nil submitted_using_slc_data won't happen after LUPEYALPHA-1010 merged } - let!(:fe_claim_no_student_loan_plan_in_slc_data) { - create(:claim, :submitted, policy: Policies::FurtherEducationPayments, eligibility: build(:further_education_payments_eligibility, :eligible), has_student_loan: nil, student_loan_plan: nil) + let!(:fe_claim_no_slc_data_nil_submitted_using_slc_data) { + create(:claim, :submitted, :with_student_loan, policy: Policies::FurtherEducationPayments, + eligibility: build(:further_education_payments_eligibility, :eligible), + has_student_loan: nil, student_loan_plan: nil, submitted_using_slc_data: nil) # having nil submitted_using_slc_data won't happen after LUPEYALPHA-1010 merged } - let!(:fe_claim_not_in_data_file) { - create(:claim, :submitted, :with_student_loan, policy: Policies::FurtherEducationPayments, eligibility: build(:further_education_payments_eligibility, :eligible)) + let!(:fe_claim_with_slc_data_no_student_loan) { + create(:claim, :submitted, policy: Policies::FurtherEducationPayments, + eligibility: build(:further_education_payments_eligibility, :eligible), + has_student_loan: nil, student_loan_plan: nil, submitted_using_slc_data: false) + } + let!(:fe_claim_with_slc_data_with_student_loan) { + create(:claim, :submitted, policy: Policies::FurtherEducationPayments, + eligibility: build(:further_education_payments_eligibility, :eligible), + has_student_loan: nil, student_loan_plan: nil, submitted_using_slc_data: false) + } + let!(:fe_claim_no_slc_data) { + create(:claim, :submitted, :with_student_loan, policy: Policies::FurtherEducationPayments, + eligibility: build(:further_education_payments_eligibility, :eligible), + has_student_loan: nil, student_loan_plan: nil, submitted_using_slc_data: false) } scenario "automated task to verify student loan plan" do @@ -57,94 +79,96 @@ click_button "Upload" end expect(page).to have_content "SLC file uploaded and queued to be imported" - expect(StudentLoansData.count).to eq 4 + expect(StudentLoansData.count).to eq 8 # Student Loans - click_link sl_claim_with_slc_data_no_student_loan.reference - expect(page).to have_content "Student loan amount" - within "li.student_loan_amount" do - expect(page).to have_content "No match" - end - expect(sl_claim_with_slc_data_no_student_loan.reload.student_loan_plan).to eq "not_applicable" - expect(sl_claim_with_slc_data_no_student_loan.has_student_loan).to be false - expect(sl_claim_with_slc_data_no_student_loan.eligibility.student_loan_repayment_amount).to eq 0 - - visit admin_claims_path - click_link ecp_claim_with_slc_data_with_student_loan.reference - expect(page).not_to have_content "Student loan amount" - expect(sl_claim_with_slc_data_with_student_loan.reload.student_loan_plan).to eq "plan_1" - expect(sl_claim_with_slc_data_with_student_loan.has_student_loan).to eq true - expect(sl_claim_with_slc_data_with_student_loan.eligibility.student_loan_repayment_amount).to eq 100 + claim = sl_claim_with_slc_data_no_student_loan + then_the_student_loan_amount_task_should_show_as(state: "No match", for_claim: claim) + expect(claim.reload.student_loan_plan).to eq "not_applicable" + expect(claim.has_student_loan).to be false + expect(claim.eligibility.student_loan_repayment_amount).to eq 0 + claim = sl_claim_with_slc_data_with_student_loan visit admin_claims_path - click_link sl_claim_no_slc_data.reference - expect(page).to have_content "Student loan amount" - within "li.student_loan_amount" do - expect(page).to have_content "No data" - end - expect(sl_claim_no_slc_data.reload.student_loan_plan).to be nil - expect(sl_claim_no_slc_data.has_student_loan).to be nil - expect(sl_claim_no_slc_data.eligibility.student_loan_repayment_amount).to eq 0 + click_link claim.reference + then_the_student_loan_amount_task_should_show_as(state: "Passed", for_claim: claim) + expect(claim.reload.student_loan_plan).to eq "plan_1" + expect(claim.has_student_loan).to eq true + expect(claim.eligibility.student_loan_repayment_amount).to eq 100 + + claim = sl_claim_no_slc_data + then_the_student_loan_amount_task_should_show_as(state: "No data", for_claim: claim) + expect(claim.reload.student_loan_plan).to be nil + expect(claim.has_student_loan).to be nil + expect(claim.eligibility.student_loan_repayment_amount).to eq 0 # Early Career Payments - visit admin_claims_path - click_link ecp_claim_with_slc_data_no_student_loan.reference - expect(page).to have_content "Student loan plan" - within "li.student_loan_plan" do - expect(page).to have_content "Passed" - end - expect(ecp_claim_with_slc_data_no_student_loan.reload.student_loan_plan).to eq "not_applicable" - expect(ecp_claim_with_slc_data_no_student_loan.has_student_loan).to be false + claim = ecp_claim_with_slc_data_no_student_loan + then_the_student_loan_plan_task_should_show_as(state: "Passed", for_claim: claim) + expect(claim.reload.student_loan_plan).to eq "not_applicable" + expect(claim.has_student_loan).to be false + + claim = ecp_claim_with_slc_data_with_student_loan + then_the_student_loan_plan_task_should_show_as(state: "Passed", for_claim: claim) + expect(claim.reload.student_loan_plan).to eq "plan_1" + expect(claim.has_student_loan).to eq true + + claim = ecp_claim_no_slc_data + then_the_student_loan_plan_task_should_show_as(state: "No data", for_claim: claim) + expect(claim.reload.student_loan_plan).to be nil # this was "not_applicable" before LUPEYALPHA-1031 + expect(claim.has_student_loan).to be nil # this was false before LUPEYALPHA-1031 + + # Further Education Payments + + claim = fe_claim_with_slc_data_no_student_loan_nil_submitted_using_slc_data + then_the_student_loan_plan_task_should_show_as(state: "Passed", for_claim: claim) + expect(claim.reload.student_loan_plan).to eq "not_applicable" + expect(claim.has_student_loan).to eq false + + claim = fe_claim_with_slc_data_with_student_loan_nil_submitted_using_slc_data + then_the_student_loan_plan_task_should_show_as(state: "Passed", for_claim: claim) + expect(claim.reload.student_loan_plan).to eq "plan_1" + expect(claim.has_student_loan).to eq true + + claim = fe_claim_no_slc_data_nil_submitted_using_slc_data + then_the_student_loan_plan_task_should_show_as(state: "No data", for_claim: claim) + expect(claim.reload.student_loan_plan).to be nil + expect(claim.has_student_loan).to be nil + + claim = fe_claim_with_slc_data_no_student_loan + then_the_student_loan_plan_task_should_show_as(state: "Passed", for_claim: claim) + expect(claim.reload.student_loan_plan).to eq "not_applicable" + expect(claim.has_student_loan).to eq false + + claim = fe_claim_with_slc_data_with_student_loan + then_the_student_loan_plan_task_should_show_as(state: "Passed", for_claim: claim) + expect(claim.reload.student_loan_plan).to eq "plan_1" + expect(claim.has_student_loan).to eq true + + claim = fe_claim_no_slc_data + then_the_student_loan_plan_task_should_show_as(state: "No data", for_claim: claim) + expect(claim.reload.student_loan_plan).to be nil + expect(claim.has_student_loan).to be nil + end + def then_the_student_loan_amount_task_should_show_as(state:, for_claim:) visit admin_claims_path - click_link ecp_claim_with_slc_data_with_student_loan.reference - expect(page).to have_content "Student loan plan" - within "li.student_loan_plan" do - expect(page).to have_content "Passed" + click_link for_claim.reference + expect(page).to have_content "Student loan amount" + within "li.student_loan_amount" do + expect(page).to have_content state end - expect(ecp_claim_with_slc_data_with_student_loan.reload.student_loan_plan).to eq "plan_1" - expect(ecp_claim_with_slc_data_with_student_loan.has_student_loan).to eq true + end + def then_the_student_loan_plan_task_should_show_as(state:, for_claim:) visit admin_claims_path - click_link ecp_claim_no_slc_data.reference + click_link for_claim.reference expect(page).to have_content "Student loan plan" within "li.student_loan_plan" do - expect(page).to have_content "No data" + expect(page).to have_content state end - expect(ecp_claim_no_slc_data.reload.student_loan_plan).to be nil # this was "not_applicable" before LUPEYALPHA-1031 - expect(ecp_claim_no_slc_data.has_student_loan).to be nil # this was false before LUPEYALPHA-1031 - - # FE - - visit admin_claims_path - click_link fe_claim_no_student_loan_plan_no_slc_data.reference - within "li.student_loan_plan" do - expect(page).to have_content "Failed" # is this right? - end - expect(fe_claim_no_student_loan_plan_no_slc_data.reload.student_loan_plan).to eq "not_applicable" - expect(fe_claim_no_student_loan_plan_no_slc_data.has_student_loan).to eq true # doesn't seem right - legacy attribute - expect(fe_claim_no_student_loan_plan_no_slc_data.submitted_using_slc_data).to be false - - visit admin_claims_path - click_link fe_claim_no_student_loan_plan_in_slc_data.reference - within "li.student_loan_plan" do - expect(page).to have_content "Passed" - end - expect(fe_claim_no_student_loan_plan_in_slc_data.reload.student_loan_plan).to eq "plan_1" - expect(fe_claim_no_student_loan_plan_in_slc_data.has_student_loan).to eq true - expect(fe_claim_no_student_loan_plan_in_slc_data.submitted_using_slc_data).to be false - - visit admin_claims_path - click_link fe_claim_not_in_data_file.reference - within "li.student_loan_plan" do - expect(page).to have_content "No data" - end - expect(fe_claim_not_in_data_file.reload.student_loan_plan).to eq "not_applicable" - expect(fe_claim_not_in_data_file.has_student_loan).to eq false - expect(fe_claim_not_in_data_file.submitted_using_slc_data).to be false - end def slc_data_csv_file @@ -156,6 +180,10 @@ def slc_data_csv_file @slc_data_csv_file.write csv_row(sl_claim_with_slc_data_with_student_loan, plan_type: "1", amount: "100") @slc_data_csv_file.write csv_row(ecp_claim_with_slc_data_no_student_loan, no_data: true) @slc_data_csv_file.write csv_row(ecp_claim_with_slc_data_with_student_loan, plan_type: "1", amount: "100") + @slc_data_csv_file.write csv_row(fe_claim_with_slc_data_no_student_loan, no_data: true) + @slc_data_csv_file.write csv_row(fe_claim_with_slc_data_with_student_loan, plan_type: "1", amount: "100") + @slc_data_csv_file.write csv_row(fe_claim_with_slc_data_no_student_loan_nil_submitted_using_slc_data, no_data: true) + @slc_data_csv_file.write csv_row(fe_claim_with_slc_data_with_student_loan_nil_submitted_using_slc_data, plan_type: "1", amount: "100") @slc_data_csv_file.rewind diff --git a/spec/features/further_education_payments/happy_path_spec.rb b/spec/features/further_education_payments/happy_path_spec.rb index 27d8f280c4..49404deb8c 100644 --- a/spec/features/further_education_payments/happy_path_spec.rb +++ b/spec/features/further_education_payments/happy_path_spec.rb @@ -7,6 +7,7 @@ let(:expected_award_amount) { college.eligible_fe_provider.max_award_amount } scenario "happy path claim" do + when_student_loan_data_exists when_further_education_payments_journey_configuration_exists and_college_exists @@ -183,6 +184,7 @@ expect(claim.first_name).to eql("John") expect(claim.surname).to eql("Doe") + expect(claim.student_loan_plan).to eq "plan_1" eligibility = Policies::FurtherEducationPayments::Eligibility.last diff --git a/spec/jobs/student_loan_plan_check_job_spec.rb b/spec/jobs/student_loan_plan_check_job_spec.rb index 1f5b168321..fb8dd4b3b5 100644 --- a/spec/jobs/student_loan_plan_check_job_spec.rb +++ b/spec/jobs/student_loan_plan_check_job_spec.rb @@ -3,7 +3,11 @@ RSpec.describe StudentLoanPlanCheckJob do subject(:perform_job) { described_class.new.perform } - let!(:claim) { create(:claim, claim_status, academic_year:, policy: Policies::LevellingUpPremiumPayments) } + before do + create(:journey_configuration, :further_education_payments) + end + + let(:claim) { create(:claim, claim_status, academic_year:, policy: Policies::LevellingUpPremiumPayments) } let(:claim_status) { :submitted } let(:academic_year) { journey_configuration.current_academic_year } @@ -47,11 +51,40 @@ end context "when a claim was submitted using the student loan questions" do + before do + claim.update!(submitted_using_slc_data: false) + end + + it "updates the student loan details" do + expect(ClaimStudentLoanDetailsUpdater).to receive(:call).with(claim) + perform_job + end + + it "runs the task" do + expect { perform_job } + .to change { claim.reload.notes.count } + .and change { claim.tasks.count } + end + end + + # this will only happen for FE claims submitted before LUPEYALPHA-1010 was merged + context "when a claim was submitted with submitted_using_slc_data: nil" do before do claim.update!(submitted_using_slc_data: nil) end - include_examples :skip_check + let(:claim) { create(:claim, claim_status, academic_year:, policy: Policies::FurtherEducationPayments) } + + it "updates the student loan details" do + expect(ClaimStudentLoanDetailsUpdater).to receive(:call).with(claim) + perform_job + end + + it "runs the task" do + expect { perform_job } + .to change { claim.reload.notes.count } + .and change { claim.tasks.count } + end end context "when the student loan plan check did not run before" do diff --git a/spec/models/claim/claims_awaiting_decision_finder_spec.rb b/spec/models/claim/claims_awaiting_decision_finder_spec.rb new file mode 100644 index 0000000000..a7982ef196 --- /dev/null +++ b/spec/models/claim/claims_awaiting_decision_finder_spec.rb @@ -0,0 +1,34 @@ +require "rails_helper" + +RSpec.describe Claim::ClaimsAwaitingDecisionFinder do + let!(:fe_journey_configuration) { create(:journey_configuration, :further_education_payments, current_academic_year: fe_academic_year) } + let!(:ap_journey_configuration) { create(:journey_configuration, :early_career_payments, current_academic_year: ecp_academic_year) } + let!(:claim_fe_awaiting_decision_submitted_using_slc_data_false) { create(:claim, :submitted, policy: Policies::FurtherEducationPayments, academic_year: fe_academic_year, submitted_using_slc_data: false) } + let!(:claim_fe_awaiting_decision_submitted_using_slc_data_nil) { create(:claim, :submitted, policy: Policies::FurtherEducationPayments, academic_year: fe_academic_year, submitted_using_slc_data: nil) } + let!(:claim_fe_awaiting_decision_submitted_using_slc_data_true) { create(:claim, :submitted, policy: Policies::FurtherEducationPayments, academic_year: fe_academic_year, submitted_using_slc_data: true) } + let!(:claim_fe_not_awaiting_decision) { create(:claim, :approved, policy: Policies::FurtherEducationPayments, academic_year: fe_academic_year, submitted_using_slc_data: false) } + let!(:claim_fe_other_year) { create(:claim, :submitted, policy: Policies::FurtherEducationPayments, academic_year: fe_previous_academic_year, submitted_using_slc_data: false) } + let!(:claim_ecp_awaiting_decision_submitted_using_slc_data_false) { create(:claim, :submitted, policy: Policies::EarlyCareerPayments, academic_year: ecp_academic_year, submitted_using_slc_data: false) } + let!(:claim_ecp_awaiting_decision_submitted_using_slc_data_nil) { create(:claim, :submitted, policy: Policies::EarlyCareerPayments, academic_year: ecp_academic_year, submitted_using_slc_data: nil) } + let!(:claim_ecp_awaiting_decision_submitted_using_slc_data_true) { create(:claim, :submitted, policy: Policies::EarlyCareerPayments, academic_year: ecp_academic_year, submitted_using_slc_data: true) } + let!(:claim_ecp_not_awaiting_decision) { create(:claim, :approved, policy: Policies::EarlyCareerPayments, academic_year: ecp_academic_year, submitted_using_slc_data: false) } + let!(:claim_ecp_other_year) { create(:claim, :submitted, policy: Policies::EarlyCareerPayments, academic_year: ecp_previous_academic_year, submitted_using_slc_data: false) } + let!(:claim_sl_awaiting_decision_submitted_using_slc_data_false) { create(:claim, :submitted, policy: Policies::StudentLoans, academic_year: fe_academic_year, submitted_using_slc_data: false) } + let(:fe_academic_year) { AcademicYear.new(2024) } + let(:fe_previous_academic_year) { AcademicYear.new(2023) } + let(:ecp_academic_year) { AcademicYear.new(2023) } + let(:ecp_previous_academic_year) { AcademicYear.new(2022) } + let(:policies) { [Policies::FurtherEducationPayments, Policies::EarlyCareerPayments] } + + describe "#claims_submitted_using_slc_data" do + subject { described_class.new(policies: policies).claims_submitted_without_slc_data } + + it "returns claims for the correct academic year for each policy submitted without SLC data" do + expect(subject).to contain_exactly( + claim_fe_awaiting_decision_submitted_using_slc_data_false, + claim_fe_awaiting_decision_submitted_using_slc_data_nil, + claim_ecp_awaiting_decision_submitted_using_slc_data_false + ) + end + end +end diff --git a/spec/models/claim_checking_tasks_spec.rb b/spec/models/claim_checking_tasks_spec.rb index 63a05a1eb2..97a0d6f65c 100644 --- a/spec/models/claim_checking_tasks_spec.rb +++ b/spec/models/claim_checking_tasks_spec.rb @@ -47,7 +47,7 @@ it "does not include a task for student loan plan when the claim was submitted using SLC data" do claim.submitted_using_slc_data = true - expect(checking_tasks.applicable_task_names).to match_array(applicable_tasks - %w[student_loan_plan]) + expect(checking_tasks.applicable_task_names).not_to include("student_loan_plan") end end @@ -94,6 +94,8 @@ let(:policy) { Policies::FurtherEducationPayments } + include_examples :student_loan_plan_task + context "when TRN is provided" do before do claim.eligibility.update!(teacher_reference_number: "1234567") diff --git a/spec/models/claim_spec.rb b/spec/models/claim_spec.rb index 76409ddac8..5c56c2a7dc 100644 --- a/spec/models/claim_spec.rb +++ b/spec/models/claim_spec.rb @@ -1265,10 +1265,11 @@ it { is_expected.to be_submitted_without_slc_data } end + # For 2024/2025 academic year onwards, only FE claims prior to the deployment of LUPEYALPHA-1010 have submitted_using_slc_data = nil context "when `submitted_using_slc_data` is `nil`" do subject(:claim) { build(:claim, submitted_using_slc_data: nil) } - it { is_expected.not_to be_submitted_without_slc_data } + it { is_expected.to be_submitted_without_slc_data } end end 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 0f13b8bf81..f3a7645682 100644 --- a/spec/requests/admin/admin_student_loans_data_upload_spec.rb +++ b/spec/requests/admin/admin_student_loans_data_upload_spec.rb @@ -3,6 +3,7 @@ RSpec.describe "SLC (Student Loans Company) data upload " do 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) } before { @signed_in_user = sign_in_as_service_operator } diff --git a/spec/support/steps/student_loan_data.rb b/spec/support/steps/student_loan_data.rb new file mode 100644 index 0000000000..14623b9b26 --- /dev/null +++ b/spec/support/steps/student_loan_data.rb @@ -0,0 +1,3 @@ +def when_student_loan_data_exists + create(:student_loans_data, nino: "PX321499A", date_of_birth: Date.new(1988, 2, 28), policy_name: Policies::FurtherEducationPayments) +end