diff --git a/app/models/case_log.rb b/app/models/case_log.rb index 4a3af3c75..1d504ac19 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -50,7 +50,7 @@ class CaseLog < ApplicationRecord } AUTOGENERATED_FIELDS = %w[id status created_at updated_at discarded_at].freeze - OPTIONAL_FIELDS = %w[postcode_known previous_la_known first_time_property_let_as_social_housing tenant_code propcode].freeze + OPTIONAL_FIELDS = %w[first_time_property_let_as_social_housing tenant_code propcode].freeze RENT_TYPE_MAPPING = { 0 => 1, 1 => 2, 2 => 2, 3 => 3, 4 => 3, 5 => 3 }.freeze RENT_TYPE_MAPPING_LABELS = { 1 => "Social Rent", 2 => "Affordable Rent", 3 => "Intermediate Rent" }.freeze HAS_BENEFITS_OPTIONS = [1, 6, 8, 7].freeze @@ -419,7 +419,8 @@ private end def dynamically_not_required - (form.invalidated_questions(self) + form.readonly_questions).map(&:id).uniq + previous_la_known_field = postcode_known? ? %w[previous_la_known] : [] + ((form.invalidated_questions(self) + form.readonly_questions).map(&:id) + previous_la_known_field).uniq end def set_derived_fields! diff --git a/spec/factories/case_log.rb b/spec/factories/case_log.rb index 2b1f780ac..11a38de09 100644 --- a/spec/factories/case_log.rb +++ b/spec/factories/case_log.rb @@ -103,6 +103,7 @@ FactoryBot.define do tenancyother { nil } net_income_value_check { nil } net_income_known { 1 } + previous_la_known { 1 } property_owner_organisation { "Test" } property_manager_organisation { "Test" } renewal { 0 } diff --git a/spec/fixtures/exports/case_logs.xml b/spec/fixtures/exports/case_logs.xml index 1d712eed8..4c91a1271 100644 --- a/spec/fixtures/exports/case_logs.xml +++ b/spec/fixtures/exports/case_logs.xml @@ -132,7 +132,7 @@ 1 1 - + 1 false