Browse Source

Import changes (#470)

pull/481/head
Stéphane Meny 3 years ago committed by GitHub
parent
commit
b8d60a86ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 26
      app/models/bulk_upload.rb
  2. 133
      app/models/case_log.rb
  3. 24
      app/models/form/question.rb
  4. 12
      app/models/validations/date_validations.rb
  5. 21
      app/models/validations/financial_validations.rb
  6. 10
      app/models/validations/household_validations.rb
  7. 2
      app/models/validations/property_validations.rb
  8. 6
      app/models/validations/setup_validations.rb
  9. 2
      app/models/validations/tenancy_validations.rb
  10. 392
      app/services/imports/case_logs_import_service.rb
  11. 346
      config/forms/2021_2022.json
  12. 40
      config/locales/en.yml
  13. 0
      db/migrate/20220207112310_additional_user_fields2.rb
  14. 13
      db/migrate/20220411092231_update_case_logs_fields.rb
  15. 29
      db/schema.rb
  16. 4
      docs/api/DLUHC-CORE-Data.v1.json
  17. 42
      spec/factories/case_log.rb
  18. 16
      spec/features/form/check_answers_page_spec.rb
  19. 6
      spec/features/form/conditional_questions_spec.rb
  20. 4
      spec/features/form/form_navigation_spec.rb
  21. 6
      spec/features/form/page_routing_spec.rb
  22. 2
      spec/features/form/saving_data_spec.rb
  23. 4
      spec/features/form/validations_spec.rb
  24. 30
      spec/fixtures/complete_case_log.json
  25. 41
      spec/fixtures/exports/case_logs.xml
  26. 66
      spec/fixtures/forms/2021_2022.json
  27. 532
      spec/fixtures/softwire_imports/case_logs/0ead17cb-1668-442d-898c-0d52879ff592.xml
  28. 514
      spec/fixtures/softwire_imports/case_logs/166fc004-392e-47a8-acb8-1c018734882b.xml
  29. 2
      spec/helpers/check_answers_helper_spec.rb
  30. 2
      spec/helpers/conditional_questions_helper_spec.rb
  31. 2
      spec/helpers/interuption_screen_helper_spec.rb
  32. 206
      spec/models/case_log_spec.rb
  33. 2
      spec/models/form/page_spec.rb
  34. 24
      spec/models/form/question_spec.rb
  35. 8
      spec/models/form/subsection_spec.rb
  36. 12
      spec/models/form_spec.rb
  37. 24
      spec/models/validations/date_validations_spec.rb
  38. 50
      spec/models/validations/financial_validations_spec.rb
  39. 94
      spec/models/validations/household_validations_spec.rb
  40. 24
      spec/models/validations/property_validations_spec.rb
  41. 20
      spec/models/validations/setup_validations_spec.rb
  42. 22
      spec/models/validations/tenancy_validations_spec.rb
  43. 8
      spec/requests/form_controller_spec.rb
  44. 34
      spec/services/imports/case_logs_import_service_spec.rb

26
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

133
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

24
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

12
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

21
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

10
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)

2
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")

6
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

2
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

392
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

346
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
}
]

40
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"

0
db/migrate/202202071123100_additional_user_fields2.rb → db/migrate/20220207112310_additional_user_fields2.rb

13
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

29
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

4
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 @@
}
}
}
}
}

42
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 }

16
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",

6
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

4
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")

6
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")

2
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

4
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")

30
spec/fixtures/complete_case_log.json vendored

@ -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,

41
spec/fixtures/exports/case_logs.xml vendored

@ -38,38 +38,36 @@
<underoccupation_benefitcap>0</underoccupation_benefitcap>
<leftreg>1</leftreg>
<reservist>0</reservist>
<illness>0</illness>
<preg_occ>1</preg_occ>
<illness>1</illness>
<preg_occ>2</preg_occ>
<tenancy_code>BZ757</tenancy_code>
<startertenancy>0</startertenancy>
<tenancylength>5</tenancylength>
<tenancy>3</tenancy>
<landlord>1</landlord>
<tenancy>1</tenancy>
<ppostcode_full>SE26RT</ppostcode_full>
<rsnvac>7</rsnvac>
<unittype_gn>2</unittype_gn>
<rsnvac>6</rsnvac>
<unittype_gn>7</unittype_gn>
<beds>3</beds>
<offered>2</offered>
<wchair>1</wchair>
<earnings>68</earnings>
<incfreq>0</incfreq>
<incfreq>1</incfreq>
<benefits>1</benefits>
<period>2</period>
<layear>2</layear>
<lawaitlist>1</lawaitlist>
<waityear>1</waityear>
<postcode_full>NW15TY</postcode_full>
<reasonpref>1</reasonpref>
<cbl>1</cbl>
<chr>1</chr>
<cap>0</cap>
<other_reason_for_leaving_last_settled_home/>
<reasonother/>
<housingneeds_a>1</housingneeds_a>
<housingneeds_b>0</housingneeds_b>
<housingneeds_c>0</housingneeds_c>
<housingneeds_f>0</housingneeds_f>
<housingneeds_g>0</housingneeds_g>
<housingneeds_h>0</housingneeds_h>
<accessibility_requirements_prefer_not_to_say>0</accessibility_requirements_prefer_not_to_say>
<illness_type_1>0</illness_type_1>
<illness_type_2>1</illness_type_2>
<illness_type_3>0</illness_type_3>
@ -90,7 +88,7 @@
<property_owner_organisation>Test</property_owner_organisation>
<property_manager_organisation>Test</property_manager_organisation>
<sale_or_letting/>
<intermediate_rent_product_name>2</intermediate_rent_product_name>
<irproduct_other/>
<purchaser_code>798794</purchaser_code>
<reason>4</reason>
<propcode>123</propcode>
@ -99,24 +97,16 @@
<prevloc>E07000105</prevloc>
<hb>6</hb>
<hbrentshortfall>0</hbrentshortfall>
<postcode>NW1</postcode>
<postcod2>5TY</postcod2>
<ppostc1>SE2</ppostc1>
<ppostc2>6RT</ppostc2>
<property_relet>0</property_relet>
<mrcdate>2020-05-05 10:36:49 UTC</mrcdate>
<mrcday>5</mrcday>
<mrcmonth>5</mrcmonth>
<mrcyear>2020</mrcyear>
<other_hhmemb>1</other_hhmemb>
<incref>0</incref>
<sale_completion_date/>
<startdate>2022-02-02 10:36:49 UTC</startdate>
<armedforces>0</armedforces>
<armedforces>1</armedforces>
<first_time_property_let_as_social_housing/>
<unitletas>2</unitletas>
<builtype>1</builtype>
<property_void_date>2019-11-03 00:00:00 UTC</property_void_date>
<voiddate>2019-11-03 00:00:00 UTC</voiddate>
<owning_organisation_id>{owning_org_id}</owning_organisation_id>
<managing_organisation_id>{managing_org_id}</managing_organisation_id>
<renttype>2</renttype>
@ -125,9 +115,6 @@
<postcode_known>1</postcode_known>
<la_known>1</la_known>
<is_la_inferred>false</is_la_inferred>
<day>2</day>
<month>2</month>
<year>2022</year>
<totchild>0</totchild>
<totelder>0</totelder>
<totadult>2</totadult>
@ -161,9 +148,6 @@
<wtshortfall>6.0</wtshortfall>
<refused>0</refused>
<housingneeds>1</housingneeds>
<vday>3</vday>
<vmonth>11</vmonth>
<vyear>2019</vyear>
<wchchrg/>
<newprop>2</newprop>
<relat2>P</relat2>
@ -174,6 +158,9 @@
<relat7/>
<relat8/>
<rent_value_check/>
<old_form_id/>
<lar/>
<irproduct/>
<providertype>1</providertype>
</form>
</forms>

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

@ -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",

532
spec/fixtures/softwire_imports/case_logs/0ead17cb-1668-442d-898c-0d52879ff592.xml vendored

@ -0,0 +1,532 @@
<?xml version="1.0" encoding="UTF-8"?>
<Group xmlns="http://data.gov.uk/core/logs/2021-CORE-SR-GN"
xmlns:app="http://www.w3.org/2007/app"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:meta="http://data.gov.uk/core/metadata"
xmlns:svc="http://www.w3.org/2007/app"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xfimpl="http://www.w3.org/2002/xforms/implementation"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<meta:metadata xmlns:es="http://www.ecmascript.org/"
xmlns:xqx="http://www.w3.org/2005/XQueryX"
xmlns:XSLT="http://www.w3.org/1999/XSL/Transform/compile">
<meta:form-name>2021-CORE-SR-GN</meta:form-name>
<meta:document-id>0ead17cb-1668-442d-898c-0d52879ff592</meta:document-id>
<meta:owner-user-id>c3061a2e6ea0b702e6f6210d5c52d2a92612d2aa
</meta:owner-user-id>
<meta:owner-institution-id>7c5bd5fb549c09a2c55d7cb90d7ba84927e64618
</meta:owner-institution-id>
<meta:managing-institution-id>7c5bd5fb549c09a2c55d7cb90d7ba84927e64618
</meta:managing-institution-id>
<meta:created-date>2021-10-08T14:48:17.096123Z</meta:created-date>
<meta:modified-date>2021-10-08T14:48:17.096123Z</meta:modified-date>
<meta:status>submitted-valid</meta:status>
<meta:reporting-year>2021</meta:reporting-year>
<meta:upload-method>Manual Entry</meta:upload-method>
<meta:schema assert-valid="true"/>
<meta:rules assert-valid="true"/>
</meta:metadata>
<Group>
<Qdp>Yes</Qdp>
<KeyDate>2021-09-30</KeyDate>
<FORM>5786509</FORM>
<Landlord source-value="1">1 Private Registered Provider</Landlord>
<Group>
<_1btenagree>1 This Landlord</_1btenagree>
<_1bifanother/>
<_1bCOREcode/>
</Group>
</Group>
<Group>
<_2a>1 Yes</_2a>
<Q2b>2 Assured</Q2b>
<Q2ba/>
<_2bTenCode>MAC003</_2bTenCode>
<_2cYears/>
</Group>
<Group>
<P1Age override-field="">23</P1Age>
<P1AR/>
<P1Sex override-field="">Female</P1Sex>
<P1Eco>6) Not Seeking Work</P1Eco>
<P1Eth>1 White: English/Scottish/Welsh/Northern Irish/British</P1Eth>
<P1Nat>1 UK national resident in UK</P1Nat>
<P2Age override-field="">2</P2Age>
<P2AR/>
<P2Sex override-field="">Male</P2Sex>
<P2Rel>Child</P2Rel>
<P2Eco>9) Child under 16</P2Eco>
<P3Age override-field=""/>
<P3AR/>
<P3Sex override-field=""/>
<P3Rel/>
<P3Eco/>
<P4Age override-field=""/>
<P4AR/>
<P4Sex override-field=""/>
<P4Rel/>
<P4Eco/>
<P5Age override-field=""/>
<P5AR/>
<P5Sex override-field=""/>
<P5Rel/>
<P5Eco/>
<P6Age override-field=""/>
<P6AR/>
<P6Sex override-field=""/>
<P6Rel/>
<P6Eco/>
<P7Age override-field=""/>
<P7AR/>
<P7Sex override-field=""/>
<P7Rel/>
<P7Eco/>
<P8Age override-field=""/>
<P8AR/>
<P8Sex override-field=""/>
<P8Rel/>
<P8Eco/>
<Group>
<ArmedF>2 No</ArmedF>
<LeftAF/>
<Inj/>
<Preg override-field="">2 No</Preg>
</Group>
<Group>
<Q6Ben>6 UC – with housing element (and not in receipt of Housing
Benefit)
</Q6Ben>
</Group>
<Group>
<Q7Ben>1 All</Q7Ben>
<Q8Refused/>
<Q8Money override-field="">600.00</Q8Money>
<Q8a>2 Monthly</Q8a>
</Group>
<Group>
<Q9a>12 Property unsuitable because of overcrowding</Q9a>
<Q9aa/>
</Group>
<Group>
<_9b override-field="">2 No</_9b>
<Q10-a/>
<Q10-b/>
<Q10-c/>
<Q10-f/>
<Q10-g>Yes</Q10-g>
<Q10-h/>
<Q10ia>2 No</Q10ia>
<Q10ib-1/>
<Q10ib-2/>
<Q10ib-3/>
<Q10ib-4/>
<Q10ib-5/>
<Q10ib-6/>
<Q10ib-7/>
<Q10ib-8/>
<Q10ib-9/>
<Q10ib-10/>
<Q11 override-field="">30 Fixed term Local Authority General Needs
tenancy
</Q11>
<Q12a>Leeds</Q12a>
<Q12aONS>E08000035</Q12aONS>
<Q12b override-field="">LS8 3HX</Q12b>
<Q12bnot/>
<Q12c>5 5 years or more</Q12c>
<Q12d>2 Less than 1 year</Q12d>
</Group>
<Group>
<Q13>1 Not homeless</Q13>
<Q14a>1 Yes</Q14a>
<Q14b1/>
<Q14b2>2_Living_in_insanitary_or_overcrowded_or_unsatisfactory_housing
</Q14b2>
<Q14b3/>
<Q14b4/>
<Q14b5/>
</Group>
<Group>
<Q15CBL>1 Yes</Q15CBL>
<Q15CHR>2 No</Q15CHR>
<Q15CAP>2 No</Q15CAP>
</Group>
<Group>
<Q16>3 PRP lettings only - nominated by a local housing authority</Q16>
</Group>
</Group>
<Group>
<Q17>4 Calendar monthly</Q17>
<Q18ai override-field="">406.09</Q18ai>
<Q18aii override-field="">32.02</Q18aii>
<Q18aiii override-field=""/>
<Q18aiv override-field=""/>
<Q18av override-field="">438.11</Q18av>
<Q18d>2 No</Q18d>
<Q18dyes override-field=""/>
<Q19void>2021-09-30</Q19void>
<Q19repair/>
<Q20 override-field="">0</Q20>
<Q21a>MCB003</Q21a>
</Group>
<Group>
<Q22 override-field="">2</Q22>
<Q23>1 Flat / maisonette</Q23>
<Q24>1 Purpose built</Q24>
<Q25>2 No</Q25>
<Q26/>
<Q27>15 First let of newbuild property</Q27>
</Group>
<Group>
<Q28Auth>Leeds</Q28Auth>
<Q28ONS>E08000035</Q28ONS>
<Q28pc override-field="">LS16 6FT</Q28pc>
</Group>
<Group>
<F1Age>1</F1Age>
<F2Age>0</F2Age>
<F3Age>0</F3Age>
<F4Age>0</F4Age>
<F5Age>0</F5Age>
<F6Age>0</F6Age>
<F7Age>0</F7Age>
<F8Age>0</F8Age>
<FAge>1</FAge>
<F1>1</F1>
<F2>0</F2>
<F3>0</F3>
<F4>0</F4>
<F5>0</F5>
<F6>0</F6>
<F7>0</F7>
<F8>0</F8>
<F>1</F>
<P1100>0</P1100>
<P2100>0</P2100>
<P3100>0</P3100>
<P4100>0</P4100>
<P5100>0</P5100>
<P6100>0</P6100>
<P7100>0</P7100>
<P8100>0</P8100>
<_100>0</_100>
<P170>0</P170>
<P270>0</P270>
<P370>0</P370>
<P470>0</P470>
<P570>0</P570>
<P670>0</P670>
<P770>0</P770>
<P870>0</P870>
<_70>0</_70>
<P1PT>0</P1PT>
<P2PT>0</P2PT>
<P3PT>0</P3PT>
<P4PT>0</P4PT>
<P5PT>0</P5PT>
<P6PT>0</P6PT>
<P7PT>0</P7PT>
<P8PT>0</P8PT>
<PT>0</PT>
<P1FT>0</P1FT>
<P2FT>0</P2FT>
<P3FT>0</P3FT>
<P4FT>0</P4FT>
<P5FT>0</P5FT>
<P6FT>0</P6FT>
<P7FT>0</P7FT>
<P8FT>0</P8FT>
<FT>0</FT>
<P1Stud>0</P1Stud>
<P2Stud>0</P2Stud>
<P3Stud>0</P3Stud>
<P4Stud>0</P4Stud>
<P5Stud>0</P5Stud>
<P6Stud>0</P6Stud>
<P7Stud>0</P7Stud>
<P8Stud>0</P8Stud>
<Stud>0</Stud>
<P2Child>1</P2Child>
<P3Child>0</P3Child>
<P4Child>0</P4Child>
<P5Child>0</P5Child>
<P6Child>0</P6Child>
<P7Child>0</P7Child>
<P8Child>0</P8Child>
<Child>1</Child>
<P2Partner>0</P2Partner>
<P3Partner>0</P3Partner>
<P4Partner>0</P4Partner>
<P5Partner>0</P5Partner>
<P6Partner>0</P6Partner>
<P7Partner>0</P7Partner>
<P8Partner>0</P8Partner>
<Partner>0</Partner>
<Q1bV1>0</Q1bV1>
<Q1bV2>0</Q1bV2>
<Q1bV3>1</Q1bV3>
<Q1bVT>1</Q1bVT>
<P1Adult>1</P1Adult>
<P2Adult>0</P2Adult>
<P3Adult>0</P3Adult>
<P4Adult>0</P4Adult>
<P5Adult>0</P5Adult>
<P6Adult>0</P6Adult>
<P7Adult>0</P7Adult>
<P8Adult>0</P8Adult>
<PAdultT>1</PAdultT>
<P2PAge>0</P2PAge>
<P3PAge>0</P3PAge>
<P4PAge>0</P4PAge>
<P5PAge>0</P5PAge>
<P6PAge>0</P6PAge>
<P7PAge>0</P7PAge>
<P8PAge>0</P8PAge>
<PAGE>23</PAGE>
<P2ChildAge>2</P2ChildAge>
<P3ChildAge>0</P3ChildAge>
<P4ChildAge>0</P4ChildAge>
<P5ChildAge>0</P5ChildAge>
<P6ChildAge>0</P6ChildAge>
<P7ChildAge>0</P7ChildAge>
<P8ChildAge>0</P8ChildAge>
<ChildAgeMin>2</ChildAgeMin>
<AgeDiff1>23</AgeDiff1>
<AgeDiff2>21</AgeDiff2>
<AgeDiff3>23</AgeDiff3>
<TODAY>2021-10-08Z</TODAY>
<FutureLimit>2021-10-23Z</FutureLimit>
<minmax1/>
<minmax2/>
<minmax3/>
<minmax4/>
<minmax5/>
<minmax6/>
<minmax7/>
<minmax8/>
<minmax9/>
<minmax0/>
<minmax10/>
<minmaxT/>
<Q10av>0</Q10av>
<Q10bv>0</Q10bv>
<Q10cv>0</Q10cv>
<Q10fv>0</Q10fv>
<Q10gv>20</Q10gv>
<Q10hv>0</Q10hv>
<Q10Validate>20</Q10Validate>
<Q2bv>C</Q2bv>
<P2Agev>1</P2Agev>
<P2Sexv>1</P2Sexv>
<P2Relv>1</P2Relv>
<P2Ecov>1</P2Ecov>
<P2valid>4</P2valid>
<P3Agev>0</P3Agev>
<P3Sexv>0</P3Sexv>
<P3Relv>0</P3Relv>
<P3Ecov>0</P3Ecov>
<P3valid>0</P3valid>
<P4Agev>0</P4Agev>
<P4Sexv>0</P4Sexv>
<P4Relv>0</P4Relv>
<P4Ecov>0</P4Ecov>
<P4valid>0</P4valid>
<P5Agev>0</P5Agev>
<P5Sexv>0</P5Sexv>
<P5Relv>0</P5Relv>
<P5Ecov>0</P5Ecov>
<P5valid>0</P5valid>
<P6Agev>0</P6Agev>
<P6Sexv>0</P6Sexv>
<P6Relv>0</P6Relv>
<P6Ecov>0</P6Ecov>
<P6valid>0</P6valid>
<P7Agev>0</P7Agev>
<P7Sexv>0</P7Sexv>
<P7Relv>0</P7Relv>
<P7Ecov>0</P7Ecov>
<P7valid>0</P7valid>
<P8Agev>0</P8Agev>
<P8Sexv>0</P8Sexv>
<P8Relv>0</P8Relv>
<P8Ecov>0</P8Ecov>
<P8valid>0</P8valid>
<Q14b1v>0</Q14b1v>
<Q14b2v>1</Q14b2v>
<Q14b3v>0</Q14b3v>
<Q14b4v>0</Q14b4v>
<Q14b5v>0</Q14b5v>
<Q14bv>1</Q14bv>
<P2Other>0</P2Other>
<P3Other>0</P3Other>
<P4Other>0</P4Other>
<P5Other>0</P5Other>
<P6Other>0</P6Other>
<P7Other>0</P7Other>
<P8Other>0</P8Other>
<Other>0</Other>
<P2ARefused>0</P2ARefused>
<P3ARefused>0</P3ARefused>
<P4ARefused>0</P4ARefused>
<P5ARefused>0</P5ARefused>
<P6ARefused>0</P6ARefused>
<P7ARefused>0</P7ARefused>
<P8ARefused>0</P8ARefused>
<TAREUSED>0</TAREUSED>
<P2RRefused>0</P2RRefused>
<P3RRefused>0</P3RRefused>
<P4RRefused>0</P4RRefused>
<P5RRefused>0</P5RRefused>
<P6RRefused>0</P6RRefused>
<P7RRefused>0</P7RRefused>
<P8RRefused>0</P8RRefused>
<TotRRefused>0</TotRRefused>
<TOTREFUSED>0</TOTREFUSED>
</Group>
<Group>
<ChildBen>21.05</ChildBen>
<TOTADULT>1</TOTADULT>
<NEW_OLD>2 Existing Tenant</NEW_OLD>
<Q18aValid>1</Q18aValid>
<Q18Valid>1</Q18Valid>
<VACDAYS>0</VACDAYS>
<HHMEMB>2</HHMEMB>
<HHTYPEP1A>1</HHTYPEP1A>
<HHTYPEP2A>0</HHTYPEP2A>
<HHTYPEP3A>0</HHTYPEP3A>
<HHTYPEP4A>0</HHTYPEP4A>
<HHTYPEP5A>0</HHTYPEP5A>
<HHTYPEP6A>0</HHTYPEP6A>
<HHTYPEP7A>0</HHTYPEP7A>
<HHTYPEP8A>0</HHTYPEP8A>
<TADULT>1</TADULT>
<HHTYPEP1E>0</HHTYPEP1E>
<HHTYPEP2E>0</HHTYPEP2E>
<HHTYPEP3E>0</HHTYPEP3E>
<HHTYPEP4E>0</HHTYPEP4E>
<HHTYPEP5E>0</HHTYPEP5E>
<HHTYPEP6E>0</HHTYPEP6E>
<HHTYPEP7E>0</HHTYPEP7E>
<HHTYPEP8E>0</HHTYPEP8E>
<TELDER>0</TELDER>
<HHTYPEP1C>0</HHTYPEP1C>
<HHTYPEP2C>1</HHTYPEP2C>
<HHTYPEP3C>0</HHTYPEP3C>
<HHTYPEP4C>0</HHTYPEP4C>
<HHTYPEP5C>0</HHTYPEP5C>
<HHTYPEP6C>0</HHTYPEP6C>
<HHTYPEP7C>0</HHTYPEP7C>
<HHTYPEP8C>0</HHTYPEP8C>
<TCHILD>1</TCHILD>
<HHTYPE>5 = 1 adult + 1 or more children</HHTYPE>
<WEEKLYINC>133.33</WEEKLYINC>
<INCOME>154.38</INCOME>
<TYPEHB>7.00</TYPEHB>
<AFFRATE/>
<Weekinc>154.38</Weekinc>
<LETTYPE>1 Private Registered Provider</LETTYPE>
<PLOACODE/>
<OACODE/>
<GOVREG>E12000003</GOVREG>
<OWNINGORGID>1034</OWNINGORGID>
<OWNINGORGNAME>LEEDS &amp; YORKSHIRE HA Ltd</OWNINGORGNAME>
<MANINGORGNAME>LEEDS &amp; YORKSHIRE HA Ltd</MANINGORGNAME>
<HCNUM>LH0704</HCNUM>
<MANHCNUM>LH0704</MANHCNUM>
<LAHA/>
<MANINGORGID>1034</MANINGORGID>
<HBTYPE1/>
<HBTYPE2/>
<HBTYPE3/>
<HBTYPE4/>
<HBTYPE5/>
<HBTYPE6/>
<HBTYPE7>7</HBTYPE7>
<HBTYPE8/>
<HBTYPE9/>
<HBTYPE10/>
<HBTYPE11/>
<HBTYPE12/>
<HBTYPE13/>
<HBTYPE14/>
<HBTYPE15/>
<HBTYPE>7</HBTYPE>
<P1R>0</P1R>
<P2R>0</P2R>
<P3R>0</P3R>
<P4R>0</P4R>
<P5R>0</P5R>
<P6R>0</P6R>
<P7R>0</P7R>
<P8R>0</P8R>
<REFUSEDTOT>0</REFUSEDTOT>
<REFUSED/>
<WTSHORTFALL/>
<WRENT>93.71</WRENT>
<WTCHARGE>101.10</WTCHARGE>
<WSCHARGE>7.39</WSCHARGE>
<WPSCHRGE/>
<WSUPCHRG/>
<WTSHORTFALL1/>
<WTSHORTFALLHB/>
<WTSHORTFALLHE/>
<WRENT1>93.71</WRENT1>
<WTCHARGE1>101.10</WTCHARGE1>
<WSCHARGE1>7.39</WSCHARGE1>
<WPSCHRGE1/>
<WSUPCHRG1/>
</Group>
<Group>
<BSa>0</BSa>
<BSb>1</BSb>
<BSc>0</BSc>
<BScm>0</BScm>
<BScf>0</BScf>
<BSd>0</BSd>
<BSdm>0.5</BSdm>
<BSdf>0</BSdf>
<BSe>0</BSe>
<BSem>0</BSem>
<BSef>0</BSef>
<BSf>1</BSf>
<BSfm>0</BSfm>
<BSff>0</BSff>
<BSfmx>1</BSfmx>
<BSffx>0</BSffx>
<BEDROOMSTAND>2</BEDROOMSTAND>
<BEDMINUSBEDS>0</BEDMINUSBEDS>
<WRENTreduced>93.71</WRENTreduced>
<NonDepDeduct>0</NonDepDeduct>
<RENTHB/>
<ChildAllowan>68.6</ChildAllowan>
<PrsnlAllowan>74.7</PrsnlAllowan>
<HousBenDisAl>25</HousBenDisAl>
<PAIDHB/>
<HCNETAF/>
<ChldAlloCat1>1</ChldAlloCat1>
<ChldAlloCat2>0</ChldAlloCat2>
<P2NnDepDedct>0</P2NnDepDedct>
<P3NnDepDedct>0</P3NnDepDedct>
<P4NnDepDedct>0</P4NnDepDedct>
<P5NnDepDedct>0</P5NnDepDedct>
<P6NnDepDedct>0</P6NnDepDedct>
<P7NnDepDedct>0</P7NnDepDedct>
<P8NnDepDedct>0</P8NnDepDedct>
<DAY>30</DAY>
<MONTH>9</MONTH>
<YEAR>2021</YEAR>
<VDAY>30</VDAY>
<VMONTH>9</VMONTH>
<VYEAR>2021</VYEAR>
<MRCDAY/>
<MRCMONTH/>
<MRCYEAR/>
<PPOSTC1>LS8</PPOSTC1>
<PPOSTC2>3HX</PPOSTC2>
<POSTCODE>LS16</POSTCODE>
<POSTCOD2>6FT</POSTCOD2>
</Group>
</Group>

514
spec/fixtures/softwire_imports/case_logs/166fc004-392e-47a8-acb8-1c018734882b.xml vendored

@ -0,0 +1,514 @@
<Group xmlns="http://data.gov.uk/core/logs/2021-CORE-IR-GN" xmlns:app="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:meta="http://data.gov.uk/core/metadata" xmlns:svc="http://www.w3.org/2007/app" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xfimpl="http://www.w3.org/2002/xforms/implementation" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xxf="http://orbeon.org/oxf/xml/xforms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<meta:metadata xmlns:es="http://www.ecmascript.org/" xmlns:xqx="http://www.w3.org/2005/XQueryX" xmlns:XSLT="http://www.w3.org/1999/XSL/Transform/compile">
<meta:form-name>2021-CORE-IR-GN</meta:form-name>
<meta:document-id>166fc004-392e-47a8-acb8-1c018734882b</meta:document-id>
<meta:owner-user-id>e29c492473446dca4d50224f2bb7cf965a261d6f</meta:owner-user-id>
<meta:owner-institution-id>26139d1be7a44ebb1af23d3f8882c14025e9903c</meta:owner-institution-id>
<meta:managing-institution-id>26139d1be7a44ebb1af23d3f8882c14025e9903c</meta:managing-institution-id>
<meta:created-date>2022-04-12T14:10:59.953121Z</meta:created-date>
<meta:modified-date>2022-04-12T14:10:59.953121Z</meta:modified-date>
<meta:status>submitted-valid</meta:status>
<meta:reporting-year>2021</meta:reporting-year>
<meta:upload-method>Manual Entry</meta:upload-method>
<meta:schema assert-valid="true"/>
<meta:rules assert-valid="true"/>
</meta:metadata>
<Group>
<Qdp>Yes</Qdp>
<IRProduct>2 London Living Rent</IRProduct>
<IRProductOther/>
<KeyDate>2021-11-10</KeyDate>
<FORM>300072</FORM>
<Landlord source-value="9">1 Private Registered Provider</Landlord>
<Group>
<_1btenagree>1 This Landlord</_1btenagree>
<_1bifanother/>
<_1bCOREcode/>
</Group>
</Group>
<Group>
<_2a>2 No</_2a>
<Q2b>2 Assured</Q2b>
<Q2ba/>
<_2bTenCode>TEN0021</_2bTenCode>
<_2cYears/>
</Group>
<Group>
<P1Age override-field="">37</P1Age>
<P1AR/>
<P1Sex override-field="">Female</P1Sex>
<P1Eco>1) Full Time</P1Eco>
<P1Eth>1 White: English/Scottish/Welsh/Northern Irish/British</P1Eth>
<P1Nat>1 UK national resident in UK</P1Nat>
<P2Age override-field="">34</P2Age>
<P2AR/>
<P2Sex override-field="">Female</P2Sex>
<P2Rel>Other</P2Rel>
<P2Eco>1) Full Time</P2Eco>
<P3Age override-field=""/>
<P3AR/>
<P3Sex override-field=""/>
<P3Rel/>
<P3Eco/>
<P4Age override-field=""/>
<P4AR/>
<P4Sex override-field=""/>
<P4Rel/>
<P4Eco/>
<P5Age override-field=""/>
<P5AR/>
<P5Sex override-field=""/>
<P5Rel/>
<P5Eco/>
<P6Age override-field=""/>
<P6AR/>
<P6Sex override-field=""/>
<P6Rel/>
<P6Eco/>
<P7Age override-field=""/>
<P7AR/>
<P7Sex override-field=""/>
<P7Rel/>
<P7Eco/>
<P8Age override-field=""/>
<P8AR/>
<P8Sex override-field=""/>
<P8Rel/>
<P8Eco/>
<Group>
<ArmedF>2 No</ArmedF>
<LeftAF/>
<Inj/>
<Preg override-field="">2 No</Preg>
</Group>
<Group>
<Q6Ben>9 Not in receipt of either UC or HB</Q6Ben>
</Group>
<Group>
<Q7Ben>3 None</Q7Ben>
<Q8Refused/>
<Q8Money override-field="">200.00</Q8Money>
<Q8a>1 Weekly</Q8a>
</Group>
<Group>
<Q9a>8 (Non-violent) relationship breakdown with partner</Q9a>
<Q9aa/>
</Group>
<Group>
<_9b override-field="">2 No</_9b>
<Q10-a/>
<Q10-b/>
<Q10-c/>
<Q10-f/>
<Q10-g>Yes</Q10-g>
<Q10-h/>
<Q10ia>1 Yes</Q10ia>
<Q10ib-1/>
<Q10ib-2/>
<Q10ib-3/>
<Q10ib-4>Yes</Q10ib-4>
<Q10ib-5/>
<Q10ib-6/>
<Q10ib-7/>
<Q10ib-8/>
<Q10ib-9/>
<Q10ib-10/>
<Q11 override-field="">28 Living with friends or family</Q11>
<Q12a>Blackpool</Q12a>
<Q12aONS>E09000009</Q12aONS>
<Q12b override-field="">FY1 1JD</Q12b>
<Q12bnot/>
<Q12c>1 Just moved to Local Authority area</Q12c>
<Q12d>1 Just moved to Local Authority area</Q12d>
</Group>
<Group>
<Q13>1 Not homeless</Q13>
<Q14a>2 No</Q14a>
<Q14b1/>
<Q14b2/>
<Q14b3/>
<Q14b4/>
<Q14b5/>
</Group>
<Group>
<Q15CBL>2 No</Q15CBL>
<Q15CHR>2 No</Q15CHR>
<Q15CAP>2 No</Q15CAP>
</Group>
<Group>
<Q16>10 Other social landlord</Q16>
</Group>
</Group>
<Group>
<Q17>1 Weekly for 52 weeks</Q17>
<Q18ai override-field="">100.00</Q18ai>
<Q18aii override-field=""/>
<Q18aiii override-field=""/>
<Q18aiv override-field=""/>
<Q18av override-field="">100.00</Q18av>
<Q18d/>
<Q18dyes override-field=""/>
<Q19void>2021-04-15</Q19void>
<Q19repair/>
<Q20 override-field="">0</Q20>
<Q21a>PROPREF0042</Q21a>
</Group>
<Group>
<Q22 override-field="">2</Q22>
<Q23>1 Flat / maisonette</Q23>
<Q24>1 Purpose built</Q24>
<Q25>2 No</Q25>
<Q26>4 An Intermediate Rent basis</Q26>
<Q27>10 Relet - tenant evicted due to arrears</Q27>
</Group>
<Group>
<Q28Auth>Basingstoke &amp; Deane</Q28Auth>
<Q28ONS>E07000084</Q28ONS>
<Q28pc override-field="">RG21 3HU</Q28pc>
</Group>
<Group>
<F1Age>1</F1Age>
<F2Age>1</F2Age>
<F3Age>0</F3Age>
<F4Age>0</F4Age>
<F5Age>0</F5Age>
<F6Age>0</F6Age>
<F7Age>0</F7Age>
<F8Age>0</F8Age>
<FAge>2</FAge>
<F1>1</F1>
<F2>1</F2>
<F3>0</F3>
<F4>0</F4>
<F5>0</F5>
<F6>0</F6>
<F7>0</F7>
<F8>0</F8>
<F>2</F>
<P1100>0</P1100>
<P2100>0</P2100>
<P3100>0</P3100>
<P4100>0</P4100>
<P5100>0</P5100>
<P6100>0</P6100>
<P7100>0</P7100>
<P8100>0</P8100>
<_100>0</_100>
<P170>0</P170>
<P270>0</P270>
<P370>0</P370>
<P470>0</P470>
<P570>0</P570>
<P670>0</P670>
<P770>0</P770>
<P870>0</P870>
<_70>0</_70>
<P1PT>0</P1PT>
<P2PT>0</P2PT>
<P3PT>0</P3PT>
<P4PT>0</P4PT>
<P5PT>0</P5PT>
<P6PT>0</P6PT>
<P7PT>0</P7PT>
<P8PT>0</P8PT>
<PT>0</PT>
<P1FT>1</P1FT>
<P2FT>1</P2FT>
<P3FT>0</P3FT>
<P4FT>0</P4FT>
<P5FT>0</P5FT>
<P6FT>0</P6FT>
<P7FT>0</P7FT>
<P8FT>0</P8FT>
<FT>2</FT>
<P1Stud>0</P1Stud>
<P2Stud>0</P2Stud>
<P3Stud>0</P3Stud>
<P4Stud>0</P4Stud>
<P5Stud>0</P5Stud>
<P6Stud>0</P6Stud>
<P7Stud>0</P7Stud>
<P8Stud>0</P8Stud>
<Stud>0</Stud>
<P2Child>0</P2Child>
<P3Child>0</P3Child>
<P4Child>0</P4Child>
<P5Child>0</P5Child>
<P6Child>0</P6Child>
<P7Child>0</P7Child>
<P8Child>0</P8Child>
<Child>0</Child>
<P2Partner>0</P2Partner>
<P3Partner>0</P3Partner>
<P4Partner>0</P4Partner>
<P5Partner>0</P5Partner>
<P6Partner>0</P6Partner>
<P7Partner>0</P7Partner>
<P8Partner>0</P8Partner>
<Partner>0</Partner>
<Q1bV1>0</Q1bV1>
<Q1bV2>0</Q1bV2>
<Q1bV3>1</Q1bV3>
<Q1bVT>1</Q1bVT>
<P1Adult>1</P1Adult>
<P2Adult>1</P2Adult>
<P3Adult>0</P3Adult>
<P4Adult>0</P4Adult>
<P5Adult>0</P5Adult>
<P6Adult>0</P6Adult>
<P7Adult>0</P7Adult>
<P8Adult>0</P8Adult>
<PAdultT>2</PAdultT>
<P2PAge>0</P2PAge>
<P3PAge>0</P3PAge>
<P4PAge>0</P4PAge>
<P5PAge>0</P5PAge>
<P6PAge>0</P6PAge>
<P7PAge>0</P7PAge>
<P8PAge>0</P8PAge>
<PAGE>37</PAGE>
<P2ChildAge>0</P2ChildAge>
<P3ChildAge>0</P3ChildAge>
<P4ChildAge>0</P4ChildAge>
<P5ChildAge>0</P5ChildAge>
<P6ChildAge>0</P6ChildAge>
<P7ChildAge>0</P7ChildAge>
<P8ChildAge>0</P8ChildAge>
<ChildAgeMin>0</ChildAgeMin>
<AgeDiff1>37</AgeDiff1>
<AgeDiff2>0</AgeDiff2>
<AgeDiff3>37</AgeDiff3>
<TODAY>2022-04-12Z</TODAY>
<FutureLimit>2022-04-27Z</FutureLimit>
<minmax1/>
<minmax2/>
<minmax3/>
<minmax4/>
<minmax5/>
<minmax6/>
<minmax7/>
<minmax8/>
<minmax9/>
<minmax0/>
<minmax10/>
<minmaxT/>
<Q10av>0</Q10av>
<Q10bv>0</Q10bv>
<Q10cv>0</Q10cv>
<Q10fv>0</Q10fv>
<Q10gv>20</Q10gv>
<Q10hv>0</Q10hv>
<Q10Validate>20</Q10Validate>
<Q2bv>C</Q2bv>
<P2Agev>1</P2Agev>
<P2Sexv>1</P2Sexv>
<P2Relv>1</P2Relv>
<P2Ecov>1</P2Ecov>
<P2valid>4</P2valid>
<P3Agev>0</P3Agev>
<P3Sexv>0</P3Sexv>
<P3Relv>0</P3Relv>
<P3Ecov>0</P3Ecov>
<P3valid>0</P3valid>
<P4Agev>0</P4Agev>
<P4Sexv>0</P4Sexv>
<P4Relv>0</P4Relv>
<P4Ecov>0</P4Ecov>
<P4valid>0</P4valid>
<P5Agev>0</P5Agev>
<P5Sexv>0</P5Sexv>
<P5Relv>0</P5Relv>
<P5Ecov>0</P5Ecov>
<P5valid>0</P5valid>
<P6Agev>0</P6Agev>
<P6Sexv>0</P6Sexv>
<P6Relv>0</P6Relv>
<P6Ecov>0</P6Ecov>
<P6valid>0</P6valid>
<P7Agev>0</P7Agev>
<P7Sexv>0</P7Sexv>
<P7Relv>0</P7Relv>
<P7Ecov>0</P7Ecov>
<P7valid>0</P7valid>
<P8Agev>0</P8Agev>
<P8Sexv>0</P8Sexv>
<P8Relv>0</P8Relv>
<P8Ecov>0</P8Ecov>
<P8valid>0</P8valid>
<Q14b1v>0</Q14b1v>
<Q14b2v>0</Q14b2v>
<Q14b3v>0</Q14b3v>
<Q14b4v>0</Q14b4v>
<Q14b5v>0</Q14b5v>
<Q14bv>0</Q14bv>
<P2Other>1</P2Other>
<P3Other>0</P3Other>
<P4Other>0</P4Other>
<P5Other>0</P5Other>
<P6Other>0</P6Other>
<P7Other>0</P7Other>
<P8Other>0</P8Other>
<Other>1</Other>
<P2ARefused>0</P2ARefused>
<P3ARefused>0</P3ARefused>
<P4ARefused>0</P4ARefused>
<P5ARefused>0</P5ARefused>
<P6ARefused>0</P6ARefused>
<P7ARefused>0</P7ARefused>
<P8ARefused>0</P8ARefused>
<TAREUSED>0</TAREUSED>
<P2RRefused>0</P2RRefused>
<P3RRefused>0</P3RRefused>
<P4RRefused>0</P4RRefused>
<P5RRefused>0</P5RRefused>
<P6RRefused>0</P6RRefused>
<P7RRefused>0</P7RRefused>
<P8RRefused>0</P8RRefused>
<TotRRefused>0</TotRRefused>
<TOTREFUSED>0</TOTREFUSED>
</Group>
<Group>
<TOTADULT>2</TOTADULT>
<NEW_OLD>2 Existing Tenant</NEW_OLD>
<Q18aValid>1</Q18aValid>
<Q18Valid>1</Q18Valid>
<VACDAYS>209</VACDAYS>
<HHMEMB>2</HHMEMB>
<HHTYPEP1A>1</HHTYPEP1A>
<HHTYPEP2A>1</HHTYPEP2A>
<HHTYPEP3A>0</HHTYPEP3A>
<HHTYPEP4A>0</HHTYPEP4A>
<HHTYPEP5A>0</HHTYPEP5A>
<HHTYPEP6A>0</HHTYPEP6A>
<HHTYPEP7A>0</HHTYPEP7A>
<HHTYPEP8A>0</HHTYPEP8A>
<TADULT>2</TADULT>
<HHTYPEP1E>0</HHTYPEP1E>
<HHTYPEP2E>0</HHTYPEP2E>
<HHTYPEP3E>0</HHTYPEP3E>
<HHTYPEP4E>0</HHTYPEP4E>
<HHTYPEP5E>0</HHTYPEP5E>
<HHTYPEP6E>0</HHTYPEP6E>
<HHTYPEP7E>0</HHTYPEP7E>
<HHTYPEP8E>0</HHTYPEP8E>
<TELDER>0</TELDER>
<HHTYPEP1C>0</HHTYPEP1C>
<HHTYPEP2C>0</HHTYPEP2C>
<HHTYPEP3C>0</HHTYPEP3C>
<HHTYPEP4C>0</HHTYPEP4C>
<HHTYPEP5C>0</HHTYPEP5C>
<HHTYPEP6C>0</HHTYPEP6C>
<HHTYPEP7C>0</HHTYPEP7C>
<HHTYPEP8C>0</HHTYPEP8C>
<TCHILD>0</TCHILD>
<HHTYPE>4 = 2 adults</HHTYPE>
<WEEKLYINC>200.00</WEEKLYINC>
<INCOME>200.00</INCOME>
<TYPEHB>13</TYPEHB>
<AFFRATE/>
<Weekinc>200.00</Weekinc>
<LETTYPE>1 Private Registered Provider</LETTYPE>
<PLOACODE/>
<OACODE/>
<GOVREG>E12000008</GOVREG>
<OWNINGORGID>107138</OWNINGORGID>
<OWNINGORGNAME>1 Test</OWNINGORGNAME>
<MANINGORGNAME>1 Test</MANINGORGNAME>
<HCNUM>655</HCNUM>
<MANHCNUM>655</MANHCNUM>
<LAHA/>
<MANINGORGID>107138</MANINGORGID>
<HBTYPE1/>
<HBTYPE2/>
<HBTYPE3/>
<HBTYPE4/>
<HBTYPE5/>
<HBTYPE6/>
<HBTYPE7/>
<HBTYPE8/>
<HBTYPE9/>
<HBTYPE10/>
<HBTYPE11/>
<HBTYPE12/>
<HBTYPE13>13</HBTYPE13>
<HBTYPE14/>
<HBTYPE15/>
<HBTYPE>13</HBTYPE>
<P1R>0</P1R>
<P2R>0</P2R>
<P3R>0</P3R>
<P4R>0</P4R>
<P5R>0</P5R>
<P6R>0</P6R>
<P7R>0</P7R>
<P8R>0</P8R>
<REFUSEDTOT>0</REFUSEDTOT>
<REFUSED/>
<WTSHORTFALL/>
<WRENT>100.00</WRENT>
<WTCHARGE>100.00</WTCHARGE>
<WSCHARGE/>
<WPSCHRGE/>
<WSUPCHRG/>
<ChildBen>0.00</ChildBen>
<WTSHORTFALL1/>
<WTSHORTFALLHB/>
<WTSHORTFALLHE/>
<WRENT1>100.00</WRENT1>
<WTCHARGE1>100.00</WTCHARGE1>
<WSCHARGE1/>
<WPSCHRGE1/>
<WSUPCHRG1/>
<ChildBen1>0</ChildBen1>
</Group>
<Group>
<BSa>0</BSa>
<BSb>2</BSb>
<BSc>0</BSc>
<BScm>0</BScm>
<BScf>0</BScf>
<BSd>0</BSd>
<BSdm>0</BSdm>
<BSdf>0</BSdf>
<BSe>0</BSe>
<BSem>0</BSem>
<BSef>0</BSef>
<BSf>0</BSf>
<BSfm>0</BSfm>
<BSff>0</BSff>
<BSfmx>0</BSfmx>
<BSffx>0</BSffx>
<BEDROOMSTAND>2</BEDROOMSTAND>
<BEDMINUSBEDS>0</BEDMINUSBEDS>
<WRENTreduced>100.00</WRENTreduced>
<NonDepDeduct>23.35</NonDepDeduct>
<RENTHB/>
<ChildAllowan>0</ChildAllowan>
<PrsnlAllowan>0</PrsnlAllowan>
<HousBenDisAl>0</HousBenDisAl>
<PAIDHB/>
<HCNETAF/>
<ChldAlloCat1>0</ChldAlloCat1>
<ChldAlloCat2>0</ChldAlloCat2>
<P2NnDepDedct>23.35</P2NnDepDedct>
<P3NnDepDedct>0</P3NnDepDedct>
<P4NnDepDedct>0</P4NnDepDedct>
<P5NnDepDedct>0</P5NnDepDedct>
<P6NnDepDedct>0</P6NnDepDedct>
<P7NnDepDedct>0</P7NnDepDedct>
<P8NnDepDedct>0</P8NnDepDedct>
<DAY>10</DAY>
<MONTH>11</MONTH>
<YEAR>2021</YEAR>
<VDAY>15</VDAY>
<VMONTH>4</VMONTH>
<VYEAR>2021</VYEAR>
<MRCDAY/>
<MRCMONTH/>
<MRCYEAR/>
<PPOSTC1>FY1</PPOSTC1>
<PPOSTC2>1JD</PPOSTC2>
<POSTCODE/>
<POSTCOD2/>
</Group>
</Group>

2
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

2
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")

2
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,
)

206
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

2
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

24
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

8
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

12
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

24
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

50
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

94
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"])

24
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"])

20
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

22
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

8
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

34
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
Loading…
Cancel
Save