diff --git a/app/models/claim.rb b/app/models/claim.rb index 1fbb6016b0..c598aa3aef 100644 --- a/app/models/claim.rb +++ b/app/models/claim.rb @@ -408,6 +408,10 @@ def has_ecp_or_lupp_policy? has_ecp_policy? || has_lupp_policy? end + def has_early_years_payments_policy? + policy == Policies::EarlyYearsPayments + end + def important_notes notes&.where(important: true) end diff --git a/app/models/policies/early_years_payments/admin_tasks_presenter.rb b/app/models/policies/early_years_payments/admin_tasks_presenter.rb new file mode 100644 index 0000000000..f45a049c0a --- /dev/null +++ b/app/models/policies/early_years_payments/admin_tasks_presenter.rb @@ -0,0 +1,20 @@ +module Policies + module EarlyYearsPayments + class AdminTasksPresenter + include Admin::PresenterMethods + + attr_reader :claim + + def initialize(claim) + @claim = claim + end + + def employment + [ + ["Current employment", claim.eligibility.eligible_ey_provider.nursery_name], + ["Start date", l(claim.eligibility.start_date)] + ] + end + end + end +end diff --git a/app/models/policies/early_years_payments/eligibility.rb b/app/models/policies/early_years_payments/eligibility.rb index f00d665786..ba3aa44f5a 100644 --- a/app/models/policies/early_years_payments/eligibility.rb +++ b/app/models/policies/early_years_payments/eligibility.rb @@ -25,6 +25,14 @@ def eligible_ey_provider def provider_claim_submitted? provider_claim_submitted_at.present? end + + def employment_task_available_at + start_date + 6.months + end + + def employment_task_available? + Date.today >= employment_task_available_at + end end end end diff --git a/app/models/task.rb b/app/models/task.rb index 8cfdd1e049..e0aa4c8679 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -53,4 +53,10 @@ def to_param def identity_confirmation? name == "identity_confirmation" end + + def employment_task_available? + return true unless claim.has_early_years_payments_policy? + + claim.eligibility.employment_task_available? + end end diff --git a/app/views/admin/tasks/employment.html.erb b/app/views/admin/tasks/employment.html.erb index 07f7608b50..11a1926c01 100644 --- a/app/views/admin/tasks/employment.html.erb +++ b/app/views/admin/tasks/employment.html.erb @@ -20,7 +20,11 @@ <% if @task.persisted? %> <%= render "task_outcome", task: @task, notes: @notes %> <% else %> - <%= render "form", task_name: "employment", claim: @claim %> + <% if @task.employment_task_available? %> + <%= render "form", task_name: "employment", claim: @claim %> + <% else %> + <%= govuk_inset_text(text: "This task will be available from #{l(@claim.eligibility.employment_task_available_at)}") %> + <% end %> <% end %> <%= render partial: "admin/task_pagination", locals: { task_pagination: @task_pagination } %> diff --git a/config/locales/en.yml b/config/locales/en.yml index a73920546a..714011aafa 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1451,6 +1451,9 @@ en: duplicate: Duplicate no_response: No response other: Other + task_questions: + employment: + title: Is the claimant still working at the current nursery above? early_years_payment_practitioner: journey_name: Claim an early years financial incentive payment - practitioner feedback_email: "help@opsteam.education.gov.uk" diff --git a/spec/models/claim_spec.rb b/spec/models/claim_spec.rb index 331b58ad28..fdd88b90f2 100644 --- a/spec/models/claim_spec.rb +++ b/spec/models/claim_spec.rb @@ -1149,6 +1149,27 @@ end end + describe "#has_early_years_payments_policy?" do + subject { claim.has_early_years_payments_policy? } + let(:claim) { create(:claim, :submitted, policy:) } + + context "with early years payements policy" do + let(:policy) { Policies::EarlyYearsPayments } + + it { is_expected.to be true } + end + + context "with other policies:" do + (Policies.all - [Policies::EarlyYearsPayments]).each do |policy| + context policy do + let(:policy) { policy } + + it { is_expected.to be false } + end + end + end + end + describe "#important_notes" do subject(:important_notes) do claim.important_notes diff --git a/spec/models/early_career_payments/admin_tasks_presenter_spec.rb b/spec/models/policies/early_career_payments/admin_tasks_presenter_spec.rb similarity index 100% rename from spec/models/early_career_payments/admin_tasks_presenter_spec.rb rename to spec/models/policies/early_career_payments/admin_tasks_presenter_spec.rb diff --git a/spec/models/early_career_payments/award_amount_calculator_spec.rb b/spec/models/policies/early_career_payments/award_amount_calculator_spec.rb similarity index 100% rename from spec/models/early_career_payments/award_amount_calculator_spec.rb rename to spec/models/policies/early_career_payments/award_amount_calculator_spec.rb diff --git a/spec/models/early_career_payments/dqt_record_spec.rb b/spec/models/policies/early_career_payments/dqt_record_spec.rb similarity index 100% rename from spec/models/early_career_payments/dqt_record_spec.rb rename to spec/models/policies/early_career_payments/dqt_record_spec.rb diff --git a/spec/models/early_career_payments/eligibility_admin_answers_presenter_spec.rb b/spec/models/policies/early_career_payments/eligibility_admin_answers_presenter_spec.rb similarity index 100% rename from spec/models/early_career_payments/eligibility_admin_answers_presenter_spec.rb rename to spec/models/policies/early_career_payments/eligibility_admin_answers_presenter_spec.rb diff --git a/spec/models/early_career_payments/eligibility_spec.rb b/spec/models/policies/early_career_payments/eligibility_spec.rb similarity index 100% rename from spec/models/early_career_payments/eligibility_spec.rb rename to spec/models/policies/early_career_payments/eligibility_spec.rb diff --git a/spec/models/early_career_payments/induction_data_spec.rb b/spec/models/policies/early_career_payments/induction_data_spec.rb similarity index 100% rename from spec/models/early_career_payments/induction_data_spec.rb rename to spec/models/policies/early_career_payments/induction_data_spec.rb diff --git a/spec/models/early_career_payments/school_check_email_data_export_presenter_spec.rb b/spec/models/policies/early_career_payments/school_check_email_data_export_presenter_spec.rb similarity index 100% rename from spec/models/early_career_payments/school_check_email_data_export_presenter_spec.rb rename to spec/models/policies/early_career_payments/school_check_email_data_export_presenter_spec.rb diff --git a/spec/models/early_career_payments/school_eligibility_spec.rb b/spec/models/policies/early_career_payments/school_eligibility_spec.rb similarity index 100% rename from spec/models/early_career_payments/school_eligibility_spec.rb rename to spec/models/policies/early_career_payments/school_eligibility_spec.rb diff --git a/spec/models/policies/early_years_payments/admin_tasks_presenter_spec.rb b/spec/models/policies/early_years_payments/admin_tasks_presenter_spec.rb new file mode 100644 index 0000000000..1e37d46268 --- /dev/null +++ b/spec/models/policies/early_years_payments/admin_tasks_presenter_spec.rb @@ -0,0 +1,26 @@ +require "rails_helper" + +RSpec.describe Policies::EarlyYearsPayments::AdminTasksPresenter do + describe "#employment" do + let(:claim) { + create(:claim, + :submitted, + policy: Policies::EarlyYearsPayments, + eligibility_attributes: { + nursery_urn: eligible_ey_provider.urn, + start_date: Date.new(2018, 1, 1) + }) + } + let(:eligible_ey_provider) { create(:eligible_ey_provider) } + + subject { described_class.new(claim).employment } + + it "shows current employment" do + expect(subject[0][1]).to eq claim.eligibility.eligible_ey_provider.nursery_name + end + + it "shows start date" do + expect(subject[1][1]).to eq "1 January 2018" + end + end +end diff --git a/spec/models/policies/early_years_payments/eligibility_spec.rb b/spec/models/policies/early_years_payments/eligibility_spec.rb new file mode 100644 index 0000000000..6753f30ad3 --- /dev/null +++ b/spec/models/policies/early_years_payments/eligibility_spec.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +require "rails_helper" + +RSpec.describe Policies::EarlyYearsPayments::Eligibility do + let(:eligibility) { build(:early_years_payments_eligibility, :eligible) } + + describe "#employment_task_available_at" do + subject { eligibility.employment_task_available_at } + + it { is_expected.to eq eligibility.start_date + 6.months } + end + + describe "#employment_task_available?" do + subject { eligibility.employment_task_available? } + + context "before 6 months from start date" do + before { travel_to eligibility.start_date } + + it { is_expected.to be false } + end + + context "exactly 6 months from start date" do + before { travel_to eligibility.start_date + 6.months } + + it { is_expected.to be true } + end + + context "after 6 months from start date" do + before { travel_to eligibility.start_date + 6.months + 1.day } + + it { is_expected.to be true } + end + end +end diff --git a/spec/models/levelling_up_premium_payments/academic_year_eligibility_spec.rb b/spec/models/policies/levelling_up_premium_payments/academic_year_eligibility_spec.rb similarity index 100% rename from spec/models/levelling_up_premium_payments/academic_year_eligibility_spec.rb rename to spec/models/policies/levelling_up_premium_payments/academic_year_eligibility_spec.rb diff --git a/spec/models/levelling_up_premium_payments/admin_tasks_presenter_spec.rb b/spec/models/policies/levelling_up_premium_payments/admin_tasks_presenter_spec.rb similarity index 100% rename from spec/models/levelling_up_premium_payments/admin_tasks_presenter_spec.rb rename to spec/models/policies/levelling_up_premium_payments/admin_tasks_presenter_spec.rb diff --git a/spec/models/levelling_up_premium_payments/award_csv_importer_spec.rb b/spec/models/policies/levelling_up_premium_payments/award_csv_importer_spec.rb similarity index 100% rename from spec/models/levelling_up_premium_payments/award_csv_importer_spec.rb rename to spec/models/policies/levelling_up_premium_payments/award_csv_importer_spec.rb diff --git a/spec/models/levelling_up_premium_payments/award_spec.rb b/spec/models/policies/levelling_up_premium_payments/award_spec.rb similarity index 100% rename from spec/models/levelling_up_premium_payments/award_spec.rb rename to spec/models/policies/levelling_up_premium_payments/award_spec.rb diff --git a/spec/models/levelling_up_premium_payments/dqt_record_spec.rb b/spec/models/policies/levelling_up_premium_payments/dqt_record_spec.rb similarity index 100% rename from spec/models/levelling_up_premium_payments/dqt_record_spec.rb rename to spec/models/policies/levelling_up_premium_payments/dqt_record_spec.rb diff --git a/spec/models/levelling_up_premium_payments/eligibility_admin_answers_presenter_spec.rb b/spec/models/policies/levelling_up_premium_payments/eligibility_admin_answers_presenter_spec.rb similarity index 100% rename from spec/models/levelling_up_premium_payments/eligibility_admin_answers_presenter_spec.rb rename to spec/models/policies/levelling_up_premium_payments/eligibility_admin_answers_presenter_spec.rb diff --git a/spec/models/levelling_up_premium_payments/eligibility_spec.rb b/spec/models/policies/levelling_up_premium_payments/eligibility_spec.rb similarity index 100% rename from spec/models/levelling_up_premium_payments/eligibility_spec.rb rename to spec/models/policies/levelling_up_premium_payments/eligibility_spec.rb diff --git a/spec/models/levelling_up_premium_payments/school_eligibility_spec.rb b/spec/models/policies/levelling_up_premium_payments/school_eligibility_spec.rb similarity index 100% rename from spec/models/levelling_up_premium_payments/school_eligibility_spec.rb rename to spec/models/policies/levelling_up_premium_payments/school_eligibility_spec.rb diff --git a/spec/models/student_loans/admin_tasks_presenter_spec.rb b/spec/models/policies/student_loans/admin_tasks_presenter_spec.rb similarity index 100% rename from spec/models/student_loans/admin_tasks_presenter_spec.rb rename to spec/models/policies/student_loans/admin_tasks_presenter_spec.rb diff --git a/spec/models/student_loans/dqt_record_spec.rb b/spec/models/policies/student_loans/dqt_record_spec.rb similarity index 100% rename from spec/models/student_loans/dqt_record_spec.rb rename to spec/models/policies/student_loans/dqt_record_spec.rb diff --git a/spec/models/student_loans/eligibility_admin_answers_presenter_spec.rb b/spec/models/policies/student_loans/eligibility_admin_answers_presenter_spec.rb similarity index 100% rename from spec/models/student_loans/eligibility_admin_answers_presenter_spec.rb rename to spec/models/policies/student_loans/eligibility_admin_answers_presenter_spec.rb diff --git a/spec/models/student_loans/eligibility_spec.rb b/spec/models/policies/student_loans/eligibility_spec.rb similarity index 100% rename from spec/models/student_loans/eligibility_spec.rb rename to spec/models/policies/student_loans/eligibility_spec.rb diff --git a/spec/models/student_loans/presenter_methods_spec.rb b/spec/models/policies/student_loans/presenter_methods_spec.rb similarity index 100% rename from spec/models/student_loans/presenter_methods_spec.rb rename to spec/models/policies/student_loans/presenter_methods_spec.rb diff --git a/spec/models/student_loans/school_eligibility_spec.rb b/spec/models/policies/student_loans/school_eligibility_spec.rb similarity index 100% rename from spec/models/student_loans/school_eligibility_spec.rb rename to spec/models/policies/student_loans/school_eligibility_spec.rb diff --git a/spec/models/task_spec.rb b/spec/models/task_spec.rb index 764c02ea05..6a6902b4ca 100644 --- a/spec/models/task_spec.rb +++ b/spec/models/task_spec.rb @@ -54,4 +54,37 @@ end end end + + describe "#employment_task_available?" do + subject { task.employment_task_available? } + + let(:task) { build(:task, claim: claim) } + let(:claim) { create(:claim, :submitted, policy:) } + + context "for claims with EarlyYearsPayments policy" do + let(:policy) { Policies::EarlyYearsPayments } + + context "when the task is available" do + let(:claim) { create(:claim, :submitted, policy:, eligibility_attributes: {start_date: 1.year.ago}) } + + it { is_expected.to be true } + end + + context "when the task is not yet available" do + let(:claim) { create(:claim, :submitted, policy:, eligibility_attributes: {start_date: 1.day.ago}) } + + it { is_expected.to be false } + end + end + + context "for claims with other policies" do + (Policies.all - [Policies::EarlyYearsPayments]).each do |policy| + context policy do + let(:policy) { policy } + + it { is_expected.to be true } + end + end + end + end end