Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't email provider for duplicate claims #3145

Merged
merged 2 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ class ClaimSubmissionForm < ::ClaimSubmissionBaseForm
def save
super

ClaimMailer.further_education_payment_provider_verification_email(claim).deliver_later
if Policies::FurtherEducationPayments.duplicate_claim?(claim)
claim.eligibility.update!(flagged_as_duplicate: true)
else
ClaimMailer.further_education_payment_provider_verification_email(claim).deliver_later
end

true
end

private
Expand Down
4 changes: 4 additions & 0 deletions app/models/policies/further_education_payments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,9 @@ def notify_reply_to_id
def verification_due_date_for_claim(claim)
(claim.created_at + 2.weeks).to_date
end

def duplicate_claim?(claim)
Claim::MatchingAttributeFinder.new(claim).matching_claims.exists?
end
end
end
1 change: 1 addition & 0 deletions config/analytics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ shared:
- subject_to_formal_performance_action
- subject_to_disciplinary_action
- half_teaching_hours
- flagged_as_duplicate
:eligible_fe_providers:
- id
- ukprn
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class AddFlaggedAsDuplicateToFurtherEducationPaymentsEligibilities < ActiveRecord::Migration[7.0]
def change
add_column :further_education_payments_eligibilities,
:flagged_as_duplicate,
:boolean,
default: false
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2024_08_21_121253) do
ActiveRecord::Schema[7.0].define(version: 2024_09_04_105917) do
# These are extensions that must be enabled in order to support this database
enable_extension "citext"
enable_extension "pg_trgm"
Expand Down Expand Up @@ -254,6 +254,7 @@
t.boolean "subject_to_disciplinary_action"
t.boolean "half_teaching_hours"
t.jsonb "verification", default: {}
t.boolean "flagged_as_duplicate", default: false
t.index ["possible_school_id"], name: "index_fe_payments_eligibilities_on_possible_school_id"
t.index ["school_id"], name: "index_fe_payments_eligibilities_on_school_id"
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,30 @@
)
)
end

it "doesn't email the provider if the claim is a duplicate" do
allow(ClaimVerifierJob).to receive(:perform_later)

allow(ClaimMailer).to(
receive(:further_education_payment_provider_verification_email)
).and_return(double(deliver_later: nil))

first_claim_form = described_class.new(journey_session: journey_session)
second_claim_form = described_class.new(journey_session: journey_session)

first_claim_form.save
second_claim_form.save

expect(ClaimMailer).to(
have_received(:further_education_payment_provider_verification_email)
.exactly(1).times
)

original_claim = first_claim_form.claim
duplicate_claim = second_claim_form.claim

expect(original_claim.eligibility.flagged_as_duplicate).to eq(false)
expect(duplicate_claim.eligibility.flagged_as_duplicate).to eq(true)
end
end
end
Loading