diff --git a/app/models/automated_checks/claim_verifiers/early_years_payments/identity.rb b/app/models/automated_checks/claim_verifiers/early_years_payments/identity.rb new file mode 100644 index 0000000000..e781efcf49 --- /dev/null +++ b/app/models/automated_checks/claim_verifiers/early_years_payments/identity.rb @@ -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: +
+ Provider: "#{claim.eligibility.practitioner_entered_full_name}" + GOV.UK One Login: "#{claim.onelogin_idv_full_name}" ++ 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: +
+ Provider: "#{claim.eligibility.practitioner_entered_full_name}" + GOV.UK One Login: "#{claim.onelogin_idv_full_name}" ++ HTML + ) + else + create_task(match: :none, passed: false) + + create_note( + body: <<-HTML + [GOV UK One Login] - IDV mismatch: +
+ GOV.UK One Login Name: "#{claim.onelogin_idv_full_name}" + GOV.UK One Login DOB: "#{claim.onelogin_idv_date_of_birth}" ++ 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 diff --git a/app/models/claim.rb b/app/models/claim.rb index 1fbb6016b0..255c2feca5 100644 --- a/app/models/claim.rb +++ b/app/models/claim.rb @@ -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? diff --git a/app/models/policies/early_years_payments.rb b/app/models/policies/early_years_payments.rb index 13624c2577..c1fb7b88c9 100644 --- a/app/models/policies/early_years_payments.rb +++ b/app/models/policies/early_years_payments.rb @@ -7,6 +7,7 @@ module EarlyYearsPayments MIN_QA_THRESHOLD = 10 VERIFIERS = [ + AutomatedChecks::ClaimVerifiers::EarlyYearsPayments::Identity, AutomatedChecks::ClaimVerifiers::StudentLoanPlan # TODO - spec ] @@ -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 diff --git a/app/models/policies/early_years_payments/admin_tasks_presenter.rb b/app/models/policies/early_years_payments/admin_tasks_presenter.rb new file mode 100644 index 0000000000..a440806149 --- /dev/null +++ b/app/models/policies/early_years_payments/admin_tasks_presenter.rb @@ -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 diff --git a/app/models/policies/early_years_payments/eligibility.rb b/app/models/policies/early_years_payments/eligibility.rb index f00d665786..3b5268d1e5 100644 --- a/app/models/policies/early_years_payments/eligibility.rb +++ b/app/models/policies/early_years_payments/eligibility.rb @@ -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 diff --git a/app/views/admin/tasks/early_years_payments/identity_confirmation.html.erb b/app/views/admin/tasks/early_years_payments/identity_confirmation.html.erb new file mode 100644 index 0000000000..c8146aa0c0 --- /dev/null +++ b/app/views/admin/tasks/early_years_payments/identity_confirmation.html.erb @@ -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? %> + +
+ Provider entered claimant name + | ++ <%= @tasks_presenter.provider_entered_claimant_name %> + | +
---|---|
+ Claimant name from One login + | ++ <%= @tasks_presenter.one_login_claimant_name %> + | +