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 Oct 31, 2024
1 parent c3e203c commit 6bf60a1
Show file tree
Hide file tree
Showing 8 changed files with 562 additions and 2 deletions.
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_entered_full_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_entered_full_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 @@ -443,6 +443,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: 1 addition & 2 deletions app/models/policies/early_years_payments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module EarlyYearsPayments
MIN_QA_THRESHOLD = 10

VERIFIERS = [
AutomatedChecks::ClaimVerifiers::EarlyYearsPayments::Identity,
AutomatedChecks::ClaimVerifiers::StudentLoanPlan # TODO - spec
]

Expand Down Expand Up @@ -56,8 +57,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
Expand Down
31 changes: 31 additions & 0 deletions app/models/policies/early_years_payments/admin_tasks_presenter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module Policies
module EarlyYearsPayments
class AdminTasksPresenter
attr_reader :claim

def initialize(claim)
@claim = claim
end

def identity_confirmation
[]
end

def provider_entered_claimant_name
claim.eligibility.practitioner_entered_full_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
end
end
end
18 changes: 18 additions & 0 deletions app/models/policies/early_years_payments/eligibility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ def eligible_ey_provider
def provider_claim_submitted?
provider_claim_submitted_at.present?
end

def practitioner_entered_full_name
"#{practitioner_first_name} #{practitioner_surname}"
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>
3 changes: 3 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1451,6 +1451,9 @@ en:
duplicate: Duplicate
no_response: No response
other: Other
task_questions:
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 6bf60a1

Please sign in to comment.