diff --git a/app/helpers/schemes_helper.rb b/app/helpers/schemes_helper.rb index 4e3fa9b13..8a3a652c7 100644 --- a/app/helpers/schemes_helper.rb +++ b/app/helpers/schemes_helper.rb @@ -11,7 +11,7 @@ module SchemesHelper { name: "Support services provided by", value: scheme.arrangement_type }, { name: "Primary client group", value: scheme.primary_client_group }, { name: "Has another client group", value: scheme.has_other_client_group }, - scheme.has_other_client_group == "Yes" ? { name: "Secondary client group", value: scheme.secondary_client_group } : nil, + scheme.has_other_client_group == "No" ? nil : { name: "Secondary client group", value: scheme.secondary_client_group }, { name: "Level of support given", value: scheme.support_type }, { name: "Intended length of stay", value: scheme.intended_stay }, { name: "Availability", value: scheme_availability(scheme) }, diff --git a/app/models/derived_variables/scheme_variables.rb b/app/models/derived_variables/scheme_variables.rb index ed06ed3c2..1d4a0c043 100644 --- a/app/models/derived_variables/scheme_variables.rb +++ b/app/models/derived_variables/scheme_variables.rb @@ -3,5 +3,8 @@ module DerivedVariables::SchemeVariables if has_other_client_group == "No" self.secondary_client_group = nil end + if secondary_client_group.present? + self.has_other_client_group = "Yes" + end end end diff --git a/app/models/scheme.rb b/app/models/scheme.rb index 4d2b5ef8b..e5a581264 100644 --- a/app/models/scheme.rb +++ b/app/models/scheme.rb @@ -192,7 +192,7 @@ class Scheme < ApplicationRecord end def validate_confirmed - required_attributes = attribute_names - %w[id created_at updated_at old_id old_visible_id confirmed end_date sensitive secondary_client_group total_units deactivation_date deactivation_date_type] + required_attributes = attribute_names - %w[id created_at updated_at old_id old_visible_id confirmed end_date sensitive secondary_client_group total_units has_other_client_group deactivation_date deactivation_date_type] if confirmed == true required_attributes.any? do |attribute|