|
|
|
@ -762,17 +762,10 @@ 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 = other_reason_fields.select { |field| send(field) == 1 } |
|
|
|
|
dont_know_selected = field_111 == 1 |
|
|
|
|
|
|
|
|
|
if selected_reasons.any? && dont_know_selected |
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
if rp_dontknow_conflict? |
|
|
|
|
errors.add(:field_111, I18n.t("#{ERROR_BASE_KEY}.reasonpref.conflict.dont_know")) |
|
|
|
|
%i[field_107 field_108 field_109 field_110].each do |field| |
|
|
|
|
errors.add(field, I18n.t("#{ERROR_BASE_KEY}.reasonpref.conflict.other")) if send(field) == 1 |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
@ -1287,11 +1280,11 @@ private
|
|
|
|
|
attributes["ppostcode_full"] = ppostcode_full |
|
|
|
|
|
|
|
|
|
attributes["reasonpref"] = field_106 |
|
|
|
|
attributes["rp_homeless"] = field_107 |
|
|
|
|
attributes["rp_insan_unsat"] = field_108 |
|
|
|
|
attributes["rp_medwel"] = field_109 |
|
|
|
|
attributes["rp_hardship"] = field_110 |
|
|
|
|
attributes["rp_dontknow"] = field_111 |
|
|
|
|
attributes["rp_homeless"] = field_107 unless rp_dontknow_conflict? |
|
|
|
|
attributes["rp_insan_unsat"] = field_108 unless rp_dontknow_conflict? |
|
|
|
|
attributes["rp_medwel"] = field_109 unless rp_dontknow_conflict? |
|
|
|
|
attributes["rp_hardship"] = field_110 unless rp_dontknow_conflict? |
|
|
|
|
attributes["rp_dontknow"] = field_111 unless rp_dontknow_conflict? |
|
|
|
|
|
|
|
|
|
attributes["cbl"] = cbl |
|
|
|
|
attributes["chr"] = chr |
|
|
|
@ -1678,4 +1671,15 @@ private
|
|
|
|
|
def bulk_upload_organisation |
|
|
|
|
Organisation.find(bulk_upload.organisation_id) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def rp_dontknow_conflict? |
|
|
|
|
other_reason_fields = %i[field_107 field_108 field_109 field_110] |
|
|
|
|
if field_106 == 1 |
|
|
|
|
selected_reasons = other_reason_fields.select { |field| send(field) == 1 } |
|
|
|
|
dont_know_selected = field_111 == 1 |
|
|
|
|
|
|
|
|
|
return true if selected_reasons.any? && dont_know_selected |
|
|
|
|
end |
|
|
|
|
false |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|