From eb7d73718b6084450bfe1567c39ace2c42f2624f Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire <94526761+natdeanlewissoftwire@users.noreply.github.com> Date: Mon, 3 Apr 2023 09:28:59 +0100 Subject: [PATCH] CLDC-1825 prepare bulk upload guidance (#1342) * feat: add inset text and old template (actual link to come) * feat: add old spec work from CLDC-1788 to avoid future conflicts, typo fix * feat: add new files and update copy * feat: add 23/24 spec files and update copy * feat: specify rack version * feat: specify rack version * refactor: lint * refactor: lint * feat: fix failing tests * db: update * refactor: typos * feat: update designs and add inset text * feat: pass year to guidance page * feat: merge with new behaviour on main --- .../forms/bulk_upload_lettings/guidance.rb | 4 ++++ .../bulk_upload_lettings/prepare_your_file.rb | 10 ++++++++++ .../forms/bulk_upload_sales/guidance.rb | 4 ++++ .../bulk_upload_sales/prepare_your_file.rb | 4 ++++ app/models/location.rb | 2 +- app/models/organisation.rb | 2 +- app/models/scheme.rb | 2 +- .../lettings/year2022/row_parser.rb | 8 ++++---- .../lettings/year2023/row_parser.rb | 8 ++++---- .../forms/prepare_your_file.html.erb | 20 ++++++++++--------- .../forms/prepare_your_file.html.erb | 17 ++++++++-------- 11 files changed, 53 insertions(+), 28 deletions(-) diff --git a/app/models/forms/bulk_upload_lettings/guidance.rb b/app/models/forms/bulk_upload_lettings/guidance.rb index 2610ed62d..55db10718 100644 --- a/app/models/forms/bulk_upload_lettings/guidance.rb +++ b/app/models/forms/bulk_upload_lettings/guidance.rb @@ -15,6 +15,10 @@ module Forms bulk_upload_lettings_log_path(id: "prepare-your-file", form: { year: }) end + def old_template_path + Forms::BulkUploadLettings::PrepareYourFile.new.old_template_path + end + def template_path Forms::BulkUploadLettings::PrepareYourFile.new(year:).template_path 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 6db68e49d..c30cf88ad 100644 --- a/app/models/forms/bulk_upload_lettings/prepare_your_file.rb +++ b/app/models/forms/bulk_upload_lettings/prepare_your_file.rb @@ -25,6 +25,10 @@ module Forms bulk_upload_lettings_log_path(id: page_id, form: { year:, needstype: }) end + def old_template_path + "/files/bulk-upload-lettings-template-2022-23.xlsx" + end + def template_path case year when 2022 @@ -47,6 +51,12 @@ module Forms "#{year}/#{year + 1 - 2000}" end + def inset_text + if year == 2022 + '
For 2022/23 data, you cannot have a CSV file with both general needs logs and supported housing logs. These must be in separate files.
'.html_safe + end + end + def save! true end diff --git a/app/models/forms/bulk_upload_sales/guidance.rb b/app/models/forms/bulk_upload_sales/guidance.rb index 869ce8be2..c9869ee14 100644 --- a/app/models/forms/bulk_upload_sales/guidance.rb +++ b/app/models/forms/bulk_upload_sales/guidance.rb @@ -15,6 +15,10 @@ module Forms bulk_upload_sales_log_path(id: "prepare-your-file", form: { year: }) end + def old_template_path + Forms::BulkUploadLettings::PrepareYourFile.new.old_template_path + end + def template_path Forms::BulkUploadSales::PrepareYourFile.new(year:).template_path 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 cdf2cf455..710cdbef3 100644 --- a/app/models/forms/bulk_upload_sales/prepare_your_file.rb +++ b/app/models/forms/bulk_upload_sales/prepare_your_file.rb @@ -23,6 +23,10 @@ module Forms bulk_upload_sales_log_path(id: "upload-your-file", form: { year: }) end + def old_template_path + "/files/bulk-upload-sales-template-2022-23.xlsx" + end + def template_path case year when 2022 diff --git a/app/models/location.rb b/app/models/location.rb index 6050a05cf..b463374df 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -53,7 +53,7 @@ class Location < ApplicationRecord enum type_of_unit: TYPE_OF_UNIT - def self.find_by_id_on_mulitple_fields(id) + def self.find_by_id_on_multiple_fields(id) return if id.nil? where(id:).or(where(old_visible_id: id)).first diff --git a/app/models/organisation.rb b/app/models/organisation.rb index 32d3540d1..279d60f49 100644 --- a/app/models/organisation.rb +++ b/app/models/organisation.rb @@ -48,7 +48,7 @@ class Organisation < ApplicationRecord validates :name, presence: { message: I18n.t("validations.organisation.name_missing") } validates :provider_type, presence: { message: I18n.t("validations.organisation.provider_type_missing") } - def self.find_by_id_on_mulitple_fields(id) + def self.find_by_id_on_multiple_fields(id) return if id.nil? if id.start_with?("ORG") diff --git a/app/models/scheme.rb b/app/models/scheme.rb index 1ab65ea32..740729749 100644 --- a/app/models/scheme.rb +++ b/app/models/scheme.rb @@ -110,7 +110,7 @@ class Scheme < ApplicationRecord enum arrangement_type: ARRANGEMENT_TYPE, _suffix: true - def self.find_by_id_on_mulitple_fields(id) + def self.find_by_id_on_multiple_fields(id) return if id.nil? if id.start_with?("S") diff --git a/app/services/bulk_upload/lettings/year2022/row_parser.rb b/app/services/bulk_upload/lettings/year2022/row_parser.rb index eb10bd3dc..289dea7ca 100644 --- a/app/services/bulk_upload/lettings/year2022/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2022/row_parser.rb @@ -419,7 +419,7 @@ private def location return if scheme.nil? - @location ||= scheme.locations.find_by_id_on_mulitple_fields(field_5) + @location ||= scheme.locations.find_by_id_on_multiple_fields(field_5) end def validate_location_exists @@ -860,7 +860,7 @@ private end def owning_organisation - Organisation.find_by_id_on_mulitple_fields(field_111) + Organisation.find_by_id_on_multiple_fields(field_111) end def owning_organisation_id @@ -868,7 +868,7 @@ private end def managing_organisation - Organisation.find_by_id_on_mulitple_fields(field_113) + Organisation.find_by_id_on_multiple_fields(field_113) end def managing_organisation_id @@ -1292,6 +1292,6 @@ private end def scheme - @scheme ||= Scheme.find_by_id_on_mulitple_fields(field_4) + @scheme ||= Scheme.find_by_id_on_multiple_fields(field_4) end end diff --git a/app/services/bulk_upload/lettings/year2023/row_parser.rb b/app/services/bulk_upload/lettings/year2023/row_parser.rb index 6f3047def..7374e6208 100644 --- a/app/services/bulk_upload/lettings/year2023/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2023/row_parser.rb @@ -1011,7 +1011,7 @@ private end def owning_organisation - Organisation.find_by_id_on_mulitple_fields(field_1) + Organisation.find_by_id_on_multiple_fields(field_1) end def owning_organisation_id @@ -1019,7 +1019,7 @@ private end def managing_organisation - Organisation.find_by_id_on_mulitple_fields(field_2) + Organisation.find_by_id_on_multiple_fields(field_2) end def managing_organisation_id @@ -1044,13 +1044,13 @@ private end def scheme - @scheme ||= Scheme.find_by_id_on_mulitple_fields(field_16) + @scheme ||= Scheme.find_by_id_on_multiple_fields(field_16) end def location return if scheme.nil? - @location ||= scheme.locations.find_by_id_on_mulitple_fields(field_17) + @location ||= scheme.locations.find_by_id_on_multiple_fields(field_17) end def renttype 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 529077e07..56b8dff90 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 @@ -10,22 +10,24 @@