Skip to content

Commit

Permalink
Merge pull request #3311 from DFE-Digital/CAPT-1468-student-loan-no-m…
Browse files Browse the repository at this point in the history
…atch

CAPT-1468 Add a no match when only the NiNo matches from the SLC data
  • Loading branch information
kenfodder authored Oct 28, 2024
2 parents 9c1a3cd + 89f8179 commit e8fe1fb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
19 changes: 13 additions & 6 deletions app/models/automated_checks/claim_verifiers/student_loan_plan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def perform
return unless claim.submitted_without_slc_data?
return unless awaiting_task?

no_student_loan_data_entry || student_loan_data_exists
student_loan_data_exists || nino_only_match_found || no_student_loan_data_entry
end

private
Expand All @@ -31,18 +31,24 @@ def student_loans_data
@student_loans_data ||= StudentLoansData.where(nino:, date_of_birth:)
end

def student_loans_data_nino_only
@student_loans_data_nino_only ||= StudentLoansData.where(nino:).where.not(date_of_birth:)
end

def awaiting_task?
claim.tasks.where(name: TASK_NAME).count.zero?
end

def no_student_loan_data_entry
return if student_loans_data.any?
def student_loan_data_exists
create_task(match: :all, passed: true) if student_loans_data.any?
end

create_note(match: nil)
def nino_only_match_found
create_task(match: :none) if student_loans_data_nino_only.any?
end

def student_loan_data_exists
create_task(match: :all, passed: true)
def no_student_loan_data_entry
create_note(match: nil)
end

def create_task(match:, passed: nil)
Expand All @@ -66,6 +72,7 @@ def create_task(match:, passed: nil)
def note_body(match:)
prefix = "[SLC Student loan plan]"
return "#{prefix} - SLC data checked, no matching entry found" unless match
return "#{prefix} - No match - DOB does not match" if match == :none

if slc_repaying_plan_types
"#{prefix} - Matched - has a student loan"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@ module ClaimVerifiers

it_behaves_like :creating_a_task_and_note
end

context "when there is student loan data matching only the NiNo, but not the DOB" do
before do
create(:student_loans_data, nino: claim.national_insurance_number, date_of_birth: claim.date_of_birth + 1.year)
end

let(:expected_to_pass?) { nil }
let(:expected_match_value) { "none" }
let(:expected_note) { "[SLC Student loan plan] - No match - DOB does not match" }

it_behaves_like :creating_a_task_and_note
end
end

# this will only happen for FE claims submitted before LUPEYALPHA-1010 was merged
Expand Down

0 comments on commit e8fe1fb

Please sign in to comment.