Browse Source

only annotate errors to the other fields if there was an error

CLDC-3987-Bug-fix-support-charge-validation
Samuel 3 days ago
parent
commit
e41d69feeb
  1. 7
      app/services/bulk_upload/lettings/year2024/row_parser.rb
  2. 7
      app/services/bulk_upload/lettings/year2025/row_parser.rb

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

@ -945,8 +945,11 @@ private
errors.add(field, I18n.t("#{ERROR_BASE_KEY}.charges.missing_charges", sentence_fragment: charge))
end
other_charge_fields.each_key do |field|
errors.add(field, I18n.t("#{ERROR_BASE_KEY}.charges.related_to_missing_charge"))
# if there were any errors, add an error to all the remaining present charges to make this entire section invalid
if blank_charge_fields.any?
other_charge_fields.each_key do |field|
errors.add(field, I18n.t("#{ERROR_BASE_KEY}.charges.related_to_missing_charge"))
end
end
end

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

@ -944,8 +944,11 @@ private
errors.add(field, I18n.t("#{ERROR_BASE_KEY}.charges.missing_charges", sentence_fragment: charge))
end
other_charge_fields.each_key do |field|
errors.add(field, I18n.t("#{ERROR_BASE_KEY}.charges.related_to_missing_charge"))
# if there were any errors, add an error to all the remaining present charges to make this entire section invalid
if blank_charge_fields.any?
other_charge_fields.each_key do |field|
errors.add(field, I18n.t("#{ERROR_BASE_KEY}.charges.related_to_missing_charge"))
end
end
end

Loading…
Cancel
Save