Browse Source

Cldc 1338 dates validation (#820)

* Change property major repairs date validation from 2 years to 10

* add voiddate_date_in_soft_range? and major_repairs_date_in_soft_range? methods

* update error messages for hard validations

* Add property_major_repairs_value_check to the form

* add void_date_value_check and fix some namings

* Update value_check hidden in check answers to depend on whether the questions is answered

* Remove a schema key

* extract constants for number of days

* change error messages wording

* update schema and csv files
pull/838/head
kosiakkatrina 2 years ago committed by GitHub
parent
commit
0ff0aa31fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/models/validations/date_validations.rb
  2. 11
      app/models/validations/soft_validations.rb
  3. 4
      app/services/imports/case_logs_import_service.rb
  4. 323
      config/forms/2021_2022.json
  5. 323
      config/forms/2022_2023.json
  6. 6
      config/locales/en.yml
  7. 5
      db/migrate/20220808090330_add_major_repairs_date_value_check.rb
  8. 5
      db/migrate/20220808093035_add_void_date_value_check.rb
  9. 2
      db/schema.rb
  10. 2
      spec/factories/case_log.rb
  11. 4
      spec/fixtures/files/case_logs_download.csv
  12. 4
      spec/fixtures/files/case_logs_download_non_support.csv
  13. 10
      spec/models/validations/date_validations_spec.rb
  14. 32
      spec/models/validations/soft_validations_spec.rb

4
app/models/validations/date_validations.rb

@ -9,8 +9,8 @@ module Validations::DateValidations
record.errors.add :mrcdate, I18n.t("validations.property.mrcdate.not_first_let")
end
if record["mrcdate"].present? && record["startdate"].present? && record["startdate"].to_date - record["mrcdate"].to_date > 730
record.errors.add :mrcdate, I18n.t("validations.property.mrcdate.730_days_before_tenancy_start")
if record["mrcdate"].present? && record["startdate"].present? && record["startdate"].to_date - record["mrcdate"].to_date > 3650
record.errors.add :mrcdate, I18n.t("validations.property.mrcdate.ten_years_before_tenancy_start")
end
end

11
app/models/validations/soft_validations.rb

@ -62,6 +62,17 @@ module Validations::SoftValidations
end
end
TWO_YEARS_IN_DAYS = 730
TEN_YEARS_IN_DAYS = 3650
def major_repairs_date_in_soft_range?
mrcdate.present? && startdate.present? && mrcdate.between?(startdate.to_date - TEN_YEARS_IN_DAYS, startdate.to_date - TWO_YEARS_IN_DAYS)
end
def voiddate_in_soft_range?
voiddate.present? && startdate.present? && voiddate.between?(startdate.to_date - TEN_YEARS_IN_DAYS, startdate.to_date - TWO_YEARS_IN_DAYS)
end
private
def details_known_or_lead_tenant?(tenant_number)

4
app/services/imports/case_logs_import_service.rb

@ -209,6 +209,8 @@ module Imports
# Soft validations can become required answers, set them to yes by default
attributes["pregnancy_value_check"] = 0
attributes["major_repairs_date_value_check"] = 0
attributes["void_date_value_check"] = 0
attributes["retirement_value_check"] = 0
attributes["rent_value_check"] = 0
attributes["net_income_value_check"] = 0
@ -273,7 +275,7 @@ module Imports
end
def fields_not_present_in_softwire_data
%w[majorrepairs illness_type_0 tshortfall_known pregnancy_value_check retirement_value_check rent_value_check net_income_value_check]
%w[majorrepairs illness_type_0 tshortfall_known pregnancy_value_check retirement_value_check rent_value_check net_income_value_check major_repairs_date_value_check void_date_value_check]
end
def check_status_completed(case_log, previous_status)

323
config/forms/2021_2022.json

@ -771,6 +771,38 @@
}
]
},
"void_date_value_check": {
"depends_on": [{ "voiddate_in_soft_range?": true }],
"title_text": {
"translation": "soft_validations.void_date.title_text"
},
"informative_text": {},
"questions": {
"void_date_value_check": {
"check_answer_label": "Void date confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"void_date_value_check": 0
},
{
"void_date_value_check": 1
}
]
},
"header": "Are you sure the time between these dates is correct?",
"type": "interruption_screen",
"answer_options": {
"0": {
"value": "Yes"
},
"1": {
"value": "No"
}
}
}
}
},
"new_build_handover_date": {
"header": "",
"description": "",
@ -867,6 +899,38 @@
"rsnvac": 19
}
]
},
"property_major_repairs_value_check": {
"depends_on": [{ "major_repairs_date_in_soft_range?": true }],
"title_text": {
"translation": "soft_validations.major_repairs_date.title_text"
},
"informative_text": {},
"questions": {
"major_repairs_date_value_check": {
"check_answer_label": "Major repairs date confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"major_repairs_date_value_check": 0
},
{
"major_repairs_date_value_check": 1
}
]
},
"header": "Are you sure the time between these dates is correct?",
"type": "interruption_screen",
"answer_options": {
"0": {
"value": "Yes"
},
"1": {
"value": "No"
}
}
}
}
}
}
},
@ -1722,8 +1786,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@ -1768,8 +1841,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@ -2216,8 +2298,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@ -2262,8 +2353,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@ -2707,8 +2807,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@ -2753,8 +2862,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@ -3195,8 +3313,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@ -3241,8 +3368,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@ -3680,8 +3816,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@ -3726,8 +3871,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@ -4162,8 +4316,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@ -4208,8 +4371,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@ -4641,8 +4813,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@ -4687,8 +4868,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@ -5117,8 +5307,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@ -5163,8 +5362,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@ -5381,8 +5589,16 @@
},
"questions": {
"pregnancy_value_check": {
"check_answer_label": "Pregnancy soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Pregnancy confirmation",
"hidden_in_check_answers": {
"depends_on": [{
"pregnancy_value_check": 0
},
{
"pregnancy_value_check": 1
}
]
},
"header": "Are you sure this is correct?",
"type": "interruption_screen",
"answer_options": {
@ -6875,8 +7091,17 @@
},
"questions": {
"net_income_value_check": {
"check_answer_label": "Net income soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Net income confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"net_income_value_check": 0
},
{
"net_income_value_check": 1
}
]
},
"header": "Are you sure this is correct?",
"type": "interruption_screen",
"answer_options": {
@ -7779,8 +8004,17 @@
},
"questions": {
"rent_value_check": {
"check_answer_label": "Rent soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Total rent confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"rent_value_check": 0
},
{
"rent_value_check": 1
}
]
},
"header": "Are you sure this is correct?",
"type": "interruption_screen",
"answer_options": {
@ -7823,8 +8057,17 @@
},
"questions": {
"rent_value_check": {
"check_answer_label": "Rent soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Total rent confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"rent_value_check": 0
},
{
"rent_value_check": 1
}
]
},
"header": "Are you sure this is correct?",
"type": "interruption_screen",
"answer_options": {

323
config/forms/2022_2023.json

@ -771,6 +771,38 @@
}
]
},
"void_date_value_check": {
"depends_on": [{ "voiddate_in_soft_range?": true }],
"title_text": {
"translation": "soft_validations.void_date.title_text"
},
"informative_text": {},
"questions": {
"void_date_value_check": {
"check_answer_label": "Void date confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"void_date_value_check": 0
},
{
"void_date_value_check": 1
}
]
},
"header": "Are you sure the time between these dates is correct?",
"type": "interruption_screen",
"answer_options": {
"0": {
"value": "Yes"
},
"1": {
"value": "No"
}
}
}
}
},
"new_build_handover_date": {
"header": "",
"description": "",
@ -867,6 +899,38 @@
"rsnvac": 19
}
]
},
"property_major_repairs_value_check": {
"depends_on": [{ "major_repairs_date_in_soft_range?": true }],
"title_text": {
"translation": "soft_validations.major_repairs_date.title_text"
},
"informative_text": {},
"questions": {
"major_repairs_date_value_check": {
"check_answer_label": "Major repairs date confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"major_repairs_date_value_check": 0
},
{
"major_repairs_date_value_check": 1
}
]
},
"header": "Are you sure the time between these dates is correct?",
"type": "interruption_screen",
"answer_options": {
"0": {
"value": "Yes"
},
"1": {
"value": "No"
}
}
}
}
}
}
},
@ -1709,8 +1773,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@ -1753,8 +1826,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@ -2201,8 +2283,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@ -2247,8 +2338,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@ -2692,8 +2792,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@ -2738,8 +2847,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@ -3180,8 +3298,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@ -3226,8 +3353,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@ -3665,8 +3801,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@ -3711,8 +3856,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@ -4147,8 +4301,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@ -4193,8 +4356,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@ -4626,8 +4798,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@ -4672,8 +4853,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@ -5102,8 +5292,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@ -5148,8 +5347,17 @@
},
"questions": {
"retirement_value_check": {
"check_answer_label": "Retirement age soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Retirement confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"retirement_value_check": 0
},
{
"retirement_value_check": 1
}
]
},
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@ -5369,8 +5577,16 @@
},
"questions": {
"pregnancy_value_check": {
"check_answer_label": "Pregnancy soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Pregnancy confirmation",
"hidden_in_check_answers": {
"depends_on": [{
"pregnancy_value_check": 0
},
{
"pregnancy_value_check": 1
}
]
},
"header": "Are you sure this is correct?",
"type": "interruption_screen",
"answer_options": {
@ -6818,8 +7034,17 @@
},
"questions": {
"net_income_value_check": {
"check_answer_label": "Net income soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Net income confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"net_income_value_check": 0
},
{
"net_income_value_check": 1
}
]
},
"header": "Are you sure this is correct?",
"type": "interruption_screen",
"answer_options": {
@ -7719,8 +7944,17 @@
},
"questions": {
"rent_value_check": {
"check_answer_label": "Rent soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Total rent confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"rent_value_check": 0
},
{
"rent_value_check": 1
}
]
},
"header": "Are you sure this is correct?",
"type": "interruption_screen",
"answer_options": {
@ -7763,8 +7997,17 @@
},
"questions": {
"rent_value_check": {
"check_answer_label": "Rent soft validation",
"hidden_in_check_answers": true,
"check_answer_label": "Total rent confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"rent_value_check": 0
},
{
"rent_value_check": 1
}
]
},
"header": "Are you sure this is correct?",
"type": "interruption_screen",
"answer_options": {

6
config/locales/en.yml

@ -122,7 +122,7 @@ en:
mrcdate:
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"
730_days_before_tenancy_start: "Enter a major repairs completion date that is no more than 730 days before the tenancy start date"
ten_years_before_tenancy_start: "Enter a major repairs completion date that is no more than 10 years before the tenancy start date"
void_date:
ten_years_before_tenancy_start: "Enter a void date must no more than 10 years before the tenancy start date"
before_tenancy_start: "Enter a void date must that is before the tenancy start date"
@ -319,6 +319,10 @@ en:
title: "You told us somebody in the household is pregnant"
no_females: "You also told us there are no female tenants living at the property."
females_not_in_soft_age_range: "You also told us that any female tenants living at the property are in the following age ranges:<ul><li>11 to 16</li><li>50 to 65</li></ul>"
major_repairs_date:
title_text: "You told us the time between the start of the tenancy and the major repairs completion date is more than 2 years"
void_date:
title_text: "You told us the time between the start of the tenancy and the void date is more than 2 years"
devise:
two_factor_authentication:

5
db/migrate/20220808090330_add_major_repairs_date_value_check.rb

@ -0,0 +1,5 @@
class AddMajorRepairsDateValueCheck < ActiveRecord::Migration[7.0]
def change
add_column :case_logs, :major_repairs_date_value_check, :integer
end
end

5
db/migrate/20220808093035_add_void_date_value_check.rb

@ -0,0 +1,5 @@
class AddVoidDateValueCheck < ActiveRecord::Migration[7.0]
def change
add_column :case_logs, :void_date_value_check, :integer
end
end

2
db/schema.rb

@ -200,6 +200,8 @@ ActiveRecord::Schema[7.0].define(version: 2022_08_10_152340) do
t.integer "vacdays"
t.bigint "scheme_id"
t.bigint "location_id"
t.integer "major_repairs_date_value_check"
t.integer "void_date_value_check"
t.index ["created_by_id"], name: "index_case_logs_on_created_by_id"
t.index ["location_id"], name: "index_case_logs_on_location_id"
t.index ["managing_organisation_id"], name: "index_case_logs_on_managing_organisation_id"

2
spec/factories/case_log.rb

@ -110,6 +110,8 @@ FactoryBot.define do
rp_dontknow { 0 }
tenancyother { nil }
net_income_value_check { nil }
void_date_value_check { 1 }
major_repairs_date_value_check { 1 }
net_income_known { 0 }
previous_la_known { 1 }
property_owner_organisation { "Test" }

4
spec/fixtures/files/case_logs_download.csv vendored

@ -1,2 +1,2 @@
id,status,created_at,updated_at,tenancycode,age1,sex1,ethnic,national,prevten,ecstat1,hhmemb,age2,sex2,ecstat2,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,leftreg,reservist,illness,preg_occ,startertenancy,tenancylength,tenancy,ppostcode_full,rsnvac,unittype_gn,beds,offered,wchair,earnings,incfreq,benefits,period,layear,waityear,postcode_full,reasonpref,cbl,chr,cap,reasonother,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,illness_type_1,illness_type_2,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,net_income_value_check,property_owner_organisation,property_manager_organisation,sale_or_letting,irproduct_other,purchaser_code,reason,propcode,majorrepairs,la,prevloc,hb,hbrentshortfall,property_relet,mrcdate,incref,sale_completion_date,startdate,armedforces,first_time_property_let_as_social_housing,unitletas,builtype,voiddate,renttype,needstype,lettype,postcode_known,is_la_inferred,totchild,totelder,totadult,net_income_known,nocharge,is_carehome,household_charge,referral,brent,scharge,pscharge,supcharg,tcharge,tshortfall,chcharge,declaration,ppcodenk,previous_la_known,is_previous_la_inferred,age1_known,age2_known,age3_known,age4_known,age5_known,age6_known,age7_known,age8_known,ethnic_group,ethnic_other,letting_allocation_unknown,details_known_2,details_known_3,details_known_4,details_known_5,details_known_6,details_known_7,details_known_8,rent_type,has_benefits,renewal,wrent,wscharge,wpschrge,wsupchrg,wtcharge,wtshortfall,refused,housingneeds,wchchrg,newprop,relat2,relat3,relat4,relat5,relat6,relat7,relat8,rent_value_check,old_form_id,lar,irproduct,old_id,joint,illness_type_0,retirement_value_check,tshortfall_known,sheltered,pregnancy_value_check,hhtype,new_old,vacdays,scheme_id,location_id,unittype_sh,owning_organisation_name,managing_organisation_name,created_by_name
{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,2,,,,,,,SE1 1TE,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Westminster,,,,,,,,,,,,,,,Supported housing,,,No,0,0,0,,0,,,,,,,,,,,,,,No,,,,,,,,,,,,,,,,,,,,0,,,,,,,,0,,,,,,,,,,,,,,,,,,,,,,9,,,{scheme_id},SE1 1TE,6,DLUHC,DLUHC,Danny Rojas
id,status,created_at,updated_at,tenancycode,age1,sex1,ethnic,national,prevten,ecstat1,hhmemb,age2,sex2,ecstat2,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,leftreg,reservist,illness,preg_occ,startertenancy,tenancylength,tenancy,ppostcode_full,rsnvac,unittype_gn,beds,offered,wchair,earnings,incfreq,benefits,period,layear,waityear,postcode_full,reasonpref,cbl,chr,cap,reasonother,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,illness_type_1,illness_type_2,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,net_income_value_check,property_owner_organisation,property_manager_organisation,sale_or_letting,irproduct_other,purchaser_code,reason,propcode,majorrepairs,la,prevloc,hb,hbrentshortfall,property_relet,mrcdate,incref,sale_completion_date,startdate,armedforces,first_time_property_let_as_social_housing,unitletas,builtype,voiddate,renttype,needstype,lettype,postcode_known,is_la_inferred,totchild,totelder,totadult,net_income_known,nocharge,is_carehome,household_charge,referral,brent,scharge,pscharge,supcharg,tcharge,tshortfall,chcharge,declaration,ppcodenk,previous_la_known,is_previous_la_inferred,age1_known,age2_known,age3_known,age4_known,age5_known,age6_known,age7_known,age8_known,ethnic_group,ethnic_other,letting_allocation_unknown,details_known_2,details_known_3,details_known_4,details_known_5,details_known_6,details_known_7,details_known_8,rent_type,has_benefits,renewal,wrent,wscharge,wpschrge,wsupchrg,wtcharge,wtshortfall,refused,housingneeds,wchchrg,newprop,relat2,relat3,relat4,relat5,relat6,relat7,relat8,rent_value_check,old_form_id,lar,irproduct,old_id,joint,illness_type_0,retirement_value_check,tshortfall_known,sheltered,pregnancy_value_check,hhtype,new_old,vacdays,scheme_id,location_id,major_repairs_date_value_check,void_date_value_check,unittype_sh,owning_organisation_name,managing_organisation_name,created_by_name
{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,2,,,,,,,SE1 1TE,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Westminster,,,,,,,,,,,,,,,Supported housing,,,No,0,0,0,,0,,,,,,,,,,,,,,No,,,,,,,,,,,,,,,,,,,,0,,,,,,,,0,,,,,,,,,,,,,,,,,,,,,,9,,,{scheme_id},SE1 1TE,,,6,DLUHC,DLUHC,Danny Rojas

1 id status created_at updated_at tenancycode age1 sex1 ethnic national prevten ecstat1 hhmemb age2 sex2 ecstat2 age3 sex3 ecstat3 age4 sex4 ecstat4 age5 sex5 ecstat5 age6 sex6 ecstat6 age7 sex7 ecstat7 age8 sex8 ecstat8 homeless underoccupation_benefitcap leftreg reservist illness preg_occ startertenancy tenancylength tenancy ppostcode_full rsnvac unittype_gn beds offered wchair earnings incfreq benefits period layear waityear postcode_full reasonpref cbl chr cap reasonother housingneeds_a housingneeds_b housingneeds_c housingneeds_f housingneeds_g housingneeds_h illness_type_1 illness_type_2 illness_type_3 illness_type_4 illness_type_8 illness_type_5 illness_type_6 illness_type_7 illness_type_9 illness_type_10 rp_homeless rp_insan_unsat rp_medwel rp_hardship rp_dontknow tenancyother net_income_value_check property_owner_organisation property_manager_organisation sale_or_letting irproduct_other purchaser_code reason propcode majorrepairs la prevloc hb hbrentshortfall property_relet mrcdate incref sale_completion_date startdate armedforces first_time_property_let_as_social_housing unitletas builtype voiddate renttype needstype lettype postcode_known is_la_inferred totchild totelder totadult net_income_known nocharge is_carehome household_charge referral brent scharge pscharge supcharg tcharge tshortfall chcharge declaration ppcodenk previous_la_known is_previous_la_inferred age1_known age2_known age3_known age4_known age5_known age6_known age7_known age8_known ethnic_group ethnic_other letting_allocation_unknown details_known_2 details_known_3 details_known_4 details_known_5 details_known_6 details_known_7 details_known_8 rent_type has_benefits renewal wrent wscharge wpschrge wsupchrg wtcharge wtshortfall refused housingneeds wchchrg newprop relat2 relat3 relat4 relat5 relat6 relat7 relat8 rent_value_check old_form_id lar irproduct old_id joint illness_type_0 retirement_value_check tshortfall_known sheltered pregnancy_value_check hhtype new_old vacdays scheme_id location_id major_repairs_date_value_check void_date_value_check unittype_sh owning_organisation_name managing_organisation_name created_by_name
2 {id} in_progress 2022-02-08 16:52:15 +0000 2022-02-08 16:52:15 +0000 2 SE1 1TE Westminster Supported housing No 0 0 0 0 No 0 0 9 {scheme_id} SE1 1TE 6 DLUHC DLUHC Danny Rojas

4
spec/fixtures/files/case_logs_download_non_support.csv vendored

@ -1,2 +1,2 @@
id,status,created_at,updated_at,tenancycode,age1,sex1,ethnic,national,prevten,ecstat1,age2,sex2,ecstat2,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,leftreg,reservist,illness,preg_occ,startertenancy,tenancylength,tenancy,ppostcode_full,rsnvac,unittype_gn,beds,offered,wchair,earnings,incfreq,benefits,period,layear,waityear,postcode_full,reasonpref,cbl,chr,cap,reasonother,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,illness_type_1,illness_type_2,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,property_owner_organisation,property_manager_organisation,irproduct_other,purchaser_code,reason,propcode,majorrepairs,la,prevloc,hb,hbrentshortfall,property_relet,mrcdate,incref,sale_completion_date,startdate,armedforces,unitletas,builtype,voiddate,lettype,nocharge,household_charge,referral,brent,scharge,pscharge,supcharg,tcharge,tshortfall,chcharge,declaration,ppcodenk,ethnic_group,ethnic_other,has_benefits,renewal,refused,housingneeds,wchchrg,newprop,relat2,relat3,relat4,relat5,relat6,relat7,relat8,lar,irproduct,joint,illness_type_0,sheltered,scheme_id,location_id,unittype_sh,owning_organisation_name,managing_organisation_name,created_by_name
{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,2,,,,,,,SE1 1TE,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Westminster,,,,,,,,,,,,,,0,,,,,,,,,,,,,,0,,0,,,,,,,,,,,,,,,,{scheme_id},SE1 1TE,6,DLUHC,DLUHC,Danny Rojas
id,status,created_at,updated_at,tenancycode,age1,sex1,ethnic,national,prevten,ecstat1,age2,sex2,ecstat2,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,leftreg,reservist,illness,preg_occ,startertenancy,tenancylength,tenancy,ppostcode_full,rsnvac,unittype_gn,beds,offered,wchair,earnings,incfreq,benefits,period,layear,waityear,postcode_full,reasonpref,cbl,chr,cap,reasonother,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,illness_type_1,illness_type_2,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,property_owner_organisation,property_manager_organisation,irproduct_other,purchaser_code,reason,propcode,majorrepairs,la,prevloc,hb,hbrentshortfall,property_relet,mrcdate,incref,sale_completion_date,startdate,armedforces,unitletas,builtype,voiddate,lettype,nocharge,household_charge,referral,brent,scharge,pscharge,supcharg,tcharge,tshortfall,chcharge,declaration,ppcodenk,ethnic_group,ethnic_other,has_benefits,renewal,refused,housingneeds,wchchrg,newprop,relat2,relat3,relat4,relat5,relat6,relat7,relat8,lar,irproduct,joint,illness_type_0,sheltered,scheme_id,location_id,major_repairs_date_value_check,void_date_value_check,unittype_sh,owning_organisation_name,managing_organisation_name,created_by_name
{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,2,,,,,,,SE1 1TE,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Westminster,,,,,,,,,,,,,,0,,,,,,,,,,,,,,0,,0,,,,,,,,,,,,,,,,{scheme_id},SE1 1TE,,,6,DLUHC,DLUHC,Danny Rojas

1 id status created_at updated_at tenancycode age1 sex1 ethnic national prevten ecstat1 age2 sex2 ecstat2 age3 sex3 ecstat3 age4 sex4 ecstat4 age5 sex5 ecstat5 age6 sex6 ecstat6 age7 sex7 ecstat7 age8 sex8 ecstat8 homeless underoccupation_benefitcap leftreg reservist illness preg_occ startertenancy tenancylength tenancy ppostcode_full rsnvac unittype_gn beds offered wchair earnings incfreq benefits period layear waityear postcode_full reasonpref cbl chr cap reasonother housingneeds_a housingneeds_b housingneeds_c housingneeds_f housingneeds_g housingneeds_h illness_type_1 illness_type_2 illness_type_3 illness_type_4 illness_type_8 illness_type_5 illness_type_6 illness_type_7 illness_type_9 illness_type_10 rp_homeless rp_insan_unsat rp_medwel rp_hardship rp_dontknow tenancyother property_owner_organisation property_manager_organisation irproduct_other purchaser_code reason propcode majorrepairs la prevloc hb hbrentshortfall property_relet mrcdate incref sale_completion_date startdate armedforces unitletas builtype voiddate lettype nocharge household_charge referral brent scharge pscharge supcharg tcharge tshortfall chcharge declaration ppcodenk ethnic_group ethnic_other has_benefits renewal refused housingneeds wchchrg newprop relat2 relat3 relat4 relat5 relat6 relat7 relat8 lar irproduct joint illness_type_0 sheltered scheme_id location_id major_repairs_date_value_check void_date_value_check unittype_sh owning_organisation_name managing_organisation_name created_by_name
2 {id} in_progress 2022-02-08 16:52:15 +0000 2022-02-08 16:52:15 +0000 2 SE1 1TE Westminster 0 0 0 {scheme_id} SE1 1TE 6 DLUHC DLUHC Danny Rojas

10
spec/models/validations/date_validations_spec.rb

@ -85,17 +85,17 @@ RSpec.describe Validations::DateValidations do
expect(record.errors["mrcdate"]).to be_empty
end
it "cannot be more than 2 years before the tenancy start date" do
it "cannot be more than 10 years before the tenancy start date" do
record.startdate = Time.zone.local(2022, 2, 1)
record.mrcdate = Time.zone.local(2020, 1, 1)
record.mrcdate = Time.zone.local(2012, 1, 1)
date_validator.validate_property_major_repairs(record)
expect(record.errors["mrcdate"])
.to include(match I18n.t("validations.property.mrcdate.730_days_before_tenancy_start"))
.to include(match I18n.t("validations.property.mrcdate.ten_years_before_tenancy_start"))
end
it "must be within 2 years of the tenancy start date" do
it "must be within 10 years of the tenancy start date" do
record.startdate = Time.zone.local(2022, 2, 1)
record.mrcdate = Time.zone.local(2020, 3, 1)
record.mrcdate = Time.zone.local(2012, 3, 1)
date_validator.validate_property_major_repairs(record)
expect(record.errors["mrcdate"]).to be_empty
end

32
spec/models/validations/soft_validations_spec.rb

@ -205,4 +205,36 @@ RSpec.describe Validations::SoftValidations do
end
end
end
describe "major repairs date soft validations" do
context "when the major repairs date is within 10 years of the tenancy start date" do
it "shows the interruption screen" do
record.update!(startdate: Time.zone.local(2022, 2, 1), mrcdate: Time.zone.local(2013, 2, 1))
expect(record.major_repairs_date_in_soft_range?).to be true
end
end
context "when the major repairs date is less than 2 years before the tenancy start date" do
it "does not show the interruption screen" do
record.update!(startdate: Time.zone.local(2022, 2, 1), mrcdate: Time.zone.local(2021, 2, 1))
expect(record.major_repairs_date_in_soft_range?).to be false
end
end
end
describe "void date soft validations" do
context "when the void date is within 10 years of the tenancy start date" do
it "shows the interruption screen" do
record.update!(startdate: Time.zone.local(2022, 2, 1), voiddate: Time.zone.local(2013, 2, 1))
expect(record.voiddate_in_soft_range?).to be true
end
end
context "when the void date is less than 2 years before the tenancy start date" do
it "does not show the interruption screen" do
record.update!(startdate: Time.zone.local(2022, 2, 1), voiddate: Time.zone.local(2021, 2, 1))
expect(record.voiddate_in_soft_range?).to be false
end
end
end
end

Loading…
Cancel
Save