From 985e62029da0feb386a5c993fbbc95587b614f07 Mon Sep 17 00:00:00 2001 From: Richard Lynch Date: Wed, 30 Oct 2024 15:39:11 +0000 Subject: [PATCH] Capture practitioner names When the provider enters the practitioner name it's stored in the `Claim#first_name` and `Claim#surname` fields. When the practitioner completes their portion of the journey the details they entered on the personal details step overwrites the values entered by the provider in the `Claim#first_name` and `Claim#surname` fields. We have a requirement to show and compare both the provider entered claimant name and practitioner entered claimant name in the admin area, this commit stores the provider entered name information in two new fields allowing us to do this. --- .../provider/authenticated/claimant_name_form.rb | 7 ++++++- .../provider/authenticated/session_answers.rb | 2 ++ config/analytics_blocklist.yml | 2 ++ ...41030153139_add_claimant_details_to_ey_eligibilities.rb | 6 ++++++ db/schema.rb | 4 +++- .../early_years_payment_provider_authenticated_answers.rb | 2 ++ .../provider/authenticated/claim_submission_form_spec.rb | 2 ++ .../provider/authenticated/claimant_name_form_spec.rb | 4 ++++ 8 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20241030153139_add_claimant_details_to_ey_eligibilities.rb diff --git a/app/forms/journeys/early_years_payment/provider/authenticated/claimant_name_form.rb b/app/forms/journeys/early_years_payment/provider/authenticated/claimant_name_form.rb index 27f12d2f4d..256fa22daa 100644 --- a/app/forms/journeys/early_years_payment/provider/authenticated/claimant_name_form.rb +++ b/app/forms/journeys/early_years_payment/provider/authenticated/claimant_name_form.rb @@ -17,7 +17,12 @@ class ClaimantNameForm < Form def save return false if invalid? - journey_session.answers.assign_attributes(first_name:, surname:) + journey_session.answers.assign_attributes( + first_name: first_name, + surname: surname, + practitioner_first_name: first_name, + practitioner_surname: surname + ) journey_session.save! end end diff --git a/app/models/journeys/early_years_payment/provider/authenticated/session_answers.rb b/app/models/journeys/early_years_payment/provider/authenticated/session_answers.rb index f953063bb8..028478f90b 100644 --- a/app/models/journeys/early_years_payment/provider/authenticated/session_answers.rb +++ b/app/models/journeys/early_years_payment/provider/authenticated/session_answers.rb @@ -14,6 +14,8 @@ class SessionAnswers < Journeys::SessionAnswers attribute :practitioner_email_address attribute :provider_contact_name attribute :provider_email_address + attribute :practitioner_first_name + attribute :practitioner_surname def policy Policies::EarlyYearsPayments diff --git a/config/analytics_blocklist.yml b/config/analytics_blocklist.yml index 4209345644..4de6714919 100644 --- a/config/analytics_blocklist.yml +++ b/config/analytics_blocklist.yml @@ -133,3 +133,5 @@ - answers :early_years_payment_eligibilities: - provider_email_address + - practitioner_first_name + - practitioner_surname diff --git a/db/migrate/20241030153139_add_claimant_details_to_ey_eligibilities.rb b/db/migrate/20241030153139_add_claimant_details_to_ey_eligibilities.rb new file mode 100644 index 0000000000..c255de4c86 --- /dev/null +++ b/db/migrate/20241030153139_add_claimant_details_to_ey_eligibilities.rb @@ -0,0 +1,6 @@ +class AddClaimantDetailsToEyEligibilities < ActiveRecord::Migration[7.0] + def change + add_column :early_years_payment_eligibilities, :practitioner_first_name, :string + add_column :early_years_payment_eligibilities, :practitioner_surname, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index cbc797b252..94eee59299 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_10_28_161228) do +ActiveRecord::Schema[7.0].define(version: 2024_10_30_153139) do # These are extensions that must be enabled in order to support this database enable_extension "citext" enable_extension "pg_trgm" @@ -204,6 +204,8 @@ t.boolean "returner_worked_with_children" t.string "returner_contract_type" t.decimal "award_amount", precision: 7, scale: 2 + t.string "practitioner_first_name" + t.string "practitioner_surname" end create_table "eligible_ey_providers", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| diff --git a/spec/factories/journeys/early_years_payment/provider/authenticated/early_years_payment_provider_authenticated_answers.rb b/spec/factories/journeys/early_years_payment/provider/authenticated/early_years_payment_provider_authenticated_answers.rb index 78e797e404..0b42fe541d 100644 --- a/spec/factories/journeys/early_years_payment/provider/authenticated/early_years_payment_provider_authenticated_answers.rb +++ b/spec/factories/journeys/early_years_payment/provider/authenticated/early_years_payment_provider_authenticated_answers.rb @@ -9,6 +9,8 @@ paye_reference { "123/A" } first_name { "John" } surname { "Doe" } + practitioner_first_name { "John" } + practitioner_surname { "Doe" } start_date { Date.parse("1/1/2024") } child_facing_confirmation_given { true } returning_within_6_months { true } diff --git a/spec/forms/journeys/early_years_payment/provider/authenticated/claim_submission_form_spec.rb b/spec/forms/journeys/early_years_payment/provider/authenticated/claim_submission_form_spec.rb index f7b6035f3e..3615a3c654 100644 --- a/spec/forms/journeys/early_years_payment/provider/authenticated/claim_submission_form_spec.rb +++ b/spec/forms/journeys/early_years_payment/provider/authenticated/claim_submission_form_spec.rb @@ -39,6 +39,8 @@ expect(eligibility.start_date).to eq answers.start_date expect(eligibility.provider_claim_submitted_at).to be_present expect(eligibility.provider_email_address).to eq "provider@example.com" + expect(eligibility.practitioner_first_name).to eq answers.first_name + expect(eligibility.practitioner_surname).to eq answers.surname end it "sends a notify email to the practitioner" do diff --git a/spec/forms/journeys/early_years_payment/provider/authenticated/claimant_name_form_spec.rb b/spec/forms/journeys/early_years_payment/provider/authenticated/claimant_name_form_spec.rb index 5e3823430e..8e2386628a 100644 --- a/spec/forms/journeys/early_years_payment/provider/authenticated/claimant_name_form_spec.rb +++ b/spec/forms/journeys/early_years_payment/provider/authenticated/claimant_name_form_spec.rb @@ -43,6 +43,10 @@ expect { subject.save }.to( change { journey_session.answers.first_name }.to(first_name).and( change { journey_session.answers.surname }.to(surname) + ).and( + change { journey_session.answers.practitioner_first_name }.to(first_name) + ).and( + change { journey_session.answers.practitioner_surname }.to(surname) ) ) end