Skip to content

Commit

Permalink
decision deadline for EY is start date + 6 months
Browse files Browse the repository at this point in the history
  • Loading branch information
asmega committed Nov 6, 2024
1 parent de6c1ed commit ce2f9d6
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 19 deletions.
4 changes: 4 additions & 0 deletions app/models/base_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,8 @@ def auto_check_student_loan_plan_task?
def approvable?(claim)
true
end

def decision_deadline_date(claim)
(claim.submitted_at + Claim::DECISION_DEADLINE).to_date
end
end
2 changes: 1 addition & 1 deletion app/models/claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,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 = ", ")
Expand Down
4 changes: 4 additions & 0 deletions app/models/policies/early_years_payments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,9 @@ def auto_check_student_loan_plan_task?
def approvable?(claim)
claim.tasks.find_or_initialize_by(name: "employment").passed?
end

def decision_deadline_date(claim)
claim.eligibility.start_date + RETENTION_PERIOD
end
end
end
2 changes: 1 addition & 1 deletion app/views/admin/claims/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<% if claims_with_warning.nonzero? %>
<td class="govuk-table__cell"><%= decision_deadline_warning(claim) %></td>
<% end %>
<td class="govuk-table__cell"><%= l(claim.decision_deadline_date) if claim.submitted? %></td>
<td class="govuk-table__cell"><%= l(claim.decision_deadline_date) if claim.decision_deadline_date %></td>
<td class="govuk-table__cell"><%= claim.assigned_to.present? ? claim.assigned_to.full_name.titleize : nil %></td>
</tr>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions spec/models/base_policy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 6 additions & 10 deletions spec/models/claim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1457,19 +1457,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
8 changes: 8 additions & 0 deletions spec/models/policies/early_years_payments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,12 @@
end
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
11 changes: 7 additions & 4 deletions spec/support/page_matchers.rb
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit ce2f9d6

Please sign in to comment.