Skip to content

Commit

Permalink
Allow searching by payment id
Browse files Browse the repository at this point in the history
When reconciling payroll issues the ops team would like the ability to
search for claims by payment id, as this is what's in the payroll CSV.
  • Loading branch information
rjlynch committed Jan 8, 2025
1 parent 61c7344 commit 1c0ddd7
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/models/claim/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ def claims
}
}.flatten.map(&:id)

claim_match_query.or(Claim.where(eligibility_id: eligibility_ids))
claims_matched_on_payment_ids = Claim.joins(:payments).merge(
Payment.where(id: search_term)
)

claim_match_query
.or(Claim.where(eligibility_id: eligibility_ids))
.or(Claim.where(id: claims_matched_on_payment_ids))
end

private
Expand Down
57 changes: 57 additions & 0 deletions spec/models/claim/search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,61 @@
specify { expect(search.claims).to contain_exactly(claim, historical_matching_claim) }
end
end

context "search by payment id" do
let!(:claim_1) do
create(
:claim,
:submitted,
bank_account_number: "12345678",
bank_sort_code: "123456",
national_insurance_number: "QQ123456C"
)
end

let!(:claim_2) do
create(
:claim,
:submitted,
bank_account_number: "12345678",
bank_sort_code: "123456",
national_insurance_number: "QQ123456C"
)
end

let!(:claim_3) do
create(
:claim,
:submitted,
bank_account_number: "12345678",
bank_sort_code: "123456",
national_insurance_number: "QQ123456C"
)
end

let!(:claim_4) do
create(
:claim,
:submitted,
bank_account_number: "12345678",
bank_sort_code: "123456",
national_insurance_number: "QQ123456C"
)
end

let!(:payment_1) { create(:payment, claims: [claim_1, claim_2]) }

let!(:payment_2) do
create(:payment, claims: [claim_3], payroll_run: payment_1.payroll_run)
end

let(:query) { payment_1.id }

subject { search.claims }

it { is_expected.to include(:claim_1) }
it { is_expected.to include(:claim_2) }
it { is_expected.not_to include(:claim_3) }
it { is_expected.not_to include(:claim_4) }
end
end

0 comments on commit 1c0ddd7

Please sign in to comment.