Skip to content

Commit

Permalink
FE admin: conditionally show employment task
Browse files Browse the repository at this point in the history
  • Loading branch information
asmega committed Sep 6, 2024
1 parent e7c4732 commit 735603e
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 21 deletions.
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
.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
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# 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
@applicable_task_names ||= Task::NAMES.dup.tap do |task_names|
task_names.delete("employment") if claim.eligibility.teacher_reference_number.blank?

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")

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
end
end

private

def task_names_for_claim
claim.tasks.pluck(:name)
end

def matching_claims
@matching_claims ||= Claim::MatchingAttributeFinder.new(claim).matching_claims
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", "Qualifications", "Census subjects taught", "Matching details", "Decision"]
else
raise "Unimplemented policy: #{policy}"
end
Expand Down

0 comments on commit 735603e

Please sign in to comment.