Browse Source

Merge branch 'main' into StaircasePropertyInfo

pull/2761/head
Rachael Booth 7 months ago committed by GitHub
parent
commit
9ad98f291a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      app/helpers/interruption_screen_helper.rb
  2. 8
      app/models/form/lettings/pages/care_home_charges_value_check.rb
  3. 9
      app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_lead_age_value_check.rb
  4. 9
      app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_lead_hhmemb_value_check.rb
  5. 9
      app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_lead_value_check.rb
  6. 21
      app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_person_age_value_check.rb
  7. 22
      app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_person_value_check.rb
  8. 9
      app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_value_check.rb
  9. 6
      app/models/form/lettings/pages/lead_tenant_over_retirement_value_check.rb
  10. 8
      app/models/form/lettings/pages/lead_tenant_under_retirement_value_check.rb
  11. 8
      app/models/form/lettings/pages/multiple_partners_value_check.rb
  12. 5
      app/models/form/lettings/pages/net_income_value_check.rb
  13. 9
      app/models/form/lettings/pages/no_females_pregnant_household_lead_age_value_check.rb
  14. 9
      app/models/form/lettings/pages/no_females_pregnant_household_lead_hhmemb_value_check.rb
  15. 9
      app/models/form/lettings/pages/no_females_pregnant_household_lead_value_check.rb
  16. 9
      app/models/form/lettings/pages/no_females_pregnant_household_person_age_value_check.rb
  17. 9
      app/models/form/lettings/pages/no_females_pregnant_household_person_value_check.rb
  18. 9
      app/models/form/lettings/pages/no_females_pregnant_household_value_check.rb
  19. 8
      app/models/form/lettings/pages/partner_under_16_value_check.rb
  20. 6
      app/models/form/lettings/pages/person_over_retirement_value_check.rb
  21. 8
      app/models/form/lettings/pages/person_under_retirement_value_check.rb
  22. 5
      app/models/form/lettings/pages/property_major_repairs_value_check.rb
  23. 8
      app/models/form/lettings/pages/pscharge_value_check.rb
  24. 5
      app/models/form/lettings/pages/reasonother_value_check.rb
  25. 5
      app/models/form/lettings/pages/referral_value_check.rb
  26. 5
      app/models/form/lettings/pages/rent_value_check.rb
  27. 8
      app/models/form/lettings/pages/scharge_value_check.rb
  28. 8
      app/models/form/lettings/pages/supcharg_value_check.rb
  29. 5
      app/models/form/lettings/pages/void_date_value_check.rb
  30. 3
      app/models/form/lettings/questions/care_home_charges_value_check.rb
  31. 3
      app/models/form/lettings/questions/major_repairs_date_value_check.rb
  32. 3
      app/models/form/lettings/questions/multiple_partners_value_check.rb
  33. 3
      app/models/form/lettings/questions/net_income_value_check.rb
  34. 3
      app/models/form/lettings/questions/no_retirement_value_check.rb
  35. 3
      app/models/form/lettings/questions/partner_under_16_value_check.rb
  36. 3
      app/models/form/lettings/questions/pregnancy_value_check.rb
  37. 4
      app/models/form/lettings/questions/pscharge_value_check.rb
  38. 3
      app/models/form/lettings/questions/reasonother_value_check.rb
  39. 3
      app/models/form/lettings/questions/referral_value_check.rb
  40. 4
      app/models/form/lettings/questions/rent_value_check.rb
  41. 3
      app/models/form/lettings/questions/retirement_value_check.rb
  42. 4
      app/models/form/lettings/questions/scharge_value_check.rb
  43. 4
      app/models/form/lettings/questions/supcharg_value_check.rb
  44. 3
      app/models/form/lettings/questions/void_date_value_check.rb
  45. 4
      app/models/form/sales/subsections/setup.rb
  46. 6
      app/models/lettings_log.rb
  47. 2
      app/models/user.rb
  48. 126
      app/models/validations/financial_validations.rb
  49. 9
      app/models/validations/household_validations.rb
  50. 8
      app/models/validations/property_validations.rb
  51. 9
      app/models/validations/sales/household_validations.rb
  52. 8
      app/models/validations/sales/property_validations.rb
  53. 8
      app/models/validations/sales/setup_validations.rb
  54. 49
      app/models/validations/setup_validations.rb
  55. 80
      app/models/validations/shared_validations.rb
  56. 4
      config/forms/2021_2022.json
  57. 4
      config/forms/2022_2023.json
  58. 147
      config/locales/en.yml
  59. 132
      config/locales/forms/2023/lettings/soft_validations.en.yml
  60. 132
      config/locales/forms/2024/lettings/soft_validations.en.yml
  61. 132
      config/locales/forms/2025/lettings/soft_validations.en.yml
  62. 10
      config/locales/forms/2025/sales/setup.en.yml
  63. 86
      config/locales/validations/lettings/financial.yml
  64. 7
      config/locales/validations/lettings/household.en.yml
  65. 6
      config/locales/validations/lettings/property_information.en.yml
  66. 35
      config/locales/validations/lettings/setup.en.yml
  67. 7
      config/locales/validations/sales/property_information.en.yml
  68. 1
      config/locales/validations/sales/setup.en.yml
  69. 19
      config/locales/validations/shared.en.yml
  70. 4
      lib/tasks/generate_lettings_documentation.rake
  71. 4
      lib/tasks/generate_sales_documentation.rake
  72. 2
      spec/factories/scheme.rb
  73. 6
      spec/fixtures/files/sales_logs_csv_export_codes_23.csv
  74. 6
      spec/fixtures/files/sales_logs_csv_export_codes_24.csv
  75. 6
      spec/fixtures/files/sales_logs_csv_export_labels_23.csv
  76. 6
      spec/fixtures/files/sales_logs_csv_export_labels_24.csv
  77. 6
      spec/fixtures/files/sales_logs_csv_export_non_support_labels_24.csv
  78. 4
      spec/fixtures/forms/2021_2022.json
  79. 2
      spec/helpers/interruption_screen_helper_spec.rb
  80. 4
      spec/models/form/lettings/pages/care_home_charges_value_check_spec.rb
  81. 40
      spec/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_person_age_value_check_spec.rb
  82. 40
      spec/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_person_value_check_spec.rb
  83. 11
      spec/models/form/lettings/pages/multiple_partners_value_check_spec.rb
  84. 4
      spec/models/form/lettings/pages/net_income_value_check_spec.rb
  85. 40
      spec/models/form/lettings/pages/no_females_pregnant_household_person_age_value_check_spec.rb
  86. 40
      spec/models/form/lettings/pages/no_females_pregnant_household_person_value_check_spec.rb
  87. 27
      spec/models/form/lettings/pages/partner_under16_value_check_spec.rb
  88. 10
      spec/models/form/lettings/pages/person_over_retirement_value_check_spec.rb
  89. 8
      spec/models/form/lettings/pages/person_under_retirement_value_check_spec.rb
  90. 2
      spec/models/form/lettings/subsections/household_characteristics_spec.rb
  91. 3
      spec/models/form/lettings/subsections/household_needs_spec.rb
  92. 2
      spec/models/form/lettings/subsections/household_situation_spec.rb
  93. 3
      spec/models/form/lettings/subsections/income_and_benefits_spec.rb
  94. 8
      spec/models/form/sales/pages/la_nominations_spec.rb
  95. 6
      spec/models/form/sales/pages/last_accommodation_la_spec.rb
  96. 6
      spec/models/form/sales/pages/last_accommodation_spec.rb
  97. 38
      spec/models/form/sales/subsections/setup_spec.rb
  98. 4
      spec/models/form_spec.rb
  99. 2
      spec/models/validations/date_validations_spec.rb
  100. 105
      spec/models/validations/financial_validations_spec.rb
  101. Some files were not shown because too many files have changed in this diff Show More

2
app/helpers/interruption_screen_helper.rb

@ -1,7 +1,7 @@
module InterruptionScreenHelper
def display_informative_text(informative_text, log)
return informative_text if informative_text.is_a? String
return "" if informative_text.nil?
return "" if informative_text.blank?
return "" unless informative_text["arguments"]
translation_params = {}

8
app/models/form/lettings/pages/care_home_charges_value_check.rb

@ -2,11 +2,15 @@ class Form::Lettings::Pages::CareHomeChargesValueCheck < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "care_home_charges_value_check"
@copy_key = "lettings.soft_validations.care_home_charges_value_check"
@depends_on = [{ "care_home_charge_expected_not_provided?" => true }]
@title_text = {
"translation" => "soft_validations.care_home_charges.title_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
}
@informative_text = {
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
@informative_text = ""
end
def questions

9
app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_lead_age_value_check.rb

@ -2,14 +2,15 @@ class Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdLeadAgeValu
def initialize(id, hsh, subsection)
super(id, hsh, subsection)
@id = "females_in_soft_age_range_in_pregnant_household_lead_age_value_check"
@copy_key = "lettings.soft_validations.pregnancy_value_check.females_in_soft_age_range_in_pregnant_household_value_check"
@depends_on = [{ "female_in_pregnant_household_in_soft_validation_range?" => true }]
@title_text = {
"translation" => "soft_validations.pregnancy.title",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [],
}
@informative_text = {
"translation" => "soft_validations.pregnancy.females_not_in_soft_age_range",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end

9
app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_lead_hhmemb_value_check.rb

@ -2,14 +2,15 @@ class Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdLeadHhmembV
def initialize(id, hsh, subsection)
super(id, hsh, subsection)
@id = "females_in_soft_age_range_in_pregnant_household_lead_hhmemb_value_check"
@copy_key = "lettings.soft_validations.pregnancy_value_check.females_in_soft_age_range_in_pregnant_household_value_check"
@depends_on = [{ "female_in_pregnant_household_in_soft_validation_range?" => true }]
@title_text = {
"translation" => "soft_validations.pregnancy.title",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [],
}
@informative_text = {
"translation" => "soft_validations.pregnancy.females_not_in_soft_age_range",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end

9
app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_lead_value_check.rb

@ -2,14 +2,15 @@ class Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdLeadValueCh
def initialize(id, hsh, subsection)
super
@id = "females_in_soft_age_range_in_pregnant_household_lead_value_check"
@copy_key = "lettings.soft_validations.pregnancy_value_check.females_in_soft_age_range_in_pregnant_household_value_check"
@depends_on = [{ "female_in_pregnant_household_in_soft_validation_range?" => true }]
@title_text = {
"translation" => "soft_validations.pregnancy.title",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [],
}
@informative_text = {
"translation" => "soft_validations.pregnancy.females_not_in_soft_age_range",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end

21
app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_person_age_value_check.rb

@ -2,6 +2,7 @@ class Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonAgeVa
def initialize(id, hsh, subsection, person_index:)
super(id, hsh, subsection)
@id = "females_in_soft_age_range_in_pregnant_household_person_#{person_index}_age_value_check"
@copy_key = "lettings.soft_validations.pregnancy_value_check.females_in_soft_age_range_in_pregnant_household_value_check"
@depends_on = [
{
"female_in_pregnant_household_in_soft_validation_range?" => true,
@ -9,24 +10,12 @@ class Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonAgeVa
},
]
@title_text = {
"translation" => "soft_validations.pregnancy.title",
"arguments" => [
{
"key" => "sex1",
"label" => true,
"i18n_template" => "sex1",
},
],
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [],
}
@informative_text = {
"translation" => "soft_validations.pregnancy.females_not_in_soft_age_range",
"arguments" => [
{
"key" => "sex1",
"label" => true,
"i18n_template" => "sex1",
},
],
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
@person_index = person_index
end

22
app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_person_value_check.rb

@ -2,6 +2,8 @@ class Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValue
def initialize(id, hsh, subsection, person_index:)
super(id, hsh, subsection)
@id = "females_in_soft_age_range_in_pregnant_household_person_#{person_index}_value_check"
@copy_key = "lettings.soft_validations.pregnancy_value_check.females_in_soft_age_range_in_pregnant_household_value_check"
@depends_on = [
{
"female_in_pregnant_household_in_soft_validation_range?" => true,
@ -9,24 +11,12 @@ class Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValue
},
]
@title_text = {
"translation" => "soft_validations.pregnancy.title",
"arguments" => [
{
"key" => "sex1",
"label" => true,
"i18n_template" => "sex1",
},
],
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [],
}
@informative_text = {
"translation" => "soft_validations.pregnancy.females_not_in_soft_age_range",
"arguments" => [
{
"key" => "sex1",
"label" => true,
"i18n_template" => "sex1",
},
],
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
@person_index = person_index
end

9
app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_value_check.rb

@ -2,14 +2,15 @@ class Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdValueCheck
def initialize(id, hsh, subsection)
super
@id = "females_in_soft_age_range_in_pregnant_household_value_check"
@copy_key = "lettings.soft_validations.pregnancy_value_check.females_in_soft_age_range_in_pregnant_household_value_check"
@depends_on = [{ "female_in_pregnant_household_in_soft_validation_range?" => true }]
@title_text = {
"translation" => "soft_validations.pregnancy.title",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [],
}
@informative_text = {
"translation" => "soft_validations.pregnancy.females_not_in_soft_age_range",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end

6
app/models/form/lettings/pages/lead_tenant_over_retirement_value_check.rb

@ -2,11 +2,13 @@ class Form::Lettings::Pages::LeadTenantOverRetirementValueCheck < ::Form::Page
def initialize(id, hsh, subsection)
super
@depends_on = [{ "person_1_not_retired_over_soft_max_age?" => true }]
@copy_key = "lettings.soft_validations.retirement_value_check"
@title_text = {
"translation" => "soft_validations.retirement.max.title",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
}
@informative_text = {
"translation" => "soft_validations.retirement.max.hint_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end

8
app/models/form/lettings/pages/lead_tenant_under_retirement_value_check.rb

@ -2,8 +2,9 @@ class Form::Lettings::Pages::LeadTenantUnderRetirementValueCheck < ::Form::Page
def initialize(id, hsh, subsection)
super
@depends_on = [{ "person_1_retired_under_soft_min_age?" => true }]
@copy_key = "lettings.soft_validations.no_retirement_value_check"
@title_text = {
"translation" => "soft_validations.retirement.min.title",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [
{
"key" => "age1",
@ -12,7 +13,10 @@ class Form::Lettings::Pages::LeadTenantUnderRetirementValueCheck < ::Form::Page
},
],
}
@informative_text = {}
@informative_text = {
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end
def questions

8
app/models/form/lettings/pages/multiple_partners_value_check.rb

@ -6,12 +6,16 @@ class Form::Lettings::Pages::MultiplePartnersValueCheck < Form::Page
"multiple_partners?" => true,
},
]
@copy_key = "lettings.soft_validations.multiple_partners_value_check"
@person_index = person_index
@title_text = {
"translation" => "soft_validations.multiple_partners_lettings.title",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [],
}
@informative_text = {
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
@informative_text = {}
end
def questions

5
app/models/form/lettings/pages/net_income_value_check.rb

@ -2,9 +2,10 @@ class Form::Lettings::Pages::NetIncomeValueCheck < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "net_income_value_check"
@copy_key = "lettings.soft_validations.net_income_value_check"
@depends_on = [{ "net_income_soft_validation_triggered?" => true }]
@title_text = {
"translation" => "soft_validations.net_income.title_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [
{
"key" => "incfreq",
@ -20,7 +21,7 @@ class Form::Lettings::Pages::NetIncomeValueCheck < ::Form::Page
}
@informative_text = {
"translation" => "soft_validations.net_income.hint_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [
{
"key" => "net_income_higher_or_lower_text",

9
app/models/form/lettings/pages/no_females_pregnant_household_lead_age_value_check.rb

@ -2,14 +2,15 @@ class Form::Lettings::Pages::NoFemalesPregnantHouseholdLeadAgeValueCheck < ::For
def initialize(id, hsh, subsection)
super(id, hsh, subsection)
@id = "no_females_pregnant_household_lead_age_value_check"
@copy_key = "lettings.soft_validations.pregnancy_value_check.no_females_pregnant_household_value_check"
@depends_on = [{ "all_male_tenants_in_a_pregnant_household?" => true }]
@title_text = {
"translation" => "soft_validations.pregnancy.title",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [],
}
@informative_text = {
"translation" => "soft_validations.pregnancy.all_male_tenants",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end

9
app/models/form/lettings/pages/no_females_pregnant_household_lead_hhmemb_value_check.rb

@ -2,14 +2,15 @@ class Form::Lettings::Pages::NoFemalesPregnantHouseholdLeadHhmembValueCheck < ::
def initialize(id, hsh, subsection)
super
@id = "no_females_pregnant_household_lead_hhmemb_value_check"
@copy_key = "lettings.soft_validations.pregnancy_value_check.no_females_pregnant_household_value_check"
@depends_on = [{ "all_male_tenants_in_a_pregnant_household?" => true }]
@title_text = {
"translation" => "soft_validations.pregnancy.title",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [],
}
@informative_text = {
"translation" => "soft_validations.pregnancy.all_male_tenants",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end

9
app/models/form/lettings/pages/no_females_pregnant_household_lead_value_check.rb

@ -2,14 +2,15 @@ class Form::Lettings::Pages::NoFemalesPregnantHouseholdLeadValueCheck < ::Form::
def initialize(id, hsh, subsection)
super
@id = "no_females_pregnant_household_lead_value_check"
@copy_key = "lettings.soft_validations.pregnancy_value_check.no_females_pregnant_household_value_check"
@depends_on = [{ "all_male_tenants_in_a_pregnant_household?" => true }]
@title_text = {
"translation" => "soft_validations.pregnancy.title",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [],
}
@informative_text = {
"translation" => "soft_validations.pregnancy.all_male_tenants",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end

9
app/models/form/lettings/pages/no_females_pregnant_household_person_age_value_check.rb

@ -2,14 +2,15 @@ class Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck < ::F
def initialize(id, hsh, subsection, person_index:)
super(id, hsh, subsection)
@id = "no_females_pregnant_household_person_#{person_index}_age_value_check"
@copy_key = "lettings.soft_validations.pregnancy_value_check.no_females_pregnant_household_value_check"
@depends_on = [{ "all_male_tenants_in_a_pregnant_household?" => true, "age#{person_index}_known" => 0 }]
@title_text = {
"translation" => "soft_validations.pregnancy.title",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [],
}
@informative_text = {
"translation" => "soft_validations.pregnancy.all_male_tenants",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
@person_index = person_index
end

9
app/models/form/lettings/pages/no_females_pregnant_household_person_value_check.rb

@ -2,14 +2,15 @@ class Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck < ::Form
def initialize(id, hsh, subsection, person_index:)
super(id, hsh, subsection)
@id = "no_females_pregnant_household_person_#{person_index}_value_check"
@copy_key = "lettings.soft_validations.pregnancy_value_check.no_females_pregnant_household_value_check"
@depends_on = [{ "all_male_tenants_in_a_pregnant_household?" => true, "details_known_#{person_index}" => 0 }]
@title_text = {
"translation" => "soft_validations.pregnancy.title",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [],
}
@informative_text = {
"translation" => "soft_validations.pregnancy.all_male_tenants",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
@person_index = person_index
end

9
app/models/form/lettings/pages/no_females_pregnant_household_value_check.rb

@ -2,14 +2,15 @@ class Form::Lettings::Pages::NoFemalesPregnantHouseholdValueCheck < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "no_females_pregnant_household_value_check"
@copy_key = "lettings.soft_validations.pregnancy_value_check.no_females_pregnant_household_value_check"
@depends_on = [{ "all_male_tenants_in_a_pregnant_household?" => true }]
@title_text = {
"translation" => "soft_validations.pregnancy.title",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [],
}
@informative_text = {
"translation" => "soft_validations.pregnancy.all_male_tenants",
"arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }],
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end

8
app/models/form/lettings/pages/partner_under_16_value_check.rb

@ -6,9 +6,10 @@ class Form::Lettings::Pages::PartnerUnder16ValueCheck < Form::Page
"person_#{person_index}_partner_under_16?" => true,
},
]
@copy_key = "lettings.soft_validations.partner_under_16_value_check"
@person_index = person_index
@title_text = {
"translation" => "soft_validations.partner_under_16_lettings.title",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [
{
"key" => "age#{person_index}",
@ -17,7 +18,10 @@ class Form::Lettings::Pages::PartnerUnder16ValueCheck < Form::Page
},
],
}
@informative_text = {}
@informative_text = {
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end
def questions

6
app/models/form/lettings/pages/person_over_retirement_value_check.rb

@ -2,11 +2,13 @@ class Form::Lettings::Pages::PersonOverRetirementValueCheck < ::Form::Page
def initialize(id, hsh, subsection, person_index:)
super(id, hsh, subsection)
@depends_on = [{ "person_#{person_index}_not_retired_over_soft_max_age?" => true }]
@copy_key = "lettings.soft_validations.retirement_value_check"
@title_text = {
"translation" => "soft_validations.retirement.max.title",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
}
@informative_text = {
"translation" => "soft_validations.retirement.max.hint_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
@person_index = person_index
end

8
app/models/form/lettings/pages/person_under_retirement_value_check.rb

@ -2,8 +2,9 @@ class Form::Lettings::Pages::PersonUnderRetirementValueCheck < ::Form::Page
def initialize(id, hsh, subsection, person_index:)
super(id, hsh, subsection)
@depends_on = [{ "person_#{person_index}_retired_under_soft_min_age?" => true }]
@copy_key = "lettings.soft_validations.no_retirement_value_check"
@title_text = {
"translation" => "soft_validations.retirement.min.title",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [
{
"key" => "age#{person_index}",
@ -12,7 +13,10 @@ class Form::Lettings::Pages::PersonUnderRetirementValueCheck < ::Form::Page
},
],
}
@informative_text = {}
@informative_text = {
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
@person_index = person_index
end

5
app/models/form/lettings/pages/property_major_repairs_value_check.rb

@ -2,10 +2,11 @@ class Form::Lettings::Pages::PropertyMajorRepairsValueCheck < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "property_major_repairs_value_check"
@copy_key = "lettings.soft_validations.major_repairs_date_value_check"
@depends_on = [{ "major_repairs_date_in_soft_range?" => true }]
@title_text = { "translation" => "soft_validations.major_repairs_date.title_text" }
@title_text = { "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text" }
@informative_text = {
"translation" => "soft_validations.major_repairs_date.hint_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end

8
app/models/form/lettings/pages/pscharge_value_check.rb

@ -2,16 +2,20 @@ class Form::Lettings::Pages::PschargeValueCheck < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "pscharge_value_check"
@copy_key = "lettings.soft_validations.pscharge_value_check"
@depends_on = [{ "pscharge_in_soft_max_range?" => true }]
@title_text = {
"translation" => "soft_validations.pscharge.over_soft_max_title",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [{
"key" => "pscharge",
"label" => true,
"i18n_template" => "pscharge",
}],
}
@informative_text = I18n.t("soft_validations.charges.informative_text")
@informative_text = {
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end
def questions

5
app/models/form/lettings/pages/reasonother_value_check.rb

@ -2,13 +2,14 @@ class Form::Lettings::Pages::ReasonotherValueCheck < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "reasonother_value_check"
@copy_key = "lettings.soft_validations.reasonother_value_check"
@depends_on = [{ "reasonother_might_be_existing_category?" => true }]
@title_text = {
"translation" => "soft_validations.reasonother.title_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [{ "key" => "reasonother", "i18n_template" => "reasonother" }],
}
@informative_text = {
"translation" => "soft_validations.reasonother.informative_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end

5
app/models/form/lettings/pages/referral_value_check.rb

@ -2,12 +2,13 @@ class Form::Lettings::Pages::ReferralValueCheck < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "referral_value_check"
@copy_key = "lettings.soft_validations.referral_value_check"
@depends_on = [{ "la_referral_for_general_needs?" => true }]
@title_text = {
"translation" => "soft_validations.referral.title_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
}
@informative_text = {
"translation" => "soft_validations.referral.hint_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end

5
app/models/form/lettings/pages/rent_value_check.rb

@ -2,8 +2,9 @@ class Form::Lettings::Pages::RentValueCheck < ::Form::Page
def initialize(id, hsh, subsection, check_answers_card_number: nil)
super(id, hsh, subsection)
@depends_on = [{ "rent_soft_validation_triggered?" => true }]
@copy_key = "lettings.soft_validations.rent_value_check"
@title_text = {
"translation" => "soft_validations.rent.outside_range_title",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [
{
"key" => "brent",
@ -13,7 +14,7 @@ class Form::Lettings::Pages::RentValueCheck < ::Form::Page
],
}
@informative_text = {
"translation" => "soft_validations.rent.informative_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [
{
"key" => "rent_soft_validation_higher_or_lower_text",

8
app/models/form/lettings/pages/scharge_value_check.rb

@ -2,16 +2,20 @@ class Form::Lettings::Pages::SchargeValueCheck < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "scharge_value_check"
@copy_key = "lettings.soft_validations.scharge_value_check"
@depends_on = [{ "scharge_in_soft_max_range?" => true }]
@title_text = {
"translation" => "soft_validations.scharge.over_soft_max_title",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [{
"key" => "scharge",
"label" => true,
"i18n_template" => "scharge",
}],
}
@informative_text = I18n.t("soft_validations.charges.informative_text")
@title_text = {
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end
def questions

8
app/models/form/lettings/pages/supcharg_value_check.rb

@ -2,16 +2,20 @@ class Form::Lettings::Pages::SupchargValueCheck < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "supcharg_value_check"
@copy_key = "lettings.soft_validations.supcharg_value_check"
@depends_on = [{ "supcharg_in_soft_max_range?" => true }]
@title_text = {
"translation" => "soft_validations.supcharg.over_soft_max_title",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [{
"key" => "supcharg",
"label" => true,
"i18n_template" => "supcharg",
}],
}
@informative_text = I18n.t("soft_validations.charges.informative_text")
@informative_text = {
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end
def questions

5
app/models/form/lettings/pages/void_date_value_check.rb

@ -2,10 +2,11 @@ class Form::Lettings::Pages::VoidDateValueCheck < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "void_date_value_check"
@copy_key = "lettings.soft_validations.void_date_value_check"
@depends_on = [{ "voiddate_in_soft_range?" => true }]
@title_text = { "translation" => "soft_validations.void_date.title_text" }
@title_text = { "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text" }
@informative_text = {
"translation" => "soft_validations.void_date.hint_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end

3
app/models/form/lettings/questions/care_home_charges_value_check.rb

@ -2,8 +2,7 @@ class Form::Lettings::Questions::CareHomeChargesValueCheck < ::Form::Question
def initialize(id, hsh, page)
super
@id = "carehome_charges_value_check"
@check_answer_label = "Care home charges confirmation"
@header = "Are you sure there are no care home charges?"
@copy_key = "lettings.soft_validations.care_home_charges_value_check"
@type = "interruption_screen"
@check_answers_card_number = 0
@answer_options = ANSWER_OPTIONS

3
app/models/form/lettings/questions/major_repairs_date_value_check.rb

@ -2,8 +2,7 @@ class Form::Lettings::Questions::MajorRepairsDateValueCheck < ::Form::Question
def initialize(id, hsh, page)
super
@id = "major_repairs_date_value_check"
@check_answer_label = "Major repairs date confirmation"
@header = "Are you sure the property has been vacant for this long?"
@copy_key = "lettings.soft_validations.major_repairs_date_value_check"
@type = "interruption_screen"
@check_answers_card_number = 0
@answer_options = ANSWER_OPTIONS

3
app/models/form/lettings/questions/multiple_partners_value_check.rb

@ -2,7 +2,7 @@ class Form::Lettings::Questions::MultiplePartnersValueCheck < ::Form::Question
def initialize(id, hsh, page, person_index:)
super(id, hsh, page)
@id = "multiple_partners_value_check"
@check_answer_label = "Multiple partners confirmation"
@copy_key = "lettings.soft_validations.multiple_partners_value_check"
@type = "interruption_screen"
@answer_options = {
"0" => { "value" => "Yes" },
@ -19,6 +19,5 @@ class Form::Lettings::Questions::MultiplePartnersValueCheck < ::Form::Question
],
}
@check_answers_card_number = person_index
@header = "Are you sure this is correct?"
end
end

3
app/models/form/lettings/questions/net_income_value_check.rb

@ -2,8 +2,7 @@ class Form::Lettings::Questions::NetIncomeValueCheck < ::Form::Question
def initialize(id, hsh, page)
super
@id = "net_income_value_check"
@check_answer_label = "Net income confirmation"
@header = "Are you sure this is correct?"
@copy_key = "lettings.soft_validations.net_income_value_check"
@type = "interruption_screen"
@check_answers_card_number = 0
@answer_options = ANSWER_OPTIONS

3
app/models/form/lettings/questions/no_retirement_value_check.rb

@ -2,8 +2,7 @@ class Form::Lettings::Questions::NoRetirementValueCheck < ::Form::Question
def initialize(id, hsh, page, person_index:)
super(id, hsh, page)
@id = "retirement_value_check"
@check_answer_label = "Retirement confirmation"
@header = "Are you sure this person is retired?"
@copy_key = "lettings.soft_validations.no_retirement_value_check"
@type = "interruption_screen"
@check_answers_card_number = person_index
@answer_options = ANSWER_OPTIONS

3
app/models/form/lettings/questions/partner_under_16_value_check.rb

@ -2,7 +2,7 @@ class Form::Lettings::Questions::PartnerUnder16ValueCheck < ::Form::Question
def initialize(id, hsh, page, person_index:)
super(id, hsh, page)
@id = "partner_under_16_value_check"
@check_answer_label = "Partner under 16 confirmation"
@copy_key = "lettings.soft_validations.partner_under_16_value_check"
@type = "interruption_screen"
@answer_options = {
"0" => { "value" => "Yes" },
@ -19,6 +19,5 @@ class Form::Lettings::Questions::PartnerUnder16ValueCheck < ::Form::Question
],
}
@check_answers_card_number = person_index
@header = "Are you sure this is correct?"
end
end

3
app/models/form/lettings/questions/pregnancy_value_check.rb

@ -2,8 +2,7 @@ class Form::Lettings::Questions::PregnancyValueCheck < ::Form::Question
def initialize(id, hsh, page, person_index:)
super(id, hsh, page)
@id = "pregnancy_value_check"
@check_answer_label = "Pregnancy confirmation"
@header = "Are you sure this is correct?"
@copy_key = page.copy_key
@type = "interruption_screen"
@check_answers_card_number = person_index
@answer_options = ANSWER_OPTIONS

4
app/models/form/lettings/questions/pscharge_value_check.rb

@ -2,13 +2,11 @@ class Form::Lettings::Questions::PschargeValueCheck < ::Form::Question
def initialize(id, hsh, page)
super
@id = "pscharge_value_check"
@check_answer_label = "Personal service charge confirmation"
@header = "Are you sure?"
@copy_key = "lettings.soft_validations.pscharge_value_check"
@type = "interruption_screen"
@check_answers_card_number = 0
@answer_options = ANSWER_OPTIONS
@hidden_in_check_answers = { "depends_on" => [{ "pscharge_value_check" => 0 }, { "pscharge_value_check" => 1 }] }
@hint_text = I18n.t("soft_validations.charges.hint_text")
end
ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze

3
app/models/form/lettings/questions/reasonother_value_check.rb

@ -2,8 +2,7 @@ class Form::Lettings::Questions::ReasonotherValueCheck < ::Form::Question
def initialize(id, hsh, page)
super
@id = "reasonother_value_check"
@check_answer_label = "Reason other confirmation"
@header = "Are you sure this doesn’t fit an existing category?"
@copy_key = "lettings.soft_validations.reasonother_value_check"
@type = "interruption_screen"
@check_answers_card_number = 0
@answer_options = ANSWER_OPTIONS

3
app/models/form/lettings/questions/referral_value_check.rb

@ -2,8 +2,7 @@ class Form::Lettings::Questions::ReferralValueCheck < ::Form::Question
def initialize(id, hsh, page)
super
@id = "referral_value_check"
@check_answer_label = "Referral confirmation"
@header = "Are you sure?"
@copy_key = "lettings.soft_validations.referral_value_check"
@type = "interruption_screen"
@check_answers_card_number = 0
@answer_options = ANSWER_OPTIONS

4
app/models/form/lettings/questions/rent_value_check.rb

@ -2,10 +2,8 @@ class Form::Lettings::Questions::RentValueCheck < ::Form::Question
def initialize(id, hsh, page, check_answers_card_number:)
super(id, hsh, page)
@id = "rent_value_check"
@check_answer_label = "Total rent confirmation"
@header = "Are you sure this is correct?"
@copy_key = "lettings.soft_validations.rent_value_check"
@type = "interruption_screen"
@hint_text = I18n.t("soft_validations.rent.hint_text")
@check_answers_card_number = check_answers_card_number
@answer_options = ANSWER_OPTIONS
@hidden_in_check_answers = { "depends_on" => [{ "rent_value_check" => 0 }, { "rent_value_check" => 1 }] }

3
app/models/form/lettings/questions/retirement_value_check.rb

@ -2,8 +2,7 @@ class Form::Lettings::Questions::RetirementValueCheck < ::Form::Question
def initialize(id, hsh, page, person_index:)
super(id, hsh, page)
@id = "retirement_value_check"
@check_answer_label = "Retirement confirmation"
@header = "Are you sure this person isn’t retired?"
@copy_key = "lettings.soft_validations.retirement_value_check"
@type = "interruption_screen"
@check_answers_card_number = person_index
@answer_options = ANSWER_OPTIONS

4
app/models/form/lettings/questions/scharge_value_check.rb

@ -2,13 +2,11 @@ class Form::Lettings::Questions::SchargeValueCheck < ::Form::Question
def initialize(id, hsh, page)
super
@id = "scharge_value_check"
@check_answer_label = "Service charge confirmation"
@header = "Are you sure?"
@copy_key = "lettings.soft_validations.scharge_value_check"
@type = "interruption_screen"
@check_answers_card_number = 0
@answer_options = ANSWER_OPTIONS
@hidden_in_check_answers = { "depends_on" => [{ "scharge_value_check" => 0 }, { "scharge_value_check" => 1 }] }
@hint_text = I18n.t("soft_validations.charges.hint_text")
end
ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze

4
app/models/form/lettings/questions/supcharg_value_check.rb

@ -2,13 +2,11 @@ class Form::Lettings::Questions::SupchargValueCheck < ::Form::Question
def initialize(id, hsh, page)
super
@id = "supcharg_value_check"
@check_answer_label = "Support charge confirmation"
@header = "Are you sure?"
@copy_key = "lettings.soft_validations.supcharg_value_check"
@type = "interruption_screen"
@check_answers_card_number = 0
@answer_options = ANSWER_OPTIONS
@hidden_in_check_answers = { "depends_on" => [{ "supcharg_value_check" => 0 }, { "supcharg_value_check" => 1 }] }
@hint_text = I18n.t("soft_validations.charges.hint_text")
end
ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze

3
app/models/form/lettings/questions/void_date_value_check.rb

@ -2,8 +2,7 @@ class Form::Lettings::Questions::VoidDateValueCheck < ::Form::Question
def initialize(id, hsh, page)
super
@id = "void_date_value_check"
@check_answer_label = "Void date confirmation"
@header = "Are you sure the property has been vacant for this long?"
@copy_key = "lettings.soft_validations.void_date_value_check"
@type = "interruption_screen"
@check_answers_card_number = 0
@answer_options = ANSWER_OPTIONS

4
app/models/form/sales/subsections/setup.rb

@ -7,15 +7,15 @@ class Form::Sales::Subsections::Setup < ::Form::Subsection
def pages
@pages ||= [
Form::Sales::Pages::SaleDate.new(nil, nil, self),
Form::Sales::Pages::OwningOrganisation.new(nil, nil, self),
Form::Sales::Pages::ManagingOrganisation.new(nil, nil, self),
Form::Sales::Pages::CreatedBy.new(nil, nil, self),
Form::Sales::Pages::SaleDate.new(nil, nil, self),
Form::Sales::Pages::PurchaserCode.new(nil, nil, self),
Form::Sales::Pages::OwnershipScheme.new(nil, nil, self),
Form::Sales::Pages::SharedOwnershipType.new(nil, nil, self),
Form::Sales::Pages::DiscountedOwnershipType.new(nil, nil, self),
Form::Sales::Pages::OutrightOwnershipType.new(nil, nil, self),
(Form::Sales::Pages::OutrightOwnershipType.new(nil, nil, self) unless form.start_year_2025_or_later?),
Form::Sales::Pages::BuyerCompany.new(nil, nil, self),
Form::Sales::Pages::BuyerLive.new(nil, nil, self),
Form::Sales::Pages::JointPurchase.new(nil, nil, self),

6
app/models/lettings_log.rb

@ -508,12 +508,6 @@ class LettingsLog < Log
hb == 10
end
# Option 7 has been removed starting from 22/23
def receives_universal_credit_but_no_housing_benefit?
# 7: Universal Credit (without housing element)
hb == 7
end
def receives_housing_related_benefits?
if collection_start_year <= 2021
receives_housing_benefit_only? || receives_uc_with_housing_element_excl_housing_benefit? ||

2
app/models/user.rb

@ -19,7 +19,7 @@ class User < ApplicationRecord
validates :password, presence: { if: :password_required? }
validates :password, length: { within: Devise.password_length, allow_blank: true }
validates :password, confirmation: { if: :password_required? }
validates :phone_extension, format: { with: /\A\d+\z/, allow_blank: true, message: I18n.t("validations.numeric.format", field: "") }
validates :phone_extension, format: { with: /\A\d+\z/, allow_blank: true, message: I18n.t("validations.not_number", field: "") }
after_validation :send_data_protection_confirmation_reminder, if: :is_dpo_changed?

126
app/models/validations/financial_validations.rb

@ -6,8 +6,8 @@ module Validations::FinancialValidations
# or 'validate_' to run on submit as well
def validate_outstanding_rent_amount(record)
if !record.has_housing_benefit_rent_shortfall? && record.tshortfall.present?
record.errors.add :tshortfall, :no_outstanding_charges, message: I18n.t("validations.financial.tshortfall.outstanding_amount_not_expected")
record.errors.add :hbrentshortfall, :no_outstanding_charges, message: I18n.t("validations.financial.hbrentshortfall.outstanding_amount_not_expected")
record.errors.add :tshortfall, :no_outstanding_charges, message: I18n.t("validations.lettings.financial.tshortfall.outstanding_amount_not_expected")
record.errors.add :hbrentshortfall, :no_outstanding_charges, message: I18n.t("validations.lettings.financial.hbrentshortfall.outstanding_amount_not_expected")
end
end
@ -19,7 +19,7 @@ module Validations::FinancialValidations
relationship = record["relat#{n}"]
is_partner_or_main = relationship == "P" || (relationship.nil? && economic_status.present?)
if is_employed && is_partner_or_main && record.benefits&.zero?
record.errors.add :benefits, I18n.t("validations.financial.benefits.part_or_full_time")
record.errors.add :benefits, I18n.t("validations.lettings.financial.benefits.part_or_full_time")
end
end
end
@ -32,25 +32,25 @@ module Validations::FinancialValidations
record.errors.add(
:earnings,
:over_hard_max,
message: I18n.t("validations.financial.earnings.over_hard_max", hard_max:),
message: I18n.t("validations.lettings.financial.earnings.over_hard_max", hard_max:),
)
record.errors.add(
:hhmemb,
:over_hard_max,
message: I18n.t("validations.financial.hhmemb.earnings.over_hard_max", earnings: format_as_currency(record.earnings), frequency:),
message: I18n.t("validations.lettings.financial.hhmemb.earnings_over_hard_max", earnings: format_as_currency(record.earnings), frequency:),
)
(1..record.hhmemb).each do |n|
record.errors.add(
"ecstat#{n}",
:over_hard_max,
message: I18n.t("validations.financial.ecstat.over_hard_max", earnings: format_as_currency(record.earnings), frequency:),
message: I18n.t("validations.lettings.financial.ecstat.earnings_over_hard_max", earnings: format_as_currency(record.earnings), frequency:),
)
next unless record["ecstat#{n}"] == 9
record.errors.add(
"age#{n}",
:over_hard_max,
message: I18n.t("validations.financial.age.earnings_over_hard_max", earnings: format_as_currency(record.earnings), frequency:),
message: I18n.t("validations.lettings.financial.age.earnings_over_hard_max", earnings: format_as_currency(record.earnings), frequency:),
)
end
end
@ -61,18 +61,18 @@ module Validations::FinancialValidations
record.errors.add(
:earnings,
:under_hard_min,
message: I18n.t("validations.financial.earnings.under_hard_min", hard_min:),
message: I18n.t("validations.lettings.financial.earnings.under_hard_min", hard_min:),
)
record.errors.add(
:hhmemb,
:under_hard_min,
message: I18n.t("validations.financial.hhmemb.earnings.under_hard_min", earnings: format_as_currency(record.earnings), frequency:),
message: I18n.t("validations.lettings.financial.hhmemb.earnings_under_hard_min", earnings: format_as_currency(record.earnings), frequency:),
)
(1..record.hhmemb).each do |n|
record.errors.add(
"ecstat#{n}",
:under_hard_min,
message: I18n.t("validations.financial.ecstat.under_hard_min", earnings: format_as_currency(record.earnings), frequency:),
message: I18n.t("validations.lettings.financial.ecstat.earnings_under_hard_min", earnings: format_as_currency(record.earnings), frequency:),
)
# N.B. It is not possible for a change to an age field to increase the hard min
end
@ -80,69 +80,61 @@ module Validations::FinancialValidations
end
if record.earnings.present? && record.incfreq.blank?
record.errors.add :incfreq, I18n.t("validations.financial.earnings.freq_missing")
record.errors.add :earnings, I18n.t("validations.financial.earnings.freq_missing")
record.errors.add :incfreq, I18n.t("validations.lettings.financial.incfreq.incfreq_missing")
record.errors.add :earnings, I18n.t("validations.lettings.financial.earnings.incfreq_missing")
end
if record.incfreq.present? && record.earnings.blank?
record.errors.add :earnings, I18n.t("validations.financial.earnings.earnings_missing")
record.errors.add :incfreq, I18n.t("validations.financial.earnings.earnings_missing")
record.errors.add :earnings, I18n.t("validations.lettings.financial.earnings.earnings_missing")
record.errors.add :incfreq, I18n.t("validations.lettings.financial.incfreq.earnings_missing")
end
end
def validate_negative_currency(record)
t = %w[earnings brent scharge pscharge supcharg]
t.each do |x|
if record[x].present? && record[x].negative?
record.errors.add x.to_sym, I18n.t("validations.financial.negative_currency")
fields = %w[earnings brent scharge pscharge supcharg]
fields.each do |field|
if record[field].present? && record[field].negative?
record.errors.add field.to_sym, I18n.t("validations.lettings.financial.#{field}.negative_currency")
end
end
end
def validate_tshortfall(record)
if record.has_housing_benefit_rent_shortfall? && no_known_benefits?(record)
record.errors.add :tshortfall, I18n.t("validations.financial.hbrentshortfall.outstanding_no_benefits")
record.errors.add :tshortfall, I18n.t("validations.lettings.financial.tshortfall.outstanding_no_benefits")
end
end
def no_known_benefits?(record)
return true unless record.collection_start_year
if record.collection_start_year <= 2021
record.benefits_unknown? ||
record.receives_no_benefits? ||
record.receives_universal_credit_but_no_housing_benefit?
else
record.benefits_unknown? ||
record.receives_no_benefits? ||
record.tenant_refuses_to_say_benefits?
end
record.benefits_unknown? || record.receives_no_benefits? || record.tenant_refuses_to_say_benefits?
end
def validate_rent_amount(record)
if record.wtshortfall
if record.is_supported_housing? && record.wchchrg && (record.wtshortfall > record.wchchrg)
record.errors.add :tshortfall, message: I18n.t("validations.financial.tshortfall.more_than_carehome_charge")
record.errors.add :chcharge, I18n.t("validations.financial.carehome.less_than_shortfall")
record.errors.add :tshortfall, message: I18n.t("validations.lettings.financial.tshortfall.more_than_carehome_charge")
record.errors.add :chcharge, I18n.t("validations.lettings.financial.chcharge.less_than_shortfall")
end
if record.wtcharge && (record.wtshortfall > record.wtcharge)
record.errors.add :tshortfall, :more_than_rent, message: I18n.t("validations.financial.tshortfall.more_than_total_charge")
record.errors.add :tcharge, I18n.t("validations.financial.tcharge.less_than_shortfall")
record.errors.add :tshortfall, :more_than_rent, message: I18n.t("validations.lettings.financial.tshortfall.more_than_total_charge")
record.errors.add :tcharge, I18n.t("validations.lettings.financial.tcharge.less_than_shortfall")
elsif record.wtshortfall < 0.01
record.errors.add :tshortfall, :must_be_positive, message: I18n.t("validations.financial.tshortfall.must_be_positive")
record.errors.add :tshortfall, :must_be_positive, message: I18n.t("validations.lettings.financial.tshortfall.must_be_positive")
end
end
if record.tcharge.present? && weekly_value_in_range(record, "tcharge", 0, 9.99)
record.errors.add :tcharge, :under_10, message: I18n.t("validations.financial.tcharge.under_10")
record.errors.add :tcharge, :under_10, message: I18n.t("validations.lettings.financial.tcharge.under_10")
end
answered_questions = [record.tcharge, record.chcharge].concat(record.household_charge && record.household_charge == 1 ? [record.household_charge] : [])
if answered_questions.count(&:present?) > 1
record.errors.add :tcharge, :complete_1_of_3, message: I18n.t("validations.financial.charges.complete_1_of_3") if record.tcharge.present?
record.errors.add :chcharge, I18n.t("validations.financial.charges.complete_1_of_3") if record.chcharge.present?
record.errors.add :household_charge, I18n.t("validations.financial.charges.complete_1_of_3") if record.household_charge.present?
record.errors.add :tcharge, :complete_1_of_3, message: I18n.t("validations.lettings.financial.tcharge.complete_1_of_3") if record.tcharge.present?
record.errors.add :chcharge, I18n.t("validations.lettings.financial.chcharge.complete_1_of_3") if record.chcharge.present?
record.errors.add :household_charge, I18n.t("validations.lettings.financial.household_charge.complete_1_of_3") if record.household_charge.present?
end
validate_charges(record)
@ -154,12 +146,12 @@ module Validations::FinancialValidations
unless record.managing_organisation.rent_periods.include? record.period
record.errors.add :period, :wrong_rent_period, message: I18n.t(
"validations.financial.rent_period.invalid_for_org.period",
"validations.lettings.financial.period.invalid_period_for_org",
org_name: record.managing_organisation.name,
rent_period: record.form.get_question("period", record).label_from_value(record.period).downcase,
)
record.errors.add :managing_organisation_id, :skip_bu_error, message: I18n.t(
"validations.financial.rent_period.invalid_for_org.managing_org",
"validations.lettings.financial.managing_organisation_id.invalid_period_for_org",
org_name: record.managing_organisation.name,
rent_period: record.form.get_question("period", record).label_from_value(record.period).downcase,
)
@ -169,18 +161,12 @@ module Validations::FinancialValidations
def validate_care_home_charges(record)
if record.is_carehome?
period = record.form.get_question("period", record).label_from_value(record.period).downcase
# NOTE: This is a temporary change to allow `ccharge` values despite `is_carehome` being true. This value
# is going to be moved to a soft validation in CLDC-2074, so we can safely do this.
if record.chcharge.blank?
# record.errors.add :is_carehome, I18n.t("validations.financial.carehome.not_provided", period:)
# record.errors.add :chcharge, I18n.t("validations.financial.carehome.not_provided", period:)
elsif !weekly_value_in_range(record, "chcharge", 10, 5000)
if record.chcharge.present? && !weekly_value_in_range(record, "chcharge", 10, 5000)
max_chcharge = record.weekly_to_value_per_period(5000)
min_chcharge = record.weekly_to_value_per_period(10)
message = I18n.t("validations.financial.carehome.out_of_range", period:, min_chcharge:, max_chcharge:)
record.errors.add :period, message
record.errors.add :chcharge, :out_of_range, message:
record.errors.add :period, I18n.t("validations.lettings.financial.period.chcharge_out_of_range", period:, min_chcharge:, max_chcharge:)
record.errors.add :chcharge, :out_of_range, message: I18n.t("validations.lettings.financial.chcharge.out_of_range", period:, min_chcharge:, max_chcharge:)
end
end
end
@ -202,8 +188,8 @@ private
provider_type_label = PROVIDER_TYPE[provider_type].to_s.humanize(capitalize: false)
maximum_per_period = record.weekly_to_value_per_period(maximum_per_week)
record.errors.add charge, :outside_the_range, message: I18n.t("validations.financial.rent.out_of_range", charge_name:, maximum_per_period:, frequency:, letting_type:, provider_type: provider_type_label)
record.errors.add :period, :outside_the_range, message: I18n.t("validations.financial.rent.out_of_range", charge_name:, maximum_per_period:, frequency:, letting_type:, provider_type: provider_type_label)
record.errors.add charge, :outside_the_range, message: I18n.t("validations.lettings.financial.#{charge}.rent_out_of_range", charge_name:, maximum_per_period:, frequency:, letting_type:, provider_type: provider_type_label)
record.errors.add :period, :outside_the_range, message: I18n.t("validations.lettings.financial.period.rent_out_of_range", charge_name:, maximum_per_period:, frequency:, letting_type:, provider_type: provider_type_label)
end
end
@ -225,29 +211,29 @@ private
if rent_range.present? && !weekly_value_in_range(record, "brent", rent_range.hard_min, rent_range.hard_max) && record.brent.present? && record.period.present?
if record.weekly_value(record["brent"]) < rent_range.hard_min
record.errors.add :brent, :below_hard_min, message: I18n.t("validations.financial.brent.below_hard_min")
record.errors.add :beds, I18n.t("validations.financial.brent.beds.below_hard_min")
record.errors.add :uprn, I18n.t("validations.financial.brent.uprn.below_hard_min")
record.errors.add :la, I18n.t("validations.financial.brent.la.below_hard_min")
record.errors.add :postcode_known, I18n.t("validations.financial.brent.postcode_known.below_hard_min")
record.errors.add :scheme_id, I18n.t("validations.financial.brent.scheme_id.below_hard_min")
record.errors.add :location_id, I18n.t("validations.financial.brent.location_id.below_hard_min")
record.errors.add :rent_type, I18n.t("validations.financial.brent.rent_type.below_hard_min")
record.errors.add :needstype, I18n.t("validations.financial.brent.needstype.below_hard_min")
record.errors.add :period, I18n.t("validations.financial.brent.period.below_hard_min")
record.errors.add :brent, :below_hard_min, message: I18n.t("validations.lettings.financial.brent.below_hard_min")
record.errors.add :beds, I18n.t("validations.lettings.financial.beds.rent_below_hard_min")
record.errors.add :uprn, I18n.t("validations.lettings.financial.uprn.rent_below_hard_min")
record.errors.add :la, I18n.t("validations.lettings.financial.la.rent_below_hard_min")
record.errors.add :postcode_known, I18n.t("validations.lettings.financial.postcode_known.rent_below_hard_min")
record.errors.add :scheme_id, I18n.t("validations.lettings.financial.scheme_id.rent_below_hard_min")
record.errors.add :location_id, I18n.t("validations.lettings.financial.location_id.rent_below_hard_min")
record.errors.add :rent_type, I18n.t("validations.lettings.financial.rent_type.rent_below_hard_min")
record.errors.add :needstype, I18n.t("validations.lettings.financial.needstype.rent_below_hard_min")
record.errors.add :period, I18n.t("validations.lettings.financial.period.rent_below_hard_min")
end
if record.weekly_value(record["brent"]) > rent_range.hard_max
record.errors.add :brent, :over_hard_max, message: I18n.t("validations.financial.brent.above_hard_max")
record.errors.add :beds, I18n.t("validations.financial.brent.beds.above_hard_max")
record.errors.add :uprn, I18n.t("validations.financial.brent.uprn.above_hard_max")
record.errors.add :la, I18n.t("validations.financial.brent.la.above_hard_max")
record.errors.add :postcode_known, I18n.t("validations.financial.brent.postcode_known.above_hard_max")
record.errors.add :scheme_id, I18n.t("validations.financial.brent.scheme_id.above_hard_max")
record.errors.add :location_id, I18n.t("validations.financial.brent.location_id.above_hard_max")
record.errors.add :rent_type, I18n.t("validations.financial.brent.rent_type.above_hard_max")
record.errors.add :needstype, I18n.t("validations.financial.brent.needstype.above_hard_max")
record.errors.add :period, I18n.t("validations.financial.brent.period.above_hard_max")
record.errors.add :brent, :over_hard_max, message: I18n.t("validations.lettings.financial.brent.above_hard_max")
record.errors.add :beds, I18n.t("validations.lettings.financial.beds.rent_above_hard_max")
record.errors.add :uprn, I18n.t("validations.lettings.financial.uprn.rent_above_hard_max")
record.errors.add :la, I18n.t("validations.lettings.financial.la.rent_above_hard_max")
record.errors.add :postcode_known, I18n.t("validations.lettings.financial.postcode_known.rent_above_hard_max")
record.errors.add :scheme_id, I18n.t("validations.lettings.financial.scheme_id.rent_above_hard_max")
record.errors.add :location_id, I18n.t("validations.lettings.financial.location_id.rent_above_hard_max")
record.errors.add :rent_type, I18n.t("validations.lettings.financial.rent_type.rent_above_hard_max")
record.errors.add :needstype, I18n.t("validations.lettings.financial.needstype.rent_above_hard_max")
record.errors.add :period, I18n.t("validations.lettings.financial.period.rent_above_hard_max")
end
end
end

9
app/models/validations/household_validations.rb

@ -52,7 +52,14 @@ module Validations::HouseholdValidations
end
def validate_partner_count(record)
shared_validate_partner_count(record, 8)
return if record.form.start_year_2024_or_later?
partner_numbers = (2..8).select { |n| person_is_partner?(record["relat#{n}"]) }
if partner_numbers.count > 1
partner_numbers.each do |n|
record.errors.add "relat#{n}", I18n.t("validations.lettings.household.relat.one_partner")
end
end
end
def validate_person_1_economic(record)

8
app/models/validations/property_validations.rb

@ -57,4 +57,12 @@ module Validations::PropertyValidations
record.errors.add :uprn, I18n.t("validations.property.uprn.invalid")
end
def validate_property_postcode(record)
postcode = record.postcode_full
if record.postcode_known? && (postcode.blank? || !postcode.match(POSTCODE_REGEXP))
error_message = I18n.t("validations.lettings.property_information.postcode_full.invalid")
record.errors.add :postcode_full, :wrong_format, message: error_message
end
end
end

9
app/models/validations/sales/household_validations.rb

@ -2,7 +2,14 @@ module Validations::Sales::HouseholdValidations
include Validations::SharedValidations
def validate_partner_count(record)
shared_validate_partner_count(record, 6)
return if record.form.start_year_2024_or_later?
partner_numbers = (2..6).select { |n| person_is_partner?(record["relat#{n}"]) }
if partner_numbers.count > 1
partner_numbers.each do |n|
record.errors.add "relat#{n}", I18n.t("validations.sales.household.relat.one_partner")
end
end
end
def validate_buyers_living_in_property(record)

8
app/models/validations/sales/property_validations.rb

@ -28,4 +28,12 @@ module Validations::Sales::PropertyValidations
record.errors.add :uprn, I18n.t("validations.sales.property_information.uprn.invalid")
end
def validate_property_postcode(record)
postcode = record.postcode_full
if record.postcode_known? && (postcode.blank? || !postcode.match(POSTCODE_REGEXP))
error_message = I18n.t("validations.sales.property_information.postcode_full.invalid")
record.errors.add :postcode_full, :wrong_format, message: error_message
end
end
end

8
app/models/validations/sales/setup_validations.rb

@ -58,6 +58,14 @@ module Validations::Sales::SetupValidations
end
end
def validate_owning_organisation_data_sharing_agremeent_signed(record)
return if record.skip_dpo_validation
if record.owning_organisation_id_changed? && record.owning_organisation.present? && !record.owning_organisation.data_protection_confirmed?
record.errors.add :owning_organisation_id, I18n.t("validations.sales.setup.owning_organisation.data_sharing_agreement_not_signed")
end
end
private
def active_collection_start_date

49
app/models/validations/setup_validations.rb

@ -72,17 +72,15 @@ module Validations::SetupValidations
end
end
def validate_scheme_has_confirmed_locations_validation(record)
def validate_scheme(record)
return unless record.scheme
unless record.scheme.locations.confirmed.any?
record.errors.add :scheme_id, :no_completed_locations, message: I18n.t("validations.lettings.setup.scheme.no_completed_locations")
if record.scheme.status == :incomplete
record.errors.add :scheme_id, :incomplete, message: I18n.t("validations.lettings.setup.scheme.incomplete")
end
end
def validate_scheme(record)
if record.scheme&.status == :incomplete
record.errors.add :scheme_id, :incomplete, message: I18n.t("validations.lettings.setup.scheme.incomplete")
if record.scheme.locations.nil? || (record.scheme.locations.present? && record.scheme.locations.confirmed.none?)
record.errors.add :scheme_id, :no_completed_locations, message: I18n.t("validations.lettings.setup.scheme.no_completed_locations")
end
scheme_during_startdate_validation(record)
@ -98,6 +96,35 @@ module Validations::SetupValidations
end
end
def location_during_startdate_validation(record)
location_inactive_status = inactive_status(record.startdate, record.location)
if location_inactive_status.present?
date, scope, deactivation_date = location_inactive_status.values_at(:date, :scope, :deactivation_date)
record.errors.add :startdate, :not_active, message: I18n.t("validations.lettings.setup.startdate.location.#{scope}.startdate", postcode: record.location.postcode, date:, deactivation_date:)
record.errors.add :location_id, :not_active, message: I18n.t("validations.lettings.setup.startdate.location.#{scope}.location_id", postcode: record.location.postcode, date:, deactivation_date:)
record.errors.add :scheme_id, :not_active, message: I18n.t("validations.lettings.setup.startdate.location.#{scope}.location_id", postcode: record.location.postcode, date:, deactivation_date:)
end
end
def scheme_during_startdate_validation(record)
scheme_inactive_status = inactive_status(record.startdate, record.scheme)
if scheme_inactive_status.present?
date, scope, deactivation_date = scheme_inactive_status.values_at(:date, :scope, :deactivation_date)
record.errors.add :startdate, I18n.t("validations.lettings.setup.startdate.scheme.#{scope}.startdate", name: record.scheme.service_name, date:, deactivation_date:)
record.errors.add :scheme_id, I18n.t("validations.lettings.setup.startdate.scheme.#{scope}.scheme_id", name: record.scheme.service_name, date:, deactivation_date:)
end
end
def tenancy_startdate_with_scheme_locations(record)
return if record.scheme.blank? || record.startdate.blank?
return if record.scheme.has_active_locations_on_date?(record.startdate)
record.errors.add :startdate, I18n.t("validations.lettings.setup.startdate.scheme.locations_inactive.startdate", name: record.scheme.service_name)
record.errors.add :scheme_id, I18n.t("validations.lettings.setup.startdate.scheme.locations_inactive.scheme_id", name: record.scheme.service_name)
end
def validate_managing_organisation_data_sharing_agremeent_signed(record)
return if record.skip_dpo_validation
@ -106,6 +133,14 @@ module Validations::SetupValidations
end
end
def validate_owning_organisation_data_sharing_agremeent_signed(record)
return if record.skip_dpo_validation
if record.owning_organisation_id_changed? && record.owning_organisation.present? && !record.owning_organisation.data_protection_confirmed?
record.errors.add :owning_organisation_id, I18n.t("validations.lettings.setup.owning_organisation.data_sharing_agreement_not_signed")
end
end
private
def active_collection_start_date

80
app/models/validations/shared_validations.rb

@ -7,12 +7,12 @@ module Validations::SharedValidations
main_field_label = main_label || main_field.to_s.humanize(capitalize: false)
other_field_label = other_label || other_field.to_s.humanize(capitalize: false)
if record[main_field] == value_other && record[other_field].blank?
record.errors.add main_field.to_sym, I18n.t("validations.other_field_missing", main_field_label:, other_field_label:)
record.errors.add other_field.to_sym, I18n.t("validations.other_field_missing", main_field_label:, other_field_label:)
record.errors.add main_field.to_sym, I18n.t("validations.shared.other_field_missing", main_field_label:, other_field_label:)
record.errors.add other_field.to_sym, I18n.t("validations.shared.other_field_missing", main_field_label:, other_field_label:)
end
if record[main_field] != value_other && record[other_field].present?
record.errors.add other_field.to_sym, I18n.t("validations.other_field_not_required", main_field_label:, other_field_label:)
record.errors.add other_field.to_sym, I18n.t("validations.shared.other_field_not_required", main_field_label:, other_field_label:)
end
end
@ -22,7 +22,7 @@ module Validations::SharedValidations
next if record.send("#{question.id}_before_type_cast").to_s.match?(/\A\d+(\.\d+)?\z/)
field = question.check_answer_label || question.id
record.errors.add question.id.to_sym, I18n.t("validations.numeric.format", field:)
record.errors.add question.id.to_sym, I18n.t("validations.shared.numeric.format", field:)
end
end
@ -55,46 +55,17 @@ module Validations::SharedValidations
incorrect_accuracy = (value.to_d * 100) % (question.step * 100) != 0
if question.step < 1 && incorrect_accuracy
record.errors.add question.id.to_sym, I18n.t("validations.numeric.nearest_hundredth", field:)
record.errors.add question.id.to_sym, I18n.t("validations.shared.numeric.nearest_hundredth", field:)
elsif incorrect_accuracy || value.to_d != value.to_i # if the user enters a value in exponent notation (eg '4e1') the to_i method does not convert this to the correct value
field = question.check_answer_label || question.id
case question.step
when 1 then record.errors.add question.id.to_sym, :not_integer, message: I18n.t("validations.numeric.whole_number", field:)
when 10 then record.errors.add question.id.to_sym, I18n.t("validations.numeric.nearest_ten", field:)
when 1 then record.errors.add question.id.to_sym, :not_integer, message: I18n.t("validations.shared.numeric.whole_number", field:)
when 10 then record.errors.add question.id.to_sym, I18n.t("validations.shared.numeric.nearest_ten", field:)
end
end
end
end
def validate_property_postcode(record)
postcode = record.postcode_full
if record.postcode_known? && (postcode.blank? || !postcode.match(POSTCODE_REGEXP))
error_message = I18n.t("validations.postcode")
record.errors.add :postcode_full, :wrong_format, message: error_message
end
end
def location_during_startdate_validation(record)
location_inactive_status = inactive_status(record.startdate, record.location)
if location_inactive_status.present?
date, scope, deactivation_date = location_inactive_status.values_at(:date, :scope, :deactivation_date)
record.errors.add :startdate, :not_active, message: I18n.t("validations.setup.startdate.location.#{scope}.startdate", postcode: record.location.postcode, date:, deactivation_date:)
record.errors.add :location_id, :not_active, message: I18n.t("validations.setup.startdate.location.#{scope}.location_id", postcode: record.location.postcode, date:, deactivation_date:)
record.errors.add :scheme_id, :not_active, message: I18n.t("validations.setup.startdate.location.#{scope}.location_id", postcode: record.location.postcode, date:, deactivation_date:)
end
end
def scheme_during_startdate_validation(record)
scheme_inactive_status = inactive_status(record.startdate, record.scheme)
if scheme_inactive_status.present?
date, scope, deactivation_date = scheme_inactive_status.values_at(:date, :scope, :deactivation_date)
record.errors.add :startdate, I18n.t("validations.setup.startdate.scheme.#{scope}.startdate", name: record.scheme.service_name, date:, deactivation_date:)
record.errors.add :scheme_id, I18n.t("validations.setup.startdate.scheme.#{scope}.scheme_id", name: record.scheme.service_name, date:, deactivation_date:)
end
end
def inactive_status(date, resource)
return if date.blank? || resource.blank?
@ -117,46 +88,15 @@ module Validations::SharedValidations
{ scope: status, date: date&.to_formatted_s(:govuk_date), deactivation_date: closest_reactivation&.deactivation_date&.to_formatted_s(:govuk_date) }
end
def tenancy_startdate_with_scheme_locations(record)
return if record.scheme.blank? || record.startdate.blank?
return if record.scheme.has_active_locations_on_date?(record.startdate)
record.errors.add :startdate, I18n.t("validations.setup.startdate.scheme.locations_inactive.startdate", name: record.scheme.service_name)
record.errors.add :scheme_id, I18n.t("validations.setup.startdate.scheme.locations_inactive.scheme_id", name: record.scheme.service_name)
end
def shared_validate_partner_count(record, max_people)
return if record.form.start_year_2024_or_later?
partner_numbers = (2..max_people).select { |n| person_is_partner?(record["relat#{n}"]) }
if partner_numbers.count > 1
partner_numbers.each do |n|
if record.sales?
record.errors.add "relat#{n}", I18n.t("validations.sales.household.relat.one_partner")
else
record.errors.add "relat#{n}", I18n.t("validations.household.relat.one_partner")
end
end
end
end
def date_valid?(question, record)
if record[question].is_a?(ActiveSupport::TimeWithZone) && record[question].year.zero?
record.errors.add question, I18n.t("validations.date.invalid_date")
record.errors.add question, I18n.t("validations.shared.date.invalid_date")
false
else
true
end
end
def validate_owning_organisation_data_sharing_agremeent_signed(record)
return if record.skip_dpo_validation
if record.owning_organisation_id_changed? && record.owning_organisation.present? && !record.owning_organisation.data_protection_confirmed?
record.errors.add :owning_organisation_id, I18n.t("validations.setup.owning_organisation.data_sharing_agreement_not_signed")
end
end
private
def person_is_partner?(relationship)
@ -169,9 +109,9 @@ private
max = [question.prefix, number_with_delimiter(question.max, delimiter: ","), question.suffix].join("") if question.max
if min && max
record.errors.add question.id.to_sym, :outside_the_range, message: I18n.t("validations.numeric.within_range", field:, min:, max:)
record.errors.add question.id.to_sym, :outside_the_range, message: I18n.t("validations.shared.numeric.within_range", field:, min:, max:)
elsif min
record.errors.add question.id.to_sym, :under_min, message: I18n.t("validations.numeric.above_min", field:, min:)
record.errors.add question.id.to_sym, :under_min, message: I18n.t("validations.shared.numeric.above_min", field:, min:)
end
end
end

4
config/forms/2021_2022.json

@ -7411,10 +7411,10 @@
}
],
"title_text": {
"translation": "soft_validations.net_income.title_text"
"translation": "forms.2024.lettings.soft_validations.net_income_value_check.title_text"
},
"informative_text": {
"translation": "soft_validations.net_income.hint_text",
"translation": "forms.2024.lettings.soft_validations.net_income_value_check.informative_text",
"arguments": [
{
"key": "ecstat1",

4
config/forms/2022_2023.json

@ -7870,7 +7870,7 @@
}
],
"title_text": {
"translation": "soft_validations.net_income.title_text",
"translation": "forms.2024.lettings.soft_validations.net_income_value_check.title_text",
"arguments": [
{
"key": "incfreq",
@ -7885,7 +7885,7 @@
]
},
"informative_text": {
"translation": "soft_validations.net_income.hint_text",
"translation": "forms.2024.lettings.soft_validations.net_income_value_check.informative_text",
"arguments": [
{
"key": "net_income_higher_or_lower_text",

147
config/locales/en.yml

@ -239,23 +239,12 @@ en:
merged: "That organisation has already been merged. Select a different organisation."
scheme_duplicates_not_resolved: "You must resolve all duplicates or indicate that there are no duplicates"
not_answered: "You must answer %{question}"
not_number: "%{field} must be a number."
invalid_option: "Enter a valid value for %{question}"
invalid_number: "Enter a number for %{question}"
no_address_found: "We could not find this address. Check the address data in your CSV file is correct and complete, or select the correct address using the CORE site."
other_field_missing: "If %{main_field_label} is other then %{other_field_label} must be provided."
other_field_not_required: "%{other_field_label} must not be provided if %{main_field_label} was not other."
numeric:
within_range: "%{field} must be between %{min} and %{max}."
above_min: "%{field} must be at least %{min}."
whole_number: "%{field} must be a whole number."
nearest_ten: "%{field} must be given to the nearest ten."
nearest_hundredth: "%{field} must be given to the nearest hundredth."
normal_format: "Enter a number."
format: "%{field} must be a number."
date:
invalid_date: "Enter a date in the correct format, for example 31 1 2024."
outside_collection_window: "Enter a date within the %{year_combo} collection year, which is between 1st April %{start_year} and 31st March %{end_year}."
postcode: "Enter a postcode in the correct format, for example AA1 1AA."
location_admin_district: "Select a local authority."
@ -271,29 +260,8 @@ en:
year_not_two_or_four_digits: "Sale completion year must be 2 or 4 digits."
type:
percentage_bought_must_be_at_least_threshold: "The minimum increase in equity while staircasing is %{threshold}% for this shared ownership type."
startdate:
before_scheme_end_date: "The tenancy start date must be before the end date for this supported housing scheme."
location:
deactivated:
startdate: "The location %{postcode} is inactive on this date. Enter another date or choose another location."
location_id: "This location is not active on the tenancy start date. Choose another location or edit the tenancy start date."
activating_soon:
startdate: "The location %{postcode} is not available until %{date}. Enter a tenancy start date after %{date}."
location_id: "The location %{postcode} is not available until %{date}. Select another location or edit the tenancy start date."
reactivating_soon:
startdate: "The location %{postcode} is not available until %{date}. Enter a tenancy start date after %{date}."
location_id: "The location %{postcode} is not available until %{date}. Select another location or edit the tenancy start date."
scheme:
deactivated:
startdate: "The scheme %{name} was deactivated on %{date} and was not available on the day you entered. Select another scheme or edit the tenancy start date."
scheme_id: "The scheme %{name} was deactivated on %{date} and was not available on the day you entered. Select another scheme or edit the tenancy start date."
reactivating_soon:
startdate: "The scheme %{name} is not available until %{date}. Enter a tenancy start date after %{date}."
scheme_id: "The scheme %{name} is not available until %{date}. Select another scheme or edit the tenancy start date."
locations_inactive:
startdate: "The scheme %{name} has no locations that are active on this date. Enter another date or choose another scheme."
scheme_id: "The scheme %{name} has no locations that are active on this date. Enter another date or choose another scheme."
owning_organisation:
data_sharing_agreement_not_signed: "The organisation must accept the Data Sharing Agreement before it can be selected as the owning organisation."
property:
@ -317,83 +285,16 @@ en:
one_three_bedroom_single_tenant_shared: "A shared house with fewer than two tenants must have 1 to 3 bedrooms."
financial:
tshortfall:
outstanding_amount_not_expected: "You cannot answer the outstanding amount question if you don’t have outstanding rent or charges."
more_than_total_charge: "Enter a value less than the total charge."
more_than_carehome_charge: "Enter a value less than the care home charge."
must_be_positive: "Enter a value over £0.01 as you told us there is an outstanding amount."
hbrentshortfall:
outstanding_amount_not_expected: "Answer must be ‘yes’ as you have answered the outstanding amount question."
outstanding_no_benefits: "Answer cannot be ‘yes’ to outstanding amount for basic rent or charges if tenant does not receive housing benefit or Universal Credit or you‘re not sure."
benefits:
part_or_full_time: "Answer cannot be ‘all’ for income from Universal Credit, state pensions or benefits if the tenant or their partner works part-time or full-time."
earnings:
over_hard_max: "The household’s income cannot be greater than %{hard_max} per week given the household’s working situation."
under_hard_min: "The household’s income cannot be less than %{hard_min} per week given the household’s working situation."
freq_missing: "Select how often the household receives income."
earnings_missing: "Enter how much income the household has in total."
income:
outside_london_income_range: "Income must be between £0 and £90,000 for properties within a London local authority."
outside_non_london_income_range: "Income must be between £0 and £80,000 for properties in a non-London local authority."
combined_over_hard_max_for_london: "Combined income must be £90,000 or lower for properties within a London local authority."
combined_over_hard_max_for_outside_london: "Combined income must be £80,000 or lower for properties outside London local authorities."
child_has_income: "Child's income must be £0."
negative_currency: "Enter an amount above 0."
rent:
out_of_range: "Enter a value for the %{charge_name} between £0 and %{maximum_per_period} paid %{frequency}. %{maximum_per_period} is the max limit for rent and charges paid %{frequency} for %{letting_type} lettings owned by a %{provider_type}."
ecstat:
over_hard_max: "The household’s income of %{earnings} %{frequency} is too high given the household’s working situation."
under_hard_min: "The household’s income of %{earnings} %{frequency} is too low given the household’s working situation."
age:
earnings_over_hard_max: "The household’s income of %{earnings} %{frequency} is too high for the number of adults. Change either the household income or the age of the tenants."
hhmemb:
earnings:
over_hard_max: "The household’s income of %{earnings} %{frequency} is too high for this number of tenants. Change either the household income or number of tenants."
under_hard_min: "The household’s income of %{earnings} %{frequency} is too low for this number of tenants. Change either the household income or number of tenants."
brent:
below_hard_min: "Rent is below the absolute minimum expected for a property of this type. Please check the rent, rent period, local authority and (if general needs) number of bedrooms."
above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type. Please check the rent, rent period, local authority and (if general needs) number of bedrooms."
scheme_id:
below_hard_min: "Rent is below the absolute minimum expected for a property of this type. Please check the rent, rent period and local authority."
above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type. Please check the rent, rent period and local authority."
location_id:
below_hard_min: "Rent is below the absolute minimum expected for a property of this type. Please check the rent, rent period and local authority."
above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type. Please check the rent, rent period and local authority."
postcode_known:
below_hard_min: "Rent is below the absolute minimum expected for a property of this type. Please check the rent, rent period, local authority and number of bedrooms."
above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type. Please check the rent, rent period, local authority and number of bedrooms."
uprn:
below_hard_min: "Rent is below the absolute minimum expected for a property of this type based on this UPRN."
above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type based on this UPRN."
la:
below_hard_min: "Rent is below the absolute minimum expected for a property of this type based on this local authority."
above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type based on this local authority."
beds:
below_hard_min: "Rent is below the absolute minimum expected for a property of this type based on this number of bedrooms."
above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type based on this number of bedrooms."
needstype:
below_hard_min: "Rent is below the absolute minimum expected for a property of this type based on this lettings type."
above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type based on this lettings type."
rent_type:
below_hard_min: "Rent is below the absolute minimum expected for a property of this type based on this lettings type."
above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type based on this lettings type."
period:
below_hard_min: "Rent is below the absolute minimum expected for a property of this type based on this period."
above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type based on this period."
charges:
complete_1_of_3: "Answer either the ‘household rent and charges’ question or ‘is this accommodation a care home‘, or select ‘no’ for ‘does the household pay rent or charges for the accommodation?’"
missing_charges: "Please enter the %{sentence_fragment}. If there is no %{sentence_fragment}, please enter '0'."
tcharge:
under_10: "Enter a total charge that is at least £10.00 per week."
less_than_shortfall: "The total charge must be more than the outstanding amount."
rent_period:
invalid_for_org:
period: "%{org_name} does not use %{rent_period} as a rent period. Choose another rent period, or a data coordinator can add rent periods to your organisation."
managing_org: "%{org_name} does not use %{rent_period} as a rent period. Set another rent period on this log, or a data coordinator can add rent periods to this organisation."
carehome:
out_of_range: "Household rent and other charges must be between %{min_chcharge} and %{max_chcharge} if paying %{period}."
not_provided: "Enter how much rent and other charges the household pays %{period}."
less_than_shortfall: "The care home charge must be more than the outstanding amount."
cash_discount_invalid: "Cash discount must be £0 - £999,999."
staircasing:
percentage_bought_must_be_greater_than_percentage_owned: "Total percentage %{buyer_now_owns} must be more than percentage bought in this transaction."
@ -451,7 +352,6 @@ en:
cannot_be_student: "Person cannot be a student if they are aged 16-19 but are not a child."
relat:
child_under_16_lettings: "Answer cannot be ‘partner’ as you told us person %{person_num}'s age is under 16."
one_partner: "Number of partners cannot be greater than 1."
not_student_16_19: "Answer cannot be ‘child’ as you told us the person %{person_num} is between 16 and 19 and is not a full-time student."
student_16_19:
cannot_be_child:
@ -553,17 +453,6 @@ en:
organisation_not_selected: "Select an organisation from the search list."
soft_validations:
net_income:
title_text: "You told us that the household’s income is %{earnings} %{incfreq}."
hint_text: "This is %{net_income_higher_or_lower_text} than we would expect for the household’s working situation."
in_soft_min_range:
message: "Net income is lower than expected based on the household’s working situation. Are you sure this is correct?"
in_soft_max_range:
message: "Net income is higher than expected based on the household’s working situation. Are you sure this is correct?"
rent:
outside_range_title: "You told us the rent is %{brent}."
informative_text: "This is %{higher_or_lower} than we would expect."
hint_text: "Check the following:<ul class=\"govuk-body-l app-panel--interruption\"><li>the decimal point</li><li>the frequency, for example every week or every calendar month</li><li>the rent type is correct, for example affordable or social rent</li></ul>"
retirement:
min:
title: "You told us this person is aged %{age} years and retired."
@ -571,40 +460,6 @@ en:
max:
title: "You told us this person is over 66 and not retired."
hint_text: "The minimum expected retirement age in England is 66."
pregnancy:
title: "You told us somebody in the household is pregnant."
all_male_tenants: "You also told us that all the tenants living at the property are male."
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>under 16 years old</li><li>over 50 years old</li></ul>"
major_repairs_date:
title_text: "You told us the property has been vacant for 2 years."
hint_text: "This is higher than we would expect."
void_date:
title_text: "You told us that the property has been vacant for more than 2 years."
hint_text: "This is higher than we would expect."
referral:
title_text: "Are you sure?"
hint_text: "This is a general needs log, and this referral type is for supported housing."
scharge:
over_soft_max_title: "You told us the service charge is %{scharge}."
pscharge:
over_soft_max_title: "You told us the personal service charge is %{pscharge}."
supcharg:
over_soft_max_title: "You told us the support charge is %{supcharg}."
charges:
informative_text: "This is higher than we would expect."
hint_text: "Check the following:<ul class=\"govuk-body-l app-panel--interruption\"><li>the decimal point</li><li>the frequency, for example every week or every calendar month</li><li>the needs type</li></ul>"
reasonother:
title_text: "You told us that the tenant’s main reason for leaving their last settled home was %{reasonother}."
informative_text: "The reason you have entered looks very similar to one of the existing response categories.
Please check the categories and select the appropriate one.
If the existing categories are not suitable, please confirm here to move onto the next question."
saledate:
must_be_less_than_3_years_from_hodate: "You told us sale completion date is more than 3 years after practical completion or handover date."
partner_under_16_lettings:
title: "You told us this person is aged %{age} years and has 'Partner' relationship to the lead tenant."
multiple_partners_lettings:
title: "You told us there are more than 1 persons with 'Partner' relationship to the lead tenant."
devise:
two_factor_authentication:
success: "Two-factor authentication successful."

132
config/locales/forms/2023/lettings/soft_validations.en.yml

@ -0,0 +1,132 @@
en:
forms:
2023:
lettings:
soft_validations:
pregnancy_value_check:
no_females_pregnant_household_value_check:
page_header: ""
check_answer_label: "Pregnancy confirmation"
hint_text: ""
question_text: "Are you sure this is correct?"
title_text: "You told us somebody in the household is pregnant."
informative_text: "You also told us that all the tenants living at the property are male."
females_in_soft_age_range_in_pregnant_household_value_check:
page_header: ""
check_answer_label: "Pregnancy confirmation"
hint_text: ""
question_text: "Are you sure this is correct?"
title_text: "You told us somebody in the household is pregnant."
informative_text: "You also told us that any female tenants living at the property are in the following age ranges:<ul class=\"govuk-body-l app-panel--interruption\"><li>under 16 years old</li><li>over 50 years old</li></ul>"
no_retirement_value_check:
page_header: ""
check_answer_label: "Retirement confirmation"
hint_text: ""
question_text: "Are you sure this person is retired?"
title_text: "You told us this person is aged %{age} years and retired."
informative_text: "The minimum expected retirement age in England is 66."
retirement_value_check:
page_header: ""
check_answer_label: "Retirement confirmation"
hint_text: ""
question_text: "Are you sure this person isn’t retired?"
title_text: "You told us this person is over 66 and not retired."
informative_text: ""
partner_under_16_value_check:
page_header: ""
check_answer_label: "Partner under 16 confirmation"
hint_text: ""
question_text: "Are you sure this is correct?"
title_text: "You told us this person is aged %{age} years and has 'Partner' relationship to the lead tenant."
informative_text: "Are you sure this is correct?"
multiple_partners_value_check:
page_header: ""
check_answer_label: "Multiple partners confirmation"
hint_text: ""
question_text: "Are you sure this is correct?"
title_text: "You told us there are more than 1 persons with 'Partner' relationship to the lead tenant."
informative_text: "Are you sure this is correct?"
reasonother_value_check:
page_header: ""
check_answer_label: "Reason other confirmation"
hint_text: ""
question_text: "Are you sure this doesn’t fit an existing category?"
title_text: "You told us that the tenant’s main reason for leaving their last settled home was %{reasonother}."
informative_text: "The reason you have entered looks very similar to one of the existing response categories. Please check the categories and select the appropriate one. If the existing categories are not suitable, please confirm here to move onto the next question."
referral_value_check:
page_header: ""
check_answer_label: "Referral confirmation"
hint_text: ""
question_text: "Are you sure?"
title_text: "Are you sure?"
informative_text: "This is a general needs log, and this referral type is for supported housing."
net_income_value_check:
page_header: ""
check_answer_label: "Net income confirmation"
hint_text: ""
question_text: "Are you sure this is correct?"
title_text: "You told us that the household’s income is %{earnings} %{incfreq}."
informative_text: "This is %{net_income_higher_or_lower_text} than we would expect for the household’s working situation."
care_home_charges_value_check:
page_header: ""
check_answer_label: "Care home charges confirmation"
hint_text: ""
question_text: "Are you sure there are no care home charges?"
title_text: "Care home charges should be provided if this is a care home accommodation."
informative_text: "Are you sure there are no care home charges?"
rent_value_check:
page_header: ""
check_answer_label: "Total rent confirmation"
hint_text: "Check the following:<ul class=\"govuk-body-l app-panel--interruption\"><li>the decimal point</li><li>the frequency, for example every week or every calendar month</li><li>the rent type is correct, for example affordable or social rent</li></ul>"
question_text: "Are you sure this is correct?"
title_text: "You told us the rent is %{brent}."
informative_text: "This is %{higher_or_lower} than we would expect."
scharge_value_check:
page_header: ""
check_answer_label: "Service charge confirmation"
hint_text: "Check the following:<ul class=\"govuk-body-l app-panel--interruption\"><li>the decimal point</li><li>the frequency, for example every week or every calendar month</li><li>the needs type</li></ul>"
question_text: "Are you sure?"
title_text: "You told us the service charge is %{scharge}."
informative_text: "This is higher than we would expect."
pscharge_value_check:
page_header: ""
check_answer_label: "Personal service charge confirmation"
hint_text: "Check the following:<ul class=\"govuk-body-l app-panel--interruption\"><li>the decimal point</li><li>the frequency, for example every week or every calendar month</li><li>the needs type</li></ul>"
question_text: "Are you sure?"
title_text: "You told us the personal service charge is %{pscharge}."
informative_text: "This is higher than we would expect."
supcharg_value_check:
page_header: ""
check_answer_label: "Support charge confirmation"
hint_text: "Check the following:<ul class=\"govuk-body-l app-panel--interruption\"><li>the decimal point</li><li>the frequency, for example every week or every calendar month</li><li>the needs type</li></ul>"
question_text: "Are you sure?"
title_text: "You told us the support charge is %{supcharg}."
informative_text: "This is higher than we would expect."
void_date_value_check:
page_header: ""
check_answer_label: "Void date confirmation"
hint_text: ""
question_text: "Are you sure the property has been vacant for this long?"
title_text: "You told us that the property has been vacant for more than 2 years."
informative_text: "This is higher than we would expect."
major_repairs_date_value_check:
page_header: ""
check_answer_label: "Major repairs date confirmation"
hint_text: ""
question_text: "Are you sure the property has been vacant for this long?"
title_text: "You told us the property has been vacant for 2 years."
informative_text: "This is higher than we would expect."

132
config/locales/forms/2024/lettings/soft_validations.en.yml

@ -0,0 +1,132 @@
en:
forms:
2024:
lettings:
soft_validations:
pregnancy_value_check:
no_females_pregnant_household_value_check:
page_header: ""
check_answer_label: "Pregnancy confirmation"
hint_text: ""
question_text: "Are you sure this is correct?"
title_text: "You told us somebody in the household is pregnant."
informative_text: "You also told us that all the tenants living at the property are male."
females_in_soft_age_range_in_pregnant_household_value_check:
page_header: ""
check_answer_label: "Pregnancy confirmation"
hint_text: ""
question_text: "Are you sure this is correct?"
title_text: "You told us somebody in the household is pregnant."
informative_text: "You also told us that any female tenants living at the property are in the following age ranges:<ul class=\"govuk-body-l app-panel--interruption\"><li>under 16 years old</li><li>over 50 years old</li></ul>"
no_retirement_value_check:
page_header: ""
check_answer_label: "Retirement confirmation"
hint_text: ""
question_text: "Are you sure this person is retired?"
title_text: "You told us this person is aged %{age} years and retired."
informative_text: "The minimum expected retirement age in England is 66."
retirement_value_check:
page_header: ""
check_answer_label: "Retirement confirmation"
hint_text: ""
question_text: "Are you sure this person isn’t retired?"
title_text: "You told us this person is over 66 and not retired."
informative_text: "Are you sure this person isn’t retired?"
partner_under_16_value_check:
page_header: ""
check_answer_label: "Partner under 16 confirmation"
hint_text: ""
question_text: "Are you sure this is correct?"
title_text: "You told us this person is aged %{age} years and has 'Partner' relationship to the lead tenant."
informative_text: "Are you sure this is correct?"
multiple_partners_value_check:
page_header: ""
check_answer_label: "Multiple partners confirmation"
hint_text: ""
question_text: "Are you sure this is correct?"
title_text: "You told us there are more than 1 persons with 'Partner' relationship to the lead tenant."
informative_text: "Are you sure this is correct?"
reasonother_value_check:
page_header: ""
check_answer_label: "Reason other confirmation"
hint_text: ""
question_text: "Are you sure this doesn’t fit an existing category?"
title_text: "You told us that the tenant’s main reason for leaving their last settled home was %{reasonother}."
informative_text: "The reason you have entered looks very similar to one of the existing response categories. Please check the categories and select the appropriate one. If the existing categories are not suitable, please confirm here to move onto the next question."
referral_value_check:
page_header: ""
check_answer_label: "Referral confirmation"
hint_text: ""
question_text: "Are you sure?"
title_text: "Are you sure?"
informative_text: "This is a general needs log, and this referral type is for supported housing."
net_income_value_check:
page_header: ""
check_answer_label: "Net income confirmation"
hint_text: ""
question_text: "Are you sure this is correct?"
title_text: "You told us that the household’s income is %{earnings} %{incfreq}."
informative_text: "This is %{net_income_higher_or_lower_text} than we would expect for the household’s working situation."
care_home_charges_value_check:
page_header: ""
check_answer_label: "Care home charges confirmation"
hint_text: ""
question_text: "Are you sure there are no care home charges?"
title_text: "Care home charges should be provided if this is a care home accommodation."
informative_text: "Are you sure there are no care home charges?"
rent_value_check:
page_header: ""
check_answer_label: "Total rent confirmation"
hint_text: "Check the following:<ul class=\"govuk-body-l app-panel--interruption\"><li>the decimal point</li><li>the frequency, for example every week or every calendar month</li><li>the rent type is correct, for example affordable or social rent</li></ul>"
question_text: "Are you sure this is correct?"
title_text: "You told us the rent is %{brent}."
informative_text: "This is %{higher_or_lower} than we would expect."
scharge_value_check:
page_header: ""
check_answer_label: "Service charge confirmation"
hint_text: "Check the following:<ul class=\"govuk-body-l app-panel--interruption\"><li>the decimal point</li><li>the frequency, for example every week or every calendar month</li><li>the needs type</li></ul>"
question_text: "Are you sure?"
title_text: "You told us the service charge is %{scharge}."
informative_text: "This is higher than we would expect."
pscharge_value_check:
page_header: ""
check_answer_label: "Personal service charge confirmation"
hint_text: "Check the following:<ul class=\"govuk-body-l app-panel--interruption\"><li>the decimal point</li><li>the frequency, for example every week or every calendar month</li><li>the needs type</li></ul>"
question_text: "Are you sure?"
title_text: "You told us the personal service charge is %{pscharge}."
informative_text: "This is higher than we would expect."
supcharg_value_check:
page_header: ""
check_answer_label: "Support charge confirmation"
hint_text: "Check the following:<ul class=\"govuk-body-l app-panel--interruption\"><li>the decimal point</li><li>the frequency, for example every week or every calendar month</li><li>the needs type</li></ul>"
question_text: "Are you sure?"
title_text: "You told us the support charge is %{supcharg}."
informative_text: "This is higher than we would expect."
void_date_value_check:
page_header: ""
check_answer_label: "Void date confirmation"
hint_text: ""
question_text: "Are you sure the property has been vacant for this long?"
title_text: "You told us that the property has been vacant for more than 2 years."
informative_text: "This is longer than we would expect."
major_repairs_date_value_check:
page_header: ""
check_answer_label: "Major repairs date confirmation"
hint_text: ""
question_text: "Are you sure the property has been vacant for this long?"
title_text: "You told us the property has been vacant for 2 years."
informative_text: "This is longer than we would expect."

132
config/locales/forms/2025/lettings/soft_validations.en.yml

@ -0,0 +1,132 @@
en:
forms:
2025:
lettings:
soft_validations:
pregnancy_value_check:
no_females_pregnant_household_value_check:
page_header: ""
check_answer_label: "Pregnancy confirmation"
hint_text: ""
question_text: "Are you sure this is correct?"
title_text: "You told us somebody in the household is pregnant."
informative_text: "You also told us that all the tenants living at the property are male."
females_in_soft_age_range_in_pregnant_household_value_check:
page_header: ""
check_answer_label: "Pregnancy confirmation"
hint_text: ""
question_text: "Are you sure this is correct?"
title_text: "You told us somebody in the household is pregnant."
informative_text: "You also told us that any female tenants living at the property are in the following age ranges:<ul class=\"govuk-body-l app-panel--interruption\"><li>under 16 years old</li><li>over 50 years old</li></ul>"
no_retirement_value_check:
page_header: ""
check_answer_label: "Retirement confirmation"
hint_text: ""
question_text: "Are you sure this person is retired?"
title_text: "You told us this person is aged %{age} years and retired."
informative_text: "The minimum expected retirement age in England is 66."
retirement_value_check:
page_header: ""
check_answer_label: "Retirement confirmation"
hint_text: ""
question_text: "Are you sure this person isn’t retired?"
title_text: "You told us this person is over 66 and not retired."
informative_text: "Are you sure this person isn’t retired?"
partner_under_16_value_check:
page_header: ""
check_answer_label: "Partner under 16 confirmation"
hint_text: ""
question_text: "Are you sure this is correct?"
title_text: "You told us this person is aged %{age} years and has 'Partner' relationship to the lead tenant."
informative_text: "Are you sure this is correct?"
multiple_partners_value_check:
page_header: ""
check_answer_label: "Multiple partners confirmation"
hint_text: ""
question_text: "Are you sure this is correct?"
title_text: "You told us there are more than 1 persons with 'Partner' relationship to the lead tenant."
informative_text: "Are you sure this is correct?"
reasonother_value_check:
page_header: ""
check_answer_label: "Reason other confirmation"
hint_text: ""
question_text: "Are you sure this doesn’t fit an existing category?"
title_text: "You told us that the tenant’s main reason for leaving their last settled home was %{reasonother}."
informative_text: "The reason you have entered looks very similar to one of the existing response categories. Please check the categories and select the appropriate one. If the existing categories are not suitable, please confirm here to move onto the next question."
referral_value_check:
page_header: ""
check_answer_label: "Referral confirmation"
hint_text: ""
question_text: "Are you sure?"
title_text: "Are you sure?"
informative_text: "This is a general needs log, and this referral type is for supported housing."
net_income_value_check:
page_header: ""
check_answer_label: "Net income confirmation"
hint_text: ""
question_text: "Are you sure this is correct?"
title_text: "You told us that the household’s income is %{earnings} %{incfreq}."
informative_text: "This is %{net_income_higher_or_lower_text} than we would expect for the household’s working situation."
care_home_charges_value_check:
page_header: ""
check_answer_label: "Care home charges confirmation"
hint_text: ""
question_text: "Are you sure there are no care home charges?"
title_text: "Care home charges should be provided if this is a care home accommodation."
informative_text: "Are you sure there are no care home charges?"
rent_value_check:
page_header: ""
check_answer_label: "Total rent confirmation"
hint_text: "Check the following:<ul class=\"govuk-body-l app-panel--interruption\"><li>the decimal point</li><li>the frequency, for example every week or every calendar month</li><li>the rent type is correct, for example affordable or social rent</li></ul>"
question_text: "Are you sure this is correct?"
title_text: "You told us the rent is %{brent}."
informative_text: "This is %{higher_or_lower} than we would expect."
scharge_value_check:
page_header: ""
check_answer_label: "Service charge confirmation"
hint_text: "Check the following:<ul class=\"govuk-body-l app-panel--interruption\"><li>the decimal point</li><li>the frequency, for example every week or every calendar month</li><li>the needs type</li></ul>"
question_text: "Are you sure?"
title_text: "You told us the service charge is %{scharge}."
informative_text: "This is higher than we would expect."
pscharge_value_check:
page_header: ""
check_answer_label: "Personal service charge confirmation"
hint_text: "Check the following:<ul class=\"govuk-body-l app-panel--interruption\"><li>the decimal point</li><li>the frequency, for example every week or every calendar month</li><li>the needs type</li></ul>"
question_text: "Are you sure?"
title_text: "You told us the personal service charge is %{pscharge}."
informative_text: "This is higher than we would expect."
supcharg_value_check:
page_header: ""
check_answer_label: "Support charge confirmation"
hint_text: "Check the following:<ul class=\"govuk-body-l app-panel--interruption\"><li>the decimal point</li><li>the frequency, for example every week or every calendar month</li><li>the needs type</li></ul>"
question_text: "Are you sure?"
title_text: "You told us the support charge is %{supcharg}."
informative_text: "This is higher than we would expect."
void_date_value_check:
page_header: ""
check_answer_label: "Void date confirmation"
hint_text: ""
question_text: "Are you sure the property has been vacant for this long?"
title_text: "You told us that the property has been vacant for more than 2 years."
informative_text: "This is longer than we would expect."
major_repairs_date_value_check:
page_header: ""
check_answer_label: "Major repairs date confirmation"
hint_text: ""
question_text: "Are you sure the property has been vacant for this long?"
title_text: "You told us the property has been vacant for 2 years."
informative_text: "This is longer than we would expect."

10
config/locales/forms/2025/sales/setup.en.yml

@ -50,16 +50,6 @@ en:
check_answer_label: "Type of discounted ownership sale"
hint_text: ""
question_text: "What is the type of discounted ownership sale?"
outright_ownership:
page_header: "Type of outright sale"
type:
check_answer_label: "Type of outright sale"
hint_text: ""
question_text: "What is the type of outright sale?"
othtype:
check_answer_label: "Type of other sale"
hint_text: ""
question_text: "What type of sale is it?"
companybuy:
page_header: ""

86
config/locales/validations/lettings/financial.yml

@ -0,0 +1,86 @@
en:
validations:
lettings:
financial:
tshortfall:
outstanding_amount_not_expected: "You cannot answer the outstanding amount question if you don’t have outstanding rent or charges."
more_than_total_charge: "Enter a value less than the total charge."
more_than_carehome_charge: "Enter a value less than the care home charge."
must_be_positive: "Enter a value over £0.01 as you told us there is an outstanding amount."
outstanding_no_benefits: "Answer cannot be ‘yes’ to outstanding amount for basic rent or charges if tenant does not receive housing benefit or Universal Credit or you‘re not sure."
hbrentshortfall:
outstanding_amount_not_expected: "Answer must be ‘yes’ as you have answered the outstanding amount question."
benefits:
part_or_full_time: "Answer cannot be ‘all’ for income from Universal Credit, state pensions or benefits if the tenant or their partner works part-time or full-time."
earnings:
over_hard_max: "The household’s income cannot be greater than %{hard_max} per week given the household’s working situation."
under_hard_min: "The household’s income cannot be less than %{hard_min} per week given the household’s working situation."
incfreq_missing: "Select how often the household receives income."
earnings_missing: "Enter how much income the household has in total."
negative_currency: "Enter an amount above 0."
hhmemb:
earnings_over_hard_max: "The household’s income of %{earnings} %{frequency} is too high for this number of tenants. Change either the household income or number of tenants."
earnings_under_hard_min: "The household’s income of %{earnings} %{frequency} is too low for this number of tenants. Change either the household income or number of tenants."
ecstat:
earnings_over_hard_max: "The household’s income of %{earnings} %{frequency} is too high given the household’s working situation."
earnings_under_hard_min: "The household’s income of %{earnings} %{frequency} is too low given the household’s working situation."
age:
earnings_over_hard_max: "The household’s income of %{earnings} %{frequency} is too high for the number of adults. Change either the household income or the age of the tenants."
incfreq:
incfreq_missing: "Select how often the household receives income."
earnings_missing: "Enter how much income the household has in total."
brent:
negative_currency: "Enter an amount above 0."
below_hard_min: "Rent is below the absolute minimum expected for a property of this type. Please check the rent, rent period, local authority and (if general needs) number of bedrooms."
above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type. Please check the rent, rent period, local authority and (if general needs) number of bedrooms."
scharge:
negative_currency: "Enter an amount above 0."
rent_out_of_range: "Enter a value for the %{charge_name} between £0 and %{maximum_per_period} paid %{frequency}. %{maximum_per_period} is the max limit for rent and charges paid %{frequency} for %{letting_type} lettings owned by a %{provider_type}."
pscharge:
negative_currency: "Enter an amount above 0."
rent_out_of_range: "Enter a value for the %{charge_name} between £0 and %{maximum_per_period} paid %{frequency}. %{maximum_per_period} is the max limit for rent and charges paid %{frequency} for %{letting_type} lettings owned by a %{provider_type}."
supcharg:
negative_currency: "Enter an amount above 0."
rent_out_of_range: "Enter a value for the %{charge_name} between £0 and %{maximum_per_period} paid %{frequency}. %{maximum_per_period} is the max limit for rent and charges paid %{frequency} for %{letting_type} lettings owned by a %{provider_type}."
chcharge:
less_than_shortfall: "The care home charge must be more than the outstanding amount."
complete_1_of_3: "Answer either the ‘household rent and charges’ question or ‘is this accommodation a care home‘, or select ‘no’ for ‘does the household pay rent or charges for the accommodation?’"
out_of_range: "Household rent and other charges must be between %{min_chcharge} and %{max_chcharge} if paying %{period}."
tcharge:
under_10: "Enter a total charge that is at least £10.00 per week."
less_than_shortfall: "The total charge must be more than the outstanding amount."
complete_1_of_3: "Answer either the ‘household rent and charges’ question or ‘is this accommodation a care home‘, or select ‘no’ for ‘does the household pay rent or charges for the accommodation?’"
household_charge:
complete_1_of_3: "Answer either the ‘household rent and charges’ question or ‘is this accommodation a care home‘, or select ‘no’ for ‘does the household pay rent or charges for the accommodation?’"
period:
invalid_period_for_org: "%{org_name} does not use %{rent_period} as a rent period. Choose another rent period, or a data coordinator can add rent periods to your organisation."
chcharge_out_of_range: "Household rent and other charges must be between %{min_chcharge} and %{max_chcharge} if paying %{period}."
rent_out_of_range: "Enter a value for the %{charge_name} between £0 and %{maximum_per_period} paid %{frequency}. %{maximum_per_period} is the max limit for rent and charges paid %{frequency} for %{letting_type} lettings owned by a %{provider_type}."
rent_below_hard_min: "Rent is below the absolute minimum expected for a property of this type based on this period."
rent_above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type based on this period."
managing_organisation_id:
invalid_period_for_org: "%{org_name} does not use %{rent_period} as a rent period. Set another rent period on this log, or a data coordinator can add rent periods to this organisation."
beds:
rent_below_hard_min: "Rent is below the absolute minimum expected for a property of this type based on this number of bedrooms."
rent_above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type based on this number of bedrooms."
uprn:
rent_below_hard_min: "Rent is below the absolute minimum expected for a property of this type based on this UPRN."
rent_above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type based on this UPRN."
la:
rent_below_hard_min: "Rent is below the absolute minimum expected for a property of this type based on this local authority."
rent_above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type based on this local authority."
postcode_known:
rent_below_hard_min: "Rent is below the absolute minimum expected for a property of this type. Please check the rent, rent period, local authority and number of bedrooms."
rent_above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type. Please check the rent, rent period, local authority and number of bedrooms."
scheme_id:
rent_below_hard_min: "Rent is below the absolute minimum expected for a property of this type. Please check the rent, rent period and local authority."
rent_above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type. Please check the rent, rent period and local authority."
location_id:
rent_below_hard_min: "Rent is below the absolute minimum expected for a property of this type. Please check the rent, rent period and local authority."
rent_above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type. Please check the rent, rent period and local authority."
rent_type:
rent_below_hard_min: "Rent is below the absolute minimum expected for a property of this type based on this lettings type."
rent_above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type based on this lettings type."
needstype:
rent_below_hard_min: "Rent is below the absolute minimum expected for a property of this type based on this lettings type."
rent_above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type based on this lettings type."

7
config/locales/validations/lettings/household.en.yml

@ -0,0 +1,7 @@
en:
validations:
lettings:
household:
relat:
one_partner: "Number of partners cannot be greater than 1."

6
config/locales/validations/lettings/property_information.en.yml

@ -0,0 +1,6 @@
en:
validations:
lettings:
property_information:
postcode_full:
invalid: "Enter a postcode in the correct format, for example AA1 1AA."

35
config/locales/validations/lettings/setup.en.yml

@ -21,12 +21,40 @@ en:
owning_organisation: "Enter a date when the owning organisation was active. %{owning_organisation} became active on %{available_from}."
managing_organisation: "Enter a date when the managing organisation was active. %{managing_organisation} became active on %{available_from}."
different_organisations: "Enter a date when the owning and managing organisations were active. %{owning_organisation} became active on %{owning_organisation_active_from}, and %{managing_organisation} became active on %{managing_organisation_active_from}."
location:
deactivated:
startdate: "The location %{postcode} is inactive on this date. Enter another date or choose another location."
location_id: "This location is not active on the tenancy start date. Choose another location or edit the tenancy start date."
activating_soon:
startdate: "The location %{postcode} is not available until %{date}. Enter a tenancy start date after %{date}."
location_id: "The location %{postcode} is not available until %{date}. Select another location or edit the tenancy start date."
reactivating_soon:
startdate: "The location %{postcode} is not available until %{date}. Enter a tenancy start date after %{date}."
location_id: "The location %{postcode} is not available until %{date}. Select another location or edit the tenancy start date."
scheme:
deactivated:
startdate: "The scheme %{name} was deactivated on %{date} and was not available on the day you entered. Select another scheme or edit the tenancy start date."
scheme_id: "The scheme %{name} was deactivated on %{date} and was not available on the day you entered. Select another scheme or edit the tenancy start date."
reactivating_soon:
startdate: "The scheme %{name} is not available until %{date}. Enter a tenancy start date after %{date}."
scheme_id: "The scheme %{name} is not available until %{date}. Select another scheme or edit the tenancy start date."
locations_inactive:
startdate: "The scheme %{name} has no locations that are active on this date. Enter another date or choose another scheme."
scheme_id: "The scheme %{name} has no locations that are active on this date. Enter another date or choose another scheme."
scheme:
incomplete: "This scheme is incomplete. Select another scheme or update this one."
no_completed_locations: "This scheme cannot be chosen as it has no completed locations."
location:
incomplete: "This location is incomplete. Select another location or update this one."
assigned_to:
invalid: "Please select the owning organisation or managing organisation that you belong to."
owning_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 owning organisation."
inactive:
merged_organisation:
"The owning organisation must be active on the tenancy start date. %{owning_organisation} became inactive on %{merge_date} and was replaced by %{absorbing_organisation}."
@ -44,10 +72,3 @@ en:
intermediate_rent_product_name:
blank: "Enter name of other intermediate rent product."
scheme:
incomplete: "This scheme is incomplete. Select another scheme or update this one."
no_completed_locations: "This scheme cannot be chosen as it has no completed locations."
location:
incomplete: "This location is incomplete. Select another location or update this one."

7
config/locales/validations/sales/property_information.en.yml

@ -3,11 +3,12 @@ en:
sales:
property_information:
postcode_full:
postcode_must_match_previous:
postcode_must_match_previous:
joint_purchase: "Buyers’ last accommodation and discounted ownership postcodes must match."
not_joint_purchase: "Buyer’s last accommodation and discounted ownership postcodes must match."
invalid: "Enter a postcode in the correct format, for example AA1 1AA."
ppostcode_full:
postcode_must_match_previous:
postcode_must_match_previous:
joint_purchase: "Buyers’ last accommodation and discounted ownership postcodes must match."
not_joint_purchase: "Buyer’s last accommodation and discounted ownership postcodes must match."
ownershipsch:
@ -15,7 +16,7 @@ en:
joint_purchase: "Buyers’ last accommodation and discounted ownership postcodes must match."
not_joint_purchase: "Buyer’s last accommodation and discounted ownership postcodes must match."
uprn:
postcode_must_match_previous:
postcode_must_match_previous:
joint_purchase: "Buyers’ last accommodation and discounted ownership postcodes must match."
not_joint_purchase: "Buyer’s last accommodation and discounted ownership postcodes must match."
invalid: "UPRN must be 12 digits or less."

1
config/locales/validations/sales/setup.en.yml

@ -17,6 +17,7 @@ en:
"Enter a date when the owning organisation was active. %{owning_organisation} became active on %{available_from}."
owning_organisation:
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 sale completion date. %{owning_organisation} became inactive on %{merge_date} and was replaced by %{absorbing_organisation}."

19
config/locales/validations/shared.en.yml

@ -0,0 +1,19 @@
en:
validations:
shared:
other_field_missing: "If %{main_field_label} is other then %{other_field_label} must be provided."
other_field_not_required: "%{other_field_label} must not be provided if %{main_field_label} was not other."
numeric:
within_range: "%{field} must be between %{min} and %{max}."
above_min: "%{field} must be at least %{min}."
whole_number: "%{field} must be a whole number."
nearest_ten: "%{field} must be given to the nearest ten."
nearest_hundredth: "%{field} must be given to the nearest hundredth."
normal_format: "Enter a number."
format: "%{field} must be a number."
postcode: "Enter a postcode in the correct format, for example AA1 1AA."
date:
invalid_date: "Enter a date in the correct format, for example 31 1 2024."

4
lib/tasks/generate_lettings_documentation.rake

@ -60,13 +60,13 @@ namespace :generate_lettings_documentation do
min = [question.prefix, question.min].join("") if question.min
max = [question.prefix, question.max].join("") if question.max
error_message = I18n.t("validations.numeric.above_min", field:, min:)
error_message = I18n.t("validations.shared.numeric.above_min", field:, min:)
validation_name = "minimum"
validation_description = "Field value is lower than the minimum value"
if min && max
validation_name = "range"
error_message = I18n.t("validations.numeric.within_range", field:, min:, max:)
error_message = I18n.t("validations.shared.numeric.within_range", field:, min:, max:)
validation_description = "Field value is lower than the minimum value or higher than the maximum value"
end

4
lib/tasks/generate_sales_documentation.rake

@ -59,13 +59,13 @@ namespace :generate_sales_documentation do
min = [question.prefix, question.min].join("") if question.min
max = [question.prefix, question.max].join("") if question.max
error_message = I18n.t("validations.numeric.above_min", field:, min:)
error_message = I18n.t("validations.shared.numeric.above_min", field:, min:)
validation_name = "minimum"
validation_description = "Field value is lower than the minimum value"
if min && max
validation_name = "range"
error_message = I18n.t("validations.numeric.within_range", field:, min:, max:)
error_message = I18n.t("validations.shared.numeric.within_range", field:, min:, max:)
validation_description = "Field value is lower than the minimum value or higher than the maximum value"
end

2
spec/factories/scheme.rb

@ -1,6 +1,6 @@
FactoryBot.define do
factory :scheme do
service_name { Faker::Name.name }
service_name { "#{Faker::Name.name}'s Housing & Co." }
sensitive { Faker::Number.within(range: 0..1) }
registered_under_care_act { 1 }
support_type { [0, 2, 3, 4, 5].sample }

6
spec/fixtures/files/sales_logs_csv_export_codes_23.csv vendored

File diff suppressed because one or more lines are too long

6
spec/fixtures/files/sales_logs_csv_export_codes_24.csv vendored

File diff suppressed because one or more lines are too long

6
spec/fixtures/files/sales_logs_csv_export_labels_23.csv vendored

File diff suppressed because one or more lines are too long

6
spec/fixtures/files/sales_logs_csv_export_labels_24.csv vendored

File diff suppressed because one or more lines are too long

6
spec/fixtures/files/sales_logs_csv_export_non_support_labels_24.csv vendored

File diff suppressed because one or more lines are too long

4
spec/fixtures/forms/2021_2022.json vendored

@ -740,7 +740,7 @@
}
],
"title_text": {
"translation": "soft_validations.net_income.title_text",
"translation": "forms.2024.lettings.soft_validations.net_income_value_check.title_text",
"arguments": [
{
"key": "incfreq",
@ -755,7 +755,7 @@
]
},
"informative_text": {
"translation": "soft_validations.net_income.hint_text",
"translation": "forms.2024.lettings.soft_validations.net_income_value_check.informative_text",
"arguments": [
{
"key": "net_income_higher_or_lower_text",

2
spec/helpers/interruption_screen_helper_spec.rb

@ -93,7 +93,7 @@ RSpec.describe InterruptionScreenHelper do
context "when 1 out of 2 arguments are given" do
it "returns an empty string" do
informative_text = {
"translation" => "soft_validations.net_income.hint_text",
"translation" => "forms.2024.lettings.soft_validations.net_income_value_check.informative_text",
"arguments" => [
{
"key" => "ecstat1",

4
spec/models/form/lettings/pages/care_home_charges_value_check_spec.rb

@ -30,12 +30,12 @@ RSpec.describe Form::Lettings::Pages::CareHomeChargesValueCheck, type: :model do
it "has the correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.care_home_charges.title_text",
"translation" => "forms.2024.lettings.soft_validations.care_home_charges_value_check.title_text",
})
end
it "has the correct informative_text" do
expect(page.informative_text).to eq("")
expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.lettings.soft_validations.care_home_charges_value_check.informative_text" })
end
it "has the correct interruption_screen_question_ids" do

40
spec/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_person_age_value_check_spec.rb

@ -37,27 +37,15 @@ RSpec.describe Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPe
it "has the correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.pregnancy.title",
"arguments" => [
{
"key" => "sex1",
"label" => true,
"i18n_template" => "sex1",
},
],
"translation" => "forms.2024.lettings.soft_validations.pregnancy_value_check.females_in_soft_age_range_in_pregnant_household_value_check.title_text",
"arguments" => [],
})
end
it "has the correct informative_text" do
expect(page.informative_text).to eq({
"translation" => "soft_validations.pregnancy.females_not_in_soft_age_range",
"arguments" => [
{
"key" => "sex1",
"label" => true,
"i18n_template" => "sex1",
},
],
"translation" => "forms.2024.lettings.soft_validations.pregnancy_value_check.females_in_soft_age_range_in_pregnant_household_value_check.informative_text",
"arguments" => [],
})
end
end
@ -82,27 +70,15 @@ RSpec.describe Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPe
it "has the correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.pregnancy.title",
"arguments" => [
{
"key" => "sex1",
"label" => true,
"i18n_template" => "sex1",
},
],
"translation" => "forms.2024.lettings.soft_validations.pregnancy_value_check.females_in_soft_age_range_in_pregnant_household_value_check.title_text",
"arguments" => [],
})
end
it "has the correct informative_text" do
expect(page.informative_text).to eq({
"translation" => "soft_validations.pregnancy.females_not_in_soft_age_range",
"arguments" => [
{
"key" => "sex1",
"label" => true,
"i18n_template" => "sex1",
},
],
"translation" => "forms.2024.lettings.soft_validations.pregnancy_value_check.females_in_soft_age_range_in_pregnant_household_value_check.informative_text",
"arguments" => [],
})
end
end

40
spec/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_person_value_check_spec.rb

@ -37,27 +37,15 @@ RSpec.describe Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPe
it "has the correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.pregnancy.title",
"arguments" => [
{
"key" => "sex1",
"label" => true,
"i18n_template" => "sex1",
},
],
"translation" => "forms.2024.lettings.soft_validations.pregnancy_value_check.females_in_soft_age_range_in_pregnant_household_value_check.title_text",
"arguments" => [],
})
end
it "has the correct informative_text" do
expect(page.informative_text).to eq({
"translation" => "soft_validations.pregnancy.females_not_in_soft_age_range",
"arguments" => [
{
"key" => "sex1",
"label" => true,
"i18n_template" => "sex1",
},
],
"translation" => "forms.2024.lettings.soft_validations.pregnancy_value_check.females_in_soft_age_range_in_pregnant_household_value_check.informative_text",
"arguments" => [],
})
end
end
@ -82,27 +70,15 @@ RSpec.describe Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPe
it "has the correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.pregnancy.title",
"arguments" => [
{
"key" => "sex1",
"label" => true,
"i18n_template" => "sex1",
},
],
"translation" => "forms.2024.lettings.soft_validations.pregnancy_value_check.females_in_soft_age_range_in_pregnant_household_value_check.title_text",
"arguments" => [],
})
end
it "has the correct informative_text" do
expect(page.informative_text).to eq({
"translation" => "soft_validations.pregnancy.females_not_in_soft_age_range",
"arguments" => [
{
"key" => "sex1",
"label" => true,
"i18n_template" => "sex1",
},
],
"translation" => "forms.2024.lettings.soft_validations.pregnancy_value_check.females_in_soft_age_range_in_pregnant_household_value_check.informative_text",
"arguments" => [],
})
end
end

11
spec/models/form/lettings/pages/multiple_partners_value_check_spec.rb

@ -4,7 +4,8 @@ RSpec.describe Form::Lettings::Pages::MultiplePartnersValueCheck, type: :model d
subject(:page) { described_class.new(page_id, page_definition, subsection, person_index:) }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
let(:subsection) { instance_double(Form::Subsection, form:) }
let(:person_index) { 1 }
let(:page_id) { "multiple_partners_value_check" }
@ -39,13 +40,13 @@ RSpec.describe Form::Lettings::Pages::MultiplePartnersValueCheck, type: :model d
it "has correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.multiple_partners_lettings.title",
"translation" => "forms.2024.lettings.soft_validations.multiple_partners_value_check.title_text",
"arguments" => [],
})
end
it "has correct informative_text" do
expect(page.informative_text).to eq({})
expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.lettings.soft_validations.multiple_partners_value_check.informative_text" })
end
it "has correct interruption_screen_question_ids" do
@ -71,13 +72,13 @@ RSpec.describe Form::Lettings::Pages::MultiplePartnersValueCheck, type: :model d
it "has correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.multiple_partners_lettings.title",
"translation" => "forms.2024.lettings.soft_validations.multiple_partners_value_check.title_text",
"arguments" => [],
})
end
it "has correct informative_text" do
expect(page.informative_text).to eq({})
expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.lettings.soft_validations.multiple_partners_value_check.informative_text" })
end
it "has correct interruption_screen_question_ids" do

4
spec/models/form/lettings/pages/net_income_value_check_spec.rb

@ -24,13 +24,13 @@ RSpec.describe Form::Lettings::Pages::NetIncomeValueCheck, type: :model do
end
it "has the correct title_text" do
expect(page.title_text).to eq({ "translation" => "soft_validations.net_income.title_text", "arguments" => [{ "i18n_template" => "incfreq", "key" => "incfreq", "label" => true }, { "arguments_for_key" => "earnings", "i18n_template" => "earnings", "key" => "field_formatted_as_currency" }] })
expect(page.title_text).to eq({ "translation" => "forms.2024.lettings.soft_validations.net_income_value_check.title_text", "arguments" => [{ "i18n_template" => "incfreq", "key" => "incfreq", "label" => true }, { "arguments_for_key" => "earnings", "i18n_template" => "earnings", "key" => "field_formatted_as_currency" }] })
end
it "has the correct informative_text" do
expect(page.informative_text).to eq({
"arguments" => [{ "i18n_template" => "net_income_higher_or_lower_text", "key" => "net_income_higher_or_lower_text", "label" => false }],
"translation" => "soft_validations.net_income.hint_text",
"translation" => "forms.2024.lettings.soft_validations.net_income_value_check.informative_text",
})
end
end

40
spec/models/form/lettings/pages/no_females_pregnant_household_person_age_value_check_spec.rb

@ -37,27 +37,15 @@ RSpec.describe Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCh
it "has the correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.pregnancy.title",
"arguments" => [
{
"key" => "sex1",
"label" => true,
"i18n_template" => "sex1",
},
],
"translation" => "forms.2024.lettings.soft_validations.pregnancy_value_check.no_females_pregnant_household_value_check.title_text",
"arguments" => [],
})
end
it "has the correct informative_text" do
expect(page.informative_text).to eq({
"translation" => "soft_validations.pregnancy.all_male_tenants",
"arguments" => [
{
"key" => "sex1",
"label" => true,
"i18n_template" => "sex1",
},
],
"translation" => "forms.2024.lettings.soft_validations.pregnancy_value_check.no_females_pregnant_household_value_check.informative_text",
"arguments" => [],
})
end
end
@ -82,27 +70,15 @@ RSpec.describe Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCh
it "has the correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.pregnancy.title",
"arguments" => [
{
"key" => "sex1",
"label" => true,
"i18n_template" => "sex1",
},
],
"translation" => "forms.2024.lettings.soft_validations.pregnancy_value_check.no_females_pregnant_household_value_check.title_text",
"arguments" => [],
})
end
it "has the correct informative_text" do
expect(page.informative_text).to eq({
"translation" => "soft_validations.pregnancy.all_male_tenants",
"arguments" => [
{
"key" => "sex1",
"label" => true,
"i18n_template" => "sex1",
},
],
"translation" => "forms.2024.lettings.soft_validations.pregnancy_value_check.no_females_pregnant_household_value_check.informative_text",
"arguments" => [],
})
end
end

40
spec/models/form/lettings/pages/no_females_pregnant_household_person_value_check_spec.rb

@ -37,27 +37,15 @@ RSpec.describe Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck
it "has the correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.pregnancy.title",
"arguments" => [
{
"key" => "sex1",
"label" => true,
"i18n_template" => "sex1",
},
],
"translation" => "forms.2024.lettings.soft_validations.pregnancy_value_check.no_females_pregnant_household_value_check.title_text",
"arguments" => [],
})
end
it "has the correct informative_text" do
expect(page.informative_text).to eq({
"translation" => "soft_validations.pregnancy.all_male_tenants",
"arguments" => [
{
"key" => "sex1",
"label" => true,
"i18n_template" => "sex1",
},
],
"translation" => "forms.2024.lettings.soft_validations.pregnancy_value_check.no_females_pregnant_household_value_check.informative_text",
"arguments" => [],
})
end
end
@ -82,27 +70,15 @@ RSpec.describe Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck
it "has the correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.pregnancy.title",
"arguments" => [
{
"key" => "sex1",
"label" => true,
"i18n_template" => "sex1",
},
],
"translation" => "forms.2024.lettings.soft_validations.pregnancy_value_check.no_females_pregnant_household_value_check.title_text",
"arguments" => [],
})
end
it "has the correct informative_text" do
expect(page.informative_text).to eq({
"translation" => "soft_validations.pregnancy.all_male_tenants",
"arguments" => [
{
"key" => "sex1",
"label" => true,
"i18n_template" => "sex1",
},
],
"translation" => "forms.2024.lettings.soft_validations.pregnancy_value_check.no_females_pregnant_household_value_check.informative_text",
"arguments" => [],
})
end
end

27
spec/models/form/lettings/pages/partner_under16_value_check_spec.rb

@ -4,7 +4,8 @@ RSpec.describe Form::Lettings::Pages::PartnerUnder16ValueCheck, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection, person_index:) }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
let(:subsection) { instance_double(Form::Subsection, form:) }
let(:person_index) { 1 }
let(:page_id) { "partner_under_16_value_check" }
@ -39,7 +40,7 @@ RSpec.describe Form::Lettings::Pages::PartnerUnder16ValueCheck, type: :model do
it "has correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.partner_under_16_lettings.title",
"translation" => "forms.2024.lettings.soft_validations.partner_under_16_value_check.title_text",
"arguments" => [
{
"key" => "age1",
@ -51,7 +52,7 @@ RSpec.describe Form::Lettings::Pages::PartnerUnder16ValueCheck, type: :model do
end
it "has correct informative_text" do
expect(page.informative_text).to eq({})
expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.lettings.soft_validations.partner_under_16_value_check.informative_text" })
end
it "has correct interruption_screen_question_ids" do
@ -77,7 +78,7 @@ RSpec.describe Form::Lettings::Pages::PartnerUnder16ValueCheck, type: :model do
it "has correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.partner_under_16_lettings.title",
"translation" => "forms.2024.lettings.soft_validations.partner_under_16_value_check.title_text",
"arguments" => [
{
"key" => "age2",
@ -89,7 +90,7 @@ RSpec.describe Form::Lettings::Pages::PartnerUnder16ValueCheck, type: :model do
end
it "has correct informative_text" do
expect(page.informative_text).to eq({})
expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.lettings.soft_validations.partner_under_16_value_check.informative_text" })
end
it "has correct interruption_screen_question_ids" do
@ -115,7 +116,7 @@ RSpec.describe Form::Lettings::Pages::PartnerUnder16ValueCheck, type: :model do
it "has correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.partner_under_16_lettings.title",
"translation" => "forms.2024.lettings.soft_validations.partner_under_16_value_check.title_text",
"arguments" => [
{
"key" => "age3",
@ -127,7 +128,7 @@ RSpec.describe Form::Lettings::Pages::PartnerUnder16ValueCheck, type: :model do
end
it "has correct informative_text" do
expect(page.informative_text).to eq({})
expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.lettings.soft_validations.partner_under_16_value_check.informative_text" })
end
it "has correct interruption_screen_question_ids" do
@ -153,7 +154,7 @@ RSpec.describe Form::Lettings::Pages::PartnerUnder16ValueCheck, type: :model do
it "has correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.partner_under_16_lettings.title",
"translation" => "forms.2024.lettings.soft_validations.partner_under_16_value_check.title_text",
"arguments" => [
{
"key" => "age4",
@ -165,7 +166,7 @@ RSpec.describe Form::Lettings::Pages::PartnerUnder16ValueCheck, type: :model do
end
it "has correct informative_text" do
expect(page.informative_text).to eq({})
expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.lettings.soft_validations.partner_under_16_value_check.informative_text" })
end
it "has correct interruption_screen_question_ids" do
@ -191,7 +192,7 @@ RSpec.describe Form::Lettings::Pages::PartnerUnder16ValueCheck, type: :model do
it "has correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.partner_under_16_lettings.title",
"translation" => "forms.2024.lettings.soft_validations.partner_under_16_value_check.title_text",
"arguments" => [
{
"key" => "age5",
@ -203,7 +204,7 @@ RSpec.describe Form::Lettings::Pages::PartnerUnder16ValueCheck, type: :model do
end
it "has correct informative_text" do
expect(page.informative_text).to eq({})
expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.lettings.soft_validations.partner_under_16_value_check.informative_text" })
end
it "has correct interruption_screen_question_ids" do
@ -229,7 +230,7 @@ RSpec.describe Form::Lettings::Pages::PartnerUnder16ValueCheck, type: :model do
it "has correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.partner_under_16_lettings.title",
"translation" => "forms.2024.lettings.soft_validations.partner_under_16_value_check.title_text",
"arguments" => [
{
"key" => "age6",
@ -241,7 +242,7 @@ RSpec.describe Form::Lettings::Pages::PartnerUnder16ValueCheck, type: :model do
end
it "has correct informative_text" do
expect(page.informative_text).to eq({})
expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.lettings.soft_validations.partner_under_16_value_check.informative_text" })
end
it "has correct interruption_screen_question_ids" do

10
spec/models/form/lettings/pages/person_over_retirement_value_check_spec.rb

@ -28,13 +28,14 @@ RSpec.describe Form::Lettings::Pages::PersonOverRetirementValueCheck, type: :mod
it "has the correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.retirement.max.title",
"translation" => "forms.2024.lettings.soft_validations.retirement_value_check.title_text",
})
end
it "has the correct informative_text" do
expect(page.informative_text).to eq({
"translation" => "soft_validations.retirement.max.hint_text",
"translation" => "forms.2024.lettings.soft_validations.retirement_value_check.informative_text",
"arguments" => [],
})
end
end
@ -50,13 +51,14 @@ RSpec.describe Form::Lettings::Pages::PersonOverRetirementValueCheck, type: :mod
it "has the correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.retirement.max.title",
"translation" => "forms.2024.lettings.soft_validations.retirement_value_check.title_text",
})
end
it "has the correct informative_text" do
expect(page.informative_text).to eq({
"translation" => "soft_validations.retirement.max.hint_text",
"translation" => "forms.2024.lettings.soft_validations.retirement_value_check.informative_text",
"arguments" => [],
})
end
end

8
spec/models/form/lettings/pages/person_under_retirement_value_check_spec.rb

@ -28,7 +28,7 @@ RSpec.describe Form::Lettings::Pages::PersonUnderRetirementValueCheck, type: :mo
it "has the correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.retirement.min.title",
"translation" => "forms.2024.lettings.soft_validations.no_retirement_value_check.title_text",
"arguments" => [
{
"key" => "age2",
@ -40,7 +40,7 @@ RSpec.describe Form::Lettings::Pages::PersonUnderRetirementValueCheck, type: :mo
end
it "has the correct informative_text" do
expect(page.informative_text).to eq({})
expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.lettings.soft_validations.no_retirement_value_check.informative_text" })
end
end
@ -55,7 +55,7 @@ RSpec.describe Form::Lettings::Pages::PersonUnderRetirementValueCheck, type: :mo
it "has the correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.retirement.min.title",
"translation" => "forms.2024.lettings.soft_validations.no_retirement_value_check.title_text",
"arguments" => [
{
"key" => "age3",
@ -67,7 +67,7 @@ RSpec.describe Form::Lettings::Pages::PersonUnderRetirementValueCheck, type: :mo
end
it "has the correct informative_text" do
expect(page.informative_text).to eq({})
expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.lettings.soft_validations.no_retirement_value_check.informative_text" })
end
end
end

2
spec/models/form/lettings/subsections/household_characteristics_spec.rb

@ -6,7 +6,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod
let(:subsection_id) { nil }
let(:subsection_definition) { nil }
let(:section) { instance_double(Form::Lettings::Sections::Household) }
let(:form) { instance_double(Form) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
before do
allow(section).to receive(:form).and_return(form)

3
spec/models/form/lettings/subsections/household_needs_spec.rb

@ -5,7 +5,8 @@ RSpec.describe Form::Lettings::Subsections::HouseholdNeeds, type: :model do
let(:subsection_id) { nil }
let(:subsection_definition) { nil }
let(:section) { instance_double(Form::Lettings::Sections::Household) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
let(:section) { instance_double(Form::Lettings::Sections::Household, form:) }
it "has correct section" do
expect(household_needs.section).to eq(section)

2
spec/models/form/lettings/subsections/household_situation_spec.rb

@ -6,7 +6,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdSituation, type: :model do
let(:subsection_id) { nil }
let(:subsection_definition) { nil }
let(:section) { instance_double(Form::Lettings::Sections::Household) }
let(:form) { instance_double(Form) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
before do
allow(section).to receive(:form).and_return(form)

3
spec/models/form/lettings/subsections/income_and_benefits_spec.rb

@ -5,7 +5,8 @@ RSpec.describe Form::Lettings::Subsections::IncomeAndBenefits, type: :model do
let(:subsection_id) { nil }
let(:subsection_definition) { nil }
let(:section) { instance_double(Form::Lettings::Sections::RentAndCharges) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
let(:section) { instance_double(Form::Lettings::Sections::RentAndCharges, form:) }
it "has correct section" do
expect(income_and_benefits.section).to eq(section)

8
spec/models/form/sales/pages/la_nominations_spec.rb

@ -7,8 +7,8 @@ RSpec.describe Form::Sales::Pages::LaNominations, type: :model do
let(:page_id) { nil }
let(:page_definition) { nil }
let(:start_year_after_2024) { false }
let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2024_or_later?: start_year_after_2024) }
let(:start_year_2024_or_later) { false }
let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2024_or_later?: start_year_2024_or_later) }
let(:subsection) { instance_double(Form::Subsection, form:) }
before do
@ -32,7 +32,7 @@ RSpec.describe Form::Sales::Pages::LaNominations, type: :model do
end
context "with 23/24 log" do
let(:start_year_after_2024) { false }
let(:start_year_2024_or_later) { false }
it "has correct routed to" do
log.staircase = 1
@ -41,7 +41,7 @@ RSpec.describe Form::Sales::Pages::LaNominations, type: :model do
end
context "with 24/25 log" do
let(:start_year_after_2024) { true }
let(:start_year_2024_or_later) { true }
it "has correct routed to when staircase is yes" do
log.staircase = 1

6
spec/models/form/sales/pages/last_accommodation_la_spec.rb

@ -5,8 +5,8 @@ RSpec.describe Form::Sales::Pages::LastAccommodationLa, type: :model do
let(:page_id) { nil }
let(:page_definition) { nil }
let(:start_year_after_2024) { false }
let(:form) { instance_double(Form, depends_on_met: true, start_date: Time.zone.local(2023, 4, 1), start_year_2024_or_later?: start_year_after_2024) }
let(:start_year_2024_or_later) { false }
let(:form) { instance_double(Form, depends_on_met: true, start_date: Time.zone.local(2023, 4, 1), start_year_2024_or_later?: start_year_2024_or_later) }
let(:subsection) { instance_double(Form::Subsection, form:, depends_on: nil, enabled?: true) }
let(:log) { build(:sales_log, :completed) }
@ -38,7 +38,7 @@ RSpec.describe Form::Sales::Pages::LastAccommodationLa, type: :model do
end
context "with 2024 form" do
let(:start_year_after_2024) { true }
let(:start_year_2024_or_later) { true }
it "is routed to for 2024 non discounted sale logs" do
log.update!(ownershipsch: 1)

6
spec/models/form/sales/pages/last_accommodation_spec.rb

@ -7,8 +7,8 @@ RSpec.describe Form::Sales::Pages::LastAccommodation, type: :model do
let(:page_id) { nil }
let(:page_definition) { nil }
let(:start_year_after_2024) { false }
let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2024_or_later?: start_year_after_2024) }
let(:start_year_2024_or_later) { false }
let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2024_or_later?: start_year_2024_or_later) }
let(:subsection) { instance_double(Form::Subsection, form:, depends_on: nil) }
it "has correct subsection" do
@ -37,7 +37,7 @@ RSpec.describe Form::Sales::Pages::LastAccommodation, type: :model do
end
context "with 2024 form" do
let(:start_year_after_2024) { true }
let(:start_year_2024_or_later) { true }
it "is routed to for 2024 non discounted sale logs" do
log.update!(ownershipsch: 1)

38
spec/models/form/sales/subsections/setup_spec.rb

@ -23,15 +23,16 @@ RSpec.describe Form::Sales::Subsections::Setup, type: :model do
context "when start year is before 2024" do
before do
allow(section.form).to receive(:start_year_2024_or_later?).and_return(false)
allow(section.form).to receive(:start_year_2025_or_later?).and_return(false)
end
it "has correct pages" do
expect(setup.pages.map(&:id)).to eq(
%w[
completion_date
owning_organisation
managing_organisation
assigned_to
completion_date
purchaser_code
ownership_scheme
shared_ownership_type
@ -46,18 +47,19 @@ RSpec.describe Form::Sales::Subsections::Setup, type: :model do
end
end
context "when start year is >= 2024" do
context "when start year is 2024" do
before do
allow(section.form).to receive(:start_year_2024_or_later?).and_return(true)
allow(section.form).to receive(:start_year_2025_or_later?).and_return(false)
end
it "has correct pages" do
expect(setup.pages.map(&:id)).to eq(
%w[
completion_date
owning_organisation
managing_organisation
assigned_to
completion_date
purchaser_code
ownership_scheme
shared_ownership_type
@ -75,4 +77,34 @@ RSpec.describe Form::Sales::Subsections::Setup, type: :model do
)
end
end
context "when start year is >= 2025" do
before do
allow(section.form).to receive(:start_year_2024_or_later?).and_return(true)
allow(section.form).to receive(:start_year_2025_or_later?).and_return(true)
end
it "has correct pages" do
expect(setup.pages.map(&:id)).to eq(
%w[
completion_date
owning_organisation
managing_organisation
assigned_to
purchaser_code
ownership_scheme
shared_ownership_type
discounted_ownership_type
buyer_company
buyer_live
joint_purchase
number_joint_buyers
buyer_interview_joint_purchase
buyer_interview
privacy_notice_joint_purchase
privacy_notice
],
)
end
end
end

4
spec/models/form_spec.rb

@ -387,10 +387,6 @@ RSpec.describe Form, type: :model do
expect(form.sections[0].class).to eq(Form::Sales::Sections::Setup)
expect(form.subsections.count).to eq(1)
expect(form.subsections.first.id).to eq("setup")
expect(form.pages.count).to eq(13)
expect(form.pages.first.id).to eq("owning_organisation")
expect(form.questions.count).to eq(14)
expect(form.questions.first.id).to eq("owning_organisation_id")
expect(form.start_date).to eq(Time.zone.parse("2022-04-01"))
expect(form.new_logs_end_date).to eq(Time.zone.parse("2023-11-20"))
expect(form.edit_end_date).to eq(Time.zone.parse("2023-11-20"))

2
spec/models/validations/date_validations_spec.rb

@ -12,7 +12,7 @@ RSpec.describe Validations::DateValidations do
it "must be a valid date" do
record.startdate = Time.zone.local(0, 7, 1)
date_validator.validate_startdate(record)
expect(record.errors["startdate"]).to include(match I18n.t("validations.date.invalid_date"))
expect(record.errors["startdate"]).to include(match I18n.t("validations.shared.date.invalid_date"))
end
it "does not raise an error when valid" do

105
spec/models/validations/financial_validations_spec.rb

@ -17,9 +17,9 @@ RSpec.describe Validations::FinancialValidations do
record.incfreq = nil
financial_validator.validate_net_income(record)
expect(record.errors["incfreq"])
.to include(match I18n.t("validations.financial.earnings.freq_missing"))
.to include(match I18n.t("validations.lettings.financial.incfreq.incfreq_missing"))
expect(record.errors["earnings"])
.to include(match I18n.t("validations.financial.earnings.freq_missing"))
.to include(match I18n.t("validations.lettings.financial.earnings.incfreq_missing"))
end
it "when income frequency is provided it validates that earnings must be provided" do
@ -27,9 +27,9 @@ RSpec.describe Validations::FinancialValidations do
record.incfreq = 1
financial_validator.validate_net_income(record)
expect(record.errors["earnings"])
.to include(match I18n.t("validations.financial.earnings.earnings_missing"))
.to include(match I18n.t("validations.lettings.financial.earnings.earnings_missing"))
expect(record.errors["incfreq"])
.to include(match I18n.t("validations.financial.earnings.earnings_missing"))
.to include(match I18n.t("validations.lettings.financial.earnings.earnings_missing"))
end
end
@ -39,14 +39,14 @@ RSpec.describe Validations::FinancialValidations do
record.benefits = 0
record.ecstat1 = 1
financial_validator.validate_net_income_uc_proportion(record)
expect(record.errors["benefits"]).to include(match I18n.t("validations.financial.benefits.part_or_full_time"))
expect(record.errors["benefits"]).to include(match I18n.t("validations.lettings.financial.benefits.part_or_full_time"))
end
it "validates that the lead tenant is not in part time employment" do
record.benefits = 0
record.ecstat1 = 0
financial_validator.validate_net_income_uc_proportion(record)
expect(record.errors["benefits"]).to include(match I18n.t("validations.financial.benefits.part_or_full_time"))
expect(record.errors["benefits"]).to include(match I18n.t("validations.lettings.financial.benefits.part_or_full_time"))
end
it "expects that the lead tenant is not in full-time or part-time employment" do
@ -61,7 +61,7 @@ RSpec.describe Validations::FinancialValidations do
record.ecstat2 = 0
record.relat2 = "P"
financial_validator.validate_net_income_uc_proportion(record)
expect(record.errors["benefits"]).to include(match I18n.t("validations.financial.benefits.part_or_full_time"))
expect(record.errors["benefits"]).to include(match I18n.t("validations.lettings.financial.benefits.part_or_full_time"))
end
it "expects that the tenant’s partner is not in full-time or part-time employment" do
@ -81,7 +81,7 @@ RSpec.describe Validations::FinancialValidations do
record.tshortfall = 99
financial_validator.validate_outstanding_rent_amount(record)
expect(record.errors["tshortfall"])
.to include(match I18n.t("validations.financial.tshortfall.outstanding_amount_not_expected"))
.to include(match I18n.t("validations.lettings.financial.tshortfall.outstanding_amount_not_expected"))
end
end
@ -104,7 +104,7 @@ RSpec.describe Validations::FinancialValidations do
record.set_derived_fields!
financial_validator.validate_rent_amount(record)
expect(record.errors["tshortfall"])
.to include(match I18n.t("validations.financial.tshortfall.must_be_positive"))
.to include(match I18n.t("validations.lettings.financial.tshortfall.must_be_positive"))
end
it "validates that total charge is no less than the shortfall" do
@ -118,9 +118,9 @@ RSpec.describe Validations::FinancialValidations do
record.set_derived_fields!
financial_validator.validate_rent_amount(record)
expect(record.errors["tcharge"])
.to include(match I18n.t("validations.financial.tcharge.less_than_shortfall"))
.to include(match I18n.t("validations.lettings.financial.tcharge.less_than_shortfall"))
expect(record.errors["tshortfall"])
.to include(match I18n.t("validations.financial.tshortfall.more_than_total_charge"))
.to include(match I18n.t("validations.lettings.financial.tshortfall.more_than_total_charge"))
end
it "validates that carehome charge is no less than the shortfall" do
@ -134,9 +134,9 @@ RSpec.describe Validations::FinancialValidations do
record.set_derived_fields!
financial_validator.validate_rent_amount(record)
expect(record.errors["chcharge"])
.to include(match I18n.t("validations.financial.carehome.less_than_shortfall"))
.to include(match I18n.t("validations.lettings.financial.chcharge.less_than_shortfall"))
expect(record.errors["tshortfall"])
.to include(match I18n.t("validations.financial.tshortfall.more_than_carehome_charge"))
.to include(match I18n.t("validations.lettings.financial.tshortfall.more_than_carehome_charge"))
end
it "expects that rent can be less than the shortfall if total charge is higher" do
@ -181,13 +181,13 @@ RSpec.describe Validations::FinancialValidations do
financial_validator.validate_rent_period(record)
expect(record.errors["period"])
.to include(match I18n.t(
"validations.financial.rent_period.invalid_for_org.period",
"validations.lettings.financial.period.invalid_period_for_org",
org_name: user.organisation.name,
rent_period: "every 4 weeks",
))
expect(record.errors["managing_organisation_id"])
.to include(match I18n.t(
"validations.financial.rent_period.invalid_for_org.managing_org",
"validations.lettings.financial.managing_organisation_id.invalid_period_for_org",
org_name: user.organisation.name,
rent_period: "every 4 weeks",
))
@ -204,7 +204,7 @@ RSpec.describe Validations::FinancialValidations do
record.hb = 9
financial_validator.validate_tshortfall(record)
expect(record.errors["tshortfall"])
.to include(match I18n.t("validations.financial.hbrentshortfall.outstanding_no_benefits"))
.to include(match I18n.t("validations.lettings.financial.tshortfall.outstanding_no_benefits"))
end
it "validates that housing benefit is not don't know" do
@ -212,16 +212,7 @@ RSpec.describe Validations::FinancialValidations do
record.hb = 3
financial_validator.validate_tshortfall(record)
expect(record.errors["tshortfall"])
.to include(match I18n.t("validations.financial.hbrentshortfall.outstanding_no_benefits"))
end
it "validates that housing benefit is not Universal Credit without housing benefit (prior to 22/23)" do
record.startdate = Time.zone.local(2022, 3, 1)
record.hbrentshortfall = 1
record.hb = 7
financial_validator.validate_tshortfall(record)
expect(record.errors["tshortfall"])
.to include(match I18n.t("validations.financial.hbrentshortfall.outstanding_no_benefits"))
.to include(match I18n.t("validations.lettings.financial.tshortfall.outstanding_no_benefits"))
end
it "validates that housing benefit is provided" do
@ -375,15 +366,15 @@ RSpec.describe Validations::FinancialValidations do
financial_validator.validate_negative_currency(record)
expect(record.errors["earnings"])
.to include(match I18n.t("validations.financial.negative_currency"))
.to include(match I18n.t("validations.lettings.financial.earnings.negative_currency"))
expect(record.errors["brent"])
.to include(match I18n.t("validations.financial.negative_currency"))
.to include(match I18n.t("validations.lettings.financial.brent.negative_currency"))
expect(record.errors["scharge"])
.to include(match I18n.t("validations.financial.negative_currency"))
.to include(match I18n.t("validations.lettings.financial.scharge.negative_currency"))
expect(record.errors["pscharge"])
.to include(match I18n.t("validations.financial.negative_currency"))
.to include(match I18n.t("validations.lettings.financial.pscharge.negative_currency"))
expect(record.errors["supcharg"])
.to include(match I18n.t("validations.financial.negative_currency"))
.to include(match I18n.t("validations.lettings.financial.supcharg.negative_currency"))
end
end
@ -466,7 +457,7 @@ RSpec.describe Validations::FinancialValidations do
record[test_case[:charge][:field]] = test_case[:charge][:value]
financial_validator.validate_rent_amount(record)
expect(record.errors[test_case[:charge][:field]])
.to include(match I18n.t("validations.financial.rent.out_of_range", charge_name: test_case[:charge_name], maximum_per_period: test_case[:maximum_per_period], frequency: test_case[:period][:label], letting_type: "general needs", provider_type: "private registered provider"))
.to include(match I18n.t("validations.lettings.financial.#{test_case[:charge][:field]}.rent_out_of_range", charge_name: test_case[:charge_name], maximum_per_period: test_case[:maximum_per_period], frequency: test_case[:period][:label], letting_type: "general needs", provider_type: "private registered provider"))
end
end
@ -578,7 +569,7 @@ RSpec.describe Validations::FinancialValidations do
record[test_case[:charge][:field]] = test_case[:charge][:value]
financial_validator.validate_rent_amount(record)
expect(record.errors[test_case[:charge][:field]])
.to include(match I18n.t("validations.financial.rent.out_of_range", charge_name: test_case[:charge_name], maximum_per_period: test_case[:maximum_per_period], frequency: test_case[:period][:label], letting_type: "supported housing", provider_type: "private registered provider"))
.to include(match I18n.t("validations.lettings.financial.#{test_case[:charge][:field]}.rent_out_of_range", charge_name: test_case[:charge_name], maximum_per_period: test_case[:maximum_per_period], frequency: test_case[:period][:label], letting_type: "supported housing", provider_type: "private registered provider"))
end
end
@ -694,7 +685,7 @@ RSpec.describe Validations::FinancialValidations do
record[test_case[:charge][:field]] = test_case[:charge][:value]
financial_validator.validate_rent_amount(record)
expect(record.errors[test_case[:charge][:field]])
.to include(match I18n.t("validations.financial.rent.out_of_range", charge_name: test_case[:charge_name], maximum_per_period: test_case[:maximum_per_period], frequency: test_case[:period][:label], letting_type: "general needs", provider_type: "local authority"))
.to include(match I18n.t("validations.lettings.financial.#{test_case[:charge][:field]}.rent_out_of_range", charge_name: test_case[:charge_name], maximum_per_period: test_case[:maximum_per_period], frequency: test_case[:period][:label], letting_type: "general needs", provider_type: "local authority"))
end
end
@ -806,7 +797,7 @@ RSpec.describe Validations::FinancialValidations do
record[test_case[:charge][:field]] = test_case[:charge][:value]
financial_validator.validate_rent_amount(record)
expect(record.errors[test_case[:charge][:field]])
.to include(match I18n.t("validations.financial.rent.out_of_range", charge_name: test_case[:charge_name], maximum_per_period: test_case[:maximum_per_period], frequency: test_case[:period][:label], letting_type: "supported housing", provider_type: "local authority"))
.to include(match I18n.t("validations.lettings.financial.#{test_case[:charge][:field]}.rent_out_of_range", charge_name: test_case[:charge_name], maximum_per_period: test_case[:maximum_per_period], frequency: test_case[:period][:label], letting_type: "supported housing", provider_type: "local authority"))
end
end
@ -885,7 +876,7 @@ RSpec.describe Validations::FinancialValidations do
record.tcharge = 9
financial_validator.validate_rent_amount(record)
expect(record.errors["tcharge"])
.to include(match I18n.t("validations.financial.tcharge.under_10"))
.to include(match I18n.t("validations.lettings.financial.tcharge.under_10"))
end
it "allows the total charge to be over 10 per week" do
@ -903,7 +894,7 @@ RSpec.describe Validations::FinancialValidations do
record.tcharge = 19.99
financial_validator.validate_rent_amount(record)
expect(record.errors["tcharge"])
.to include(match I18n.t("validations.financial.tcharge.under_10"))
.to include(match I18n.t("validations.lettings.financial.tcharge.under_10"))
end
it "allows the total charge to be over 10 per week" do
@ -922,11 +913,11 @@ RSpec.describe Validations::FinancialValidations do
record.household_charge = 1
financial_validator.validate_rent_amount(record)
expect(record.errors["tcharge"])
.to include(match I18n.t("validations.financial.charges.complete_1_of_3"))
.to include(match I18n.t("validations.lettings.financial.tcharge.complete_1_of_3"))
expect(record.errors["chcharge"])
.to include(match I18n.t("validations.financial.charges.complete_1_of_3"))
.to include(match I18n.t("validations.lettings.financial.chcharge.complete_1_of_3"))
expect(record.errors["household_charge"])
.to include(match I18n.t("validations.financial.charges.complete_1_of_3"))
.to include(match I18n.t("validations.lettings.financial.household_charge.complete_1_of_3"))
end
it "returns an error for tcharge and chcharge types selected" do
@ -936,9 +927,9 @@ RSpec.describe Validations::FinancialValidations do
expect(record.errors["household_charge"])
.to be_empty
expect(record.errors["tcharge"])
.to include(match I18n.t("validations.financial.charges.complete_1_of_3"))
.to include(match I18n.t("validations.lettings.financial.tcharge.complete_1_of_3"))
expect(record.errors["chcharge"])
.to include(match I18n.t("validations.financial.charges.complete_1_of_3"))
.to include(match I18n.t("validations.lettings.financial.chcharge.complete_1_of_3"))
end
it "returns an error for tcharge type and household_charge not paid selected" do
@ -948,9 +939,9 @@ RSpec.describe Validations::FinancialValidations do
expect(record.errors["chcharge"])
.to be_empty
expect(record.errors["tcharge"])
.to include(match I18n.t("validations.financial.charges.complete_1_of_3"))
.to include(match I18n.t("validations.lettings.financial.tcharge.complete_1_of_3"))
expect(record.errors["household_charge"])
.to include(match I18n.t("validations.financial.charges.complete_1_of_3"))
.to include(match I18n.t("validations.lettings.financial.household_charge.complete_1_of_3"))
end
it "returns an error for chcharge type and household_charge not paid selected" do
@ -960,9 +951,9 @@ RSpec.describe Validations::FinancialValidations do
expect(record.errors["tcharge"])
.to be_empty
expect(record.errors["chcharge"])
.to include(match I18n.t("validations.financial.charges.complete_1_of_3"))
.to include(match I18n.t("validations.lettings.financial.chcharge.complete_1_of_3"))
expect(record.errors["household_charge"])
.to include(match I18n.t("validations.financial.charges.complete_1_of_3"))
.to include(match I18n.t("validations.lettings.financial.household_charge.complete_1_of_3"))
end
end
@ -1038,7 +1029,7 @@ RSpec.describe Validations::FinancialValidations do
financial_validator.validate_rent_amount(record)
expect(record.errors["brent"])
.to include(match I18n.t("validations.financial.brent.below_hard_min"))
.to include(match I18n.t("validations.lettings.financial.brent.below_hard_min"))
end
it "validates hard minimum for supported housing" do
@ -1051,11 +1042,11 @@ RSpec.describe Validations::FinancialValidations do
financial_validator.validate_rent_amount(record)
expect(record.errors["brent"])
.to include(match I18n.t("validations.financial.brent.below_hard_min"))
.to include(match I18n.t("validations.lettings.financial.brent.below_hard_min"))
%w[beds la postcode_known scheme_id location_id rent_type needstype period].each do |field|
expect(record.errors[field])
.to include(match I18n.t("validations.financial.brent.#{field}.below_hard_min"))
.to include(match I18n.t("validations.lettings.financial.#{field}.rent_below_hard_min"))
end
end
@ -1070,11 +1061,11 @@ RSpec.describe Validations::FinancialValidations do
financial_validator.validate_rent_amount(record)
expect(record.errors["brent"])
.to include(match I18n.t("validations.financial.brent.above_hard_max"))
.to include(match I18n.t("validations.lettings.financial.brent.above_hard_max"))
%w[beds la postcode_known scheme_id location_id rent_type needstype period].each do |field|
expect(record.errors[field])
.to include(match I18n.t("validations.financial.brent.#{field}.above_hard_max"))
.to include(match I18n.t("validations.lettings.financial.#{field}.rent_above_hard_max"))
end
end
@ -1088,11 +1079,11 @@ RSpec.describe Validations::FinancialValidations do
financial_validator.validate_rent_amount(record)
expect(record.errors["brent"])
.to include(match I18n.t("validations.financial.brent.above_hard_max"))
.to include(match I18n.t("validations.lettings.financial.brent.above_hard_max"))
%w[beds la postcode_known scheme_id location_id rent_type needstype period].each do |field|
expect(record.errors[field])
.to include(match I18n.t("validations.financial.brent.#{field}.above_hard_max"))
.to include(match I18n.t("validations.lettings.financial.#{field}.rent_above_hard_max"))
end
end
@ -1106,11 +1097,11 @@ RSpec.describe Validations::FinancialValidations do
financial_validator.validate_rent_amount(record)
expect(record.errors["brent"])
.to include(match I18n.t("validations.financial.brent.above_hard_max"))
.to include(match I18n.t("validations.lettings.financial.brent.above_hard_max"))
%w[beds la postcode_known scheme_id location_id rent_type needstype period].each do |field|
expect(record.errors[field])
.to include(match I18n.t("validations.financial.brent.#{field}.above_hard_max"))
.to include(match I18n.t("validations.lettings.financial.#{field}.rent_above_hard_max"))
end
end
@ -1213,9 +1204,9 @@ RSpec.describe Validations::FinancialValidations do
record.chcharge = nil
financial_validator.validate_care_home_charges(record)
expect(record.errors["chcharge"])
.to include(match I18n.t("validations.financial.carehome.not_provided", period: "every 4 weeks"))
.to include(match I18n.t("validations.lettings.financial.carehome.not_provided", period: "every 4 weeks"))
expect(record.errors["is_carehome"])
.to include(match I18n.t("validations.financial.carehome.not_provided", period: "every 4 weeks"))
.to include(match I18n.t("validations.lettings.financial.carehome.not_provided", period: "every 4 weeks"))
end
end

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save