-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add provider verification admin task
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
Showing
10 changed files
with
619 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
app/models/policies/further_education_payments/admin_provider_verification_task_presenter.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
36 changes: 36 additions & 0 deletions
36
app/models/policies/further_education_payments/admin_tasks_presenter.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
17 changes: 17 additions & 0 deletions
17
app/models/policies/further_education_payments/eligibility_admin_answers_presenter.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
|
@@ -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" | ||
|
@@ -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: | ||
|
Oops, something went wrong.