Skip to content

Commit

Permalink
Merge pull request #3111 from DFE-Digital/LUPEYALPHA-771-check-your-a…
Browse files Browse the repository at this point in the history
…nswers

[LUPEYALPHA-771] check your answers
  • Loading branch information
alkesh authored Aug 28, 2024
2 parents 3239f34 + 1757652 commit 16ebfbb
Show file tree
Hide file tree
Showing 32 changed files with 502 additions and 17 deletions.
1 change: 1 addition & 0 deletions app/controllers/claims_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ClaimsController < BasePublicController
include AuthorisedSlugs
include FormSubmittable
include ClaimsFormCallbacks
include ClaimSubmission

def existing_session
@existing_session = journey_sessions.first
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/claims_form_callbacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ def check_your_email_after_form_save_success
render("check_your_email")
end

def check_your_answers_after_form_save_success
create_and_save_claim_form
end

private

def set_backlink_override_to_current_slug
Expand Down
15 changes: 15 additions & 0 deletions app/controllers/concerns/claim_submission.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module ClaimSubmission
extend ActiveSupport::Concern

def create_and_save_claim_form
@form = journey::ClaimSubmissionForm.new(journey_session: journey_session)

if @form.save
session[:submitted_claim_id] = @form.claim.id
clear_claim_session
redirect_to claim_confirmation_path
else
render "claims/check_your_answers"
end
end
end
11 changes: 2 additions & 9 deletions app/controllers/submissions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
class SubmissionsController < BasePublicController
include PartOfClaimJourney
include ClaimSubmission

skip_before_action :send_unstarted_claimants_to_the_start, only: [:show]

def create
@form = journey::ClaimSubmissionForm.new(journey_session: journey_session)

if @form.save
session[:submitted_claim_id] = @form.claim.id
clear_claim_session
redirect_to claim_confirmation_path
else
render "claims/check_your_answers"
end
create_and_save_claim_form
end

def show
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module Journeys
module EarlyYearsPayment
module Provider
module Authenticated
class CheckYourAnswersForm < Form
attribute :provider_contact_name

validates :provider_contact_name, presence: {message: i18n_error_message(:valid)}

def save
return false if invalid?

journey_session.answers.assign_attributes(provider_contact_name:)
journey_session.save!
end
end
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class ClaimSubmissionForm < ::ClaimSubmissionBaseForm
private

def main_eligibility
@main_eligibility ||= Policies::EarlyYearsPayments::Eligibility.new
@main_eligibility ||= eligibilities.first
end

def calculate_award_amount(eligibility)
Expand Down
3 changes: 2 additions & 1 deletion app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class ApplicationMailer < Mail::Notify::Mailer
CLAIM_REJECTED_NOTIFY_TEMPLATE_ID: "1edc468c-a1bf-4bea-bb79-042740cd8547".freeze
}
EARLY_YEARS_PAYMENTS = {
CLAIM_PROVIDER_EMAIL_TEMPLATE_ID: "e0b78a08-601b-40ba-a97f-61fb00a7c951".freeze
CLAIM_PROVIDER_EMAIL_TEMPLATE_ID: "e0b78a08-601b-40ba-a97f-61fb00a7c951".freeze,
CLAIM_RECEIVED_NOTIFY_TEMPLATE_ID: "149c5999-12fb-4b99-aff5-23a7c3302783".freeze
}
end
11 changes: 7 additions & 4 deletions app/models/claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ class Claim < ApplicationRecord
identity_confirmed_with_onelogin: false,
logged_in_with_onelogin: false,
onelogin_credentials: true,
onelogin_user_info: true
onelogin_user_info: true,
paye_reference: true,
practitioner_email_address: true,
provider_contact_name: true
}.freeze
DECISION_DEADLINE = 12.weeks
DECISION_DEADLINE_WARNING_POINT = 2.weeks
Expand Down Expand Up @@ -142,11 +145,11 @@ class Claim < ApplicationRecord
# TODO: remove when a form object is created for email-address
validates :email_address, on: [:submit], presence: {message: "Enter an email address"}

validates :bank_sort_code, on: [:submit, :amendment], presence: {message: "Enter a sort code"}
validates :bank_account_number, on: [:submit, :amendment], presence: {message: "Enter an account number"}
validates :bank_sort_code, on: [:amendment], presence: {message: "Enter a sort code"}
validates :bank_account_number, on: [:amendment], presence: {message: "Enter an account number"}
validates :building_society_roll_number, on: [:submit, :amendment], presence: {message: "Enter a roll number"}, if: -> { building_society? }

validates :payroll_gender, on: [:"payroll-gender-task", :submit], presence: {message: "You must select a gender that will be passed to HMRC"}
validates :payroll_gender, on: [:"payroll-gender-task"], presence: {message: "You must select a gender that will be passed to HMRC"}

validate :bank_account_number_must_be_eight_digits
validate :bank_sort_code_must_be_six_digits
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ module Authenticated
"start-date" => StartDateForm,
"child-facing" => ChildFacingForm,
"returner" => ReturnerForm,
"employee-email" => EmployeeEmailForm
"employee-email" => EmployeeEmailForm,
"check-your-answers" => CheckYourAnswersForm
}
}
START_WITH_MAGIC_LINK = true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
module Journeys
module EarlyYearsPayment
module Provider
module Authenticated
class AnswersPresenter < BaseAnswersPresenter
include ActionView::Helpers::TranslationHelper

def claim_answers
[].tap do |a|
a << nursery
a << paye_reference
a << employee_name
a << start_date
a << child_facing_confirmation_given
a << returner
a << employee_email_address
end
end

private

def nursery
[
"Employee’s workplace",
EligibleEyProvider.find_by(urn: answers.nursery_urn).nursery_name,
"current-nursery"
]
end

def paye_reference
[
"Employer’s PAYE reference number",
answers.paye_reference,
"paye-reference"
]
end

def employee_name
[
"Employee’s name",
[answers.first_name, answers.surname].join(" "),
"claimant-name"
]
end

def start_date
[
"Employee’s start date",
answers.start_date.to_fs(:long_date),
"start-date"
]
end

def child_facing_confirmation_given
[
"Confirmation that employee spends most of their time in their job working directly with children",
(answers.child_facing_confirmation_given ? "Yes" : "No"),
"child-facing"
]
end

def returner
[
"Confirmation that employee worked in an early years setting 6 months before the start date",
(answers.first_job_within_6_months ? "Yes" : "No"),
"returner"
]
end

def employee_email_address
[
"Employee’s email address",
answers.practitioner_email_address,
"employee-email"
]
end
end
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@ class SessionAnswers < Journeys::SessionAnswers
attribute :first_job_within_6_months, :boolean
attribute :start_date, :date
attribute :practitioner_email_address
attribute :provider_contact_name

def policy
Policies::EarlyYearsPayments
end

def provide_mobile_number
false
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<% content_for(
:page_title,
page_title(
t("early_years_payment_provider_authenticated.check_your_answers.title"),
journey: current_journey_routing_name,
show_error: @form.errors.any?
)
) %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<% if @form.errors.any? %>
<%= render("shared/error_summary", instance: @form, errored_field_id_overrides: {"provider_contact_name":"claim-provider-contact-name-field-error"}) %>
<% end %>
<h1 class="govuk-heading-xl">
<%= t("early_years_payment_provider_authenticated.check_your_answers.title") %>
</h1>

<%= render partial: "claims/check_your_answers_section", locals: {heading: nil, answers: journey.answers_for_claim(@form.journey_session).claim_answers} %>
<%= form_with model: @form, url: claim_path(current_journey_routing_name), method: :patch, builder: GOVUKDesignSystemFormBuilder::FormBuilder do |form| %>
<h2 class="govuk-heading-m"><%= t("early_years_payment_provider_authenticated.check_your_answers.heading_send_application") %></h2>

<p class="govuk-body"><%= t("early_years_payment_provider_authenticated.check_your_answers.statement") %></p>

<%= form.govuk_text_field :provider_contact_name, label: { text: "Your full name" }, spellcheck: "false" %>

<div class="govuk-form-group">
<%= form.submit t("early_years_payment_provider_authenticated.check_your_answers.btn_text"), class: "govuk-button" %>
</div>
<% end %>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= form_with model: @form, url: claim_path(current_journey_routing_name), method: :patch, builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %>
<%= f.govuk_error_summary %>

<%= f.govuk_check_boxes_fieldset :child_facing_confirmation_given, multiple: false, legend: { text: @form.t(:question, first_name: answers.first_name), tag: "h1", size: "l" }, hint: -> do %>
<div class="govuk-body">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= form_with model: @form, url: claim_path(current_journey_routing_name), method: :patch, builder: GOVUKDesignSystemFormBuilder::FormBuilder, html: { novalidate: false } do |f| %>
<%= f.govuk_error_summary %>

<%= f.govuk_check_boxes_fieldset :consent_given, multiple: false, legend: { text: @form.t(:question), tag: "h1", size: "l" }, hint: -> do %>
<p class="govuk-body">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= form_with model: @form, url: claim_path(current_journey_routing_name), method: :patch, builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %>
<%= f.govuk_error_summary %>

<%= f.govuk_text_field :practitioner_email_address,
label: { text: @form.t(:question, first_name: answers.first_name), tag: "h1", size: "l" },
hint: { text: @form.t(:hint) }, spellcheck: "false" %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= form_with model: @form, url: claim_path(current_journey_routing_name), method: :patch, builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %>
<%= f.govuk_error_summary %>

<%= f.govuk_text_field :paye_reference,
label: { text: @form.t(:question, nursery_name: @form.nursery_name), tag: "h1", size: "l" },
hint: { text: @form.t(:hint) },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<% content_for(:page_title, page_title("Claim submitted", journey: current_journey_routing_name)) %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">

<div class="govuk-panel govuk-panel--confirmation">
<h1 class="govuk-panel__title" id="submitted-title">Claim submitted</h1>

<div class="govuk-panel__body">
Your claim reference<br>
<strong><%= submitted_claim.reference %></strong>
</div>
</div>

<h2 class="govuk-heading-m">
You’ve successfully submitted a claim for an early years financial
incentive payment on behalf of <%= submitted_claim.first_name %> <%= submitted_claim.surname %>.
</h2>

<p class="govuk-body">
We’ve sent a confirmation email to <%= submitted_claim.email_address %>.
</p>

<h2 class="govuk-heading-m">What happens next</h2>

<p class="govuk-body">
We’ll send an email to your employee asking for them to provide some
further information. We’ll also ask them to provide their payment details.
</p>

<p class="govuk-body">
For more information, read more about the
<%= govuk_link_to("early years financial incentive", "#") %>.
</p>
</div>
</div>

4 changes: 4 additions & 0 deletions config/analytics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -306,5 +306,9 @@ shared:
- updated_at
:early_years_payment_eligibilities:
- id
- nursery_urn
- start_date
- child_facing_confirmation_given
- first_job_within_6_months
- created_at
- updated_at
3 changes: 3 additions & 0 deletions config/analytics_blocklist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
- teacher_id_user_info
- onelogin_credentials
- onelogin_user_info
- paye_reference
- practitioner_email_address
- provider_contact_name
:claim_decisions:
- trn
- claimant_age
Expand Down
9 changes: 9 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,15 @@ en:
hint: We’ll use this to ask your employee to provide their payment details.
errors:
valid: Enter a valid email address
check_your_answers:
errors:
valid: You cannot submit this claim without providing your full name
check_your_answers:
title: Check your answers before submitting this claim
heading_send_application: Before submitting this claim
statement:
By submitting this claim you’re confirming that, to the best of your knowledge, the details you’re providing are correct.
btn_text: Accept and send
early_years_payments:
<<: *early_years_payment_provider_authenticated
claim_subject: "Early Years Payment"
Expand Down
7 changes: 7 additions & 0 deletions db/migrate/20240821110005_add_answer_fields_to_claims.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class AddAnswerFieldsToClaims < ActiveRecord::Migration[7.0]
def change
add_column :claims, :paye_reference, :string
add_column :claims, :practitioner_email_address, :string
add_column :claims, :provider_contact_name, :string
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class AddAnswerFieldsToEyEligibilities < ActiveRecord::Migration[7.0]
def change
add_column :early_years_payment_eligibilities, :nursery_urn, :string
add_column :early_years_payment_eligibilities, :start_date, :date
add_column :early_years_payment_eligibilities, :child_facing_confirmation_given, :boolean
add_column :early_years_payment_eligibilities, :first_job_within_6_months, :boolean
end
end
Loading

0 comments on commit 16ebfbb

Please sign in to comment.