Skip to content

Commit

Permalink
Merge pull request #3021 from DFE-Digital/fe-award-amount
Browse files Browse the repository at this point in the history
[LUPEYALPHA-653] FE award amount
  • Loading branch information
asmega authored Jul 24, 2024
2 parents fbe51c0 + 367379c commit 68d1b56
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ class EligibleForm < Form
def save
true
end

def award_amount
journey_session.answers.award_amount
end
end
end
end
2 changes: 1 addition & 1 deletion app/models/journeys/further_education_payments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ module FurtherEducationPayments
"teaching-qualification" => TeachingQualificationForm,
"poor-performance" => PoorPerformanceForm,
"check-your-answers" => CheckYourAnswersForm,
"ineligible" => IneligibleForm,
"half-teaching-hours" => HalfTeachingHoursForm,
"hours-teaching-eligible-subjects" => HoursTeachingEligibleSubjectsForm,
"eligible" => EligibleForm,
"ineligible" => IneligibleForm,
"teacher-reference-number" => TeacherReferenceNumberForm
}
}
Expand Down
11 changes: 11 additions & 0 deletions app/models/journeys/further_education_payments/session_answers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,17 @@ def all_selected_courses_ineligible?
def less_than_half_hours_teaching_eligible_courses?
hours_teaching_eligible_subjects == false
end

def award_amount
case teaching_hours_per_week
when "more_than_12"
school.eligible_fe_provider.max_award_amount
when "between_2_5_and_12"
school.eligible_fe_provider.lower_award_amount
else
0
end
end
end
end
end
4 changes: 4 additions & 0 deletions app/models/school.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ def self.search(search_term, fe_only: false)
sql
end

def eligible_fe_provider(academic_year: AcademicYear.current)
EligibleFeProvider.find_by(ukprn:, academic_year:)
end

def address
[street, locality, town, county, postcode].reject(&:blank?).join(", ")
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</div>

<div class="govuk-heading-l">
£???
<%= number_to_currency(@form.award_amount, precision: 0) %>
</div>

<div class="govuk-body">
Expand Down
4 changes: 4 additions & 0 deletions spec/features/further_education_payments/happy_path_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
require "rails_helper"

RSpec.feature "Further education payments" do
include ActionView::Helpers::NumberHelper

let(:college) { create(:school, :further_education, :fe_eligible) }
let(:expected_award_amount) { college.eligible_fe_provider.max_award_amount }

scenario "happy path claim" do
when_further_education_payments_journey_configuration_exists
Expand Down Expand Up @@ -106,6 +109,7 @@
click_button "Continue"

expect(page).to have_content("You’re eligible for a financial incentive payment")
expect(page).to have_content(number_to_currency(expected_award_amount, precision: 0))
expect(page).to have_content("Apply now")
click_button "Apply now"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
require "rails_helper"

RSpec.describe Journeys::FurtherEducationPayments::SessionAnswers do
subject { described_class.new(answers.attributes) }

let(:school) { create(:school, :further_education, :fe_eligible) }

describe "#award_amount" do
context "when teaching over 12 hours per week" do
let(:answers) do
build(
:further_education_payments_answers,
school_id: school.id,
teaching_hours_per_week: "more_than_12"
)
end

it "returns max award amount" do
expect(subject.award_amount).to eql(school.eligible_fe_provider.max_award_amount)
end
end

context "when teaching between 2.5 and 12 hours per week" do
let(:answers) do
build(
:further_education_payments_answers,
school_id: school.id,
teaching_hours_per_week: "between_2_5_and_12"
)
end

it "returns lower award amount" do
expect(subject.award_amount).to eql(school.eligible_fe_provider.lower_award_amount)
end
end

context "when teaching less than 2.5 hours per week" do
let(:answers) do
build(
:further_education_payments_answers,
school_id: school.id,
teaching_hours_per_week: "less_than_2_5"
)
end

it "returns zero" do
expect(subject.award_amount).to be_zero
end
end
end
end

0 comments on commit 68d1b56

Please sign in to comment.