Browse Source

CLDC-4432: Skip invalid field errors if the question is not routed to

pull/3322/head
samyou-softwire 2 weeks ago
parent
commit
22b6c80208
  1. 8
      app/services/bulk_upload/lettings/year2025/row_parser.rb
  2. 8
      app/services/bulk_upload/lettings/year2026/row_parser.rb
  3. 8
      app/services/bulk_upload/sales/year2025/row_parser.rb
  4. 8
      app/services/bulk_upload/sales/year2026/row_parser.rb

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

@ -1035,6 +1035,14 @@ private
def add_errors_for_invalid_fields def add_errors_for_invalid_fields
invalid_fields.each do |field| invalid_fields.each do |field|
# ensure questions not routed to are not included in error report
error_questions_ids = field_mapping_for_errors
.select { |_k, fields| fields.map(&:to_s).include?(field.to_s) }
.keys
.map(&:to_s)
error_questions = questions.select { |question| error_questions_ids.include?(question.id) }
next if error_questions.none? { |question| question.page.routed_to?(log, nil) }
errors.delete(field) # take precedence over any other errors as this is a BU format issue errors.delete(field) # take precedence over any other errors as this is a BU format issue
errors.add(field, I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: QUESTIONS[field.to_sym])) errors.add(field, I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: QUESTIONS[field.to_sym]))
end end

8
app/services/bulk_upload/lettings/year2026/row_parser.rb

@ -1113,6 +1113,14 @@ private
def add_errors_for_invalid_fields def add_errors_for_invalid_fields
invalid_fields.each do |field| invalid_fields.each do |field|
# ensure questions not routed to are not included in error report
error_questions_ids = field_mapping_for_errors
.select { |_k, fields| fields.map(&:to_s).include?(field.to_s) }
.keys
.map(&:to_s)
error_questions = questions.select { |question| error_questions_ids.include?(question.id) }
next if error_questions.none? { |question| question.page.routed_to?(log, nil) }
errors.delete(field) # take precedence over any other errors as this is a BU format issue errors.delete(field) # take precedence over any other errors as this is a BU format issue
errors.add(field, I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: QUESTIONS[field.to_sym])) errors.add(field, I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: QUESTIONS[field.to_sym]))
end end

8
app/services/bulk_upload/sales/year2025/row_parser.rb

@ -689,6 +689,14 @@ private
def add_errors_for_invalid_fields def add_errors_for_invalid_fields
invalid_fields.each do |field| invalid_fields.each do |field|
# ensure questions not routed to are not included in error report
error_questions_ids = field_mapping_for_errors
.select { |_k, fields| fields.map(&:to_s).include?(field.to_s) }
.keys
.map(&:to_s)
error_questions = questions.select { |question| error_questions_ids.include?(question.id) }
next if error_questions.none? { |question| question.page.routed_to?(log, nil) }
errors.delete(field) # take precedence over any other errors as this is a BU format issue errors.delete(field) # take precedence over any other errors as this is a BU format issue
errors.add(field, I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: QUESTIONS[field.to_sym])) errors.add(field, I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: QUESTIONS[field.to_sym]))
end end

8
app/services/bulk_upload/sales/year2026/row_parser.rb

@ -750,6 +750,14 @@ private
def add_errors_for_invalid_fields def add_errors_for_invalid_fields
invalid_fields.each do |field| invalid_fields.each do |field|
# ensure questions not routed to are not included in error report
error_questions_ids = field_mapping_for_errors
.select { |_k, fields| fields.map(&:to_s).include?(field.to_s) }
.keys
.map(&:to_s)
error_questions = questions.select { |question| error_questions_ids.include?(question.id) }
next if error_questions.none? { |question| question.page.routed_to?(log, nil) }
errors.delete(field) # take precedence over any other errors as this is a BU format issue errors.delete(field) # take precedence over any other errors as this is a BU format issue
errors.add(field, I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: QUESTIONS[field.to_sym])) errors.add(field, I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: QUESTIONS[field.to_sym]))
end end

Loading…
Cancel
Save