Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CAPT-1921] EY claim index data #3366

Merged
merged 2 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/helpers/admin/claims_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ def claim_route(claim)
def identity_confirmation_task_claim_verifier_match_status_tag(claim)
task = claim.tasks.detect { |t| t.name == "identity_confirmation" }

if task.nil?
if claim.policy == Policies::EarlyYearsPayments && !claim.eligibility.practitioner_journey_completed?
status = "Incomplete"
status_colour = "grey"
elsif task.nil?
status = "Unverified"
status_colour = "grey"
elsif task.passed?
Expand Down
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
4 changes: 4 additions & 0 deletions spec/factories/claims.rb
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,10 @@
end
end

trait :awaiting_practitioner do
submitted_at { nil }
end

trait :with_dqt_teacher_status do
dqt_teacher_status do
{
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
19 changes: 18 additions & 1 deletion spec/helpers/admin/claims_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@
end

describe "#identity_confirmation_task_claim_verifier_match_status_tag" do
subject(:identity_confirmation_task_claim_verifier_match_status_tag) { helper.identity_confirmation_task_claim_verifier_match_status_tag(claim) }
subject(:identity_confirmation_task_claim_verifier_match_status_tag) do
helper.identity_confirmation_task_claim_verifier_match_status_tag(claim)
end

let(:claim) do
build(
Expand All @@ -182,6 +184,21 @@
)
end

context "EY specific and practitioner yet to complete their half" do
let(:claim) do
build(
:claim,
:awaiting_practitioner,
policy: Policies::EarlyYearsPayments
)
end

it "return incomplete grey tag" do
expect(subject).to match("Incomplete")
expect(subject).to match("grey")
end
end

context "without task" do
let(:claim_tasks) { [] }

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