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) 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 bdb25c243..a323a3664 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}." +