From df2a21714e15765db4cfbb3d626eb1bd4fb12f91 Mon Sep 17 00:00:00 2001 From: Alkesh Vaghmaria Date: Mon, 28 Oct 2024 12:33:35 +0000 Subject: [PATCH] EY matching claims task --- app/models/claim/matching_attribute_finder.rb | 4 +-- app/models/policies/early_career_payments.rb | 3 +- app/models/policies/early_years_payments.rb | 7 ++++ .../claim_checking_tasks.rb | 29 ++++++++++++++++ .../policies/further_education_payments.rb | 3 +- .../policies/levelling_up_premium_payments.rb | 3 +- app/models/policies/student_loans.rb | 3 +- config/locales/en.yml | 2 ++ .../claim/matching_attribute_finder_spec.rb | 34 +++++++++++++++++-- 9 files changed, 80 insertions(+), 8 deletions(-) create mode 100644 app/models/policies/early_years_payments/claim_checking_tasks.rb diff --git a/app/models/claim/matching_attribute_finder.rb b/app/models/claim/matching_attribute_finder.rb index 25f7005825..5ae00a4632 100644 --- a/app/models/claim/matching_attribute_finder.rb +++ b/app/models/claim/matching_attribute_finder.rb @@ -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) diff --git a/app/models/policies/early_career_payments.rb b/app/models/policies/early_career_payments.rb index 2248580d05..1a798cdc7b 100644 --- a/app/models/policies/early_career_payments.rb +++ b/app/models/policies/early_career_payments.rb @@ -30,7 +30,8 @@ module EarlyCareerPayments OTHER_CLAIMABLE_POLICIES = [ LevellingUpPremiumPayments, StudentLoans, - FurtherEducationPayments + FurtherEducationPayments, + EarlyYearsPayments ].freeze ELIGIBILITY_MATCHING_ATTRIBUTES = [["teacher_reference_number"]].freeze diff --git a/app/models/policies/early_years_payments.rb b/app/models/policies/early_years_payments.rb index 13624c2577..5cd579f240 100644 --- a/app/models/policies/early_years_payments.rb +++ b/app/models/policies/early_years_payments.rb @@ -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 diff --git a/app/models/policies/early_years_payments/claim_checking_tasks.rb b/app/models/policies/early_years_payments/claim_checking_tasks.rb new file mode 100644 index 0000000000..3b6c104eeb --- /dev/null +++ b/app/models/policies/early_years_payments/claim_checking_tasks.rb @@ -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 diff --git a/app/models/policies/further_education_payments.rb b/app/models/policies/further_education_payments.rb index cfbce29f5c..cce0a47160 100644 --- a/app/models/policies/further_education_payments.rb +++ b/app/models/policies/further_education_payments.rb @@ -8,7 +8,8 @@ module FurtherEducationPayments OTHER_CLAIMABLE_POLICIES = [ EarlyCareerPayments, StudentLoans, - LevellingUpPremiumPayments + LevellingUpPremiumPayments, + EarlyYearsPayments ] ELIGIBILITY_MATCHING_ATTRIBUTES = [["teacher_reference_number"]].freeze diff --git a/app/models/policies/levelling_up_premium_payments.rb b/app/models/policies/levelling_up_premium_payments.rb index 827a46e72b..1f0bbd8260 100644 --- a/app/models/policies/levelling_up_premium_payments.rb +++ b/app/models/policies/levelling_up_premium_payments.rb @@ -17,7 +17,8 @@ module LevellingUpPremiumPayments OTHER_CLAIMABLE_POLICIES = [ EarlyCareerPayments, StudentLoans, - FurtherEducationPayments + FurtherEducationPayments, + EarlyYearsPayments ].freeze ELIGIBILITY_MATCHING_ATTRIBUTES = [["teacher_reference_number"]].freeze diff --git a/app/models/policies/student_loans.rb b/app/models/policies/student_loans.rb index 5de4c4828b..1bd9e947b3 100644 --- a/app/models/policies/student_loans.rb +++ b/app/models/policies/student_loans.rb @@ -30,7 +30,8 @@ module StudentLoans OTHER_CLAIMABLE_POLICIES = [ EarlyCareerPayments, LevellingUpPremiumPayments, - FurtherEducationPayments + FurtherEducationPayments, + EarlyYearsPayments ] ELIGIBILITY_MATCHING_ATTRIBUTES = [["teacher_reference_number"]].freeze diff --git a/config/locales/en.yml b/config/locales/en.yml index 714011aafa..ce84ed1824 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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: diff --git a/spec/models/claim/matching_attribute_finder_spec.rb b/spec/models/claim/matching_attribute_finder_spec.rb index bcebac7e54..d86a76d4be 100644 --- a/spec/models/claim/matching_attribute_finder_spec.rb +++ b/spec/models/claim/matching_attribute_finder_spec.rb @@ -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: "genghis.khan@mongol-empire.com", + 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: "genghis.khan@mongol-empire.com", + 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