diff --git a/app/controllers/bulk_upload_sales_results_controller.rb b/app/controllers/bulk_upload_sales_results_controller.rb index feb7b3e06..7f97fd743 100644 --- a/app/controllers/bulk_upload_sales_results_controller.rb +++ b/app/controllers/bulk_upload_sales_results_controller.rb @@ -27,6 +27,12 @@ class BulkUploadSalesResultsController < ApplicationController authorize @bulk_upload end + def deletion_report + @bulk_upload = BulkUpload.lettings.find(params[:id]) + + authorize @bulk_upload + end + private def reset_logs_filters diff --git a/app/services/bulk_upload/sales/year2023/row_parser.rb b/app/services/bulk_upload/sales/year2023/row_parser.rb index 6ed79f3af..58783dcef 100644 --- a/app/services/bulk_upload/sales/year2023/row_parser.rb +++ b/app/services/bulk_upload/sales/year2023/row_parser.rb @@ -608,18 +608,18 @@ private def validate_uprn_exists_if_any_key_address_fields_are_blank if field_19.blank? && (field_20.blank? || field_22.blank?) - errors.add(:field_19, I18n.t("validations.not_answered", question: "UPRN")) + errors.add(:field_19, I18n.t("validations.not_answered", question: "UPRN"), category: :not_answered) end end def validate_address_fields if field_19.blank? || log.errors.attribute_names.include?(:uprn) if field_20.blank? - errors.add(:field_20, I18n.t("validations.not_answered", question: "address line 1")) + errors.add(:field_20, I18n.t("validations.not_answered", question: "address line 1"), category: :not_answered) end if field_22.blank? - errors.add(:field_22, I18n.t("validations.not_answered", question: "town or city")) + errors.add(:field_22, I18n.t("validations.not_answered", question: "town or city"), category: :not_answered) end end end @@ -1245,7 +1245,7 @@ private else fields.each do |field| unless errors.any? { |e| fields.include?(e.attribute) } - errors.add(field, I18n.t("validations.not_answered", question: question.error_display_label&.downcase)) + errors.add(field, I18n.t("validations.not_answered", question: question.error_display_label&.downcase), category: :not_answered) end end end diff --git a/app/views/bulk_upload_sales_results/deletion_report.html.erb b/app/views/bulk_upload_sales_results/deletion_report.html.erb new file mode 100644 index 000000000..3bb03eaae --- /dev/null +++ b/app/views/bulk_upload_sales_results/deletion_report.html.erb @@ -0,0 +1,31 @@ +<% content_for :before_content do %> + <%= govuk_back_link(href: :back) %> +<% end %> + +
+
+ Bulk upload for sales (<%= @bulk_upload.year_combo %>) +

<%= pluralize(unique_answers_to_be_cleared(@bulk_upload).count, "answer") %> will be deleted if you upload the <%= "log".pluralize(@bulk_upload.logs.count) %>

+ +

The following cells contain data this is incorrect.

+

If you upload the logs, these answers will be deleted. You will have to re-enter the data on the site and resolve these errors.

+

If you do not want these answers to be deleted, correct the data in the CSV and upload the file again.

+ +

File: <%= @bulk_upload.filename %>

+
+
+ +
+
+ <% @bulk_upload.bulk_upload_errors.order_by_row.order_by_cell.group_by(&:row).each do |_row, errors_for_row| %> + <%= render BulkUploadErrorRowComponent.new(bulk_upload_errors: errors_for_row.reject { |e| e.category == :not_answered }) %> + <% end %> +
+
+ +
+ <%= form_with model: @form, scope: :form, url: page_bulk_upload_sales_resume_path(@bulk_upload, page: "confirm"), method: :patch do |f| %> + <%= f.govuk_submit "Clear this data and upload the logs" %> + <%= govuk_button_link_to "I have fixed these errors and I want to reupload the file", start_bulk_upload_sales_logs_path, secondary: true %> + <% end %> +
diff --git a/app/views/bulk_upload_sales_resume/confirm.html.erb b/app/views/bulk_upload_sales_resume/confirm.html.erb index 05a8cfd41..0e4e73d9c 100644 --- a/app/views/bulk_upload_sales_resume/confirm.html.erb +++ b/app/views/bulk_upload_sales_resume/confirm.html.erb @@ -5,14 +5,23 @@
Bulk upload for sales (<%= @bulk_upload.year_combo %>) -

You have chosen to upload all logs from this bulk upload.

+

Are you sure you want to upload all logs from this bulk upload?

-

<%= logs_and_errors_warning(@bulk_upload) %>

+

+ <%= logs_and_errors_warning(@bulk_upload) %> + <%= govuk_link_to "View the error report", deletion_report_bulk_upload_sales_result_path %> +

- <%= form_with model: @form, scope: :form, url: page_bulk_upload_sales_resume_path(@bulk_upload, page: "confirm"), method: :patch do |f| %> - <%= f.govuk_submit %> - - <%= govuk_button_link_to "Cancel", @form.back_path, secondary: true %> + <%= govuk_warning_text do %> + <%= deleted_errors_warning_text(@bulk_upload) %> + <%= govuk_link_to "See which answers will be deleted", deletion_report_bulk_upload_sales_result_path %> <% end %> + +
+ <%= form_with model: @form, scope: :form, url: page_bulk_upload_sales_resume_path(@bulk_upload, page: "confirm"), method: :patch do |f| %> + <%= f.govuk_submit "Confirm" %> + <%= govuk_button_link_to "Cancel", @form.back_path, secondary: true %> + <% end %> +
diff --git a/app/views/bulk_upload_sales_resume/fix_choice.html.erb b/app/views/bulk_upload_sales_resume/fix_choice.html.erb index b9cba32ed..850bd54f0 100644 --- a/app/views/bulk_upload_sales_resume/fix_choice.html.erb +++ b/app/views/bulk_upload_sales_resume/fix_choice.html.erb @@ -18,6 +18,10 @@ <%= @form.recommendation %> +
+ <%= govuk_link_to "View the error report", deletion_report_bulk_upload_sales_result_path %> +
+ <%= govuk_details(summary_text: "How to choose between fixing errors on the CORE site or in the CSV") do %>

You may find it easier to fix the errors in the CSV file if: