-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FE admin: conditionally show employment task
- Loading branch information
Showing
4 changed files
with
102 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
app/models/policies/further_education_payments/claim_checking_tasks.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters