diff --git a/app/models/derived_variables/lettings_log_variables.rb b/app/models/derived_variables/lettings_log_variables.rb index d0aab14cb..ac17e0219 100644 --- a/app/models/derived_variables/lettings_log_variables.rb +++ b/app/models/derived_variables/lettings_log_variables.rb @@ -91,6 +91,9 @@ module DerivedVariables::LettingsLogVariables self.prevten = 30 if owning_organisation&.provider_type == "LA" end end + if form.start_year_after_2024? && is_bedsit? + self.beds = 1 + end child_under_16_constraints! @@ -179,6 +182,9 @@ private self.wchair = nil self.location_id = nil end + if form.start_year_after_2024? && (unittype_gn_changed? && unittype_gn_was == 2) + self.beds = nil + end end def get_totelder diff --git a/app/models/derived_variables/sales_log_variables.rb b/app/models/derived_variables/sales_log_variables.rb index 12d860492..f662ab3df 100644 --- a/app/models/derived_variables/sales_log_variables.rb +++ b/app/models/derived_variables/sales_log_variables.rb @@ -24,6 +24,10 @@ module DerivedVariables::SalesLogVariables self.hhmemb = number_of_household_members self.hhtype = household_type + if saledate && form.start_year_after_2024? + self.soctenant = soctenant_from_prevten_values + end + self.uprn_known = 0 if address_answered_without_uprn? if uprn_known&.zero? @@ -157,4 +161,14 @@ private def address_answered_without_uprn? [address_line1, town_or_city].all?(&:present?) && uprn.nil? && form.start_date.year >= 2023 end + + def soctenant_from_prevten_values + return unless prevten && shared_ownership_scheme? + + prevten_was_social_housing? ? 1 : 2 + end + + def prevten_was_social_housing? + [1, 2].include?(prevten) || [1, 2].include?(prevtenbuy2) + end end diff --git a/app/models/form/lettings/pages/property_number_of_bedrooms.rb b/app/models/form/lettings/pages/property_number_of_bedrooms.rb index c3a1a2365..8ed9dc37a 100644 --- a/app/models/form/lettings/pages/property_number_of_bedrooms.rb +++ b/app/models/form/lettings/pages/property_number_of_bedrooms.rb @@ -2,7 +2,7 @@ class Form::Lettings::Pages::PropertyNumberOfBedrooms < ::Form::Page def initialize(id, hsh, subsection) super @id = "property_number_of_bedrooms" - @depends_on = [{ "is_general_needs?" => true }] + @depends_on = [{ "is_general_needs?" => true, "is_beds_inferred?" => false }] end def questions diff --git a/app/models/form/lettings/questions/beds.rb b/app/models/form/lettings/questions/beds.rb index 6fa6c7c2b..e75e688bb 100644 --- a/app/models/form/lettings/questions/beds.rb +++ b/app/models/form/lettings/questions/beds.rb @@ -9,8 +9,11 @@ class Form::Lettings::Questions::Beds < ::Form::Question @check_answers_card_number = 0 @max = 12 @min = 1 - @hint_text = "If shared accommodation, enter the number of bedrooms occupied by this household. A bedsit has 1 bedroom." @step = 1 @question_number = 22 end + + def hint_text + form.start_year_after_2024? ? "If shared accommodation, enter the number of bedrooms occupied by this household." : "If shared accommodation, enter the number of bedrooms occupied by this household. A bedsit has 1 bedroom." + end end diff --git a/app/models/form/lettings/questions/gender_identity1.rb b/app/models/form/lettings/questions/gender_identity1.rb index 769dc1850..f7bba8e89 100644 --- a/app/models/form/lettings/questions/gender_identity1.rb +++ b/app/models/form/lettings/questions/gender_identity1.rb @@ -6,7 +6,6 @@ class Form::Lettings::Questions::GenderIdentity1 < ::Form::Question @header = "Which of these best describes the lead tenant’s gender identity?" @type = "radio" @check_answers_card_number = 1 - @hint_text = "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." @answer_options = ANSWER_OPTIONS @question_number = 33 end @@ -18,4 +17,12 @@ class Form::Lettings::Questions::GenderIdentity1 < ::Form::Question "divider" => { "value" => true }, "R" => { "value" => "Tenant prefers not to say" }, }.freeze + + def hint_text + if form.start_year_after_2024? + "This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth." + else + "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." + end + end end diff --git a/app/models/form/lettings/questions/person_gender_identity.rb b/app/models/form/lettings/questions/person_gender_identity.rb index 1416a3414..657438071 100644 --- a/app/models/form/lettings/questions/person_gender_identity.rb +++ b/app/models/form/lettings/questions/person_gender_identity.rb @@ -6,7 +6,6 @@ class Form::Lettings::Questions::PersonGenderIdentity < ::Form::Question @header = "Which of these best describes person #{person_index}’s gender identity?" @type = "radio" @check_answers_card_number = person_index - @hint_text = "" @answer_options = ANSWER_OPTIONS @question_number = 32 + (4 * person_index) end @@ -18,4 +17,12 @@ class Form::Lettings::Questions::PersonGenderIdentity < ::Form::Question "divider" => { "value" => true }, "R" => { "value" => "Person prefers not to say" }, }.freeze + + def hint_text + if form.start_year_after_2024? + "This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth." + else + "" + end + end end diff --git a/app/models/form/lettings/questions/reason.rb b/app/models/form/lettings/questions/reason.rb index 9598780ec..a60cc3b3f 100644 --- a/app/models/form/lettings/questions/reason.rb +++ b/app/models/form/lettings/questions/reason.rb @@ -6,8 +6,7 @@ class Form::Lettings::Questions::Reason < ::Form::Question @header = "What is the tenant’s main reason for the household leaving their last settled home?" @type = "radio" @check_answers_card_number = 0 - @hint_text = "The tenant’s ‘last settled home’ is their last long-standing home. For tenants who were in temporary accommodation or sleeping rough, their last settled home is where they were living previously." - @answer_options = ANSWER_OPTIONS + @hint_text = form.start_year_after_2024? ? "The tenant’s ‘last settled home’ is their last long-standing home. For tenants who were in temporary accommodation, sleeping rough or otherwise homeless, their last settled home is where they were living previously." : "The tenant’s ‘last settled home’ is their last long-standing home. For tenants who were in temporary accommodation or sleeping rough, their last settled home is where they were living previously." @conditional_for = { "reasonother" => [ 20, @@ -16,114 +15,81 @@ class Form::Lettings::Questions::Reason < ::Form::Question @question_number = 77 end - ANSWER_OPTIONS = { - "40" => { - "value" => "End of assured shorthold tenancy (no fault)", - }, - "41" => { - "value" => "End of assured shorthold tenancy (eviction or tenant at fault)", - }, - "42" => { - "value" => "End of fixed term tenancy (no fault)", - }, - "43" => { - "value" => "End of fixed term tenancy (eviction or tenant at fault)", - }, - "1" => { - "value" => "Permanently decanted from another property owned by this landlord", - }, - "46" => { - "value" => "Discharged from long-stay hospital or similar institution", - }, - "45" => { - "value" => "Discharged from prison", - }, - "2" => { - "value" => "Left home country as a refugee", - }, - "4" => { - "value" => "Loss of tied accommodation", - }, - "9" => { - "value" => "Asked to leave by family or friends", - }, - "44" => { - "value" => "Death of household member in last settled accommodation", - }, - "8" => { - "value" => "Relationship breakdown (non-violent) with partner", - }, - "16" => { - "value" => "To move nearer to family, friends or school", - }, - "17" => { - "value" => "To move nearer to work", - }, - "48" => { - "value" => "Domestic abuse - previously joint tenancy with partner", - }, - "49" => { - "value" => "Domestic abuse - other", - }, - "31" => { - "value" => "Hate crime", - }, - "10" => { - "value" => "Racial harassment", - }, - "11" => { - "value" => "Other problems with neighbours", - }, - "35" => { - "value" => "Couldn’t afford fees attached to renewing the tenancy", - }, - "36" => { - "value" => "Couldn’t afford increase in rent", - }, - "38" => { - "value" => "Couldn’t afford rent or mortgage (employment)", - }, - "37" => { - "value" => "Couldn’t afford rent or mortgage (welfare reforms)", - }, - "39" => { - "value" => "Couldn’t afford rent or mortgage (other)", - }, - "34" => { - "value" => "Repossession", - }, - "12" => { - "value" => "Property unsuitable because of overcrowding", - }, - "13" => { - "value" => "Property unsuitable because of ill health or disability", - }, - "14" => { - "value" => "Property unsuitable because of poor condition", - }, - "18" => { - "value" => "To move to accommodation with support", - }, - "19" => { - "value" => "To move to independent accommodation", - }, - "30" => { - "value" => "Under occupation (no incentive)", - }, - "29" => { - "value" => "Under occupation (offered incentive to downsize)", - }, - "20" => { - "value" => "Other", - }, - "47" => { - "value" => "Tenant prefers not to say", - }, - "divider" => { - "value" => true, - }, - "28" => { - "value" => "Don’t know", - }, - }.freeze + def answer_options + if form.start_year_after_2024? + { + "50" => { "value" => "End of social housing tenancy - no fault" }, + "51" => { "value" => "End of social housing tenancy - evicted due to anti-social behaviour (ASB)" }, + "52" => { "value" => "End of social housing tenancy - evicted due to rent arrears" }, + "53" => { "value" => "End of social housing tenancy - evicted for any other reason" }, + "1" => { "value" => "Permanently decanted from another property owned by this landlord" }, + "2" => { "value" => "Left home country as a refugee" }, + "45" => { "value" => "Discharged from prison" }, + "46" => { "value" => "Discharged from long-stay hospital or similar institution" }, + "4" => { "value" => "Loss of tied accommodation" }, + "9" => { "value" => "Asked to leave by family or friends" }, + "8" => { "value" => "Relationship breakdown (non-violent) with partner" }, + "44" => { "value" => "Death of household member in last settled accommodation" }, + "16" => { "value" => "To move nearer to family, friends or school" }, + "17" => { "value" => "To move nearer to work" }, + "48" => { "value" => "Domestic abuse - previously joint tenancy with partner" }, + "49" => { "value" => "Domestic abuse - other" }, + "10" => { "value" => "Racial harassment" }, + "31" => { "value" => "Hate crime" }, + "11" => { "value" => "Other problems with neighbours" }, + "34" => { "value" => "Repossession" }, + "54" => { "value" => "Could no longer afford rent or mortgage" }, + "12" => { "value" => "Property unsuitable because of overcrowding" }, + "13" => { "value" => "Property unsuitable because of ill health or disability" }, + "14" => { "value" => "Property unsuitable because of poor condition" }, + "29" => { "value" => "Under occupation (offered incentive to downsize)" }, + "30" => { "value" => "Under occupation (no incentive)" }, + "18" => { "value" => "To move to accommodation with support" }, + "19" => { "value" => "To move to independent accommodation" }, + "20" => { "value" => "Other" }, + "28" => { "value" => "Don’t know" }, + "divider" => { "value" => true }, + "47" => { "value" => "Tenant prefers not to say" }, + }.freeze + else + { + "40" => { "value" => "End of assured shorthold tenancy (no fault)" }, + "41" => { "value" => "End of assured shorthold tenancy (eviction or tenant at fault)" }, + "42" => { "value" => "End of fixed term tenancy (no fault)" }, + "43" => { "value" => "End of fixed term tenancy (eviction or tenant at fault)" }, + "1" => { "value" => "Permanently decanted from another property owned by this landlord" }, + "46" => { "value" => "Discharged from long-stay hospital or similar institution" }, + "45" => { "value" => "Discharged from prison" }, + "2" => { "value" => "Left home country as a refugee" }, + "4" => { "value" => "Loss of tied accommodation" }, + "9" => { "value" => "Asked to leave by family or friends" }, + "44" => { "value" => "Death of household member in last settled accommodation" }, + "8" => { "value" => "Relationship breakdown (non-violent) with partner" }, + "16" => { "value" => "To move nearer to family, friends or school" }, + "17" => { "value" => "To move nearer to work" }, + "48" => { "value" => "Domestic abuse - previously joint tenancy with partner" }, + "49" => { "value" => "Domestic abuse - other" }, + "31" => { "value" => "Hate crime" }, + "10" => { "value" => "Racial harassment" }, + "11" => { "value" => "Other problems with neighbours" }, + "35" => { "value" => "Couldn’t afford fees attached to renewing the tenancy" }, + "36" => { "value" => "Couldn’t afford increase in rent" }, + "38" => { "value" => "Couldn’t afford rent or mortgage (employment)" }, + "37" => { "value" => "Couldn’t afford rent or mortgage (welfare reforms)" }, + "39" => { "value" => "Couldn’t afford rent or mortgage (other)" }, + "34" => { "value" => "Repossession" }, + "12" => { "value" => "Property unsuitable because of overcrowding" }, + "13" => { "value" => "Property unsuitable because of ill health or disability" }, + "14" => { "value" => "Property unsuitable because of poor condition" }, + "18" => { "value" => "To move to accommodation with support" }, + "19" => { "value" => "To move to independent accommodation" }, + "30" => { "value" => "Under occupation (no incentive)" }, + "29" => { "value" => "Under occupation (offered incentive to downsize)" }, + "20" => { "value" => "Other" }, + "47" => { "value" => "Tenant prefers not to say" }, + "divider" => { "value" => true }, + "28" => { "value" => "Don’t know" }, + }.freeze + end + end end diff --git a/app/models/form/lettings/questions/reason_renewal.rb b/app/models/form/lettings/questions/reason_renewal.rb index 0158eba63..526df044c 100644 --- a/app/models/form/lettings/questions/reason_renewal.rb +++ b/app/models/form/lettings/questions/reason_renewal.rb @@ -7,7 +7,6 @@ class Form::Lettings::Questions::ReasonRenewal < ::Form::Question @type = "radio" @check_answers_card_number = 0 @hint_text = "You told us this letting is a renewal. We have removed some options because of this." - @answer_options = ANSWER_OPTIONS @question_number = 77 @conditional_for = { "reasonother" => [ @@ -16,20 +15,27 @@ class Form::Lettings::Questions::ReasonRenewal < ::Form::Question } end - ANSWER_OPTIONS = { - "40" => { "value" => "End of assured shorthold tenancy (no fault)" }, - "42" => { "value" => "End of fixed term tenancy (no fault)" }, - "20" => { - "value" => "Other", - }, - "47" => { - "value" => "Tenant prefers not to say", - }, - "divider" => { - "value" => true, - }, - "28" => { - "value" => "Don’t know", - }, - }.freeze + def answer_options + if form.start_year_after_2024? + { + "50" => { "value" => "End of social housing tenancy - no fault" }, + "51" => { "value" => "End of social housing tenancy - evicted due to anti-social behaviour (ASB)" }, + "52" => { "value" => "End of social housing tenancy - evicted due to rent arrears" }, + "53" => { "value" => "End of social housing tenancy - evicted for any other reason" }, + "20" => { "value" => "Other" }, + "47" => { "value" => "Tenant prefers not to say" }, + "divider" => { "value" => true }, + "28" => { "value" => "Don’t know" }, + }.freeze + else + { + "40" => { "value" => "End of assured shorthold tenancy (no fault)" }, + "42" => { "value" => "End of fixed term tenancy (no fault)" }, + "20" => { "value" => "Other" }, + "47" => { "value" => "Tenant prefers not to say" }, + "divider" => { "value" => true }, + "28" => { "value" => "Don’t know" }, + }.freeze + end + end end diff --git a/app/models/form/lettings/questions/wheelchair.rb b/app/models/form/lettings/questions/wheelchair.rb index 3ba4f081f..c2aaa3700 100644 --- a/app/models/form/lettings/questions/wheelchair.rb +++ b/app/models/form/lettings/questions/wheelchair.rb @@ -6,7 +6,7 @@ class Form::Lettings::Questions::Wheelchair < ::Form::Question @header = "Is the property built or adapted to wheelchair-user standards?" @type = "radio" @check_answers_card_number = 0 - @hint_text = "" + @hint_text = form.start_year_after_2024? ? "This is whether someone who uses a wheelchair is able to make full use of all of the property’s rooms and facilities, including use of both inside and outside space, and entering and exiting the property." : "" @answer_options = ANSWER_OPTIONS @question_number = 21 end diff --git a/app/models/form/sales/pages/buyer_previous.rb b/app/models/form/sales/pages/buyer_previous.rb index f37c6a847..3a4618d8f 100644 --- a/app/models/form/sales/pages/buyer_previous.rb +++ b/app/models/form/sales/pages/buyer_previous.rb @@ -2,7 +2,7 @@ class Form::Sales::Pages::BuyerPrevious < ::Form::Page def initialize(id, hsh, subsection, joint_purchase:) super(id, hsh, subsection) @joint_purchase = joint_purchase - @depends_on = [{ "joint_purchase?" => joint_purchase }] + @depends_on = [{ "joint_purchase?" => joint_purchase, "soctenant_is_inferred?" => false }] end def questions @@ -10,4 +10,10 @@ class Form::Sales::Pages::BuyerPrevious < ::Form::Page Form::Sales::Questions::BuyerPrevious.new(nil, nil, self, joint_purchase: @joint_purchase), ] end + + def routed_to?(log, _current_user) + return false if log.is_staircase? && log.form.start_year_after_2024? + + super + end end diff --git a/app/models/form/sales/pages/la_nominations.rb b/app/models/form/sales/pages/la_nominations.rb index e756e3071..0ac2cde75 100644 --- a/app/models/form/sales/pages/la_nominations.rb +++ b/app/models/form/sales/pages/la_nominations.rb @@ -9,4 +9,10 @@ class Form::Sales::Pages::LaNominations < ::Form::Page Form::Sales::Questions::LaNominations.new(nil, nil, self), ] end + + def routed_to?(log, _current_user) + return false if log.staircase == 1 && log.form.start_year_after_2024? + + super + end end diff --git a/app/models/form/sales/questions/buyer_live.rb b/app/models/form/sales/questions/buyer_live.rb index ee0a79611..2a3bf7eaf 100644 --- a/app/models/form/sales/questions/buyer_live.rb +++ b/app/models/form/sales/questions/buyer_live.rb @@ -3,7 +3,7 @@ class Form::Sales::Questions::BuyerLive < ::Form::Question super @id = "buylivein" @check_answer_label = "Buyers living in property" - @header = "Will the buyers live in the property?" + @header = form.start_year_after_2024? ? "Will any buyers live in the property?" : "Will the buyers live in the property?" @type = "radio" @answer_options = ANSWER_OPTIONS @question_number = 8 diff --git a/app/models/form/sales/questions/buyer_previous.rb b/app/models/form/sales/questions/buyer_previous.rb index aaea81cfc..cc16ce107 100644 --- a/app/models/form/sales/questions/buyer_previous.rb +++ b/app/models/form/sales/questions/buyer_previous.rb @@ -21,4 +21,8 @@ class Form::Sales::Questions::BuyerPrevious < ::Form::Question "2" => { "value" => "No" }, } end + + def derived? + form.start_year_after_2024? + end end diff --git a/app/models/form/sales/questions/discount.rb b/app/models/form/sales/questions/discount.rb index ee39b8916..4c4595ce1 100644 --- a/app/models/form/sales/questions/discount.rb +++ b/app/models/form/sales/questions/discount.rb @@ -6,7 +6,7 @@ class Form::Sales::Questions::Discount < ::Form::Question @header = "What was the percentage discount?" @type = "numeric" @min = 0 - @max = 100 + @max = form.start_year_after_2024? ? 70 : 100 @step = 1 @width = 5 @suffix = "%" diff --git a/app/models/form/sales/questions/gender_identity1.rb b/app/models/form/sales/questions/gender_identity1.rb index b9b47ee0a..7ee550df1 100644 --- a/app/models/form/sales/questions/gender_identity1.rb +++ b/app/models/form/sales/questions/gender_identity1.rb @@ -5,7 +5,6 @@ class Form::Sales::Questions::GenderIdentity1 < ::Form::Question @check_answer_label = "Buyer 1’s gender identity" @header = "Which of these best describes buyer 1’s gender identity?" @type = "radio" - @hint_text = "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." @answer_options = ANSWER_OPTIONS @check_answers_card_number = 1 @question_number = 21 @@ -17,4 +16,12 @@ class Form::Sales::Questions::GenderIdentity1 < ::Form::Question "X" => { "value" => "Non-binary" }, "R" => { "value" => "Prefers not to say" }, }.freeze + + def hint_text + if form.start_year_after_2024? + "This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth." + else + "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." + end + end end diff --git a/app/models/form/sales/questions/gender_identity2.rb b/app/models/form/sales/questions/gender_identity2.rb index 15ef9fda1..87c155acb 100644 --- a/app/models/form/sales/questions/gender_identity2.rb +++ b/app/models/form/sales/questions/gender_identity2.rb @@ -22,4 +22,10 @@ class Form::Sales::Questions::GenderIdentity2 < ::Form::Question "X" => { "value" => "Non-binary" }, "R" => { "value" => "Buyer prefers not to say" }, }.freeze + + def hint_text + return unless form.start_year_after_2024? + + "This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth." + end end diff --git a/app/models/form/sales/questions/person_gender_identity.rb b/app/models/form/sales/questions/person_gender_identity.rb index 94774f5ce..e2da876a4 100644 --- a/app/models/form/sales/questions/person_gender_identity.rb +++ b/app/models/form/sales/questions/person_gender_identity.rb @@ -21,4 +21,10 @@ class Form::Sales::Questions::PersonGenderIdentity < ::Form::Question "X" => { "value" => "Non-binary" }, "R" => { "value" => "Person prefers not to say" }, }.freeze + + def hint_text + return unless form.start_year_after_2024? + + "This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth." + end end diff --git a/app/models/form/sales/questions/property_wheelchair_accessible.rb b/app/models/form/sales/questions/property_wheelchair_accessible.rb index feb017be0..588f350a2 100644 --- a/app/models/form/sales/questions/property_wheelchair_accessible.rb +++ b/app/models/form/sales/questions/property_wheelchair_accessible.rb @@ -7,6 +7,7 @@ class Form::Sales::Questions::PropertyWheelchairAccessible < ::Form::Question @type = "radio" @answer_options = ANSWER_OPTIONS @question_number = 17 + @hint_text = form.start_year_after_2024? ? "This is whether someone who uses a wheelchair is able to make full use of all of the property’s rooms and facilities, including use of both inside and outside space, and entering and exiting the property." : nil end ANSWER_OPTIONS = { diff --git a/app/models/lettings_log.rb b/app/models/lettings_log.rb index 03405a12d..cc8c7d58b 100644 --- a/app/models/lettings_log.rb +++ b/app/models/lettings_log.rb @@ -356,6 +356,10 @@ class LettingsLog < Log unittype_gn == 2 end + def is_beds_inferred? + form.start_year_after_2024? && is_bedsit? + end + def is_shared_housing? # 4: Shared flat or maisonette # 9: Shared house diff --git a/app/models/sales_log.rb b/app/models/sales_log.rb index 3f47dea80..76c43b09e 100644 --- a/app/models/sales_log.rb +++ b/app/models/sales_log.rb @@ -470,6 +470,10 @@ class SalesLog < Log form.start_date.year >= 2023 && uprn.present? ? "uprn" : nil].compact end + def soctenant_is_inferred? + form.start_year_after_2024? + end + def duplicates SalesLog.where.not(duplicate_set_id: nil).where(duplicate_set_id:).where.not(id:) end @@ -477,4 +481,18 @@ class SalesLog < Log def nationality2_uk_or_prefers_not_to_say? nationality_all_buyer2_group&.zero? || nationality_all_buyer2_group == 826 end + + def is_staircase? + staircase == 1 + end + + def discount_value + return unless discount && value + + value * discount / 100 + end + + def is_not_staircasing? + staircase == 2 || staircase == 3 + end end diff --git a/app/models/validations/property_validations.rb b/app/models/validations/property_validations.rb index 2f2d8d6b8..ba8318282 100644 --- a/app/models/validations/property_validations.rb +++ b/app/models/validations/property_validations.rb @@ -34,7 +34,7 @@ module Validations::PropertyValidations def validate_shared_housing_rooms(record) unless record.unittype_gn.nil? - if record.is_bedsit? && record.beds != 1 && record.beds.present? + if record.is_bedsit? && record.beds != 1 && record.beds.present? && !record.form.start_year_after_2024? record.errors.add :unittype_gn, I18n.t("validations.property.unittype_gn.one_bedroom_bedsit") record.errors.add :beds, I18n.t("validations.property.unittype_gn.one_bedroom_bedsit") end diff --git a/app/models/validations/sales/sale_information_validations.rb b/app/models/validations/sales/sale_information_validations.rb index 5b036580d..0aaa77a93 100644 --- a/app/models/validations/sales/sale_information_validations.rb +++ b/app/models/validations/sales/sale_information_validations.rb @@ -55,4 +55,59 @@ module Validations::Sales::SaleInformationValidations record.errors.add :type, I18n.t("validations.sale_information.monthly_rent.higher_than_expected") end end + + def validate_grant_amount(record) + return unless record.saledate && record.form.start_year_after_2024? + return unless record.grant && (record.type == 8 || record.type == 21) + + unless record.grant.between?(9_000, 16_000) + record.errors.add :grant, I18n.t("validations.sale_information.grant.out_of_range") + end + end + + def validate_stairbought(record) + return unless record.stairbought && record.type + return unless record.saledate && record.form.start_year_after_2024? + + max_stairbought = case record.type + when 30, 16, 28, 31, 32 + 90 + when 2, 18 + 75 + when 24 + 50 + end + + if max_stairbought && record.stairbought > max_stairbought + record.errors.add :stairbought, I18n.t("validations.sale_information.stairbought.over_max", max_stairbought:, type: record.form.get_question("type", record).answer_label(record)) + record.errors.add :type, I18n.t("validations.sale_information.stairbought.over_max", max_stairbought:, type: record.form.get_question("type", record).answer_label(record)) + end + end + + def validate_discount_and_value(record) + return unless record.saledate && record.form.start_year_after_2024? + return unless record.discount && record.value && record.la + + if record.london_property? && record.discount_value > 136_400 + %i[discount value la postcode_full uprn].each do |field| + record.errors.add field, I18n.t("validations.sale_information.value.over_discounted_london_max", discount_value: record.field_formatted_as_currency("discount_value")) + end + elsif record.property_not_in_london? && record.discount_value > 102_400 + %i[discount value la postcode_full uprn].each do |field| + record.errors.add field, I18n.t("validations.sale_information.value.over_discounted_max", discount_value: record.field_formatted_as_currency("discount_value")) + end + end + end + + def validate_non_staircasing_mortgage(record) + return unless record.mortgage && record.value && record.deposit && record.equity + return unless record.is_not_staircasing? + return unless record.saledate && record.form.start_year_after_2024? + + if record.mortgage_and_deposit_total != record.expected_shared_ownership_deposit_value + %i[mortgage value deposit equity].each do |field| + record.errors.add field, I18n.t("validations.sale_information.non_staircasing_mortgage", mortgage_and_deposit_total: record.field_formatted_as_currency("mortgage_and_deposit_total"), expected_shared_ownership_deposit_value: record.field_formatted_as_currency("expected_shared_ownership_deposit_value")) + end + end + end end diff --git a/app/models/validations/sales/soft_validations.rb b/app/models/validations/sales/soft_validations.rb index fce544754..ae9ee66cc 100644 --- a/app/models/validations/sales/soft_validations.rb +++ b/app/models/validations/sales/soft_validations.rb @@ -116,7 +116,8 @@ module Validations::Sales::SoftValidations end def grant_outside_common_range? - return unless grant + return unless grant && type && saledate + return if form.start_year_after_2024? && (type == 21 || type == 8) !grant.between?(9_000, 16_000) end diff --git a/app/services/bulk_upload/lettings/year2024/row_parser.rb b/app/services/bulk_upload/lettings/year2024/row_parser.rb index c87cd0c03..5f05b6e10 100644 --- a/app/services/bulk_upload/lettings/year2024/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2024/row_parser.rb @@ -1036,7 +1036,7 @@ private attributes["unittype_gn"] = field_26 attributes["builtype"] = field_27 attributes["wchair"] = field_28 - attributes["beds"] = field_29 + attributes["beds"] = field_26 == 2 ? 1 : field_29 attributes["joint"] = field_36 attributes["startertenancy"] = field_37 attributes["tenancy"] = field_38 diff --git a/app/services/bulk_upload/sales/year2024/row_parser.rb b/app/services/bulk_upload/sales/year2024/row_parser.rb index 037fb8eef..28e7ef100 100644 --- a/app/services/bulk_upload/sales/year2024/row_parser.rb +++ b/app/services/bulk_upload/sales/year2024/row_parser.rb @@ -717,7 +717,6 @@ private lanomagr: %i[field_97], frombeds: %i[field_98], fromprop: %i[field_99], - soctenant: %i[field_98 field_99 field_100], value: %i[field_101 field_114 field_125], equity: %i[field_102], mortgage: %i[field_104 field_118 field_127], @@ -927,7 +926,7 @@ private attributes["stairbought"] = field_87 attributes["stairowned"] = field_88 attributes["socprevten"] = field_100 - attributes["soctenant"] = [attributes["socprevten"], attributes["frombeds"], attributes["fromprop"]].any?(&:present?) ? 1 : 0 + attributes["soctenant"] = infer_soctenant_from_prevten_and_prevtenbuy2 attributes["mortgageused"] = mortgageused attributes["uprn"] = field_22 @@ -1123,6 +1122,16 @@ private 0 if field_62 == 1 end + def infer_soctenant_from_prevten_and_prevtenbuy2 + return unless shared_ownership? + + if [1, 2].include?(field_61) || [1, 2].include?(field_71.to_i) + 1 + else + 2 + end + end + def block_log_creation! self.block_log_creation = true end diff --git a/app/views/bulk_upload_lettings_logs/forms/prepare_your_file_2024.html.erb b/app/views/bulk_upload_lettings_logs/forms/prepare_your_file_2024.html.erb index 5bdf31536..8bc375450 100644 --- a/app/views/bulk_upload_lettings_logs/forms/prepare_your_file_2024.html.erb +++ b/app/views/bulk_upload_lettings_logs/forms/prepare_your_file_2024.html.erb @@ -13,22 +13,17 @@

Download template

-

Use this template to upload logs for 2024/25:

- -

There are 7 or 8 rows of content in the templates. These rows are called the ‘headers’. They contain the CORE form questions and guidance about which questions are required and how to format your answers.

+

<%= govuk_link_to "Download the lettings bulk upload template (2024 to 2025)", @form.template_path %>

+

There are 8 rows of content in the templates. These rows are called the ‘headers’. They contain the CORE form questions and guidance about which questions are required and how to format your answers.

Create your file

<%= govuk_inset_text(text: "You can upload both general needs and supported housing logs in the same file for 2023/24 data.") %> diff --git a/app/views/bulk_upload_sales_logs/forms/prepare_your_file_2024.html.erb b/app/views/bulk_upload_sales_logs/forms/prepare_your_file_2024.html.erb index 2babe13b2..15d63a957 100644 --- a/app/views/bulk_upload_sales_logs/forms/prepare_your_file_2024.html.erb +++ b/app/views/bulk_upload_sales_logs/forms/prepare_your_file_2024.html.erb @@ -13,19 +13,17 @@

Download template

-

Use this template to upload logs for 2024/25:

- -

There are 7 or 8 rows of content in the templates. These rows are called the ‘headers’. They contain the CORE form questions and guidance about which questions are required and how to format your answers.

+

Use one of these templates to upload logs for 2024/25:

+

<%= govuk_link_to "Download the sales bulk upload template (2024 to 2025)", @form.template_path %>: In this template, the questions are in the same order as the 2024/25 paper form and web form.

+

There are 8 rows of content in the templates. These rows are called the ‘headers’. They contain the CORE form questions and guidance about which questions are required and how to format your answers.

Create your file

Save your file

diff --git a/app/views/bulk_upload_shared/guidance.html.erb b/app/views/bulk_upload_shared/guidance.html.erb index 1c63a3602..e018251d0 100644 --- a/app/views/bulk_upload_shared/guidance.html.erb +++ b/app/views/bulk_upload_shared/guidance.html.erb @@ -28,7 +28,11 @@ <%= accordion.with_section(heading_text: "Using the bulk upload template") do %>

For each collection year, we publish a bulk upload template and specification.

-

The bulk upload templates contain 7 or 8 rows of ‘headers’ with information about how to fill in the template, including:

+ <% if @form.year == 2023 %> +

The bulk upload templates contain 7 or 8 rows of ‘headers’ with information about how to fill in the template, including:

+ <% else %> +

The bulk upload templates contain 8 rows of ‘headers’ with information about how to fill in the template, including:

+ <% end %>