Skip to content

Commit

Permalink
Setup the admin to display IRP claims
Browse files Browse the repository at this point in the history
In order to be able to display the IRP claims in the admin, there are
some basic methods that need to be available.

This change ensures the minimum implementation for displaying claims
without being concerned about the correctness of the required methods.
Specifically the `award_amount` is a placeholder.

In order to ensure we can successfully check for duplicate claims, I
made an assumption that we would use passport number rather than teacher
reference number as a unique identifier.

I don't think claimants for IRP will have TRNs, therefore we need some
other way of matching.

We can change this assumption easily in the future but for now this
allows us to ship the admin changes and keep moving forward.
  • Loading branch information
felixclack committed Jul 1, 2024
1 parent fbb7689 commit a817b0f
Show file tree
Hide file tree
Showing 17 changed files with 149 additions and 10 deletions.
4 changes: 4 additions & 0 deletions app/models/base_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,8 @@ def searchable_eligibility_attributes

self::SEARCHABLE_ELIGIBILITY_ATTRIBUTES
end

def international_relocation_payments?
to_s == "InternationalRelocationPayments"
end
end
2 changes: 2 additions & 0 deletions app/models/claim/claims_preventing_payment_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def claims_preventing_payment
private

def find_claims_preventing_payment
return [] if claim.policy == Policies::InternationalRelocationPayments

eligibility_ids = claim.policy.policies_claimable.map { |policy|
policy::Eligibility.where(teacher_reference_number: claim.eligibility.teacher_reference_number)
}.flatten.map(&:id)
Expand Down
4 changes: 4 additions & 0 deletions app/models/claim_checking_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ def initialize(claim)
@claim = claim
end

delegate :policy, to: :claim

def applicable_task_names
return [] if policy.international_relocation_payments?

@applicable_task_names ||= Task::NAMES.dup.tap do |task_names|
task_names.delete("induction_confirmation") unless claim.policy == Policies::EarlyCareerPayments
task_names.delete("student_loan_amount") unless claim.policy == Policies::StudentLoans
Expand Down
3 changes: 2 additions & 1 deletion app/models/policies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ module Policies
POLICIES = [
StudentLoans,
EarlyCareerPayments,
LevellingUpPremiumPayments
LevellingUpPremiumPayments,
InternationalRelocationPayments
].freeze

AMENDABLE_ELIGIBILITY_ATTRIBUTES = POLICIES.map do |policy|
Expand Down
3 changes: 3 additions & 0 deletions app/models/policies/international_relocation_payments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ module InternationalRelocationPayments
include BasePolicy
extend self

ELIGIBILITY_MATCHING_ATTRIBUTES = [["passport_number"]].freeze
OTHER_CLAIMABLE_POLICIES = []

# NOTE RL: currently IRP only has a single reply to address, so notify
# doesn't show the address id
def notify_reply_to_id
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Policies
module InternationalRelocationPayments
class AdminTasksPresenter
include Admin::PresenterMethods

attr_reader :claim

def initialize(claim)
@claim = claim
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,21 @@ module InternationalRelocationPayments
class Eligibility < ApplicationRecord
self.table_name = "international_relocation_payments_eligibilities"

AMENDABLE_ATTRIBUTES = %i[].freeze

has_one :claim, as: :eligibility, inverse_of: :eligibility

attr_accessor :teacher_reference_number

def award_amount
0
end

# No current_school attribute on the model. This method is for compatibility with the admin UI.
def current_school
nil
end

def ineligible?
false
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module Policies
module InternationalRelocationPayments
class EligibilityAdminAnswersPresenter
include Admin::PresenterMethods

attr_reader :eligibility

def initialize(eligibility)
@eligibility = eligibility
end

def answers
[].tap do |a|
a << current_school
end
end

private

def current_school
[
translate("admin.current_school"),
eligibility.current_school.present? ? display_school(eligibility.current_school) : "No"
]
end
end
end
end
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,8 @@ en:
"By selecting continue you are confirming that, to the best of your knowledge, the details you are providing are correct."
international_relocation_payments:
<<: *get_a_teacher_relocation_payment
policy_short_name: "International Relocation Payments"
policy_acronym: "IRP"

further_education_payments:
landing_page: Find out if you are eligible for any incentive payments for further education teachers
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 @@ -14,6 +14,10 @@
routing_name { Journeys::GetATeacherRelocationPayment::ROUTING_NAME }
end

trait :international_relocation_payments do
routing_name { Journeys::GetATeacherRelocationPayment::ROUTING_NAME }
end

trait :early_career_payments do
additional_payments
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
FactoryBot.define do
factory :international_relocation_payments_eligibility, class: "Policies::InternationalRelocationPayments::Eligibility" do
trait :eligible_home_office do
passport_number { "123456789" }
nationality { "French" }
end

trait :eligible do
eligible_home_office
end
end
end
30 changes: 25 additions & 5 deletions spec/features/admin_claim_allocation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
before do
create(:journey_configuration, :student_loans)
create(:journey_configuration, :additional_payments)
create(:journey_configuration, :get_a_teacher_relocation_payment)

submitted_claims = []
@signed_in_user = sign_in_as_service_operator
Expand All @@ -29,6 +30,9 @@
# index: 35-38
submitted_claims << create_list(:claim, 4, :submitted, policy: Policies::LevellingUpPremiumPayments)

# index: 39
submitted_claims << create_list(:claim, 1, :submitted, policy: Policies::InternationalRelocationPayments)

@submitted_claims = submitted_claims.flatten
end

Expand Down Expand Up @@ -60,6 +64,7 @@
let(:twenty_sixth_claim) { @submitted_claims[25] }
let(:thirtieth_claim) { @submitted_claims[29] }
let(:thirty_fifth_claim) { @submitted_claims[34] }
let(:thirty_ninth_claim) { @submitted_claims[38] }

let(:student_loan_claims) do
[
Expand All @@ -83,6 +88,8 @@
].flatten
end

let(:international_relocation_payment_claims) { [thirty_ninth_claim] }

let(:levelling_up_premium_payments) { @submitted_claims.slice(36...35) }

let!(:sarah) { create(:dfe_signin_user, given_name: "Sarah", family_name: "Strawbridge", organisation_name: "Department for Education", role_codes: [DfeSignIn::User::SERVICE_OPERATOR_DFE_SIGN_IN_ROLE_CODE]) }
Expand All @@ -97,11 +104,11 @@

within("#allocations") do
expect(page).to have_select("allocate_to_team_member", options: ["Aaron Admin", "Sarah Strawbridge", "Frank Yee", "Abdul Rafiq"])
expect(page).to have_select("allocate_to_policy", options: ["All", "Student Loans", "Early-Career Payments", "Levelling Up Premium Payments"])
expect(page).to have_select("allocate_to_policy", options: ["All", "Student Loans", "Early-Career Payments", "Levelling Up Premium Payments", "International Relocation Payments"])
expect(page).to have_button("Allocate claims", disabled: false)
expect(page).to have_button("Unallocate claims")
end
expect(@submitted_claims.size).to eq 39
expect(@submitted_claims.size).to eq 40

@submitted_claims.each do |claim|
expect(claim.assigned_to).to be_nil
Expand Down Expand Up @@ -152,7 +159,7 @@
within(".govuk-flash__notice") do
expect(page).to have_text I18n.t(
"admin.allocations.bulk_allocate.success",
quantity: 14,
quantity: 15,
pluralized_or_singular_claim: "claims",
allocate_to_policy: "",
dfe_user: frank.full_name.titleize
Expand All @@ -171,11 +178,11 @@
scenario "Student Loans" do
click_on "View claims"

expect(@submitted_claims.size).to eq 39
expect(@submitted_claims.size).to eq 40

within("#allocations") do
expect(page).to have_select("allocate_to_team_member", options: ["Aaron Admin", "Sarah Strawbridge", "Frank Yee", "Abdul Rafiq"])
expect(page).to have_select("allocate_to_policy", options: ["All", "Student Loans", "Early-Career Payments", "Levelling Up Premium Payments"])
expect(page).to have_select("allocate_to_policy", options: ["All", "Student Loans", "Early-Career Payments", "Levelling Up Premium Payments", "International Relocation Payments"])
expect(page).to have_button("Allocate claims", disabled: false)
expect(page).to have_button("Unallocate claims")
end
Expand Down Expand Up @@ -207,6 +214,19 @@
end
end

scenario "International Relocation Payments" do
click_on "View claims"

within("#allocations") do
expect(page).to have_select("allocate_to_team_member", options: ["Aaron Admin", "Sarah Strawbridge", "Frank Yee", "Abdul Rafiq"])
expect(page).to have_select("allocate_to_policy", options: ["All", "Student Loans", "Early-Career Payments", "Levelling Up Premium Payments", "International Relocation Payments"])
expect(page).to have_button("Allocate claims", disabled: false)
expect(page).to have_button("Unallocate claims")
end

expect(thirty_ninth_claim.assigned_to).to be_nil
end

scenario "when no claims for specified policy awaiting assignment" do
[
first_claim,
Expand Down
2 changes: 1 addition & 1 deletion spec/mailers/payment_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
end

it "sets the GOV.UK Notify reply_to_id according to the policy" do
expect(mail["reply_to_id"].first.value).to eql(policy.notify_reply_to_id)
expect(mail["reply_to_id"]&.first&.value).to eql(policy.notify_reply_to_id)
end

it "mentions the type of claim in the subject" do
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require "rails_helper"

RSpec.describe Policies::InternationalRelocationPayments::AdminTasksPresenter, type: :model do
subject { presenter }

let(:claim) { build(:claim, policy: Policies::InternationalRelocationPayments) }
let(:eligibility) { claim.eligibility }
let(:presenter) { described_class.new(claim) }

describe "#claim" do
subject { presenter.claim }

it { is_expected.to eq claim }
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require "rails_helper"

RSpec.describe Policies::InternationalRelocationPayments::EligibilityAdminAnswersPresenter, type: :model do
let(:claim) { build(:claim, :submittable, policy: Policies::InternationalRelocationPayments, academic_year: "2021/2022") }

subject(:presenter) { described_class.new(claim.eligibility) }

describe "#answers" do
it "returns an array of questions and answers for displaying to service operator" do
expect(presenter.answers).to eq [[I18n.t("admin.current_school"), "No"]]
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 @@ -6,7 +6,8 @@
expect(described_class::POLICIES).to eq([
Policies::StudentLoans,
Policies::EarlyCareerPayments,
Policies::LevellingUpPremiumPayments
Policies::LevellingUpPremiumPayments,
Policies::InternationalRelocationPayments
])
end
end
Expand All @@ -30,7 +31,8 @@
expect(described_class.options_for_select).to eq([
["Student Loans", "student-loans"],
["Early-Career Payments", "early-career-payments"],
["Levelling Up Premium Payments", "levelling-up-premium-payments"]
["Levelling Up Premium Payments", "levelling-up-premium-payments"],
["International Relocation Payments", "international-relocation-payments"]
])
end
end
Expand Down
9 changes: 8 additions & 1 deletion spec/support/admin_view_claim_feature_shared_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@
}

let!(:similar_claim) {
eligibility = create(:"#{policy.to_s.underscore}_eligibility", :eligible, teacher_reference_number: multiple_claim.eligibility.teacher_reference_number)
duplicate_attribute = if policy == Policies::InternationalRelocationPayments
{passport_number: multiple_claim.eligibility.passport_number}
else
{teacher_reference_number: multiple_claim.eligibility.teacher_reference_number}
end
eligibility = create(:"#{policy.to_s.underscore}_eligibility", :eligible, duplicate_attribute)
create(
:claim,
:submitted,
Expand Down Expand Up @@ -173,6 +178,8 @@ def expect_page_to_have_policy_sections(policy)
["Identity confirmation", "Qualifications", "Census subjects taught", "Employment", "Student loan plan", "Decision"]
when Policies::EarlyCareerPayments
["Identity confirmation", "Qualifications", "Induction confirmation", "Census subjects taught", "Employment", "Student loan plan", "Decision"]
when Policies::InternationalRelocationPayments
["Decision"]
else
raise "Unimplemented policy: #{policy}"
end
Expand Down

0 comments on commit a817b0f

Please sign in to comment.