Skip to content

Commit

Permalink
EY matching claims task
Browse files Browse the repository at this point in the history
  • Loading branch information
alkesh committed Oct 31, 2024
1 parent df84981 commit df2a217
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/models/claim/matching_attribute_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ def matching_claims

concatenated_columns = "CONCAT(#{attributes.join(",")})"
policies_to_find_matches.map { |policy|
policy::Eligibility.where("LOWER(#{concatenated_columns}) = LOWER(?)", vals.join)
policy::Eligibility.where("LOWER(#{concatenated_columns}) = LOWER(?)", vals.join) if (attributes - policy::Eligibility.column_names).empty?
}
}.compact.flatten.map(&:id)
}.flatten.compact.map(&:id)

eligibility_match_query = Claim.where(eligibility_id: eligibility_ids)
match_queries = match_queries.or(eligibility_match_query)
Expand Down
3 changes: 2 additions & 1 deletion app/models/policies/early_career_payments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ module EarlyCareerPayments
OTHER_CLAIMABLE_POLICIES = [
LevellingUpPremiumPayments,
StudentLoans,
FurtherEducationPayments
FurtherEducationPayments,
EarlyYearsPayments
].freeze

ELIGIBILITY_MATCHING_ATTRIBUTES = [["teacher_reference_number"]].freeze
Expand Down
7 changes: 7 additions & 0 deletions app/models/policies/early_years_payments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ module EarlyYearsPayments
include BasePolicy
extend self

OTHER_CLAIMABLE_POLICIES = [
EarlyCareerPayments,
LevellingUpPremiumPayments,
StudentLoans,
FurtherEducationPayments
]

# Percentage of claims to QA
MIN_QA_THRESHOLD = 10

Expand Down
29 changes: 29 additions & 0 deletions app/models/policies/early_years_payments/claim_checking_tasks.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

module Policies
module EarlyYearsPayments
class ClaimCheckingTasks
attr_reader :claim

def initialize(claim)
@claim = claim
end

delegate :policy, to: :claim

def applicable_task_names
tasks = []

tasks << "matching_details" if matching_claims.exists?

tasks
end

private

def matching_claims
@matching_claims ||= Claim::MatchingAttributeFinder.new(claim).matching_claims
end
end
end
end
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 @@ -8,7 +8,8 @@ module FurtherEducationPayments
OTHER_CLAIMABLE_POLICIES = [
EarlyCareerPayments,
StudentLoans,
LevellingUpPremiumPayments
LevellingUpPremiumPayments,
EarlyYearsPayments
]

ELIGIBILITY_MATCHING_ATTRIBUTES = [["teacher_reference_number"]].freeze
Expand Down
3 changes: 2 additions & 1 deletion app/models/policies/levelling_up_premium_payments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ module LevellingUpPremiumPayments
OTHER_CLAIMABLE_POLICIES = [
EarlyCareerPayments,
StudentLoans,
FurtherEducationPayments
FurtherEducationPayments,
EarlyYearsPayments
].freeze

ELIGIBILITY_MATCHING_ATTRIBUTES = [["teacher_reference_number"]].freeze
Expand Down
3 changes: 2 additions & 1 deletion app/models/policies/student_loans.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ module StudentLoans
OTHER_CLAIMABLE_POLICIES = [
EarlyCareerPayments,
LevellingUpPremiumPayments,
FurtherEducationPayments
FurtherEducationPayments,
EarlyYearsPayments
]

ELIGIBILITY_MATCHING_ATTRIBUTES = [["teacher_reference_number"]].freeze
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1452,6 +1452,8 @@ en:
no_response: No response
other: Other
task_questions:
matching_details:
title: Is this claim still valid despite having matching details with other claims?
employment:
title: Is the claimant still working at the current nursery above?
early_years_payment_practitioner:
Expand Down
34 changes: 32 additions & 2 deletions spec/models/claim/matching_attribute_finder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,40 @@
eligibility_attributes: {teacher_reference_number: "0902344"})
}

let!(:fe_claim) {
create(:claim,
:submitted,
first_name: "Genghis",
surname: "Khan",
date_of_birth: Date.new(1162, 5, 31),
national_insurance_number: "QQ891011C",
email_address: "[email protected]",
bank_account_number: "34682151",
bank_sort_code: "972654",
academic_year: AcademicYear.new("2019"),
building_society_roll_number: "123456789/ABCD",
policy: Policies::FurtherEducationPayments,
eligibility_attributes: {teacher_reference_number: "0902344"})
}

let!(:ey_claim) {
create(:claim,
:submitted,
first_name: "Genghis",
surname: "Khan",
date_of_birth: Date.new(1162, 5, 31),
national_insurance_number: "QQ891011C",
email_address: "[email protected]",
bank_account_number: "34682151",
bank_sort_code: "972654",
academic_year: AcademicYear.new("2019"),
policy: Policies::EarlyYearsPayments)
}

subject(:matching_claims) { Claim::MatchingAttributeFinder.new(source_claim).matching_claims }

it "includes only claims for ECP or LUP claims" do
expect(matching_claims).to contain_exactly(lup_claim, student_loans_claim)
it "includes claims for ECP, LUP, FE and EY claims" do
expect(matching_claims).to contain_exactly(lup_claim, student_loans_claim, fe_claim, ey_claim)
end
end

Expand Down

0 comments on commit df2a217

Please sign in to comment.