From bfe4bac0572200bd44cfe70a4467540dc3a8b06b Mon Sep 17 00:00:00 2001 From: vacabor <166112501+vacabor@users.noreply.github.com> Date: Wed, 23 Oct 2024 21:54:30 +0100 Subject: [PATCH] EY claim rejection reasons --- app/jobs/claim_verifier_job.rb | 24 ++++++++----- app/models/policies.rb | 3 +- app/models/policies/early_years_payments.rb | 17 +++++++++ .../early_years_payments/eligibility.rb | 5 +++ .../eligibility_admin_answers_presenter.rb | 18 ++++++++++ config/locales/en.yml | 10 +++++- spec/factories/journey_configurations.rb | 4 +++ .../early_years_payments/eligibilities.rb | 5 +++ .../admin/admin_claim_allocation_spec.rb | 3 +- spec/features/admin/admin_view_claim_spec.rb | 10 ++++-- .../admin/claim_summary_helper_spec.rb | 2 +- spec/jobs/claim_verifier_job_spec.rb | 9 ----- spec/models/decision_spec.rb | 36 +++++++++++++++++++ .../policies/early_years_payments_spec.rb | 9 +++++ spec/models/policies_spec.rb | 6 ++-- ...dmin_view_claim_feature_shared_examples.rb | 3 ++ 16 files changed, 138 insertions(+), 26 deletions(-) create mode 100644 app/models/policies/early_years_payments/eligibility_admin_answers_presenter.rb create mode 100644 spec/models/policies/early_years_payments_spec.rb diff --git a/app/jobs/claim_verifier_job.rb b/app/jobs/claim_verifier_job.rb index 1cd4f5e596..f149cce24a 100644 --- a/app/jobs/claim_verifier_job.rb +++ b/app/jobs/claim_verifier_job.rb @@ -1,14 +1,20 @@ class ClaimVerifierJob < ApplicationJob def perform(claim) - if claim.eligibility.respond_to?(:teacher_reference_number) - AutomatedChecks::ClaimVerifier.new( - claim:, - dqt_teacher_status: claim.has_dqt_record? ? Dqt::Teacher.new(claim.dqt_teacher_status) : Dqt::Client.new.teacher.find( - claim.eligibility.teacher_reference_number, - birthdate: claim.date_of_birth.to_s, - nino: claim.national_insurance_number - ) - ).perform + dqt_teacher_status = if claim.policy == Policies::EarlyYearsPayments + nil + elsif claim.has_dqt_record? + Dqt::Teacher.new(claim.dqt_teacher_status) + else + Dqt::Client.new.teacher.find( + claim.eligibility.teacher_reference_number, + birthdate: claim.date_of_birth.to_s, + nino: claim.national_insurance_number + ) end + + AutomatedChecks::ClaimVerifier.new( + claim:, + dqt_teacher_status: + ).perform end end diff --git a/app/models/policies.rb b/app/models/policies.rb index f08416c093..06015e1106 100644 --- a/app/models/policies.rb +++ b/app/models/policies.rb @@ -4,7 +4,8 @@ module Policies EarlyCareerPayments, LevellingUpPremiumPayments, InternationalRelocationPayments, - FurtherEducationPayments + FurtherEducationPayments, + EarlyYearsPayments ].freeze AMENDABLE_ELIGIBILITY_ATTRIBUTES = POLICIES.map do |policy| diff --git a/app/models/policies/early_years_payments.rb b/app/models/policies/early_years_payments.rb index bd2634c6a5..13624c2577 100644 --- a/app/models/policies/early_years_payments.rb +++ b/app/models/policies/early_years_payments.rb @@ -41,6 +41,23 @@ module EarlyYearsPayments # NOOP as PERSONAL_DATA_ATTRIBUTES_TO_RETAIN_FOR_EXTENDED_PERIOD is empty EXTENDED_PERIOD_END_DATE = ->(start_of_academic_year) {} + # Options shown to admins when rejecting a claim + ADMIN_DECISION_REJECTED_REASONS = [ + :claim_cancelled_by_employer, + :six_month_retention_check_failed, + :duplicate, + :no_response, + :other + ] + + OTHER_CLAIMABLE_POLICIES = [ + EarlyCareerPayments, + StudentLoans, + LevellingUpPremiumPayments + ] + + VERIFIERS = [] + # TODO: This is needed once the reply-to email address has been added to Gov Notify def notify_reply_to_id nil diff --git a/app/models/policies/early_years_payments/eligibility.rb b/app/models/policies/early_years_payments/eligibility.rb index 9629cf1a75..f00d665786 100644 --- a/app/models/policies/early_years_payments/eligibility.rb +++ b/app/models/policies/early_years_payments/eligibility.rb @@ -1,10 +1,15 @@ module Policies module EarlyYearsPayments class Eligibility < ApplicationRecord + AMENDABLE_ATTRIBUTES = [].freeze + self.table_name = "early_years_payment_eligibilities" has_one :claim, as: :eligibility, inverse_of: :eligibility + # does nothing, simply here for duck typing compatability + attr_accessor :teacher_reference_number + def policy Policies::EarlyYearsPayments end diff --git a/app/models/policies/early_years_payments/eligibility_admin_answers_presenter.rb b/app/models/policies/early_years_payments/eligibility_admin_answers_presenter.rb new file mode 100644 index 0000000000..5a197a16d1 --- /dev/null +++ b/app/models/policies/early_years_payments/eligibility_admin_answers_presenter.rb @@ -0,0 +1,18 @@ +module Policies + module EarlyYearsPayments + class EligibilityAdminAnswersPresenter + include Admin::PresenterMethods + include ActionView::Helpers::NumberHelper + + attr_reader :eligibility + + def initialize(eligibility) + @eligibility = eligibility + end + + def answers + [] + end + end + end +end diff --git a/config/locales/en.yml b/config/locales/en.yml index 02bbde8c01..a0e21a93d4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1420,11 +1420,12 @@ en: By submitting this claim you’re confirming that, to the best of your knowledge, the details you’re providing are correct. btn_text: Accept and send early_years_payments: - <<: *early_years_payment_provider_authenticated claim_subject: "Early Years Payment" policy_acronym: EY policy_short_name: Early Years policy_full_name: Early years financial incentive payment + support_email_address: "earlycareerteacherpayments@digital.education.gov.uk" + claim_description: for an early years financial incentive payment govuk_verify_fields: full_name: Applicant name admin: @@ -1444,6 +1445,13 @@ en: provider_submitted_at: Provider submitted at practitioner_started_at: Claimant started at submitted_at: Claimant submitted at + decision: + rejected_reasons: + claim_cancelled_by_employer: Claim cancelled by employer + six_month_retention_check_failed: 6 month retention check failed + duplicate: Duplicate + no_response: No response + other: Other early_years_payment_practitioner: journey_name: Claim an early years financial incentive payment - practitioner feedback_email: "help@opsteam.education.gov.uk" diff --git a/spec/factories/journey_configurations.rb b/spec/factories/journey_configurations.rb index 0c20571941..323ef3fab2 100644 --- a/spec/factories/journey_configurations.rb +++ b/spec/factories/journey_configurations.rb @@ -46,6 +46,10 @@ routing_name { Journeys::EarlyYearsPayment::Practitioner::ROUTING_NAME } end + trait :early_years_payments do + routing_name { Journeys::EarlyYearsPayment::Practitioner::ROUTING_NAME } + end + trait :closed do open_for_submissions { false } end diff --git a/spec/factories/policies/early_years_payments/eligibilities.rb b/spec/factories/policies/early_years_payments/eligibilities.rb index 6653904c5c..ef54add349 100644 --- a/spec/factories/policies/early_years_payments/eligibilities.rb +++ b/spec/factories/policies/early_years_payments/eligibilities.rb @@ -4,6 +4,11 @@ start_date { 1.year.ago } child_facing_confirmation_given { true } returning_within_6_months { false } + with_eligible_ey_provider + end + + trait :with_eligible_ey_provider do + nursery_urn { create(:eligible_ey_provider).urn } end trait :provider_claim_submitted do diff --git a/spec/features/admin/admin_claim_allocation_spec.rb b/spec/features/admin/admin_claim_allocation_spec.rb index 46f7ca6261..4f9e01bb4a 100644 --- a/spec/features/admin/admin_claim_allocation_spec.rb +++ b/spec/features/admin/admin_claim_allocation_spec.rb @@ -8,7 +8,8 @@ "Early-Career Payments", "School Targeted Retention Incentive", "International Relocation Payments", - "Further Education Targeted Retention Incentive" + "Further Education Targeted Retention Incentive", + "Early Years" ] end diff --git a/spec/features/admin/admin_view_claim_spec.rb b/spec/features/admin/admin_view_claim_spec.rb index 7d6cd73255..7194010e24 100644 --- a/spec/features/admin/admin_view_claim_spec.rb +++ b/spec/features/admin/admin_view_claim_spec.rb @@ -1,6 +1,12 @@ require "rails_helper" RSpec.feature "Admin view claim" do - Policies.all.each { |policy| it_behaves_like "Admin View Claim Feature", policy } - Policies.all.excluding(Policies::EarlyYearsPayments, Policies::FurtherEducationPayments).each { |policy| it_behaves_like "Admin View Claim logged in with tid", policy } + Policies + .all + .each { |policy| it_behaves_like "Admin View Claim Feature", policy } + + Policies + .all + .excluding(Policies::EarlyYearsPayments, Policies::FurtherEducationPayments) + .each { |policy| it_behaves_like "Admin View Claim logged in with tid", policy } end diff --git a/spec/helpers/admin/claim_summary_helper_spec.rb b/spec/helpers/admin/claim_summary_helper_spec.rb index 4ad610aeb3..847d5c7463 100644 --- a/spec/helpers/admin/claim_summary_helper_spec.rb +++ b/spec/helpers/admin/claim_summary_helper_spec.rb @@ -8,7 +8,7 @@ before { assign(:claim, claim) } - Policies.all.excluding(Policies::FurtherEducationPayments, Policies::InternationalRelocationPayments).each do |policy| + Policies.all.excluding(Policies::FurtherEducationPayments, Policies::InternationalRelocationPayments, Policies::EarlyYearsPayments).each do |policy| context "for policy #{policy}" do let(:policy) { policy } diff --git a/spec/jobs/claim_verifier_job_spec.rb b/spec/jobs/claim_verifier_job_spec.rb index 83f6bab5d1..46163c322a 100644 --- a/spec/jobs/claim_verifier_job_spec.rb +++ b/spec/jobs/claim_verifier_job_spec.rb @@ -38,15 +38,6 @@ expect(AutomatedChecks::ClaimVerifier).to receive(:new).with(claim:, dqt_teacher_status: mock_payload) described_class.new.perform(claim) end - - context "when the claim does not have a TRN" do - let(:claim) { build(:claim, policy: Policies::EarlyYearsPayments) } - - it "does not perform the verifier job" do - expect(AutomatedChecks::ClaimVerifier).not_to receive(:new) - described_class.new.perform(claim) - end - end end context "when the claim does not have a DQT record payload" do diff --git a/spec/models/decision_spec.rb b/spec/models/decision_spec.rb index 11b2ff4ba0..1dc081a8bd 100644 --- a/spec/models/decision_spec.rb +++ b/spec/models/decision_spec.rb @@ -138,6 +138,15 @@ :other ] end + let(:expected_reasons_ey) do + [ + :claim_cancelled_by_employer, + :six_month_retention_check_failed, + :duplicate, + :no_response, + :other + ] + end context "when the claim policy is ECP" do let(:policy) { Policies::EarlyCareerPayments } @@ -156,6 +165,12 @@ it { is_expected.to eq(expected_reasons_tslr) } end + + context "when the claim policy is EY" do + let(:policy) { Policies::EarlyYearsPayments } + + it { is_expected.to eq(expected_reasons_ey) } + end end describe "#rejected_reasons_hash" do @@ -236,6 +251,27 @@ ) end end + + context "with an EY claim" do + let(:rejected_reasons) do + { + rejected_reasons_claim_cancelled_by_employer: "1", + rejected_reasons_six_month_retention_check_failed: "1" + } + end + + let(:claim) { create(:claim, policy: Policies::EarlyYearsPayments) } + + it do + is_expected.to eq( + reason_claim_cancelled_by_employer: "1", + reason_six_month_retention_check_failed: "1", + reason_duplicate: "0", + reason_no_response: "0", + reason_other: "0" + ) + end + end end describe "#selected_rejected_reasons" do diff --git a/spec/models/policies/early_years_payments_spec.rb b/spec/models/policies/early_years_payments_spec.rb new file mode 100644 index 0000000000..f8bd407827 --- /dev/null +++ b/spec/models/policies/early_years_payments_spec.rb @@ -0,0 +1,9 @@ +require "rails_helper" + +RSpec.describe Policies::EarlyYearsPayments do + describe "::VERIFIERS" do + it "does not talk to DQT" do + expect(described_class::VERIFIERS).not_to include(AutomatedChecks::ClaimVerifiers::Identity) + end + end +end diff --git a/spec/models/policies_spec.rb b/spec/models/policies_spec.rb index aacefd8310..19e527b769 100644 --- a/spec/models/policies_spec.rb +++ b/spec/models/policies_spec.rb @@ -8,7 +8,8 @@ Policies::EarlyCareerPayments, Policies::LevellingUpPremiumPayments, Policies::InternationalRelocationPayments, - Policies::FurtherEducationPayments + Policies::FurtherEducationPayments, + Policies::EarlyYearsPayments ]) end end @@ -34,7 +35,8 @@ ["Early-Career Payments", "early-career-payments"], ["School Targeted Retention Incentive", "levelling-up-premium-payments"], ["International Relocation Payments", "international-relocation-payments"], - ["Further Education Targeted Retention Incentive", "further-education-payments"] + ["Further Education Targeted Retention Incentive", "further-education-payments"], + ["Early Years", "early-years-payments"] ]) end end diff --git a/spec/support/admin_view_claim_feature_shared_examples.rb b/spec/support/admin_view_claim_feature_shared_examples.rb index c67fd350f3..7f07e8bf40 100644 --- a/spec/support/admin_view_claim_feature_shared_examples.rb +++ b/spec/support/admin_view_claim_feature_shared_examples.rb @@ -19,6 +19,7 @@ else :eligible end + create( :claim, :submitted, @@ -161,6 +162,8 @@ def expect_page_to_have_policy_sections(policy) ["Previous payment", "Identity confirmation", "Visa", "Arrival date", "Previous residency", "Employment", "Employment contract", "Employment start", "Subject", "Teaching hours", "Decision"] when Policies::FurtherEducationPayments ["Identity confirmation", "Provider verification", "Student loan plan", "Decision"] + when Policies::EarlyYearsPayments + ["Identity confirmation", "Qualifications", "Census subjects taught", "Employment", "Decision"] else raise "Unimplemented policy: #{policy}" end