diff --git a/app/forms/journeys/further_education_payments/claim_submission_form.rb b/app/forms/journeys/further_education_payments/claim_submission_form.rb index 757f410c3c..83e6eb5582 100644 --- a/app/forms/journeys/further_education_payments/claim_submission_form.rb +++ b/app/forms/journeys/further_education_payments/claim_submission_form.rb @@ -4,7 +4,9 @@ class ClaimSubmissionForm < ::ClaimSubmissionBaseForm def save super - unless Policies::FurtherEducationPayments.duplicate_claim?(claim) + 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 diff --git a/config/analytics.yml b/config/analytics.yml index 071d906938..f46111dadd 100644 --- a/config/analytics.yml +++ b/config/analytics.yml @@ -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 diff --git a/db/migrate/20240904105917_add_flagged_as_duplicate_to_further_education_payments_eligibilities.rb b/db/migrate/20240904105917_add_flagged_as_duplicate_to_further_education_payments_eligibilities.rb new file mode 100644 index 0000000000..39e4241b4a --- /dev/null +++ b/db/migrate/20240904105917_add_flagged_as_duplicate_to_further_education_payments_eligibilities.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 4ed500a64b..9e6740d5c2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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" @@ -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 diff --git a/spec/forms/journeys/further_education_payments/claim_submission_form_spec.rb b/spec/forms/journeys/further_education_payments/claim_submission_form_spec.rb index aa10a438d5..9b0480561e 100644 --- a/spec/forms/journeys/further_education_payments/claim_submission_form_spec.rb +++ b/spec/forms/journeys/further_education_payments/claim_submission_form_spec.rb @@ -60,6 +60,7 @@ expect(eligibility.subject_to_formal_performance_action).to eq(answers.subject_to_formal_performance_action) expect(eligibility.subject_to_disciplinary_action).to eq(answers.subject_to_disciplinary_action) expect(eligibility.half_teaching_hours).to eq(answers.half_teaching_hours) + expect(eligibility.flagged_as_duplicate).to eq(false) end it "emails the claim provider" do @@ -91,12 +92,19 @@ receive(:further_education_payment_provider_verification_email) ).and_return(double(deliver_later: nil)) - 2.times { described_class.new(journey_session: journey_session).save } + 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 ) + + duplicate_claim = second_claim_form.claim + expect(duplicate_claim.eligibility.flagged_as_duplicate).to eq(true) end end end