Skip to content

Commit

Permalink
check for provider email being sent instead of matching_details task
Browse files Browse the repository at this point in the history
  • Loading branch information
alkesh committed Sep 23, 2024
1 parent 0a010a8 commit aaa470a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 37 deletions.
16 changes: 4 additions & 12 deletions app/models/claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -212,17 +212,12 @@ class Claim < ApplicationRecord
scope :awaiting_qa, -> { approved.qa_required.where(qa_completed_at: nil) }
scope :qa_required, -> { where(qa_required: true) }
scope :awaiting_further_education_provider_verification, -> do
# TODO change this to check provider email has been sent
joins("INNER JOIN further_education_payments_eligibilities ON further_education_payments_eligibilities.id = claims.eligibility_id")
# .left_outer_joins(:notes)
# .where(notes: {label: [nil, "provider_verification"]})
.left_outer_joins(:tasks)
.left_outer_joins(:notes)
.where("further_education_payments_eligibilities.verification = '{}'")
.where(tasks: {name: [nil, "matching_details"]})
.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(tasks: {name: "matching_details", passed: true})))
# .or(Claim.where("further_education_payments_eligibilities.flagged_as_duplicate = TRUE").and(Claim.where(notes: {label: "provider_verification"})))
.or(Claim.where("further_education_payments_eligibilities.flagged_as_duplicate = TRUE").and(Claim.where(notes: {label: "provider_verification"})))
)
end

Expand Down Expand Up @@ -454,11 +449,8 @@ def awaiting_provider_verification?

return false if eligibility.verified?

if tasks.where(name: "matching_details").any?
tasks.where(name: "matching_details", passed: true).any?
else
Claim::MatchingAttributeFinder.new(self).matching_claims.empty?
end
# TODO - duplication with app/models/policies/further_education_payments/admin_provider_verification_task_presenter.rb
!eligibility.flagged_as_duplicate? || notes.where(label: "provider_verification").any?
end

private
Expand Down
43 changes: 18 additions & 25 deletions spec/models/claim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -909,21 +909,20 @@
describe ".awaiting_further_education_provider_verification" do
subject { described_class.awaiting_further_education_provider_verification }

let!(:claim_not_verified_without_matching_details_task) { create(:claim, :submitted, policy: Policies::FurtherEducationPayments, eligibility_trait: :eligible) }
let!(:claim_not_verified_with_matching_details_task_answered_no) { create(:claim, :submitted, policy: Policies::FurtherEducationPayments, eligibility_trait: :eligible_duplicate) }
let!(:claim_not_verified_with_matching_details_task_answered_yes) { create(:claim, :submitted, policy: Policies::FurtherEducationPayments, eligibility_trait: :eligible_duplicate) }
let!(:claim_not_verified_with_duplicate_claims) { create(:claim, :submitted, policy: Policies::FurtherEducationPayments, eligibility_trait: :eligible_duplicate) }
let!(:claim_not_verified_provider_email_automatically_sent) { create(:claim, :submitted, policy: Policies::FurtherEducationPayments, eligibility_trait: :eligible) }
let!(:claim_not_verified_provider_email_not_sent) { create(:claim, :submitted, policy: Policies::FurtherEducationPayments, eligibility_trait: :eligible_duplicate) }
let!(:claim_not_verified_has_duplicates_provider_email_not_sent) { create(:claim, :submitted, policy: Policies::FurtherEducationPayments, eligibility_trait: :eligible_duplicate) }
let!(:claim_not_verified_has_duplicates_provider_email_manually_sent) { create(:claim, :submitted, policy: Policies::FurtherEducationPayments, eligibility_trait: :eligible_duplicate) }
let!(:claim_with_fe_provider_verification) { create(:claim, policy: Policies::FurtherEducationPayments, eligibility_trait: :verified) }
let!(:non_fe_claim) { create(:claim, policy: Policies::StudentLoans) }

before do
create(:task, claim: claim_not_verified_with_matching_details_task_answered_yes, name: "matching_details", passed: true)
create(:task, claim: claim_not_verified_with_matching_details_task_answered_no, name: "matching_details", passed: false)
create(:task, claim: claim_not_verified_with_matching_details_task_answered_no, name: "student_loan_plan", passed: true)
create(:note, claim: claim_not_verified_has_duplicates_provider_email_manually_sent, label: "provider_verification")
create(:note, claim: claim_not_verified_provider_email_not_sent, label: "student_loan_plan")
end

it "returns claims that have not been verified by the provider, and have no matching_details task or have a passed matching_details task" do
is_expected.to match_array([claim_not_verified_without_matching_details_task, claim_not_verified_with_matching_details_task_answered_yes])
is_expected.to match_array([claim_not_verified_provider_email_automatically_sent, claim_not_verified_has_duplicates_provider_email_manually_sent])
end
end

Expand Down Expand Up @@ -1343,31 +1342,25 @@
subject { claim.awaiting_provider_verification? }

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

context "there is not a matching_details task" do
context "when there are matching claims" do
before { create(:claim, :submitted, policy: Policies::FurtherEducationPayments, eligibility_trait: :eligible, email_address: claim.email_address) }
it { is_expected.to be true }
end

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

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

context "when there are no matching claims" do
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

context "when there is a passed matching_details task" do
before { create(:task, claim: claim, name: "matching_details", passed: true) }

it { is_expected.to be true }
end

context "when there is a failed matching_details task" do
before { create(:task, claim: claim, name: "matching_details", passed: false) }

it { is_expected.to be false }
end
end

context "when the eligiblity is verified" do
Expand Down

0 comments on commit aaa470a

Please sign in to comment.