Browse Source

CLDC-3092 Update nationality question for 24/25 (#2193)

* Add new nationality columns

* Add nationality questions to lettings

* Add nationality questions to sales

* Infer nationality where appropriate

* Add synonyms

* Update csv exports

* Export nationality_all for 24/25

* Update prefers not to say value

* Set 24/25 nationality fields from BU

* Undo the export (there's a separate ticket)

* Correctly display answers

* Rebase fixes, tests and lint

* Set nationality from lettings BU 24/25

* Rename files, add synonyms and accents

* Fix sales csvs

* Extract constant
pull/2217/head
kosiakkatrina 11 months ago committed by GitHub
parent
commit
dc92466139
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 206
      app/constants/global_constants.rb
  2. 11
      app/helpers/question_view_helper.rb
  3. 2
      app/models/derived_variables/lettings_log_variables.rb
  4. 3
      app/models/derived_variables/sales_log_variables.rb
  5. 9
      app/models/form/lettings/pages/lead_tenant_nationality.rb
  6. 16
      app/models/form/lettings/questions/nationality_all.rb
  7. 21
      app/models/form/lettings/questions/nationality_all_group.rb
  8. 25
      app/models/form/sales/pages/buyer1_nationality.rb
  9. 9
      app/models/form/sales/pages/buyer2_nationality.rb
  10. 18
      app/models/form/sales/pages/nationality1.rb
  11. 2
      app/models/form/sales/questions/buyer1_nationality.rb
  12. 15
      app/models/form/sales/questions/nationality_all.rb
  13. 20
      app/models/form/sales/questions/nationality_all_group.rb
  14. 2
      app/models/form/sales/subsections/household_characteristics.rb
  15. 4
      app/models/log.rb
  16. 4
      app/models/sales_log.rb
  17. 13
      app/services/bulk_upload/lettings/year2024/row_parser.rb
  18. 20
      app/services/bulk_upload/sales/year2024/row_parser.rb
  19. 2
      app/services/csv/lettings_log_csv_service.rb
  20. 2
      app/services/csv/sales_log_csv_service.rb
  21. 2
      app/views/form/_select_question.html.erb
  22. 14
      db/migrate/20240130084707_add_nationality_all.rb
  23. 8
      db/schema.rb
  24. 4
      spec/fixtures/files/lettings_log_csv_export_codes.csv
  25. 4
      spec/fixtures/files/lettings_log_csv_export_labels.csv
  26. 4
      spec/fixtures/files/lettings_log_csv_export_non_support_codes.csv
  27. 4
      spec/fixtures/files/lettings_log_csv_export_non_support_labels.csv
  28. 4
      spec/fixtures/files/sales_logs_csv_export_codes.csv
  29. 4
      spec/fixtures/files/sales_logs_csv_export_labels.csv
  30. 39
      spec/models/form/lettings/questions/nationality_all_group_spec.rb
  31. 35
      spec/models/form/lettings/questions/nationality_all_spec.rb
  32. 18
      spec/models/form/sales/pages/buyer1_nationality_spec.rb
  33. 16
      spec/models/form/sales/pages/buyer2_nationality_spec.rb
  34. 2
      spec/models/form/sales/questions/buyer1_nationality_spec.rb
  35. 89
      spec/models/form/sales/questions/nationality_all_group_spec.rb
  36. 73
      spec/models/form/sales/questions/nationality_all_spec.rb
  37. 37
      spec/models/lettings_log_spec.rb
  38. 19
      spec/models/sales_log_spec.rb
  39. 74
      spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb
  40. 146
      spec/services/bulk_upload/sales/year2024/row_parser_spec.rb

206
app/constants/global_constants.rb

@ -1,3 +1,209 @@
module GlobalConstants
HELPDESK_URL = "https://dluhcdigital.atlassian.net/servicedesk/customer/portal/6/group/11".freeze
COUNTRIES_ANSWER_OPTIONS = {
"" => "Select an option",
"4" => { "name" => "Afghanistan", "synonyms" => "AF" },
"8" => { "name" => "Albania", "synonyms" => "AL" },
"12" => { "name" => "Algeria", "synonyms" => "DZ" },
"20" => { "name" => "Andorra", "synonyms" => "AD" },
"24" => { "name" => "Angola", "synonyms" => "AO" },
"28" => { "name" => "Antigua and Barbuda", "synonyms" => "AG" },
"32" => { "name" => "Argentina", "synonyms" => "AR" },
"51" => { "name" => "Armenia", "synonyms" => "AM" },
"36" => { "name" => "Australia", "synonyms" => "AU" },
"40" => { "name" => "Austria", "synonyms" => "AT" },
"31" => { "name" => "Azerbaijan", "synonyms" => "AZ" },
"44" => { "name" => "Bahamas", "synonyms" => "" },
"48" => { "name" => "Bahrain", "synonyms" => "BH" },
"50" => { "name" => "Bangladesh", "synonyms" => "BD" },
"52" => { "name" => "Barbados", "synonyms" => "BB" },
"112" => { "name" => "Belarus", "synonyms" => "BY" },
"56" => { "name" => "Belgium", "synonyms" => "BE" },
"84" => { "name" => "Belize", "synonyms" => "BZ" },
"204" => { "name" => "Benin", "synonyms" => "BJ" },
"64" => { "name" => "Bhutan", "synonyms" => "BT" },
"68" => { "name" => "Bolivia", "synonyms" => "BO" },
"70" => { "name" => "Bosnia and Herzegovina", "synonyms" => "BA" },
"72" => { "name" => "Botswana", "synonyms" => "BW" },
"76" => { "name" => "Brazil", "synonyms" => "BR" },
"96" => { "name" => "Brunei", "synonyms" => "BN" },
"100" => { "name" => "Bulgaria", "synonyms" => "BG" },
"854" => { "name" => "Burkina Faso", "synonyms" => "BF" },
"108" => { "name" => "Burundi", "synonyms" => "BI" },
"132" => { "name" => "Cabo Verde", "synonyms" => "" },
"116" => { "name" => "Cambodia", "synonyms" => "KH" },
"120" => { "name" => "Cameroon", "synonyms" => "CM" },
"124" => { "name" => "Canada", "synonyms" => "CA" },
"140" => { "name" => "Central African Republic", "synonyms" => "CF" },
"148" => { "name" => "Chad", "synonyms" => "TD" },
"152" => { "name" => "Chile", "synonyms" => "CL" },
"156" => { "name" => "China", "synonyms" => "CN" },
"170" => { "name" => "Colombia", "synonyms" => "CO" },
"174" => { "name" => "Comoros", "synonyms" => "KM" },
"178" => { "name" => "Congo", "synonyms" => "CG" },
"188" => { "name" => "Costa Rica", "synonyms" => "CR" },
"384" => { "name" => "Côte d'Ivoire", "synonyms" => "" },
"191" => { "name" => "Croatia", "synonyms" => "HR" },
"192" => { "name" => "Cuba", "synonyms" => "CU" },
"196" => { "name" => "Cyprus", "synonyms" => "CY" },
"203" => { "name" => "Czechia", "synonyms" => "CZ" },
"180" => { "name" => "Democratic Republic of the Congo", "synonyms" => "" },
"208" => { "name" => "Denmark", "synonyms" => "DK" },
"262" => { "name" => "Djibouti", "synonyms" => "DJ" },
"212" => { "name" => "Dominica", "synonyms" => "DM" },
"214" => { "name" => "Dominican Republic", "synonyms" => "DO" },
"218" => { "name" => "Ecuador", "synonyms" => "EC" },
"818" => { "name" => "Egypt", "synonyms" => "EG" },
"222" => { "name" => "El Salvador", "synonyms" => "SV" },
"226" => { "name" => "Equatorial Guinea", "synonyms" => "GQ" },
"232" => { "name" => "Eritrea", "synonyms" => "ER" },
"233" => { "name" => "Estonia", "synonyms" => "EE" },
"748" => { "name" => "Eswatini", "synonyms" => "SZ" },
"231" => { "name" => "Ethiopia", "synonyms" => "ET" },
"238" => { "name" => "Falkland Islands", "synonyms" => "" },
"242" => { "name" => "Fiji", "synonyms" => "FJ" },
"246" => { "name" => "Finland", "synonyms" => "FI" },
"250" => { "name" => "France", "synonyms" => "FR" },
"266" => { "name" => "Gabon", "synonyms" => "GA" },
"270" => { "name" => "Gambia", "synonyms" => "" },
"268" => { "name" => "Georgia", "synonyms" => "GE" },
"276" => { "name" => "Germany", "synonyms" => "DE" },
"288" => { "name" => "Ghana", "synonyms" => "GH" },
"292" => { "name" => "Gibraltar", "synonyms" => "" },
"300" => { "name" => "Greece", "synonyms" => "GR" },
"308" => { "name" => "Grenada", "synonyms" => "GD" },
"320" => { "name" => "Guatemala", "synonyms" => "GT" },
"831" => { "name" => "Guernsey", "synonyms" => "" },
"324" => { "name" => "Guinea", "synonyms" => "GN" },
"624" => { "name" => "Guinea-Bissau", "synonyms" => "GW" },
"328" => { "name" => "Guyana", "synonyms" => "GY" },
"332" => { "name" => "Haiti", "synonyms" => "HT" },
"340" => { "name" => "Honduras", "synonyms" => "HN" },
"344" => { "name" => "Hong Kong", "synonyms" => "" },
"348" => { "name" => "Hungary", "synonyms" => "HU" },
"352" => { "name" => "Iceland", "synonyms" => "IS" },
"356" => { "name" => "India", "synonyms" => "IN" },
"360" => { "name" => "Indonesia", "synonyms" => "ID" },
"364" => { "name" => "Iran", "synonyms" => "IR" },
"368" => { "name" => "Iraq", "synonyms" => "IQ" },
"372" => { "name" => "Ireland", "synonyms" => "IE" },
"833" => { "name" => "Isle of Man", "synonyms" => "" },
"376" => { "name" => "Israel", "synonyms" => "IL" },
"380" => { "name" => "Italy", "synonyms" => "IT" },
"388" => { "name" => "Jamaica", "synonyms" => "JM" },
"392" => { "name" => "Japan", "synonyms" => "JP" },
"832" => { "name" => "Jersey", "synonyms" => "" },
"400" => { "name" => "Jordan", "synonyms" => "JO" },
"398" => { "name" => "Kazakhstan", "synonyms" => "KZ" },
"404" => { "name" => "Kenya", "synonyms" => "KE" },
"296" => { "name" => "Kiribati", "synonyms" => "KI" },
"414" => { "name" => "Kuwait", "synonyms" => "KW" },
"417" => { "name" => "Kyrgyzstan", "synonyms" => "KG" },
"418" => { "name" => "Laos", "synonyms" => "LA" },
"428" => { "name" => "Latvia", "synonyms" => "LV" },
"422" => { "name" => "Lebanon", "synonyms" => "LB" },
"426" => { "name" => "Lesotho", "synonyms" => "LS" },
"430" => { "name" => "Liberia", "synonyms" => "LR" },
"434" => { "name" => "Libya", "synonyms" => "LY" },
"438" => { "name" => "Liechtenstein", "synonyms" => "LI" },
"440" => { "name" => "Lithuania", "synonyms" => "LT" },
"442" => { "name" => "Luxembourg", "synonyms" => "LU" },
"450" => { "name" => "Madagascar", "synonyms" => "MG" },
"454" => { "name" => "Malawi", "synonyms" => "MW" },
"458" => { "name" => "Malaysia", "synonyms" => "MY" },
"462" => { "name" => "Maldives", "synonyms" => "MV" },
"466" => { "name" => "Mali", "synonyms" => "ML" },
"470" => { "name" => "Malta", "synonyms" => "MT" },
"584" => { "name" => "Marshall Islands", "synonyms" => "MH" },
"478" => { "name" => "Mauritania", "synonyms" => "MR" },
"480" => { "name" => "Mauritius", "synonyms" => "MU" },
"484" => { "name" => "Mexico", "synonyms" => "MX" },
"583" => { "name" => "Micronesia (Federated States of)", "synonyms" => "" },
"498" => { "name" => "Moldova", "synonyms" => "MD" },
"492" => { "name" => "Monaco", "synonyms" => "MC" },
"496" => { "name" => "Mongolia", "synonyms" => "MN" },
"499" => { "name" => "Montenegro", "synonyms" => "ME" },
"504" => { "name" => "Morocco", "synonyms" => "MA" },
"508" => { "name" => "Mozambique", "synonyms" => "MZ" },
"104" => { "name" => "Myanmar", "synonyms" => "" },
"516" => { "name" => "Namibia", "synonyms" => "NA" },
"520" => { "name" => "Nauru", "synonyms" => "NR" },
"524" => { "name" => "Nepal", "synonyms" => "NP" },
"528" => { "name" => "Netherlands", "synonyms" => "NL" },
"554" => { "name" => "New Zealand", "synonyms" => "NZ" },
"558" => { "name" => "Nicaragua", "synonyms" => "NI" },
"562" => { "name" => "Niger", "synonyms" => "NE" },
"566" => { "name" => "Nigeria", "synonyms" => "NG" },
"807" => { "name" => "North Macedonia", "synonyms" => "MK" },
"408" => { "name" => "North Korea", "synonyms" => "KP" },
"578" => { "name" => "Norway", "synonyms" => "NO" },
"512" => { "name" => "Oman", "synonyms" => "OM" },
"586" => { "name" => "Pakistan", "synonyms" => "PK" },
"585" => { "name" => "Palau", "synonyms" => "PW" },
"275" => { "name" => "Palestine, State of", "synonyms" => "" },
"591" => { "name" => "Panama", "synonyms" => "PA" },
"598" => { "name" => "Papua New Guinea", "synonyms" => "PG" },
"600" => { "name" => "Paraguay", "synonyms" => "PY" },
"604" => { "name" => "Peru", "synonyms" => "PE" },
"608" => { "name" => "Philippines", "synonyms" => "PH" },
"616" => { "name" => "Poland", "synonyms" => "PL" },
"620" => { "name" => "Portugal", "synonyms" => "PT" },
"634" => { "name" => "Qatar", "synonyms" => "QA" },
"642" => { "name" => "Romania", "synonyms" => "RO" },
"643" => { "name" => "Russia", "synonyms" => "RU" },
"646" => { "name" => "Rwanda", "synonyms" => "RW" },
"659" => { "name" => "Saint Kitts and Nevis", "synonyms" => "" },
"662" => { "name" => "Saint Lucia", "synonyms" => "" },
"670" => { "name" => "Saint Vincent and the Grenadines", "synonyms" => "" },
"882" => { "name" => "Samoa", "synonyms" => "WS" },
"674" => { "name" => "San Marino", "synonyms" => "SM" },
"678" => { "name" => "São Tomé and Príncipe", "synonyms" => "ST,Sao Tome and Principe" },
"682" => { "name" => "Saudi Arabia", "synonyms" => "SA" },
"686" => { "name" => "Senegal", "synonyms" => "SN" },
"688" => { "name" => "Serbia", "synonyms" => "RS" },
"690" => { "name" => "Seychelles", "synonyms" => "SC" },
"694" => { "name" => "Sierra Leone", "synonyms" => "SL" },
"702" => { "name" => "Singapore", "synonyms" => "SG" },
"703" => { "name" => "Slovakia", "synonyms" => "SK" },
"705" => { "name" => "Slovenia", "synonyms" => "SI" },
"90" => { "name" => "Solomon Islands", "synonyms" => "SB" },
"706" => { "name" => "Somalia", "synonyms" => "SO" },
"710" => { "name" => "South Africa", "synonyms" => "ZA" },
"410" => { "name" => "South Korea", "synonyms" => "KR" },
"728" => { "name" => "South Sudan", "synonyms" => "SS" },
"724" => { "name" => "Spain", "synonyms" => "ES" },
"144" => { "name" => "Sri Lanka", "synonyms" => "LK" },
"729" => { "name" => "Sudan", "synonyms" => "SD" },
"740" => { "name" => "Suriname", "synonyms" => "SR" },
"752" => { "name" => "Sweden", "synonyms" => "SE" },
"756" => { "name" => "Switzerland", "synonyms" => "CH" },
"760" => { "name" => "Syria", "synonyms" => "SY" },
"158" => { "name" => "Taiwan", "synonyms" => "" },
"762" => { "name" => "Tajikistan", "synonyms" => "TJ" },
"834" => { "name" => "Tanzania", "synonyms" => "TZ" },
"764" => { "name" => "Thailand", "synonyms" => "TH" },
"626" => { "name" => "Timor-Leste", "synonyms" => "" },
"768" => { "name" => "Togo", "synonyms" => "TG" },
"776" => { "name" => "Tonga", "synonyms" => "TO" },
"780" => { "name" => "Trinidad and Tobago", "synonyms" => "TT" },
"788" => { "name" => "Tunisia", "synonyms" => "TN" },
"792" => { "name" => "Turkey", "synonyms" => "TR" },
"795" => { "name" => "Turkmenistan", "synonyms" => "TM" },
"798" => { "name" => "Tuvalu", "synonyms" => "TV" },
"800" => { "name" => "Uganda", "synonyms" => "UG" },
"804" => { "name" => "Ukraine", "synonyms" => "UA" },
"784" => { "name" => "United Arab Emirates", "synonyms" => "AE" },
"826" => { "name" => "United Kingdom", "synonyms" => "GB,UK,England,Wales,Scotland,Northern Ireland,Great Britain" },
"840" => { "name" => "United States of America", "synonyms" => "US,USA" },
"858" => { "name" => "Uruguay", "synonyms" => "UY" },
"860" => { "name" => "Uzbekistan", "synonyms" => "UZ" },
"548" => { "name" => "Vanuatu", "synonyms" => "VU" },
"336" => { "name" => "Vatican City", "synonyms" => "VA" },
"862" => { "name" => "Venezuela", "synonyms" => "VE" },
"704" => { "name" => "Vietnam", "synonyms" => "VN" },
"887" => { "name" => "Yemen", "synonyms" => "YE" },
"894" => { "name" => "Zambia", "synonyms" => "ZM" },
"716" => { "name" => "Zimbabwe", "synonyms" => "ZW" },
}.freeze
end

11
app/helpers/question_view_helper.rb

@ -14,9 +14,13 @@ module QuestionViewHelper
end
def answer_option_synonyms(resource)
return unless resource.instance_of?(Scheme)
return unless resource.instance_of?(Scheme) || resource.is_a?(Hash)
if resource.instance_of?(Scheme)
resource.locations.map(&:postcode).join(",")
else
resource["synonyms"]
end
end
def answer_option_append(resource)
@ -33,6 +37,11 @@ module QuestionViewHelper
[resource.primary_client_group, resource.secondary_client_group].compact.join(", ")
end
def select_option_name(value)
return value.service_name if value.respond_to?(:service_name)
return value["name"] if value.is_a?(Hash) && value["name"].present?
end
private
def label_size(page_header, conditional, question)

2
app/models/derived_variables/lettings_log_variables.rb

@ -115,6 +115,8 @@ module DerivedVariables::LettingsLogVariables
self.uprn_known = 0
end
self.nationality_all = nationality_all_group if nationality_uk_or_prefers_not_to_say?
reset_address_fields! if is_supported_housing?
end

3
app/models/derived_variables/sales_log_variables.rb

@ -35,6 +35,9 @@ module DerivedVariables::SalesLogVariables
self.uprn_known = 0
end
self.nationality_all = nationality_all_group if nationality_uk_or_prefers_not_to_say?
self.nationality_all_buyer2 = nationality_all_buyer2_group if nationality2_uk_or_prefers_not_to_say?
set_encoded_derived_values!(DEPENDENCIES)
end

9
app/models/form/lettings/pages/lead_tenant_nationality.rb

@ -6,6 +6,13 @@ class Form::Lettings::Pages::LeadTenantNationality < ::Form::Page
end
def questions
@questions ||= [Form::Lettings::Questions::Nationality.new(nil, nil, self)]
@questions ||= if form.start_year_after_2024?
[
Form::Lettings::Questions::NationalityAllGroup.new(nil, nil, self),
Form::Lettings::Questions::NationalityAll.new(nil, nil, self),
]
else
[Form::Lettings::Questions::Nationality.new(nil, nil, self)]
end
end
end

16
app/models/form/lettings/questions/nationality_all.rb

@ -0,0 +1,16 @@
class Form::Lettings::Questions::NationalityAll < ::Form::Question
def initialize(id, hsh, page)
super
@id = "nationality_all"
@check_answer_label = "Lead tenant’s nationality"
@header = "Enter a nationality"
@type = "select"
@check_answers_card_number = 1
@answer_options = GlobalConstants::COUNTRIES_ANSWER_OPTIONS
@question_number = 36
end
def answer_label(log, _current_user = nil)
answer_options[log.nationality_all.to_s]["name"]
end
end

21
app/models/form/lettings/questions/nationality_all_group.rb

@ -0,0 +1,21 @@
class Form::Lettings::Questions::NationalityAllGroup < ::Form::Question
def initialize(id, hsh, page)
super
@id = "nationality_all_group"
@check_answer_label = "Lead tenant’s nationality"
@header = "What is the nationality of the lead tenant?"
@type = "radio"
@check_answers_card_number = 1
@hint_text = "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest."
@answer_options = ANSWER_OPTIONS
@question_number = 36
@conditional_for = { "nationality_all" => [12] }
@hidden_in_check_answers = { "depends_on" => [{ "nationality_all_group" => 12 }] }
end
ANSWER_OPTIONS = {
"826" => { "value" => "United Kingdom" },
"12" => { "value" => "Other" },
"0" => { "value" => "Tenant prefers not to say" },
}.freeze
end

25
app/models/form/sales/pages/buyer1_nationality.rb

@ -0,0 +1,25 @@
class Form::Sales::Pages::Buyer1Nationality < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_1_nationality"
@depends_on = [
{
"buyer_has_seen_privacy_notice?" => true,
},
{
"buyer_not_interviewed?" => true,
},
]
end
def questions
@questions ||= if form.start_year_after_2024?
[
Form::Sales::Questions::NationalityAllGroup.new("nationality_all_group", nil, self, 1),
Form::Sales::Questions::NationalityAll.new("nationality_all", nil, self, 1),
]
else
[Form::Sales::Questions::Buyer1Nationality.new(nil, nil, self)]
end
end
end

9
app/models/form/sales/pages/buyer2_nationality.rb

@ -15,6 +15,13 @@ class Form::Sales::Pages::Buyer2Nationality < ::Form::Page
end
def questions
@questions ||= [Form::Sales::Questions::Buyer2Nationality.new(nil, nil, self)]
@questions ||= if form.start_year_after_2024?
[
Form::Sales::Questions::NationalityAllGroup.new("nationality_all_buyer2_group", nil, self, 2),
Form::Sales::Questions::NationalityAll.new("nationality_all_buyer2", nil, self, 2),
]
else
[Form::Sales::Questions::Buyer2Nationality.new(nil, nil, self)]
end
end
end

18
app/models/form/sales/pages/nationality1.rb

@ -1,18 +0,0 @@
class Form::Sales::Pages::Nationality1 < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_1_nationality"
@depends_on = [
{
"buyer_has_seen_privacy_notice?" => true,
},
{
"buyer_not_interviewed?" => true,
},
]
end
def questions
@questions ||= [Form::Sales::Questions::Nationality1.new(nil, nil, self)]
end
end

2
app/models/form/sales/questions/nationality1.rb → app/models/form/sales/questions/buyer1_nationality.rb

@ -1,4 +1,4 @@
class Form::Sales::Questions::Nationality1 < ::Form::Question
class Form::Sales::Questions::Buyer1Nationality < ::Form::Question
def initialize(id, hsh, page)
super
@id = "national"

15
app/models/form/sales/questions/nationality_all.rb

@ -0,0 +1,15 @@
class Form::Sales::Questions::NationalityAll < ::Form::Question
def initialize(id, hsh, page, buyer_index)
super(id, hsh, page)
@check_answer_label = "Buyer #{buyer_index}’s nationality"
@header = "Enter a nationality"
@type = "select"
@answer_options = GlobalConstants::COUNTRIES_ANSWER_OPTIONS
@check_answers_card_number = buyer_index
@question_number = buyer_index == 1 ? 24 : 32
end
def answer_label(log, _current_user = nil)
answer_options[log.send(id).to_s]["name"]
end
end

20
app/models/form/sales/questions/nationality_all_group.rb

@ -0,0 +1,20 @@
class Form::Sales::Questions::NationalityAllGroup < ::Form::Question
def initialize(id, hsh, page, buyer_index)
super(id, hsh, page)
@check_answer_label = "Buyer #{buyer_index}’s nationality"
@header = "What is buyer #{buyer_index}’s nationality?"
@type = "radio"
@hint_text = buyer_index == 1 ? "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." : ""
@answer_options = ANSWER_OPTIONS
@check_answers_card_number = buyer_index
@question_number = buyer_index == 1 ? 24 : 32
@conditional_for = buyer_index == 1 ? { "nationality_all" => [12] } : { "nationality_all_buyer2" => [12] }
@hidden_in_check_answers = { "depends_on" => [{ id => 12 }] }
end
ANSWER_OPTIONS = {
"826" => { "value" => "United Kingdom" },
"12" => { "value" => "Other" },
"0" => { "value" => "Buyer prefers not to say" },
}.freeze
end

2
app/models/form/sales/subsections/household_characteristics.rb

@ -21,7 +21,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::Buyer1EthnicBackgroundArab.new(nil, nil, self),
Form::Sales::Pages::Buyer1EthnicBackgroundMixed.new(nil, nil, self),
Form::Sales::Pages::Buyer1EthnicBackgroundWhite.new(nil, nil, self),
Form::Sales::Pages::Nationality1.new(nil, nil, self),
Form::Sales::Pages::Buyer1Nationality.new(nil, nil, self),
Form::Sales::Pages::Buyer1WorkingSituation.new(nil, nil, self),
Form::Sales::Pages::RetirementValueCheck.new("working_situation_1_retirement_value_check", nil, self, person_index: 1),
Form::Sales::Pages::Buyer1IncomeMinValueCheck.new("working_situation_buyer_1_income_min_value_check", nil, self),

4
app/models/log.rb

@ -209,6 +209,10 @@ class Log < ApplicationRecord
end
end
def nationality_uk_or_prefers_not_to_say?
nationality_all_group&.zero? || nationality_all_group == 826
end
private
# Handle logs that are older than previous collection start date

4
app/models/sales_log.rb

@ -473,4 +473,8 @@ class SalesLog < Log
def duplicates
SalesLog.where.not(duplicate_set_id: nil).where(duplicate_set_id:).where.not(id:)
end
def nationality2_uk_or_prefers_not_to_say?
nationality_all_buyer2_group&.zero? || nationality_all_buyer2_group == 826
end
end

13
app/services/bulk_upload/lettings/year2024/row_parser.rb

@ -906,7 +906,7 @@ private
ethnic_group: %i[field_44],
ethnic: %i[field_44],
national: %i[field_45],
nationality_all: %i[field_45],
relat2: %i[field_47],
relat3: %i[field_51],
@ -1079,7 +1079,8 @@ private
attributes["ethnic_group"] = ethnic_group_from_ethnic
attributes["ethnic"] = field_44
attributes["national"] = field_45
attributes["nationality_all"] = field_45
attributes["nationality_all_group"] = nationality_group(attributes["nationality_all"])
attributes["relat2"] = field_47
attributes["relat3"] = field_51
@ -1466,4 +1467,12 @@ private
0
end
end
def nationality_group(nationality_value)
return unless nationality_value
return 0 if nationality_value.zero?
return 826 if nationality_value == 826
12
end
end

20
app/services/bulk_upload/sales/year2024/row_parser.rb

@ -675,7 +675,8 @@ private
ecstat6: %i[field_60],
ethnic_group: %i[field_33],
ethnic: %i[field_33],
national: %i[field_34],
nationality_all: %i[field_34],
nationality_all_group: %i[field_34],
income1nk: %i[field_77],
income1: %i[field_77],
income2nk: %i[field_79],
@ -767,7 +768,8 @@ private
ethnic_group2: %i[field_40],
ethnicbuy2: %i[field_40],
nationalbuy2: %i[field_41],
nationality_all_buyer2: %i[field_41],
nationality_all_buyer2_group: %i[field_41],
buy2living: %i[field_70],
prevtenbuy2: %i[field_71],
@ -831,7 +833,8 @@ private
attributes["ethnic_group"] = ethnic_group_from_ethnic
attributes["ethnic"] = field_33
attributes["national"] = field_34
attributes["nationality_all"] = field_34
attributes["nationality_all_group"] = nationality_group(attributes["nationality_all"])
attributes["income1nk"] = field_77 == "R" ? 1 : 0
attributes["income1"] = field_77.to_i if attributes["income1nk"]&.zero? && field_77&.match(/\A\d+\z/)
@ -938,7 +941,8 @@ private
attributes["ethnic_group2"] = infer_buyer2_ethnic_group_from_ethnic
attributes["ethnicbuy2"] = field_40
attributes["nationalbuy2"] = field_41
attributes["nationality_all_buyer2"] = field_41
attributes["nationality_all_buyer2_group"] = nationality_group(attributes["nationality_all_buyer2"])
attributes["buy2living"] = field_70
attributes["prevtenbuy2"] = prevtenbuy2
@ -1202,6 +1206,14 @@ private
created_by&.organisation || bulk_upload.user.organisation
end
def nationality_group(nationality_value)
return unless nationality_value
return 0 if nationality_value.zero?
return 826 if nationality_value == 826
12
end
def validate_managing_org_related
if owning_organisation && managing_organisation && !owning_organisation.can_be_managed_by?(organisation: managing_organisation)
block_log_creation!

2
app/services/csv/lettings_log_csv_service.rb

@ -300,7 +300,7 @@ module Csv
def lettings_log_attributes
ordered_questions = FormHandler.instance.ordered_lettings_questions_for_all_years
ordered_questions.reject! { |q| q.id.match?(/age\d_known|rent_value_check/) }
ordered_questions.reject! { |q| q.id.match?(/age\d_known|rent_value_check|nationality_all_group/) }
attributes = ordered_questions.flat_map do |question|
if question.type == "checkbox"
question.answer_options.keys.reject { |key| key == "divider" }.map { |key|

2
app/services/csv/sales_log_csv_service.rb

@ -134,7 +134,7 @@ module Csv
def sales_log_attributes
ordered_questions = FormHandler.instance.ordered_sales_questions_for_all_years
ordered_questions.reject! { |q| q.id.match?(/((?<!la)_known)|(_check)|(_asked)/) }
ordered_questions.reject! { |q| q.id.match?(/((?<!la)_known)|(_check)|(_asked)|nationality_all_group|nationality_all_buyer2_group/) }
attributes = ordered_questions.flat_map do |question|
if question.type == "checkbox"
question.answer_options.keys

2
app/views/form/_select_question.html.erb

@ -1,6 +1,6 @@
<% selected = @log.public_send(question.id) || "" %>
<% answers = question.displayed_answer_options(@log, current_user).map { |key, value| OpenStruct.new(id: key, name: value.respond_to?(:service_name) ? value.service_name : nil, resource: value) } %>
<% answers = question.displayed_answer_options(@log, current_user).map { |key, value| OpenStruct.new(id: key, name: select_option_name(value), resource: value) } %>
<%= render partial: "form/guidance/#{question.top_guidance_partial}" if question.top_guidance? %>
<%= f.govuk_select(question.id.to_sym,

14
db/migrate/20240130084707_add_nationality_all.rb

@ -0,0 +1,14 @@
class AddNationalityAll < ActiveRecord::Migration[7.0]
def change
change_table :lettings_logs, bulk: true do |t|
t.column :nationality_all, :integer
t.column :nationality_all_group, :integer
end
change_table :sales_logs, bulk: true do |t|
t.column :nationality_all, :integer
t.column :nationality_all_group, :integer
t.column :nationality_all_buyer2, :integer
t.column :nationality_all_buyer2_group, :integer
end
end
end

8
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: 2024_01_18_183843) do
ActiveRecord::Schema[7.0].define(version: 2024_01_30_084707) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -303,6 +303,8 @@ ActiveRecord::Schema[7.0].define(version: 2024_01_18_183843) do
t.integer "scharge_value_check"
t.integer "pscharge_value_check"
t.integer "duplicate_set_id"
t.integer "nationality_all"
t.integer "nationality_all_group"
t.index ["bulk_upload_id"], name: "index_lettings_logs_on_bulk_upload_id"
t.index ["created_by_id"], name: "index_lettings_logs_on_created_by_id"
t.index ["location_id"], name: "index_lettings_logs_on_location_id"
@ -652,6 +654,10 @@ ActiveRecord::Schema[7.0].define(version: 2024_01_18_183843) do
t.datetime "values_updated_at"
t.bigint "managing_organisation_id"
t.integer "duplicate_set_id"
t.integer "nationality_all"
t.integer "nationality_all_group"
t.integer "nationality_all_buyer2"
t.integer "nationality_all_buyer2_group"
t.index ["bulk_upload_id"], name: "index_sales_logs_on_bulk_upload_id"
t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id"
t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id"

4
spec/fixtures/files/lettings_log_csv_export_codes.csv vendored

@ -1,2 +1,2 @@
id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,old_id,old_form_id,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,postcode_known,uprn_known,uprn,uprn_confirmed,address_line1,address_line2,town_or_city,county,postcode_full,is_la_inferred,la_label,la,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,pregnancy_value_check,refused,hhtype,totchild,totelder,totadult,age1,retirement_value_check,sex1,ethnic_group,ethnic,national,ecstat1,details_known_2,relat2,age2,sex2,ecstat2,details_known_3,relat3,age3,sex3,ecstat3,details_known_4,relat4,age4,sex4,ecstat4,details_known_5,relat5,age5,sex5,ecstat5,details_known_6,relat6,age6,sex6,ecstat6,details_known_7,relat7,age7,sex7,ecstat7,details_known_8,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,new_old,homeless,ppcodenk,ppostcode_full,previous_la_known,is_previous_la_inferred,prevloc_label,prevloc,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,referral_value_check,net_income_known,incref,earnings,incfreq,net_income_value_check,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,wrent,rent_value_check,scharge,wscharge,pscharge,wpschrge,supcharg,wsupchrg,tcharge,wtcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall_known,tshortfall,wtshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate
,completed,,s.port@jeemayle.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,1,,,2023,DLUHC,DLUHC,1,7,0,2023-11-26,2,2,1,,2,HIJKLMN,ABCDEFG,1,0,,,fake address,,London,,NW9 5LL,false,Barnet,E09000003,0,2,6,2,2,7,1,1,3,2023-11-24,,,1,2023-11-25,,3,1,4,,2,,1,4,,1,4,0,0,2,35,,F,0,2,13,0,0,P,32,M,6,1,R,-9,R,10,0,R,-9,R,10,,,,,,,,,,,,,,,,,,,,,1,4,1,2,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,2,7,4,,6,2,1,0,TN23 6LZ,1,false,Ashford,E07000105,1,0,1,0,0,0,0,0,1,,2,,0,0,268,1,,6,1,1,,0,2,,,,,200.0,100.0,,50.0,25.0,40.0,20.0,35.0,17.5,325.0,162.5,,,,1,0,12.0,6.0,,,,,,,,,,,,,,,,,,,,
id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,old_id,old_form_id,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,postcode_known,uprn_known,uprn,uprn_confirmed,address_line1,address_line2,town_or_city,county,postcode_full,is_la_inferred,la_label,la,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,pregnancy_value_check,refused,hhtype,totchild,totelder,totadult,age1,retirement_value_check,sex1,ethnic_group,ethnic,national,nationality_all,ecstat1,details_known_2,relat2,age2,sex2,ecstat2,details_known_3,relat3,age3,sex3,ecstat3,details_known_4,relat4,age4,sex4,ecstat4,details_known_5,relat5,age5,sex5,ecstat5,details_known_6,relat6,age6,sex6,ecstat6,details_known_7,relat7,age7,sex7,ecstat7,details_known_8,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,new_old,homeless,ppcodenk,ppostcode_full,previous_la_known,is_previous_la_inferred,prevloc_label,prevloc,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,referral_value_check,net_income_known,incref,earnings,incfreq,net_income_value_check,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,wrent,rent_value_check,scharge,wscharge,pscharge,wpschrge,supcharg,wsupchrg,tcharge,wtcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall_known,tshortfall,wtshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate
,completed,,s.port@jeemayle.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,1,,,2023,DLUHC,DLUHC,1,7,0,2023-11-26,2,2,1,,2,HIJKLMN,ABCDEFG,1,0,,,fake address,,London,,NW9 5LL,false,Barnet,E09000003,0,2,6,2,2,7,1,1,3,2023-11-24,,,1,2023-11-25,,3,1,4,,2,,1,4,,1,4,0,0,2,35,,F,0,2,13,,0,0,P,32,M,6,1,R,-9,R,10,0,R,-9,R,10,,,,,,,,,,,,,,,,,,,,,1,4,1,2,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,2,7,4,,6,2,1,0,TN23 6LZ,1,false,Ashford,E07000105,1,0,1,0,0,0,0,0,1,,2,,0,0,268,1,,6,1,1,,0,2,,,,,200.0,100.0,,50.0,25.0,40.0,20.0,35.0,17.5,325.0,162.5,,,,1,0,12.0,6.0,,,,,,,,,,,,,,,,,,,,

1 id status duplicate_set_id created_by is_dpo created_at updated_by updated_at creation_method old_id old_form_id collection_start_year owning_organisation_name managing_organisation_name needstype lettype renewal startdate renttype renttype_detail irproduct irproduct_other lar tenancycode propcode postcode_known uprn_known uprn uprn_confirmed address_line1 address_line2 town_or_city county postcode_full is_la_inferred la_label la first_time_property_let_as_social_housing unitletas rsnvac newprop offered unittype_gn builtype wchair beds voiddate vacdays void_date_value_check majorrepairs mrcdate major_repairs_date_value_check joint startertenancy tenancy tenancyother tenancylength sheltered declaration hhmemb pregnancy_value_check refused hhtype totchild totelder totadult age1 retirement_value_check sex1 ethnic_group ethnic national nationality_all ecstat1 details_known_2 relat2 age2 sex2 ecstat2 details_known_3 relat3 age3 sex3 ecstat3 details_known_4 relat4 age4 sex4 ecstat4 details_known_5 relat5 age5 sex5 ecstat5 details_known_6 relat6 age6 sex6 ecstat6 details_known_7 relat7 age7 sex7 ecstat7 details_known_8 relat8 age8 sex8 ecstat8 armedforces leftreg reservist preg_occ housingneeds housingneeds_type housingneeds_a housingneeds_b housingneeds_c housingneeds_f housingneeds_g housingneeds_h housingneeds_other illness illness_type_4 illness_type_5 illness_type_2 illness_type_6 illness_type_7 illness_type_3 illness_type_9 illness_type_8 illness_type_1 illness_type_10 layear waityear reason reasonother prevten new_old homeless ppcodenk ppostcode_full previous_la_known is_previous_la_inferred prevloc_label prevloc reasonpref rp_homeless rp_insan_unsat rp_medwel rp_hardship rp_dontknow cbl cap chr letting_allocation_none referral referral_value_check net_income_known incref earnings incfreq net_income_value_check hb has_benefits benefits household_charge nocharge period is_carehome chcharge wchchrg carehome_charges_value_check brent wrent rent_value_check scharge wscharge pscharge wpschrge supcharg wsupchrg tcharge wtcharge scharge_value_check pscharge_value_check supcharg_value_check hbrentshortfall tshortfall_known tshortfall wtshortfall scheme_code scheme_service_name scheme_sensitive SCHTYPE scheme_registered_under_care_act scheme_owning_organisation_name scheme_primary_client_group scheme_has_other_client_group scheme_secondary_client_group scheme_support_type scheme_intended_stay scheme_created_at location_code location_postcode location_name location_units location_type_of_unit location_mobility_type location_local_authority location_startdate
2 completed s.port@jeemayle.com false 2023-11-26T00:00:00+00:00 2023-11-26T00:00:00+00:00 1 2023 DLUHC DLUHC 1 7 0 2023-11-26 2 2 1 2 HIJKLMN ABCDEFG 1 0 fake address London NW9 5LL false Barnet E09000003 0 2 6 2 2 7 1 1 3 2023-11-24 1 2023-11-25 3 1 4 2 1 4 1 4 0 0 2 35 F 0 2 13 0 0 P 32 M 6 1 R -9 R 10 0 R -9 R 10 1 4 1 2 1 0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 2 7 4 6 2 1 0 TN23 6LZ 1 false Ashford E07000105 1 0 1 0 0 0 0 0 1 2 0 0 268 1 6 1 1 0 2 200.0 100.0 50.0 25.0 40.0 20.0 35.0 17.5 325.0 162.5 1 0 12.0 6.0

4
spec/fixtures/files/lettings_log_csv_export_labels.csv vendored

@ -1,2 +1,2 @@
id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,old_id,old_form_id,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,postcode_known,uprn_known,uprn,uprn_confirmed,address_line1,address_line2,town_or_city,county,postcode_full,is_la_inferred,la_label,la,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,pregnancy_value_check,refused,hhtype,totchild,totelder,totadult,age1,retirement_value_check,sex1,ethnic_group,ethnic,national,ecstat1,details_known_2,relat2,age2,sex2,ecstat2,details_known_3,relat3,age3,sex3,ecstat3,details_known_4,relat4,age4,sex4,ecstat4,details_known_5,relat5,age5,sex5,ecstat5,details_known_6,relat6,age6,sex6,ecstat6,details_known_7,relat7,age7,sex7,ecstat7,details_known_8,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,new_old,homeless,ppcodenk,ppostcode_full,previous_la_known,is_previous_la_inferred,prevloc_label,prevloc,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,referral_value_check,net_income_known,incref,earnings,incfreq,net_income_value_check,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,wrent,rent_value_check,scharge,wscharge,pscharge,wpschrge,supcharg,wsupchrg,tcharge,wtcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall_known,tshortfall,wtshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate
,completed,,s.port@jeemayle.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,single log,,,2023,DLUHC,DLUHC,General needs,Affordable rent general needs local authority,No,2023-11-26,Affordable Rent,Affordable Rent,Rent to Buy,,No,HIJKLMN,ABCDEFG,Yes,No,,,fake address,,London,,NW9 5LL,No,Barnet,E09000003,No,Affordable rent basis,Tenant abandoned property,No,2,House,Purpose built,Yes,3,2023-11-24,,,Yes,2023-11-25,,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,Yes,4,,Yes,4,0,0,2,35,,Female,White,Irish,Tenant prefers not to say,Other,Yes,Partner,32,Male,Not seeking work,No,Prefers not to say,Not known,Prefers not to say,Prefers not to say,Yes,Person prefers not to say,Not known,Person prefers not to say,Person prefers not to say,,,,,,,,,,,,,,,,,,,,,Yes – the person is a current or former regular,No – they left up to and including 5 years ago,Yes,No,Yes,Fully wheelchair accessible housing,Yes,No,No,No,No,No,No,Yes,No,No,Yes,No,No,No,No,No,No,No,Less than 1 year,1 year but under 2 years,Loss of tied accommodation,,Other supported housing,2,No,Yes,TN23 6LZ,Yes,No,Ashford,E07000105,Yes,,Yes,,,,No,No,Yes,,Tenant applied directly (no referral or nomination),,Yes,No,268,Weekly,,Universal Credit housing element,Yes,All,,No,Every 2 weeks,,,,,200.0,100.0,,50.0,25.0,40.0,20.0,35.0,17.5,325.0,162.5,,,,Yes,Yes,12.0,6.0,,,,,,,,,,,,,,,,,,,,
id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,old_id,old_form_id,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,postcode_known,uprn_known,uprn,uprn_confirmed,address_line1,address_line2,town_or_city,county,postcode_full,is_la_inferred,la_label,la,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,pregnancy_value_check,refused,hhtype,totchild,totelder,totadult,age1,retirement_value_check,sex1,ethnic_group,ethnic,national,nationality_all,ecstat1,details_known_2,relat2,age2,sex2,ecstat2,details_known_3,relat3,age3,sex3,ecstat3,details_known_4,relat4,age4,sex4,ecstat4,details_known_5,relat5,age5,sex5,ecstat5,details_known_6,relat6,age6,sex6,ecstat6,details_known_7,relat7,age7,sex7,ecstat7,details_known_8,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,new_old,homeless,ppcodenk,ppostcode_full,previous_la_known,is_previous_la_inferred,prevloc_label,prevloc,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,referral_value_check,net_income_known,incref,earnings,incfreq,net_income_value_check,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,wrent,rent_value_check,scharge,wscharge,pscharge,wpschrge,supcharg,wsupchrg,tcharge,wtcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall_known,tshortfall,wtshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate
,completed,,s.port@jeemayle.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,single log,,,2023,DLUHC,DLUHC,General needs,Affordable rent general needs local authority,No,2023-11-26,Affordable Rent,Affordable Rent,Rent to Buy,,No,HIJKLMN,ABCDEFG,Yes,No,,,fake address,,London,,NW9 5LL,No,Barnet,E09000003,No,Affordable rent basis,Tenant abandoned property,No,2,House,Purpose built,Yes,3,2023-11-24,,,Yes,2023-11-25,,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,Yes,4,,Yes,4,0,0,2,35,,Female,White,Irish,Tenant prefers not to say,,Other,Yes,Partner,32,Male,Not seeking work,No,Prefers not to say,Not known,Prefers not to say,Prefers not to say,Yes,Person prefers not to say,Not known,Person prefers not to say,Person prefers not to say,,,,,,,,,,,,,,,,,,,,,Yes – the person is a current or former regular,No – they left up to and including 5 years ago,Yes,No,Yes,Fully wheelchair accessible housing,Yes,No,No,No,No,No,No,Yes,No,No,Yes,No,No,No,No,No,No,No,Less than 1 year,1 year but under 2 years,Loss of tied accommodation,,Other supported housing,2,No,Yes,TN23 6LZ,Yes,No,Ashford,E07000105,Yes,,Yes,,,,No,No,Yes,,Tenant applied directly (no referral or nomination),,Yes,No,268,Weekly,,Universal Credit housing element,Yes,All,,No,Every 2 weeks,,,,,200.0,100.0,,50.0,25.0,40.0,20.0,35.0,17.5,325.0,162.5,,,,Yes,Yes,12.0,6.0,,,,,,,,,,,,,,,,,,,,

1 id status duplicate_set_id created_by is_dpo created_at updated_by updated_at creation_method old_id old_form_id collection_start_year owning_organisation_name managing_organisation_name needstype lettype renewal startdate renttype renttype_detail irproduct irproduct_other lar tenancycode propcode postcode_known uprn_known uprn uprn_confirmed address_line1 address_line2 town_or_city county postcode_full is_la_inferred la_label la first_time_property_let_as_social_housing unitletas rsnvac newprop offered unittype_gn builtype wchair beds voiddate vacdays void_date_value_check majorrepairs mrcdate major_repairs_date_value_check joint startertenancy tenancy tenancyother tenancylength sheltered declaration hhmemb pregnancy_value_check refused hhtype totchild totelder totadult age1 retirement_value_check sex1 ethnic_group ethnic national nationality_all ecstat1 details_known_2 relat2 age2 sex2 ecstat2 details_known_3 relat3 age3 sex3 ecstat3 details_known_4 relat4 age4 sex4 ecstat4 details_known_5 relat5 age5 sex5 ecstat5 details_known_6 relat6 age6 sex6 ecstat6 details_known_7 relat7 age7 sex7 ecstat7 details_known_8 relat8 age8 sex8 ecstat8 armedforces leftreg reservist preg_occ housingneeds housingneeds_type housingneeds_a housingneeds_b housingneeds_c housingneeds_f housingneeds_g housingneeds_h housingneeds_other illness illness_type_4 illness_type_5 illness_type_2 illness_type_6 illness_type_7 illness_type_3 illness_type_9 illness_type_8 illness_type_1 illness_type_10 layear waityear reason reasonother prevten new_old homeless ppcodenk ppostcode_full previous_la_known is_previous_la_inferred prevloc_label prevloc reasonpref rp_homeless rp_insan_unsat rp_medwel rp_hardship rp_dontknow cbl cap chr letting_allocation_none referral referral_value_check net_income_known incref earnings incfreq net_income_value_check hb has_benefits benefits household_charge nocharge period is_carehome chcharge wchchrg carehome_charges_value_check brent wrent rent_value_check scharge wscharge pscharge wpschrge supcharg wsupchrg tcharge wtcharge scharge_value_check pscharge_value_check supcharg_value_check hbrentshortfall tshortfall_known tshortfall wtshortfall scheme_code scheme_service_name scheme_sensitive SCHTYPE scheme_registered_under_care_act scheme_owning_organisation_name scheme_primary_client_group scheme_has_other_client_group scheme_secondary_client_group scheme_support_type scheme_intended_stay scheme_created_at location_code location_postcode location_name location_units location_type_of_unit location_mobility_type location_local_authority location_startdate
2 completed s.port@jeemayle.com false 2023-11-26T00:00:00+00:00 2023-11-26T00:00:00+00:00 single log 2023 DLUHC DLUHC General needs Affordable rent general needs local authority No 2023-11-26 Affordable Rent Affordable Rent Rent to Buy No HIJKLMN ABCDEFG Yes No fake address London NW9 5LL No Barnet E09000003 No Affordable rent basis Tenant abandoned property No 2 House Purpose built Yes 3 2023-11-24 Yes 2023-11-25 Don’t know Yes Assured Shorthold Tenancy (AST) – Fixed term 2 Yes 4 Yes 4 0 0 2 35 Female White Irish Tenant prefers not to say Other Yes Partner 32 Male Not seeking work No Prefers not to say Not known Prefers not to say Prefers not to say Yes Person prefers not to say Not known Person prefers not to say Person prefers not to say Yes – the person is a current or former regular No – they left up to and including 5 years ago Yes No Yes Fully wheelchair accessible housing Yes No No No No No No Yes No No Yes No No No No No No No Less than 1 year 1 year but under 2 years Loss of tied accommodation Other supported housing 2 No Yes TN23 6LZ Yes No Ashford E07000105 Yes Yes No No Yes Tenant applied directly (no referral or nomination) Yes No 268 Weekly Universal Credit housing element Yes All No Every 2 weeks 200.0 100.0 50.0 25.0 40.0 20.0 35.0 17.5 325.0 162.5 Yes Yes 12.0 6.0

4
spec/fixtures/files/lettings_log_csv_export_non_support_codes.csv vendored

@ -1,2 +1,2 @@
id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,uprn_known,uprn,address_line1,address_line2,town_or_city,county,postcode_full,la_label,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,refused,age1,sex1,ethnic_group,ethnic,national,ecstat1,relat2,age2,sex2,ecstat2,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,relat7,age7,sex7,ecstat7,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,homeless,ppcodenk,ppostcode_full,prevloc_label,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,referral_value_check,incref,earnings,incfreq,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,scharge,pscharge,supcharg,tcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate
,completed,,choreographer@owtluk.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,1,2023,DLUHC,DLUHC,1,7,0,2023-11-26,2,2,1,,2,HIJKLMN,ABCDEFG,0,,fake address,,London,,NW9 5LL,Barnet,2,6,2,2,7,1,1,3,2023-11-24,1,,1,2023-11-25,,3,1,4,,2,,1,4,1,35,F,0,2,13,0,P,32,M,6,R,-9,R,10,R,-9,R,10,,,,,,,,,,,,,,,,,1,4,1,2,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,2,7,4,,6,1,0,TN23 6LZ,Ashford,1,0,1,0,0,0,0,0,1,,2,,0,268,1,6,1,1,,0,2,,,,,200.0,50.0,40.0,35.0,325.0,,,,1,12.0,,,,,,,,,,,,,,,,,,,,
id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,uprn_known,uprn,address_line1,address_line2,town_or_city,county,postcode_full,la_label,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,refused,age1,sex1,ethnic_group,ethnic,national,nationality_all,ecstat1,relat2,age2,sex2,ecstat2,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,relat7,age7,sex7,ecstat7,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,homeless,ppcodenk,ppostcode_full,prevloc_label,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,referral_value_check,incref,earnings,incfreq,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,scharge,pscharge,supcharg,tcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate
,completed,,choreographer@owtluk.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,1,2023,DLUHC,DLUHC,1,7,0,2023-11-26,2,2,1,,2,HIJKLMN,ABCDEFG,0,,fake address,,London,,NW9 5LL,Barnet,2,6,2,2,7,1,1,3,2023-11-24,1,,1,2023-11-25,,3,1,4,,2,,1,4,1,35,F,0,2,13,,0,P,32,M,6,R,-9,R,10,R,-9,R,10,,,,,,,,,,,,,,,,,1,4,1,2,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,2,7,4,,6,1,0,TN23 6LZ,Ashford,1,0,1,0,0,0,0,0,1,,2,,0,268,1,6,1,1,,0,2,,,,,200.0,50.0,40.0,35.0,325.0,,,,1,12.0,,,,,,,,,,,,,,,,,,,,

1 id status duplicate_set_id created_by is_dpo created_at updated_by updated_at creation_method collection_start_year owning_organisation_name managing_organisation_name needstype lettype renewal startdate renttype renttype_detail irproduct irproduct_other lar tenancycode propcode uprn_known uprn address_line1 address_line2 town_or_city county postcode_full la_label unitletas rsnvac newprop offered unittype_gn builtype wchair beds voiddate vacdays void_date_value_check majorrepairs mrcdate major_repairs_date_value_check joint startertenancy tenancy tenancyother tenancylength sheltered declaration hhmemb refused age1 sex1 ethnic_group ethnic national nationality_all ecstat1 relat2 age2 sex2 ecstat2 relat3 age3 sex3 ecstat3 relat4 age4 sex4 ecstat4 relat5 age5 sex5 ecstat5 relat6 age6 sex6 ecstat6 relat7 age7 sex7 ecstat7 relat8 age8 sex8 ecstat8 armedforces leftreg reservist preg_occ housingneeds housingneeds_type housingneeds_a housingneeds_b housingneeds_c housingneeds_f housingneeds_g housingneeds_h housingneeds_other illness illness_type_4 illness_type_5 illness_type_2 illness_type_6 illness_type_7 illness_type_3 illness_type_9 illness_type_8 illness_type_1 illness_type_10 layear waityear reason reasonother prevten homeless ppcodenk ppostcode_full prevloc_label reasonpref rp_homeless rp_insan_unsat rp_medwel rp_hardship rp_dontknow cbl cap chr letting_allocation_none referral referral_value_check incref earnings incfreq hb has_benefits benefits household_charge nocharge period is_carehome chcharge wchchrg carehome_charges_value_check brent scharge pscharge supcharg tcharge scharge_value_check pscharge_value_check supcharg_value_check hbrentshortfall tshortfall scheme_code scheme_service_name scheme_sensitive SCHTYPE scheme_registered_under_care_act scheme_owning_organisation_name scheme_primary_client_group scheme_has_other_client_group scheme_secondary_client_group scheme_support_type scheme_intended_stay scheme_created_at location_code location_postcode location_name location_units location_type_of_unit location_mobility_type location_local_authority location_startdate
2 completed choreographer@owtluk.com false 2023-11-26T00:00:00+00:00 2023-11-26T00:00:00+00:00 1 2023 DLUHC DLUHC 1 7 0 2023-11-26 2 2 1 2 HIJKLMN ABCDEFG 0 fake address London NW9 5LL Barnet 2 6 2 2 7 1 1 3 2023-11-24 1 1 2023-11-25 3 1 4 2 1 4 1 35 F 0 2 13 0 P 32 M 6 R -9 R 10 R -9 R 10 1 4 1 2 1 0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 2 7 4 6 1 0 TN23 6LZ Ashford 1 0 1 0 0 0 0 0 1 2 0 268 1 6 1 1 0 2 200.0 50.0 40.0 35.0 325.0 1 12.0

4
spec/fixtures/files/lettings_log_csv_export_non_support_labels.csv vendored

@ -1,2 +1,2 @@
id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,uprn_known,uprn,address_line1,address_line2,town_or_city,county,postcode_full,la_label,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,refused,age1,sex1,ethnic_group,ethnic,national,ecstat1,relat2,age2,sex2,ecstat2,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,relat7,age7,sex7,ecstat7,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,homeless,ppcodenk,ppostcode_full,prevloc_label,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,referral_value_check,incref,earnings,incfreq,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,scharge,pscharge,supcharg,tcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate
,completed,,choreographer@owtluk.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,single log,2023,DLUHC,DLUHC,General needs,Affordable rent general needs local authority,No,2023-11-26,Affordable Rent,Affordable Rent,Rent to Buy,,No,HIJKLMN,ABCDEFG,No,,fake address,,London,,NW9 5LL,Barnet,Affordable rent basis,Tenant abandoned property,No,2,House,Purpose built,Yes,3,2023-11-24,1,,Yes,2023-11-25,,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,Yes,4,Yes,35,Female,White,Irish,Tenant prefers not to say,Other,Partner,32,Male,Not seeking work,Prefers not to say,Not known,Prefers not to say,Prefers not to say,Person prefers not to say,Not known,Person prefers not to say,Person prefers not to say,,,,,,,,,,,,,,,,,Yes – the person is a current or former regular,No – they left up to and including 5 years ago,Yes,No,Yes,Fully wheelchair accessible housing,Yes,No,No,No,No,No,No,Yes,No,No,Yes,No,No,No,No,No,No,No,Less than 1 year,1 year but under 2 years,Loss of tied accommodation,,Other supported housing,No,Yes,TN23 6LZ,Ashford,Yes,,Yes,,,,No,No,Yes,,Tenant applied directly (no referral or nomination),,No,268,Weekly,Universal Credit housing element,Yes,All,,No,Every 2 weeks,,,,,200.0,50.0,40.0,35.0,325.0,,,,Yes,12.0,,,,,,,,,,,,,,,,,,,,
id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,uprn_known,uprn,address_line1,address_line2,town_or_city,county,postcode_full,la_label,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,refused,age1,sex1,ethnic_group,ethnic,national,nationality_all,ecstat1,relat2,age2,sex2,ecstat2,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,relat7,age7,sex7,ecstat7,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,homeless,ppcodenk,ppostcode_full,prevloc_label,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,referral_value_check,incref,earnings,incfreq,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,scharge,pscharge,supcharg,tcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate
,completed,,choreographer@owtluk.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,single log,2023,DLUHC,DLUHC,General needs,Affordable rent general needs local authority,No,2023-11-26,Affordable Rent,Affordable Rent,Rent to Buy,,No,HIJKLMN,ABCDEFG,No,,fake address,,London,,NW9 5LL,Barnet,Affordable rent basis,Tenant abandoned property,No,2,House,Purpose built,Yes,3,2023-11-24,1,,Yes,2023-11-25,,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,Yes,4,Yes,35,Female,White,Irish,Tenant prefers not to say,,Other,Partner,32,Male,Not seeking work,Prefers not to say,Not known,Prefers not to say,Prefers not to say,Person prefers not to say,Not known,Person prefers not to say,Person prefers not to say,,,,,,,,,,,,,,,,,Yes – the person is a current or former regular,No – they left up to and including 5 years ago,Yes,No,Yes,Fully wheelchair accessible housing,Yes,No,No,No,No,No,No,Yes,No,No,Yes,No,No,No,No,No,No,No,Less than 1 year,1 year but under 2 years,Loss of tied accommodation,,Other supported housing,No,Yes,TN23 6LZ,Ashford,Yes,,Yes,,,,No,No,Yes,,Tenant applied directly (no referral or nomination),,No,268,Weekly,Universal Credit housing element,Yes,All,,No,Every 2 weeks,,,,,200.0,50.0,40.0,35.0,325.0,,,,Yes,12.0,,,,,,,,,,,,,,,,,,,,

1 id status duplicate_set_id created_by is_dpo created_at updated_by updated_at creation_method collection_start_year owning_organisation_name managing_organisation_name needstype lettype renewal startdate renttype renttype_detail irproduct irproduct_other lar tenancycode propcode uprn_known uprn address_line1 address_line2 town_or_city county postcode_full la_label unitletas rsnvac newprop offered unittype_gn builtype wchair beds voiddate vacdays void_date_value_check majorrepairs mrcdate major_repairs_date_value_check joint startertenancy tenancy tenancyother tenancylength sheltered declaration hhmemb refused age1 sex1 ethnic_group ethnic national nationality_all ecstat1 relat2 age2 sex2 ecstat2 relat3 age3 sex3 ecstat3 relat4 age4 sex4 ecstat4 relat5 age5 sex5 ecstat5 relat6 age6 sex6 ecstat6 relat7 age7 sex7 ecstat7 relat8 age8 sex8 ecstat8 armedforces leftreg reservist preg_occ housingneeds housingneeds_type housingneeds_a housingneeds_b housingneeds_c housingneeds_f housingneeds_g housingneeds_h housingneeds_other illness illness_type_4 illness_type_5 illness_type_2 illness_type_6 illness_type_7 illness_type_3 illness_type_9 illness_type_8 illness_type_1 illness_type_10 layear waityear reason reasonother prevten homeless ppcodenk ppostcode_full prevloc_label reasonpref rp_homeless rp_insan_unsat rp_medwel rp_hardship rp_dontknow cbl cap chr letting_allocation_none referral referral_value_check incref earnings incfreq hb has_benefits benefits household_charge nocharge period is_carehome chcharge wchchrg carehome_charges_value_check brent scharge pscharge supcharg tcharge scharge_value_check pscharge_value_check supcharg_value_check hbrentshortfall tshortfall scheme_code scheme_service_name scheme_sensitive SCHTYPE scheme_registered_under_care_act scheme_owning_organisation_name scheme_primary_client_group scheme_has_other_client_group scheme_secondary_client_group scheme_support_type scheme_intended_stay scheme_created_at location_code location_postcode location_name location_units location_type_of_unit location_mobility_type location_local_authority location_startdate
2 completed choreographer@owtluk.com false 2023-11-26T00:00:00+00:00 2023-11-26T00:00:00+00:00 single log 2023 DLUHC DLUHC General needs Affordable rent general needs local authority No 2023-11-26 Affordable Rent Affordable Rent Rent to Buy No HIJKLMN ABCDEFG No fake address London NW9 5LL Barnet Affordable rent basis Tenant abandoned property No 2 House Purpose built Yes 3 2023-11-24 1 Yes 2023-11-25 Don’t know Yes Assured Shorthold Tenancy (AST) – Fixed term 2 Yes 4 Yes 35 Female White Irish Tenant prefers not to say Other Partner 32 Male Not seeking work Prefers not to say Not known Prefers not to say Prefers not to say Person prefers not to say Not known Person prefers not to say Person prefers not to say Yes – the person is a current or former regular No – they left up to and including 5 years ago Yes No Yes Fully wheelchair accessible housing Yes No No No No No No Yes No No Yes No No No No No No No Less than 1 year 1 year but under 2 years Loss of tied accommodation Other supported housing No Yes TN23 6LZ Ashford Yes Yes No No Yes Tenant applied directly (no referral or nomination) No 268 Weekly Universal Credit housing element Yes All No Every 2 weeks 200.0 50.0 40.0 35.0 325.0 Yes 12.0

4
spec/fixtures/files/sales_logs_csv_export_codes.csv vendored

@ -1,2 +1,2 @@
id,status,duplicate_set_id,created_at,updated_at,old_form_id,collection_start_year,creation_method,is_dpo,owning_organisation_name,managing_organisation_name,created_by,day,month,year,purchid,ownershipsch,type,othtype,companybuy,buylivein,jointpur,jointmore,noint,uprn,uprn_confirmed,address_line1,address_line2,town_or_city,county,pcode1,pcode2,la_known,la,la_label,beds,proptype,builtype,pcodenk,wchair,privacynotice,age1,sex1,ethnic_group,ethnic,national,ecstat1,buy1livein,relat2,age2,sex2,ethnic_group2,ethnicbuy2,nationalbuy2,ecstat2,buy2livein,hholdcount,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,prevten,ppcodenk,ppostc1,ppostc2,previous_la_known,prevloc,prevloc_label,pregyrha,pregother,pregla,pregghb,pregblank,buy2living,prevtenbuy2,hhregres,hhregresstill,armedforcesspouse,disabled,wheel,income1nk,income1,inc1mort,income2nk,income2,inc2mort,hb,savingsnk,savings,prevown,prevshared,proplen,staircase,stairbought,stairowned,staircasesale,resale,exday,exmonth,exyear,hoday,homonth,hoyear,lanomagr,soctenant,frombeds,fromprop,socprevten,value,equity,mortgageused,mortgage,mortgagelender,mortgagelenderother,mortlen,extrabor,deposit,cashdis,mrent,has_mscharge,mscharge,discount,grant
,completed,,2023-12-08T00:00:00+00:00,2023-12-08T00:00:00+00:00,,2023,1,false,DLUHC,DLUHC,billyboy@eyeklaud.com,8,12,2023,,2,8,,,,1,1,2,,,Address line 1,,Town or city,,SW1A,1AA,1,E09000003,Barnet,2,1,1,0,1,1,30,X,17,17,18,1,1,P,35,X,17,,13,1,1,3,C,14,X,9,X,-9,X,3,R,-9,R,10,,,,,1,1,,,0,,,1,1,1,1,,3,,1,4,5,1,1,0,10000,1,0,10000,1,4,1,,1,2,10,,,,,,,,,,,,,,,,,110000.0,,1,20000.0,5,,10,1,80000.0,,,1,100.0,,10000.0
id,status,duplicate_set_id,created_at,updated_at,old_form_id,collection_start_year,creation_method,is_dpo,owning_organisation_name,managing_organisation_name,created_by,day,month,year,purchid,ownershipsch,type,othtype,companybuy,buylivein,jointpur,jointmore,noint,uprn,uprn_confirmed,address_line1,address_line2,town_or_city,county,pcode1,pcode2,la_known,la,la_label,beds,proptype,builtype,pcodenk,wchair,privacynotice,age1,sex1,ethnic_group,ethnic,national,nationality_all,ecstat1,buy1livein,relat2,age2,sex2,ethnic_group2,ethnicbuy2,nationalbuy2,nationality_all_buyer2,ecstat2,buy2livein,hholdcount,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,prevten,ppcodenk,ppostc1,ppostc2,previous_la_known,prevloc,prevloc_label,pregyrha,pregother,pregla,pregghb,pregblank,buy2living,prevtenbuy2,hhregres,hhregresstill,armedforcesspouse,disabled,wheel,income1nk,income1,inc1mort,income2nk,income2,inc2mort,hb,savingsnk,savings,prevown,prevshared,proplen,staircase,stairbought,stairowned,staircasesale,resale,exday,exmonth,exyear,hoday,homonth,hoyear,lanomagr,soctenant,frombeds,fromprop,socprevten,value,equity,mortgageused,mortgage,mortgagelender,mortgagelenderother,mortlen,extrabor,deposit,cashdis,mrent,has_mscharge,mscharge,discount,grant
,completed,,2023-12-08T00:00:00+00:00,2023-12-08T00:00:00+00:00,,2023,1,false,DLUHC,DLUHC,billyboy@eyeklaud.com,8,12,2023,,2,8,,,,1,1,2,,,Address line 1,,Town or city,,SW1A,1AA,1,E09000003,Barnet,2,1,1,0,1,1,30,X,17,17,18,,1,1,P,35,X,17,,13,,1,1,3,C,14,X,9,X,-9,X,3,R,-9,R,10,,,,,1,1,,,0,,,1,1,1,1,,3,,1,4,5,1,1,0,10000,1,0,10000,1,4,1,,1,2,10,,,,,,,,,,,,,,,,,110000.0,,1,20000.0,5,,10,1,80000.0,,,1,100.0,,10000.0

1 id status duplicate_set_id created_at updated_at old_form_id collection_start_year creation_method is_dpo owning_organisation_name managing_organisation_name created_by day month year purchid ownershipsch type othtype companybuy buylivein jointpur jointmore noint uprn uprn_confirmed address_line1 address_line2 town_or_city county pcode1 pcode2 la_known la la_label beds proptype builtype pcodenk wchair privacynotice age1 sex1 ethnic_group ethnic national nationality_all ecstat1 buy1livein relat2 age2 sex2 ethnic_group2 ethnicbuy2 nationalbuy2 nationality_all_buyer2 ecstat2 buy2livein hholdcount relat3 age3 sex3 ecstat3 relat4 age4 sex4 ecstat4 relat5 age5 sex5 ecstat5 relat6 age6 sex6 ecstat6 prevten ppcodenk ppostc1 ppostc2 previous_la_known prevloc prevloc_label pregyrha pregother pregla pregghb pregblank buy2living prevtenbuy2 hhregres hhregresstill armedforcesspouse disabled wheel income1nk income1 inc1mort income2nk income2 inc2mort hb savingsnk savings prevown prevshared proplen staircase stairbought stairowned staircasesale resale exday exmonth exyear hoday homonth hoyear lanomagr soctenant frombeds fromprop socprevten value equity mortgageused mortgage mortgagelender mortgagelenderother mortlen extrabor deposit cashdis mrent has_mscharge mscharge discount grant
2 completed 2023-12-08T00:00:00+00:00 2023-12-08T00:00:00+00:00 2023 1 false DLUHC DLUHC billyboy@eyeklaud.com 8 12 2023 2 8 1 1 2 Address line 1 Town or city SW1A 1AA 1 E09000003 Barnet 2 1 1 0 1 1 30 X 17 17 18 1 1 P 35 X 17 13 1 1 3 C 14 X 9 X -9 X 3 R -9 R 10 1 1 0 1 1 1 1 3 1 4 5 1 1 0 10000 1 0 10000 1 4 1 1 2 10 110000.0 1 20000.0 5 10 1 80000.0 1 100.0 10000.0

4
spec/fixtures/files/sales_logs_csv_export_labels.csv vendored

@ -1,2 +1,2 @@
id,status,duplicate_set_id,created_at,updated_at,old_form_id,collection_start_year,creation_method,is_dpo,owning_organisation_name,managing_organisation_name,created_by,day,month,year,purchid,ownershipsch,type,othtype,companybuy,buylivein,jointpur,jointmore,noint,uprn,uprn_confirmed,address_line1,address_line2,town_or_city,county,pcode1,pcode2,la_known,la,la_label,beds,proptype,builtype,pcodenk,wchair,privacynotice,age1,sex1,ethnic_group,ethnic,national,ecstat1,buy1livein,relat2,age2,sex2,ethnic_group2,ethnicbuy2,nationalbuy2,ecstat2,buy2livein,hholdcount,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,prevten,ppcodenk,ppostc1,ppostc2,previous_la_known,prevloc,prevloc_label,pregyrha,pregother,pregla,pregghb,pregblank,buy2living,prevtenbuy2,hhregres,hhregresstill,armedforcesspouse,disabled,wheel,income1nk,income1,inc1mort,income2nk,income2,inc2mort,hb,savingsnk,savings,prevown,prevshared,proplen,staircase,stairbought,stairowned,staircasesale,resale,exday,exmonth,exyear,hoday,homonth,hoyear,lanomagr,soctenant,frombeds,fromprop,socprevten,value,equity,mortgageused,mortgage,mortgagelender,mortgagelenderother,mortlen,extrabor,deposit,cashdis,mrent,has_mscharge,mscharge,discount,grant
,completed,,2023-12-08T00:00:00+00:00,2023-12-08T00:00:00+00:00,,2023,single log,false,DLUHC,DLUHC,billyboy@eyeklaud.com,8,12,2023,,Yes - a discounted ownership scheme,Right to Acquire (RTA),,,,Yes,Yes,Yes,,,Address line 1,,Town or city,,SW1A,1AA,1,E09000003,Barnet,2,Flat or maisonette,Purpose built,0,Yes,1,30,Non-binary,Buyer 1 prefers not to say,17,United Kingdom,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,Buyer 2 prefers not to say,,Buyer prefers not to say,Full-time - 30 hours or more,Yes,3,Child,14,Non-binary,Child under 16,Other,Not known,Non-binary,"In government training into work, such as New Deal",Prefers not to say,Not known,Prefers not to say,Prefers not to say,,,,,Local authority tenant,No,,,No,,,1,1,1,1,,Don't know,,Yes,Yes,No,Yes,Yes,Yes,10000,Yes,Yes,10000,Yes,"Don’t know ",No,,Yes,No,10,,,,,,,,,,,,,,,,,110000.0,,Yes,20000.0,Cambridge Building Society,,10,Yes,80000.0,,,Yes,100.0,,10000.0
id,status,duplicate_set_id,created_at,updated_at,old_form_id,collection_start_year,creation_method,is_dpo,owning_organisation_name,managing_organisation_name,created_by,day,month,year,purchid,ownershipsch,type,othtype,companybuy,buylivein,jointpur,jointmore,noint,uprn,uprn_confirmed,address_line1,address_line2,town_or_city,county,pcode1,pcode2,la_known,la,la_label,beds,proptype,builtype,pcodenk,wchair,privacynotice,age1,sex1,ethnic_group,ethnic,national,nationality_all,ecstat1,buy1livein,relat2,age2,sex2,ethnic_group2,ethnicbuy2,nationalbuy2,nationality_all_buyer2,ecstat2,buy2livein,hholdcount,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,prevten,ppcodenk,ppostc1,ppostc2,previous_la_known,prevloc,prevloc_label,pregyrha,pregother,pregla,pregghb,pregblank,buy2living,prevtenbuy2,hhregres,hhregresstill,armedforcesspouse,disabled,wheel,income1nk,income1,inc1mort,income2nk,income2,inc2mort,hb,savingsnk,savings,prevown,prevshared,proplen,staircase,stairbought,stairowned,staircasesale,resale,exday,exmonth,exyear,hoday,homonth,hoyear,lanomagr,soctenant,frombeds,fromprop,socprevten,value,equity,mortgageused,mortgage,mortgagelender,mortgagelenderother,mortlen,extrabor,deposit,cashdis,mrent,has_mscharge,mscharge,discount,grant
,completed,,2023-12-08T00:00:00+00:00,2023-12-08T00:00:00+00:00,,2023,single log,false,DLUHC,DLUHC,billyboy@eyeklaud.com,8,12,2023,,Yes - a discounted ownership scheme,Right to Acquire (RTA),,,,Yes,Yes,Yes,,,Address line 1,,Town or city,,SW1A,1AA,1,E09000003,Barnet,2,Flat or maisonette,Purpose built,0,Yes,1,30,Non-binary,Buyer 1 prefers not to say,17,United Kingdom,,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,Buyer 2 prefers not to say,,Buyer prefers not to say,,Full-time - 30 hours or more,Yes,3,Child,14,Non-binary,Child under 16,Other,Not known,Non-binary,"In government training into work, such as New Deal",Prefers not to say,Not known,Prefers not to say,Prefers not to say,,,,,Local authority tenant,No,,,No,,,1,1,1,1,,Don't know,,Yes,Yes,No,Yes,Yes,Yes,10000,Yes,Yes,10000,Yes,"Don’t know ",No,,Yes,No,10,,,,,,,,,,,,,,,,,110000.0,,Yes,20000.0,Cambridge Building Society,,10,Yes,80000.0,,,Yes,100.0,,10000.0

1 id status duplicate_set_id created_at updated_at old_form_id collection_start_year creation_method is_dpo owning_organisation_name managing_organisation_name created_by day month year purchid ownershipsch type othtype companybuy buylivein jointpur jointmore noint uprn uprn_confirmed address_line1 address_line2 town_or_city county pcode1 pcode2 la_known la la_label beds proptype builtype pcodenk wchair privacynotice age1 sex1 ethnic_group ethnic national nationality_all ecstat1 buy1livein relat2 age2 sex2 ethnic_group2 ethnicbuy2 nationalbuy2 nationality_all_buyer2 ecstat2 buy2livein hholdcount relat3 age3 sex3 ecstat3 relat4 age4 sex4 ecstat4 relat5 age5 sex5 ecstat5 relat6 age6 sex6 ecstat6 prevten ppcodenk ppostc1 ppostc2 previous_la_known prevloc prevloc_label pregyrha pregother pregla pregghb pregblank buy2living prevtenbuy2 hhregres hhregresstill armedforcesspouse disabled wheel income1nk income1 inc1mort income2nk income2 inc2mort hb savingsnk savings prevown prevshared proplen staircase stairbought stairowned staircasesale resale exday exmonth exyear hoday homonth hoyear lanomagr soctenant frombeds fromprop socprevten value equity mortgageused mortgage mortgagelender mortgagelenderother mortlen extrabor deposit cashdis mrent has_mscharge mscharge discount grant
2 completed 2023-12-08T00:00:00+00:00 2023-12-08T00:00:00+00:00 2023 single log false DLUHC DLUHC billyboy@eyeklaud.com 8 12 2023 Yes - a discounted ownership scheme Right to Acquire (RTA) Yes Yes Yes Address line 1 Town or city SW1A 1AA 1 E09000003 Barnet 2 Flat or maisonette Purpose built 0 Yes 1 30 Non-binary Buyer 1 prefers not to say 17 United Kingdom Full-time - 30 hours or more Yes Partner 35 Non-binary Buyer 2 prefers not to say Buyer prefers not to say Full-time - 30 hours or more Yes 3 Child 14 Non-binary Child under 16 Other Not known Non-binary In government training into work, such as New Deal Prefers not to say Not known Prefers not to say Prefers not to say Local authority tenant No No 1 1 1 1 Don't know Yes Yes No Yes Yes Yes 10000 Yes Yes 10000 Yes Don’t know No Yes No 10 110000.0 Yes 20000.0 Cambridge Building Society 10 Yes 80000.0 Yes 100.0 10000.0

39
spec/models/form/lettings/questions/nationality_all_group_spec.rb

@ -0,0 +1,39 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::NationalityAllGroup, type: :model do
subject(:question) { described_class.new(nil, nil, page) }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct id" do
expect(question.id).to eq("nationality_all_group")
end
it "has the correct header" do
expect(question.header).to eq("What is the nationality of the lead tenant?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Lead tenant’s nationality")
end
it "has the correct type" do
expect(question.type).to eq("radio")
end
it "has the correct hint_text" do
expect(question.hint_text).to eq("The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.")
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"826" => { "value" => "United Kingdom" },
"12" => { "value" => "Other" },
"0" => { "value" => "Tenant prefers not to say" },
})
end
end

35
spec/models/form/lettings/questions/nationality_all_spec.rb

@ -0,0 +1,35 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::NationalityAll, type: :model do
subject(:question) { described_class.new(nil, nil, page) }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct id" do
expect(question.id).to eq("nationality_all")
end
it "has the correct header" do
expect(question.header).to eq("Enter a nationality")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Lead tenant’s nationality")
end
it "has the correct type" do
expect(question.type).to eq("select")
end
it "has the correct hint_text" do
expect(question.hint_text).to be_nil
end
it "has the correct answer_options" do
expect(question.answer_options.count).to eq(203)
end
end

18
spec/models/form/sales/pages/nationality1_spec.rb → spec/models/form/sales/pages/buyer1_nationality_spec.rb

@ -1,9 +1,15 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::Nationality1, type: :model do
RSpec.describe Form::Sales::Pages::Buyer1Nationality, type: :model do
subject(:page) { described_class.new(nil, nil, subsection) }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form) }
before do
allow(subsection).to receive(:form).and_return(form)
allow(form).to receive(:start_year_after_2024?).and_return(false)
end
it "has correct subsection" do
expect(page.subsection).to be subsection
@ -28,4 +34,14 @@ RSpec.describe Form::Sales::Pages::Nationality1, type: :model do
it "has correct depends_on" do
expect(page.depends_on).to eq [{ "buyer_has_seen_privacy_notice?" => true }, { "buyer_not_interviewed?" => true }]
end
context "with year 2024" do
before do
allow(form).to receive(:start_year_after_2024?).and_return(true)
end
it "has correct questions" do
expect(page.questions.map(&:id)).to eq %w[nationality_all_group nationality_all]
end
end
end

16
spec/models/form/sales/pages/buyer2_nationality_spec.rb

@ -4,6 +4,12 @@ RSpec.describe Form::Sales::Pages::Buyer2Nationality, type: :model do
subject(:page) { described_class.new(nil, nil, subsection) }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form) }
before do
allow(subsection).to receive(:form).and_return(form)
allow(form).to receive(:start_year_after_2024?).and_return(false)
end
it "has correct subsection" do
expect(page.subsection).to be subsection
@ -37,4 +43,14 @@ RSpec.describe Form::Sales::Pages::Buyer2Nationality, type: :model do
},
]
end
context "with year 2024" do
before do
allow(form).to receive(:start_year_after_2024?).and_return(true)
end
it "has correct questions" do
expect(page.questions.map(&:id)).to eq %w[nationality_all_buyer2_group nationality_all_buyer2]
end
end
end

2
spec/models/form/sales/questions/nationality1_spec.rb → spec/models/form/sales/questions/buyer1_nationality_spec.rb

@ -1,6 +1,6 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::Nationality1, type: :model do
RSpec.describe Form::Sales::Questions::Buyer1Nationality, type: :model do
subject(:question) { described_class.new(nil, nil, page) }
let(:page) { instance_double(Form::Page) }

89
spec/models/form/sales/questions/nationality_all_group_spec.rb

@ -0,0 +1,89 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::NationalityAllGroup, type: :model do
subject(:question) { described_class.new("some_id", nil, page, buyer_index) }
let(:buyer_index) { 1 }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to be page
end
it "has the correct id" do
expect(question.id).to eq "some_id"
end
it "has the correct type" do
expect(question.type).to eq "radio"
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"826" => { "value" => "United Kingdom" },
"12" => { "value" => "Other" },
"0" => { "value" => "Buyer prefers not to say" },
})
end
it "has correct hidden in check answers" do
expect(question.hidden_in_check_answers).to eq({ "depends_on" => [{ "some_id" => 12 }] })
end
context "with buyer 1" do
let(:buyer_index) { 1 }
it "has correct conditional for" do
expect(question.conditional_for).to eq({ "nationality_all" => [12] })
end
it "has correct question_number" do
expect(question.question_number).to eq(24)
end
it "has correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(1)
end
it "has the correct hint" do
expect(question.hint_text).to eq "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest."
end
it "has the correct header" do
expect(question.header).to eq "What is buyer 1’s nationality?"
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq "Buyer 1’s nationality"
end
end
context "with buyer 2" do
let(:buyer_index) { 2 }
it "has correct conditional for" do
expect(question.conditional_for).to eq({ "nationality_all_buyer2" => [12] })
end
it "has correct question_number" do
expect(question.question_number).to eq(32)
end
it "has correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(2)
end
it "has the correct hint" do
expect(question.hint_text).to eq("")
end
it "has the correct header" do
expect(question.header).to eq "What is buyer 2’s nationality?"
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq "Buyer 2’s nationality"
end
end
end

73
spec/models/form/sales/questions/nationality_all_spec.rb

@ -0,0 +1,73 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::NationalityAll, type: :model do
subject(:question) { described_class.new("some_id", nil, page, buyer_index) }
let(:buyer_index) { 1 }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to be page
end
it "has the correct id" do
expect(question.id).to eq "some_id"
end
it "has the correct header" do
expect(question.header).to eq "Enter a nationality"
end
it "has the correct type" do
expect(question.type).to eq "select"
end
it "has the correct hint" do
expect(question.hint_text).to be_nil
end
it "has the correct answer_options" do
expect(question.answer_options.count).to eq(203)
end
it "has correct conditional for" do
expect(question.conditional_for).to be_nil
end
it "has correct hidden in check answers" do
expect(question.hidden_in_check_answers).to be_nil
end
context "with buyer 1" do
let(:buyer_index) { 1 }
it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to be 1
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq "Buyer 1’s nationality"
end
it "has the correct question_number" do
expect(question.question_number).to be 24
end
end
context "with buyer 2" do
let(:buyer_index) { 2 }
it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to be 2
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq "Buyer 2’s nationality"
end
it "has the correct question_number" do
expect(question.question_number).to be 32
end
end
end

37
spec/models/lettings_log_spec.rb

@ -2330,6 +2330,43 @@ RSpec.describe LettingsLog do
expect(record_from_db["irproduct"]).to eq(nil)
end
end
context "when updating nationality_all_group" do
let!(:lettings_log) do
described_class.create({
managing_organisation: owning_organisation,
owning_organisation:,
created_by: created_by_user,
startdate: Time.zone.local(2024, 4, 10),
needstype: 1,
renewal: 1,
rent_type: 1,
})
end
before do
Timecop.freeze(Time.zone.local(2024, 4, 10))
Singleton.__init__(FormHandler)
end
after do
Timecop.return
Singleton.__init__(FormHandler)
end
it "correctly derives nationality_all when it's UK" do
expect { lettings_log.update!(nationality_all_group: 826, declaration: 1) }.to change(lettings_log, :nationality_all).to 826
end
it "correctly derives nationality_all when it's prefers not to say" do
expect { lettings_log.update!(nationality_all_group: 0, declaration: 1) }.to change(lettings_log, :nationality_all).to 0
end
it "does not derive nationality_all when it's other or not given" do
expect { lettings_log.update!(nationality_all_group: 12, declaration: 1) }.not_to change(lettings_log, :nationality_all)
expect { lettings_log.update!(nationality_all_group: nil, declaration: 1) }.not_to change(lettings_log, :nationality_all)
end
end
end
describe "optional fields" do

19
spec/models/sales_log_spec.rb

@ -577,6 +577,25 @@ RSpec.describe SalesLog, type: :model do
end
end
end
context "when deriving nationality variables" do
it "correctly derives nationality_all/nationality_all_buyer2 when it's UK" do
expect { sales_log.update!(nationality_all_group: 826) }.to change(sales_log, :nationality_all).to 826
expect { sales_log.update!(nationality_all_buyer2_group: 826) }.to change(sales_log, :nationality_all_buyer2).to 826
end
it "correctly derives nationality_all/nationality_all_buyer2 when buyer prefers not to say" do
expect { sales_log.update!(nationality_all_group: 0) }.to change(sales_log, :nationality_all).to 0
expect { sales_log.update!(nationality_all_buyer2_group: 0) }.to change(sales_log, :nationality_all_buyer2).to 0
end
it "does not derive nationality_all/nationality_all_buyer2 when it is other or not given" do
expect { sales_log.update!(nationality_all_group: 12) }.not_to change(sales_log, :nationality_all)
expect { sales_log.update!(nationality_all_buyer2_group: 12) }.not_to change(sales_log, :nationality_all_buyer2)
expect { sales_log.update!(nationality_all_group: nil) }.not_to change(sales_log, :nationality_all)
expect { sales_log.update!(nationality_all_buyer2_group: nil) }.not_to change(sales_log, :nationality_all_buyer2)
end
end
end
context "when saving addresses" do

74
spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb

@ -1510,6 +1510,80 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end
end
describe "#field_45" do
context "when field_45 is a 3 digit nationality code" do
let(:attributes) { setup_section_params.merge({ field_45: "036" }) }
it "is correctly set" do
expect(parser.log.nationality_all).to be(36)
expect(parser.log.nationality_all_group).to be(12)
end
end
context "when field_45 is a nationality code without the trailing 0s" do
let(:attributes) { setup_section_params.merge({ field_45: "36" }) }
it "is correctly set" do
expect(parser.log.nationality_all).to be(36)
expect(parser.log.nationality_all_group).to be(12)
end
end
context "when field_45 is a nationality code with trailing 0s" do
let(:attributes) { setup_section_params.merge({ field_45: "0036" }) }
it "is correctly set" do
expect(parser.log.nationality_all).to be(36)
expect(parser.log.nationality_all_group).to be(12)
end
end
context "when field_45 is 0" do
let(:attributes) { setup_section_params.merge({ field_45: "0" }) }
it "is correctly set" do
expect(parser.log.nationality_all).to be(0)
expect(parser.log.nationality_all_group).to be(0)
end
end
context "when field_45 is 000" do
let(:attributes) { setup_section_params.merge({ field_45: "000" }) }
it "is correctly set" do
expect(parser.log.nationality_all).to be(0)
expect(parser.log.nationality_all_group).to be(0)
end
end
context "when field_45 is 0000" do
let(:attributes) { setup_section_params.merge({ field_45: "0000" }) }
it "is correctly set" do
expect(parser.log.nationality_all).to be(0)
expect(parser.log.nationality_all_group).to be(0)
end
end
context "when field_45 is 826" do
let(:attributes) { setup_section_params.merge({ field_45: "826" }) }
it "is correctly set" do
expect(parser.log.nationality_all).to be(826)
expect(parser.log.nationality_all_group).to be(826)
end
end
context "when field_45 is 826 with trailing 0s" do
let(:attributes) { setup_section_params.merge({ field_45: "0826" }) }
it "is correctly set" do
expect(parser.log.nationality_all).to be(826)
expect(parser.log.nationality_all_group).to be(826)
end
end
end
describe "soft validations" do
context "when soft validation is triggered" do
let(:attributes) { setup_section_params.merge({ field_42: 22, field_46: 5 }) }

146
spec/services/bulk_upload/sales/year2024/row_parser_spec.rb

@ -1067,11 +1067,151 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
end
end
describe "#nationalbuy2" do
let(:attributes) { setup_section_params.merge({ field_41: "18" }) }
describe "#nationality_all" do
context "when field_34 is a 3 digit nationality code" do
let(:attributes) { setup_section_params.merge({ field_34: "036" }) }
it "is correctly set" do
expect(parser.log.nationalbuy2).to be(18)
expect(parser.log.nationality_all).to be(36)
expect(parser.log.nationality_all_group).to be(12)
end
end
context "when field_34 is a nationality code without the trailing 0s" do
let(:attributes) { setup_section_params.merge({ field_34: "36" }) }
it "is correctly set" do
expect(parser.log.nationality_all).to be(36)
expect(parser.log.nationality_all_group).to be(12)
end
end
context "when field_34 is a nationality code with trailing 0s" do
let(:attributes) { setup_section_params.merge({ field_34: "0036" }) }
it "is correctly set" do
expect(parser.log.nationality_all).to be(36)
expect(parser.log.nationality_all_group).to be(12)
end
end
context "when field_34 is 0" do
let(:attributes) { setup_section_params.merge({ field_34: "0" }) }
it "is correctly set" do
expect(parser.log.nationality_all).to be(0)
expect(parser.log.nationality_all_group).to be(0)
end
end
context "when field_34 is 000" do
let(:attributes) { setup_section_params.merge({ field_34: "000" }) }
it "is correctly set" do
expect(parser.log.nationality_all).to be(0)
expect(parser.log.nationality_all_group).to be(0)
end
end
context "when field_34 is 0000" do
let(:attributes) { setup_section_params.merge({ field_34: "0000" }) }
it "is correctly set" do
expect(parser.log.nationality_all).to be(0)
expect(parser.log.nationality_all_group).to be(0)
end
end
context "when field_34 is 826" do
let(:attributes) { setup_section_params.merge({ field_34: "826" }) }
it "is correctly set" do
expect(parser.log.nationality_all).to be(826)
expect(parser.log.nationality_all_group).to be(826)
end
end
context "when field_34 is 826 with trailing 0s" do
let(:attributes) { setup_section_params.merge({ field_34: "0826" }) }
it "is correctly set" do
expect(parser.log.nationality_all).to be(826)
expect(parser.log.nationality_all_group).to be(826)
end
end
end
describe "#nationality_all_buyer2" do
context "when field_41 is a 3 digit nationality code" do
let(:attributes) { setup_section_params.merge({ field_41: "036" }) }
it "is correctly set" do
expect(parser.log.nationality_all_buyer2).to be(36)
expect(parser.log.nationality_all_buyer2_group).to be(12)
end
end
context "when field_41 is a nationality code without the trailing 0s" do
let(:attributes) { setup_section_params.merge({ field_41: "36" }) }
it "is correctly set" do
expect(parser.log.nationality_all_buyer2).to be(36)
expect(parser.log.nationality_all_buyer2_group).to be(12)
end
end
context "when field_41 is a nationality code with trailing 0s" do
let(:attributes) { setup_section_params.merge({ field_41: "0036" }) }
it "is correctly set" do
expect(parser.log.nationality_all_buyer2).to be(36)
expect(parser.log.nationality_all_buyer2_group).to be(12)
end
end
context "when field_41 is 0" do
let(:attributes) { setup_section_params.merge({ field_41: "0" }) }
it "is correctly set" do
expect(parser.log.nationality_all_buyer2).to be(0)
expect(parser.log.nationality_all_buyer2_group).to be(0)
end
end
context "when field_41 is 000" do
let(:attributes) { setup_section_params.merge({ field_41: "000" }) }
it "is correctly set" do
expect(parser.log.nationality_all_buyer2).to be(0)
expect(parser.log.nationality_all_buyer2_group).to be(0)
end
end
context "when field_41 is 0000" do
let(:attributes) { setup_section_params.merge({ field_41: "0000" }) }
it "is correctly set" do
expect(parser.log.nationality_all_buyer2).to be(0)
expect(parser.log.nationality_all_buyer2_group).to be(0)
end
end
context "when field_41 is 826" do
let(:attributes) { setup_section_params.merge({ field_41: "826" }) }
it "is correctly set" do
expect(parser.log.nationality_all_buyer2).to be(826)
expect(parser.log.nationality_all_buyer2_group).to be(826)
end
end
context "when field_41 is 826 with trailing 0s" do
let(:attributes) { setup_section_params.merge({ field_41: "0826" }) }
it "is correctly set" do
expect(parser.log.nationality_all_buyer2).to be(826)
expect(parser.log.nationality_all_buyer2_group).to be(826)
end
end
end

Loading…
Cancel
Save