Skip to content

Commit

Permalink
Add provider verification admin task
Browse files Browse the repository at this point in the history
Adds the admin task for reviewing the provider's verification of the
claimant's claim.
This task is currently a manual check by the admin but in a future
iteration will be replaced with an automated check. There isn't a design
for the manual check yet but all the other checks use a yes / no radio
button so we've gone for that, the copy for the admin question may be
suject to change.
There's a bit of awkwardness in presenting the verification table as
there questions the provider signs off on are slightly different to
those shown in the admin task. Rather than clutter the
admin_tasks_presenter, which will handle showing information about other
tasks, the admin task presenter calls a specific verification presenter
to handle displaying the verification table.
Some of this code feels a bit awkward, maybe we need to consider moving
the verification json into and object.
  • Loading branch information
rjlynch committed Sep 2, 2024
1 parent 79d2861 commit 869d408
Show file tree
Hide file tree
Showing 10 changed files with 619 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/models/base_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,8 @@ def searchable_eligibility_attributes
def international_relocation_payments?
to_s == "InternationalRelocationPayments"
end

def further_education_payments?
to_s == "FurtherEducationPayments"
end
end
3 changes: 3 additions & 0 deletions app/models/claim_checking_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ def applicable_task_names
task_names.delete("subject")
task_names.delete("teaching_hours")
end
unless claim.policy.further_education_payments?
task_names.delete("provider_verification")
end
end
end

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
module Policies
module FurtherEducationPayments
class AdminProviderVerificationTaskPresenter
class Row < Struct.new(
:label,
:claimant_answer,
:provider_answer,
keyword_init: true
)
def ==(other)
other.is_a?(Row) &&
label == other.label &&
claimant_answer == other.claimant_answer &&
provider_answer == other.provider_answer
end
end

attr_reader :claim

def initialize(claim)
@claim = claim
end

def rows
assertions.map do |assertion|
Row.new(
label: label(assertion),
claimant_answer: claimant_answer(assertion),
provider_answer: provider_answer(assertion)
)
end
end

private

def verification
@verification ||= claim.eligibility.verification
end

def assertions
verification["assertions"] + [courses_taught_assertion]
end

# The provider verifies the courses taught question as part of verifying the
# subjects taught question, however the admin UI designs require we
# display these separately, so we construct an additional "assertion" for
# courses taught
def courses_taught_assertion
subjects_taught_outcome = verification["assertions"].detect do |a|
a["name"] == "subjects_taught"
end.fetch("outcome")

{
"name" => "courses_taught",
"outcome" => subjects_taught_outcome
}
end

def label(assertion)
I18n.t(
[
"further_education_payments",
"admin",
"task_questions",
"provider_verification",
assertion["name"],
"label"
].join(".")
)
end

def claimant_answer(assertion)
key = assertion["name"]
case key
when "subjects_taught"
subjects_taught
when "courses_taught"
courses_taught
when "further_education_teaching_start_year"
"September #{further_education_teaching_start_year} " \
"to August #{further_education_teaching_start_year.to_i + 1}"
else
I18n.t(
[
"further_education_payments",
"admin",
"task_questions",
"provider_verification",
key,
"claimant_answers",
claim.eligibility.send(key)
].join(".")
)
end
end

def provider_answer(assertion)
assertion["outcome"] ? "Yes" : "No"
end

def subjects_taught
claim.eligibility.subjects_taught.map do |subject|
I18n.t(
[
"further_education_payments",
"forms",
"subjects_taught",
"options",
subject
].join(".")
)
end
end

def courses_taught
claim.eligibility.courses_taught.map(&:description)
end

def further_education_teaching_start_year
claim.eligibility.further_education_teaching_start_year
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module Policies
module FurtherEducationPayments
class AdminTasksPresenter
include Admin::PresenterMethods

attr_reader :claim

def initialize(claim)
@claim = claim
end

def provider_verification
AdminProviderVerificationTaskPresenter.new(claim).rows
end

def provider_name
[verifier.fetch("first_name"), verifier.fetch("last_name")].join(" ")
end

def provider_verification_submitted?
claim.eligibility.verification.present?
end

# FIXME RL - temp stub so the provider verification task can be completed
def qualifications
[]
end

private

def verifier
@verifier ||= claim.eligibility.verification.fetch("verifier")
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module Policies
module FurtherEducationPayments
class EligibilityAdminAnswersPresenter
include Admin::PresenterMethods

attr_reader :eligibility

def initialize(eligibility)
@eligibility = eligibility
end

def answers
[]
end
end
end
end
1 change: 1 addition & 0 deletions app/models/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
class Task < ApplicationRecord
NAMES = %w[
identity_confirmation
provider_verification
visa
arrival_date
qualifications
Expand Down
69 changes: 69 additions & 0 deletions app/views/admin/tasks/provider_verification.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<% content_for(:page_title) { page_title("Claim #{@claim.reference} provider verification check for# {@claim.policy.short_name}") } %>
<%= link_to "Back", admin_claim_tasks_path(claim_id: @claim.id), class: "govuk-back-link" %>
<%= 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", claim: @claim, heading: "Provider verification" %>

<div class="govuk-grid-column-three-quarters">
<h2 class="govuk-heading-xl"><%= @current_task_name.humanize %></h2>

<% if @tasks_presenter.provider_verification_submitted? %>
<p class="govuk-body">
This task was verified by the provider
(<%= @tasks_presenter.provider_name %>).
</p>

<table class="govuk-table govuk-!-margin-bottom-9">
<caption class="govuk-table__caption govuk-visually-hidden">
<%= @current_task_name.humanize %>
</caption>
<thead>
<tr class="govuk-table__row">
<th scope="col" class="govuk-table__header">
Eligibility check
</th>
<th scope="col" class="govuk-table__header">
Claimant submitted
</th>
<th scope="col" class="govuk-table__header">
Provider response
</th>
</tr>
</thead>
<tbody class="govuk-table__body">
<% @tasks_presenter.provider_verification.each do |row| %>
<tr class="govuk-table__row govuk-!-width-one-quarter">
<th scope="row" class="govuk-table__header">
<%= row.label %>
</th>
<td class="govuk-table__cell govuk-!-width-one-half">
<%= Array.wrap(row.claimant_answer).join("<br><br>").html_safe %>
</td>
<td class="govuk-table__cell govuk-!-width-one-quarter">
<%= row.provider_answer %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<p class="govuk-body">
This task has not yet been completed by the provider
</p>
<% end %>
</div>

<% if @tasks_presenter.provider_verification_submitted? %>
<div class="govuk-grid-column-two-thirds">
<% if @task.persisted? %>
<%= render "task_outcome", task: @task, notes: @notes %>
<% else %>
<%= render "form", task_name: "provider_verification", claim: @claim %>
<% end %>

<%= render partial: "admin/task_pagination" %>
</div>
<% end %>
</div>
46 changes: 46 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ en:
employment: "Check employment information"
matching_details: "Review matching details from other claims"
identity_confirmation: "Confirm the claimant made the claim"
provider_verification: "Confirm the provider verification"
payroll_gender: "Add a payroll gender for HMRC"
student_loan_amount: "Check student loan amount"
student_loan_plan: "Check student loan plan"
Expand All @@ -149,6 +150,8 @@ en:
employment_start: "Check employment start date"
subject: "Check subject"
teaching_hours: "Check teaching hours"
provider_verification: "Confirm the provider verification"

undo_decision:
approved: "Undo approval"
rejected: "Undo rejection"
Expand Down Expand Up @@ -827,6 +830,49 @@ en:
feedback_email: "[email protected]"
support_email_address: "[email protected]"
claim_subject: "Further education payment"
admin:
task_questions:
provider_verification:
title: "Has the provider confirmed the claimant's details?"
contract_type:
label: "Contract of employment"
claimant_answers:
permanent: "Permanent"
fixed_term: "Fixed term"
variable_hours: "Variable hours"
teaching_responsibilities:
label: "Teaching responsibilities"
claimant_answers:
true: "Yes"
false: "No"
further_education_teaching_start_year:
label: "First 5 years of teaching"
teaching_hours_per_week:
label: "Timetabled teaching hours"
claimant_answers:
more_than_12: "More than 12 hours per week"
between_2_5_and_12: "Between 2.5 and 12 hours per week"
less_than_2_5: "Less than 2.5 hours per week"
half_teaching_hours:
label: "Age range taught"
claimant_answers:
true: "Yes"
false: "No"
subjects_taught:
label: "Subject"
courses_taught:
label: "Course"
teaching_hours_per_week_next_term:
label: "Timetabled teaching hours next term"
claimant_answers:
at_least_2_5: "At least 2.5 hours per week"
less_than_2_5: "Less than 2.5 hours per week"
taught_at_least_one_term:
label: "Taught at least one term"
claimant_answers:
true: "Yes"
false: "No"

forms:
ineligible:
courses:
Expand Down
Loading

0 comments on commit 869d408

Please sign in to comment.