diff --git a/app/components/create_log_actions_component.html.erb b/app/components/create_log_actions_component.html.erb index bd2ba1e98..26e7af6de 100644 --- a/app/components/create_log_actions_component.html.erb +++ b/app/components/create_log_actions_component.html.erb @@ -11,7 +11,7 @@ <% if FeatureToggle.create_test_logs_enabled? %>
Testing tools - These options can only be seen and used in testing environments. + These tools can only be seen and used in testing environments.
<%= govuk_button_link_to create_test_log_href, class: "govuk-button" do %> New test log diff --git a/app/services/bulk_upload/lettings/year2024/row_parser.rb b/app/services/bulk_upload/lettings/year2024/row_parser.rb index 5f253bdf9..822550887 100644 --- a/app/services/bulk_upload/lettings/year2024/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2024/row_parser.rb @@ -445,6 +445,7 @@ class BulkUpload::Lettings::Year2024::RowParser validate :validate_incomplete_soft_validations, on: :after_log validate :validate_nationality, on: :after_log validate :validate_reasonpref_reason_values, on: :after_log + validate :validate_prevten_value_when_renewal, on: :after_log validate :validate_nulls, on: :after_log @@ -674,6 +675,13 @@ private end end + def validate_prevten_value_when_renewal + return unless field_7 == 1 + return if field_100.blank? || [6, 30, 31, 32, 33, 34, 35, 36].include?(field_100) + + errors.add(:field_100, I18n.t("#{ERROR_BASE_KEY}.prevten.invalid")) + end + def duplicate_check_fields [ "startdate", diff --git a/app/services/bulk_upload/lettings/year2025/row_parser.rb b/app/services/bulk_upload/lettings/year2025/row_parser.rb index 89dfac334..4521fb369 100644 --- a/app/services/bulk_upload/lettings/year2025/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2025/row_parser.rb @@ -444,6 +444,7 @@ class BulkUpload::Lettings::Year2025::RowParser validate :validate_incomplete_soft_validations, on: :after_log validate :validate_nationality, on: :after_log validate :validate_reasonpref_reason_values, on: :after_log + validate :validate_prevten_value_when_renewal, on: :after_log validate :validate_nulls, on: :after_log @@ -673,6 +674,13 @@ private end end + def validate_prevten_value_when_renewal + return unless field_7 == 1 + return if field_100.blank? || [6, 30, 31, 32, 33, 34, 35, 38].include?(field_100) + + errors.add(:field_100, I18n.t("#{ERROR_BASE_KEY}.prevten.invalid")) + end + def duplicate_check_fields [ "startdate", diff --git a/config/locales/validations/lettings/2024/bulk_upload.en.yml b/config/locales/validations/lettings/2024/bulk_upload.en.yml index 824a8f515..d0c6269e2 100644 --- a/config/locales/validations/lettings/2024/bulk_upload.en.yml +++ b/config/locales/validations/lettings/2024/bulk_upload.en.yml @@ -62,3 +62,5 @@ en: conflict: dont_know: "You cannot select 'Don't know' if any of the other reasonable preference reasons are also selected." other: "You cannot select this reasonable preference reason as you've also selected 'Don't know' as a reason." + prevten: + invalid: "You said this letting is a renewal to the same tenant in the same property in the set up section. This means where the household was immediately before this letting must be \"Fixed-term local authority general needs tenancy\", \"Fixed-term private registered provider (PRP) general needs tenancy\", \"Lifetime local authority general needs tenancy\", \"Lifetime private registered provider (PRP) general needs tenancy\", \"Extra care housing\", \"Specialist retirement housing\", \"Sheltered housing for adults under 55 years\" or \"Other supported housing.\"" diff --git a/config/locales/validations/lettings/2025/bulk_upload.en.yml b/config/locales/validations/lettings/2025/bulk_upload.en.yml index 28866de21..0d38dc840 100644 --- a/config/locales/validations/lettings/2025/bulk_upload.en.yml +++ b/config/locales/validations/lettings/2025/bulk_upload.en.yml @@ -62,3 +62,5 @@ en: conflict: dont_know: "You cannot select 'Don't know' if any of the other reasonable preference reasons are also selected." other: "You cannot select this reasonable preference reason as you've also selected 'Don't know' as a reason." + prevten: + invalid: "You said this letting is a renewal to the same tenant in the same property in the set up section. This means where the household was immediately before this letting must be \"Fixed-term local authority general needs tenancy\", \"Fixed-term private registered provider (PRP) general needs tenancy\", \"Lifetime local authority general needs tenancy\", \"Lifetime private registered provider (PRP) general needs tenancy\", \"Extra care housing\", \"Older people's housing for tenants with low support needs\" or \"Other supported housing.\"" 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 e051cc447..1e3657dbe 100644 --- a/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb @@ -1216,6 +1216,27 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do end end + describe "#field_100" do + context "when log is a renewal and field 100 is an invalid value" do + let(:attributes) { { bulk_upload:, field_7: 1, field_100: 5 } } + + it "adds an error to field 100" do + parser.valid? + expect(parser.errors[:field_100]).to be_present + expect(parser.errors[:field_100]).to include(I18n.t("validations.lettings.2024.bulk_upload.prevten.invalid")) + end + end + + context "when log is a renewal and field 100 is a valid value" do + let(:attributes) { { bulk_upload:, field_7: 1, field_100: 32 } } + + it "does not add an error" do + parser.valid? + expect(parser.errors[:field_100]).to be_blank + end + end + end + describe "#field_112 - 115 (lettings allocation methods)" do %i[field_112 field_113 field_114 field_115].each do |field| context "when only #{field} is not given" do diff --git a/spec/services/bulk_upload/lettings/year2025/row_parser_spec.rb b/spec/services/bulk_upload/lettings/year2025/row_parser_spec.rb index 2692c05ac..902985943 100644 --- a/spec/services/bulk_upload/lettings/year2025/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/year2025/row_parser_spec.rb @@ -1053,6 +1053,27 @@ RSpec.describe BulkUpload::Lettings::Year2025::RowParser do end end + describe "#field_100" do + context "when log is a renewal and field 100 is an invalid value" do + let(:attributes) { { bulk_upload:, field_7: 1, field_100: 4 } } + + it "adds an error to field 100" do + parser.valid? + expect(parser.errors[:field_100]).to be_present + expect(parser.errors[:field_100]).to include(I18n.t("validations.lettings.2025.bulk_upload.prevten.invalid")) + end + end + + context "when log is a renewal and field 100 is a valid value" do + let(:attributes) { { bulk_upload:, field_7: 1, field_100: 38 } } + + it "does not add an error" do + parser.valid? + expect(parser.errors[:field_100]).to be_blank + end + end + end + describe "#field_112 - 115 (lettings allocation methods)" do %i[field_112 field_113 field_114 field_115].each do |field| context "when only #{field} is not given" do