diff --git a/app/models/claim.rb b/app/models/claim.rb index df7ea95da9..c126001d60 100644 --- a/app/models/claim.rb +++ b/app/models/claim.rb @@ -421,13 +421,6 @@ def dqt_teacher_record policy::DqtRecord.new(Dqt::Teacher.new(dqt_teacher_status), eligibility) if has_dqt_record? end - def set_a_reminder? - Reminder.set_a_reminder?( - policy_year: Journeys.for_policy(policy).configuration.current_academic_year, - itt_academic_year: eligibility.itt_academic_year - ) - end - def same_claimant?(other_claim) CLAIMANT_MATCHING_ATTRIBUTES.all? do |attr| public_send(attr) == other_claim.public_send(attr) diff --git a/app/models/journeys/additional_payments_for_teaching.rb b/app/models/journeys/additional_payments_for_teaching.rb index cb4563a7c2..046939829f 100644 --- a/app/models/journeys/additional_payments_for_teaching.rb +++ b/app/models/journeys/additional_payments_for_teaching.rb @@ -33,5 +33,13 @@ module AdditionalPaymentsForTeaching "email-verification" => Reminders::EmailVerificationForm } }.freeze + + def set_a_reminder?(itt_academic_year:, policy_year: configuration.current_academic_year) + return false if policy_year >= EligibilityCheckable::FINAL_COMBINED_ECP_AND_LUP_POLICY_YEAR + + next_year = policy_year + 1 + eligible_itt_years = JourneySubjectEligibilityChecker.selectable_itt_years_for_claim_year(next_year) + eligible_itt_years.include?(itt_academic_year) + end end end diff --git a/app/models/reminder.rb b/app/models/reminder.rb index 08a69a5359..bf228c305c 100644 --- a/app/models/reminder.rb +++ b/app/models/reminder.rb @@ -7,14 +7,6 @@ class Reminder < ApplicationRecord scope :inside_academic_year, -> { where(itt_academic_year: AcademicYear.current.to_s) } scope :to_be_sent, -> { email_verified.not_yet_sent.inside_academic_year } - def self.set_a_reminder?(policy_year:, itt_academic_year:) - return false if policy_year >= EligibilityCheckable::FINAL_COMBINED_ECP_AND_LUP_POLICY_YEAR - - next_year = policy_year + 1 - eligible_itt_years = JourneySubjectEligibilityChecker.selectable_itt_years_for_claim_year(next_year) - eligible_itt_years.include?(itt_academic_year) - end - def send_year itt_academic_year.start_year end diff --git a/app/views/additional_payments/submissions/show.html.erb b/app/views/additional_payments/submissions/show.html.erb index 2c3f87dcac..6535881ed5 100644 --- a/app/views/additional_payments/submissions/show.html.erb +++ b/app/views/additional_payments/submissions/show.html.erb @@ -24,7 +24,7 @@ <%= render partial: "submissions/confirmation" %> - <% if submitted_claim.set_a_reminder? %> + <% if journey.set_a_reminder?(itt_academic_year: submitted_claim.eligibility.itt_academic_year) %> <%= render partial: "submissions/reminder" %> <% end %> diff --git a/spec/models/journeys/additional_payments_for_teaching_spec.rb b/spec/models/journeys/additional_payments_for_teaching_spec.rb index 5ccadf6064..a2e8276cd1 100644 --- a/spec/models/journeys/additional_payments_for_teaching_spec.rb +++ b/spec/models/journeys/additional_payments_for_teaching_spec.rb @@ -66,4 +66,114 @@ it { is_expected.to eq(Journeys::AdditionalPaymentsForTeaching::AnswersPresenter) } end + + describe ".set_a_reminder?" do + subject { described_class.set_a_reminder?(itt_academic_year: itt_academic_year, policy_year: policy_year) } + let(:itt_academic_year) { AcademicYear.new(year) } + + context "Claim year: 22/23" do + let(:policy_year) { AcademicYear.new(2022) } + + # Eligible now - but falls out of 5 year window next year so don't set a reminder + context "ITT year: 17/18" do + let(:year) { 2017 } + + specify { expect(subject).to be false } + end + + context "ITT year: 18/19" do + let(:year) { 2018 } + + specify { expect(subject).to be true } + end + + context "ITT year: 19/20" do + let(:year) { 2019 } + + specify { expect(subject).to be true } + end + + context "ITT year: 20/21" do + let(:year) { 2020 } + + specify { expect(subject).to be true } + end + + context "ITT year: 21/22" do + let(:year) { 2021 } + + specify { expect(subject).to be true } + end + end + + context "Claim year: 23/24" do + let(:policy_year) { AcademicYear.new(2023) } + + # Eligible now - but falls out of 5 year window next year so don't set a reminder + context "ITT year: 18/19" do + let(:year) { 2018 } + + specify { expect(subject).to be false } + end + + context "ITT year: 19/20" do + let(:year) { 2019 } + + specify { expect(subject).to be true } + end + + context "ITT year: 20/21" do + let(:year) { 2020 } + + specify { expect(subject).to be true } + end + + context "ITT year: 21/22" do + let(:year) { 2021 } + + specify { expect(subject).to be true } + end + + context "ITT year: 22/23" do + let(:year) { 2022 } + + specify { expect(subject).to be true } + end + end + + # Last policy year - no reminders to set + context "Claim year: 24/25" do + let(:policy_year) { AcademicYear.new(2024) } + + context "ITT year: 19/20" do + let(:year) { 2019 } + + specify { expect(subject).to be false } + end + + context "ITT year: 20/21" do + let(:year) { 2020 } + + specify { expect(subject).to be false } + end + + context "ITT year: 21/22" do + let(:year) { 2021 } + + specify { expect(subject).to be false } + end + + context "ITT year: 22/23" do + let(:year) { 2022 } + + specify { expect(subject).to be false } + end + + context "ITT year: 23/24" do + let(:year) { 2023 } + + specify { expect(subject).to be false } + end + end + end end diff --git a/spec/models/reminder_spec.rb b/spec/models/reminder_spec.rb index b89e1314c0..7e55fcb046 100644 --- a/spec/models/reminder_spec.rb +++ b/spec/models/reminder_spec.rb @@ -46,114 +46,4 @@ end end end - - describe ".set_a_reminder?" do - subject { Reminder.set_a_reminder?(policy_year: policy_year, itt_academic_year: itt_academic_year) } - let(:itt_academic_year) { AcademicYear.new(year) } - - context "Claim year: 22/23" do - let(:policy_year) { AcademicYear.new(2022) } - - # Eligible now - but falls out of 5 year window next year so don't set a reminder - context "ITT year: 17/18" do - let(:year) { 2017 } - - specify { expect(subject).to be false } - end - - context "ITT year: 18/19" do - let(:year) { 2018 } - - specify { expect(subject).to be true } - end - - context "ITT year: 19/20" do - let(:year) { 2019 } - - specify { expect(subject).to be true } - end - - context "ITT year: 20/21" do - let(:year) { 2020 } - - specify { expect(subject).to be true } - end - - context "ITT year: 21/22" do - let(:year) { 2021 } - - specify { expect(subject).to be true } - end - end - - context "Claim year: 23/24" do - let(:policy_year) { AcademicYear.new(2023) } - - # Eligible now - but falls out of 5 year window next year so don't set a reminder - context "ITT year: 18/19" do - let(:year) { 2018 } - - specify { expect(subject).to be false } - end - - context "ITT year: 19/20" do - let(:year) { 2019 } - - specify { expect(subject).to be true } - end - - context "ITT year: 20/21" do - let(:year) { 2020 } - - specify { expect(subject).to be true } - end - - context "ITT year: 21/22" do - let(:year) { 2021 } - - specify { expect(subject).to be true } - end - - context "ITT year: 22/23" do - let(:year) { 2022 } - - specify { expect(subject).to be true } - end - end - - # Last policy year - no reminders to set - context "Claim year: 24/25" do - let(:policy_year) { AcademicYear.new(2024) } - - context "ITT year: 19/20" do - let(:year) { 2019 } - - specify { expect(subject).to be false } - end - - context "ITT year: 20/21" do - let(:year) { 2020 } - - specify { expect(subject).to be false } - end - - context "ITT year: 21/22" do - let(:year) { 2021 } - - specify { expect(subject).to be false } - end - - context "ITT year: 22/23" do - let(:year) { 2022 } - - specify { expect(subject).to be false } - end - - context "ITT year: 23/24" do - let(:year) { 2023 } - - specify { expect(subject).to be false } - end - end - end end