diff --git a/app/controllers/bulk_upload_lettings_logs_controller.rb b/app/controllers/bulk_upload_lettings_logs_controller.rb index ec5975432..40f898012 100644 --- a/app/controllers/bulk_upload_lettings_logs_controller.rb +++ b/app/controllers/bulk_upload_lettings_logs_controller.rb @@ -21,11 +21,6 @@ class BulkUploadLettingsLogsController < ApplicationController end end - def guidance - @form = Forms::BulkUploadLettings::PrepareYourFile.new - render "bulk_upload_shared/guidance" - end - private def current_year @@ -44,6 +39,8 @@ private Forms::BulkUploadLettings::Year.new(form_params) when "prepare-your-file" Forms::BulkUploadLettings::PrepareYourFile.new(form_params) + when "guidance" + Forms::BulkUploadLettings::Guidance.new(form_params) when "needstype" Forms::BulkUploadLettings::Needstype.new(form_params) when "upload-your-file" diff --git a/app/controllers/bulk_upload_sales_logs_controller.rb b/app/controllers/bulk_upload_sales_logs_controller.rb index 2b3432399..85be7e96d 100644 --- a/app/controllers/bulk_upload_sales_logs_controller.rb +++ b/app/controllers/bulk_upload_sales_logs_controller.rb @@ -21,11 +21,6 @@ class BulkUploadSalesLogsController < ApplicationController end end - def guidance - @form = Forms::BulkUploadSales::PrepareYourFile.new - render "bulk_upload_shared/guidance" - end - private def current_year @@ -42,6 +37,8 @@ private Forms::BulkUploadSales::Year.new(form_params) when "prepare-your-file" Forms::BulkUploadSales::PrepareYourFile.new(form_params) + when "guidance" + Forms::BulkUploadSales::Guidance.new(form_params) when "upload-your-file" Forms::BulkUploadSales::UploadYourFile.new(form_params.merge(current_user:)) when "checking-file" diff --git a/app/models/forms/bulk_upload_lettings/guidance.rb b/app/models/forms/bulk_upload_lettings/guidance.rb new file mode 100644 index 000000000..2610ed62d --- /dev/null +++ b/app/models/forms/bulk_upload_lettings/guidance.rb @@ -0,0 +1,27 @@ +module Forms + module BulkUploadLettings + class Guidance + include ActiveModel::Model + include ActiveModel::Attributes + include Rails.application.routes.url_helpers + + attribute :year, :integer + + def view_path + "bulk_upload_shared/guidance" + end + + def back_path + bulk_upload_lettings_log_path(id: "prepare-your-file", form: { year: }) + end + + def template_path + Forms::BulkUploadLettings::PrepareYourFile.new(year:).template_path + end + + def specification_path + Forms::BulkUploadLettings::PrepareYourFile.new(year:).specification_path + end + end + end +end diff --git a/app/models/forms/bulk_upload_lettings/prepare_your_file.rb b/app/models/forms/bulk_upload_lettings/prepare_your_file.rb index 68b9dd5c6..6db68e49d 100644 --- a/app/models/forms/bulk_upload_lettings/prepare_your_file.rb +++ b/app/models/forms/bulk_upload_lettings/prepare_your_file.rb @@ -26,11 +26,21 @@ module Forms end def template_path - "/files/bulk-upload-lettings-template-v1.xlsx" + case year + when 2022 + "/files/bulk-upload-lettings-template-2022-23.xlsx" + when 2023 + "/files/bulk-upload-lettings-template-2023-24.xlsx" + end end def specification_path - "/files/bulk-upload-lettings-specification-2022-23.xlsx" + case year + when 2022 + "/files/bulk-upload-lettings-specification-2022-23.xlsx" + when 2023 + "/files/bulk-upload-lettings-specification-2023-24.xlsx" + end end def year_combo diff --git a/app/models/forms/bulk_upload_sales/guidance.rb b/app/models/forms/bulk_upload_sales/guidance.rb new file mode 100644 index 000000000..869ce8be2 --- /dev/null +++ b/app/models/forms/bulk_upload_sales/guidance.rb @@ -0,0 +1,27 @@ +module Forms + module BulkUploadSales + class Guidance + include ActiveModel::Model + include ActiveModel::Attributes + include Rails.application.routes.url_helpers + + attribute :year, :integer + + def view_path + "bulk_upload_shared/guidance" + end + + def back_path + bulk_upload_sales_log_path(id: "prepare-your-file", form: { year: }) + end + + def template_path + Forms::BulkUploadSales::PrepareYourFile.new(year:).template_path + end + + def specification_path + Forms::BulkUploadSales::PrepareYourFile.new(year:).specification_path + end + end + end +end diff --git a/app/models/forms/bulk_upload_sales/prepare_your_file.rb b/app/models/forms/bulk_upload_sales/prepare_your_file.rb index 52d70a85c..cdf2cf455 100644 --- a/app/models/forms/bulk_upload_sales/prepare_your_file.rb +++ b/app/models/forms/bulk_upload_sales/prepare_your_file.rb @@ -24,11 +24,21 @@ module Forms end def template_path - "/files/bulk-upload-sales-template-v1.xlsx" + case year + when 2022 + "/files/bulk-upload-sales-template-2022-23.xlsx" + when 2023 + "/files/bulk-upload-sales-template-2023-24.xlsx" + end end def specification_path - "/files/bulk-upload-sales-specification-2022-23.xlsx" + case year + when 2022 + "/files/bulk-upload-sales-specification-2022-23.xlsx" + when 2023 + "/files/bulk-upload-sales-specification-2023-24.xlsx" + end end def year_combo diff --git a/app/models/validations/financial_validations.rb b/app/models/validations/financial_validations.rb index fc1c44585..c68343ae1 100644 --- a/app/models/validations/financial_validations.rb +++ b/app/models/validations/financial_validations.rb @@ -4,7 +4,7 @@ module Validations::FinancialValidations # or 'validate_' to run on submit as well def validate_outstanding_rent_amount(record) if !record.has_hbrentshortfall? && record.tshortfall.present? - record.errors.add :tshortfall, I18n.t("validations.financial.tshortfall.outstanding_amount_not_required") + record.errors.add :tshortfall, :no_outstanding_charges, message: I18n.t("validations.financial.tshortfall.outstanding_amount_not_required") end end diff --git a/app/models/validations/sales/financial_validations.rb b/app/models/validations/sales/financial_validations.rb index 8f81aa117..2cd06b9ba 100644 --- a/app/models/validations/sales/financial_validations.rb +++ b/app/models/validations/sales/financial_validations.rb @@ -37,7 +37,7 @@ module Validations::Sales::FinancialValidations end def validate_mortgage(record) - record.errors.add :mortgage, I18n.t("validations.financial.mortgage") if record.mortgage_used? && record.mortgage&.zero? + record.errors.add :mortgage, :cannot_be_0, message: I18n.t("validations.financial.mortgage") if record.mortgage_used? && record.mortgage&.zero? end def validate_cash_discount(record) diff --git a/app/models/validations/tenancy_validations.rb b/app/models/validations/tenancy_validations.rb index 5e1ec4a3c..14727d3b0 100644 --- a/app/models/validations/tenancy_validations.rb +++ b/app/models/validations/tenancy_validations.rb @@ -42,7 +42,7 @@ module Validations::TenancyValidations def validate_joint_tenancy(record) return unless record.collection_start_year && record.joint - if record.hhmemb == 1 && record.joint != 2 && record.collection_start_year >= 2022 + if record.hhmemb == 1 && record.joint == 1 && record.collection_start_year >= 2022 record.errors.add :joint, :not_joint_tenancy, message: I18n.t("validations.tenancy.not_joint") record.errors.add :hhmemb, I18n.t("validations.tenancy.joint_more_than_one_member") end diff --git a/app/services/imports/lettings_logs_import_service.rb b/app/services/imports/lettings_logs_import_service.rb index ecd32c51d..9bbb15723 100644 --- a/app/services/imports/lettings_logs_import_service.rb +++ b/app/services/imports/lettings_logs_import_service.rb @@ -332,6 +332,12 @@ module Imports @logs_overridden << lettings_log.old_id attributes.delete("ecstat1") save_lettings_log(attributes, previous_status) + elsif lettings_log.errors.of_kind?(:tshortfall, :no_outstanding_charges) + @logger.warn("Log #{lettings_log.old_id}: Removing tshortfall as there are no outstanding charges") + @logs_overridden << lettings_log.old_id + attributes.delete("tshortfall") + attributes.delete("hbrentshortfall") + save_lettings_log(attributes, previous_status) else @logger.error("Log #{lettings_log.old_id}: Failed to import") lettings_log.errors.each do |error| diff --git a/app/services/imports/sales_logs_import_service.rb b/app/services/imports/sales_logs_import_service.rb index e6f735b3e..4d26639da 100644 --- a/app/services/imports/sales_logs_import_service.rb +++ b/app/services/imports/sales_logs_import_service.rb @@ -225,6 +225,11 @@ module Imports attributes.delete("postcode_full") attributes["pcodenk"] = attributes["la"].present? ? 1 : nil save_sales_log(attributes, previous_status) + elsif sales_log.errors.of_kind?(:mortgage, :cannot_be_0) + @logger.warn("Log #{sales_log.old_id}: Removing mortgage because it cannot be 0") + @logs_overridden << sales_log.old_id + attributes.delete("mortgage") + save_sales_log(attributes, previous_status) else @logger.error("Log #{sales_log.old_id}: Failed to import") sales_log.errors.each do |error| diff --git a/app/views/bulk_upload_lettings_logs/forms/prepare_your_file.html.erb b/app/views/bulk_upload_lettings_logs/forms/prepare_your_file.html.erb index eb5c95adc..65f0a7eaf 100644 --- a/app/views/bulk_upload_lettings_logs/forms/prepare_your_file.html.erb +++ b/app/views/bulk_upload_lettings_logs/forms/prepare_your_file.html.erb @@ -13,14 +13,14 @@
- We could not create logs from your bulk upload. Below is a list of everything that you need to fix your spreadsheet. You can download the specification to help you fix the cells in your CSV file. + We could not create logs from your bulk upload. Below is a list of everything that you need to fix your spreadsheet. You can download the <%= govuk_link_to "specification", Forms::BulkUploadLettings::PrepareYourFile.new(year: @bulk_upload.year).specification_path, target: "_blank" %> to help you fix the cells in your CSV file.
diff --git a/app/views/bulk_upload_sales_logs/forms/prepare_your_file.html.erb b/app/views/bulk_upload_sales_logs/forms/prepare_your_file.html.erb index d2a6bd70c..9f59bf509 100644 --- a/app/views/bulk_upload_sales_logs/forms/prepare_your_file.html.erb +++ b/app/views/bulk_upload_sales_logs/forms/prepare_your_file.html.erb @@ -13,13 +13,13 @@
It can take HMS providers a while to update these per new collection year, so you may have to wait for updates to export, or adjust your data manually post-export.
<% end %> <%= govuk_details(summary_text: "My organisation does not have a CMS") do %> -Your organisation’s IT team may be able to export CSV data for you - <%= govuk_link_to "find out more about data specification", @form.specification_path %>. This document outlines:
+Your organisation’s IT team may be able to export CSV data for you - <%= govuk_link_to "find out more about data specification", @form.specification_path, target: "_blank" %>. This document outlines:
There is no step-by-step bulk upload guide like there is with single log upload. However, you can download <%= govuk_link_to "our template", @form.template_path %>, which you can copy-paste data into from your systems column-by-column. You can also view a post-upload report showing any data errors, and our <%= govuk_link_to "data specification", @form.specification_path %> can help fix these.
+There is no step-by-step bulk upload guide like there is with single log upload. However, you can download <%= govuk_link_to "our template", @form.template_path %>, which you can copy-paste data into from your systems column-by-column. You can also view a post-upload report showing any data errors, and our <%= govuk_link_to "data specification", @form.specification_path, target: "_blank" %> can help fix these.
If you still need support mapping data in the way we need, DLUHC’s helpdesk can help. If your data is across multiple systems, or is hard to export as a single file in the correct format, you could try different exports, or copy-pasting data by hand.