diff --git a/app/models/form/lettings/pages/new_build_handover_date.rb b/app/models/form/lettings/pages/new_build_handover_date.rb
deleted file mode 100644
index e7cb2e5d9..000000000
--- a/app/models/form/lettings/pages/new_build_handover_date.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-class Form::Lettings::Pages::NewBuildHandoverDate < ::Form::Page
- def initialize(id, hsh, subsection)
- super
- @id = "new_build_handover_date"
- @depends_on = [{ "is_renewal?" => false, "has_first_let_vacancy_reason?" => true }]
- end
-
- def questions
- @questions ||= [Form::Lettings::Questions::VoiddateNewBuild.new(nil, nil, self)]
- end
-end
diff --git a/app/models/form/lettings/pages/void_or_renewal_date.rb b/app/models/form/lettings/pages/void_date.rb
similarity index 52%
rename from app/models/form/lettings/pages/void_or_renewal_date.rb
rename to app/models/form/lettings/pages/void_date.rb
index 0905f1058..43d066a70 100644
--- a/app/models/form/lettings/pages/void_or_renewal_date.rb
+++ b/app/models/form/lettings/pages/void_date.rb
@@ -1,8 +1,9 @@
-class Form::Lettings::Pages::VoidOrRenewalDate < ::Form::Page
+class Form::Lettings::Pages::VoidDate < ::Form::Page
def initialize(id, hsh, subsection)
super
- @id = "void_or_renewal_date"
- @depends_on = [{ "is_renewal?" => false, "vacancy_reason_not_renewal_or_first_let?" => true }]
+ @id = "void_date"
+ @depends_on = [{ "is_renewal?" => false, "vacancy_reason_not_renewal_or_first_let?" => true },
+ { "is_renewal?" => false, "has_first_let_vacancy_reason?" => true }]
end
def questions
diff --git a/app/models/form/lettings/questions/voiddate.rb b/app/models/form/lettings/questions/voiddate.rb
index a91ac6ddb..0431b9adb 100644
--- a/app/models/form/lettings/questions/voiddate.rb
+++ b/app/models/form/lettings/questions/voiddate.rb
@@ -2,10 +2,12 @@ class Form::Lettings::Questions::Voiddate < ::Form::Question
def initialize(id, hsh, page)
super
@id = "voiddate"
- @check_answer_label = "Void or renewal date"
- @header = "What is the void or renewal date?"
+ @check_answer_label = "Void date"
+ @header = "What is the void date?"
@type = "date"
@check_answers_card_number = 0
@question_number = 23
+ @guidance_partial = "void_date"
+ @guidance_position = GuidancePosition::BOTTOM
end
end
diff --git a/app/models/form/lettings/questions/voiddate_new_build.rb b/app/models/form/lettings/questions/voiddate_new_build.rb
deleted file mode 100644
index dcf1326b0..000000000
--- a/app/models/form/lettings/questions/voiddate_new_build.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-class Form::Lettings::Questions::VoiddateNewBuild < ::Form::Question
- def initialize(id, hsh, page)
- super
- @id = "voiddate"
- @check_answer_label = "New-build handover date"
- @header = "What is the new-build handover date?"
- @type = "date"
- @check_answers_card_number = 0
- @hint_text = ""
- @question_number = 23
- end
-end
diff --git a/app/models/form/lettings/subsections/property_information.rb b/app/models/form/lettings/subsections/property_information.rb
index c20c2b27c..2e21b8c5a 100644
--- a/app/models/form/lettings/subsections/property_information.rb
+++ b/app/models/form/lettings/subsections/property_information.rb
@@ -20,9 +20,8 @@ class Form::Lettings::Subsections::PropertyInformation < ::Form::Subsection
Form::Lettings::Pages::PropertyBuildingType.new(nil, nil, self),
Form::Lettings::Pages::PropertyWheelchairAccessible.new(nil, nil, self),
Form::Lettings::Pages::PropertyNumberOfBedrooms.new(nil, nil, self),
- Form::Lettings::Pages::VoidOrRenewalDate.new(nil, nil, self),
+ Form::Lettings::Pages::VoidDate.new(nil, nil, self),
Form::Lettings::Pages::VoidDateValueCheck.new(nil, nil, self),
- Form::Lettings::Pages::NewBuildHandoverDate.new(nil, nil, self),
Form::Lettings::Pages::PropertyMajorRepairs.new(nil, nil, self),
Form::Lettings::Pages::PropertyMajorRepairsValueCheck.new(nil, nil, self),
].flatten.compact
diff --git a/app/models/form/question.rb b/app/models/form/question.rb
index de77674e6..aecb20ac6 100644
--- a/app/models/form/question.rb
+++ b/app/models/form/question.rb
@@ -14,11 +14,11 @@ class Form::Question
def initialize(id, hsh, page)
@id = id
@page = page
- @guidance_position = GuidancePosition::TOP
if hsh
@check_answer_label = hsh["check_answer_label"]
@header = hsh["header"]
@guidance_partial = hsh["guidance_partial"]
+ @guidance_position = hsh["guidance_position"] || GuidancePosition::TOP
@hint_text = hsh["hint_text"]
@type = hsh["type"]
@min = hsh["min"]
diff --git a/app/models/validations/date_validations.rb b/app/models/validations/date_validations.rb
index ae5d7ee19..518f0361f 100644
--- a/app/models/validations/date_validations.rb
+++ b/app/models/validations/date_validations.rb
@@ -27,6 +27,7 @@ module Validations::DateValidations
if record["voiddate"].present? && record["mrcdate"].present? && record["mrcdate"].to_date < record["voiddate"].to_date
record.errors.add :voiddate, I18n.t("validations.property.void_date.after_mrcdate")
+ record.errors.add :mrcdate, I18n.t("validations.property.mrcdate.before_void_date")
end
end
@@ -45,6 +46,14 @@ module Validations::DateValidations
record.errors.add :startdate, I18n.t("validations.setup.startdate.after_major_repair_date")
end
+ if record["voiddate"].present? && record["startdate"].to_date - record["voiddate"].to_date > 3650
+ record.errors.add :startdate, I18n.t("validations.setup.startdate.ten_years_after_void_date")
+ end
+
+ if record["mrcdate"].present? && record["startdate"].to_date - record["mrcdate"].to_date > 3650
+ record.errors.add :startdate, I18n.t("validations.setup.startdate.ten_years_after_mrc_date")
+ end
+
location_during_startdate_validation(record, :startdate)
scheme_during_startdate_validation(record, :startdate)
end
diff --git a/app/services/bulk_upload/lettings/year2022/row_parser.rb b/app/services/bulk_upload/lettings/year2022/row_parser.rb
index 432897d0b..0726c9a07 100644
--- a/app/services/bulk_upload/lettings/year2022/row_parser.rb
+++ b/app/services/bulk_upload/lettings/year2022/row_parser.rb
@@ -91,9 +91,9 @@ class BulkUpload::Lettings::Year2022::RowParser
field_86: "Does the household pay rent or other charges for the accommodation?",
field_87: "After the household has received any housing-related benefits, will they still need to pay basic rent and other charges?",
field_88: "What do you expect the outstanding amount to be?",
- field_89: "What is the void or renewal date?",
- field_90: "What is the void or renewal date?",
- field_91: "What is the void or renewal date?",
+ field_89: "What is the void date?",
+ field_90: "What is the void date?",
+ field_91: "What is the void date?",
field_92: "What date were major repairs completed on?",
field_93: "What date were major repairs completed on?",
field_94: "What date were major repairs completed on?",
diff --git a/app/views/form/guidance/_void_date.html.erb b/app/views/form/guidance/_void_date.html.erb
new file mode 100644
index 000000000..69ea9384f
--- /dev/null
+++ b/app/views/form/guidance/_void_date.html.erb
@@ -0,0 +1,9 @@
+<%= govuk_details(summary_text: "What is a void date?") do %>
+
Date the property was (legally or contractually) available to let, or for:
+
+ - re-lets: the day after the previous tenant's contract ended
+ - new builds: the day the landlord legally first owned the property (‘completion date’)
+ - new conversions or acquisitions: completion date, or the day after rehabilitation work ended
+ - new leases: the day the landlord got contractual property rights and could let it out to tenants
+
+<% end %>
diff --git a/config/forms/2022_2023.json b/config/forms/2022_2023.json
index 3162a2b36..8e1eca338 100644
--- a/config/forms/2022_2023.json
+++ b/config/forms/2022_2023.json
@@ -714,15 +714,17 @@
}
]
},
- "void_or_renewal_date": {
+ "void_date": {
"header": "",
"description": "",
"questions": {
"voiddate": {
- "check_answer_label": "Void or renewal date",
- "header": "What is the void or renewal date?",
+ "check_answer_label": "Void date",
+ "header": "What is the void date?",
"hint_text": "For example, 27 3 2021.",
- "type": "date"
+ "type": "date",
+ "guidance_partial": "void_date",
+ "guidance_position": 2
}
},
"depends_on": [
@@ -765,6 +767,18 @@
{
"renewal": 0,
"rsnvac": 19
+ },
+ {
+ "renewal": 0,
+ "rsnvac": 15
+ },
+ {
+ "renewal": 0,
+ "rsnvac": 16
+ },
+ {
+ "renewal": 0,
+ "rsnvac": 17
}
]
},
@@ -804,32 +818,6 @@
}
}
},
- "new_build_handover_date": {
- "header": "",
- "description": "",
- "questions": {
- "voiddate": {
- "check_answer_label": "New-build handover date",
- "header": "What is the new-build handover date?",
- "hint_text": "",
- "type": "date"
- }
- },
- "depends_on": [
- {
- "renewal": 0,
- "rsnvac": 15
- },
- {
- "renewal": 0,
- "rsnvac": 16
- },
- {
- "renewal": 0,
- "rsnvac": 17
- }
- ]
- },
"property_major_repairs": {
"header": "",
"description": "",
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 7e514b17f..bef0a1130 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -173,6 +173,9 @@ en:
after_void_date: "Enter a tenancy start date that is after the void date"
after_major_repair_date: "Enter a tenancy start date that is after the major repair date"
year_not_two_digits: Tenancy start year must be 2 digits
+ ten_years_after_void_date: "Enter a tenancy start date that is no more than 10 years after the void date"
+ ten_years_after_mrc_date: "Enter a tenancy start date that is no more than 10 years after the major repairs completion date"
+
location:
deactivated: "The location %{postcode} was deactivated on %{date} and was not available on the day you entered."
reactivating_soon: "The location %{postcode} is not available until %{date}. Select another location or edit the tenancy start date"
@@ -200,6 +203,7 @@ en:
before_tenancy_start: "Enter a major repairs date that is before the tenancy start date"
not_first_let: "Major repairs date must not be completed if the tenancy is a first let"
ten_years_before_tenancy_start: "Enter a major repairs completion date that is no more than 10 years before the tenancy start date"
+ before_void_date: "Major repairs date must be after the void date if provided"
void_date:
ten_years_before_tenancy_start: "Enter a void date no more than 10 years before the tenancy start date"
before_tenancy_start: "Enter a void date that is before the tenancy start date"
diff --git a/spec/models/form/lettings/pages/void_date_spec.rb b/spec/models/form/lettings/pages/void_date_spec.rb
new file mode 100644
index 000000000..7a4b394d4
--- /dev/null
+++ b/spec/models/form/lettings/pages/void_date_spec.rb
@@ -0,0 +1,33 @@
+require "rails_helper"
+
+RSpec.describe Form::Lettings::Pages::VoidDate, type: :model do
+ subject(:page) { described_class.new(page_id, page_definition, subsection) }
+
+ let(:page_id) { nil }
+ let(:page_definition) { nil }
+ let(:subsection) { instance_double(Form::Subsection) }
+
+ it "has correct subsection" do
+ expect(page.subsection).to eq(subsection)
+ end
+
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[voiddate])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("void_date")
+ end
+
+ it "has the correct header" do
+ expect(page.header).to be_nil
+ end
+
+ it "has the correct description" do
+ expect(page.description).to be_nil
+ end
+
+ it "has the correct depends_on" do
+ expect(page.depends_on).to eq([{ "is_renewal?" => false, "vacancy_reason_not_renewal_or_first_let?" => true }, { "has_first_let_vacancy_reason?" => true, "is_renewal?" => false }])
+ end
+end
diff --git a/spec/models/form/lettings/questions/voiddate_spec.rb b/spec/models/form/lettings/questions/voiddate_spec.rb
new file mode 100644
index 000000000..f35f3a575
--- /dev/null
+++ b/spec/models/form/lettings/questions/voiddate_spec.rb
@@ -0,0 +1,45 @@
+require "rails_helper"
+
+RSpec.describe Form::Lettings::Questions::Voiddate, type: :model do
+ subject(:question) { described_class.new(question_id, question_definition, page) }
+
+ let(:question_id) { nil }
+ let(:question_definition) { nil }
+ let(:page) { instance_double(Form::Page) }
+
+ it "has correct page" do
+ expect(question.page).to eq(page)
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("voiddate")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("What is the void date?")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Void date")
+ end
+
+ it "has the correct check_answers_card_number" do
+ expect(question.check_answers_card_number).to eq(0)
+ end
+
+ it "has the correct question_number" do
+ expect(question.question_number).to eq(23)
+ end
+
+ it "has the correct guidance_partial" do
+ expect(question.guidance_partial).to eq("void_date")
+ end
+
+ it "has the correct type" do
+ expect(question.type).to eq("date")
+ end
+
+ it "is not marked as derived" do
+ expect(question).not_to be_derived
+ end
+end
diff --git a/spec/models/form/lettings/subsections/property_information_spec.rb b/spec/models/form/lettings/subsections/property_information_spec.rb
index 2e7e58deb..c1fd9f720 100644
--- a/spec/models/form/lettings/subsections/property_information_spec.rb
+++ b/spec/models/form/lettings/subsections/property_information_spec.rb
@@ -30,9 +30,8 @@ RSpec.describe Form::Lettings::Subsections::PropertyInformation, type: :model do
property_building_type
property_wheelchair_accessible
property_number_of_bedrooms
- void_or_renewal_date
+ void_date
void_date_value_check
- new_build_handover_date
property_major_repairs
property_major_repairs_value_check
],
@@ -61,9 +60,8 @@ RSpec.describe Form::Lettings::Subsections::PropertyInformation, type: :model do
property_building_type
property_wheelchair_accessible
property_number_of_bedrooms
- void_or_renewal_date
+ void_date
void_date_value_check
- new_build_handover_date
property_major_repairs
property_major_repairs_value_check
],
diff --git a/spec/models/validations/date_validations_spec.rb b/spec/models/validations/date_validations_spec.rb
index 18912b1c8..239be2853 100644
--- a/spec/models/validations/date_validations_spec.rb
+++ b/spec/models/validations/date_validations_spec.rb
@@ -234,8 +234,11 @@ RSpec.describe Validations::DateValidations do
record.startdate = Time.zone.local(2022, 2, 1)
record.mrcdate = Time.zone.local(2012, 1, 1)
date_validator.validate_property_major_repairs(record)
+ date_validator.validate_startdate(record)
expect(record.errors["mrcdate"])
.to include(match I18n.t("validations.property.mrcdate.ten_years_before_tenancy_start"))
+ expect(record.errors["startdate"])
+ .to include(match I18n.t("validations.setup.startdate.ten_years_after_mrc_date"))
end
it "must be within 10 years of the tenancy start date" do
@@ -243,6 +246,7 @@ RSpec.describe Validations::DateValidations do
record.mrcdate = Time.zone.local(2012, 3, 1)
date_validator.validate_property_major_repairs(record)
expect(record.errors["mrcdate"]).to be_empty
+ expect(record.errors["startdate"]).to be_empty
end
context "when reason for vacancy is first let of property" do
@@ -301,8 +305,11 @@ RSpec.describe Validations::DateValidations do
record.startdate = Time.zone.local(2022, 2, 1)
record.voiddate = Time.zone.local(2012, 1, 1)
date_validator.validate_property_void_date(record)
+ date_validator.validate_startdate(record)
expect(record.errors["voiddate"])
.to include(match I18n.t("validations.property.void_date.ten_years_before_tenancy_start"))
+ expect(record.errors["startdate"])
+ .to include(match I18n.t("validations.setup.startdate.ten_years_after_void_date"))
end
it "must be within 10 years of the tenancy start date" do
@@ -310,15 +317,18 @@ RSpec.describe Validations::DateValidations do
record.voiddate = Time.zone.local(2012, 3, 1)
date_validator.validate_property_void_date(record)
expect(record.errors["voiddate"]).to be_empty
+ expect(record.errors["startdate"]).to be_empty
end
context "when major repairs have been carried out" do
- it "cannot be after major repairs date" do
+ it "void_date cannot be after major repairs date" do
record.mrcdate = Time.zone.local(2022, 1, 1)
record.voiddate = Time.zone.local(2022, 2, 1)
date_validator.validate_property_void_date(record)
expect(record.errors["voiddate"])
.to include(match I18n.t("validations.property.void_date.after_mrcdate"))
+ expect(record.errors["mrcdate"])
+ .to include(match I18n.t("validations.property.mrcdate.before_void_date"))
end
it "must be before major repairs date" do