Skip to content

Commit

Permalink
Add identity task for early years
Browse files Browse the repository at this point in the history
This task displays differently to other tasks as such we've introduced a
separate claim verifier and separate view template.
  • Loading branch information
rjlynch committed Nov 1, 2024
1 parent b6e4549 commit 1cca885
Show file tree
Hide file tree
Showing 9 changed files with 554 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
module AutomatedChecks
module ClaimVerifiers
module EarlyYearsPayments
class Identity < AutomatedChecks::ClaimVerifiers::Identity
def perform
return unless claim.eligibility.practitioner_journey_completed?
return unless awaiting_task?(TASK_NAME)

if one_login_idv_match?
create_task(match: nil, passed: true)
elsif one_login_idv_partial_match?
create_task(match: :any, passed: nil)

create_note(
body: <<-HTML
[GOV UK One Login Name] - Names partially match:
<pre>
Provider: "#{claim.eligibility.practitioner_name}"
GOV.UK One Login: "#{claim.onelogin_idv_full_name}"
</pre>
HTML
)
elsif claim.one_login_idv_match?
create_task(match: nil, passed: false)

create_note(
body: <<-HTML
[GOV UK One Login Name] - Names do not match:
<pre>
Provider: "#{claim.eligibility.practitioner_name}"
GOV.UK One Login: "#{claim.onelogin_idv_full_name}"
</pre>
HTML
)
else
create_task(match: :none, passed: false)

create_note(
body: <<-HTML
[GOV UK One Login] - IDV mismatch:
<pre>
GOV.UK One Login Name: "#{claim.onelogin_idv_full_name}"
GOV.UK One Login DOB: "#{claim.onelogin_idv_date_of_birth}"
</pre>
HTML
)
end
end

private

def one_login_idv_match?
return false unless claim.one_login_idv_match?

claim.eligibility.practitioner_and_provider_entered_names_match?
end

def one_login_idv_partial_match?
return false unless claim.one_login_idv_match?

claim.eligibility.practitioner_and_provider_entered_names_partial_match?
end
end
end
end
end
4 changes: 4 additions & 0 deletions app/models/claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,10 @@ def one_login_idv_mismatch?
!one_login_idv_name_match? || !one_login_idv_dob_match?
end

def one_login_idv_match?
one_login_idv_name_match? && one_login_idv_dob_match?
end

def awaiting_provider_verification?
return false unless has_further_education_policy?

Expand Down
3 changes: 2 additions & 1 deletion app/models/policies/early_years_payments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ module EarlyYearsPayments
MIN_QA_THRESHOLD = 10

VERIFIERS = [
AutomatedChecks::ClaimVerifiers::StudentLoanPlan
AutomatedChecks::ClaimVerifiers::StudentLoanPlan,
AutomatedChecks::ClaimVerifiers::EarlyYearsPayments::Identity
]

# Attributes to delete from claims submitted before the current academic
Expand Down
26 changes: 26 additions & 0 deletions app/models/policies/early_years_payments/admin_tasks_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,32 @@ def employment
["Start date", l(claim.eligibility.start_date)]
]
end

def identity_confirmation
[]
end

def provider_entered_claimant_name
claim.eligibility.practitioner_name
end

def one_login_claimant_name
claim.onelogin_idv_full_name
end

def practitioner_journey_completed?
claim.eligibility.practitioner_journey_completed?
end

def qualifications
[]
end

def student_loan_plan
[
["Student loan plan", claim.student_loan_plan&.humanize]
]
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def initialize(claim)
def applicable_task_names
tasks = []

tasks << "identity_confirmation"
tasks << "student_loan_plan" if claim.submitted_without_slc_data?

tasks
Expand Down
14 changes: 14 additions & 0 deletions app/models/policies/early_years_payments/eligibility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ def employment_task_available?
def practitioner_name
[practitioner_first_name, practitioner_surname].join(" ")
end

def practitioner_and_provider_entered_names_match?
practitioner_first_name.downcase == claim.onelogin_idv_first_name.downcase &&
practitioner_surname.downcase == claim.onelogin_idv_last_name.downcase
end

def practitioner_and_provider_entered_names_partial_match?
practitioner_first_name.downcase == claim.onelogin_idv_first_name.downcase ||
practitioner_surname.downcase == claim.onelogin_idv_last_name.downcase
end

def practitioner_journey_completed?
claim.submitted_at.present?
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<% content_for(:page_title) { page_title("Claim #{@claim.reference} identity confirmation check for #{@claim.policy.short_name}") } %>

<% content_for :back_link do %>
<%= govuk_back_link href: admin_claim_tasks_path(@claim) %>
<% end %>

<%= render "shared/error_summary", instance: @task, errored_field_id_overrides: { "passed": "task_passed_true" } if @task.errors.any? %>

<div class="govuk-grid-row">
<%= render claim_summary_view, claim: @claim, heading: "Identity confirmation" %>

<div class="govuk-grid-column-two-thirds">
<h2 class="govuk-heading-l"><%= @current_task_name.humanize %></h2>
</div>

<div class="govuk-grid-column-two-thirds">
<h3 class="govuk-heading-m">
<%= I18n.t(
"admin.tasks.identity_confirmation.title",
claim_full_name: @claim.full_name
) %>
</h3>

<table class="govuk-table">
<tbody class="govuk-table__body">
<tr class="govuk-table__row">
<th scope="row" class="govuk-table__header">
Provider entered claimant name
</th>
<td class="govuk-table__cell">
<%= @tasks_presenter.provider_entered_claimant_name %>
</td>
</tr>
<tr class="govuk-table__row">
<th scope="row" class="govuk-table__header">
Claimant name from One login
</th>
<td class="govuk-table__cell">
<%= @tasks_presenter.one_login_claimant_name %>
</td>
</tr>
</tbody>
</table>

<% if @tasks_presenter.practitioner_journey_completed? %>
<% if @task.claim_verifier_match_any? && @task.passed.nil? %>
<%= render "form", task_name: "identity_confirmation", claim: @claim %>
<% else %>
<%= render "task_outcome", task: @task %>
<% end %>
<% else %>
<div class="govuk-inset-text">
This task is not available until the claimant has submitted their
claim.
</div>
<% end %>

<%= render partial: "admin/task_pagination", locals: { task_pagination: @task_pagination } %>
</div>
</div>
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1462,6 +1462,8 @@ en:
task_questions:
employment:
title: Is the claimant still working at the current nursery above?
identity_confirmation:
title: "Do these names match?"
early_years_payment_practitioner:
journey_name: Claim an early years financial incentive payment - practitioner
feedback_email: "[email protected]"
Expand Down
Loading

0 comments on commit 1cca885

Please sign in to comment.