Browse Source

Merge branch 'main' into CLDC-3980-Add-ability-to-change-organisaiton-name-with-startdate

pull/3056/head
Manny Dinssa 2 weeks ago
parent
commit
80c28de641
  1. 1
      app/models/derived_variables/lettings_log_variables.rb
  2. 4
      app/models/validations/property_validations.rb
  3. 4
      config/locales/validations/lettings/property_information.en.yml
  4. 1
      spec/models/validations/property_validations_spec.rb

1
app/models/derived_variables/lettings_log_variables.rb

@ -181,6 +181,7 @@ private
},
derived_values: {
referral: 1,
referral_type: 3,
waityear: 2,
offered: 0,
rsnvac: 14,

4
app/models/validations/property_validations.rb

@ -22,10 +22,10 @@ module Validations::PropertyValidations
def validate_shared_housing_rooms(record)
return unless record.unittype_gn
if record.hhmemb == 1 && record.is_shared_housing? &&
!record.beds.to_i.between?(1, 3) && record.beds.present?
if record.hhmemb == 1 && record.is_shared_housing? && !record.beds.to_i.between?(1, 3) && record.beds.present?
record.errors.add :unittype_gn, I18n.t("validations.lettings.property.unittype_gn.one_three_bedroom_single_tenant_shared")
record.errors.add :beds, :one_three_bedroom_single_tenant_shared, message: I18n.t("validations.lettings.property.beds.one_three_bedroom_single_tenant_shared")
record.errors.add :hhmemb, I18n.t("validations.lettings.property.hhmemb.one_three_bedroom_single_tenant_shared")
elsif record.is_shared_housing? && record.beds.present? && !record.beds.to_i.between?(1, 7)
record.errors.add :unittype_gn, I18n.t("validations.lettings.property.unittype_gn.one_seven_bedroom_shared")
record.errors.add :beds, I18n.t("validations.lettings.property.beds.one_seven_bedroom_shared")

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

@ -17,6 +17,8 @@ en:
beds:
one_three_bedroom_single_tenant_shared: "A shared house with fewer than two tenants must have 1 to 3 bedrooms."
one_seven_bedroom_shared: "A shared house must have 1 to 7 bedrooms."
hhmemb:
one_three_bedroom_single_tenant_shared: "A shared house with more than 3 bedrooms cannot have fewer than two tenants."
uprn:
invalid: "UPRN must be 12 digits or less."
not_in_england: "It looks like you have entered an address outside of England. Only create logs for lettings in England."
@ -30,7 +32,7 @@ en:
not_in_england: "This scheme’s only location is outside of England. Only create logs for lettings in England."
location_id:
not_in_england: "It looks like you have selected a location outside of England. Only create logs for lettings in England."
startdate:
startdate:
postcode_not_in_england: "It looks like you have an entered a postcode outside of England. Only create logs for lettings in England."
address_not_in_england: "It looks like you have entered an address outside of England. Only create logs for lettings in England."
location_not_in_england: "It looks like you have selected a location outside of England. Only create logs for lettings in England."

1
spec/models/validations/property_validations_spec.rb

@ -85,6 +85,7 @@ RSpec.describe Validations::PropertyValidations do
property_validator.validate_shared_housing_rooms(log)
expect(log.errors["unittype_gn"]).to include(match(expected_error))
expect(log.errors["beds"]).to include(I18n.t("validations.lettings.property.unittype_gn.one_three_bedroom_single_tenant_shared"))
expect(log.errors["hhmemb"]).to include(I18n.t("validations.lettings.property.hhmemb.one_three_bedroom_single_tenant_shared"))
end
end
end

Loading…
Cancel
Save