From f49bbfef9e9b531001b2639e3ff234fa8aaab6e3 Mon Sep 17 00:00:00 2001 From: Phil Lee Date: Fri, 8 Nov 2024 11:52:42 +0000 Subject: [PATCH] tweak practitioner claim start timestamp - this is now when practitioner submits their reference number --- .../practitioner/claim_submission_form.rb | 7 +++++-- .../practitioner/find_reference_form.rb | 3 ++- .../early_years_payment/practitioner/session_answers.rb | 1 + .../journeys/early_years_payment/practitioner/answers.rb | 1 + .../practitioner/find_reference_form_spec.rb | 6 ++++++ 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/forms/journeys/early_years_payment/practitioner/claim_submission_form.rb b/app/forms/journeys/early_years_payment/practitioner/claim_submission_form.rb index 2c5eb6622d..72cdaf709d 100644 --- a/app/forms/journeys/early_years_payment/practitioner/claim_submission_form.rb +++ b/app/forms/journeys/early_years_payment/practitioner/claim_submission_form.rb @@ -19,11 +19,14 @@ def generate_policy_options_provided end def new_or_find_claim - Claim.find_by(reference: journey_session.answers.reference_number) || Claim.new + (Claim.find_by(reference: journey_session.answers.reference_number) || Claim.new).tap do |c| + if c.eligibility + c.eligibility.practitioner_claim_started_at = journey_session.answers.practitioner_claim_started_at + end + end end def set_submitted_at_attributes - claim.eligibility.practitioner_claim_started_at = journey_session.created_at claim.submitted_at = Time.zone.now end end diff --git a/app/forms/journeys/early_years_payment/practitioner/find_reference_form.rb b/app/forms/journeys/early_years_payment/practitioner/find_reference_form.rb index 159b30ec11..698ca45bc6 100644 --- a/app/forms/journeys/early_years_payment/practitioner/find_reference_form.rb +++ b/app/forms/journeys/early_years_payment/practitioner/find_reference_form.rb @@ -17,7 +17,8 @@ def save reference_number:, reference_number_found: existing_claim.present?, claim_already_submitted: existing_claim&.submitted?, - nursery_name: existing_claim&.eligibility&.eligible_ey_provider&.nursery_name + nursery_name: existing_claim&.eligibility&.eligible_ey_provider&.nursery_name, + practitioner_claim_started_at: Time.now ) journey_session.save! end diff --git a/app/models/journeys/early_years_payment/practitioner/session_answers.rb b/app/models/journeys/early_years_payment/practitioner/session_answers.rb index 45963da9de..c5cead1164 100644 --- a/app/models/journeys/early_years_payment/practitioner/session_answers.rb +++ b/app/models/journeys/early_years_payment/practitioner/session_answers.rb @@ -7,6 +7,7 @@ class SessionAnswers < Journeys::SessionAnswers attribute :claim_already_submitted, :boolean, default: nil attribute :nursery_name attribute :start_email, :string + attribute :practitioner_claim_started_at, :datetime def policy Policies::EarlyYearsPayments diff --git a/spec/factories/journeys/early_years_payment/practitioner/answers.rb b/spec/factories/journeys/early_years_payment/practitioner/answers.rb index 44788ac043..f77bb9745f 100644 --- a/spec/factories/journeys/early_years_payment/practitioner/answers.rb +++ b/spec/factories/journeys/early_years_payment/practitioner/answers.rb @@ -12,6 +12,7 @@ banking_name { "John Doe" } bank_sort_code { rand(100000..999999) } bank_account_number { rand(10000000..99999999) } + practitioner_claim_started_at { 30.minutes.ago } end trait :submittable do diff --git a/spec/forms/journeys/early_years_payment/practitioner/find_reference_form_spec.rb b/spec/forms/journeys/early_years_payment/practitioner/find_reference_form_spec.rb index 604c5df27c..fe9a2aa06f 100644 --- a/spec/forms/journeys/early_years_payment/practitioner/find_reference_form_spec.rb +++ b/spec/forms/journeys/early_years_payment/practitioner/find_reference_form_spec.rb @@ -70,6 +70,12 @@ }.to change { journey_session.reload.answers.nursery_name }.from(nil).to(eligible_ey_provider.nursery_name) end + it "sets practitioner_claim_started_at" do + expect { + subject.save + }.to change { journey_session.reload.answers.practitioner_claim_started_at }.from(nil) + end + context "when the claim has only been submitted by the provider, not the practitioner" do let(:claim) do create(