Skip to content

Commit

Permalink
Merge pull request #3167 from DFE-Digital/LUPEYALPHA-356/provider-ver…
Browse files Browse the repository at this point in the history
…ification-email

Record who sent the email to the provider
  • Loading branch information
rjlynch authored Sep 16, 2024
2 parents c2367ea + 691e245 commit 8d307fc
Show file tree
Hide file tree
Showing 7 changed files with 301 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ class ProviderVerificationEmailsController < Admin::BaseAdminController
def create
claim = Claim.find(params[:claim_id])

claim.notes.create!(
created_by: admin_user,
label: "provider_verification",
body: "Verification email sent to #{claim.school.name}"
)

ClaimMailer.further_education_payment_provider_verification_email(claim).deliver_later

flash[:notice] = "Verification email sent to #{claim.school.name}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ def rows
end
end

def admin_sent_emails
@admin_sent_emails ||= claim.notes.by_label("provider_verification").order(created_at: :desc)
end

def verification_email_sent?
!claim.eligibility.flagged_as_duplicate? || verification_email_sent_by_admin_team?
end

def verification_email_sent_by_admin_team?
admin_sent_emails.any?
end

private

def verification
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def initialize(claim)
end

def provider_verification
AdminProviderVerificationTaskPresenter.new(claim).rows
AdminProviderVerificationTaskPresenter.new(claim)
end

def provider_name
Expand Down
38 changes: 38 additions & 0 deletions app/views/admin/tasks/_provider_verification_submitted.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<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.rows.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>
35 changes: 35 additions & 0 deletions app/views/admin/tasks/_provider_verification_unsubmitted.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<% if @tasks_presenter.provider_verification.verification_email_sent? %>
<% if @tasks_presenter.provider_verification.verification_email_sent_by_admin_team? %>
<div class="govuk-inset-text">
<% @tasks_presenter.provider_verification.admin_sent_emails.each do |verification_email| %>
<p>
The verification request was sent to the provider by
<%= user_details(verification_email.created_by) %> on <%= l(verification_email.created_at) %>
</p>
<% end %>
</div>
<% end %>

<%= govuk_button_to(
"Resend provider verification request",
admin_claim_further_education_payments_provider_verification_emails_path(@claim),
class: "govuk-!-margin-bottom-0"
) %>
<% else %>
<p class="govuk-body">
This task has not been sent to the provider yet.
</p>

<div class="govuk-inset-text">
<p>
You need to check the matching details and confirm if this is a
duplicate claim. If it isn't a duplicate claim, send the verification
request to the provider.
</p>
<%= govuk_button_to(
"Send provider verification request",
admin_claim_further_education_payments_provider_verification_emails_path(@claim),
class: "govuk-!-margin-bottom-0"
) %>
</div>
<% end %>
56 changes: 2 additions & 54 deletions app/views/admin/tasks/provider_verification.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,61 +10,9 @@
<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>
<%= render "provider_verification_submitted" %>
<% else %>
<p class="govuk-body">
This task has not been sent to the provider yet.
</p>

<div class="govuk-inset-text">
<p>
You need to check the matching details and confirm if this is a
duplicate claim. If it isn't a duplicate claim, send the verification
request to the provider.
</p>
<%= govuk_button_to(
"Send provider verification request",
admin_claim_further_education_payments_provider_verification_emails_path(@claim),
class: "govuk-!-margin-bottom-0"
) %>
</div>
<%= render "provider_verification_unsubmitted" %>
<% end %>
</div>

Expand Down
Loading

0 comments on commit 8d307fc

Please sign in to comment.