From 29a5889aa63cb76f563bac72d5ddd4a278a7832d Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Tue, 15 Oct 2024 15:41:52 +0100 Subject: [PATCH 1/5] CLDC-3653 Copy changes - sales setup validations (#2677) * Extract sales setup validations to translation file --- .../validations/sales/setup_validations.rb | 34 +++++++++---------- config/locales/en.yml | 9 ----- config/locales/validations/sales/setup.en.yml | 25 ++++++++++++++ 3 files changed, 41 insertions(+), 27 deletions(-) create mode 100644 config/locales/validations/sales/setup.en.yml diff --git a/app/models/validations/sales/setup_validations.rb b/app/models/validations/sales/setup_validations.rb index e32fa70a1..a28777a17 100644 --- a/app/models/validations/sales/setup_validations.rb +++ b/app/models/validations/sales/setup_validations.rb @@ -20,7 +20,7 @@ module Validations::Sales::SetupValidations return unless record.saledate && date_valid?("saledate", record) && !FeatureToggle.allow_future_form_use? if record.saledate > Time.zone.today + 14.days - record.errors.add :saledate, I18n.t("validations.setup.saledate.later_than_14_days_after") + record.errors.add :saledate, I18n.t("validations.sales.setup.saledate.not_within.next_two_weeks") end end @@ -28,16 +28,16 @@ module Validations::Sales::SetupValidations return unless record.saledate && date_valid?("saledate", record) if merged_owning_organisation_inactive?(record) - record.errors.add :saledate, I18n.t("validations.setup.saledate.invalid_merged_organisations_saledate", + record.errors.add :saledate, I18n.t("validations.sales.setup.saledate.invalid.merged_organisations", owning_organisation: record.owning_organisation.name, - owning_organisation_merge_date: record.owning_organisation.merge_date.to_formatted_s(:govuk_date), - owning_absorbing_organisation: record.owning_organisation.absorbing_organisation.name) + merge_date: record.owning_organisation.merge_date.to_formatted_s(:govuk_date), + absorbing_organisation: record.owning_organisation.absorbing_organisation.name) end if absorbing_owning_organisation_inactive?(record) - record.errors.add :saledate, I18n.t("validations.setup.saledate.invalid_absorbing_organisations_saledate", + record.errors.add :saledate, I18n.t("validations.sales.setup.saledate.invalid.absorbing_organisations", owning_organisation: record.owning_organisation.name, - owning_organisation_available_from: record.owning_organisation.available_from.to_formatted_s(:govuk_date)) + available_from: record.owning_organisation.available_from.to_formatted_s(:govuk_date)) end end @@ -46,14 +46,14 @@ module Validations::Sales::SetupValidations if record.owning_organisation.present? if record.owning_organisation&.merge_date.present? && record.owning_organisation.merge_date <= record.saledate - record.errors.add :owning_organisation_id, I18n.t("validations.setup.owning_organisation.inactive_merged_organisation_sales", + record.errors.add :owning_organisation_id, I18n.t("validations.sales.setup.owning_organisation.inactive.merged_organisation", owning_organisation: record.owning_organisation.name, - owning_organisation_merge_date: record.owning_organisation.merge_date.to_formatted_s(:govuk_date), - owning_absorbing_organisation: record.owning_organisation.absorbing_organisation.name) + merge_date: record.owning_organisation.merge_date.to_formatted_s(:govuk_date), + absorbing_organisation: record.owning_organisation.absorbing_organisation.name) elsif record.owning_organisation&.absorbed_organisations.present? && record.owning_organisation.available_from.present? && record.owning_organisation.available_from.to_date > record.saledate.to_date - record.errors.add :owning_organisation_id, I18n.t("validations.setup.owning_organisation.inactive_absorbing_organisation_sales", + record.errors.add :owning_organisation_id, I18n.t("validations.sales.setup.owning_organisation.inactive.absorbing_organisation", owning_organisation: record.owning_organisation.name, - owning_organisation_available_from: record.owning_organisation.available_from.to_formatted_s(:govuk_date)) + available_from: record.owning_organisation.available_from.to_formatted_s(:govuk_date)) end end end @@ -77,24 +77,22 @@ private end def saledate_validation_error_message - current_end_year_long = current_collection_end_date.strftime("#{current_collection_end_date.day.ordinalize} %B %Y") - if FormHandler.instance.sales_in_crossover_period? I18n.t( - "validations.setup.saledate.previous_and_current_collection_year", + "validations.sales.setup.saledate.must_be_within.previous_and_current_collection_year", previous_start_year_short: previous_collection_start_date.strftime("%y"), previous_end_year_short: previous_collection_end_date.strftime("%y"), previous_start_year_long: previous_collection_start_date.strftime("#{previous_collection_start_date.day.ordinalize} %B %Y"), current_end_year_short: current_collection_end_date.strftime("%y"), - current_end_year_long:, + current_end_year_long: current_collection_end_date.strftime("#{current_collection_end_date.day.ordinalize} %B %Y"), ) else I18n.t( - "validations.setup.saledate.current_collection_year", + "validations.sales.setup.saledate.must_be_within.current_collection_year", current_start_year_short: current_collection_start_date.strftime("%y"), - current_end_year_short: current_collection_end_date.strftime("%y"), current_start_year_long: current_collection_start_date.strftime("#{current_collection_start_date.day.ordinalize} %B %Y"), - current_end_year_long:, + current_end_year_short: current_collection_end_date.strftime("%y"), + current_end_year_long: current_collection_end_date.strftime("#{current_collection_end_date.day.ordinalize} %B %Y"), ) end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 7aef84fea..85be0e677 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -281,14 +281,7 @@ en: intermediate_rent_product_name: blank: "Enter name of other intermediate rent product." saledate: - later_than_14_days_after: "Sale completion date must not be later than 14 days from today’s date." - current_collection_year: - "Enter a date within the %{current_start_year_short}/%{current_end_year_short} collection year, which is between %{current_start_year_long} and %{current_end_year_long}." - previous_and_current_collection_year: - "Enter a date within the %{previous_start_year_short}/%{previous_end_year_short} or %{previous_end_year_short}/%{current_end_year_short} collection years, which is between %{previous_start_year_long} and %{current_end_year_long}." year_not_two_digits: "Sale completion year must be 2 digits." - invalid_merged_organisations_saledate: "Enter a date when the owning organisation was active. %{owning_organisation} became inactive on %{owning_organisation_merge_date} and was replaced by %{owning_absorbing_organisation}." - invalid_absorbing_organisations_saledate: "Enter a date when the owning organisation was active. %{owning_organisation} became active on %{owning_organisation_available_from}." type: percentage_bought_must_be_at_least_threshold: "The minimum increase in equity while staircasing is %{threshold}% for this shared ownership type." @@ -341,8 +334,6 @@ en: data_sharing_agreement_not_signed: "The organisation must accept the Data Sharing Agreement before it can be selected as the owning organisation." inactive_merged_organisation: "The owning organisation must be active on the tenancy start date. %{owning_organisation} became inactive on %{owning_organisation_merge_date} and was replaced by %{owning_absorbing_organisation}." inactive_absorbing_organisation: "The owning organisation must be active on the tenancy start date. %{owning_organisation} became active on %{owning_organisation_available_from}." - inactive_merged_organisation_sales: "The owning organisation must be active on the sale completion date. %{owning_organisation} became inactive on %{owning_organisation_merge_date} and was replaced by %{owning_absorbing_organisation}." - inactive_absorbing_organisation_sales: "The owning organisation must be active on the sale completion date. %{owning_organisation} became active on %{owning_organisation_available_from}." managing_organisation: invalid: "Please select the owning organisation or managing organisation that you belong to." data_sharing_agreement_not_signed: "The organisation must accept the Data Sharing Agreement before it can be selected as the managing organisation." diff --git a/config/locales/validations/sales/setup.en.yml b/config/locales/validations/sales/setup.en.yml new file mode 100644 index 000000000..2741464b0 --- /dev/null +++ b/config/locales/validations/sales/setup.en.yml @@ -0,0 +1,25 @@ +en: + validations: + sales: + setup: + saledate: + not_within: + next_two_weeks: "Sale completion date must not be later than 14 days from today’s date." + must_be_within: + current_collection_year: + "Enter a date within the %{current_start_year_short}/%{current_end_year_short} collection year, which is between %{current_start_year_long} and %{current_end_year_long}." + previous_and_current_collection_year: + "Enter a date within the %{previous_start_year_short}/%{previous_end_year_short} or %{previous_end_year_short}/%{current_end_year_short} collection years, which is between %{previous_start_year_long} and %{current_end_year_long}." + invalid: + merged_organisations: + "Enter a date when the owning organisation was active. %{owning_organisation} became inactive on %{merge_date} and was replaced by %{absorbing_organisation}." + absorbing_organisations: + "Enter a date when the owning organisation was active. %{owning_organisation} became active on %{available_from}." + + owning_organisation: + inactive: + merged_organisation: + "The owning organisation must be active on the sale completion date. %{owning_organisation} became inactive on %{merge_date} and was replaced by %{absorbing_organisation}." + absorbing_organisation: + "The owning organisation must be active on the sale completion date. %{owning_organisation} became active on %{available_from}." + From 2475215e13374ffd4f17c64e614717e69d3366e0 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Wed, 16 Oct 2024 10:47:48 +0100 Subject: [PATCH 2/5] Update rails version (#2706) --- Gemfile | 2 +- Gemfile.lock | 128 +++++++++++++++++++++++++-------------------------- 2 files changed, 65 insertions(+), 65 deletions(-) diff --git a/Gemfile b/Gemfile index a5c7dd01f..baaddab2e 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby "3.1.4" # Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main' -gem "rails", "~> 7.0.8.3" +gem "rails", "~> 7.0.8.5" # Use postgresql as the database for Active Record gem "pg", "~> 1.1" # Use Puma as the app server diff --git a/Gemfile.lock b/Gemfile.lock index 43d9374d1..cc9e57d24 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,71 +1,71 @@ GEM remote: https://rubygems.org/ specs: - actioncable (7.0.8.4) - actionpack (= 7.0.8.4) - activesupport (= 7.0.8.4) + actioncable (7.0.8.5) + actionpack (= 7.0.8.5) + activesupport (= 7.0.8.5) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.8.4) - actionpack (= 7.0.8.4) - activejob (= 7.0.8.4) - activerecord (= 7.0.8.4) - activestorage (= 7.0.8.4) - activesupport (= 7.0.8.4) + actionmailbox (7.0.8.5) + actionpack (= 7.0.8.5) + activejob (= 7.0.8.5) + activerecord (= 7.0.8.5) + activestorage (= 7.0.8.5) + activesupport (= 7.0.8.5) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.8.4) - actionpack (= 7.0.8.4) - actionview (= 7.0.8.4) - activejob (= 7.0.8.4) - activesupport (= 7.0.8.4) + actionmailer (7.0.8.5) + actionpack (= 7.0.8.5) + actionview (= 7.0.8.5) + activejob (= 7.0.8.5) + activesupport (= 7.0.8.5) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.0) - actionpack (7.0.8.4) - actionview (= 7.0.8.4) - activesupport (= 7.0.8.4) + actionpack (7.0.8.5) + actionview (= 7.0.8.5) + activesupport (= 7.0.8.5) rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.8.4) - actionpack (= 7.0.8.4) - activerecord (= 7.0.8.4) - activestorage (= 7.0.8.4) - activesupport (= 7.0.8.4) + actiontext (7.0.8.5) + actionpack (= 7.0.8.5) + activerecord (= 7.0.8.5) + activestorage (= 7.0.8.5) + activesupport (= 7.0.8.5) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.8.4) - activesupport (= 7.0.8.4) + actionview (7.0.8.5) + activesupport (= 7.0.8.5) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.8.4) - activesupport (= 7.0.8.4) + activejob (7.0.8.5) + activesupport (= 7.0.8.5) globalid (>= 0.3.6) - activemodel (7.0.8.4) - activesupport (= 7.0.8.4) + activemodel (7.0.8.5) + activesupport (= 7.0.8.5) activemodel-serializers-xml (1.0.2) activemodel (> 5.x) activesupport (> 5.x) builder (~> 3.1) - activerecord (7.0.8.4) - activemodel (= 7.0.8.4) - activesupport (= 7.0.8.4) - activestorage (7.0.8.4) - actionpack (= 7.0.8.4) - activejob (= 7.0.8.4) - activerecord (= 7.0.8.4) - activesupport (= 7.0.8.4) + activerecord (7.0.8.5) + activemodel (= 7.0.8.5) + activesupport (= 7.0.8.5) + activestorage (7.0.8.5) + actionpack (= 7.0.8.5) + activejob (= 7.0.8.5) + activerecord (= 7.0.8.5) + activesupport (= 7.0.8.5) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (7.0.8.4) + activesupport (7.0.8.5) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -218,7 +218,7 @@ GEM hashdiff (1.1.0) html-attributes-utils (1.0.2) activesupport (>= 6.1.4.4) - i18n (1.14.5) + i18n (1.14.6) concurrent-ruby (~> 1.0) ice_nine (0.11.2) iniparse (1.5.0) @@ -258,13 +258,13 @@ GEM matrix (0.4.2) method_source (1.1.0) mini_mime (1.1.5) - minitest (5.24.1) + minitest (5.25.1) msgpack (1.7.2) multipart-post (2.4.1) nested_form (0.3.2) net-http (0.4.1) uri - net-imap (0.4.14) + net-imap (0.4.17) date net-protocol net-pop (0.1.2) @@ -274,11 +274,11 @@ GEM net-smtp (0.5.0) net-protocol nio4r (2.7.3) - nokogiri (1.16.6-arm64-darwin) + nokogiri (1.16.7-arm64-darwin) racc (~> 1.4) - nokogiri (1.16.6-x86_64-darwin) + nokogiri (1.16.7-x86_64-darwin) racc (~> 1.4) - nokogiri (1.16.6-x86_64-linux) + nokogiri (1.16.7-x86_64-linux) racc (~> 1.4) notifications-ruby-client (6.0.0) jwt (>= 1.5, < 3) @@ -319,28 +319,28 @@ GEM pundit (2.3.1) activesupport (>= 3.0.0) raabro (1.4.0) - racc (1.8.0) - rack (2.2.9) + racc (1.8.1) + rack (2.2.10) rack-attack (6.7.0) rack (>= 1.0, < 4) rack-mini-profiler (2.3.4) rack (>= 1.2.0) rack-test (2.1.0) rack (>= 1.3) - rails (7.0.8.4) - actioncable (= 7.0.8.4) - actionmailbox (= 7.0.8.4) - actionmailer (= 7.0.8.4) - actionpack (= 7.0.8.4) - actiontext (= 7.0.8.4) - actionview (= 7.0.8.4) - activejob (= 7.0.8.4) - activemodel (= 7.0.8.4) - activerecord (= 7.0.8.4) - activestorage (= 7.0.8.4) - activesupport (= 7.0.8.4) + rails (7.0.8.5) + actioncable (= 7.0.8.5) + actionmailbox (= 7.0.8.5) + actionmailer (= 7.0.8.5) + actionpack (= 7.0.8.5) + actiontext (= 7.0.8.5) + actionview (= 7.0.8.5) + activejob (= 7.0.8.5) + activemodel (= 7.0.8.5) + activerecord (= 7.0.8.5) + activestorage (= 7.0.8.5) + activesupport (= 7.0.8.5) bundler (>= 1.15.0) - railties (= 7.0.8.4) + railties (= 7.0.8.5) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -354,9 +354,9 @@ GEM nested_form (~> 0.3) rails (>= 6.0, < 8) turbo-rails (~> 1.0) - railties (7.0.8.4) - actionpack (= 7.0.8.4) - activesupport (= 7.0.8.4) + railties (7.0.8.5) + actionpack (= 7.0.8.5) + activesupport (= 7.0.8.5) method_source rake (>= 12.2) thor (~> 1.0) @@ -464,7 +464,7 @@ GEM stimulus-rails (1.3.3) railties (>= 6.0.0) strscan (3.1.0) - thor (1.3.1) + thor (1.3.2) thread_safe (0.3.6) timecop (0.9.8) timeout (0.4.1) @@ -504,7 +504,7 @@ GEM websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.16) + zeitwerk (2.6.18) PLATFORMS arm64-darwin-21 @@ -555,7 +555,7 @@ DEPENDENCIES rack (>= 2.2.6.3) rack-attack rack-mini-profiler (~> 2.0) - rails (~> 7.0.8.3) + rails (~> 7.0.8.5) rails_admin (~> 3.1) redcarpet (~> 3.6) redis (~> 4.8) From 2e6e56720d3d9299c0d246d37bd43ffbc8ae51a7 Mon Sep 17 00:00:00 2001 From: Rachael Booth Date: Thu, 17 Oct 2024 13:14:03 +0100 Subject: [PATCH 3/5] CLDC-3257: Default to current collection year for BU guidance pages (#2695) * CLDC-3257: Default to current collection year for BU guidance pages * Ignore rubocop RSpec/AnyInstance when necessary --- .../forms/bulk_upload_lettings/guidance.rb | 7 +++++++ app/models/forms/bulk_upload_sales/guidance.rb | 7 +++++++ .../forms/bulk_upload_lettings/guidance_spec.rb | 17 +++++++++++++++++ .../forms/bulk_upload_sales/guidance_spec.rb | 17 +++++++++++++++++ 4 files changed, 48 insertions(+) diff --git a/app/models/forms/bulk_upload_lettings/guidance.rb b/app/models/forms/bulk_upload_lettings/guidance.rb index dc0de3271..b2fcf947e 100644 --- a/app/models/forms/bulk_upload_lettings/guidance.rb +++ b/app/models/forms/bulk_upload_lettings/guidance.rb @@ -4,11 +4,18 @@ module Forms include ActiveModel::Model include ActiveModel::Attributes include Rails.application.routes.url_helpers + include CollectionTimeHelper attribute :year, :integer attribute :referrer attribute :organisation_id, :integer + def initialize(params) + super(params) + + self.year = current_collection_start_year if year.nil? + end + def view_path "bulk_upload_shared/guidance" end diff --git a/app/models/forms/bulk_upload_sales/guidance.rb b/app/models/forms/bulk_upload_sales/guidance.rb index be61ef650..80cfc5143 100644 --- a/app/models/forms/bulk_upload_sales/guidance.rb +++ b/app/models/forms/bulk_upload_sales/guidance.rb @@ -4,11 +4,18 @@ module Forms include ActiveModel::Model include ActiveModel::Attributes include Rails.application.routes.url_helpers + include CollectionTimeHelper attribute :year, :integer attribute :referrer attribute :organisation_id, :integer + def initialize(params) + super(params) + + self.year = current_collection_start_year if year.nil? + end + def view_path "bulk_upload_shared/guidance" end diff --git a/spec/models/forms/bulk_upload_lettings/guidance_spec.rb b/spec/models/forms/bulk_upload_lettings/guidance_spec.rb index 271ff8b27..41e74c50c 100644 --- a/spec/models/forms/bulk_upload_lettings/guidance_spec.rb +++ b/spec/models/forms/bulk_upload_lettings/guidance_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Forms::BulkUploadLettings::Guidance do subject(:bu_guidance) { described_class.new(year:, referrer:) } let(:year) { 2024 } + let(:referrer) { nil } describe "#back_path" do context "when referrer is prepare-your-file" do @@ -40,4 +41,20 @@ RSpec.describe Forms::BulkUploadLettings::Guidance do end end end + + describe "year" do + context "when year is not provided" do + let(:year) { nil } + + before do + # rubocop:disable RSpec/AnyInstance + allow_any_instance_of(CollectionTimeHelper).to receive(:current_collection_start_year).and_return(2030) + # rubocop:enable RSpec/AnyInstance + end + + it "is set to the current collection start year" do + expect(bu_guidance.year).to eq(2030) + end + end + end end diff --git a/spec/models/forms/bulk_upload_sales/guidance_spec.rb b/spec/models/forms/bulk_upload_sales/guidance_spec.rb index 6eacf6d0c..f9c986cb2 100644 --- a/spec/models/forms/bulk_upload_sales/guidance_spec.rb +++ b/spec/models/forms/bulk_upload_sales/guidance_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Forms::BulkUploadSales::Guidance do subject(:bu_guidance) { described_class.new(year:, referrer:) } let(:year) { 2024 } + let(:referrer) { nil } describe "#back_path" do context "when referrer is prepare-your-file" do @@ -40,4 +41,20 @@ RSpec.describe Forms::BulkUploadSales::Guidance do end end end + + describe "year" do + context "when year is not provided" do + let(:year) { nil } + + before do + # rubocop:disable RSpec/AnyInstance + allow_any_instance_of(CollectionTimeHelper).to receive(:current_collection_start_year).and_return(2030) + # rubocop:enable RSpec/AnyInstance + end + + it "is set to the current collection start year" do + expect(bu_guidance.year).to eq(2030) + end + end + end end From 2246b8cce556ac21f3d7b7233da1990edcb07415 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Fri, 18 Oct 2024 10:50:41 +0100 Subject: [PATCH 4/5] Update email allowlist (#2710) --- config/credentials.yml.enc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc index 9cd4bba71..8e0af1b34 100644 --- a/config/credentials.yml.enc +++ b/config/credentials.yml.enc @@ -1 +1 @@ -QGn9IiI91BaO4IGAtfy92FrNP46X9T2jJErRv+o/PRG9LrimEGeuOE+FwhArKZQ5cTipaDqo8u9Ajv45Kitv3c0GynOOvz0r3OjPRHO/p4hW8BFWQDv581cWWPsyZT2JO51zZ5LnwNFvWrjEB2q49YESgtfADPkJWmtx/By5Cg2/PVIRxvhGKOnheme5cih050wqg/43BdiF0PD9FDTZXJDLJg/QQ8nQYkvQe2jN4nM4mTVpkQkmzDKgGknmUWFfW3qWFzlsdMkdkPdeP9wLnJVbFTeyaaJT3wv6l19d2rKqo8iVvacdaQjRev+LVXqOsNAjVHwcPNQVq9s8pxG24HLk3aQ14Eyjf6tHAuZAV4jLnNqQtBQ0AIldWeOl6SKmlTom1P1tcLp9KpajEADplmWSwUktIGmaakFjk/ApYaUBiYTku2iLHMrT/xSc3jPj5W/ZggeJ0Ij6nuGYE1cmBxWGxda9PzOrDP8coEK9vPHiNeDDM1RoukVmf8gwDmshILi5EwIAsO2gJXM1wtPYMu41+H4/y3c0GIwgfv9QP11q+nqhG1MMcOrAUKGhypAS+M+uLwfGQudfQDKP9Zv3VCnOk3mkKlpIzMMD4UdJxQeE/8sfwIsEhWggEo3oa93ptbRdvJ7YYcVvmMmkVBxk0KWFprl4i/BkFHLWrKNl5LBOGA==--ziMOTnYBB5TDyXYU--3FJMs8e6R8lheqcqB8p8uQ== \ No newline at end of file +M2+y4Ll2PwjN9IiCvliQ5Ytiy+/9bSepV2siwg6hvttLc63q0W4hbNobseAZAYqWLajrnJ7lm9AfT8CuBreHtwFsdQ/HV8NPrvzLB/P+X15MKLtb1Sg7bNjtW24uoE3zYrWILecpNygLc1ZXxgjka3yjc7XdV7MA3NR2/2zvkGREJvjbJlEn7036CWnNfN7PD0S57O1z+LqilrrhecWAmGeJRU2Ve2UZNoUExz865ovpk1enGReiU5+0jlNTIK3SCc75HH3grET6HkAbzsZvC763OkEkEQGVJeaytQ2cGkyk8t98nqGRq6fK9uAwKyGh6KwHH8BT++OOF3Re4Uf2A9boFdJ5AOwuV7ZK+OonPu7x/bThRmb+Sl057+L1pSrpILvFUzA3K8k34G9ZMHMLIX0/rHLEav+ToFFwBxARleiUdSgEv9txP0wU+7fPyuJlHJb7CIrC9dRQIeyM9RAIvxZYhP2KrTqm9eEyCJNttAWpYnXfnoxgbQEoQw94KOal/i26bK09TZNwv10oTYZqxB6PqfsQQ9wVIesO9v6uK3HQ2jVXeCb4caj1HWFOjFLhcDoAEFe6DUmjSdxf2tDQ90pwQKQ7IWi9jPOOQSVQ7VoCc1uD3cImDjsY/04sGbCdSpGt53E3Rn9UCGHdVhzzOXRhU4wQLBFEFin79KJ7q0m71jesGEpVNKI2s8aC+Ux8btSBu92JLS4b9zZHT13D729CW2T8--EZ5GxuRKaFfGdzCE--OZ1EwaObJ4ZF59N0JcJ7Dg== \ No newline at end of file From 2974bcddd7fd7f634a2c99fe3d63512752fd3d74 Mon Sep 17 00:00:00 2001 From: Rachael Booth Date: Mon, 21 Oct 2024 10:58:53 +0100 Subject: [PATCH 5/5] CLDC-3330: Use partial postcodes in bulk upload (#2692) * CLDC-3330: Use partial postcodes in bulk upload * Adjust key address fields provided validations * Use join to only insert space when both parts of postcode are provided --- app/services/bulk_upload/lettings/year2024/row_parser.rb | 4 ++-- app/services/bulk_upload/sales/year2024/row_parser.rb | 4 ++-- .../bulk_upload/lettings/year2024/row_parser_spec.rb | 8 ++++++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/services/bulk_upload/lettings/year2024/row_parser.rb b/app/services/bulk_upload/lettings/year2024/row_parser.rb index a40094e26..a7eb96c61 100644 --- a/app/services/bulk_upload/lettings/year2024/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2024/row_parser.rb @@ -618,7 +618,7 @@ private end def key_address_fields_provided? - field_17.present? && field_19.present? && field_21.present? && field_22.present? + field_17.present? && field_19.present? && postcode_full.present? end def validate_address_fields @@ -1355,7 +1355,7 @@ private end def postcode_full - "#{field_21} #{field_22}" if field_21 && field_22 + [field_21, field_22].compact_blank.join(" ") if field_21 || field_22 end def owning_organisation diff --git a/app/services/bulk_upload/sales/year2024/row_parser.rb b/app/services/bulk_upload/sales/year2024/row_parser.rb index 44e81786b..fbc99ba02 100644 --- a/app/services/bulk_upload/sales/year2024/row_parser.rb +++ b/app/services/bulk_upload/sales/year2024/row_parser.rb @@ -616,7 +616,7 @@ private end def key_address_fields_provided? - field_23.present? && field_25.present? && field_27.present? && field_28.present? + field_23.present? && field_25.present? && postcode_full.present? end def validate_address_fields @@ -1074,7 +1074,7 @@ private end def postcode_full - "#{field_27} #{field_28}" if field_27 && field_28 + [field_27, field_28].compact_blank.join(" ") if field_27 || field_28 end def ppostcode_full diff --git a/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb b/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb index 596712162..2e4c82635 100644 --- a/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb @@ -2718,6 +2718,14 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do it "strips whitespace" do expect(parser.log.postcode_full).to eql("EC1N 2TD") end + + context "when a partial postcode is provided" do + let(:attributes) { { bulk_upload:, field_4: 1, field_21: "EC1N", field_22: "" } } + + it "is set to the partial value" do + expect(parser.log.postcode_full).to eql("EC1N") + end + end end describe "#la" do