diff --git a/app/models/bulk_upload.rb b/app/models/bulk_upload.rb
index aeccfc4cd..9b8c8a9ba 100644
--- a/app/models/bulk_upload.rb
+++ b/app/models/bulk_upload.rb
@@ -57,7 +57,6 @@ class BulkUpload
def map_row(row)
{
lettype: row[1],
- landlord: row[2],
# reg_num_la_core_code: row[3],
# managementgroup: row[4],
# schemecode: row[5],
@@ -67,8 +66,7 @@ class BulkUpload
tenancy: row[9],
tenancyother: row[10],
# tenancyduration: row[11],
- other_hhmemb: other_hhmemb(row),
- hhmemb: other_hhmemb(row) + 1,
+ hhmemb: hhmemb(row),
age1: row[12],
age2: row[13],
age3: row[14],
@@ -111,7 +109,7 @@ class BulkUpload
earnings: row[50],
# increfused: row[51],
reason: row[52],
- other_reason_for_leaving_last_settled_home: row[53],
+ reasonother: row[53],
underoccupation_benefitcap: row[54],
housingneeds_a: row[55],
housingneeds_b: row[56],
@@ -121,11 +119,9 @@ class BulkUpload
housingneeds_h: row[60],
prevten: row[61],
prevloc: row[62],
- # ppostc1: row[63],
- # ppostc2: row[64],
# prevpco_unknown: row[65],
layear: row[66],
- lawaitlist: row[67],
+ waityear: row[67],
homeless: row[68],
reasonpref: row[69],
rp_homeless: row[70],
@@ -147,15 +143,9 @@ class BulkUpload
# no_rent_or_charge: row[86],
hbrentshortfall: row[87],
tshortfall: row[88],
- property_void_date: row[89].to_s + row[90].to_s + row[91].to_s,
- # property_void_date_day: row[89],
- # property_void_date_month: row[90],
- # property_void_date_year: row[91],
+ voiddate: row[89].to_s + row[90].to_s + row[91].to_s,
majorrepairs: row[92].present? ? "1" : nil,
mrcdate: row[92].to_s + row[93].to_s + row[94].to_s,
- mrcday: row[92],
- mrcmonth: row[93],
- mrcyear: row[94],
# supported_scheme: row[95],
startdate: date_time(row[98], row[97], row[96]),
# startdate_day: row[96],
@@ -170,8 +160,6 @@ class BulkUpload
property_relet: row[105],
rsnvac: row[106],
la: row[107],
- # postcode: row[108],
- # postcod2: row[109],
# row[110] removed
# row[111] is owning organisation used above
# username: row[112],
@@ -193,7 +181,7 @@ class BulkUpload
illness_type_10: row[128],
# london_affordable: row[129],
rent_type: row[130],
- intermediate_rent_product_name: row[131],
+ irproduct_other: row[131],
# data_protection: row[132],
sale_or_letting: "letting",
declaration: 1,
@@ -206,7 +194,7 @@ class BulkUpload
Time.zone.local("20#{year}", month.to_s, day.to_s)
end
- def other_hhmemb(row)
- [13, 14, 15, 16, 17, 18, 19].count { |idx| row[idx].present? }
+ def hhmemb(row)
+ [14, 15, 16, 17, 18, 19, 20].count { |idx| row[idx].present? }
end
end
diff --git a/app/models/case_log.rb b/app/models/case_log.rb
index 4eb2ff467..0cbd13ce9 100644
--- a/app/models/case_log.rb
+++ b/app/models/case_log.rb
@@ -122,19 +122,23 @@ class CaseLog < ApplicationRecord
end
def net_income_refused?
+ # 2: Tenant prefers not to say
net_income_known == 2
end
def net_income_is_weekly?
- !!(incfreq && incfreq.zero?)
+ # 1: Weekly
+ !!(incfreq && incfreq == 1)
end
def net_income_is_monthly?
- incfreq == 1
+ # 2: Monthly
+ incfreq == 2
end
def net_income_is_yearly?
- incfreq == 2
+ # 3: Yearly
+ incfreq == 3
end
def net_income_soft_validation_triggered?
@@ -142,138 +146,181 @@ class CaseLog < ApplicationRecord
end
def given_reasonable_preference?
+ # 1: Yes
reasonpref == 1
end
def is_renewal?
+ # 1: Yes
renewal == 1
end
def is_general_needs?
+ # 1: General Needs
needstype == 1
end
def is_supported_housing?
- !!(needstype && needstype.zero?)
+ # 2: Supported Housing
+ needstype == 2
end
def has_hbrentshortfall?
- !!(hbrentshortfall && hbrentshortfall.zero?)
+ # 0: Yes
+ !!hbrentshortfall&.zero?
end
def postcode_known?
+ # 1: Yes
postcode_known == 1
end
def previous_postcode_known?
+ # 1: Yes
previous_postcode_known == 1
end
def la_known?
+ # 1: Yes
la_known == 1
end
def previous_la_known?
+ # 1: Yes
previous_la_known == 1
end
def is_secure_tenancy?
- tenancy == 3
+ # 1: Secure (including flexible)
+ tenancy == 1
end
def is_assured_shorthold_tenancy?
- tenancy == 1
+ # 4: Assured Shorthold
+ tenancy == 4
end
def is_internal_transfer?
+ # 1: Internal Transfer
referral == 1
end
def is_relet_to_temp_tenant?
- rsnvac == 2
+ # 9: Re-let to tenant who occupied same property as temporary accommodation
+ rsnvac == 9
end
def is_bedsit?
- unittype_gn == 1
+ # 2: Bedsit
+ unittype_gn == 2
end
def is_shared_housing?
- [4, 5, 6].include?(unittype_gn)
+ # 4: Shared flat or maisonette
+ # 9: Shared house
+ # 10: Shared bungalow
+ [4, 9, 10].include?(unittype_gn)
end
def has_first_let_vacancy_reason?
+ # 15: First let of new-build property
+ # 16: First let of conversion, rehabilitation or acquired property
+ # 17: First let of leased property
[15, 16, 17].include?(rsnvac)
end
def previous_tenancy_was_temporary?
- ![4, 5, 16, 21, 22].include?(prevten)
+ # 4: Tied housing or renting with job
+ # 6: Supported housing
+ # 8: Sheltered accomodation
+ # 24: Housed by National Asylum Support Service (prev Home Office)
+ # 25: Other
+ ![4, 6, 8, 24, 25].include?(prevten)
end
def armed_forces_regular?
- !!(armedforces && armedforces.zero?)
+ # 1: Yes – the person is a current or former regular
+ !!(armedforces && armedforces == 1)
end
def armed_forces_no?
- armedforces == 3
+ # 2: No
+ armedforces == 2
end
def armed_forces_refused?
- armedforces == 4
+ # 3: Person prefers not to say / Refused
+ armedforces == 3
end
def has_pregnancy?
- !!(preg_occ && preg_occ.zero?)
+ # 1: Yes
+ !!(preg_occ && preg_occ == 1)
end
def pregnancy_refused?
- preg_occ == 2
+ # 3: Tenant prefers not to say / Refused
+ preg_occ == 3
end
def is_assessed_homeless?
+ # 11: Assessed as homeless (or threatened with homelessness within 56 days) by a local authority and owed a homelessness duty
homeless == 11
end
def is_other_homeless?
+ # 7: Other homeless – not found statutorily homeless but considered homeless by landlord
homeless == 7
end
def is_not_homeless?
+ # 1: No
homeless == 1
end
def is_london_rent?
+ # 2: London Affordable Rent
+ # 4: London Living Rent
rent_type == 2 || rent_type == 4
end
def previous_tenancy_was_foster_care?
+ # 13: Children's home or foster care
prevten == 13
end
def previous_tenancy_was_refuge?
+ # 21: Refuge
prevten == 21
end
def is_reason_permanently_decanted?
+ # 1: Permanently decanted from another property owned by this landlord
reason == 1
end
def receives_housing_benefit_only?
+ # 1: Housing benefit
hb == 1
end
def receives_housing_benefit_and_universal_credit?
+ # 8: Housing benefit and Universal Credit (without housing element)
hb == 8
end
def receives_uc_with_housing_element_excl_housing_benefit?
+ # 6: Universal Credit with housing element (excluding housing benefit)
hb == 6
end
def receives_no_benefits?
+ # 9: None
hb == 9
end
def receives_universal_credit_but_no_housing_benefit?
+ # 7: Universal Credit (without housing element)
hb == 7
end
@@ -283,22 +330,18 @@ class CaseLog < ApplicationRecord
end
def benefits_unknown?
+ # 3: Don’t know
hb == 3
end
- def this_landlord?
- landlord == 1
- end
-
- def other_landlord?
- landlord == 2
- end
-
def local_housing_referral?
+ # 3: PRP lettings only - Nominated by local housing authority
referral == 3
end
def is_prevten_la_general_needs?
+ # 30: Fixed term Local Authority General Needs tenancy
+ # 31: Lifetime Local Authority General Needs tenancy
[30, 31].any?(prevten)
end
@@ -379,30 +422,10 @@ private
end
def set_derived_fields!
- if ppostcode_full.present?
- self.ppostc1 = UKPostcode.parse(ppostcode_full).outcode
- self.ppostc2 = UKPostcode.parse(ppostcode_full).incode
- end
- if mrcdate.present?
- self.mrcday = mrcdate.day
- self.mrcmonth = mrcdate.month
- self.mrcyear = mrcdate.year
- end
- if startdate.present?
- self.day = startdate.day
- self.month = startdate.month
- self.year = startdate.year
- end
- if property_void_date.present?
- self.vday = property_void_date.day
- self.vmonth = property_void_date.month
- self.vyear = property_void_date.year
- end
if rsnvac.present?
self.newprop = has_first_let_vacancy_reason? ? 1 : 2
end
self.incref = 1 if net_income_refused?
- self.other_hhmemb = hhmemb - 1 if hhmemb.present?
self.renttype = RENT_TYPE_MAPPING[rent_type]
self.lettype = get_lettype
self.totchild = get_totchild
@@ -431,14 +454,14 @@ private
weekly_value(tshortfall)
end
self.nocharge = household_charge&.zero? ? 1 : 0
- self.underoccupation_benefitcap = 3 if renewal == 1 && year == 2021
self.housingneeds = get_housingneeds
if is_renewal?
- self.underoccupation_benefitcap = 2 if year == 2021
+ self.underoccupation_benefitcap = 2 if collection_start_year == 2021
self.homeless = 2
self.referral = 0
self.layear = 1
if is_general_needs?
+ # fixed term
self.prevten = 32 if managing_organisation.provider_type == "PRP"
self.prevten = 30 if managing_organisation.provider_type == "LA"
end
@@ -450,47 +473,41 @@ private
self["ecstat#{idx}"] = nil
end
end
- self.landlord = 1 if owning_organisation.provider_type == "LA"
- self.landlord = 2 if owning_organisation.provider_type == "PRP"
end
def process_postcode_changes!
self.postcode_full = postcode_full.present? ? postcode_full.upcase.gsub(/\s+/, "") : postcode_full
- process_postcode(postcode_full, "postcode_known", "is_la_inferred", "la", "postcode", "postcod2")
+ process_postcode(postcode_full, "postcode_known", "is_la_inferred", "la")
end
def process_previous_postcode_changes!
self.ppostcode_full = ppostcode_full.present? ? ppostcode_full.upcase.gsub(/\s+/, "") : ppostcode_full
- process_postcode(ppostcode_full, "previous_postcode_known", "is_previous_la_inferred", "prevloc", "ppostc1", "ppostc2")
+ process_postcode(ppostcode_full, "previous_postcode_known", "is_previous_la_inferred", "prevloc")
end
- def process_postcode(postcode, postcode_known_key, la_inferred_key, la_key, outcode_key, incode_key)
+ def process_postcode(postcode, postcode_known_key, la_inferred_key, la_key)
return if postcode.blank?
self[postcode_known_key] = 1
inferred_la = get_inferred_la(postcode)
self[la_inferred_key] = inferred_la.present?
self[la_key] = inferred_la if inferred_la.present?
- self[outcode_key] = UKPostcode.parse(postcode).outcode
- self[incode_key] = UKPostcode.parse(postcode).incode
end
def reset_location_fields!
- reset_location(is_la_inferred, "la", "is_la_inferred", "postcode_full", "postcode", "postcod2", la_known)
+ reset_location(is_la_inferred, "la", "is_la_inferred", "postcode_full", la_known)
end
def reset_previous_location_fields!
- reset_location(is_previous_la_inferred, "prevloc", "is_previous_la_inferred", "ppostcode_full", "ppostc1", "ppostc2", previous_la_known)
+ reset_location(is_previous_la_inferred, "prevloc", "is_previous_la_inferred", "ppostcode_full", previous_la_known)
end
- def reset_location(is_inferred, la_key, is_inferred_key, postcode_key, incode_key, outcode_key, is_la_known)
+ def reset_location(is_inferred, la_key, is_inferred_key, postcode_key, is_la_known)
if is_inferred || is_la_known != 1
self[la_key] = nil
end
self[is_inferred_key] = false
self[postcode_key] = nil
- self[incode_key] = nil
- self[outcode_key] = nil
end
def get_totelder
diff --git a/app/models/form/question.rb b/app/models/form/question.rb
index 5d3d50bb9..e451f0c3c 100644
--- a/app/models/form/question.rb
+++ b/app/models/form/question.rb
@@ -224,9 +224,9 @@ private
end
ANSWER_SUFFIX_LABELS = {
- 0 => " every week",
- 1 => " every month",
- 2 => " every year",
+ 1 => " every week",
+ 2 => " every month",
+ 3 => " every year",
}.freeze
RADIO_YES_VALUE = {
@@ -240,11 +240,11 @@ private
majorrepairs: [1],
startertenancy: [0],
letting_in_sheltered_accommodation: [0, 1],
- armedforces: [0, 1, 2],
+ armedforces: [1, 4, 5],
leftreg: [0],
reservist: [0],
- preg_occ: [0],
- illness: [0],
+ preg_occ: [1],
+ illness: [1],
underoccupation_benefitcap: [4, 5, 6],
reasonpref: [1],
net_income_known: [0],
@@ -265,11 +265,11 @@ private
majorrepairs: [0],
startertenancy: [1],
letting_in_sheltered_accommodation: [2],
- armedforces: [3],
+ armedforces: [2],
leftreg: [1],
reservist: [1],
- preg_occ: [1],
- illness: [1],
+ preg_occ: [2],
+ illness: [2],
underoccupation_benefitcap: [2],
reasonpref: [2],
net_income_known: [1],
@@ -289,6 +289,7 @@ private
hb: [5],
benefits: [3],
unitletas: [3],
+ illness: [3],
}.freeze
RADIO_REFUSED_VALUE = {
@@ -316,11 +317,10 @@ private
ecstat7: [10],
ecstat8: [10],
letting_in_sheltered_accommodation: [3],
- armedforces: [4],
+ armedforces: [3],
leftreg: [3],
reservist: [2],
- preg_occ: [2],
- illness: [2],
+ preg_occ: [3],
hb: [6],
}.freeze
end
diff --git a/app/models/validations/date_validations.rb b/app/models/validations/date_validations.rb
index 0341cc365..669718868 100644
--- a/app/models/validations/date_validations.rb
+++ b/app/models/validations/date_validations.rb
@@ -15,16 +15,16 @@ module Validations::DateValidations
end
def validate_property_void_date(record)
- if record["property_void_date"].present? && record["startdate"].present? && record["startdate"].to_date - record["property_void_date"].to_date > 3650
- record.errors.add :property_void_date, I18n.t("validations.property.void_date.ten_years_before_tenancy_start")
+ if record["voiddate"].present? && record["startdate"].present? && record["startdate"].to_date - record["voiddate"].to_date > 3650
+ record.errors.add :voiddate, I18n.t("validations.property.void_date.ten_years_before_tenancy_start")
end
- if record["property_void_date"].present? && record["startdate"].present? && record["startdate"].to_date < record["property_void_date"].to_date
- record.errors.add :property_void_date, I18n.t("validations.property.void_date.before_tenancy_start")
+ if record["voiddate"].present? && record["startdate"].present? && record["startdate"].to_date < record["voiddate"].to_date
+ record.errors.add :voiddate, I18n.t("validations.property.void_date.before_tenancy_start")
end
- if record["property_void_date"].present? && record["mrcdate"].present? && record["mrcdate"].to_date < record["property_void_date"].to_date
- record.errors.add :property_void_date, I18n.t("validations.property.void_date.after_mrcdate")
+ if record["voiddate"].present? && record["mrcdate"].present? && record["mrcdate"].to_date < record["voiddate"].to_date
+ record.errors.add :voiddate, I18n.t("validations.property.void_date.after_mrcdate")
end
end
diff --git a/app/models/validations/financial_validations.rb b/app/models/validations/financial_validations.rb
index a85042996..a95cf25c1 100644
--- a/app/models/validations/financial_validations.rb
+++ b/app/models/validations/financial_validations.rb
@@ -84,46 +84,47 @@ private
CHARGE_MAXIMUMS = {
scharge: {
- this_landlord: {
+ private_registered_provider: {
general_needs: 55,
supported_housing: 280,
},
- other_landlord: {
+ local_authority: {
general_needs: 45,
supported_housing: 165,
},
},
pscharge: {
- this_landlord: {
+ private_registered_provider: {
general_needs: 30,
supported_housing: 200,
},
- other_landlord: {
+ local_authority: {
general_needs: 35,
supported_housing: 75,
},
},
supcharg: {
- this_landlord: {
+ private_registered_provider: {
general_needs: 40,
supported_housing: 465,
},
- other_landlord: {
+ local_authority: {
general_needs: 60,
supported_housing: 120,
},
},
}.freeze
- LANDLORD_VALUES = { 1 => :this_landlord, 2 => :other_landlord }.freeze
- NEEDSTYPE_VALUES = { 0 => :supported_housing, 1 => :general_needs }.freeze
+ PROVIDER_TYPE = { 1 => :local_authority, 2 => :private_registered_provider }.freeze
+ NEEDSTYPE_VALUES = { 2 => :supported_housing, 1 => :general_needs }.freeze
def validate_charges(record)
+ provider_type = record.owning_organisation.provider_type_before_type_cast
%i[scharge pscharge supcharg].each do |charge|
- maximum = CHARGE_MAXIMUMS.dig(charge, LANDLORD_VALUES[record.landlord], NEEDSTYPE_VALUES[record.needstype])
+ maximum = CHARGE_MAXIMUMS.dig(charge, PROVIDER_TYPE[provider_type], NEEDSTYPE_VALUES[record.needstype])
if maximum.present? && record[:period].present? && record[charge].present? && !weekly_value_in_range(record, charge, 0.0, maximum)
- record.errors.add charge, I18n.t("validations.financial.rent.#{charge}.#{LANDLORD_VALUES[record.landlord]}.#{NEEDSTYPE_VALUES[record.needstype]}")
+ record.errors.add charge, I18n.t("validations.financial.rent.#{charge}.#{PROVIDER_TYPE[provider_type]}.#{NEEDSTYPE_VALUES[record.needstype]}")
end
end
end
diff --git a/app/models/validations/household_validations.rb b/app/models/validations/household_validations.rb
index a980e94be..5d0f52037 100644
--- a/app/models/validations/household_validations.rb
+++ b/app/models/validations/household_validations.rb
@@ -18,7 +18,7 @@ module Validations::HouseholdValidations
record.errors.add :underoccupation_benefitcap, I18n.t("validations.household.underoccupation_benefitcap.dont_know_required")
record.errors.add :reason, I18n.t("validations.household.underoccupation_benefitcap.dont_know_required")
end
- validate_other_field(record, 31, :reason, :other_reason_for_leaving_last_settled_home)
+ validate_other_field(record, 31, :reason, :reasonother)
if record.is_reason_permanently_decanted? && record.referral.present? && !record.is_internal_transfer?
record.errors.add :referral, I18n.t("validations.household.referral.reason_permanently_decanted")
@@ -56,7 +56,7 @@ module Validations::HouseholdValidations
end
def validate_accessibility_requirements(record)
- all_options = [record.housingneeds_a, record.housingneeds_b, record.housingneeds_c, record.housingneeds_f, record.housingneeds_g, record.housingneeds_h, record.accessibility_requirements_prefer_not_to_say]
+ all_options = [record.housingneeds_a, record.housingneeds_b, record.housingneeds_c, record.housingneeds_f, record.housingneeds_g, record.housingneeds_h]
if all_options.count(1) > 1
mobility_accessibility_options = [record.housingneeds_a, record.housingneeds_b, record.housingneeds_c]
unless all_options.count(1) == 2 && record.housingneeds_f == 1 && mobility_accessibility_options.any? { |x| x == 1 }
@@ -105,12 +105,12 @@ module Validations::HouseholdValidations
record.errors.add :homeless, I18n.t("validations.household.homeless.other.internal_transfer")
end
- if record.is_internal_transfer? && record.this_landlord? && record.is_prevten_la_general_needs?
+ if record.is_internal_transfer? && record.owning_organisation.provider_type == "PRP" && record.is_prevten_la_general_needs?
record.errors.add :referral, I18n.t("validations.household.referral.la_general_needs.internal_transfer")
record.errors.add :prevten, I18n.t("validations.household.prevten.la_general_needs.internal_transfer")
end
- if record.other_landlord? && record.local_housing_referral?
+ if record.owning_organisation.provider_type == "LA" && record.local_housing_referral?
record.errors.add :referral, I18n.t("validations.household.referral.prp.local_housing_referral")
end
end
@@ -124,7 +124,7 @@ module Validations::HouseholdValidations
private
def household_no_illness?(record)
- record.illness != 0
+ record.illness != 1
end
def women_of_child_bearing_age_in_household(record)
diff --git a/app/models/validations/property_validations.rb b/app/models/validations/property_validations.rb
index ab97a20d4..720cad20d 100644
--- a/app/models/validations/property_validations.rb
+++ b/app/models/validations/property_validations.rb
@@ -112,7 +112,7 @@ module Validations::PropertyValidations
record.errors.add :beds, I18n.t("validations.property.unittype_gn.one_bedroom_bedsit")
end
- if record.other_hhmemb&.zero? && record.is_shared_housing? &&
+ 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.property.unittype_gn.one_three_bedroom_single_tenant_shared")
record.errors.add :beds, I18n.t("validations.property.unittype_gn.one_three_bedroom_single_tenant_shared")
diff --git a/app/models/validations/setup_validations.rb b/app/models/validations/setup_validations.rb
index 927a32de9..44770c947 100644
--- a/app/models/validations/setup_validations.rb
+++ b/app/models/validations/setup_validations.rb
@@ -1,7 +1,7 @@
module Validations::SetupValidations
- def validate_intermediate_rent_product_name(record)
- if intermediate_product_rent_type?(record) && record.intermediate_rent_product_name.blank?
- record.errors.add :intermediate_rent_product_name, I18n.t("validations.setup.intermediate_rent_product_name.blank")
+ def validate_irproduct_other(record)
+ if intermediate_product_rent_type?(record) && record.irproduct_other.blank?
+ record.errors.add :irproduct_other, I18n.t("validations.setup.intermediate_rent_product_name.blank")
end
end
diff --git a/app/models/validations/tenancy_validations.rb b/app/models/validations/tenancy_validations.rb
index b6991f1c6..84af343c6 100644
--- a/app/models/validations/tenancy_validations.rb
+++ b/app/models/validations/tenancy_validations.rb
@@ -30,6 +30,6 @@ module Validations::TenancyValidations
end
def validate_other_tenancy_type(record)
- validate_other_field(record, 4, :tenancy, :tenancyother)
+ validate_other_field(record, 3, :tenancy, :tenancyother)
end
end
diff --git a/app/services/imports/case_logs_import_service.rb b/app/services/imports/case_logs_import_service.rb
new file mode 100644
index 000000000..806f55856
--- /dev/null
+++ b/app/services/imports/case_logs_import_service.rb
@@ -0,0 +1,392 @@
+module Imports
+ class CaseLogsImportService < ImportService
+ def create_logs(folder)
+ import_from(folder, :create_log)
+ end
+
+ private
+
+ GN_SH = {
+ general_needs: 1,
+ supported_housing: 2,
+ }.freeze
+
+ SR_AR_IR = {
+ social_rent: 1,
+ affordable_rent: 2,
+ intermediate_rent: 3,
+ }.freeze
+
+ # For providertype, values are reversed!!!
+ PRP_LA = {
+ private_registered_provider: 1,
+ local_authority: 2,
+ }.freeze
+
+ IRPRODUCT = {
+ rent_to_buy: 1,
+ london_living_rent: 2,
+ other_intermediate_rent_product: 3,
+ }.freeze
+
+ # These must match our form
+ RENT_TYPE = {
+ social_rent: 0,
+ affordable_rent: 1,
+ london_affordable_rent: 2,
+ rent_to_buy: 3,
+ london_living_rent: 4,
+ other_intermediate_rent_product: 5,
+ }.freeze
+
+ def create_log(xml_doc)
+ attributes = {}
+
+ # Required fields for status complete or logic to work
+ # Note: order matters when we derive from previous values (attributes parameter)
+ attributes["startdate"] = compose_date(xml_doc, "DAY", "MONTH", "YEAR")
+ attributes["owning_organisation_id"] = find_organisation_id(xml_doc, "OWNINGORGID", "OWNINGORGNAME", "HCNUM")
+ attributes["managing_organisation_id"] = find_organisation_id(xml_doc, "MANINGORGID", "MANINGORGNAME", "MANHCNUM")
+ attributes["startertenancy"] = unsafe_string_as_integer(xml_doc, "_2a")
+ attributes["tenancy"] = unsafe_string_as_integer(xml_doc, "Q2b")
+ attributes["tenancyother"] = string_or_nil(xml_doc, "Q2ba")
+ attributes["tenancylength"] = safe_string_as_integer(xml_doc, "_2cYears")
+ attributes["needstype"] = needs_type(xml_doc)
+ attributes["lar"] = london_affordable_rent(xml_doc)
+ attributes["irproduct"] = unsafe_string_as_integer(xml_doc, "IRProduct")
+ attributes["irproduct_other"] = string_or_nil(xml_doc, "IRProductOther")
+ attributes["rent_type"] = rent_type(xml_doc, attributes["lar"], attributes["irproduct"])
+ attributes["hhmemb"] = safe_string_as_integer(xml_doc, "HHMEMB")
+ (1..8).each do |index|
+ attributes["age#{index}"] = safe_string_as_integer(xml_doc, "P#{index}Age")
+ attributes["age#{index}_known"] = age_known(xml_doc, index, attributes["hhmemb"])
+ attributes["sex#{index}"] = sex(xml_doc, index)
+ attributes["ecstat#{index}"] = unsafe_string_as_integer(xml_doc, "P#{index}Eco")
+ end
+ (2..8).each do |index|
+ attributes["relat#{index}"] = relat(xml_doc, index)
+ end
+ attributes["ethnic"] = unsafe_string_as_integer(xml_doc, "P1Eth")
+ attributes["ethnic_group"] = ethnic_group(attributes["ethnic"])
+ attributes["national"] = unsafe_string_as_integer(xml_doc, "P1Nat")
+ attributes["preg_occ"] = unsafe_string_as_integer(xml_doc, "Preg")
+
+ attributes["armedforces"] = unsafe_string_as_integer(xml_doc, "ArmedF")
+ attributes["leftreg"] = unsafe_string_as_integer(xml_doc, "LeftAF")
+ attributes["reservist"] = unsafe_string_as_integer(xml_doc, "Inj")
+
+ attributes["hb"] = unsafe_string_as_integer(xml_doc, "Q6Ben")
+ attributes["benefits"] = unsafe_string_as_integer(xml_doc, "Q7Ben")
+ attributes["earnings"] = safe_string_as_decimal(xml_doc, "Q8Money")
+ attributes["net_income_known"] = net_income_known(xml_doc, attributes["earnings"])
+ attributes["incfreq"] = unsafe_string_as_integer(xml_doc, "Q8a")
+
+ attributes["reason"] = unsafe_string_as_integer(xml_doc, "Q9a")
+ attributes["reasonother"] = string_or_nil(xml_doc, "Q9aa")
+ attributes["underoccupation_benefitcap"] = unsafe_string_as_integer(xml_doc, "_9b")
+ %w[a b c f g h].each do |letter|
+ attributes["housingneeds_#{letter}"] = housing_needs(xml_doc, letter)
+ end
+
+ attributes["illness"] = unsafe_string_as_integer(xml_doc, "Q10ia")
+ (1..10).each do |index|
+ attributes["illness_type_#{index}"] = illness_type(xml_doc, index)
+ end
+
+ attributes["prevten"] = unsafe_string_as_integer(xml_doc, "Q11")
+ attributes["prevloc"] = string_or_nil(xml_doc, "Q12aONS")
+ attributes["previous_postcode_known"] = previous_postcode_known(xml_doc)
+ attributes["ppostcode_full"] = compose_postcode(xml_doc, "PPOSTC1", "PPOSTC2")
+ attributes["layear"] = unsafe_string_as_integer(xml_doc, "Q12c")
+ attributes["waityear"] = unsafe_string_as_integer(xml_doc, "Q12d")
+ attributes["homeless"] = unsafe_string_as_integer(xml_doc, "Q13")
+
+ attributes["reasonpref"] = unsafe_string_as_integer(xml_doc, "Q14a")
+ attributes["rp_homeless"] = unsafe_string_as_integer(xml_doc, "Q14b1")
+ attributes["rp_insan_unsat"] = unsafe_string_as_integer(xml_doc, "Q14b2")
+ attributes["rp_medwel"] = unsafe_string_as_integer(xml_doc, "Q14b3")
+ attributes["rp_hardship"] = unsafe_string_as_integer(xml_doc, "Q14b4")
+ attributes["rp_dontknow"] = unsafe_string_as_integer(xml_doc, "Q14b5")
+
+ attributes["cbl"] = unsafe_string_as_integer(xml_doc, "Q15CBL")
+ attributes["chr"] = unsafe_string_as_integer(xml_doc, "Q15CHR")
+ attributes["cap"] = unsafe_string_as_integer(xml_doc, "Q15CAP")
+
+ attributes["referral"] = unsafe_string_as_integer(xml_doc, "Q16")
+ attributes["period"] = unsafe_string_as_integer(xml_doc, "Q17")
+
+ attributes["brent"] = safe_string_as_decimal(xml_doc, "Q18ai")
+ attributes["scharge"] = safe_string_as_decimal(xml_doc, "Q18aii")
+ attributes["pscharge"] = safe_string_as_decimal(xml_doc, "Q18aiii")
+ attributes["supcharg"] = safe_string_as_decimal(xml_doc, "Q18aiv")
+ attributes["tcharge"] = safe_string_as_decimal(xml_doc, "Q18av")
+
+ attributes["hbrentshortfall"] = unsafe_string_as_integer(xml_doc, "Q18d")
+
+ attributes["voiddate"] = compose_date(xml_doc, "VDAY", "VMONTH", "VYEAR")
+ attributes["mrcdate"] = compose_date(xml_doc, "MRCDAY", "MRCMONTH", "MRCYEAR")
+
+ attributes["offered"] = safe_string_as_integer(xml_doc, "Q20")
+ attributes["propcode"] = string_or_nil(xml_doc, "Q21a")
+ attributes["beds"] = safe_string_as_integer(xml_doc, "Q22")
+ attributes["unittype_gn"] = unsafe_string_as_integer(xml_doc, "Q23")
+ attributes["builtype"] = unsafe_string_as_integer(xml_doc, "Q24")
+ attributes["wchair"] = unsafe_string_as_integer(xml_doc, "Q25")
+ attributes["unitletas"] = unsafe_string_as_integer(xml_doc, "Q26")
+ attributes["rsnvac"] = unsafe_string_as_integer(xml_doc, "Q27")
+ attributes["renewal"] = renewal(attributes["rsnvac"])
+
+ attributes["la"] = string_or_nil(xml_doc, "Q28ONS")
+ attributes["postcode_full"] = compose_postcode(xml_doc, "POSTCODE", "POSTCOD2")
+ attributes["postcode_known"] = attributes["postcode_full"].nil? ? 0 : 1
+
+ # Not specific to our form but required for CDS and can't be inferred
+ attributes["old_form_id"] = Integer(field_value(xml_doc, "xmlns", "FORM"))
+
+ # Specific to us
+ attributes["previous_la_known"] = 1 # Defaulting to Yes (Required)
+ attributes["la_known"] = 1 # Defaulting to Yes (Required)
+ attributes["created_at"] = Date.parse(field_value(xml_doc, "meta", "created-date"))
+ attributes["updated_at"] = Date.parse(field_value(xml_doc, "meta", "modified-date"))
+
+ case_log = CaseLog.new(attributes)
+ case_log.save!
+ end
+
+ # Safe: A string that represents only an integer (or empty/nil)
+ def safe_string_as_integer(xml_doc, attribute)
+ str = field_value(xml_doc, "xmlns", attribute)
+ Integer(str, exception: false)
+ end
+
+ # Safe: A string that represents only a decimal (or empty/nil)
+ def safe_string_as_decimal(xml_doc, attribute)
+ str = field_value(xml_doc, "xmlns", attribute)
+ BigDecimal(str, exception: false)
+ end
+
+ # Unsafe: A string that has more than just the integer value
+ def unsafe_string_as_integer(xml_doc, attribute)
+ str = field_value(xml_doc, "xmlns", attribute)
+ if str.blank?
+ nil
+ else
+ str.to_i
+ end
+ end
+
+ def compose_date(xml_doc, day_str, month_str, year_str)
+ day = Integer(field_value(xml_doc, "xmlns", day_str), exception: false)
+ month = Integer(field_value(xml_doc, "xmlns", month_str), exception: false)
+ year = Integer(field_value(xml_doc, "xmlns", year_str), exception: false)
+ if day.nil? || month.nil? || year.nil?
+ nil
+ else
+ Date.new(year, month, day)
+ end
+ end
+
+ def get_form_name_component(xml_doc, index)
+ form_name = field_value(xml_doc, "meta", "form-name")
+ form_type_components = form_name.split("-")
+ form_type_components[index]
+ end
+
+ def needs_type(xml_doc)
+ gn_sh = get_form_name_component(xml_doc, -1)
+ case gn_sh
+ when "GN"
+ GN_SH[:general_needs]
+ when "SH"
+ GN_SH[:supported_housing]
+ else
+ raise "Unknown needstype value: #{gn_sh}"
+ end
+ end
+
+ # This does not match renttype (CDS) which is derived by case log logic
+ def rent_type(xml_doc, lar, irproduct)
+ sr_ar_ir = get_form_name_component(xml_doc, -2)
+
+ case sr_ar_ir
+ when "SR"
+ RENT_TYPE[:social_rent]
+ when "AR"
+ if lar == 1
+ RENT_TYPE[:london_affordable_rent]
+ else
+ RENT_TYPE[:affordable_rent]
+ end
+ when "IR"
+ if irproduct == IRPRODUCT[:rent_to_buy]
+ RENT_TYPE[:rent_to_buy]
+ elsif irproduct == IRPRODUCT[:london_living_rent]
+ RENT_TYPE[:london_living_rent]
+ elsif irproduct == IRPRODUCT[:other_intermediate_rent_product]
+ RENT_TYPE[:other_intermediate_rent_product]
+ end
+ else
+ raise "Could not infer rent type with '#{sr_ar_ir}'"
+ end
+ end
+
+ def find_organisation_id(xml_doc, id_field, name_field, reg_field)
+ old_visible_id = unsafe_string_as_integer(xml_doc, id_field)
+ organisation = Organisation.find_by(old_visible_id:)
+ # Quick hack: should be removed when all organisations are imported
+ # Will fail in the future if the organisation is missing
+ if organisation.nil?
+ organisation = Organisation.new
+ organisation.old_visible_id = old_visible_id
+ let_type = unsafe_string_as_integer(xml_doc, "landlord")
+ organisation.provider_type = if let_type == PRP_LA[:local_authority]
+ 1
+ else
+ 2
+ end
+ organisation.name = string_or_nil(xml_doc, name_field)
+ organisation.housing_registration_no = string_or_nil(xml_doc, reg_field)
+ organisation.save!
+ end
+ organisation.id
+ end
+
+ def sex(xml_doc, index)
+ sex = field_value(xml_doc, "xmlns", "P#{index}Sex")
+ case sex
+ when "Male"
+ "M"
+ when "Female"
+ "F"
+ when "Other", "Non-binary"
+ "X"
+ when "Refused"
+ "R"
+ end
+ end
+
+ def relat(xml_doc, index)
+ relat = field_value(xml_doc, "xmlns", "P#{index}Rel")
+ case relat
+ when "Child"
+ "C"
+ when "Partner"
+ "P"
+ when "Other", "Non-binary"
+ "X"
+ when "Refused"
+ "R"
+ end
+ end
+
+ def age_known(xml_doc, index, hhmemb)
+ return nil if index > hhmemb
+
+ age_refused = field_value(xml_doc, "xmlns", "P#{index}AR")
+ if age_refused == "AGE_REFUSED"
+ 1 # No
+ else
+ 0 # Yes
+ end
+ end
+
+ def previous_postcode_known(xml_doc)
+ previous_postcode_known = field_value(xml_doc, "xmlns", "Q12bnot")
+ if previous_postcode_known == "Temporary or Unknown"
+ 0
+ else
+ 1
+ end
+ end
+
+ def compose_postcode(xml_doc, outcode, incode)
+ outcode_value = field_value(xml_doc, "xmlns", outcode)
+ incode_value = field_value(xml_doc, "xmlns", incode)
+ if outcode_value.blank? || incode_value.blank?
+ nil
+ else
+ "#{outcode_value} #{incode_value}"
+ end
+ end
+
+ def london_affordable_rent(xml_doc)
+ lar = unsafe_string_as_integer(xml_doc, "LAR")
+ if lar == 1
+ 1
+ else
+ # We default to No for any other values (nil, not known)
+ 2
+ end
+ end
+
+ def renewal(rsnvac)
+ # Relet – renewal of fixed-term tenancy
+ if rsnvac == 14
+ 1
+ else
+ 0
+ end
+ end
+
+ def string_or_nil(xml_doc, attribute)
+ str = field_value(xml_doc, "xmlns", attribute)
+ str.presence
+ end
+
+ def ethnic_group(ethnic)
+ case ethnic
+ when 1, 2, 3, 18
+ # White
+ 0
+ when 4, 5, 6, 7
+ # Mixed
+ 1
+ when 8, 9, 10, 11, 15
+ # Asian
+ 2
+ when 12, 13, 14
+ # Black
+ 3
+ when 16, 19
+ # Others
+ 4
+ when 17
+ # Refused
+ 5
+ end
+ end
+
+ # Letters should be lowercase to match case
+ def housing_needs(xml_doc, letter)
+ housing_need = field_value(xml_doc, "xmlns", "Q10-#{letter}")
+ if housing_need == "Yes"
+ 1
+ else
+ 0
+ end
+ end
+
+ def net_income_known(xml_doc, earnings)
+ incref = field_value(xml_doc, "xmlns", "Q8Refused")
+ if incref == "Refused"
+ # Tenant prefers not to say
+ 2
+ elsif earnings.nil?
+ # No
+ 1
+ else
+ # Yes
+ 0
+ end
+ end
+
+ def illness_type(xml_doc, index)
+ illness_type = string_or_nil(xml_doc, "Q10ib-#{index}")
+ if illness_type == "Yes"
+ 1
+ else
+ 0
+ end
+ end
+ end
+end
diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json
index 9695c29f4..2ede442db 100644
--- a/config/forms/2021_2022.json
+++ b/config/forms/2021_2022.json
@@ -22,7 +22,7 @@
"1": {
"value": "General needs"
},
- "0": {
+ "2": {
"value": "Supported housing"
}
}
@@ -587,13 +587,13 @@
"type": "radio",
"answer_options": {
"1": {
- "value": "Affordable rent basis"
+ "value": "Social rent basis"
},
"2": {
- "value": "Intermediate rent basis"
+ "value": "Affordable rent basis"
},
- "0": {
- "value": "Social rent basis"
+ "4": {
+ "value": "Intermediate rent basis"
},
"divider": {
"value": true
@@ -621,39 +621,39 @@
"hint_text": "",
"type": "radio",
"answer_options": {
- "1": {
+ "13": {
"value": "Internal transfer",
"hint": "Excluding renewals of a fixed-term tenancy"
},
- "10": {
+ "5": {
"value": "Previous tenant died with no succession"
},
- "2": {
+ "9": {
"value": "Re-let to tenant who occupied same property as temporary accommodation"
},
- "0": {
+ "14": {
"value": "Renewal of fixed-term tenancy"
},
- "7": {
- "value": "Tenant abandoned property"
- },
- "3": {
+ "19": {
"value": "Tenant involved in a succession downsize"
},
- "6": {
- "value": "Tenant moved to care home"
+ "8": {
+ "value": "Tenant moved to private sector or other accommodation"
},
- "5": {
+ "12": {
"value": "Tenant moved to other social housing provider"
},
- "4": {
- "value": "Tenant moved to private sector or other accommodation"
+ "18": {
+ "value": "Tenant moved to care home"
},
- "9": {
- "value": "Tenant was evicted due to anti-social behaviour"
+ "6": {
+ "value": "Tenant abandoned property"
},
- "8": {
+ "10": {
"value": "Tenant was evicted due to rent arrears"
+ },
+ "11": {
+ "value": "Tenant was evicted due to anti-social behaviour"
}
}
}
@@ -675,14 +675,14 @@
"hint_text": "",
"type": "radio",
"answer_options": {
- "15": {
- "value": "First let of new-build property"
- },
"16": {
"value": "First let of conversion, rehabilitation or acquired property"
},
"17": {
"value": "First let of leased property"
+ },
+ "15": {
+ "value": "First let of new-build property"
}
}
}
@@ -748,28 +748,28 @@
"hint_text": "",
"type": "radio",
"answer_options": {
- "1": {
+ "2": {
"value": "Bedsit"
},
- "3": {
+ "8": {
"value": "Bungalow"
},
- "0": {
+ "1": {
"value": "Flat or maisonette"
},
- "2": {
+ "7": {
"value": "House"
},
- "6": {
+ "10": {
"value": "Shared bungalow"
},
"4": {
"value": "Shared flat or maisonette"
},
- "5": {
+ "9": {
"value": "Shared house"
},
- "7": {
+ "6": {
"value": "Other"
}
}
@@ -786,10 +786,10 @@
"hint_text": "",
"type": "radio",
"answer_options": {
- "1": {
+ "2": {
"value": "Converted from previous residential or non-residential property"
},
- "0": {
+ "1": {
"value": "Purpose built"
}
}
@@ -806,10 +806,10 @@
"hint_text": "",
"type": "radio",
"answer_options": {
- "0": {
+ "1": {
"value": "Yes"
},
- "1": {
+ "2": {
"value": "No"
}
}
@@ -841,7 +841,7 @@
"header": "",
"description": "",
"questions": {
- "property_void_date": {
+ "voiddate": {
"check_answer_label": "Void or renewal date",
"header": "What is the void or renewal date?",
"hint_text": "For example, 27 3 2021.",
@@ -863,7 +863,7 @@
"header": "",
"description": "",
"questions": {
- "property_void_date": {
+ "voiddate": {
"check_answer_label": "New-build handover date",
"header": "What is the new-build handover date?",
"hint_text": "",
@@ -938,10 +938,10 @@
"hint_text": "",
"type": "radio",
"answer_options": {
- "0": {
+ "1": {
"value": "Yes"
},
- "1": {
+ "2": {
"value": "No"
}
}
@@ -958,25 +958,25 @@
"hint_text": "",
"type": "radio",
"answer_options": {
- "0": {
+ "2": {
"value": "Assured"
},
- "1": {
+ "4": {
"value": "Assured Shorthold"
},
- "2": {
+ "5": {
"value": "Licence agreement (almshouses only)"
},
- "3": {
+ "1": {
"value": "Secure (including flexible)"
},
- "4": {
+ "3": {
"value": "Other"
}
},
"conditional_for": {
"tenancyother": [
- 4
+ 3
]
}
},
@@ -1002,25 +1002,25 @@
"hint_text": "This is also known as an ‘introductory period’.",
"type": "radio",
"answer_options": {
- "0": {
+ "2": {
"value": "Assured"
},
- "1": {
+ "4": {
"value": "Assured Shorthold"
},
- "2": {
+ "5": {
"value": "Licence agreement (almshouses only)"
},
- "3": {
+ "1": {
"value": "Secure (including flexible)"
},
- "4": {
+ "3": {
"value": "Other"
}
},
"conditional_for": {
"tenancyother": [
- 4
+ 3
]
}
},
@@ -1053,10 +1053,10 @@
},
"depends_on": [
{
- "tenancy": 3
+ "tenancy": 1
},
{
- "tenancy": 1
+ "tenancy": 4
}
]
},
@@ -1064,25 +1064,25 @@
"header": "",
"description": "",
"questions": {
- "letting_in_sheltered_accommodation": {
+ "shelteredaccom": {
"check_answer_label": "Is this letting in sheltered accommodation?",
"header": "Is this letting in sheltered accommodation?",
"hint_text": "",
"type": "radio",
"answer_options": {
- "0": {
+ "1": {
"value": "Yes – sheltered housing"
},
- "1": {
+ "2": {
"value": "Yes – extra care housing"
},
- "2": {
+ "3": {
"value": "No"
},
"divider": {
"value": true
},
- "3": {
+ "4": {
"value": "Don’t know"
}
}
@@ -1090,7 +1090,7 @@
},
"depends_on": [
{
- "needstype": 0
+ "needstype": 2
}
]
}
@@ -1228,7 +1228,7 @@
"divider": {
"value": true
},
- "5": {
+ "17": {
"value": "Tenant prefers not to say"
}
}
@@ -1245,16 +1245,16 @@
"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.",
"type": "radio",
"answer_options": {
- "0": {
+ "19": {
"value": "Arab"
},
- "1": {
+ "16": {
"value": "Other ethnic group"
}
},
"conditional_for": {
"ethnic_other": [
- 1
+ 16
]
}
},
@@ -1280,25 +1280,25 @@
"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.",
"type": "radio",
"answer_options": {
- "0": {
+ "10": {
"value": "Bangladeshi"
},
- "1": {
+ "15": {
"value": "Chinese"
},
- "2": {
+ "8": {
"value": "Indian"
},
- "3": {
+ "9": {
"value": "Pakistani"
},
- "4": {
+ "11": {
"value": "Other ethnic group"
}
},
"conditional_for": {
"ethnic_other": [
- 4
+ 11
]
}
},
@@ -1324,13 +1324,13 @@
"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.",
"type": "radio",
"answer_options": {
- "0": {
+ "13": {
"value": "African"
},
- "1": {
+ "12": {
"value": "Caribbean"
},
- "2": {
+ "14": {
"value": "Any other Black, African or Caribbean background"
}
},
@@ -1362,19 +1362,22 @@
"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.",
"type": "radio",
"answer_options": {
- "0": {
+ "4": {
"value": "White and Black Caribbean"
},
- "1": {
+ "5": {
"value": "White and Black African"
},
- "2": {
+ "6": {
+ "value": "White and Asian"
+ },
+ "7": {
"value": "Any other Mixed or Multiple ethnic background"
}
},
"conditional_for": {
"ethnic_other": [
- 2
+ 7
]
}
},
@@ -1400,17 +1403,14 @@
"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.",
"type": "radio",
"answer_options": {
- "0": {
+ "1": {
"value": "English, Welsh, Northern Irish, Scottish or British"
},
- "1": {
+ "2": {
"value": "Irish"
},
- "2": {
+ "18": {
"value": "Gypsy or Irish Traveller"
- },
- "3": {
- "value": "Any other White background"
}
},
"conditional_for": {
@@ -1564,25 +1564,25 @@
},
"depends_on": [
{
- "other_hhmemb": 1
+ "hhmemb": 2
},
{
- "other_hhmemb": 2
+ "hhmemb": 3
},
{
- "other_hhmemb": 3
+ "hhmemb": 4
},
{
- "other_hhmemb": 4
+ "hhmemb": 5
},
{
- "other_hhmemb": 5
+ "hhmemb": 6
},
{
- "other_hhmemb": 6
+ "hhmemb": 7
},
{
- "other_hhmemb": 7
+ "hhmemb": 8
}
]
},
@@ -1777,22 +1777,22 @@
},
"depends_on": [
{
- "other_hhmemb": 2
+ "hhmemb": 3
},
{
- "other_hhmemb": 3
+ "hhmemb": 4
},
{
- "other_hhmemb": 4
+ "hhmemb": 5
},
{
- "other_hhmemb": 5
+ "hhmemb": 6
},
{
- "other_hhmemb": 6
+ "hhmemb": 7
},
{
- "other_hhmemb": 7
+ "hhmemb": 8
}
]
},
@@ -1987,19 +1987,19 @@
},
"depends_on": [
{
- "other_hhmemb": 3
+ "hhmemb": 4
},
{
- "other_hhmemb": 4
+ "hhmemb": 5
},
{
- "other_hhmemb": 5
+ "hhmemb": 6
},
{
- "other_hhmemb": 6
+ "hhmemb": 7
},
{
- "other_hhmemb": 7
+ "hhmemb": 8
}
]
},
@@ -2194,16 +2194,16 @@
},
"depends_on": [
{
- "other_hhmemb": 4
+ "hhmemb": 5
},
{
- "other_hhmemb": 5
+ "hhmemb": 6
},
{
- "other_hhmemb": 6
+ "hhmemb": 7
},
{
- "other_hhmemb": 7
+ "hhmemb": 8
}
]
},
@@ -2398,13 +2398,13 @@
},
"depends_on": [
{
- "other_hhmemb": 5
+ "hhmemb": 6
},
{
- "other_hhmemb": 6
+ "hhmemb": 7
},
{
- "other_hhmemb": 7
+ "hhmemb": 8
}
]
},
@@ -2599,10 +2599,10 @@
},
"depends_on": [
{
- "other_hhmemb": 6
+ "hhmemb": 7
},
{
- "other_hhmemb": 7
+ "hhmemb": 8
}
]
},
@@ -2797,7 +2797,7 @@
},
"depends_on": [
{
- "other_hhmemb": 7
+ "hhmemb": 8
}
]
},
@@ -2992,22 +2992,22 @@
"type": "radio",
"check_answer_label": "Household links to UK armed forces",
"answer_options": {
- "0": {
+ "1": {
"value": "Yes – the person is a current or former regular"
},
- "1": {
+ "4": {
"value": "Yes – the person is a current or former reserve"
},
- "2": {
+ "5": {
"value": "Yes – the person is a spouse or civil partner of a UK armed forces member and has been bereaved or separated from them within the last 2 years"
},
- "3": {
+ "2": {
"value": "No"
},
"divider": {
"value": true
},
- "4": {
+ "3": {
"value": "Person prefers not to say"
}
}
@@ -3019,7 +3019,7 @@
"description": "",
"depends_on": [
{
- "armedforces": 0
+ "armedforces": 1
}
],
"questions": {
@@ -3053,10 +3053,10 @@
"description": "",
"depends_on": [
{
- "armedforces": 0
+ "armedforces": 1
},
{
- "armedforces": 1
+ "armedforces": 4
}
],
"questions": {
@@ -3092,16 +3092,16 @@
"type": "radio",
"check_answer_label": "Anybody in household pregnant",
"answer_options": {
- "0": {
+ "1": {
"value": "Yes"
},
- "1": {
+ "2": {
"value": "No"
},
"divider": {
"value": true
},
- "2": {
+ "3": {
"value": "Tenant prefers not to say"
}
}
@@ -3153,16 +3153,16 @@
"type": "radio",
"check_answer_label": "Anybody in household with physical or mental health condition",
"answer_options": {
- "0": {
+ "1": {
"value": "Yes"
},
- "1": {
+ "2": {
"value": "No"
},
"divider": {
"value": true
},
- "2": {
+ "3": {
"value": "Tenant prefers not to say"
}
}
@@ -3174,7 +3174,7 @@
"description": "",
"depends_on": [
{
- "illness": 0
+ "illness": 1
}
],
"questions": {
@@ -3284,37 +3284,37 @@
"header": "",
"description": "",
"questions": {
- "lawaitlist": {
+ "waityear": {
"check_answer_label": "Length of time on local authority waiting list",
"header": "How long has the household been on the local authority waiting list for the new letting?",
"hint_text": "",
"type": "radio",
"answer_options": {
- "0": {
+ "1": {
"value": "Just moved to local authority area"
},
- "1": {
+ "2": {
"value": "Less than 1 year"
},
- "2": {
+ "7": {
"value": "1 year but under 2 years"
},
- "3": {
+ "8": {
"value": "2 years but under 3 years"
},
- "4": {
+ "9": {
"value": "3 years but under 4 years"
},
- "5": {
+ "10": {
"value": "4 years but under 5 years"
},
- "6": {
+ "5": {
"value": "5 years or more"
},
"divider": {
"value": true
},
- "7": {
+ "6": {
"value": "Don’t know"
}
}
@@ -3437,18 +3437,15 @@
},
"28": {
"value": "Don’t know"
- },
- "10000": {
- "value": "Tenant prefers not to say"
}
},
"conditional_for": {
- "other_reason_for_leaving_last_settled_home": [
- 31
+ "reasonother": [
+ 20
]
}
},
- "other_reason_for_leaving_last_settled_home": {
+ "reasonother": {
"header": "What is the reason?",
"hint_text": "",
"type": "text"
@@ -3595,7 +3592,7 @@
"depends_on": [
{
"renewal": 1,
- "needstype": 0
+ "needstype": 2
}
]
},
@@ -4391,7 +4388,7 @@
"depends_on": [
{
"managing_organisation.provider_type": "LA",
- "needstype": 0,
+ "needstype": 2,
"renewal": 0
}
]
@@ -4451,7 +4448,7 @@
"depends_on": [
{
"managing_organisation.provider_type": "PRP",
- "needstype": 0,
+ "needstype": 2,
"renewal": 0
}
]
@@ -4520,19 +4517,19 @@
{
"label": "every week",
"depends_on": {
- "incfreq": 0
+ "incfreq": 1
}
},
{
"label": "every month",
"depends_on": {
- "incfreq": 1
+ "incfreq": 2
}
},
{
- "label": "every month",
+ "label": "every year",
"depends_on": {
- "incfreq": 2
+ "incfreq": 3
}
}
]
@@ -4543,13 +4540,13 @@
"hint_text": "",
"type": "radio",
"answer_options": {
- "0": {
+ "1": {
"value": "Weekly"
},
- "1": {
+ "2": {
"value": "Monthly"
},
- "2": {
+ "3": {
"value": "Yearly"
}
},
@@ -4611,9 +4608,6 @@
},
"3": {
"value": "Don’t know"
- },
- "6": {
- "value": "Tenant prefers not to say"
}
}
}
@@ -4629,19 +4623,19 @@
"hint_text": "This excludes child and housing benefit, council tax support and tax credits.",
"type": "radio",
"answer_options": {
- "0": {
+ "1": {
"value": "All"
},
- "1": {
+ "2": {
"value": "Some"
},
- "2": {
+ "3": {
"value": "None"
},
"divider": {
"value": true
},
- "3": {
+ "4": {
"value": "Don’t know"
}
}
@@ -4669,7 +4663,7 @@
},
"depends_on": [
{
- "needstype": 0
+ "needstype": 2
}
]
},
@@ -4759,62 +4753,62 @@
"depends_on": [
{
"period": 1,
- "needstype": 0,
+ "needstype": 2,
"household_charge": 0
},
{
"period": 1,
- "needstype": 0,
+ "needstype": 2,
"household_charge": null
},
{
"period": 5,
- "needstype": 0,
+ "needstype": 2,
"household_charge": 0
},
{
"period": 5,
- "needstype": 0,
+ "needstype": 2,
"household_charge": null
},
{
"period": 6,
- "needstype": 0,
+ "needstype": 2,
"household_charge": 0
},
{
"period": 6,
- "needstype": 0,
+ "needstype": 2,
"household_charge": null
},
{
"period": 7,
- "needstype": 0,
+ "needstype": 2,
"household_charge": 0
},
{
"period": 7,
- "needstype": 0,
+ "needstype": 2,
"household_charge": null
},
{
"period": 8,
- "needstype": 0,
+ "needstype": 2,
"household_charge": 0
},
{
"period": 8,
- "needstype": 0,
+ "needstype": 2,
"household_charge": null
},
{
"period": 9,
- "needstype": 0,
+ "needstype": 2,
"household_charge": 0
},
{
"period": 9,
- "needstype": 0,
+ "needstype": 2,
"household_charge": null
}
]
@@ -4856,12 +4850,12 @@
"depends_on": [
{
"period": 2,
- "needstype": 0,
+ "needstype": 2,
"household_charge": 0
},
{
"period": 2,
- "needstype": 0,
+ "needstype": 2,
"household_charge": null
}
]
@@ -4903,12 +4897,12 @@
"depends_on": [
{
"period": 3,
- "needstype": 0,
+ "needstype": 2,
"household_charge": 0
},
{
"period": 3,
- "needstype": 0,
+ "needstype": 2,
"household_charge": null
}
]
@@ -4950,12 +4944,12 @@
"depends_on": [
{
"period": 4,
- "needstype": 0,
+ "needstype": 2,
"household_charge": 0
},
{
"period": 4,
- "needstype": 0,
+ "needstype": 2,
"household_charge": null
}
]
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 3e024df62..ebd5762bc 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -101,26 +101,26 @@ en:
rent:
less_than_double_shortfall: "Answer must be more than double the shortfall in basic rent"
scharge:
- this_landlord:
- general_needs: "Service charge must be between £0 and £55 per week if the landlord is the same and it is a general needs letting"
- supported_housing: "Service charge must be between £0 and £280 per week if the landlord is the same and it is a supported housing letting"
- other_landlord:
- general_needs: "Service charge must be between £0 and £45 per week if the landlord is another registered provider and it is a general needs letting"
- supported_housing: "Service charge must be between £0 and £165 per week if the landlord is another registered provider and it is a supported housing letting"
+ private_registered_provider:
+ general_needs: "Service charge must be between £0 and £55 per week if the landlord is a private registered provider and it is a general needs letting"
+ supported_housing: "Service charge must be between £0 and £280 per week if the landlord is a private registered provider and it is a supported housing letting"
+ local_authority:
+ general_needs: "Service charge must be between £0 and £45 per week if the landlord is a local authority and it is a general needs letting"
+ supported_housing: "Service charge must be between £0 and £165 per week if the landlord is a local authority and it is a supported housing letting"
pscharge:
- this_landlord:
- general_needs: "Personal service charge must be between £0 and £30 per week if the landlord is the same and it is a general needs letting"
- supported_housing: "Personal service charge must be between £0 and £200 per week if the landlord is the same and it is a supported housing letting"
- other_landlord:
- general_needs: "Personal service charge must be between £0 and £35 per week if the landlord is another registered provider and it is a general needs letting"
- supported_housing: "Personal service charge must be between £0 and £75 per week if the landlord is another registered provider and it is a supported housing letting"
+ private_registered_provider:
+ general_needs: "Personal service charge must be between £0 and £30 per week if the landlord is a private registered provider and it is a general needs letting"
+ supported_housing: "Personal service charge must be between £0 and £200 per week if the landlord is a private registered provider and it is a supported housing letting"
+ local_authority:
+ general_needs: "Personal service charge must be between £0 and £35 per week if the landlord is a local authority and it is a general needs letting"
+ supported_housing: "Personal service charge must be between £0 and £75 per week if the landlord is a local authority and it is a supported housing letting"
supcharg:
- this_landlord:
- general_needs: "Support charge must be between £0 and £40 per week if the landlord is the same and it is a general needs letting"
- supported_housing: "Support charge must be between £0 and £465 per week if the landlord is the same and it is a supported housing letting"
- other_landlord:
- general_needs: "Support charge must be between £0 and £60 per week if the landlord is another registered provider and it is a general needs letting"
- supported_housing: "Support charge must be between £0 and £120 per week if the landlord is another registered provider and it is a supported housing letting"
+ private_registered_provider:
+ general_needs: "Support charge must be between £0 and £40 per week if the landlord is a private registered provider and it is a general needs letting"
+ supported_housing: "Support charge must be between £0 and £465 per week if the landlord is a private registered provider and it is a supported housing letting"
+ local_authority:
+ general_needs: "Support charge must be between £0 and £60 per week if the landlord is a local authority and it is a general needs letting"
+ supported_housing: "Support charge must be between £0 and £120 per week if the landlord is a local authority and it is a supported housing letting"
brent:
not_in_range: "Basic rent is outside of the expected range based on the lettings type, local authority and number of bedrooms"
la:
@@ -183,7 +183,7 @@ en:
male_refuge: "Answer cannot be refuge as the lead tenant identifies as male"
internal_transfer: "Answer cannot be %{prevten} as you already told us this tenancy is an internal transfer"
la_general_needs:
- internal_transfer: "Answer cannot be a fixed-term or lifetime local authority general needs tenancy as you already told us it's the same landlord on the tenancy agreement and it is an internal transfer"
+ internal_transfer: "Answer cannot be a fixed-term or lifetime local authority general needs tenancy as you already told us it's a private registered provider on the tenancy agreement and it is an internal transfer"
referral:
secure_tenancy: "Answer must be internal transfer as you already told us this is a secure tenancy"
rsnvac_non_temp: "Answer cannot be this source of referral as you already told us this is a re-let to tenant who occupied the same property as temporary accommodation"
@@ -195,7 +195,7 @@ en:
la_general_needs:
internal_transfer: "Answer cannot be internal transfer as you already told us it's the same landlord on the tenancy agreement and the household had either a fixed-term or lifetime local authority general needs tenancy immediately before this letting"
prp:
- local_housing_referral: "Answer cannot be 'nominated by a local housing authority' as you already told us it's another landlord on the tenancy agreement"
+ local_housing_referral: "Answer cannot be 'nominated by a local housing authority' as you already told us it is a local authority on the tenancy agreement"
homeless:
assessed:
internal_transfer: "Answer cannot be assessed as homeless as you already told us this tenancy is an internal transfer"
diff --git a/db/migrate/202202071123100_additional_user_fields2.rb b/db/migrate/20220207112310_additional_user_fields2.rb
similarity index 100%
rename from db/migrate/202202071123100_additional_user_fields2.rb
rename to db/migrate/20220207112310_additional_user_fields2.rb
diff --git a/db/migrate/20220411092231_update_case_logs_fields.rb b/db/migrate/20220411092231_update_case_logs_fields.rb
new file mode 100644
index 000000000..09b83e633
--- /dev/null
+++ b/db/migrate/20220411092231_update_case_logs_fields.rb
@@ -0,0 +1,13 @@
+class UpdateCaseLogsFields < ActiveRecord::Migration[7.0]
+ def change
+ change_table :case_logs, bulk: true do |t|
+ t.integer :old_form_id, :lar, :irproduct
+ t.remove :day, :month, :year, :vday, :vmonth, :vyear, :mrcday, :mrcmonth, :mrcyear, :other_hhmemb, :accessibility_requirements_prefer_not_to_say, :landlord, type: :integer
+ t.remove :ppostc1, :ppostc2, :postcode, :postcod2, type: :string
+ t.rename :intermediate_rent_product_name, :irproduct_other
+ t.rename :lawaitlist, :waityear
+ t.rename :other_reason_for_leaving_last_settled_home, :reasonother
+ t.rename :property_void_date, :voiddate
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 61368691c..8a8103a23 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema[7.0].define(version: 202202071123100) do
+ActiveRecord::Schema[7.0].define(version: 2022_04_11_092231) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -86,7 +86,6 @@ ActiveRecord::Schema[7.0].define(version: 202202071123100) do
t.integer "startertenancy"
t.integer "tenancylength"
t.integer "tenancy"
- t.integer "landlord"
t.string "ppostcode_full"
t.integer "rsnvac"
t.integer "unittype_gn"
@@ -98,20 +97,19 @@ ActiveRecord::Schema[7.0].define(version: 202202071123100) do
t.integer "benefits"
t.integer "period"
t.integer "layear"
- t.integer "lawaitlist"
+ t.integer "waityear"
t.string "postcode_full"
t.integer "reasonpref"
t.integer "cbl"
t.integer "chr"
t.integer "cap"
- t.string "other_reason_for_leaving_last_settled_home"
+ t.string "reasonother"
t.integer "housingneeds_a"
t.integer "housingneeds_b"
t.integer "housingneeds_c"
t.integer "housingneeds_f"
t.integer "housingneeds_g"
t.integer "housingneeds_h"
- t.integer "accessibility_requirements_prefer_not_to_say"
t.integer "illness_type_1"
t.integer "illness_type_2"
t.integer "illness_type_3"
@@ -132,7 +130,7 @@ ActiveRecord::Schema[7.0].define(version: 202202071123100) do
t.string "property_owner_organisation"
t.string "property_manager_organisation"
t.string "sale_or_letting"
- t.string "intermediate_rent_product_name"
+ t.string "irproduct_other"
t.string "purchaser_code"
t.integer "reason"
t.string "propcode"
@@ -141,16 +139,8 @@ ActiveRecord::Schema[7.0].define(version: 202202071123100) do
t.string "prevloc"
t.integer "hb"
t.integer "hbrentshortfall"
- t.string "postcode"
- t.string "postcod2"
- t.string "ppostc1"
- t.string "ppostc2"
t.integer "property_relet"
t.datetime "mrcdate", precision: nil
- t.integer "mrcday"
- t.integer "mrcmonth"
- t.integer "mrcyear"
- t.integer "other_hhmemb"
t.integer "incref"
t.datetime "sale_completion_date", precision: nil
t.datetime "startdate", precision: nil
@@ -158,7 +148,7 @@ ActiveRecord::Schema[7.0].define(version: 202202071123100) do
t.integer "first_time_property_let_as_social_housing"
t.integer "unitletas"
t.integer "builtype"
- t.datetime "property_void_date", precision: nil
+ t.datetime "voiddate", precision: nil
t.bigint "owning_organisation_id"
t.bigint "managing_organisation_id"
t.integer "renttype"
@@ -167,9 +157,6 @@ ActiveRecord::Schema[7.0].define(version: 202202071123100) do
t.integer "postcode_known"
t.integer "la_known"
t.boolean "is_la_inferred"
- t.integer "day"
- t.integer "month"
- t.integer "year"
t.integer "totchild"
t.integer "totelder"
t.integer "totadult"
@@ -219,9 +206,6 @@ ActiveRecord::Schema[7.0].define(version: 202202071123100) do
t.decimal "wtshortfall", precision: 10, scale: 2
t.integer "refused"
t.integer "housingneeds"
- t.integer "vday"
- t.integer "vmonth"
- t.integer "vyear"
t.decimal "wchchrg", precision: 10, scale: 2
t.integer "newprop"
t.string "relat2"
@@ -232,6 +216,9 @@ ActiveRecord::Schema[7.0].define(version: 202202071123100) do
t.string "relat7"
t.string "relat8"
t.integer "rent_value_check"
+ t.integer "old_form_id"
+ t.integer "lar"
+ t.integer "irproduct"
t.index ["managing_organisation_id"], name: "index_case_logs_on_managing_organisation_id"
t.index ["owning_organisation_id"], name: "index_case_logs_on_owning_organisation_id"
end
diff --git a/docs/api/DLUHC-CORE-Data.v1.json b/docs/api/DLUHC-CORE-Data.v1.json
index 742c2a571..dc709691b 100644
--- a/docs/api/DLUHC-CORE-Data.v1.json
+++ b/docs/api/DLUHC-CORE-Data.v1.json
@@ -361,7 +361,7 @@
"cap": 0,
"hbrentshortfall": 0,
"tshortfall": 12,
- "other_reason_for_leaving_last_settled_home": null,
+ "reasonother": null,
"housingneeds_a": 1,
"housingneeds_b": 0,
"housingneeds_c": 0,
@@ -940,4 +940,4 @@
}
}
}
-}
\ No newline at end of file
+}
diff --git a/spec/factories/case_log.rb b/spec/factories/case_log.rb
index 2bec19c48..ce2dfaf90 100644
--- a/spec/factories/case_log.rb
+++ b/spec/factories/case_log.rb
@@ -7,7 +7,6 @@ FactoryBot.define do
needstype { 1 }
rent_type { 1 }
startdate { Time.zone.local(2022, 5, 1) }
- year { 2022 }
end
trait :in_progress do
status { 1 }
@@ -21,7 +20,7 @@ FactoryBot.define do
status { 1 }
ecstat1 { 1 }
earnings { 750 }
- incfreq { 0 }
+ incfreq { 1 }
end
trait :conditional_section_complete do
tenant_code { "TH356" }
@@ -30,19 +29,17 @@ FactoryBot.define do
ethnic { 2 }
national { 4 }
ecstat1 { 2 }
- other_hhmemb { 0 }
+ hhmemb { 1 }
end
trait :completed do
status { 2 }
tenant_code { "BZ737" }
- postcode { "NW1 7TY" }
age1 { 35 }
sex1 { "F" }
ethnic { 2 }
national { 4 }
prevten { 6 }
ecstat1 { 0 }
- other_hhmemb { 1 }
hhmemb { 2 }
relat2 { "P" }
age2 { 32 }
@@ -52,25 +49,21 @@ FactoryBot.define do
underoccupation_benefitcap { 0 }
leftreg { 1 }
reservist { 0 }
- illness { 0 }
- preg_occ { 1 }
+ illness { 1 }
+ preg_occ { 2 }
tenancy_code { "BZ757" }
startertenancy { 0 }
tenancylength { 5 }
- tenancy { 3 }
- landlord { 1 }
+ tenancy { 1 }
ppostcode_full { "SE2 6RT" }
- rsnvac { 7 }
- unittype_gn { 2 }
+ rsnvac { 6 }
+ unittype_gn { 7 }
beds { 3 }
- property_void_date { "03/11/2019" }
- vday { 3 }
- vmonth { 11 }
- vyear { 2019 }
+ voiddate { "03/11/2019" }
offered { 2 }
wchair { 1 }
earnings { 68 }
- incfreq { 0 }
+ incfreq { 1 }
benefits { 1 }
period { 2 }
brent { 200 }
@@ -79,20 +72,19 @@ FactoryBot.define do
supcharg { 35 }
tcharge { 325 }
layear { 2 }
- lawaitlist { 1 }
+ waityear { 1 }
postcode_full { "NW1 5TY" }
reasonpref { 1 }
cbl { 1 }
chr { 1 }
cap { 0 }
- other_reason_for_leaving_last_settled_home { nil }
+ reasonother { nil }
housingneeds_a { 1 }
housingneeds_b { 0 }
housingneeds_c { 0 }
housingneeds_f { 0 }
housingneeds_g { 0 }
housingneeds_h { 0 }
- accessibility_requirements_prefer_not_to_say { 0 }
illness_type_1 { 0 }
illness_type_2 { 1 }
illness_type_3 { 0 }
@@ -115,7 +107,6 @@ FactoryBot.define do
property_manager_organisation { "Test" }
renewal { 0 }
rent_type { 1 }
- intermediate_rent_product_name { 2 }
needstype { 1 }
purchaser_code { 798_794 }
reason { 4 }
@@ -126,21 +117,12 @@ FactoryBot.define do
hb { 6 }
hbrentshortfall { 0 }
tshortfall { 12 }
- postcod2 { "w3" }
- ppostc1 { "w3" }
- ppostc2 { "w3" }
property_relet { 0 }
mrcdate { Time.utc(2020, 5, 0o5, 10, 36, 49) }
- mrcday { mrcdate.day }
- mrcmonth { mrcdate.month }
- mrcyear { mrcdate.year }
incref { 0 }
sale_completion_date { nil }
startdate { Time.utc(2022, 2, 2, 10, 36, 49) }
- day { startdate.day }
- month { startdate.month }
- year { startdate.year }
- armedforces { 0 }
+ armedforces { 1 }
builtype { 1 }
unitletas { 2 }
has_benefits { 1 }
diff --git a/spec/features/form/check_answers_page_spec.rb b/spec/features/form/check_answers_page_spec.rb
index 34125ee41..523e43038 100644
--- a/spec/features/form/check_answers_page_spec.rb
+++ b/spec/features/form/check_answers_page_spec.rb
@@ -53,7 +53,7 @@ RSpec.describe "Form Check Answers Page" do
it "has question headings based on the subsection" do
visit("/logs/#{id}/#{subsection}/check-answers")
- question_labels = ["Tenant code", "Lead tenant’s age", "Lead tenant’s gender identity", "Number of Other Household Members"]
+ question_labels = ["Tenant code", "Lead tenant’s age", "Lead tenant’s gender identity", "Number of Household Members"]
question_labels.each do |label|
expect(page).to have_content(label)
end
@@ -113,7 +113,7 @@ RSpec.describe "Form Check Answers Page" do
it "displays conditional question that were visited" do
visit("/logs/#{id}/conditional-question")
- choose("case-log-preg-occ-1-field", allow_label_click: true)
+ choose("case-log-preg-occ-2-field", allow_label_click: true)
click_button("Save and continue")
visit("/logs/#{id}/#{conditional_subsection}/check-answers")
question_labels = ["Has the condition been met?", "Has the condition not been met?"]
@@ -151,7 +151,7 @@ RSpec.describe "Form Check Answers Page" do
tenant_code: "123",
age1: 35,
sex1: "M",
- other_hhmemb: 0,
+ hhmemb: 1,
)
end
@@ -164,9 +164,9 @@ RSpec.describe "Form Check Answers Page" do
tenant_code: "123",
age1: 35,
sex1: "M",
- other_hhmemb: 0,
+ hhmemb: 1,
armedforces: 3,
- illness: 0,
+ illness: 1,
)
end
@@ -179,9 +179,9 @@ RSpec.describe "Form Check Answers Page" do
tenant_code: "123",
age1: 35,
sex1: "M",
- other_hhmemb: 0,
+ hhmemb: 1,
armedforces: 3,
- illness: 0,
+ illness: 1,
housingneeds_h: 1,
la: "E06000014",
illness_type_1: 1,
@@ -197,7 +197,7 @@ RSpec.describe "Form Check Answers Page" do
tenant_code: nil,
age1: nil,
layear: 2,
- lawaitlist: 1,
+ waityear: 1,
postcode_full: "NW1 5TY",
reason: 4,
ppostcode_full: "SE2 6RT",
diff --git a/spec/features/form/conditional_questions_spec.rb b/spec/features/form/conditional_questions_spec.rb
index db558c93a..9b5c01a20 100644
--- a/spec/features/form/conditional_questions_spec.rb
+++ b/spec/features/form/conditional_questions_spec.rb
@@ -27,11 +27,11 @@ RSpec.describe "Form Conditional Questions" do
it "shows conditional questions if the required answer is selected and hides it again when a different answer option is selected", js: true do
visit("/logs/#{id}/armed-forces")
# Something about our styling makes the selenium webdriver think the actual radio buttons are not visible so we allow label click here
- choose("case-log-armedforces-0-field", allow_label_click: true)
- fill_in("case-log-leftreg-field", with: "text")
choose("case-log-armedforces-1-field", allow_label_click: true)
+ fill_in("case-log-leftreg-field", with: "text")
+ choose("case-log-armedforces-4-field", allow_label_click: true)
expect(page).not_to have_field("case-log-leftreg-field")
- choose("case-log-armedforces-0-field", allow_label_click: true)
+ choose("case-log-armedforces-1-field", allow_label_click: true)
expect(page).to have_field("case-log-leftreg-field", with: "")
end
end
diff --git a/spec/features/form/form_navigation_spec.rb b/spec/features/form/form_navigation_spec.rb
index fd4f78b08..ef8bc7448 100644
--- a/spec/features/form/form_navigation_spec.rb
+++ b/spec/features/form/form_navigation_spec.rb
@@ -19,7 +19,7 @@ RSpec.describe "Form Navigation" do
age1: { type: "numeric", answer: 25, path: "person-1-age" },
sex1: { type: "radio", answer: "Female", path: "person-1-gender" },
ecstat1: { type: "radio", answer: 3, path: "person-1-working-situation" },
- other_hhmemb: { type: "numeric", answer: 2, path: "household-number-of-other-members" },
+ hhmemb: { type: "numeric", answer: 1, path: "household-number-of-members" },
}
end
@@ -71,7 +71,7 @@ RSpec.describe "Form Navigation" do
visit("/logs")
visit("/logs/#{id}/net-income")
fill_in("case-log-earnings-field", with: 740)
- choose("case-log-incfreq-0-field", allow_label_click: true)
+ choose("case-log-incfreq-1-field", allow_label_click: true)
click_button("Save and continue")
click_link(text: "Back")
click_link(text: "Back")
diff --git a/spec/features/form/page_routing_spec.rb b/spec/features/form/page_routing_spec.rb
index d4f50f118..83a1078ff 100644
--- a/spec/features/form/page_routing_spec.rb
+++ b/spec/features/form/page_routing_spec.rb
@@ -24,12 +24,12 @@ RSpec.describe "Form Page Routing" do
visit("/logs/#{id}/conditional-question")
# using a question name that is already in the db to avoid
# having to add a new column to the db for this test
- choose("case-log-preg-occ-0-field", allow_label_click: true)
+ choose("case-log-preg-occ-1-field", allow_label_click: true)
click_button("Save and continue")
expect(page).to have_current_path("/logs/#{id}/conditional-question-yes-page")
click_link(text: "Back")
expect(page).to have_current_path("/logs/#{id}/conditional-question")
- choose("case-log-preg-occ-1-field", allow_label_click: true)
+ choose("case-log-preg-occ-2-field", allow_label_click: true)
click_button("Save and continue")
expect(page).to have_current_path("/logs/#{id}/conditional-question-no-page")
end
@@ -40,7 +40,7 @@ RSpec.describe "Form Page Routing" do
click_button("Save and continue")
expect(page).to have_current_path("/logs/#{id}/person-1-working-situation")
visit("/logs/#{id}/conditional-question")
- choose("case-log-preg-occ-1-field", allow_label_click: true)
+ choose("case-log-preg-occ-2-field", allow_label_click: true)
click_button("Save and continue")
expect(page).to have_current_path("/logs/#{id}/conditional-question-no-page")
click_button("Save and continue")
diff --git a/spec/features/form/saving_data_spec.rb b/spec/features/form/saving_data_spec.rb
index d9fa2feba..9e8d09f58 100644
--- a/spec/features/form/saving_data_spec.rb
+++ b/spec/features/form/saving_data_spec.rb
@@ -26,7 +26,7 @@ RSpec.describe "Form Saving Data" do
tenant_code: { type: "text", answer: "BZ737", path: "tenant_code" },
age1: { type: "numeric", answer: 25, path: "person_1_age" },
sex1: { type: "radio", answer: { "F" => "Female" }, path: "person_1_gender" },
- other_hhmemb: { type: "numeric", answer: 2, path: "household_number_of_other_members" },
+ hhmemb: { type: "numeric", answer: 3, path: "household_number_of_members" },
}
end
diff --git a/spec/features/form/validations_spec.rb b/spec/features/form/validations_spec.rb
index b884264a4..75e7f3e99 100644
--- a/spec/features/form/validations_spec.rb
+++ b/spec/features/form/validations_spec.rb
@@ -127,7 +127,7 @@ RSpec.describe "validations" do
it "prompts the user to confirm the value is correct with an interruption screen" do
visit("/logs/#{case_log.id}/net-income")
fill_in("case-log-earnings-field", with: income_over_soft_limit)
- choose("case-log-incfreq-0-field", allow_label_click: true)
+ choose("case-log-incfreq-1-field", allow_label_click: true)
click_button("Save and continue")
expect(page).to have_current_path("/logs/#{case_log.id}/net-income-value-check")
expect(page).to have_content("Net income is outside the expected range based on the lead tenant’s working situation")
@@ -141,7 +141,7 @@ RSpec.describe "validations" do
it "returns the user to the previous question if they do not confirm the value as correct on the interruption screen" do
visit("/logs/#{case_log.id}/net-income")
fill_in("case-log-earnings-field", with: income_over_soft_limit)
- choose("case-log-incfreq-0-field", allow_label_click: true)
+ choose("case-log-incfreq-1-field", allow_label_click: true)
click_button("Save and continue")
choose("case-log-net-income-value-check-1-field", allow_label_click: true)
click_button("Save and continue")
diff --git a/spec/fixtures/complete_case_log.json b/spec/fixtures/complete_case_log.json
index 9240f92de..d32fe927f 100644
--- a/spec/fixtures/complete_case_log.json
+++ b/spec/fixtures/complete_case_log.json
@@ -6,10 +6,9 @@
"ethnic": 0,
"national": 0,
"prevten": 6,
- "armedforces": 0,
+ "armedforces": 1,
"armed_forces_partner": "",
"ecstat1": 1,
- "other_hhmemb": 7,
"hhmemb": 8,
"relat2": "P",
"age2": 32,
@@ -43,39 +42,30 @@
"underoccupation_benefitcap": 0,
"leftreg": 1,
"reservist": 0,
- "illness": 0,
- "preg_occ": 0,
+ "illness": 1,
+ "preg_occ": 1,
"tenancy_code": "BZ757",
"startdate": "12/12/2021",
- "day": 12,
- "month": 12,
- "year": 2021,
"startertenancy": 0,
"tenancylength": 5,
- "tenancy": 3,
+ "tenancy": 1,
"landlord": 1,
"la": "Barnet",
"postcode_full": "NW1 5TY",
"property_relet": 0,
- "rsnvac": 0,
+ "rsnvac": 14,
"property_reference": "P9876",
- "unittype_gn": 2,
+ "unittype_gn": 7,
"property_building_type": "dummy",
"beds": 3,
- "property_void_date": "10/10/2020",
- "vday": 10,
- "vmonth": 10,
- "vyear": 2020,
+ "voiddate": "10/10/2020",
"majorrepairs": 1,
"mrcdate": "11/11/2020",
- "mrcday": 11,
- "mrcmonth": 11,
- "mrcyear": 2020,
"offered": 2,
"wchair": 1,
"net_income_known": 1,
"earnings": 150,
- "incfreq": 0,
+ "incfreq": 1,
"benefits": 1,
"hb": 1,
"period": 2,
@@ -95,7 +85,7 @@
"cap": 0,
"hbrentshortfall": 0,
"tshortfall": 12,
- "other_reason_for_leaving_last_settled_home": null,
+ "reasonother": null,
"housingneeds_a": 1,
"housingneeds_b": 0,
"housingneeds_c": 0,
@@ -131,8 +121,6 @@
"propcode": "123",
"postcode": "a1",
"postcod2": "w3",
- "ppostc1": "w3",
- "ppostc2": "w3",
"first_time_property_let_as_social_housing": 0,
"unitletas": 1,
"builtype": 0,
diff --git a/spec/fixtures/exports/case_logs.xml b/spec/fixtures/exports/case_logs.xml
index 6ad128d05..a5dd626af 100644
--- a/spec/fixtures/exports/case_logs.xml
+++ b/spec/fixtures/exports/case_logs.xml
@@ -38,38 +38,36 @@
0
1
0
- 0
- 1
+ 1
+ 2
BZ757
0
5
- 3
- 1
+ 1
SE26RT
- 7
- 2
+ 6
+ 7
3
2
1
68
- 0
+ 1
1
2
2
- 1
+ 1
NW15TY
1
1
1
0
-
+
1
0
0
0
0
0
- 0
0
1
0
@@ -90,7 +88,7 @@
Test
Test
- 2
+
798794
4
123
@@ -99,24 +97,16 @@
E07000105
6
0
- NW1
- 5TY
- SE2
- 6RT
0
2020-05-05 10:36:49 UTC
- 5
- 5
- 2020
- 1
0
2022-02-02 10:36:49 UTC
- 0
+ 1
2
1
- 2019-11-03 00:00:00 UTC
+ 2019-11-03 00:00:00 UTC
{owning_org_id}
{managing_org_id}
2
@@ -125,9 +115,6 @@
1
1
false
- 2
- 2
- 2022
0
0
2
@@ -161,9 +148,6 @@
6.0
0
1
- 3
- 11
- 2019
2
P
@@ -174,6 +158,9 @@
+
+
+
1
diff --git a/spec/fixtures/forms/2021_2022.json b/spec/fixtures/forms/2021_2022.json
index 77649d8c2..74f4b1916 100644
--- a/spec/fixtures/forms/2021_2022.json
+++ b/spec/fixtures/forms/2021_2022.json
@@ -114,21 +114,21 @@
}
}
},
- "household_number_of_other_members": {
+ "household_number_of_members": {
"questions": {
- "other_hhmemb": {
- "check_answer_label": "Number of Other Household Members",
- "header": "How many other people are there in the household?",
- "hint_text": "The maximum number of others is 1",
+ "hhmemb": {
+ "check_answer_label": "Number of Household Members",
+ "header": "How many people are there in the household?",
+ "hint_text": "The maximum number of members is 8",
"type": "numeric",
"min": 0,
- "max": 7,
+ "max": 8,
"step": 1,
"width": 2,
"conditional_for": {
- "relat2": ">0",
- "age2": ">0",
- "sex2": ">0"
+ "relat2": ">1",
+ "age2": ">1",
+ "sex2": ">1"
}
},
"relat2": {
@@ -225,24 +225,24 @@
"type": "radio",
"check_answer_label": "Household links to UK armed forces",
"answer_options": {
- "0": {
+ "1": {
"value": "Yes, the person is a current or former regular"
},
- "1": {
+ "4": {
"value": "Yes, the person is a current or former reserve"
},
- "2": {
+ "5": {
"value": "Yes, the tenant is a spouse or civil partner of a UK armed forces member and has been bereaved or separated from them within the last 2 years"
},
- "3": {
+ "2": {
"value": "No"
},
- "4": {
+ "3": {
"value": "Person prefers not to say"
}
},
"conditional_for": {
- "leftreg": [0]
+ "leftreg": [1]
}
},
"leftreg": {
@@ -260,20 +260,14 @@
"type": "radio",
"check_answer_label": "Physical, mental health or illness in the household",
"answer_options": {
- "0": {
- "value": "Yes"
- },
"1": {
- "value": "No"
- },
- "divider": {
- "value": true
+ "value": "Yes"
},
"2": {
- "value": "Don’t know"
+ "value": "No"
},
"3": {
- "value": "Prefer not to say"
+ "value": "Don’t know"
}
}
}
@@ -463,10 +457,10 @@
"header": "Has the condition been met?",
"type": "radio",
"answer_options": {
- "0": {
+ "1": {
"value": "Yes"
},
- "1": {
+ "2": {
"value": "No"
}
}
@@ -486,7 +480,7 @@
}
}
},
- "depends_on": [{ "preg_occ": 0 }, { "wchair" : 1 }]
+ "depends_on": [{ "preg_occ": 1 }, { "wchair" : 1 }]
},
"conditional_question_no_page": {
"questions": {
@@ -504,7 +498,7 @@
}
}
},
- "depends_on": [{ "preg_occ": 1 }]
+ "depends_on": [{ "preg_occ": 2 }]
},
"conditional_question_no_second_page": {
"questions": {
@@ -522,7 +516,7 @@
}
}
},
- "depends_on": [{ "preg_occ": 1, "sex1": "M" }]
+ "depends_on": [{ "preg_occ": 2, "sex1": "M" }]
}
}
}
@@ -548,9 +542,9 @@
"width": 5,
"prefix": "£",
"suffix": [
- { "label": "every week", "depends_on" : { "incfreq": 0 } },
- { "label": "every month", "depends_on" : { "incfreq": 1 } },
- { "label": "every month", "depends_on" : { "incfreq": 2 } }
+ { "label": "every week", "depends_on" : { "incfreq": 1 } },
+ { "label": "every month", "depends_on" : { "incfreq": 2 } },
+ { "label": "every month", "depends_on" : { "incfreq": 3 } }
]
},
"incfreq": {
@@ -558,13 +552,13 @@
"header": "How often do they receive this income?",
"type": "radio",
"answer_options": {
- "0": {
+ "1": {
"value": "Weekly"
},
- "1": {
+ "2": {
"value": "Monthly"
},
- "2": {
+ "3": {
"value": "Yearly"
}
}
@@ -646,7 +640,7 @@
}
},
"dependent_page": {
- "depends_on": [{ "incfreq": 0 }],
+ "depends_on": [{ "incfreq": 1 }],
"questions": {
"dependent_question": {
"check_answer_label": "Dependent Question",
diff --git a/spec/fixtures/softwire_imports/case_logs/0ead17cb-1668-442d-898c-0d52879ff592.xml b/spec/fixtures/softwire_imports/case_logs/0ead17cb-1668-442d-898c-0d52879ff592.xml
new file mode 100644
index 000000000..34ccc8e12
--- /dev/null
+++ b/spec/fixtures/softwire_imports/case_logs/0ead17cb-1668-442d-898c-0d52879ff592.xml
@@ -0,0 +1,532 @@
+
+
+
+ 2021-CORE-SR-GN
+ 0ead17cb-1668-442d-898c-0d52879ff592
+ c3061a2e6ea0b702e6f6210d5c52d2a92612d2aa
+
+ 7c5bd5fb549c09a2c55d7cb90d7ba84927e64618
+
+ 7c5bd5fb549c09a2c55d7cb90d7ba84927e64618
+
+ 2021-10-08T14:48:17.096123Z
+ 2021-10-08T14:48:17.096123Z
+ submitted-valid
+ 2021
+ Manual Entry
+
+
+
+
+ Yes
+ 2021-09-30
+
+ 1 Private Registered Provider
+
+ <_1btenagree>1 This Landlord
+ <_1bifanother/>
+ <_1bCOREcode/>
+
+
+
+ <_2a>1 Yes
+ 2 Assured
+
+ <_2bTenCode>MAC003
+ <_2cYears/>
+
+
+ 23
+
+ Female
+ 6) Not Seeking Work
+ 1 White: English/Scottish/Welsh/Northern Irish/British
+ 1 UK national resident in UK
+ 2
+
+ Male
+ Child
+ 9) Child under 16
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 2 No
+
+
+ 2 No
+
+
+ 6 UC – with housing element (and not in receipt of Housing
+ Benefit)
+
+
+
+ 1 All
+
+ 600.00
+ 2 Monthly
+
+
+ 12 Property unsuitable because of overcrowding
+
+
+
+ <_9b override-field="">2 No
+
+
+
+
+ Yes
+
+ 2 No
+
+
+
+
+
+
+
+
+
+
+ 30 Fixed term Local Authority General Needs
+ tenancy
+
+ Leeds
+ E08000035
+ LS8 3HX
+
+ 5 5 years or more
+ 2 Less than 1 year
+
+
+ 1 Not homeless
+ 1 Yes
+
+ 2_Living_in_insanitary_or_overcrowded_or_unsatisfactory_housing
+
+
+
+
+
+
+ 1 Yes
+ 2 No
+ 2 No
+
+
+ 3 PRP lettings only - nominated by a local housing authority
+
+
+
+ 4 Calendar monthly
+ 406.09
+ 32.02
+
+
+ 438.11
+ 2 No
+
+ 2021-09-30
+
+ 0
+ MCB003
+
+
+ 2
+ 1 Flat / maisonette
+ 1 Purpose built
+ 2 No
+
+ 15 First let of newbuild property
+
+
+ Leeds
+ E08000035
+ LS16 6FT
+
+
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ <_100>0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ <_70>0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ 1
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 23
+ 2
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 2
+ 23
+ 21
+ 23
+ 2021-10-08Z
+ 2021-10-23Z
+
+
+
+
+
+
+
+
+
+
+
+
+ 0
+ 0
+ 0
+ 0
+ 20
+ 0
+ 20
+ C
+ 1
+ 1
+ 1
+ 1
+ 4
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ 0
+ 0
+ 0
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+
+
+ 21.05
+ 1
+ 2 Existing Tenant
+ 1
+ 1
+ 0
+ 2
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ 5 = 1 adult + 1 or more children
+ 133.33
+ 154.38
+ 7.00
+
+ 154.38
+ 1 Private Registered Provider
+
+
+ E12000003
+ 1034
+ LEEDS & YORKSHIRE HA Ltd
+ LEEDS & YORKSHIRE HA Ltd
+ LH0704
+ LH0704
+
+ 1034
+
+
+
+
+
+
+ 7
+
+
+
+
+
+
+
+
+ 7
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+
+
+ 93.71
+ 101.10
+ 7.39
+
+
+
+
+
+ 93.71
+ 101.10
+ 7.39
+
+
+
+
+ 0
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0.5
+ 0
+ 0
+ 0
+ 0
+ 1
+ 0
+ 0
+ 1
+ 0
+ 2
+ 0
+ 93.71
+ 0
+
+ 68.6
+ 74.7
+ 25
+
+
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 30
+ 9
+ 2021
+ 30
+ 9
+ 2021
+
+
+
+ LS8
+ 3HX
+ LS16
+ 6FT
+
+
diff --git a/spec/fixtures/softwire_imports/case_logs/166fc004-392e-47a8-acb8-1c018734882b.xml b/spec/fixtures/softwire_imports/case_logs/166fc004-392e-47a8-acb8-1c018734882b.xml
new file mode 100644
index 000000000..e119e81ce
--- /dev/null
+++ b/spec/fixtures/softwire_imports/case_logs/166fc004-392e-47a8-acb8-1c018734882b.xml
@@ -0,0 +1,514 @@
+
+
+ 2021-CORE-IR-GN
+ 166fc004-392e-47a8-acb8-1c018734882b
+ e29c492473446dca4d50224f2bb7cf965a261d6f
+ 26139d1be7a44ebb1af23d3f8882c14025e9903c
+ 26139d1be7a44ebb1af23d3f8882c14025e9903c
+ 2022-04-12T14:10:59.953121Z
+ 2022-04-12T14:10:59.953121Z
+ submitted-valid
+ 2021
+ Manual Entry
+
+
+
+
+ Yes
+ 2 London Living Rent
+
+ 2021-11-10
+
+ 1 Private Registered Provider
+
+ <_1btenagree>1 This Landlord
+ <_1bifanother/>
+ <_1bCOREcode/>
+
+
+
+ <_2a>2 No
+ 2 Assured
+
+ <_2bTenCode>TEN0021
+ <_2cYears/>
+
+
+ 37
+
+ Female
+ 1) Full Time
+ 1 White: English/Scottish/Welsh/Northern Irish/British
+ 1 UK national resident in UK
+ 34
+
+ Female
+ Other
+ 1) Full Time
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 2 No
+
+
+ 2 No
+
+
+ 9 Not in receipt of either UC or HB
+
+
+ 3 None
+
+ 200.00
+ 1 Weekly
+
+
+ 8 (Non-violent) relationship breakdown with partner
+
+
+
+ <_9b override-field="">2 No
+
+
+
+
+ Yes
+
+ 1 Yes
+
+
+
+ Yes
+
+
+
+
+
+
+ 28 Living with friends or family
+ Blackpool
+ E09000009
+ FY1 1JD
+
+ 1 Just moved to Local Authority area
+ 1 Just moved to Local Authority area
+
+
+ 1 Not homeless
+ 2 No
+
+
+
+
+
+
+
+ 2 No
+ 2 No
+ 2 No
+
+
+ 10 Other social landlord
+
+
+
+ 1 Weekly for 52 weeks
+ 100.00
+
+
+
+ 100.00
+
+
+ 2021-04-15
+
+ 0
+ PROPREF0042
+
+
+ 2
+ 1 Flat / maisonette
+ 1 Purpose built
+ 2 No
+ 4 An Intermediate Rent basis
+ 10 Relet - tenant evicted due to arrears
+
+
+ Basingstoke & Deane
+ E07000084
+ RG21 3HU
+
+
+ 1
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 2
+ 1
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 2
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ <_100>0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ <_70>0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 2
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ 1
+ 1
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 2
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 37
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 37
+ 0
+ 37
+ 2022-04-12Z
+ 2022-04-27Z
+
+
+
+
+
+
+
+
+
+
+
+
+ 0
+ 0
+ 0
+ 0
+ 20
+ 0
+ 20
+ C
+ 1
+ 1
+ 1
+ 1
+ 4
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+
+
+ 2
+ 2 Existing Tenant
+ 1
+ 1
+ 209
+ 2
+ 1
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 2
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 4 = 2 adults
+ 200.00
+ 200.00
+ 13
+
+ 200.00
+ 1 Private Registered Provider
+
+
+ E12000008
+ 107138
+ 1 Test
+ 1 Test
+ 655
+ 655
+
+ 107138
+
+
+
+
+
+
+
+
+
+
+
+
+ 13
+
+
+ 13
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+
+
+ 100.00
+ 100.00
+
+
+
+ 0.00
+
+
+
+ 100.00
+ 100.00
+
+
+
+ 0
+
+
+ 0
+ 2
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 2
+ 0
+ 100.00
+ 23.35
+
+ 0
+ 0
+ 0
+
+
+ 0
+ 0
+ 23.35
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 10
+ 11
+ 2021
+ 15
+ 4
+ 2021
+
+
+
+ FY1
+ 1JD
+
+
+
+
diff --git a/spec/helpers/check_answers_helper_spec.rb b/spec/helpers/check_answers_helper_spec.rb
index c0642db81..8c7b4e69d 100644
--- a/spec/helpers/check_answers_helper_spec.rb
+++ b/spec/helpers/check_answers_helper_spec.rb
@@ -16,7 +16,7 @@ RSpec.describe CheckAnswersHelper do
context "when a section has been completed" do
it "returns that you have answered all the questions" do
case_log.sex1 = "F"
- case_log.other_hhmemb = 0
+ case_log.hhmemb = 1
case_log.propcode = "123"
case_log.ecstat1 = 200
case_log.ecstat2 = 9
diff --git a/spec/helpers/conditional_questions_helper_spec.rb b/spec/helpers/conditional_questions_helper_spec.rb
index 919984a09..ab3898ea0 100644
--- a/spec/helpers/conditional_questions_helper_spec.rb
+++ b/spec/helpers/conditional_questions_helper_spec.rb
@@ -14,7 +14,7 @@ RSpec.describe ConditionalQuestionsHelper do
describe "find conditional question" do
let(:question) { page.questions.find { |q| q.id == "armedforces" } }
- let(:answer_value) { 0 }
+ let(:answer_value) { 1 }
it "returns the conditional question for a given answer option" do
expect(find_conditional_question(page, question, answer_value).id).to eq("leftreg")
diff --git a/spec/helpers/interuption_screen_helper_spec.rb b/spec/helpers/interuption_screen_helper_spec.rb
index efcf4d1e2..cb2fc3520 100644
--- a/spec/helpers/interuption_screen_helper_spec.rb
+++ b/spec/helpers/interuption_screen_helper_spec.rb
@@ -11,7 +11,7 @@ RSpec.describe InteruptionScreenHelper do
:in_progress,
ecstat1: 1,
earnings: 750,
- incfreq: 0,
+ incfreq: 1,
owning_organisation: user.organisation,
managing_organisation: user.organisation,
)
diff --git a/spec/models/case_log_spec.rb b/spec/models/case_log_spec.rb
index 3f10f92bd..bcf132aa0 100644
--- a/spec/models/case_log_spec.rb
+++ b/spec/models/case_log_spec.rb
@@ -2,7 +2,7 @@ require "rails_helper"
RSpec.describe CaseLog do
let(:owning_organisation) { FactoryBot.create(:organisation) }
- let(:managing_organisation) { owning_organisation }
+ let(:different_managing_organisation) { FactoryBot.create(:organisation) }
describe "#form" do
let(:case_log) { FactoryBot.build(:case_log) }
@@ -33,7 +33,7 @@ RSpec.describe CaseLog do
let(:case_log) do
described_class.create(
owning_organisation:,
- managing_organisation:,
+ managing_organisation: owning_organisation,
)
end
@@ -57,7 +57,7 @@ RSpec.describe CaseLog do
end
it "validates intermediate rent product name" do
- expect(validator).to receive(:validate_intermediate_rent_product_name)
+ expect(validator).to receive(:validate_irproduct_other)
end
it "validates other household member details" do
@@ -175,32 +175,31 @@ RSpec.describe CaseLog do
let(:case_log) { FactoryBot.build(:case_log, earnings: net_income) }
it "returns input income if frequency is already weekly" do
- case_log.incfreq = 0
+ case_log.incfreq = 1
expect(case_log.weekly_net_income).to eq(net_income)
end
it "calculates the correct weekly income from monthly income" do
- case_log.incfreq = 1
+ case_log.incfreq = 2
expect(case_log.weekly_net_income).to eq(1154)
end
it "calculates the correct weekly income from yearly income" do
- case_log.incfreq = 2
+ case_log.incfreq = 3
expect(case_log.weekly_net_income).to eq(417)
end
end
describe "derived variables" do
- let(:organisation) { FactoryBot.create(:organisation, provider_type: "PRP") }
let!(:case_log) do
described_class.create({
- managing_organisation: organisation,
- owning_organisation: organisation,
+ managing_organisation: owning_organisation,
+ owning_organisation:,
postcode_full: "M1 1AE",
ppostcode_full: "M2 2AE",
startdate: Time.gm(2021, 10, 10),
mrcdate: Time.gm(2021, 5, 4),
- property_void_date: Time.gm(2021, 3, 3),
+ voiddate: Time.gm(2021, 3, 3),
net_income_known: 2,
hhmemb: 7,
rent_type: 4,
@@ -210,36 +209,18 @@ RSpec.describe CaseLog do
})
end
- it "correctly derives and saves partial and full postcodes" do
- record_from_db = ActiveRecord::Base.connection.execute("select postcode, postcod2 from case_logs where id=#{case_log.id}").to_a[0]
- expect(record_from_db["postcode"]).to eq("M1")
- expect(record_from_db["postcod2"]).to eq("1AE")
- end
-
- it "correctly derives and saves partial and full previous postcodes" do
- record_from_db = ActiveRecord::Base.connection.execute("select ppostc1, ppostc2 from case_logs where id=#{case_log.id}").to_a[0]
- expect(record_from_db["ppostc1"]).to eq("M2")
- expect(record_from_db["ppostc2"]).to eq("2AE")
- end
-
it "correctly derives and saves partial and full major repairs date" do
- record_from_db = ActiveRecord::Base.connection.execute("select mrcday, mrcmonth, mrcyear, mrcdate from case_logs where id=#{case_log.id}").to_a[0]
+ record_from_db = ActiveRecord::Base.connection.execute("select mrcdate from case_logs where id=#{case_log.id}").to_a[0]
expect(record_from_db["mrcdate"].day).to eq(4)
expect(record_from_db["mrcdate"].month).to eq(5)
expect(record_from_db["mrcdate"].year).to eq(2021)
- expect(record_from_db["mrcday"]).to eq(4)
- expect(record_from_db["mrcmonth"]).to eq(5)
- expect(record_from_db["mrcyear"]).to eq(2021)
end
it "correctly derives and saves partial and full major property void date" do
- record_from_db = ActiveRecord::Base.connection.execute("select vday, vmonth, vyear, property_void_date from case_logs where id=#{case_log.id}").to_a[0]
- expect(record_from_db["property_void_date"].day).to eq(3)
- expect(record_from_db["property_void_date"].month).to eq(3)
- expect(record_from_db["property_void_date"].year).to eq(2021)
- expect(record_from_db["vday"]).to eq(3)
- expect(record_from_db["vmonth"]).to eq(3)
- expect(record_from_db["vyear"]).to eq(2021)
+ record_from_db = ActiveRecord::Base.connection.execute("select voiddate from case_logs where id=#{case_log.id}").to_a[0]
+ expect(record_from_db["voiddate"].day).to eq(3)
+ expect(record_from_db["voiddate"].month).to eq(3)
+ expect(record_from_db["voiddate"].year).to eq(2021)
end
it "correctly derives and saves incref" do
@@ -247,40 +228,19 @@ RSpec.describe CaseLog do
expect(record_from_db["incref"]).to eq(1)
end
- it "correctly derives and saves other_hhmemb" do
- record_from_db = ActiveRecord::Base.connection.execute("select other_hhmemb from case_logs where id=#{case_log.id}").to_a[0]
- expect(record_from_db["other_hhmemb"]).to eq(6)
- end
-
it "correctly derives and saves renttype" do
record_from_db = ActiveRecord::Base.connection.execute("select renttype from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.renttype).to eq(3)
expect(record_from_db["renttype"]).to eq(3)
end
- context "when the owning organisation is a PRP" do
- it "correctly derives and saves landlord based on owning_organisation provider_type" do
- record_from_db = ActiveRecord::Base.connection.execute("select landlord from case_logs where id=#{case_log.id}").to_a[0]
- expect(case_log.landlord).to eq(2)
- expect(record_from_db["landlord"]).to eq(2)
- end
- end
-
- context "when the owning organisation is an LA" do
- let(:organisation) { FactoryBot.create(:organisation) }
-
- it "correctly derives and saves landlord based on owning_organisation provider_type" do
- record_from_db = ActiveRecord::Base.connection.execute("select landlord from case_logs where id=#{case_log.id}").to_a[0]
- expect(case_log.landlord).to eq(1)
- expect(record_from_db["landlord"]).to eq(1)
- end
- end
-
context "when deriving lettype" do
context "when the owning organisation is a PRP" do
+ before { case_log.owning_organisation.update!(provider_type: 2) }
+
context "when the rent type is intermediate rent and supported housing" do
it "correctly derives and saves lettype" do
- case_log.update!(rent_type: 4, needstype: 0)
+ case_log.update!(rent_type: 4, needstype: 2)
record_from_db = ActiveRecord::Base.connection.execute("select lettype from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.lettype).to eq(10)
expect(record_from_db["lettype"]).to eq(10)
@@ -298,7 +258,7 @@ RSpec.describe CaseLog do
context "when the rent type is affordable rent and supported housing" do
it "correctly derives and saves lettype" do
- case_log.update!(rent_type: 2, needstype: 0)
+ case_log.update!(rent_type: 2, needstype: 2)
record_from_db = ActiveRecord::Base.connection.execute("select lettype from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.lettype).to eq(6)
expect(record_from_db["lettype"]).to eq(6)
@@ -316,7 +276,7 @@ RSpec.describe CaseLog do
context "when the rent type is social rent and supported housing" do
it "correctly derives and saves lettype" do
- case_log.update!(rent_type: 0, needstype: 0)
+ case_log.update!(rent_type: 0, needstype: 2)
record_from_db = ActiveRecord::Base.connection.execute("select lettype from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.lettype).to eq(2)
expect(record_from_db["lettype"]).to eq(2)
@@ -357,17 +317,17 @@ RSpec.describe CaseLog do
end
it "correctly derives and saves weekly personal service charge" do
- case_log.update!(pscharge: 70, period: 2)
+ case_log.update!(pscharge: 60, period: 2)
record_from_db = ActiveRecord::Base.connection.execute("select wpschrge from case_logs where id=#{case_log.id}").to_a[0]
- expect(case_log.wpschrge).to eq(35.0)
- expect(record_from_db["wpschrge"]).to eq(35.0)
+ expect(case_log.wpschrge).to eq(30.0)
+ expect(record_from_db["wpschrge"]).to eq(30.0)
end
it "correctly derives and saves weekly support charge" do
- case_log.update!(supcharg: 100, period: 2)
+ case_log.update!(supcharg: 80, period: 2)
record_from_db = ActiveRecord::Base.connection.execute("select wsupchrg from case_logs where id=#{case_log.id}").to_a[0]
- expect(case_log.wsupchrg).to eq(50.0)
- expect(record_from_db["wsupchrg"]).to eq(50.0)
+ expect(case_log.wsupchrg).to eq(40.0)
+ expect(record_from_db["wsupchrg"]).to eq(40.0)
end
it "correctly derives and saves weekly total charge" do
@@ -407,18 +367,18 @@ RSpec.describe CaseLog do
end
it "correctly derives floats" do
- case_log.update!(supcharg: 60.12, pscharge: 60.13, scharge: 60.98, brent: 60.97, period: 2)
+ case_log.update!(supcharg: 60.12, pscharge: 50.13, scharge: 60.98, brent: 60.97, period: 2)
record_from_db = ActiveRecord::Base.connection.execute("select wtcharge, wsupchrg, wpschrge, wscharge, wrent from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wsupchrg).to eq(30.06)
- expect(case_log.wpschrge).to eq(30.06)
+ expect(case_log.wpschrge).to eq(25.06)
expect(case_log.wscharge).to eq(30.49)
expect(case_log.wrent).to eq(30.49)
- expect(case_log.wtcharge).to eq(121.1)
+ expect(case_log.wtcharge).to eq(116.1)
expect(record_from_db["wsupchrg"]).to eq(30.06)
- expect(record_from_db["wpschrge"]).to eq(30.06)
+ expect(record_from_db["wpschrge"]).to eq(25.06)
expect(record_from_db["wscharge"]).to eq(30.49)
expect(record_from_db["wrent"]).to eq(30.49)
- expect(record_from_db["wtcharge"]).to eq(121.1)
+ expect(record_from_db["wtcharge"]).to eq(116.1)
end
end
@@ -1055,28 +1015,28 @@ RSpec.describe CaseLog do
end
it "correctly derives floats" do
- case_log.update!(supcharg: 30.12, pscharge: 30.13, scharge: 30.98, brent: 100.97, period: 1)
+ case_log.update!(supcharg: 30.12, pscharge: 25.13, scharge: 30.98, brent: 100.97, period: 1)
record_from_db = ActiveRecord::Base.connection.execute("select wtcharge, wsupchrg, wpschrge, wscharge, wrent from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wsupchrg).to eq(30.12)
- expect(case_log.wpschrge).to eq(30.13)
+ expect(case_log.wpschrge).to eq(25.13)
expect(case_log.wscharge).to eq(30.98)
expect(case_log.wrent).to eq(100.97)
- expect(case_log.wtcharge).to eq(192.2)
+ expect(case_log.wtcharge).to eq(187.2)
expect(record_from_db["wsupchrg"]).to eq(30.12)
- expect(record_from_db["wpschrge"]).to eq(30.13)
+ expect(record_from_db["wpschrge"]).to eq(25.13)
expect(record_from_db["wscharge"]).to eq(30.98)
expect(record_from_db["wrent"]).to eq(100.97)
- expect(record_from_db["wtcharge"]).to eq(192.2)
+ expect(record_from_db["wtcharge"]).to eq(187.2)
end
end
end
- context "when the owning organisation is an LA" do
- let(:organisation) { FactoryBot.create(:organisation, provider_type: "LA") }
+ context "when the owning organisation is a LA" do
+ before { case_log.owning_organisation.update!(provider_type: "LA") }
context "when the rent type is intermediate rent and supported housing" do
it "correctly derives and saves lettype" do
- case_log.update!(rent_type: 4, needstype: 0)
+ case_log.update!(rent_type: 4, needstype: 2)
record_from_db = ActiveRecord::Base.connection.execute("select lettype from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.lettype).to eq(12)
expect(record_from_db["lettype"]).to eq(12)
@@ -1094,7 +1054,7 @@ RSpec.describe CaseLog do
context "when the rent type is affordable rent and supported housing" do
it "correctly derives and saves lettype" do
- case_log.update!(rent_type: 2, needstype: 0)
+ case_log.update!(rent_type: 2, needstype: 2)
record_from_db = ActiveRecord::Base.connection.execute("select lettype from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.lettype).to eq(8)
expect(record_from_db["lettype"]).to eq(8)
@@ -1112,7 +1072,7 @@ RSpec.describe CaseLog do
context "when the rent type is social rent and supported housing" do
it "correctly derives and saves lettype" do
- case_log.update!(rent_type: 0, needstype: 0)
+ case_log.update!(rent_type: 0, needstype: 2)
record_from_db = ActiveRecord::Base.connection.execute("select lettype from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.lettype).to eq(4)
expect(record_from_db["lettype"]).to eq(4)
@@ -1131,13 +1091,10 @@ RSpec.describe CaseLog do
end
it "correctly derives and saves day, month, year from start date" do
- record_from_db = ActiveRecord::Base.connection.execute("select day, month, year, startdate from case_logs where id=#{case_log.id}").to_a[0]
+ record_from_db = ActiveRecord::Base.connection.execute("select startdate from case_logs where id=#{case_log.id}").to_a[0]
expect(record_from_db["startdate"].day).to eq(10)
expect(record_from_db["startdate"].month).to eq(10)
expect(record_from_db["startdate"].year).to eq(2021)
- expect(record_from_db["day"]).to eq(10)
- expect(record_from_db["month"]).to eq(10)
- expect(record_from_db["year"]).to eq(2021)
end
context "when any charge field is set" do
@@ -1152,14 +1109,16 @@ RSpec.describe CaseLog do
end
end
- def check_postcode_fields(postcode_field, outcode_field, incode_field)
- record_from_db = ActiveRecord::Base.connection.execute("select #{postcode_field}, #{outcode_field}, #{incode_field} from case_logs where id=#{address_case_log.id}").to_a[0]
+ def check_postcode_fields(postcode_field)
+ record_from_db = ActiveRecord::Base.connection.execute("select #{postcode_field} from case_logs where id=#{address_case_log.id}").to_a[0]
+ expect(address_case_log[postcode_field]).to eq("M11AE")
+ expect(record_from_db[postcode_field]).to eq("M11AE")
+ end
+
+ def check_previous_postcode_fields(postcode_field)
+ record_from_db = ActiveRecord::Base.connection.execute("select #{postcode_field} from case_logs where id=#{address_case_log.id}").to_a[0]
expect(address_case_log[postcode_field]).to eq("M11AE")
expect(record_from_db[postcode_field]).to eq("M11AE")
- expect(address_case_log[outcode_field]).to eq("M1")
- expect(record_from_db[outcode_field]).to eq("M1")
- expect(address_case_log[incode_field]).to eq("1AE")
- expect(record_from_db[incode_field]).to eq("1AE")
end
context "when saving addresses" do
before do
@@ -1169,15 +1128,15 @@ RSpec.describe CaseLog do
let!(:address_case_log) do
described_class.create({
- managing_organisation: organisation,
- owning_organisation: organisation,
+ managing_organisation: owning_organisation,
+ owning_organisation:,
postcode_known: 1,
postcode_full: "M1 1AE",
})
end
def check_property_postcode_fields
- check_postcode_fields("postcode_full", "postcode", "postcod2")
+ check_postcode_fields("postcode_full")
end
it "correctly formats previous postcode" do
@@ -1256,29 +1215,29 @@ RSpec.describe CaseLog do
let!(:address_case_log) do
described_class.create({
- managing_organisation: organisation,
- owning_organisation: organisation,
+ managing_organisation: owning_organisation,
+ owning_organisation:,
previous_postcode_known: 1,
ppostcode_full: "M1 1AE",
})
end
- def check_previous_postcode_fields
- check_postcode_fields("ppostcode_full", "ppostc1", "ppostc2")
+ def previous_postcode_fields
+ check_previous_postcode_fields("ppostcode_full")
end
it "correctly formats previous postcode" do
address_case_log.update!(ppostcode_full: "M1 1AE")
- check_previous_postcode_fields
+ previous_postcode_fields
address_case_log.update!(ppostcode_full: "m1 1ae")
- check_previous_postcode_fields
+ previous_postcode_fields
address_case_log.update!(ppostcode_full: "m11Ae")
- check_previous_postcode_fields
+ previous_postcode_fields
address_case_log.update!(ppostcode_full: "m11ae")
- check_previous_postcode_fields
+ previous_postcode_fields
end
it "correctly infers prevloc" do
@@ -1340,8 +1299,8 @@ RSpec.describe CaseLog do
context "when saving rent and charges" do
let!(:case_log) do
described_class.create({
- managing_organisation: organisation,
- owning_organisation: organisation,
+ managing_organisation: owning_organisation,
+ owning_organisation:,
brent: 5.77,
scharge: 10.01,
pscharge: 3,
@@ -1358,9 +1317,9 @@ RSpec.describe CaseLog do
context "when validating household members derived vars" do
let!(:household_case_log) do
described_class.create!({
- managing_organisation: organisation,
- owning_organisation: organisation,
- other_hhmemb: 4,
+ managing_organisation: owning_organisation,
+ owning_organisation:,
+ hhmemb: 3,
relat2: "X",
relat3: "C",
relat4: "X",
@@ -1411,10 +1370,10 @@ RSpec.describe CaseLog do
context "when it is a renewal" do
let!(:case_log) do
described_class.create({
- managing_organisation: organisation,
- owning_organisation: organisation,
+ managing_organisation: owning_organisation,
+ owning_organisation:,
renewal: 1,
- year: 2021,
+ startdate: Time.zone.local(2021, 4, 10),
})
end
@@ -1431,6 +1390,7 @@ RSpec.describe CaseLog do
end
it "correctly derives and saves prevten" do
+ case_log.managing_organisation.update!({ provider_type: "PRP" })
case_log.update!({ needstype: 1 })
record_from_db = ActiveRecord::Base.connection.execute("select prevten from case_logs where id=#{case_log.id}").to_a[0]
@@ -1455,8 +1415,8 @@ RSpec.describe CaseLog do
context "when answering the household characteristics questions" do
let!(:case_log) do
described_class.create({
- managing_organisation: organisation,
- owning_organisation: organisation,
+ managing_organisation: owning_organisation,
+ owning_organisation:,
age1_known: 1,
sex1: "R",
relat2: "R",
@@ -1474,8 +1434,8 @@ RSpec.describe CaseLog do
context "when the data provider is filling in household needs" do
let!(:case_log) do
described_class.create({
- managing_organisation: organisation,
- owning_organisation: organisation,
+ managing_organisation: owning_organisation,
+ owning_organisation:,
})
end
@@ -1501,9 +1461,9 @@ RSpec.describe CaseLog do
context "when it is supported housing and a care home charge has been supplied" do
let!(:case_log) do
described_class.create({
- managing_organisation: organisation,
- owning_organisation: organisation,
- needstype: 0,
+ managing_organisation: owning_organisation,
+ owning_organisation:,
+ needstype: 2,
})
end
@@ -1655,16 +1615,16 @@ RSpec.describe CaseLog do
context "when the data provider is filling in the reason for the property being vacant" do
let!(:first_let_case_log) do
described_class.create({
- managing_organisation: organisation,
- owning_organisation: organisation,
+ managing_organisation: owning_organisation,
+ owning_organisation:,
first_time_property_let_as_social_housing: 1,
})
end
let!(:relet_case_log) do
described_class.create({
- managing_organisation: organisation,
- owning_organisation: organisation,
+ managing_organisation: owning_organisation,
+ owning_organisation:,
first_time_property_let_as_social_housing: 0,
})
end
@@ -1687,7 +1647,7 @@ RSpec.describe CaseLog do
describe "resetting invalidated fields" do
context "when a question that has already been answered, no longer has met dependencies" do
- let(:case_log) { FactoryBot.create(:case_log, :in_progress, cbl: 1, preg_occ: 1, wchair: 1) }
+ let(:case_log) { FactoryBot.create(:case_log, :in_progress, cbl: 1, preg_occ: 2, wchair: 1) }
it "clears the answer" do
expect { case_log.update!(preg_occ: nil) }.to change(case_log, :cbl).from(1).to(nil)
@@ -1703,7 +1663,7 @@ RSpec.describe CaseLog do
end
context "with two pages having the same question key, only one's dependency is met" do
- let(:case_log) { FactoryBot.create(:case_log, :in_progress, cbl: 0, preg_occ: 1, wchair: 1) }
+ let(:case_log) { FactoryBot.create(:case_log, :in_progress, cbl: 0, preg_occ: 2, wchair: 1) }
it "does not clear the value for answers that apply to both pages" do
expect(case_log.cbl).to eq(0)
@@ -1712,7 +1672,7 @@ RSpec.describe CaseLog do
it "does clear the value for answers that do not apply for invalidated page" do
case_log.update!({ wchair: 1, sex2: "F", age2: 33 })
case_log.update!({ cbl: 1 })
- case_log.update!({ preg_occ: 0 })
+ case_log.update!({ preg_occ: 1 })
expect(case_log.cbl).to eq(nil)
end
diff --git a/spec/models/form/page_spec.rb b/spec/models/form/page_spec.rb
index a09fcace6..57c9393b3 100644
--- a/spec/models/form/page_spec.rb
+++ b/spec/models/form/page_spec.rb
@@ -56,7 +56,7 @@ RSpec.describe Form::Page, type: :model do
end
it "evaluates met conditions correctly" do
- case_log.incfreq = "Weekly"
+ case_log.incfreq = 1
expect(page.routed_to?(case_log)).to be true
end
end
diff --git a/spec/models/form/question_spec.rb b/spec/models/form/question_spec.rb
index 227e99126..094351870 100644
--- a/spec/models/form/question_spec.rb
+++ b/spec/models/form/question_spec.rb
@@ -75,16 +75,16 @@ RSpec.describe Form::Question, type: :model do
let(:question_id) { "incfreq" }
it "has answer options" do
- expected_answer_options = { "0" => { "value" => "Weekly" }, "1" => { "value" => "Monthly" }, "2" => { "value" => "Yearly" } }
+ expected_answer_options = { "1" => { "value" => "Weekly" }, "2" => { "value" => "Monthly" }, "3" => { "value" => "Yearly" } }
expect(question.answer_options).to eq(expected_answer_options)
end
it "can map value from label" do
- expect(question.value_from_label("Monthly")).to eq("1")
+ expect(question.value_from_label("Monthly")).to eq("2")
end
it "can map label from value" do
- expect(question.label_from_value(2)).to eq("Yearly")
+ expect(question.label_from_value(3)).to eq("Yearly")
end
context "when answer options include yes, no, prefer not to say" do
@@ -94,11 +94,11 @@ RSpec.describe Form::Question, type: :model do
let(:question_id) { "illness" }
it "maps those options" do
- expect(question).to be_value_is_yes(0)
- expect(question).not_to be_value_is_no(0)
- expect(question).not_to be_value_is_refused(0)
- expect(question).to be_value_is_no(1)
- expect(question).to be_value_is_refused(2)
+ expect(question).to be_value_is_yes(1)
+ expect(question).not_to be_value_is_no(1)
+ expect(question).not_to be_value_is_refused(1)
+ expect(question).to be_value_is_no(2)
+ expect(question).to be_value_is_dont_know(3)
end
end
@@ -221,7 +221,7 @@ RSpec.describe Form::Question, type: :model do
let(:question_id) { "incfreq" }
it "has an answer label" do
- case_log.incfreq = 0
+ case_log.incfreq = 1
expect(question.answer_label(case_log)).to eq("Weekly")
end
@@ -321,12 +321,12 @@ RSpec.describe Form::Question, type: :model do
let(:question_id) { "earnings" }
it "displays the correct label for given suffix and answer the suffix depends on" do
- case_log.incfreq = 0
+ case_log.incfreq = 1
case_log.earnings = 500
expect(question.answer_label(case_log)).to eq("£500.00 every week")
- case_log.incfreq = 1
- expect(question.answer_label(case_log)).to eq("£500.00 every month")
case_log.incfreq = 2
+ expect(question.answer_label(case_log)).to eq("£500.00 every month")
+ case_log.incfreq = 3
expect(question.answer_label(case_log)).to eq("£500.00 every year")
end
end
diff --git a/spec/models/form/subsection_spec.rb b/spec/models/form/subsection_spec.rb
index cb0bed8a2..a9c573816 100644
--- a/spec/models/form/subsection_spec.rb
+++ b/spec/models/form/subsection_spec.rb
@@ -25,12 +25,12 @@ RSpec.describe Form::Subsection, type: :model do
end
it "has pages" do
- expected_pages = %w[tenant_code person_1_age person_1_gender person_1_working_situation household_number_of_other_members person_2_working_situation propcode]
+ expected_pages = %w[tenant_code person_1_age person_1_gender person_1_working_situation household_number_of_members person_2_working_situation propcode]
expect(subsection.pages.map(&:id)).to eq(expected_pages)
end
it "has questions" do
- expected_questions = %w[tenant_code age1 sex1 ecstat1 other_hhmemb relat2 age2 sex2 ecstat2 propcode]
+ expected_questions = %w[tenant_code age1 sex1 ecstat1 hhmemb relat2 age2 sex2 ecstat2 propcode]
expect(subsection.questions.map(&:id)).to eq(expected_questions)
end
@@ -73,7 +73,7 @@ RSpec.describe Form::Subsection, type: :model do
end
it "has question helpers for the number of applicable questions" do
- expected_questions = %w[tenant_code age1 sex1 ecstat1 other_hhmemb ecstat2 propcode]
+ expected_questions = %w[tenant_code age1 sex1 ecstat1 hhmemb ecstat2 propcode]
expect(subsection.applicable_questions(case_log).map(&:id)).to eq(expected_questions)
expect(subsection.applicable_questions_count(case_log)).to eq(7)
end
@@ -94,7 +94,7 @@ RSpec.describe Form::Subsection, type: :model do
end
it "has a question helpers for the unanswered questions" do
- expected_questions = %w[sex1 ecstat1 other_hhmemb ecstat2 propcode]
+ expected_questions = %w[sex1 ecstat1 hhmemb ecstat2 propcode]
expect(subsection.unanswered_questions(case_log).map(&:id)).to eq(expected_questions)
end
end
diff --git a/spec/models/form_spec.rb b/spec/models/form_spec.rb
index d9c8b5ee9..9bc9369db 100644
--- a/spec/models/form_spec.rb
+++ b/spec/models/form_spec.rb
@@ -16,7 +16,7 @@ RSpec.describe Form, type: :model do
context "when the current page is a value check page" do
before do
- case_log.incfreq = 0
+ case_log.incfreq = 1
case_log.earnings = 140
case_log.ecstat1 = 1
end
@@ -39,7 +39,7 @@ RSpec.describe Form, type: :model do
let!(:page_ids) { subsection.pages.map(&:id) }
before do
- case_log.preg_occ = 1
+ case_log.preg_occ = 2
end
it "returns the previous page if the page is routed to" do
@@ -68,7 +68,7 @@ RSpec.describe Form, type: :model do
end
it "returns a correct page path if there is conditional routing" do
- case_log["preg_occ"] = 1
+ case_log["preg_occ"] = 2
expect(form.next_page_redirect_path(previous_conditional_page, case_log)).to eq("case_log_conditional_question_no_page_path")
end
end
@@ -102,7 +102,7 @@ RSpec.describe Form, type: :model do
def answer_income_and_benefits(case_log)
case_log.earnings = 30_000
- case_log.incfreq = "Yearly"
+ case_log.incfreq = 3
case_log.benefits = "Some"
case_log.hb = "Tenant prefers not to say"
end
@@ -118,7 +118,7 @@ RSpec.describe Form, type: :model do
def answer_local_authority(case_log)
case_log.layear = "1 year but under 2 years"
- case_log.lawaitlist = "Less than 1 year"
+ case_log.waityear = "Less than 1 year"
case_log.postcode_full = "NW1 5TY"
case_log.reason = "Permanently decanted from another property owned by this landlord"
case_log.ppostcode_full = "SE2 6RT"
@@ -130,7 +130,7 @@ RSpec.describe Form, type: :model do
case_log.age1 = 35
case_log.sex1 = "M"
case_log.ecstat1 = 0
- case_log.other_hhmemb = 1
+ case_log.hhmemb = 2
case_log.relat2 = "P"
case_log.sex2 = "F"
case_log.ecstat2 = 1
diff --git a/spec/models/validations/date_validations_spec.rb b/spec/models/validations/date_validations_spec.rb
index 9ab24f747..9cf8e1d8d 100644
--- a/spec/models/validations/date_validations_spec.rb
+++ b/spec/models/validations/date_validations_spec.rb
@@ -102,48 +102,48 @@ RSpec.describe Validations::DateValidations do
describe "property void date" do
it "cannot be after the tenancy start date" do
record.startdate = Time.zone.local(2022, 1, 1)
- record.property_void_date = Time.zone.local(2022, 2, 1)
+ record.voiddate = Time.zone.local(2022, 2, 1)
date_validator.validate_property_void_date(record)
- expect(record.errors["property_void_date"])
+ expect(record.errors["voiddate"])
.to include(match I18n.t("validations.property.void_date.before_tenancy_start"))
end
it "must be before the tenancy start date" do
record.startdate = Time.zone.local(2022, 2, 1)
- record.property_void_date = Time.zone.local(2022, 1, 1)
+ record.voiddate = Time.zone.local(2022, 1, 1)
date_validator.validate_property_void_date(record)
- expect(record.errors["property_void_date"]).to be_empty
+ expect(record.errors["voiddate"]).to be_empty
end
it "cannot be more than 10 years before the tenancy start date" do
record.startdate = Time.zone.local(2022, 2, 1)
- record.property_void_date = Time.zone.local(2012, 1, 1)
+ record.voiddate = Time.zone.local(2012, 1, 1)
date_validator.validate_property_void_date(record)
- expect(record.errors["property_void_date"])
+ expect(record.errors["voiddate"])
.to include(match I18n.t("validations.property.void_date.ten_years_before_tenancy_start"))
end
it "must be within 10 years of the tenancy start date" do
record.startdate = Time.zone.local(2022, 2, 1)
- record.property_void_date = Time.zone.local(2012, 3, 1)
+ record.voiddate = Time.zone.local(2012, 3, 1)
date_validator.validate_property_void_date(record)
- expect(record.errors["property_void_date"]).to be_empty
+ expect(record.errors["voiddate"]).to be_empty
end
context "when major repairs have been carried out" do
it "cannot be after major repairs date" do
record.mrcdate = Time.zone.local(2022, 1, 1)
- record.property_void_date = Time.zone.local(2022, 2, 1)
+ record.voiddate = Time.zone.local(2022, 2, 1)
date_validator.validate_property_void_date(record)
- expect(record.errors["property_void_date"])
+ expect(record.errors["voiddate"])
.to include(match I18n.t("validations.property.void_date.after_mrcdate"))
end
it "must be before major repairs date" do
record.mrcdate = Time.zone.local(2022, 2, 1)
- record.property_void_date = Time.zone.local(2022, 1, 1)
+ record.voiddate = Time.zone.local(2022, 1, 1)
date_validator.validate_property_void_date(record)
- expect(record.errors["property_void_date"]).to be_empty
+ expect(record.errors["voiddate"]).to be_empty
end
end
end
diff --git a/spec/models/validations/financial_validations_spec.rb b/spec/models/validations/financial_validations_spec.rb
index 7582190a3..68b5f4629 100644
--- a/spec/models/validations/financial_validations_spec.rb
+++ b/spec/models/validations/financial_validations_spec.rb
@@ -17,7 +17,7 @@ RSpec.describe Validations::FinancialValidations do
it "when income frequency is provided it validates that earnings must be provided" do
record.earnings = nil
- record.incfreq = 0
+ record.incfreq = 1
financial_validator.validate_net_income(record)
expect(record.errors["earnings"])
.to include(match I18n.t("validations.financial.earnings.earnings_missing"))
@@ -124,7 +124,7 @@ RSpec.describe Validations::FinancialValidations do
describe "Net income validations" do
it "validates that the net income is within the expected range for the tenant's employment status" do
record.earnings = 200
- record.incfreq = 0
+ record.incfreq = 1
record.ecstat1 = 1
financial_validator.validate_net_income(record)
expect(record.errors["earnings"]).to be_empty
@@ -133,7 +133,7 @@ RSpec.describe Validations::FinancialValidations do
context "when the net income is higher than the hard max for their employment status" do
it "adds an error" do
record.earnings = 5000
- record.incfreq = 0
+ record.incfreq = 1
record.ecstat1 = 1
financial_validator.validate_net_income(record)
expect(record.errors["earnings"])
@@ -144,7 +144,7 @@ RSpec.describe Validations::FinancialValidations do
context "when the net income is lower than the hard min for their employment status" do
it "adds an error" do
record.earnings = 50
- record.incfreq = 0
+ record.incfreq = 1
record.ecstat1 = 1
financial_validator.validate_net_income(record)
expect(record.errors["earnings"])
@@ -201,12 +201,11 @@ RSpec.describe Validations::FinancialValidations do
end
end
- context "when the landlord is this landlord" do
+ context "when the owning organisation is a private registered provider" do
+ before { record.owning_organisation.provider_type = 2 }
+
context "when needstype is general needs" do
- before do
- record.needstype = 1
- record.landlord = 1
- end
+ before { record.needstype = 1 }
[{
period: { label: "weekly", value: 1 },
@@ -249,7 +248,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.#{test_case[:charge][:field]}.this_landlord.general_needs"))
+ .to include(match I18n.t("validations.financial.rent.#{test_case[:charge][:field]}.private_registered_provider.general_needs"))
end
end
@@ -300,10 +299,7 @@ RSpec.describe Validations::FinancialValidations do
end
context "when needstype is supported housing" do
- before do
- record.needstype = 0
- record.landlord = 1
- end
+ before { record.needstype = 2 }
[{
period: { label: "weekly", value: 1 },
@@ -346,7 +342,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.#{test_case[:charge][:field]}.this_landlord.supported_housing"))
+ .to include(match I18n.t("validations.financial.rent.#{test_case[:charge][:field]}.private_registered_provider.supported_housing"))
end
end
@@ -397,12 +393,11 @@ RSpec.describe Validations::FinancialValidations do
end
end
- context "when the landlord is another RP" do
+ context "when the owning organisation is a local authority" do
+ before { record.owning_organisation.provider_type = 1 }
+
context "when needstype is general needs" do
- before do
- record.needstype = 1
- record.landlord = 2
- end
+ before { record.needstype = 1 }
[{
period: { label: "weekly", value: 1 },
@@ -445,7 +440,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.#{test_case[:charge][:field]}.other_landlord.general_needs"))
+ .to include(match I18n.t("validations.financial.rent.#{test_case[:charge][:field]}.local_authority.general_needs"))
end
end
@@ -496,10 +491,7 @@ RSpec.describe Validations::FinancialValidations do
end
context "when needstype is supported housing" do
- before do
- record.needstype = 0
- record.landlord = 2
- end
+ before { record.needstype = 2 }
[{
period: { label: "weekly", value: 1 },
@@ -542,7 +534,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.#{test_case[:charge][:field]}.other_landlord.supported_housing"))
+ .to include(match I18n.t("validations.financial.rent.#{test_case[:charge][:field]}.local_authority.supported_housing"))
end
end
@@ -757,7 +749,6 @@ RSpec.describe Validations::FinancialValidations do
record.period = 1
record.la = "E07000223"
record.beds = 1
- record.year = 2021
record.startdate = Time.zone.local(2021, 9, 17)
record.brent = 9.17
@@ -772,7 +763,6 @@ RSpec.describe Validations::FinancialValidations do
record.la = "E07000223"
record.beds = 1
record.startdate = Time.zone.local(2021, 9, 17)
- record.year = 2021
record.brent = 200
financial_validator.validate_rent_amount(record)
@@ -794,9 +784,6 @@ RSpec.describe Validations::FinancialValidations do
record.la = "E07000223"
record.startdate = Time.zone.local(2022, 2, 5)
record.beds = 1
- record.year = 2022
- record.month = 2
- record.day = 5
record.brent = 200
financial_validator.validate_rent_amount(record)
@@ -814,7 +801,6 @@ RSpec.describe Validations::FinancialValidations do
it "does not error if some of the fields are missing" do
record.managing_organisation.provider_type = 2
- record.year = 2021
record.startdate = Time.zone.local(2021, 9, 17)
record.brent = 200
diff --git a/spec/models/validations/household_validations_spec.rb b/spec/models/validations/household_validations_spec.rb
index 36edd3f12..6fdf72dc9 100644
--- a/spec/models/validations/household_validations_spec.rb
+++ b/spec/models/validations/household_validations_spec.rb
@@ -58,7 +58,7 @@ RSpec.describe Validations::HouseholdValidations do
describe "pregnancy validations" do
context "when there are no female tenants" do
it "validates that pregnancy cannot be yes" do
- record.preg_occ = 0
+ record.preg_occ = 1
record.sex1 = "M"
household_validator.validate_pregnancy(record)
expect(record.errors["preg_occ"])
@@ -66,7 +66,7 @@ RSpec.describe Validations::HouseholdValidations do
end
it "validates that pregnancy cannot be prefer not to say" do
- record.preg_occ = 2
+ record.preg_occ = 3
record.sex1 = "M"
household_validator.validate_pregnancy(record)
expect(record.errors["preg_occ"])
@@ -77,7 +77,7 @@ RSpec.describe Validations::HouseholdValidations do
context "when there are female tenants" do
context "but they are older than 50" do
it "validates that pregnancy cannot be yes" do
- record.preg_occ = 0
+ record.preg_occ = 1
record.sex1 = "F"
record.age1 = 51
household_validator.validate_pregnancy(record)
@@ -113,7 +113,7 @@ RSpec.describe Validations::HouseholdValidations do
describe "reason for leaving last settled home validations" do
let(:field) { "validations.other_field_not_required" }
let(:main_field_label) { "reason" }
- let(:other_field_label) { "other reason for leaving last settled home" }
+ let(:other_field_label) { "reasonother" }
let(:expected_error) { I18n.t(field, main_field_label:, other_field_label:) }
context "when reason is other" do
@@ -121,34 +121,34 @@ RSpec.describe Validations::HouseholdValidations do
it "validates that a reason is provided" do
record.reason = 31
- record.other_reason_for_leaving_last_settled_home = nil
+ record.reasonother = nil
household_validator.validate_reason_for_leaving_last_settled_home(record)
- expect(record.errors["other_reason_for_leaving_last_settled_home"])
+ expect(record.errors["reasonother"])
.to include(match(expected_error))
end
it "expects that a reason is provided" do
record.reason = 31
- record.other_reason_for_leaving_last_settled_home = "Some unusual reason"
+ record.reasonother = "Some unusual reason"
household_validator.validate_reason_for_leaving_last_settled_home(record)
- expect(record.errors["other_reason_for_leaving_last_settled_home"]).to be_empty
+ expect(record.errors["reasonother"]).to be_empty
end
end
context "when reason is not other" do
it "validates that other reason is not provided" do
record.reason = 18
- record.other_reason_for_leaving_last_settled_home = "Some other reason"
+ record.reasonother = "Some other reason"
household_validator.validate_reason_for_leaving_last_settled_home(record)
- expect(record.errors["other_reason_for_leaving_last_settled_home"])
+ expect(record.errors["reasonother"])
.to include(match(expected_error))
end
it "expects that other reason is not provided" do
record.reason = 18
- record.other_reason_for_leaving_last_settled_home = nil
+ record.reasonother = nil
household_validator.validate_reason_for_leaving_last_settled_home(record)
- expect(record.errors["other_reason_for_leaving_last_settled_home"]).to be_empty
+ expect(record.errors["reasonother"]).to be_empty
end
end
@@ -197,8 +197,8 @@ RSpec.describe Validations::HouseholdValidations do
.to be_empty
end
- it "cannot have `this landlord` as landlord and Housing situation before this letting cannot be LA general needs" do
- record.landlord = 1
+ it "cannot have a PRP as landlord and Housing situation before this letting cannot be LA general needs" do
+ record.owning_organisation.provider_type = "PRP"
record.prevten = 30
record.referral = 1
household_validator.validate_referral(record)
@@ -217,17 +217,17 @@ RSpec.describe Validations::HouseholdValidations do
end
context "when referral is nominated by a local housing authority" do
- it "cannot have `other landlord`" do
- record.landlord = 2
+ it "cannot have a local authority" do
+ record.owning_organisation.provider_type = "LA"
record.referral = 3
household_validator.validate_referral(record)
expect(record.errors["referral"])
.to include(match(I18n.t("validations.household.referral.prp.local_housing_referral")))
end
- it "can have `this landlord`" do
+ it "can have a private registered provider" do
+ record.owning_organisation.provider_type = "PRP"
record.referral = 3
- record.landlord = 1
household_validator.validate_referral(record)
expect(record.errors["referral"])
.to be_empty
@@ -238,7 +238,7 @@ RSpec.describe Validations::HouseholdValidations do
describe "armed forces validations" do
context "when the tenant or partner was and is not a member of the armed forces" do
it "validates that injured in the armed forces is not yes" do
- record.armedforces = 3
+ record.armedforces = 2
record.reservist = 0
household_validator.validate_armed_forces(record)
expect(record.errors["reservist"])
@@ -248,7 +248,7 @@ RSpec.describe Validations::HouseholdValidations do
context "when the tenant prefers not to say if they were or are in the armed forces" do
it "validates that injured in the armed forces is not yes" do
- record.armedforces = 4
+ record.armedforces = 3
record.reservist = 0
household_validator.validate_armed_forces(record)
expect(record.errors["reservist"])
@@ -276,7 +276,7 @@ RSpec.describe Validations::HouseholdValidations do
context "when the tenant's partner was or is a member of the armed forces" do
it "expects that injured in the armed forces can be yes" do
- record.armedforces = 2
+ record.armedforces = 5
record.reservist = 0
household_validator.validate_armed_forces(record)
expect(record.errors["reservist"]).to be_empty
@@ -285,7 +285,7 @@ RSpec.describe Validations::HouseholdValidations do
context "when the tenant or partner has left the armed forces" do
it "validates that they served in the armed forces" do
- record.armedforces = 3
+ record.armedforces = 2
record.leftreg = 0
household_validator.validate_armed_forces(record)
expect(record.errors["leftreg"])
@@ -293,14 +293,14 @@ RSpec.describe Validations::HouseholdValidations do
end
it "expects that they served in the armed forces" do
- record.armedforces = 0
+ record.armedforces = 1
record.leftreg = 0
household_validator.validate_armed_forces(record)
expect(record.errors["leftreg"]).to be_empty
end
it "expects that they served in the armed forces and may have been injured" do
- record.armedforces = 0
+ record.armedforces = 1
record.leftreg = 0
record.reservist = 0
household_validator.validate_armed_forces(record)
@@ -462,24 +462,24 @@ RSpec.describe Validations::HouseholdValidations do
expect(record.errors["age2"]).to be_empty
end
- it "validates that the number of other household members cannot be less than 0" do
- record.other_hhmemb = -1
+ it "validates that the number of household members cannot be less than 0" do
+ record.hhmemb = -1
household_validator.validate_numeric_min_max(record)
- expect(record.errors["other_hhmemb"])
- .to include(match I18n.t("validations.numeric.valid", field: "Number of Other Household Members", min: 0, max: 7))
+ expect(record.errors["hhmemb"])
+ .to include(match I18n.t("validations.numeric.valid", field: "Number of Household Members", min: 0, max: 8))
end
- it "validates that the number of other household members cannot be more than 7" do
- record.other_hhmemb = 8
+ it "validates that the number of household members cannot be more than 8" do
+ record.hhmemb = 9
household_validator.validate_numeric_min_max(record)
- expect(record.errors["other_hhmemb"])
- .to include(match I18n.t("validations.numeric.valid", field: "Number of Other Household Members", min: 0, max: 7))
+ expect(record.errors["hhmemb"])
+ .to include(match I18n.t("validations.numeric.valid", field: "Number of Household Members", min: 0, max: 8))
end
it "expects that the number of other household members is between the min and max" do
- record.other_hhmemb = 5
+ record.hhmemb = 5
household_validator.validate_numeric_min_max(record)
- expect(record.errors["other_hhmemb"]).to be_empty
+ expect(record.errors["hhmemb"]).to be_empty
end
end
@@ -512,7 +512,7 @@ RSpec.describe Validations::HouseholdValidations do
describe "condition effects validation" do
it "validates vision can't be selected if answer to anyone in household with health condition is not yes" do
- record.illness = 1
+ record.illness = 2
record.illness_type_1 = 1
household_validator.validate_condition_effects(record)
expect(record.errors["condition_effects"])
@@ -520,7 +520,7 @@ RSpec.describe Validations::HouseholdValidations do
end
it "validates hearing can't be selected if answer to anyone in household with health condition is not yes" do
- record.illness = 1
+ record.illness = 2
record.illness_type_2 = 1
household_validator.validate_condition_effects(record)
expect(record.errors["condition_effects"])
@@ -528,7 +528,7 @@ RSpec.describe Validations::HouseholdValidations do
end
it "validates mobility can't be selected if answer to anyone in household with health condition is not yes" do
- record.illness = 1
+ record.illness = 2
record.illness_type_3 = 1
household_validator.validate_condition_effects(record)
expect(record.errors["condition_effects"])
@@ -536,7 +536,7 @@ RSpec.describe Validations::HouseholdValidations do
end
it "validates dexterity can't be selected if answer to anyone in household with health condition is not yes" do
- record.illness = 1
+ record.illness = 2
record.illness_type_4 = 1
household_validator.validate_condition_effects(record)
expect(record.errors["condition_effects"])
@@ -544,7 +544,7 @@ RSpec.describe Validations::HouseholdValidations do
end
it "validates learning or understanding or concentrating can't be selected if answer to anyone in household with health condition is not yes" do
- record.illness = 1
+ record.illness = 2
record.illness_type_5 = 1
household_validator.validate_condition_effects(record)
expect(record.errors["condition_effects"])
@@ -552,7 +552,7 @@ RSpec.describe Validations::HouseholdValidations do
end
it "validates memory can't be selected if answer to anyone in household with health condition is not yes" do
- record.illness = 1
+ record.illness = 2
record.illness_type_6 = 1
household_validator.validate_condition_effects(record)
expect(record.errors["condition_effects"])
@@ -560,7 +560,7 @@ RSpec.describe Validations::HouseholdValidations do
end
it "validates mental health can't be selected if answer to anyone in household with health condition is not yes" do
- record.illness = 1
+ record.illness = 2
record.illness_type_7 = 1
household_validator.validate_condition_effects(record)
expect(record.errors["condition_effects"])
@@ -568,7 +568,7 @@ RSpec.describe Validations::HouseholdValidations do
end
it "validates stamina or breathing or fatigue can't be selected if answer to anyone in household with health condition is not yes" do
- record.illness = 1
+ record.illness = 2
record.illness_type_8 = 1
household_validator.validate_condition_effects(record)
expect(record.errors["condition_effects"])
@@ -576,7 +576,7 @@ RSpec.describe Validations::HouseholdValidations do
end
it "validates socially or behaviourally can't be selected if answer to anyone in household with health condition is not yes" do
- record.illness = 1
+ record.illness = 2
record.illness_type_9 = 1
household_validator.validate_condition_effects(record)
expect(record.errors["condition_effects"])
@@ -584,7 +584,7 @@ RSpec.describe Validations::HouseholdValidations do
end
it "validates other can't be selected if answer to anyone in household with health condition is not yes" do
- record.illness = 1
+ record.illness = 2
record.illness_type_10 = 1
household_validator.validate_condition_effects(record)
expect(record.errors["condition_effects"])
@@ -592,7 +592,7 @@ RSpec.describe Validations::HouseholdValidations do
end
it "expects that an illness can be selected if answer to anyone in household with health condition is yes " do
- record.illness = 0
+ record.illness = 1
record.illness_type_1 = 1
record.illness_type_2 = 1
record.illness_type_3 = 1
@@ -654,6 +654,7 @@ RSpec.describe Validations::HouseholdValidations do
end
it "can be non internal transfer" do
+ record.owning_organisation.provider_type = "PRP"
record.homeless = 0
record.referral = 3
household_validator.validate_referral(record)
@@ -674,6 +675,7 @@ RSpec.describe Validations::HouseholdValidations do
end
it "can be non internal transfer" do
+ record.owning_organisation.provider_type = "PRP"
record.referral = 3
record.homeless = 1
household_validator.validate_referral(record)
@@ -697,7 +699,7 @@ RSpec.describe Validations::HouseholdValidations do
describe "previous housing situation validations" do
context "when the property is being relet to a previously temporary tenant" do
it "validates that previous tenancy was temporary" do
- record.rsnvac = 2
+ record.rsnvac = 9
record.prevten = 4
household_validator.validate_previous_housing_situation(record)
expect(record.errors["prevten"])
diff --git a/spec/models/validations/property_validations_spec.rb b/spec/models/validations/property_validations_spec.rb
index 5dd339984..08052ee7e 100644
--- a/spec/models/validations/property_validations_spec.rb
+++ b/spec/models/validations/property_validations_spec.rb
@@ -43,7 +43,7 @@ RSpec.describe Validations::PropertyValidations do
context "when number of bedrooms has not been answered" do
it "does not add an error" do
record.beds = nil
- record.unittype_gn = 1
+ record.unittype_gn = 2
property_validator.validate_shared_housing_rooms(record)
expect(record.errors).to be_empty
end
@@ -52,7 +52,7 @@ RSpec.describe Validations::PropertyValidations do
context "when unit type is shared and number of bedrooms has not been answered" do
it "does not add an error" do
record.beds = nil
- record.unittype_gn = 6
+ record.unittype_gn = 10
property_validator.validate_shared_housing_rooms(record)
expect(record.errors).to be_empty
end
@@ -72,7 +72,7 @@ RSpec.describe Validations::PropertyValidations do
it "adds an error" do
record.beds = 2
- record.unittype_gn = 1
+ record.unittype_gn = 2
property_validator.validate_shared_housing_rooms(record)
expect(record.errors["unittype_gn"]).to include(match(expected_error))
expect(record.errors["beds"]).to include(I18n.t("validations.property.unittype_gn.one_bedroom_bedsit"))
@@ -84,7 +84,7 @@ RSpec.describe Validations::PropertyValidations do
it "adds an error" do
record.beds = 0
- record.unittype_gn = 1
+ record.unittype_gn = 2
property_validator.validate_shared_housing_rooms(record)
expect(record.errors["unittype_gn"]).to include(match(expected_error))
expect(record.errors["beds"]).to include(I18n.t("validations.property.unittype_gn.one_bedroom_bedsit"))
@@ -96,8 +96,8 @@ RSpec.describe Validations::PropertyValidations do
it "adds an error if the number of bedrooms is not between 1 and 7" do
record.beds = 8
- record.unittype_gn = 5
- record.other_hhmemb = 2
+ record.unittype_gn = 9
+ record.hhmemb = 3
property_validator.validate_shared_housing_rooms(record)
expect(record.errors["unittype_gn"]).to include(match(expected_error))
expect(record.errors["beds"]).to include(I18n.t("validations.property.unittype_gn.one_seven_bedroom_shared"))
@@ -109,8 +109,8 @@ RSpec.describe Validations::PropertyValidations do
it "adds an error if the number of bedrooms is not between 1 and 7" do
record.beds = 0
- record.unittype_gn = 5
- record.other_hhmemb = 2
+ record.unittype_gn = 9
+ record.hhmemb = 3
property_validator.validate_shared_housing_rooms(record)
expect(record.errors["unittype_gn"]).to include(match(expected_error))
expect(record.errors["beds"]).to include(I18n.t("validations.property.unittype_gn.one_seven_bedroom_shared"))
@@ -122,8 +122,8 @@ RSpec.describe Validations::PropertyValidations do
it "adds an error" do
record.beds = 4
- record.unittype_gn = 5
- record.other_hhmemb = 0
+ record.unittype_gn = 9
+ record.hhmemb = 1
property_validator.validate_shared_housing_rooms(record)
expect(record.errors["unittype_gn"]).to include(match(expected_error))
expect(record.errors["beds"]).to include(I18n.t("validations.property.unittype_gn.one_three_bedroom_single_tenant_shared"))
@@ -286,7 +286,7 @@ RSpec.describe Validations::PropertyValidations do
it "validates that the property is not being relet to tenant who occupied as temporary" do
non_temporary_previous_tenancies.each do |prevten|
- record.rsnvac = 2
+ record.rsnvac = 9
record.prevten = prevten
property_validator.validate_rsnvac(record)
expect(record.errors["rsnvac"])
@@ -296,7 +296,7 @@ RSpec.describe Validations::PropertyValidations do
it "validates that the letting source is not a referral" do
referral_sources.each do |src|
- record.rsnvac = 2
+ record.rsnvac = 9
record.referral = src
property_validator.validate_rsnvac(record)
expect(record.errors["rsnvac"])
diff --git a/spec/models/validations/setup_validations_spec.rb b/spec/models/validations/setup_validations_spec.rb
index 0c333d6d7..56b335464 100644
--- a/spec/models/validations/setup_validations_spec.rb
+++ b/spec/models/validations/setup_validations_spec.rb
@@ -6,28 +6,28 @@ RSpec.describe Validations::SetupValidations do
let(:setup_validator_class) { Class.new { include Validations::SetupValidations } }
let(:record) { FactoryBot.create(:case_log) }
- describe "#validate_intermediate_rent_product_name" do
+ describe "#validate_irproduct" do
it "adds an error when the intermediate rent product name is not provided but the rent type was given as other intermediate rent product" do
record.rent_type = 5
- record.intermediate_rent_product_name = nil
- setup_validator.validate_intermediate_rent_product_name(record)
- expect(record.errors["intermediate_rent_product_name"])
+ record.irproduct_other = nil
+ setup_validator.validate_irproduct_other(record)
+ expect(record.errors["irproduct_other"])
.to include(match I18n.t("validations.setup.intermediate_rent_product_name.blank"))
end
it "adds an error when the intermediate rent product name is blank but the rent type was given as other intermediate rent product" do
record.rent_type = 5
- record.intermediate_rent_product_name = ""
- setup_validator.validate_intermediate_rent_product_name(record)
- expect(record.errors["intermediate_rent_product_name"])
+ record.irproduct_other = ""
+ setup_validator.validate_irproduct_other(record)
+ expect(record.errors["irproduct_other"])
.to include(match I18n.t("validations.setup.intermediate_rent_product_name.blank"))
end
it "Does not add an error when the intermediate rent product name is provided and the rent type was given as other intermediate rent product" do
record.rent_type = 5
- record.intermediate_rent_product_name = "Example"
- setup_validator.validate_intermediate_rent_product_name(record)
- expect(record.errors["intermediate_rent_product_name"]).to be_empty
+ record.irproduct_other = "Example"
+ setup_validator.validate_irproduct_other(record)
+ expect(record.errors["irproduct_other"]).to be_empty
end
end
end
diff --git a/spec/models/validations/tenancy_validations_spec.rb b/spec/models/validations/tenancy_validations_spec.rb
index 689a7f383..711b1481a 100644
--- a/spec/models/validations/tenancy_validations_spec.rb
+++ b/spec/models/validations/tenancy_validations_spec.rb
@@ -12,7 +12,7 @@ RSpec.describe Validations::TenancyValidations do
let(:expected_error) { I18n.t("validations.tenancy.length.fixed_term_not_required") }
it "tenancy length should not be present" do
- record.tenancy = 4
+ record.tenancy = 3
record.tenancylength = 10
tenancy_validator.validate_fixed_term_tenancy(record)
expect(record.errors["tenancylength"]).to include(match(expected_error))
@@ -23,9 +23,10 @@ RSpec.describe Validations::TenancyValidations do
context "when type of tenancy is assured shorthold" do
let(:expected_error) { I18n.t("validations.tenancy.length.shorthold") }
+ before { record.tenancy = 4 }
+
context "when tenancy length is greater than 1" do
it "adds an error" do
- record.tenancy = 1
record.tenancylength = 1
tenancy_validator.validate_fixed_term_tenancy(record)
expect(record.errors["tenancylength"]).to include(match(expected_error))
@@ -35,7 +36,6 @@ RSpec.describe Validations::TenancyValidations do
context "when tenancy length is less than 100" do
it "adds an error" do
- record.tenancy = 1
record.tenancylength = 100
tenancy_validator.validate_fixed_term_tenancy(record)
expect(record.errors["tenancylength"]).to include(match(expected_error))
@@ -45,7 +45,6 @@ RSpec.describe Validations::TenancyValidations do
context "when tenancy length is between 2-99" do
it "does not add an error" do
- record.tenancy = 1
record.tenancylength = 3
tenancy_validator.validate_fixed_term_tenancy(record)
expect(record.errors["tenancylength"]).to be_empty
@@ -55,7 +54,6 @@ RSpec.describe Validations::TenancyValidations do
context "when tenancy length has not been answered" do
it "does not add an error" do
- record.tenancy = 1
record.tenancylength = nil
tenancy_validator.validate_fixed_term_tenancy(record)
expect(record.errors["tenancylength"]).to be_empty
@@ -67,9 +65,10 @@ RSpec.describe Validations::TenancyValidations do
context "when type of tenancy is secure" do
let(:expected_error) { I18n.t("validations.tenancy.length.secure") }
+ before { record.tenancy = 1 }
+
context "when tenancy length is greater than 1" do
it "adds an error" do
- record.tenancy = 3
record.tenancylength = 1
tenancy_validator.validate_fixed_term_tenancy(record)
expect(record.errors["tenancylength"]).to include(match(expected_error))
@@ -79,7 +78,6 @@ RSpec.describe Validations::TenancyValidations do
context "when tenancy length is less than 100" do
it "adds an error" do
- record.tenancy = 3
record.tenancylength = 100
tenancy_validator.validate_fixed_term_tenancy(record)
expect(record.errors["tenancylength"]).to include(match(expected_error))
@@ -89,7 +87,6 @@ RSpec.describe Validations::TenancyValidations do
context "when tenancy length is between 2-99" do
it "does not add an error" do
- record.tenancy = 3
record.tenancylength = 3
tenancy_validator.validate_fixed_term_tenancy(record)
expect(record.errors["tenancylength"]).to be_empty
@@ -99,7 +96,6 @@ RSpec.describe Validations::TenancyValidations do
context "when tenancy length has not been answered" do
it "does not add an error" do
- record.tenancy = 3
record.tenancylength = nil
tenancy_validator.validate_fixed_term_tenancy(record)
expect(record.errors["tenancylength"]).to be_empty
@@ -117,15 +113,15 @@ RSpec.describe Validations::TenancyValidations do
let(:expected_error) { I18n.t(field, main_field_label:, other_field_label:) }
context "when tenancy type is other" do
+ before { record.tenancy = 3 }
+
it "validates that other tenancy type is provided" do
- record.tenancy = 4
record.tenancyother = nil
tenancy_validator.validate_other_tenancy_type(record)
expect(record.errors[other_field_label]).to include(match(expected_error))
end
it "expects that other tenancy type is provided" do
- record.tenancy = 4
record.tenancyother = "Some other tenancy type"
tenancy_validator.validate_other_tenancy_type(record)
expect(record.errors[other_field_label]).to be_empty
@@ -136,14 +132,14 @@ RSpec.describe Validations::TenancyValidations do
let(:field) { "validations.other_field_not_required" }
it "validates that other tenancy type is not provided" do
- record.tenancy = 0
+ record.tenancy = 2
record.tenancyother = "Some other tenancy type"
tenancy_validator.validate_other_tenancy_type(record)
expect(record.errors[other_field_label]).to include(match(expected_error))
end
it "expects that other tenancy type is not provided" do
- record.tenancy = 3
+ record.tenancy = 1
record.tenancyother = nil
tenancy_validator.validate_other_tenancy_type(record)
expect(record.errors[other_field_label]).to be_empty
diff --git a/spec/requests/form_controller_spec.rb b/spec/requests/form_controller_spec.rb
index 32d8016d9..8e99f7e78 100644
--- a/spec/requests/form_controller_spec.rb
+++ b/spec/requests/form_controller_spec.rb
@@ -248,9 +248,7 @@ RSpec.describe FormController, type: :request do
"housingneeds_f" => "Other disability requirements",
"housingneeds_g" => "No disability requirements",
"divider_a" => true,
- "housingneeds_h" => "Don’t know",
- "divider_b" => true,
- "accessibility_requirements_prefer_not_to_say" => "Prefer not to say" },
+ "housingneeds_h" => "Don’t know" },
}, nil
),
Form::Question.new("tenant_code", { "type" => "text" }, nil),
@@ -277,7 +275,7 @@ RSpec.describe FormController, type: :request do
id: case_log.id,
case_log: {
page: "conditional_question",
- preg_occ: 0,
+ preg_occ: 1,
},
}
end
@@ -286,7 +284,7 @@ RSpec.describe FormController, type: :request do
id: case_log.id,
case_log: {
page: "conditional_question",
- preg_occ: 1,
+ preg_occ: 2,
},
}
end
diff --git a/spec/services/imports/case_logs_import_service_spec.rb b/spec/services/imports/case_logs_import_service_spec.rb
new file mode 100644
index 000000000..55b6cadca
--- /dev/null
+++ b/spec/services/imports/case_logs_import_service_spec.rb
@@ -0,0 +1,34 @@
+require "rails_helper"
+
+RSpec.describe Imports::CaseLogsImportService do
+ let(:remote_folder) { "case_logs" }
+ let(:fixture_directory) { "spec/fixtures/softwire_imports/case_logs" }
+ let(:case_log_id) { "0ead17cb-1668-442d-898c-0d52879ff592" }
+ let(:case_log_id2) { "166fc004-392e-47a8-acb8-1c018734882b" }
+ let(:case_log_file) { File.open("#{fixture_directory}/#{case_log_id}.xml") }
+ let(:case_log_file2) { File.open("#{fixture_directory}/#{case_log_id2}.xml") }
+ let(:storage_service) { instance_double(StorageService) }
+ let(:real_2021_2022_form) { Form.new("config/forms/2021_2022.json", "2021_2022") }
+
+ context "when importing users" do
+ subject(:case_log_service) { described_class.new(storage_service) }
+
+ before do
+ # Stub the S3 file listing and download
+ allow(storage_service).to receive(:list_files)
+ .and_return(%W[#{remote_folder}/#{case_log_id}.xml #{remote_folder}/#{case_log_id2}.xml])
+ allow(storage_service).to receive(:get_file_io)
+ .with("#{remote_folder}/#{case_log_id}.xml")
+ .and_return(case_log_file)
+ allow(storage_service).to receive(:get_file_io)
+ .with("#{remote_folder}/#{case_log_id2}.xml")
+ .and_return(case_log_file2)
+ # Stub the form handler to use the real form
+ allow(FormHandler.instance).to receive(:get_form).with(anything).and_return(real_2021_2022_form)
+ end
+
+ it "successfully create a case log with the expected data" do
+ case_log_service.create_logs(remote_folder)
+ end
+ end
+end