Skip to content

Commit

Permalink
WIP - add provider verification task
Browse files Browse the repository at this point in the history
Adds the task for the provider to verify the claim.

This commit is a work in progress as there's still a few things
outstanding:
* various admin localisations
* updating the task presenter so submitting the task form doesn't error
  when redirecting to the next page
* Handling different rows for variable hours contracts

I mostly wanted to check that how we're storing the verification worked
reasonably when we wanted to render the information on the admin task
side.

This task isn't automatically approved, admins need to go in and
manually confirm that the provider verification looks correct. I think
this makes sense from and MVP approach and we can itterate towards
automatic approval.
The designs for the pending task page haven't been completed so expect
that to change, currently we just say the task is pending and show an
email link.

As the verification table in the ui requires stiching together data from
the verification and the eligibility we've introduced a separate
presenter object that the task presenter just calls. Mixing in the
verification presenter logic in the task verifier would be a bit much
once all the other tasks were added. Maybe a separate "Verification"
record would make this easier to work with.

This commit should be cleaned up and the message rewritten before
merging.
  • Loading branch information
rjlynch committed Aug 28, 2024
1 parent c7fbafb commit 87a9693
Show file tree
Hide file tree
Showing 10 changed files with 422 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,100 @@
module Policies
module FurtherEducationPayments
class AdminProviderVerificationTaskPresenter
class Row < Struct.new(
:label,
:claimant_answer,
:provider_answer,
keyword_init: true
); end

ROWS = [
["contract_type", "contract_type", "contract_type"],
["teaching_responsibilities", "teaching_responsibilities", "teaching_responsibilities"],
["further_education_teaching_start_year", "further_education_teaching_start_year", "further_education_teaching_start_year"],
["teaching_hours_per_week", "teaching_hours_per_week", "teaching_hours_per_week"],
["half_teaching_hours", "half_teaching_hours", "half_teaching_hours"],
["subjects_taught", "subjects_taught", "subjects_taught"],
["courses_taught", "courses_taught", "subjects_taught"]
]

attr_reader :claim

def initialize(claim)
@claim = claim
end

def rows
ROWS.map do |label_key, claimant_key, provider_key|
Row.new(
label: label(label_key),
claimant_answer: claimant_answer(claimant_key),
provider_answer: provider_answer(provider_key)
)
end
end

private

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

def claimant_answer(key)
case key
when "subjects_taught"
subjects_taught
when "courses_taught"
courses_taught
when "further_education_teaching_start_year"
"September #{claim.eligibility.further_education_teaching_start_year} to August #{claim.eligibility.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(key)
claim.eligibility.verification.fetch("assertions").find do |assertion|
assertion["name"] == key
end.fetch("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
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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

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
75 changes: 75 additions & 0 deletions app/views/admin/tasks/provider_verification.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<% 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 is pending verification by the provider
</p>
<p class="govuk-body">
Provider verification link <%= govuk_link_to(
Journeys::FurtherEducationPayments::Provider::SlugSequence.verify_claim_url(@claim),
Journeys::FurtherEducationPayments::Provider::SlugSequence.verify_claim_url(@claim)
) %>
</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>
35 changes: 35 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,38 @@ 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 employment?"
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"
forms:
ineligible:
courses:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
end

trait :verified do
contract_type { "permanent" }
teaching_responsibilities { true }
further_education_teaching_start_year { "2023" }
teaching_hours_per_week { "more_than_12" }
hours_teaching_eligible_subjects { false }
half_teaching_hours { true }
subjects_taught { ["maths", "physics"] }
maths_courses { ["approved_level_321_maths", "gcse_maths"] }
physics_courses { ["gcse_physics"] }
verification do
{
"assertions" => [
Expand Down
Loading

0 comments on commit 87a9693

Please sign in to comment.