From 8abfad7816f919fcb81ce9b9b2c87d796866f7a2 Mon Sep 17 00:00:00 2001 From: Phil Lee Date: Wed, 6 Nov 2024 12:39:19 +0000 Subject: [PATCH] decision deadline for EY is start date + 6 months --- app/models/base_policy.rb | 4 ++++ app/models/claim.rb | 2 +- app/models/policies/early_years_payments.rb | 4 ++++ app/views/admin/claims/index.html.erb | 2 +- ...admin_view_claim_early_years_payments_spec.rb | 2 +- ..._view_full_claim_early_years_payments_spec.rb | 4 ++-- spec/models/base_policy_spec.rb | 8 ++++++++ spec/models/claim_spec.rb | 16 ++++++---------- .../models/policies/early_years_payments_spec.rb | 8 ++++++++ spec/support/page_matchers.rb | 11 +++++++---- 10 files changed, 42 insertions(+), 19 deletions(-) diff --git a/app/models/base_policy.rb b/app/models/base_policy.rb index 08ce571683..5f8def046c 100644 --- a/app/models/base_policy.rb +++ b/app/models/base_policy.rb @@ -58,4 +58,8 @@ def further_education_payments? def auto_check_student_loan_plan_task? false end + + def decision_deadline_date(claim) + (claim.submitted_at + Claim::DECISION_DEADLINE).to_date + end end diff --git a/app/models/claim.rb b/app/models/claim.rb index 97c1964a38..a65108b040 100644 --- a/app/models/claim.rb +++ b/app/models/claim.rb @@ -323,7 +323,7 @@ def payment_prevented_by_other_claims? end def decision_deadline_date - (submitted_at + DECISION_DEADLINE).to_date if submitted? + policy.decision_deadline_date(self) end def address(separator = ", ") diff --git a/app/models/policies/early_years_payments.rb b/app/models/policies/early_years_payments.rb index 299b0bf25f..40c4e1f42d 100644 --- a/app/models/policies/early_years_payments.rb +++ b/app/models/policies/early_years_payments.rb @@ -72,5 +72,9 @@ def award_amount def auto_check_student_loan_plan_task? true end + + def decision_deadline_date(claim) + claim.eligibility.start_date + RETENTION_PERIOD + end end end diff --git a/app/views/admin/claims/index.html.erb b/app/views/admin/claims/index.html.erb index 85599ec91b..64f5c251ff 100644 --- a/app/views/admin/claims/index.html.erb +++ b/app/views/admin/claims/index.html.erb @@ -86,7 +86,7 @@ <% if claims_with_warning.nonzero? %> <%= decision_deadline_warning(claim) %> <% end %> - <%= l(claim.decision_deadline_date) if claim.submitted? %> + <%= l(claim.decision_deadline_date) if claim.decision_deadline_date %> <%= claim.assigned_to.present? ? claim.assigned_to.full_name.titleize : nil %> <% end %> diff --git a/spec/features/admin/admin_view_claim_early_years_payments_spec.rb b/spec/features/admin/admin_view_claim_early_years_payments_spec.rb index 19ece4a079..a5c9e23733 100644 --- a/spec/features/admin/admin_view_claim_early_years_payments_spec.rb +++ b/spec/features/admin/admin_view_claim_early_years_payments_spec.rb @@ -54,7 +54,7 @@ expect(page).to have_summary_item(key: "Mobile number", value: practitioner_claim.mobile_number) expect(page).to have_summary_item(key: "Reference", value: practitioner_claim.reference) expect(page).to have_summary_item(key: "Submitted", value: practitioner_claim.submitted_at.strftime(I18n.t("time.formats.default"))) - expect(page).to have_summary_item(key: "Decision due", value: practitioner_claim.decision_deadline_date.strftime(I18n.t("date.formats.default"))) + expect(page).to have_summary_item(key: "Decision due", value: practitioner_claim.decision_deadline_date.strftime(I18n.t("date.formats.default")), exact_text: false) expect(page).to have_summary_item(key: "Status", value: "Awaiting decision - not on hold") expect(page).to have_summary_item(key: "Claim amount", value: "£0.00") expect(page).to have_summary_item(key: "PAYE reference", value: "123/ABC") diff --git a/spec/features/admin/admin_view_full_claim_early_years_payments_spec.rb b/spec/features/admin/admin_view_full_claim_early_years_payments_spec.rb index 6655992c4d..f6d516850a 100644 --- a/spec/features/admin/admin_view_full_claim_early_years_payments_spec.rb +++ b/spec/features/admin/admin_view_full_claim_early_years_payments_spec.rb @@ -131,8 +131,8 @@ expect(summary_row("Provider submitted at")).to have_content("2 January 2020 12:00pm") expect(summary_row("Claimant started at")).to have_content("3 January 2020 12:00pm") expect(summary_row("Claimant submitted at")).to have_content("4 January 2020 12:00") - expect(summary_row("Decision deadline")).to have_content("28 March 2020") - expect(summary_row("Overdue")).to have_content("N/A") + expect(page).to have_summary_item(key: "Decision deadline", value: "1 July 2018") + expect(summary_row("Overdue")).to have_content("-580 days") end end diff --git a/spec/models/base_policy_spec.rb b/spec/models/base_policy_spec.rb index abc200c266..f4ee6b97bd 100644 --- a/spec/models/base_policy_spec.rb +++ b/spec/models/base_policy_spec.rb @@ -112,4 +112,12 @@ class Eligibility expect(Policies::TestPolicyA.searchable_eligibility_attributes).to be_empty end end + + describe "#decision_deadline_date" do + let(:claim) { build(:claim, :submitted) } + + it "is 12 weeks after submitted date" do + expect(Policies::TestPolicy.decision_deadline_date(claim)).to eql((claim.submitted_at + 12.weeks).to_date) + end + end end diff --git a/spec/models/claim_spec.rb b/spec/models/claim_spec.rb index a526d9bafd..7f37e89f7e 100644 --- a/spec/models/claim_spec.rb +++ b/spec/models/claim_spec.rb @@ -1427,19 +1427,15 @@ end describe "#decision_deadline_date" do - subject { claim.decision_deadline_date } + let(:policy) { Policies.all.sample } + let(:claim) { create(:claim, :eligible, :early_years_provider_submitted, policy:) } - before { travel_to Date.new(2024, 1, 1) } + it "delegates to policy" do + allow(policy).to receive(:decision_deadline_date) - context "when submitted_at populated" do - let(:claim) { create(:claim, :early_years_provider_submitted, policy: Policies::EarlyYearsPayments) } - it { is_expected.to eq nil } - end - - context "when submitted_at not populated" do - let(:claim) { create(:claim, :submitted, policy: Policies::EarlyYearsPayments) } + claim.decision_deadline_date - it { is_expected.to eq Date.new(2024, 3, 25) } + expect(policy).to have_received(:decision_deadline_date).with(claim) end end end diff --git a/spec/models/policies/early_years_payments_spec.rb b/spec/models/policies/early_years_payments_spec.rb index f8bd407827..2d8abd1d57 100644 --- a/spec/models/policies/early_years_payments_spec.rb +++ b/spec/models/policies/early_years_payments_spec.rb @@ -6,4 +6,12 @@ expect(described_class::VERIFIERS).not_to include(AutomatedChecks::ClaimVerifiers::Identity) end end + + describe "#decision_deadline_date" do + let(:claim) { build(:claim, :eligible, policy: Policies::EarlyYearsPayments) } + + it "is 6 months after start date" do + expect(described_class.decision_deadline_date(claim)).to eql((claim.eligibility.start_date + 6.months).to_date) + end + end end diff --git a/spec/support/page_matchers.rb b/spec/support/page_matchers.rb index 9e119dc8b4..e4d9da309f 100644 --- a/spec/support/page_matchers.rb +++ b/spec/support/page_matchers.rb @@ -1,18 +1,21 @@ module PageMatchers # Matcher for items within the [Summary list](https://design-system.service.gov.uk/components/summary-list/) component. class HaveSummaryItem - def initialize(key:, value:) + attr_reader :exact_text + + def initialize(key:, value:, exact_text: true) @key = key @value = value + @exact_text = exact_text end def matches?(page) - page.find("dt", text: @key, exact_text: true).sibling("dd", text: @value, exact_text: true) + page.find("dt", text: @key, exact_text:).sibling("dd", text: @value, exact_text:) end end - def have_summary_item(key:, value:) - HaveSummaryItem.new(key: key, value: value) + def have_summary_item(key:, value:, exact_text: true) + HaveSummaryItem.new(key:, value:, exact_text:) end def have_summary_error(text)