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

[LUPEYALPHA-954] FE admin tasks #3157

Merged
merged 3 commits into from
Sep 6, 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: 5 additions & 0 deletions app/models/automated_checks/claim_verifiers/employment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@ def initialize(claim:, admin_user: nil)
end

def perform
return unless required?
return unless awaiting_task?

no_data || no_match || matched
end

private

def required?
claim.eligibility.teacher_reference_number.present?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if this negatively impacts other policies?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be ok, most of the other journeys require a TRN from the claimant to submit, IRP doesn't but it doesn't use this claim verifier

end

attr_accessor :admin_user, :claim, :teachers_pensions_service

def awaiting_task?
Expand Down
48 changes: 28 additions & 20 deletions app/models/claim_checking_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,34 @@ def initialize(claim)
delegate :policy, to: :claim

def applicable_task_names
@applicable_task_names ||= Task::NAMES.dup.tap do |task_names|
task_names.delete("induction_confirmation") unless claim.policy == Policies::EarlyCareerPayments
task_names.delete("student_loan_amount") unless claim.policy == Policies::StudentLoans
task_names.delete("student_loan_plan") unless claim.has_ecp_or_lupp_policy? && claim.submitted_without_slc_data?
task_names.delete("payroll_details") unless claim.must_manually_validate_bank_details?
task_names.delete("matching_details") unless matching_claims.exists?
task_names.delete("payroll_gender") unless claim.payroll_gender_missing? || task_names_for_claim.include?("payroll_gender")
if claim.policy.international_relocation_payments?
task_names.delete("qualifications")
task_names.delete("census_subjects_taught")
end
unless claim.policy.international_relocation_payments?
task_names.delete("visa")
task_names.delete("arrival_date")
task_names.delete("employment_contract")
task_names.delete("employment_start")
task_names.delete("subject")
task_names.delete("teaching_hours")
end
unless claim.policy.further_education_payments?
case policy
when Policies::FurtherEducationPayments
Policies::FurtherEducationPayments::ClaimCheckingTasks
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 nice

.new(claim)
.applicable_task_names
else
@applicable_task_names ||= Task::NAMES.dup.tap do |task_names|
task_names.delete("induction_confirmation") unless claim.policy == Policies::EarlyCareerPayments
task_names.delete("student_loan_amount") unless claim.policy == Policies::StudentLoans
task_names.delete("student_loan_plan") unless claim.has_ecp_or_lupp_policy? && claim.submitted_without_slc_data?
task_names.delete("payroll_details") unless claim.must_manually_validate_bank_details?
task_names.delete("matching_details") unless matching_claims.exists?
task_names.delete("payroll_gender") unless claim.payroll_gender_missing? || task_names_for_claim.include?("payroll_gender")

if claim.policy.international_relocation_payments?
task_names.delete("qualifications")
task_names.delete("census_subjects_taught")
end

unless claim.policy.international_relocation_payments?
task_names.delete("visa")
task_names.delete("arrival_date")
task_names.delete("employment_contract")
task_names.delete("employment_start")
task_names.delete("subject")
task_names.delete("teaching_hours")
end

task_names.delete("provider_verification")
end
end
Expand Down
3 changes: 2 additions & 1 deletion app/models/policies/further_education_payments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ module FurtherEducationPayments
MIN_QA_THRESHOLD = 10

VERIFIERS = [
AutomatedChecks::ClaimVerifiers::ProviderVerification
AutomatedChecks::ClaimVerifiers::ProviderVerification,
AutomatedChecks::ClaimVerifiers::Employment
]

# Options shown to admins when rejecting a claim
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ def qualifications
[]
end

def employment
[]
end

def identity_confirmation
[]
end

def student_loan_plan
[]
end

Comment on lines +29 to +40
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

placeholders

private

def verifier
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# frozen_string_literal: true

module Policies
module FurtherEducationPayments
class ClaimCheckingTasks
attr_reader :claim

def initialize(claim)
@claim = claim
end

delegate :policy, to: :claim

def applicable_task_names
tasks = []

tasks << "identity_confirmation"
tasks << "provider_verification"
tasks << "employment" if claim.eligibility.teacher_reference_number.present?
tasks << "student_loan_plan"
tasks << "payroll_details"
tasks << "matching_details" if matching_claims.exists?
tasks << "payroll_gender" if claim.payroll_gender_missing?

tasks
end

private

def matching_claims
@matching_claims ||= Claim::MatchingAttributeFinder.new(claim).matching_claims
end
end
end
end
37 changes: 37 additions & 0 deletions spec/models/automated_checks/claim_verifier_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,42 @@
it { is_expected.to eq(0) }
end
end

context "when verifier is conditional" do
subject(:perform) { claim_verifier }

let(:claim) { create(:claim, policy: Policies::FurtherEducationPayments) }

let(:claim_verifier_args) do
{
claim:,
dqt_teacher_status: nil
}
end

context "and is needed" do
before do
claim.eligibility.update teacher_reference_number: "1234567"
end

it "creates relevant task" do
expect {
subject.perform
}.to change { Task.where(name: "employment").count }.by(1)
end
end

context "and is not needed" do
before do
claim.eligibility.update teacher_reference_number: nil
end

it "does not create relevant task" do
expect {
subject.perform
}.to change { Task.where(name: "employment").count }.by(0)
end
end
end
end
end
26 changes: 26 additions & 0 deletions spec/models/claim_checking_tasks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,32 @@
include_examples :payroll_details_task
include_examples :student_loan_plan_task
end

context "FurtherEducationPayments claim" do
subject { described_class.new(claim) }

let(:policy) { Policies::FurtherEducationPayments }

context "when TRN is provided" do
before do
claim.eligibility.update!(teacher_reference_number: "1234567")
end

it "includes employment task" do
expect(subject.applicable_task_names).to include("employment")
end
end

context "when TRN is not included" do
before do
claim.eligibility.update!(teacher_reference_number: nil)
end

it "excludes employment task" do
expect(subject.applicable_task_names).not_to include("employment")
end
end
end
end

describe "#incomplete_task_names" do
Expand Down
2 changes: 1 addition & 1 deletion spec/support/admin_view_claim_feature_shared_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def expect_page_to_have_policy_sections(policy)
when Policies::InternationalRelocationPayments
["Identity confirmation", "Visa", "Arrival date", "Employment", "Employment contract", "Employment start", "Subject", "Teaching hours", "Decision"]
when Policies::FurtherEducationPayments
["Identity confirmation", "Provider verification", "Qualifications", "Census subjects taught", "Employment", "Matching details", "Decision"]
["Identity confirmation", "Provider verification", "Student loan plan", "Payroll details", "Matching details", "Decision"]
else
raise "Unimplemented policy: #{policy}"
end
Expand Down