From 94d94a1d2175f4c24002e30197013e8f923193d5 Mon Sep 17 00:00:00 2001 From: vacabor <166112501+vacabor@users.noreply.github.com> Date: Mon, 7 Oct 2024 10:22:57 +0100 Subject: [PATCH] [LUPEYALPHA-1061] Practitioner invalid reference screen (#3279) --- .../practitioner/find_reference_form.rb | 14 +---- .../practitioner/session_answers.rb | 1 + .../practitioner/slug_sequence.rb | 8 ++- .../policy_eligibility_checker.rb | 12 +++- ...bility_reference_number_not_found.html.erb | 25 ++++++++ .../practitioner/claims/ineligible.html.erb | 2 + config/locales/en.yml | 5 +- .../practitioner/find_reference_spec.rb | 27 ++++++-- .../practitioner/find_reference_form_spec.rb | 62 +++++++++++-------- 9 files changed, 106 insertions(+), 50 deletions(-) create mode 100644 app/views/early_years_payment/practitioner/claims/_ineligibility_reference_number_not_found.html.erb create mode 100644 app/views/early_years_payment/practitioner/claims/ineligible.html.erb diff --git a/app/forms/journeys/early_years_payment/practitioner/find_reference_form.rb b/app/forms/journeys/early_years_payment/practitioner/find_reference_form.rb index cc16691389..89f7055c1f 100644 --- a/app/forms/journeys/early_years_payment/practitioner/find_reference_form.rb +++ b/app/forms/journeys/early_years_payment/practitioner/find_reference_form.rb @@ -6,14 +6,14 @@ class FindReferenceForm < Form attribute :email, :string validates :reference_number, presence: {message: i18n_error_message(:presence)} - validate :validate_permissible_reference_number def save return false if invalid? journey_session.answers.assign_attributes( reference_number:, - start_email: email + start_email: email, + reference_number_found: claim_exists? ) journey_session.save! end @@ -27,16 +27,6 @@ def claim_exists? .where(practitioner_email_address: email) .exists? end - - def validate_permissible_reference_number - unless claim_exists? - errors.add( - :reference_number, - :impermissible, - message: self.class.i18n_error_message(:impermissible) - ) - end - end end end end diff --git a/app/models/journeys/early_years_payment/practitioner/session_answers.rb b/app/models/journeys/early_years_payment/practitioner/session_answers.rb index 4e96aefd5e..2415e58378 100644 --- a/app/models/journeys/early_years_payment/practitioner/session_answers.rb +++ b/app/models/journeys/early_years_payment/practitioner/session_answers.rb @@ -3,6 +3,7 @@ module EarlyYearsPayment module Practitioner class SessionAnswers < Journeys::SessionAnswers attribute :reference_number, :string + attribute :reference_number_found, :boolean, default: nil attribute :start_email, :string def policy diff --git a/app/models/journeys/early_years_payment/practitioner/slug_sequence.rb b/app/models/journeys/early_years_payment/practitioner/slug_sequence.rb index 249ea9e7b8..c917a3b1e5 100644 --- a/app/models/journeys/early_years_payment/practitioner/slug_sequence.rb +++ b/app/models/journeys/early_years_payment/practitioner/slug_sequence.rb @@ -2,7 +2,7 @@ module Journeys module EarlyYearsPayment module Practitioner class SlugSequence - SLUGS = %w[ + CLAIM_SLUGS = %w[ find-reference sign-in how-we-use-your-information @@ -14,6 +14,12 @@ class SlugSequence check-your-answers ].freeze + RESULTS_SLUGS = %w[ + ineligible + ].freeze + + SLUGS = (CLAIM_SLUGS + RESULTS_SLUGS).freeze + def self.start_page_url Rails.application.routes.url_helpers.landing_page_path("early-years-payment-practitioner") end diff --git a/app/models/policies/early_years_payments/policy_eligibility_checker.rb b/app/models/policies/early_years_payments/policy_eligibility_checker.rb index 7cb772b3f1..67f5908415 100644 --- a/app/models/policies/early_years_payments/policy_eligibility_checker.rb +++ b/app/models/policies/early_years_payments/policy_eligibility_checker.rb @@ -20,7 +20,7 @@ def ineligible? end def ineligibility_reason - start_ineligibility_reason || authenticated_ineligibility_reason + start_ineligibility_reason || provider_ineligibility_reason || practitioner_ineligibility_reason end def start_ineligibility_reason @@ -31,7 +31,7 @@ def start_ineligibility_reason end end - def authenticated_ineligibility_reason + def provider_ineligibility_reason return nil unless answers.is_a?(Journeys::EarlyYearsPayment::Provider::Authenticated::SessionAnswers) if answers.nursery_urn.to_s == "none_of_the_above" @@ -43,6 +43,14 @@ def authenticated_ineligibility_reason end end + def practitioner_ineligibility_reason + return nil unless answers.is_a?(Journeys::EarlyYearsPayment::Practitioner::SessionAnswers) + + if answers.reference_number_found == false + :reference_number_not_found + end + end + private def ineligible_returner? diff --git a/app/views/early_years_payment/practitioner/claims/_ineligibility_reference_number_not_found.html.erb b/app/views/early_years_payment/practitioner/claims/_ineligibility_reference_number_not_found.html.erb new file mode 100644 index 0000000000..b4877a8bd6 --- /dev/null +++ b/app/views/early_years_payment/practitioner/claims/_ineligibility_reference_number_not_found.html.erb @@ -0,0 +1,25 @@ +<% content_for(:page_title, page_title("There is a problem", journey: current_journey_routing_name)) %> +<% @backlink_path = claim_path(current_journey_routing_name, "find-reference", request.query_parameters) %> + +
+ This claim reference isn’t correct. Check your invite email. +
+ ++ Your employer will also have the claim reference in their claim confirmation email. +
+ ++ Contact us at + <%= govuk_link_to t("early_years_payment_practitioner.feedback_email"), "mailto:#{t("early_years_payment_practitioner.feedback_email")}", no_visited_state: true %>. + if you need further assistance to sign into the early years financial incentive payments service. +
+ + <%= govuk_button_link_to "Try again", claim_path(current_journey_routing_name, "find-reference", request.query_parameters) %> +