diff --git a/app/models/form/lettings/pages/address.rb b/app/models/form/lettings/pages/address.rb
index 6f88bad0d..cf6f73036 100644
--- a/app/models/form/lettings/pages/address.rb
+++ b/app/models/form/lettings/pages/address.rb
@@ -2,7 +2,7 @@ class Form::Lettings::Pages::Address < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "address"
- @header = "What is the property's address?"
+ @header = "Q12 - What is the property's address?"
end
def questions
diff --git a/app/models/form/lettings/questions/address_line1.rb b/app/models/form/lettings/questions/address_line1.rb
index 6f82edf45..b3288c82c 100644
--- a/app/models/form/lettings/questions/address_line1.rb
+++ b/app/models/form/lettings/questions/address_line1.rb
@@ -6,7 +6,7 @@ class Form::Lettings::Questions::AddressLine1 < ::Form::Question
@header = "Address line 1"
@type = "text"
@plain_label = true
- @question_number = 12
+ @check_answer_label = "Q12 - Address"
end
def hidden_in_check_answers?(log, _current_user = nil)
diff --git a/app/models/form/lettings/questions/uprn_known.rb b/app/models/form/lettings/questions/uprn_known.rb
index 6e3ce0302..d206885fb 100644
--- a/app/models/form/lettings/questions/uprn_known.rb
+++ b/app/models/form/lettings/questions/uprn_known.rb
@@ -3,7 +3,7 @@ class Form::Lettings::Questions::UprnKnown < ::Form::Question
super
@id = "uprn_known"
@check_answer_label = "UPRN known?"
- @header = "Do you know the property UPRN?"
+ @header = "Do you know the property's UPRN?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@hint_text = "The Unique Property Reference Number (UPRN) is a unique number system created by Ordnance Survey and used by housing providers and sectors UK-wide. For example 10010457355.
diff --git a/app/models/form/sales/pages/address.rb b/app/models/form/sales/pages/address.rb
index aa8ab7e0d..ca686d1b1 100644
--- a/app/models/form/sales/pages/address.rb
+++ b/app/models/form/sales/pages/address.rb
@@ -2,7 +2,7 @@ class Form::Sales::Pages::Address < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "address"
- @header = "What is the property's address?"
+ @header = "Q15 - What is the property's address?"
end
def questions
diff --git a/app/models/form/sales/questions/address_line1.rb b/app/models/form/sales/questions/address_line1.rb
index 2dd3a734e..a71229970 100644
--- a/app/models/form/sales/questions/address_line1.rb
+++ b/app/models/form/sales/questions/address_line1.rb
@@ -6,7 +6,7 @@ class Form::Sales::Questions::AddressLine1 < ::Form::Question
@header = "Address line 1"
@type = "text"
@plain_label = true
- @question_number = 15
+ @check_answer_label = "Q15 - Address"
end
def hidden_in_check_answers?(log, _current_user = nil)
diff --git a/app/models/form/sales/questions/uprn_known.rb b/app/models/form/sales/questions/uprn_known.rb
index 9f192f7de..b07b0b7d7 100644
--- a/app/models/form/sales/questions/uprn_known.rb
+++ b/app/models/form/sales/questions/uprn_known.rb
@@ -3,7 +3,7 @@ class Form::Sales::Questions::UprnKnown < ::Form::Question
super
@id = "uprn_known"
@check_answer_label = "UPRN known?"
- @header = "Do you know the property UPRN?"
+ @header = "Do you know the property's UPRN?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@hint_text = "The Unique Property Reference Number (UPRN) is a unique number system created by Ordnance Survey and used by housing providers and sectors UK-wide. For example 10010457355.
diff --git a/app/models/form_handler.rb b/app/models/form_handler.rb
index 12ae4473b..b2d9168b2 100644
--- a/app/models/form_handler.rb
+++ b/app/models/form_handler.rb
@@ -47,7 +47,7 @@ class FormHandler
form = Form.new(form_path)
form_to_set = form_name_from_start_year(form.start_date.year, "lettings")
- forms[form_to_set] = form if forms[form_to_set].blank?
+ forms[form_to_set] = form if form_to_set && forms[form_to_set].blank?
end
end
diff --git a/app/models/validations/household_validations.rb b/app/models/validations/household_validations.rb
index 0b871fce0..e56a16783 100644
--- a/app/models/validations/household_validations.rb
+++ b/app/models/validations/household_validations.rb
@@ -35,12 +35,6 @@ module Validations::HouseholdValidations
end
end
- def validate_pregnancy(record)
- if (record.has_pregnancy? || record.pregnancy_refused?) && women_in_household(record) && !women_of_child_bearing_age_in_household(record)
- record.errors.add :preg_occ, I18n.t("validations.household.preg_occ.no_female")
- end
- end
-
def validate_household_number_of_other_members(record)
(2..8).each do |n|
validate_person_age_matches_economic_status(record, n)
diff --git a/app/models/validations/soft_validations.rb b/app/models/validations/soft_validations.rb
index fc2c469ca..fbc5ab3b9 100644
--- a/app/models/validations/soft_validations.rb
+++ b/app/models/validations/soft_validations.rb
@@ -53,11 +53,11 @@ module Validations::SoftValidations
end
def no_females_in_a_pregnant_household?
- !females_in_the_household? && all_tenants_age_and_gender_information_completed? && preg_occ == 1
+ !females_in_the_household? && all_tenants_gender_information_completed? && preg_occ == 1
end
def female_in_pregnant_household_in_soft_validation_range?
- all_tenants_age_and_gender_information_completed? && (females_in_age_range(11, 15) || females_in_age_range(51, 65)) && !females_in_age_range(16, 50) && preg_occ == 1
+ all_tenants_age_and_gender_information_completed? && females_in_the_household? && !females_in_age_range(16, 50) && preg_occ == 1
end
def all_tenants_age_and_gender_information_completed?
@@ -66,6 +66,12 @@ module Validations::SoftValidations
end
end
+ def all_tenants_gender_information_completed?
+ (1..hhmemb).all? do |n|
+ public_send("sex#{n}").present? && details_known_or_lead_tenant?(n)
+ end
+ end
+
TWO_YEARS_IN_DAYS = 730
TEN_YEARS_IN_DAYS = 3650
diff --git a/app/services/bulk_upload/lettings/year2022/row_parser.rb b/app/services/bulk_upload/lettings/year2022/row_parser.rb
index b2bc24110..d9cc99505 100644
--- a/app/services/bulk_upload/lettings/year2022/row_parser.rb
+++ b/app/services/bulk_upload/lettings/year2022/row_parser.rb
@@ -308,14 +308,14 @@ class BulkUpload::Lettings::Year2022::RowParser
validate :validate_dont_know_disabled_needs_conjunction
validate :validate_no_and_dont_know_disabled_needs_conjunction
- validate :validate_owning_org_permitted
- validate :validate_owning_org_owns_stock
- validate :validate_owning_org_exists
validate :validate_owning_org_data_given
+ validate :validate_owning_org_exists
+ validate :validate_owning_org_owns_stock
+ validate :validate_owning_org_permitted
- validate :validate_managing_org_related
- validate :validate_managing_org_exists
validate :validate_managing_org_data_given
+ validate :validate_managing_org_exists
+ validate :validate_managing_org_related
validate :validate_scheme_related
validate :validate_scheme_exists
@@ -436,19 +436,26 @@ private
def validate_managing_org_related
if owning_organisation && managing_organisation && !owning_organisation.can_be_managed_by?(organisation: managing_organisation)
block_log_creation!
- errors.add(:field_113, "This managing organisation does not have a relationship with the owning organisation")
+
+ if errors[:field_113].blank?
+ errors.add(:field_113, "This managing organisation does not have a relationship with the owning organisation")
+ end
end
end
def validate_managing_org_exists
if managing_organisation.nil?
- errors.delete(:field_113)
- errors.add(:field_113, "The managing organisation code is incorrect")
+ block_log_creation!
+
+ if errors[:field_113].blank?
+ errors.add(:field_113, "The managing organisation code is incorrect")
+ end
end
end
def validate_managing_org_data_given
if field_113.blank?
+ block_log_creation!
errors.add(:field_113, "The managing organisation code is incorrect", category: :setup)
end
end
@@ -456,29 +463,40 @@ private
def validate_owning_org_owns_stock
if owning_organisation && !owning_organisation.holds_own_stock?
block_log_creation!
- errors.delete(:field_111)
- errors.add(:field_111, "The owning organisation code provided is for an organisation that does not own stock")
+
+ if errors[:field_111].blank?
+ errors.add(:field_111, "The owning organisation code provided is for an organisation that does not own stock")
+ end
end
end
def validate_owning_org_exists
if owning_organisation.nil?
- errors.delete(:field_111)
- errors.add(:field_111, "The owning organisation code is incorrect")
+ block_log_creation!
+
+ if errors[:field_111].blank?
+ errors.add(:field_111, "The owning organisation code is incorrect")
+ end
end
end
def validate_owning_org_data_given
if field_111.blank?
- errors.add(:field_111, "The owning organisation code is incorrect", category: :setup)
+ block_log_creation!
+
+ if errors[:field_111].blank?
+ errors.add(:field_111, "The owning organisation code is incorrect", category: :setup)
+ end
end
end
def validate_owning_org_permitted
if owning_organisation && !bulk_upload.user.organisation.affiliated_stock_owners.include?(owning_organisation)
block_log_creation!
- errors.delete(:field_111)
- errors.add(:field_111, "You do not have permission to add logs for this owning organisation")
+
+ if errors[:field_111].blank?
+ errors.add(:field_111, "You do not have permission to add logs for this owning organisation")
+ end
end
end
diff --git a/app/services/bulk_upload/lettings/year2023/row_parser.rb b/app/services/bulk_upload/lettings/year2023/row_parser.rb
index e4ba7cb82..dc2a04a66 100644
--- a/app/services/bulk_upload/lettings/year2023/row_parser.rb
+++ b/app/services/bulk_upload/lettings/year2023/row_parser.rb
@@ -311,14 +311,14 @@ class BulkUpload::Lettings::Year2023::RowParser
validate :validate_dont_know_disabled_needs_conjunction
validate :validate_no_and_dont_know_disabled_needs_conjunction
- validate :validate_owning_org_permitted
- validate :validate_owning_org_owns_stock
- validate :validate_owning_org_exists
validate :validate_owning_org_data_given
+ validate :validate_owning_org_exists
+ validate :validate_owning_org_owns_stock
+ validate :validate_owning_org_permitted
- validate :validate_managing_org_related
- validate :validate_managing_org_exists
validate :validate_managing_org_data_given
+ validate :validate_managing_org_exists
+ validate :validate_managing_org_related
validate :validate_scheme_related
validate :validate_scheme_exists
@@ -551,19 +551,26 @@ private
def validate_managing_org_related
if owning_organisation && managing_organisation && !owning_organisation.can_be_managed_by?(organisation: managing_organisation)
block_log_creation!
- errors.add(:field_2, "This managing organisation does not have a relationship with the owning organisation")
+
+ if errors[:field_2].blank?
+ errors.add(:field_2, "This managing organisation does not have a relationship with the owning organisation")
+ end
end
end
def validate_managing_org_exists
if managing_organisation.nil?
- errors.delete(:field_2)
- errors.add(:field_2, "The managing organisation code is incorrect")
+ block_log_creation!
+
+ if errors[:field_2].blank?
+ errors.add(:field_2, "The managing organisation code is incorrect")
+ end
end
end
def validate_managing_org_data_given
if field_2.blank?
+ block_log_creation!
errors.add(:field_2, "The managing organisation code is incorrect", category: :setup)
end
end
@@ -571,20 +578,26 @@ private
def validate_owning_org_owns_stock
if owning_organisation && !owning_organisation.holds_own_stock?
block_log_creation!
- errors.delete(:field_1)
- errors.add(:field_1, "The owning organisation code provided is for an organisation that does not own stock")
+
+ if errors[:field_1].blank?
+ errors.add(:field_1, "The owning organisation code provided is for an organisation that does not own stock")
+ end
end
end
def validate_owning_org_exists
if owning_organisation.nil?
- errors.delete(:field_1)
- errors.add(:field_1, "The owning organisation code is incorrect")
+ block_log_creation!
+
+ if errors[:field_1].blank?
+ errors.add(:field_1, "The owning organisation code is incorrect")
+ end
end
end
def validate_owning_org_data_given
if field_1.blank?
+ block_log_creation!
errors.add(:field_1, "The owning organisation code is incorrect", category: :setup)
end
end
@@ -592,8 +605,10 @@ private
def validate_owning_org_permitted
if owning_organisation && !bulk_upload.user.organisation.affiliated_stock_owners.include?(owning_organisation)
block_log_creation!
- errors.delete(:field_1)
- errors.add(:field_1, "You do not have permission to add logs for this owning organisation")
+
+ if errors[:field_1].blank?
+ errors.add(:field_1, "You do not have permission to add logs for this owning organisation")
+ end
end
end
diff --git a/config/initializers/feature_toggle.rb b/config/initializers/feature_toggle.rb
index 6c889bcc5..de1c11fbd 100644
--- a/config/initializers/feature_toggle.rb
+++ b/config/initializers/feature_toggle.rb
@@ -5,7 +5,7 @@ class FeatureToggle
end
def self.startdate_collection_window_validation_enabled?
- Rails.env.production? || Rails.env.test? || Rails.env.staging?
+ Rails.env.production? || Rails.env.test?
end
def self.startdate_two_week_validation_enabled?
diff --git a/config/locales/en.yml b/config/locales/en.yml
index a7a5e5400..7e514b17f 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -335,8 +335,6 @@ en:
leftreg:
question_required: "Tell us whether the person is still serving in the UK armed forces as you told us they’re a current or former regular"
question_not_required: "You cannot answer whether the person is still serving in the UK armed forces as you told us they’re not a current or former regular"
- preg_occ:
- no_female: "Enter ‘no’ as there are no female tenants aged 11-65 in the household"
age:
retired_male: "A male tenant who is retired must be 65 or over"
retired_female: "A female tenant who is retired must be 60 or over"
@@ -516,7 +514,7 @@ en:
pregnancy:
title: "You told us somebody in the household is pregnant"
no_females: "You also told us there are no female tenants living at the property."
- females_not_in_soft_age_range: "You also told us that any female tenants living at the property are in the following age ranges: