Skip to content

Commit

Permalink
Merge branch 'master' into LUPEYALPHA-1061-invalid-reference-number
Browse files Browse the repository at this point in the history
  • Loading branch information
vacabor authored Oct 7, 2024
2 parents ebcd90d + dc656f2 commit a95ad86
Show file tree
Hide file tree
Showing 11 changed files with 169 additions and 18 deletions.
2 changes: 1 addition & 1 deletion app/forms/admin/claims_filter_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def claims
when "awaiting_provider_verification"
Claim.by_policy(Policies::FurtherEducationPayments).awaiting_further_education_provider_verification
else
Claim.includes(:decisions).not_held.awaiting_decision
Claim.includes(:decisions).not_held.awaiting_decision.not_awaiting_further_education_provider_verification
end

@claims = @claims.by_policy(selected_policy) if selected_policy
Expand Down
4 changes: 3 additions & 1 deletion app/helpers/admin/claims_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ def claim_summary_heading(claim)
end

def status(claim)
if claim.all_payrolled?
if claim.awaiting_provider_verification?
"Awaiting provider verification"
elsif claim.all_payrolled?
"Payrolled"
elsif claim.latest_decision&.approved? && claim.awaiting_qa? && !claim.held?
"Approved awaiting QA"
Expand Down
18 changes: 18 additions & 0 deletions app/models/claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,15 @@ class Claim < ApplicationRecord
scope :qa_required, -> { where(qa_required: true) }
scope :awaiting_further_education_provider_verification, -> do
joins("INNER JOIN further_education_payments_eligibilities ON further_education_payments_eligibilities.id = claims.eligibility_id")
.left_outer_joins(:notes)
.where("further_education_payments_eligibilities.verification = '{}'")
.and(
Claim.where("further_education_payments_eligibilities.flagged_as_duplicate = FALSE")
.or(Claim.where("further_education_payments_eligibilities.flagged_as_duplicate = TRUE").and(Claim.where(notes: {label: "provider_verification"})))
)
end
scope :not_awaiting_further_education_provider_verification, -> do
where.not(id: Claim.awaiting_further_education_provider_verification)
end

def onelogin_idv_full_name
Expand Down Expand Up @@ -439,6 +447,12 @@ def one_login_idv_mismatch?
!one_login_idv_name_match? || !one_login_idv_dob_match?
end

def awaiting_provider_verification?
return false unless has_further_education_policy?

eligibility.awaiting_provider_verification?
end

private

def one_login_idv_name_match?
Expand All @@ -449,6 +463,10 @@ def one_login_idv_dob_match?
onelogin_idv_date_of_birth == date_of_birth
end

def has_further_education_policy?
policy == Policies::FurtherEducationPayments
end

def normalise_ni_number
self.national_insurance_number = normalised_ni_number
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def admin_sent_emails
end

def verification_email_sent?
!claim.eligibility.flagged_as_duplicate? || verification_email_sent_by_admin_team?
claim.eligibility.awaiting_provider_verification?
end

def verification_email_sent_by_admin_team?
Expand Down
7 changes: 7 additions & 0 deletions app/models/policies/further_education_payments/eligibility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ def permanent_contract?
def verified?
verification.present?
end

def awaiting_provider_verification?
return false if verified?

# when a provider verification email is sent by the admin team, a note is created
!flagged_as_duplicate? || claim.notes.where(label: "provider_verification").any?
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
association :school, factory: :fe_eligible_school
end

trait :duplicate do
flagged_as_duplicate { true }
end

trait :verified do
contract_type { "permanent" }
teaching_responsibilities { true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
describe "provider verification task" do
context "when the provider is yet to verify the claim" do
context "when a verification email has not been sent" do
it "allows the admins to sent the email" do
it "allows the admins to send the email" do
fe_provider = create(
:school,
:further_education,
Expand Down
4 changes: 3 additions & 1 deletion spec/features/admin/admin_claims_filtering_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
let(:auto_approved_awaiting_payroll_claims) { create_list(:claim, 2, :auto_approved, policy: Policies::LevellingUpPremiumPayments) }
let(:approved_claim) { create(:claim, :approved, policy: Policies::LevellingUpPremiumPayments, assigned_to: mette, decision_creator: mary) }
let(:further_education_claims_awaiting_provider_verification) { create_list(:claim, 2, :submitted, policy: Policies::FurtherEducationPayments, eligibility_trait: :not_verified, assigned_to: valentino) }
let(:further_education_claims_provider_verification_email_not_sent) { create_list(:claim, 2, :submitted, policy: Policies::FurtherEducationPayments, eligibility_trait: :duplicate, assigned_to: valentino) }
let(:rejected_claim) { create(:claim, :rejected, policy: Policies::LevellingUpPremiumPayments, assigned_to: valentino) }

let!(:claims) do
Expand All @@ -38,6 +39,7 @@
auto_approved_awaiting_payroll_claims,
approved_claim,
further_education_claims_awaiting_provider_verification,
further_education_claims_provider_verification_email_not_sent,
rejected_claim
]
end
Expand Down Expand Up @@ -124,7 +126,7 @@
early_career_payments_claims_for_mette,
early_career_payments_claims_failed_bank_validation,
lup_claims_unassigned,
further_education_claims_awaiting_provider_verification
further_education_claims_provider_verification_email_not_sent
)

select "Awaiting provider verification", from: "Status:"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

RSpec.feature "Admin view claim for FurtherEducationPayments" do
let!(:journey_configuration) { create(:journey_configuration, "further_education_payments") }
let(:eligibility) { create(:further_education_payments_eligibility, :eligible) }
let(:eligibility_with_trn) { create(:further_education_payments_eligibility, :eligible, :with_trn) }
let!(:claim) {
create(
:claim,
:submitted,
policy: Policies::FurtherEducationPayments,
eligibility: eligibility
eligibility_trait: :duplicate
)
}
let!(:claim_with_trn) {
Expand All @@ -20,9 +19,45 @@
eligibility: eligibility_with_trn
)
}
let!(:claim_not_verified) {
create(
:claim,
:submitted,
policy: Policies::FurtherEducationPayments,
eligibility_trait: :not_verified
)
}
let!(:claim_with_duplicates_no_provider_email_sent) {
create(
:claim,
:submitted,
policy: Policies::FurtherEducationPayments,
eligibility_trait: :duplicate
)
}
let!(:claim_with_duplicates_provider_email_sent) {
create(
:claim,
:submitted,
policy: Policies::FurtherEducationPayments,
eligibility_trait: :duplicate
)
}
let!(:verified_claim) {
create(
:claim,
:submitted,
policy: Policies::FurtherEducationPayments,
eligibility_trait: :verified
)
}

scenario "view claim summary for claim with no TRN" do
before do
sign_in_as_service_operator
create(:note, claim: claim_with_duplicates_provider_email_sent, label: "provider_verification")
end

scenario "view claim summary for claim with no TRN" do
visit admin_claims_path
find("a[href='#{admin_claim_tasks_path(claim)}']").click
expect(page).not_to have_content("Claim route")
Expand All @@ -33,12 +68,29 @@
end

scenario "view claim summary for claim with TRN" do
sign_in_as_service_operator
visit admin_claims_path
find("a[href='#{admin_claim_tasks_path(claim_with_trn)}']").click
expect(page).not_to have_content("Not provided")
expect(page).to have_content(claim_with_trn.eligibility.teacher_reference_number)
expect(page).to have_content("UK Provider Reference Number (UKPRN)")
expect(page).to have_content(claim_with_trn.school.ukprn)
end

scenario "Awaiting provider verification claim status" do
visit admin_claims_path(status: "awaiting_provider_verification")
find("a[href='#{admin_claim_tasks_path(claim_not_verified)}']").click
expect(page).to have_content("Awaiting provider verification")

visit admin_claims_path
find("a[href='#{admin_claim_tasks_path(claim_with_duplicates_no_provider_email_sent)}']").click
expect(page).to have_content("Awaiting decision - not on hold")

visit admin_claims_path(status: "awaiting_provider_verification")
find("a[href='#{admin_claim_tasks_path(claim_with_duplicates_provider_email_sent)}']").click
expect(page).to have_content("Awaiting provider verification")

visit admin_claims_path
find("a[href='#{admin_claim_tasks_path(verified_claim)}']").click
expect(page).to have_content("Awaiting decision - not on hold")
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
eligibility: build(
:further_education_payments_eligibility,
:eligible,
:verified,
provider_verification_email_last_sent_at: DateTime.new(2024, 10, 1, 7, 0, 0)
))
}
Expand All @@ -59,7 +58,6 @@
eligibility: build(
:further_education_payments_eligibility,
:eligible,
:verified,
provider_verification_email_last_sent_at: DateTime.new(2024, 9, 1, 8, 0, 0),
provider_verification_chase_email_last_sent_at: DateTime.new(2024, 9, 22, 8, 0, 0)
))
Expand All @@ -83,7 +81,7 @@
policy: Policies::FurtherEducationPayments,
eligibility: build(
:further_education_payments_eligibility,
:eligible,
:not_verified,
provider_verification_email_last_sent_at: DateTime.new(2024, 10, 1, 7, 0, 0)
))
}
Expand Down
80 changes: 74 additions & 6 deletions spec/models/claim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -906,15 +906,45 @@
end
end

describe ".awaiting_further_education_provider_verification" do
subject { described_class.awaiting_further_education_provider_verification }

describe "awaiting further education provider verification scopes" do
let!(:claim_not_verified_provider_email_automatically_sent) { create(:claim, :submitted, policy: Policies::FurtherEducationPayments, eligibility_trait: :not_verified) }
let!(:claim_not_verified_has_duplicates_provider_email_not_sent_has_other_note) { create(:claim, :submitted, policy: Policies::FurtherEducationPayments, eligibility_trait: :duplicate) }
let!(:claim_not_verified_has_duplicates_provider_email_not_sent) { create(:claim, :submitted, policy: Policies::FurtherEducationPayments, eligibility_trait: :duplicate) }
let!(:claim_not_verified_has_duplicates_provider_email_manually_sent) { create(:claim, :submitted, policy: Policies::FurtherEducationPayments, eligibility_trait: :duplicate) }
let!(:claim_with_fe_provider_verification) { create(:claim, policy: Policies::FurtherEducationPayments, eligibility_trait: :verified) }
let!(:claim_awaiting_fe_provider_verification) { create(:claim, policy: Policies::FurtherEducationPayments, eligibility_trait: :not_verified) }
let!(:non_fe_claim) { create(:claim, policy: Policies::StudentLoans) }

it "returns claims that are awaiting FE provider verification" do
is_expected.to match_array([claim_awaiting_fe_provider_verification])
before do
create(:note, claim: claim_not_verified_has_duplicates_provider_email_manually_sent, label: "provider_verification")
create(:note, claim: claim_not_verified_has_duplicates_provider_email_not_sent_has_other_note, label: "student_loan_plan")
end

describe ".awaiting_further_education_provider_verification" do
subject { described_class.awaiting_further_education_provider_verification }

it "returns claims that have not been verified by the provider, and have had a provider email sent" do
is_expected.to match_array(
[
claim_not_verified_provider_email_automatically_sent,
claim_not_verified_has_duplicates_provider_email_manually_sent
]
)
end
end

describe ".not_awaiting_further_education_provider_verification" do
subject { described_class.not_awaiting_further_education_provider_verification }

it "returns claims that have no FE eligiblity, or FE claims that have been verified by the provider, or non-verified claims where a provider email has not been sent" do
is_expected.to match_array(
[
claim_not_verified_has_duplicates_provider_email_not_sent_has_other_note,
claim_not_verified_has_duplicates_provider_email_not_sent,
claim_with_fe_provider_verification,
non_fe_claim
]
)
end
end
end

Expand Down Expand Up @@ -1330,4 +1360,42 @@
it { is_expected.to be false }
end
end

describe "#awaiting_provider_verification?" do
subject { claim.awaiting_provider_verification? }

context "when the eligiblity is not verified" do
context "when there are no duplicates" do
let(:claim) { create(:claim, :submitted, policy: Policies::FurtherEducationPayments, eligibility_trait: :not_verified) }

it { is_expected.to be true }
end

context "when there are duplicates" do
let(:claim) { create(:claim, :submitted, policy: Policies::FurtherEducationPayments, eligibility_trait: :duplicate) }

context "the provider email has not been sent" do
it { is_expected.to be false }
end

context "when the provider email has been sent" do
before { create(:note, claim: claim, label: "provider_verification") }

it { is_expected.to be true }
end
end
end

context "when the eligiblity is verified" do
let(:claim) { build(:claim, policy: Policies::FurtherEducationPayments, eligibility_trait: :verified) }

it { is_expected.to be false }
end

context "when the eligiblity is not further education payments" do
let(:claim) { build(:claim, policy: Policies::StudentLoans) }

it { is_expected.to be false }
end
end
end

0 comments on commit a95ad86

Please sign in to comment.