From c75b467598f366c47446c08c82e3d9ad3f720881 Mon Sep 17 00:00:00 2001 From: Richard Lynch Date: Fri, 6 Sep 2024 14:25:24 +0100 Subject: [PATCH] Add name and dob check to matching claims A requirement is to trigger a "multiple claims with matching details" warning if there is another claim with a matching name and date of birth. This check is to work across all policies. --- app/models/claim/matching_attribute_finder.rb | 3 +- .../claim/matching_attribute_finder_spec.rb | 58 ++++++++++++++++++- spec/models/claim_checking_tasks_spec.rb | 2 +- ...dmin_view_claim_feature_shared_examples.rb | 4 +- 4 files changed, 61 insertions(+), 6 deletions(-) diff --git a/app/models/claim/matching_attribute_finder.rb b/app/models/claim/matching_attribute_finder.rb index b954458c8a..9379215030 100644 --- a/app/models/claim/matching_attribute_finder.rb +++ b/app/models/claim/matching_attribute_finder.rb @@ -4,7 +4,8 @@ class MatchingAttributeFinder CLAIM_ATTRIBUTE_GROUPS_TO_MATCH = [ ["email_address"], ["national_insurance_number"], - ["bank_account_number", "bank_sort_code", "building_society_roll_number"] + ["bank_account_number", "bank_sort_code", "building_society_roll_number"], + ["first_name", "surname", "date_of_birth"] ].freeze def initialize(source_claim) diff --git a/spec/models/claim/matching_attribute_finder_spec.rb b/spec/models/claim/matching_attribute_finder_spec.rb index 0900059af4..494ebbc0fa 100644 --- a/spec/models/claim/matching_attribute_finder_spec.rb +++ b/spec/models/claim/matching_attribute_finder_spec.rb @@ -4,6 +4,9 @@ describe "#matching_claims for ECP/LUP claims" do let!(:source_claim) { create(:claim, + 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", @@ -17,6 +20,9 @@ let!(:student_loans_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", @@ -30,6 +36,9 @@ let!(:lup_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", @@ -50,6 +59,9 @@ describe "#matching_claims" do let(:source_claim) { create(:claim, + 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", @@ -172,6 +184,39 @@ expect(matching_claims).to be_empty end + + it "does not include a claim with a matching name" do + create( + :claim, + :submitted, + first_name: source_claim.first_name, + surname: source_claim.surname + ) + + expect(matching_claims).to be_empty + end + + it "does not include a claim with a matching date of birth" do + create( + :claim, + :submitted, + date_of_birth: source_claim.date_of_birth + ) + + expect(matching_claims).to be_empty + end + + it "includes a claim with a matching name and date of birth" do + claim_with_matching_attributes = create( + :claim, + :submitted, + first_name: source_claim.first_name, + surname: source_claim.surname, + date_of_birth: source_claim.date_of_birth + ) + + expect(matching_claims).to eq([claim_with_matching_attributes]) + end end describe "matching_claims - blank trn" do @@ -193,7 +238,8 @@ :claim, :submitted, policy: policy, - eligibility: eligibility + eligibility: eligibility, + surname: Faker::Name.last_name ) } @@ -221,7 +267,8 @@ :claim, :submitted, policy: policy, - eligibility: eligibility + eligibility: eligibility, + surname: Faker::Name.last_name ) } @@ -253,7 +300,8 @@ :claim, :submitted, policy: policy, - eligibility: eligibility + eligibility: eligibility, + surname: Faker::Name.last_name ) } @@ -266,6 +314,8 @@ it "returns the attributes that match" do source_claim = create( :claim, + first_name: "genghis", + surname: "khan", email_address: "genghis.khan@example.com", national_insurance_number: "QQ891011C", bank_account_number: "34682151", @@ -277,6 +327,8 @@ other_claim = create( :claim, + first_name: "genghis", + surname: "khan2", email_address: "genghis.khan@example.com", national_insurance_number: "QQ891011C", bank_account_number: "11111111", diff --git a/spec/models/claim_checking_tasks_spec.rb b/spec/models/claim_checking_tasks_spec.rb index 97a0d6f65c..508657a369 100644 --- a/spec/models/claim_checking_tasks_spec.rb +++ b/spec/models/claim_checking_tasks_spec.rb @@ -21,7 +21,7 @@ end it "includes a task for payroll gender when a payroll gender task has previously been completed" do - claim.tasks << create(:task, name: "payroll_gender") + create(:task, name: "payroll_gender", claim: claim) expect(checking_tasks.applicable_task_names).to match_array(applicable_tasks + %w[payroll_gender]) end diff --git a/spec/support/admin_view_claim_feature_shared_examples.rb b/spec/support/admin_view_claim_feature_shared_examples.rb index 7fa8597d41..e8b54eb2f9 100644 --- a/spec/support/admin_view_claim_feature_shared_examples.rb +++ b/spec/support/admin_view_claim_feature_shared_examples.rb @@ -8,7 +8,9 @@ :claim, :submitted, policy: policy, - eligibility: eligibility + eligibility: eligibility, + first_name: Faker::Name.first_name, + surname: Faker::Name.last_name ) }