diff --git a/app/models/base_policy.rb b/app/models/base_policy.rb index da9f4a0c42..a9a327a0be 100644 --- a/app/models/base_policy.rb +++ b/app/models/base_policy.rb @@ -46,4 +46,8 @@ def searchable_eligibility_attributes self::SEARCHABLE_ELIGIBILITY_ATTRIBUTES end + + def international_relocation_payments? + to_s == "InternationalRelocationPayments" + end end diff --git a/app/models/claim/claims_preventing_payment_finder.rb b/app/models/claim/claims_preventing_payment_finder.rb index 82be1248d9..d0f467962a 100644 --- a/app/models/claim/claims_preventing_payment_finder.rb +++ b/app/models/claim/claims_preventing_payment_finder.rb @@ -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) diff --git a/app/models/claim_checking_tasks.rb b/app/models/claim_checking_tasks.rb index 676e641e71..2fcdbc5620 100644 --- a/app/models/claim_checking_tasks.rb +++ b/app/models/claim_checking_tasks.rb @@ -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 diff --git a/app/models/policies.rb b/app/models/policies.rb index c155fd43bf..d51f30fa9a 100644 --- a/app/models/policies.rb +++ b/app/models/policies.rb @@ -2,7 +2,8 @@ module Policies POLICIES = [ StudentLoans, EarlyCareerPayments, - LevellingUpPremiumPayments + LevellingUpPremiumPayments, + InternationalRelocationPayments ].freeze AMENDABLE_ELIGIBILITY_ATTRIBUTES = POLICIES.map do |policy| diff --git a/app/models/policies/international_relocation_payments.rb b/app/models/policies/international_relocation_payments.rb index 52d02a93ba..d66ed2c747 100644 --- a/app/models/policies/international_relocation_payments.rb +++ b/app/models/policies/international_relocation_payments.rb @@ -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 diff --git a/app/models/policies/international_relocation_payments/admin_tasks_presenter.rb b/app/models/policies/international_relocation_payments/admin_tasks_presenter.rb new file mode 100644 index 0000000000..e50adb3676 --- /dev/null +++ b/app/models/policies/international_relocation_payments/admin_tasks_presenter.rb @@ -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 diff --git a/app/models/policies/international_relocation_payments/eligibility.rb b/app/models/policies/international_relocation_payments/eligibility.rb index 932d3c009f..d8e9912135 100644 --- a/app/models/policies/international_relocation_payments/eligibility.rb +++ b/app/models/policies/international_relocation_payments/eligibility.rb @@ -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 diff --git a/app/models/policies/international_relocation_payments/eligibility_admin_answers_presenter.rb b/app/models/policies/international_relocation_payments/eligibility_admin_answers_presenter.rb new file mode 100644 index 0000000000..9849566d4c --- /dev/null +++ b/app/models/policies/international_relocation_payments/eligibility_admin_answers_presenter.rb @@ -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 diff --git a/config/locales/en.yml b/config/locales/en.yml index 58e74ef139..c100be0598 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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 diff --git a/spec/factories/journey_configurations.rb b/spec/factories/journey_configurations.rb index 0cc791d529..2212a19d64 100644 --- a/spec/factories/journey_configurations.rb +++ b/spec/factories/journey_configurations.rb @@ -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 diff --git a/spec/factories/policies/international_relocation_payments/eligibilities.rb b/spec/factories/policies/international_relocation_payments/eligibilities.rb index c1a58415af..efd0ef5a84 100644 --- a/spec/factories/policies/international_relocation_payments/eligibilities.rb +++ b/spec/factories/policies/international_relocation_payments/eligibilities.rb @@ -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 diff --git a/spec/features/admin_claim_allocation_spec.rb b/spec/features/admin_claim_allocation_spec.rb index d55e122cb4..d894dcccc0 100644 --- a/spec/features/admin_claim_allocation_spec.rb +++ b/spec/features/admin_claim_allocation_spec.rb @@ -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 @@ -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 @@ -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 [ @@ -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]) } @@ -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 @@ -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 @@ -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 @@ -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, diff --git a/spec/mailers/payment_mailer_spec.rb b/spec/mailers/payment_mailer_spec.rb index 90e3f04de0..60ebf2e3a4 100644 --- a/spec/mailers/payment_mailer_spec.rb +++ b/spec/mailers/payment_mailer_spec.rb @@ -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 diff --git a/spec/models/policies/international_relocation_payments/admin_tasks_presenter_spec.rb b/spec/models/policies/international_relocation_payments/admin_tasks_presenter_spec.rb new file mode 100644 index 0000000000..eb57c4e44f --- /dev/null +++ b/spec/models/policies/international_relocation_payments/admin_tasks_presenter_spec.rb @@ -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 diff --git a/spec/models/policies/international_relocation_payments/eligibility_admin_answers_presenter_spec.rb b/spec/models/policies/international_relocation_payments/eligibility_admin_answers_presenter_spec.rb new file mode 100644 index 0000000000..082fa27871 --- /dev/null +++ b/spec/models/policies/international_relocation_payments/eligibility_admin_answers_presenter_spec.rb @@ -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 diff --git a/spec/models/policies_spec.rb b/spec/models/policies_spec.rb index 9384573a53..3786b3c6da 100644 --- a/spec/models/policies_spec.rb +++ b/spec/models/policies_spec.rb @@ -6,7 +6,8 @@ expect(described_class::POLICIES).to eq([ Policies::StudentLoans, Policies::EarlyCareerPayments, - Policies::LevellingUpPremiumPayments + Policies::LevellingUpPremiumPayments, + Policies::InternationalRelocationPayments ]) end end @@ -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 diff --git a/spec/support/admin_view_claim_feature_shared_examples.rb b/spec/support/admin_view_claim_feature_shared_examples.rb index 6a94d47da8..0e211b8b0b 100644 --- a/spec/support/admin_view_claim_feature_shared_examples.rb +++ b/spec/support/admin_view_claim_feature_shared_examples.rb @@ -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, @@ -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