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.\""