Skip to content

Commit

Permalink
Merge pull request #3350 from DFE-Digital/ey-rejection-reasons
Browse files Browse the repository at this point in the history
[LUPEYALPHA-1173][LUPEYALPHA-1176] EY rejection reasons
  • Loading branch information
asmega authored Oct 31, 2024
2 parents 4b9eabf + ddd910f commit 099ab4c
Show file tree
Hide file tree
Showing 18 changed files with 147 additions and 28 deletions.
24 changes: 15 additions & 9 deletions app/jobs/claim_verifier_job.rb
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class ApplicationMailer < Mail::Notify::Mailer
EARLY_YEARS_PAYMENTS = {
CLAIM_PROVIDER_EMAIL_TEMPLATE_ID: "e0b78a08-601b-40ba-a97f-61fb00a7c951".freeze,
CLAIM_RECEIVED_NOTIFY_TEMPLATE_ID: "149c5999-12fb-4b99-aff5-23a7c3302783".freeze,
CLAIM_PRACTITIONER_NOTIFY_TEMPLATE_ID: "ef21f1d7-8a5c-4261-80b9-e1b78f844575".freeze
CLAIM_PRACTITIONER_NOTIFY_TEMPLATE_ID: "ef21f1d7-8a5c-4261-80b9-e1b78f844575".freeze,
CLAIM_REJECTED_NOTIFY_TEMPLATE_ID: "90e32881-1d11-4c6b-b33a-e7ae698de2f2".freeze
}
end
3 changes: 2 additions & 1 deletion app/models/policies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ module Policies
EarlyCareerPayments,
LevellingUpPremiumPayments,
InternationalRelocationPayments,
FurtherEducationPayments
FurtherEducationPayments,
EarlyYearsPayments
].freeze

AMENDABLE_ELIGIBILITY_ATTRIBUTES = POLICIES.map do |policy|
Expand Down
17 changes: 17 additions & 0 deletions app/models/policies/early_years_payments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Policies
module EarlyYearsPayments
class ClaimPersonalDataScrubber < Policies::ClaimPersonalDataScrubber
end
end
end
5 changes: 5 additions & 0 deletions app/models/policies/early_years_payments/eligibility.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
12 changes: 10 additions & 2 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1419,11 +1419,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_short_name: Early Years Financial Incentive Payments
policy_full_name: Early years financial incentive payment
support_email_address: "[email protected]"
claim_description: for an early years financial incentive payment
govuk_verify_fields:
full_name: Applicant name
admin:
Expand All @@ -1443,6 +1444,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: "[email protected]"
Expand Down
4 changes: 4 additions & 0 deletions spec/factories/journey_configurations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions spec/factories/policies/early_years_payments/eligibilities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion spec/features/admin/admin_claim_allocation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 Financial Incentive Payments"
]
end

Expand Down
10 changes: 8 additions & 2 deletions spec/features/admin/admin_view_claim_spec.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion spec/helpers/admin/claim_summary_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
9 changes: 0 additions & 9 deletions spec/jobs/claim_verifier_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 36 additions & 0 deletions spec/models/decision_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions spec/models/policies/early_years_payments_spec.rb
Original file line number Diff line number Diff line change
@@ -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
6 changes: 4 additions & 2 deletions spec/models/policies_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
Policies::EarlyCareerPayments,
Policies::LevellingUpPremiumPayments,
Policies::InternationalRelocationPayments,
Policies::FurtherEducationPayments
Policies::FurtherEducationPayments,
Policies::EarlyYearsPayments
])
end
end
Expand All @@ -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 Financial Incentive Payments", "early-years-payments"]
])
end
end
Expand Down
3 changes: 3 additions & 0 deletions spec/support/admin_view_claim_feature_shared_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
else
:eligible
end

create(
:claim,
:submitted,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 099ab4c

Please sign in to comment.