From 1bbb4b581900df16455d91ba5524b9f67bbd0ae6 Mon Sep 17 00:00:00 2001 From: Phil Lee Date: Thu, 7 Nov 2024 10:21:26 +0000 Subject: [PATCH] EY start date eligibility --- .../provider/authenticated/start_date_form.rb | 11 ++++- app/models/policies/early_years_payments.rb | 1 + .../policy_eligibility_checker.rb | 2 + ...ty_start_date_before_policy_start.html.erb | 31 ++++++++++++ .../provider/start/landing_page.html.erb | 2 +- ..._payment_provider_authenticated_answers.rb | 2 +- .../admin/admin_ey_identity_task_spec.rb | 2 +- .../ineligible_start_date_spec.rb | 48 +++++++++++++++++++ .../authenticated/answers_presenter_spec.rb | 2 +- .../policy_eligibility_checker_spec.rb | 15 ++++++ 10 files changed, 111 insertions(+), 5 deletions(-) create mode 100644 app/views/early_years_payment/provider/authenticated/claims/_ineligibility_start_date_before_policy_start.html.erb create mode 100644 spec/features/early_years_payment/provider/authenticated/ineligible_start_date_spec.rb diff --git a/app/forms/journeys/early_years_payment/provider/authenticated/start_date_form.rb b/app/forms/journeys/early_years_payment/provider/authenticated/start_date_form.rb index 8a790f875d..9c34e4a204 100644 --- a/app/forms/journeys/early_years_payment/provider/authenticated/start_date_form.rb +++ b/app/forms/journeys/early_years_payment/provider/authenticated/start_date_form.rb @@ -8,7 +8,14 @@ class StartDateForm < Form attribute :start_date, :date validates :start_date, presence: {message: i18n_error_message(:presence)} - validates :start_date, comparison: {less_than: ->(_) { Date.tomorrow }, message: i18n_error_message(:date_not_in_future)}, if: :start_date + validates :start_date, + comparison: { + less_than: ->(_) { + Date.tomorrow + }, + message: i18n_error_message(:date_not_in_future) + }, + if: :start_date validate :start_year_has_four_digits, if: :start_date def initialize(journey_session:, journey:, params:) @@ -33,6 +40,8 @@ def nursery_name EligibleEyProvider.find_by(urn: answers.nursery_urn)&.nursery_name end + private + def start_year_has_four_digits if start_date.year < 1000 errors.add(:start_date, i18n_errors_path(:year_must_have_4_digits)) diff --git a/app/models/policies/early_years_payments.rb b/app/models/policies/early_years_payments.rb index eda56863aa..2354c7a024 100644 --- a/app/models/policies/early_years_payments.rb +++ b/app/models/policies/early_years_payments.rb @@ -3,6 +3,7 @@ module EarlyYearsPayments include BasePolicy extend self + POLICY_START_DATE = Date.new(2024, 11, 15) - 1.month # TODO: remove -1.month for launch RETENTION_PERIOD = 6.months OTHER_CLAIMABLE_POLICIES = [ 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 859a932a8f..10ae1492e8 100644 --- a/app/models/policies/early_years_payments/policy_eligibility_checker.rb +++ b/app/models/policies/early_years_payments/policy_eligibility_checker.rb @@ -38,6 +38,8 @@ def provider_ineligibility_reason :nursery_is_not_listed elsif answers.child_facing_confirmation_given == false :not_child_facing_enough + elsif answers.start_date && (answers.start_date < Policies::EarlyYearsPayments::POLICY_START_DATE) + :start_date_before_policy_start elsif ineligible_returner? :returner end diff --git a/app/views/early_years_payment/provider/authenticated/claims/_ineligibility_start_date_before_policy_start.html.erb b/app/views/early_years_payment/provider/authenticated/claims/_ineligibility_start_date_before_policy_start.html.erb new file mode 100644 index 0000000000..84329358e4 --- /dev/null +++ b/app/views/early_years_payment/provider/authenticated/claims/_ineligibility_start_date_before_policy_start.html.erb @@ -0,0 +1,31 @@ +<% title = "This person may not be eligible" %> +<% content_for(:page_title, page_title(title, journey: current_journey_routing_name)) %> +<% @backlink_path = claim_path(current_journey_routing_name, "start-date") %> + +
+
+

<%= title %>

+ +

+ This person needs to have started their role on or after <%= l(Policies::EarlyYearsPayments::POLICY_START_DATE) %>. +

+ +

+ Based on the date you’ve provided, this person is not eligible for an early years financial incentive payment. +

+ +

+ For further guidance, you should refer to the + <%= govuk_link_to "full eligibility criteria", claim_path(Journeys::EarlyYearsPayment::Provider::Start::ROUTING_NAME, "landing-page") %> + at the start of this service. +

+ +

Get help with your claim

+ +

+ Contact us for help at + <%= govuk_mail_to support_email_address(current_journey_routing_name), support_email_address(current_journey_routing_name) %> +

+ <%= govuk_button_link_to "Start again", claim_path(Journeys::EarlyYearsPayment::Provider::Start::ROUTING_NAME, "landing-page") %> +
+
diff --git a/app/views/early_years_payment/provider/start/landing_page.html.erb b/app/views/early_years_payment/provider/start/landing_page.html.erb index 84a7c02dc5..f5bf012213 100644 --- a/app/views/early_years_payment/provider/start/landing_page.html.erb +++ b/app/views/early_years_payment/provider/start/landing_page.html.erb @@ -15,7 +15,7 @@ <%= govuk_list [ "have applied for a job with an incentive attached", - "have started their job after 15 May 2024", + "have started their job on or after #{l(Policies::EarlyYearsPayments::POLICY_START_DATE)}", "spend most of the time in their job (70% or more) working directly with children - there is no minimum number of hours and applies to all EYFS part and full time roles" ], type: :bullet %> diff --git a/spec/factories/journeys/early_years_payment/provider/authenticated/early_years_payment_provider_authenticated_answers.rb b/spec/factories/journeys/early_years_payment/provider/authenticated/early_years_payment_provider_authenticated_answers.rb index 0b42fe541d..158fc802aa 100644 --- a/spec/factories/journeys/early_years_payment/provider/authenticated/early_years_payment_provider_authenticated_answers.rb +++ b/spec/factories/journeys/early_years_payment/provider/authenticated/early_years_payment_provider_authenticated_answers.rb @@ -11,7 +11,7 @@ surname { "Doe" } practitioner_first_name { "John" } practitioner_surname { "Doe" } - start_date { Date.parse("1/1/2024") } + start_date { Policies::EarlyYearsPayments::POLICY_START_DATE + 1.day } child_facing_confirmation_given { true } returning_within_6_months { true } practitioner_email_address { "johndoe@example.com" } diff --git a/spec/features/admin/admin_ey_identity_task_spec.rb b/spec/features/admin/admin_ey_identity_task_spec.rb index cbe281f354..23b1cc514c 100644 --- a/spec/features/admin/admin_ey_identity_task_spec.rb +++ b/spec/features/admin/admin_ey_identity_task_spec.rb @@ -263,7 +263,7 @@ def complete_provider_journey fill_in "Last name", with: "Bobberson" click_button "Continue" - date = Date.yesterday + date = Policies::EarlyYearsPayments::POLICY_START_DATE + 1.day fill_in("Day", with: date.day) fill_in("Month", with: date.month) fill_in("Year", with: date.year) diff --git a/spec/features/early_years_payment/provider/authenticated/ineligible_start_date_spec.rb b/spec/features/early_years_payment/provider/authenticated/ineligible_start_date_spec.rb new file mode 100644 index 0000000000..4373fcaf33 --- /dev/null +++ b/spec/features/early_years_payment/provider/authenticated/ineligible_start_date_spec.rb @@ -0,0 +1,48 @@ +require "rails_helper" + +RSpec.feature "Early years payment provider" do + let(:email_address) { "johndoe@example.com" } + let(:journey_session) { Journeys::EarlyYearsPayment::Provider::Authenticated::Session.last } + let(:mail) { ActionMailer::Base.deliveries.last } + let(:magic_link) { mail[:personalisation].unparsed_value[:magic_link] } + let!(:nursery) { create(:eligible_ey_provider, primary_key_contact_email_address: email_address) } + + scenario "magic link onwards" do + when_early_years_payment_provider_authenticated_journey_configuration_exists + when_early_years_payment_provider_start_journey_completed + + visit magic_link + expect(page).to have_content("Declaration of Employee Consent") + expect(page.current_path).to eq "/early-years-payment-provider/consent" + check "I confirm that I have obtained consent from my employee and have provided them with the relevant privacy notice." + click_button "Continue" + + expect(journey_session.reload.answers.email_address).to be nil + expect(journey_session.reload.answers.email_verified).to be nil + expect(journey_session.reload.answers.provider_email_address).to eq email_address + + expect(page.current_path).to eq "/early-years-payment-provider/current-nursery" + choose nursery.nursery_name + click_button "Continue" + + expect(page.current_path).to eq "/early-years-payment-provider/paye-reference" + expect(page).to have_content("What is #{nursery.nursery_name}’s employer PAYE reference?") + fill_in "claim-paye-reference-field", with: "123/123456SE90" + click_button "Continue" + + expect(page.current_path).to eq "/early-years-payment-provider/claimant-name" + fill_in "First name", with: "Bobby" + fill_in "Last name", with: "Bobberson" + click_button "Continue" + + expect(page.current_path).to eq "/early-years-payment-provider/start-date" + date = Policies::EarlyYearsPayments::POLICY_START_DATE - 10.days + fill_in("Day", with: date.day) + fill_in("Month", with: date.month) + fill_in("Year", with: date.year) + click_button "Continue" + + expect(page.current_path).to eq "/early-years-payment-provider/ineligible" + expect(page).to have_content("This person may not be eligible") + end +end diff --git a/spec/models/journeys/early_years_payment/provider/authenticated/answers_presenter_spec.rb b/spec/models/journeys/early_years_payment/provider/authenticated/answers_presenter_spec.rb index 77c7cf1ded..57414f0a63 100644 --- a/spec/models/journeys/early_years_payment/provider/authenticated/answers_presenter_spec.rb +++ b/spec/models/journeys/early_years_payment/provider/authenticated/answers_presenter_spec.rb @@ -31,7 +31,7 @@ ], [ "Employee’s start date", - "1 January 2024", + (Policies::EarlyYearsPayments::POLICY_START_DATE + 1.day).strftime("%d %B %Y"), "start-date" ], [ diff --git a/spec/models/policies/early_years_payments/policy_eligibility_checker_spec.rb b/spec/models/policies/early_years_payments/policy_eligibility_checker_spec.rb index 1c8d494816..ce23ad0cbc 100644 --- a/spec/models/policies/early_years_payments/policy_eligibility_checker_spec.rb +++ b/spec/models/policies/early_years_payments/policy_eligibility_checker_spec.rb @@ -4,6 +4,21 @@ subject { described_class.new(answers: answers) } describe "#status, #ineligible?, #ineligibility_reason" do + context "start date is before POLICY_START_DATE" do + let(:answers) do + build( + :early_years_payment_answers, + start_date: Policies::EarlyYearsPayments::POLICY_START_DATE - 1.day + ) + end + + it "is not eligible" do + expect(subject).to be_ineligible + expect(subject.status).to eql(:ineligible) + expect(subject.ineligibility_reason).to eql(:start_date_before_policy_start) + end + end + context "not a returner" do let(:answers) do build(