Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make teaching qualification duration optional #1845

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions app/lib/work_history_duration.rb
Original file line number Diff line number Diff line change
@@ -1,28 +1,46 @@
# frozen_string_literal: true

class WorkHistoryDuration
def initialize(application_form:, relation:)
def initialize(
application_form:,
relation:,
consider_teaching_qualification: true
)
@application_form = application_form
@relation =
relation.where.not(start_date: nil).where.not(hours_per_week: nil)
@consider_teaching_qualification = consider_teaching_qualification
end

def self.for_application_form(application_form)
def self.for_application_form(
application_form,
consider_teaching_qualification: true
)
WorkHistoryDuration.new(
application_form:,
relation: application_form.work_histories,
consider_teaching_qualification:,
)
end

def self.for_ids(ids, application_form:)
def self.for_ids(
ids,
application_form:,
consider_teaching_qualification: true
)
WorkHistoryDuration.new(
application_form:,
relation: application_form.work_histories.where(id: ids),
consider_teaching_qualification:,
)
end

def self.for_record(record)
for_ids([record.id], application_form: record.application_form)
def self.for_record(record, consider_teaching_qualification: true)
for_ids(
[record.id],
application_form: record.application_form,
consider_teaching_qualification:,
)
end

def count_months
Expand Down Expand Up @@ -59,7 +77,7 @@ def enough_to_skip_induction?
AVERAGE_WEEKS_PER_MONTH = 4.34
HOURS_PER_FULL_TIME_MONTH = 130.0

attr_reader :application_form, :relation
attr_reader :application_form, :relation, :consider_teaching_qualification

def work_histories
@work_histories ||=
Expand All @@ -71,7 +89,10 @@ def work_histories
end

def teaching_qualification
@teaching_qualification ||= application_form.teaching_qualification
@teaching_qualification ||=
if consider_teaching_qualification
application_form.teaching_qualification
end
end

def work_history_full_time_months(work_history)
Expand Down
Loading