Browse Source

Update 2025 row parser

pull/2955/head
Manny Dinssa 2 months ago
parent
commit
68b16d197a
  1. 1
      app/services/bulk_upload/lettings/year2024/row_parser.rb
  2. 17
      app/services/bulk_upload/lettings/year2025/row_parser.rb
  3. 4
      config/locales/validations/lettings/2025/bulk_upload.en.yml
  4. 13
      spec/services/bulk_upload/lettings/year2025/row_parser_spec.rb

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

@ -756,7 +756,6 @@ private
dont_know_selected = field_111 == 1 dont_know_selected = field_111 == 1
if selected_reasons.any? && dont_know_selected if selected_reasons.any? && dont_know_selected
block_log_creation!
errors.add(:field_111, I18n.t("#{ERROR_BASE_KEY}.reasonpref.conflict.dont_know")) errors.add(:field_111, I18n.t("#{ERROR_BASE_KEY}.reasonpref.conflict.dont_know"))
selected_reasons.each do |field| selected_reasons.each do |field|

17
app/services/bulk_upload/lettings/year2025/row_parser.rb

@ -417,6 +417,7 @@ class BulkUpload::Lettings::Year2025::RowParser
validate :validate_no_and_dont_know_disabled_needs_conjunction, on: :after_log validate :validate_no_and_dont_know_disabled_needs_conjunction, on: :after_log
validate :validate_no_housing_needs_questions_answered, 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_homeless, on: :after_log
validate :validate_reasonable_preference_dont_know, on: :after_log
validate :validate_condition_effects, 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? } validate :validate_if_log_already_exists, on: :after_log, if: -> { FeatureToggle.bulk_upload_duplicate_log_check_enabled? }
@ -747,6 +748,22 @@ private
end end
end 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
end
end
end
def validate_condition_effects 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] 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? if household_no_illness?

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

@ -58,3 +58,7 @@ en:
invalid: "Select a valid nationality." invalid: "Select a valid nationality."
charges: charges:
missing_charges: "Please enter the %{sentence_fragment}. If there is no %{sentence_fragment}, please enter '0'." missing_charges: "Please enter the %{sentence_fragment}. If there is no %{sentence_fragment}, please enter '0'."
reasonpref:
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."

13
spec/services/bulk_upload/lettings/year2025/row_parser_spec.rb

@ -1083,6 +1083,19 @@ RSpec.describe BulkUpload::Lettings::Year2025::RowParser do
expect(parser.errors[:field_111]).to be_present expect(parser.errors[:field_111]).to be_present
end end
end end
context "when some reasonable preference options are selected" do
let(:attributes) { setup_section_params.merge({ bulk_upload:, field_106: "1", field_107: "1", field_108: nil, field_109: "1", field_110: nil, field_111: nil }) }
it "sets the rest of the options to 0" do
parser.valid?
expect(parser.log.rp_homeless).to eq(1)
expect(parser.log.rp_insan_unsat).to eq(0)
expect(parser.log.rp_medwel).to eq(1)
expect(parser.log.rp_hardship).to eq(0)
expect(parser.log.rp_dontknow).to eq(0)
end
end
end end
describe "#field_116" do # referral describe "#field_116" do # referral

Loading…
Cancel
Save