diff --git a/app/controllers/claims_controller.rb b/app/controllers/claims_controller.rb index 2813617f68..3bd1c38936 100644 --- a/app/controllers/claims_controller.rb +++ b/app/controllers/claims_controller.rb @@ -15,6 +15,7 @@ class ClaimsController < BasePublicController include AuthorisedSlugs include FormSubmittable include ClaimsFormCallbacks + include ClaimSubmission def existing_session @existing_session = journey_sessions.first diff --git a/app/controllers/claims_form_callbacks.rb b/app/controllers/claims_form_callbacks.rb index d5acf98d10..3afc56eef0 100644 --- a/app/controllers/claims_form_callbacks.rb +++ b/app/controllers/claims_form_callbacks.rb @@ -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 diff --git a/app/controllers/concerns/claim_submission.rb b/app/controllers/concerns/claim_submission.rb new file mode 100644 index 0000000000..f72b63d045 --- /dev/null +++ b/app/controllers/concerns/claim_submission.rb @@ -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 diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index 45b3de0439..e4de544469 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -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 diff --git a/app/forms/journeys/early_years_payment/provider/authenticated/check_your_answers_form.rb b/app/forms/journeys/early_years_payment/provider/authenticated/check_your_answers_form.rb new file mode 100644 index 0000000000..aabc2c5118 --- /dev/null +++ b/app/forms/journeys/early_years_payment/provider/authenticated/check_your_answers_form.rb @@ -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 diff --git a/app/forms/journeys/early_years_payment/provider/authenticated/claim_submission_form.rb b/app/forms/journeys/early_years_payment/provider/authenticated/claim_submission_form.rb index ca4302c99c..07ea12ec2a 100644 --- a/app/forms/journeys/early_years_payment/provider/authenticated/claim_submission_form.rb +++ b/app/forms/journeys/early_years_payment/provider/authenticated/claim_submission_form.rb @@ -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) diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 1f696937f3..e1f072fc09 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -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 diff --git a/app/models/claim.rb b/app/models/claim.rb index 0c8d418a54..c09e860c50 100644 --- a/app/models/claim.rb +++ b/app/models/claim.rb @@ -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 @@ -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 diff --git a/app/models/journeys/early_years_payment/provider/authenticated.rb b/app/models/journeys/early_years_payment/provider/authenticated.rb index 36e8af9cd1..ea61d8b3bd 100644 --- a/app/models/journeys/early_years_payment/provider/authenticated.rb +++ b/app/models/journeys/early_years_payment/provider/authenticated.rb @@ -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 diff --git a/app/models/journeys/early_years_payment/provider/authenticated/answers_presenter.rb b/app/models/journeys/early_years_payment/provider/authenticated/answers_presenter.rb new file mode 100644 index 0000000000..fbeaf33545 --- /dev/null +++ b/app/models/journeys/early_years_payment/provider/authenticated/answers_presenter.rb @@ -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 diff --git a/app/models/journeys/early_years_payment/provider/authenticated/session_answers.rb b/app/models/journeys/early_years_payment/provider/authenticated/session_answers.rb index e3e877e138..e2465370f4 100644 --- a/app/models/journeys/early_years_payment/provider/authenticated/session_answers.rb +++ b/app/models/journeys/early_years_payment/provider/authenticated/session_answers.rb @@ -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 diff --git a/app/views/early_years_payment/provider/authenticated/claims/check_your_answers.html.erb b/app/views/early_years_payment/provider/authenticated/claims/check_your_answers.html.erb index e69de29bb2..e87d45e799 100644 --- a/app/views/early_years_payment/provider/authenticated/claims/check_your_answers.html.erb +++ b/app/views/early_years_payment/provider/authenticated/claims/check_your_answers.html.erb @@ -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? + ) +) %> + +
<%= t("early_years_payment_provider_authenticated.check_your_answers.statement") %>
+ + <%= form.govuk_text_field :provider_contact_name, label: { text: "Your full name" }, spellcheck: "false" %> + +diff --git a/app/views/early_years_payment/provider/authenticated/claims/employee_email.html.erb b/app/views/early_years_payment/provider/authenticated/claims/employee_email.html.erb index 1978a95cf6..88c66c6529 100644 --- a/app/views/early_years_payment/provider/authenticated/claims/employee_email.html.erb +++ b/app/views/early_years_payment/provider/authenticated/claims/employee_email.html.erb @@ -3,6 +3,8 @@
+ We’ve sent a confirmation email to <%= submitted_claim.email_address %>. +
+ ++ 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. +
+ ++ For more information, read more about the + <%= govuk_link_to("early years financial incentive", "#") %>. +
+