diff --git a/app/lib/work_history_duration.rb b/app/lib/work_history_duration.rb index 32ce0d004b..c1ddd044d0 100644 --- a/app/lib/work_history_duration.rb +++ b/app/lib/work_history_duration.rb @@ -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 @@ -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 ||= @@ -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)