From 3cf9d15f686f7bed7ae43f9d909a66fc3192b664 Mon Sep 17 00:00:00 2001 From: Alkesh Vaghmaria Date: Mon, 23 Sep 2024 14:37:24 +0100 Subject: [PATCH] refactor - remove duplication with AdminProviderVerificationTaskPresenter --- app/models/claim.rb | 5 +---- .../admin_provider_verification_task_presenter.rb | 2 +- .../policies/further_education_payments/eligibility.rb | 7 +++++++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/models/claim.rb b/app/models/claim.rb index 0c35169223..38904495c9 100644 --- a/app/models/claim.rb +++ b/app/models/claim.rb @@ -449,10 +449,7 @@ def one_login_idv_mismatch? def awaiting_provider_verification? return false unless has_further_education_policy? - return false if eligibility.verified? - - # 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? + eligibility.awaiting_provider_verification? end private diff --git a/app/models/policies/further_education_payments/admin_provider_verification_task_presenter.rb b/app/models/policies/further_education_payments/admin_provider_verification_task_presenter.rb index 890ca01694..a8ac063ad6 100644 --- a/app/models/policies/further_education_payments/admin_provider_verification_task_presenter.rb +++ b/app/models/policies/further_education_payments/admin_provider_verification_task_presenter.rb @@ -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? diff --git a/app/models/policies/further_education_payments/eligibility.rb b/app/models/policies/further_education_payments/eligibility.rb index 90be4cc547..01ace6850c 100644 --- a/app/models/policies/further_education_payments/eligibility.rb +++ b/app/models/policies/further_education_payments/eligibility.rb @@ -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