diff --git a/app/models/case_log.rb b/app/models/case_log.rb index f3984e247..0261f7d6a 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -144,7 +144,6 @@ class CaseLog < ApplicationRecord enum declaration: POLAR, _suffix: true AUTOGENERATED_FIELDS = %w[id status created_at updated_at discarded_at].freeze - OPTIONAL_FIELDS = %w[postcode_known la_known first_time_property_let_as_social_housing].freeze def form FormHandler.instance.get_form(form_name) diff --git a/app/models/constants/case_log.rb b/app/models/constants/case_log.rb index 73cfc4a51..3a2593314 100644 --- a/app/models/constants/case_log.rb +++ b/app/models/constants/case_log.rb @@ -1123,4 +1123,6 @@ module Constants::CaseLog "Sheltered accomodation", "Home Office Asylum Support", "Other"].freeze + + OPTIONAL_FIELDS = %w[postcode_known la_known first_time_property_let_as_social_housing tenant_code propcode].freeze end diff --git a/app/models/form/subsection.rb b/app/models/form/subsection.rb index e3166a4e1..c0c330bec 100644 --- a/app/models/form/subsection.rb +++ b/app/models/form/subsection.rb @@ -1,4 +1,6 @@ class Form::Subsection + include Constants::CaseLog + attr_accessor :id, :label, :section, :pages, :depends_on, :form def initialize(id, hsh, section) @@ -30,7 +32,7 @@ class Form::Subsection return :cannot_start_yet end - qs = applicable_questions(case_log) + qs = applicable_questions(case_log).reject { |q| OPTIONAL_FIELDS.include?(q.id) } return :not_started if qs.all? { |question| case_log[question.id].blank? || question.read_only? } return :completed if qs.all? { |question| question.completed?(case_log) }