Browse Source

Update setting errors

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

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

@ -750,13 +750,18 @@ private
end
def validate_reasonable_preference_dont_know
other_reason_fields = %i[field_107 field_108 field_109 field_110]
if field_106 == 1
selected_reasons = [field_107, field_108, field_109, field_110].count(1)
selected_reasons = other_reason_fields.select { |field| send(field) == 1 }
dont_know_selected = field_111 == 1
if selected_reasons.positive? && dont_know_selected
if selected_reasons.any? && dont_know_selected
block_log_creation!
errors.add(:field_111, I18n.t("#{ERROR_BASE_KEY}.reasonpref.conflict"))
errors.add(:field_111, I18n.t("#{ERROR_BASE_KEY}.reasonpref.conflict.dont_know"))
selected_reasons.each do |field|
errors.add(field, I18n.t("#{ERROR_BASE_KEY}.reasonpref.conflict.other"))
end
end
end
end

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

@ -59,4 +59,6 @@ en:
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."
conflict:
dont_know: "You cannot select 'Don't know' if any of the other reasonable preference reasons are also selected."
other: "You cannot select this reasonable preference reason as you've also selected 'Don't know' as a reason."

Loading…
Cancel
Save