Browse Source

Add validation on reasonpref dontknow

CLDC-3860-Bulk-upload-prevent-reasonpref-dontknow-being-selected
Manny Dinssa 2 weeks ago
parent
commit
212a0bda0c
  1. 12
      app/services/bulk_upload/lettings/year2024/row_parser.rb
  2. 2
      config/locales/validations/lettings/2024/bulk_upload.en.yml

12
app/services/bulk_upload/lettings/year2024/row_parser.rb

@ -418,6 +418,7 @@ class BulkUpload::Lettings::Year2024::RowParser
validate :validate_no_and_dont_know_disabled_needs_conjunction, on: :after_log
validate :validate_no_housing_needs_questions_answered, on: :after_log
validate :validate_reasonable_preference_homeless, on: :after_log
validate :validate_reasonable_preference_dont_know, on: :after_log
validate :validate_condition_effects, on: :after_log
validate :validate_if_log_already_exists, on: :after_log, if: -> { FeatureToggle.bulk_upload_duplicate_log_check_enabled? }
@ -748,6 +749,17 @@ private
end
end
def validate_reasonable_preference_dont_know
if field_106 == 1
selected_reasons = [field_107, field_108, field_109, field_110].count(1)
dont_know_selected = field_111 == 1
if selected_reasons.positive? && dont_know_selected
errors.add(:field_111, I18n.t("#{ERROR_BASE_KEY}.reasonpref.conflict"))
end
end
end
def validate_condition_effects
illness_option_fields = %i[field_94 field_88 field_91 field_86 field_87 field_89 field_90 field_93 field_92 field_95]
if household_no_illness?

2
config/locales/validations/lettings/2024/bulk_upload.en.yml

@ -58,3 +58,5 @@ en:
invalid: "Select a valid nationality."
charges:
missing_charges: "Please enter the %{sentence_fragment}. If there is no %{sentence_fragment}, please enter '0'."
reasonpref:
conflict: "You cannot select 'Don't know' if any of the other reasonable preference reasons are also selected."

Loading…
Cancel
Save