diff --git a/app/services/bulk_upload/lettings/year2024/row_parser.rb b/app/services/bulk_upload/lettings/year2024/row_parser.rb index 101352f0a..064aa3f26 100644 --- a/app/services/bulk_upload/lettings/year2024/row_parser.rb +++ b/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 diff --git a/app/services/bulk_upload/lettings/year2025/row_parser.rb b/app/services/bulk_upload/lettings/year2025/row_parser.rb index 61351764b..0745056d2 100644 --- a/app/services/bulk_upload/lettings/year2025/row_parser.rb +++ b/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