-
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.
WIP - add provider verification task
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
Showing
10 changed files
with
422 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
100 changes: 100 additions & 0 deletions
100
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,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 |
31 changes: 31 additions & 0 deletions
31
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,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 |
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,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> |
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,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: | ||
|
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
Oops, something went wrong.