From dc92466139980d9944dd03565f87634f17ce955d Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Mon, 5 Feb 2024 15:26:15 +0000 Subject: [PATCH] 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 --- app/constants/global_constants.rb | 206 ++++++++++++++++++ app/helpers/question_view_helper.rb | 13 +- .../lettings_log_variables.rb | 2 + .../derived_variables/sales_log_variables.rb | 3 + .../lettings/pages/lead_tenant_nationality.rb | 9 +- .../lettings/questions/nationality_all.rb | 16 ++ .../questions/nationality_all_group.rb | 21 ++ .../form/sales/pages/buyer1_nationality.rb | 25 +++ .../form/sales/pages/buyer2_nationality.rb | 9 +- app/models/form/sales/pages/nationality1.rb | 18 -- ...{nationality1.rb => buyer1_nationality.rb} | 2 +- .../form/sales/questions/nationality_all.rb | 15 ++ .../sales/questions/nationality_all_group.rb | 20 ++ .../subsections/household_characteristics.rb | 2 +- app/models/log.rb | 4 + app/models/sales_log.rb | 4 + .../lettings/year2024/row_parser.rb | 13 +- .../bulk_upload/sales/year2024/row_parser.rb | 20 +- app/services/csv/lettings_log_csv_service.rb | 2 +- app/services/csv/sales_log_csv_service.rb | 2 +- app/views/form/_select_question.html.erb | 2 +- .../20240130084707_add_nationality_all.rb | 14 ++ db/schema.rb | 8 +- .../files/lettings_log_csv_export_codes.csv | 4 +- .../files/lettings_log_csv_export_labels.csv | 4 +- ...tings_log_csv_export_non_support_codes.csv | 4 +- ...ings_log_csv_export_non_support_labels.csv | 4 +- .../files/sales_logs_csv_export_codes.csv | 4 +- .../files/sales_logs_csv_export_labels.csv | 4 +- .../questions/nationality_all_group_spec.rb | 39 ++++ .../questions/nationality_all_spec.rb | 35 +++ ...ty1_spec.rb => buyer1_nationality_spec.rb} | 18 +- .../sales/pages/buyer2_nationality_spec.rb | 16 ++ ...ty1_spec.rb => buyer1_nationality_spec.rb} | 2 +- .../questions/nationality_all_group_spec.rb | 89 ++++++++ .../sales/questions/nationality_all_spec.rb | 73 +++++++ spec/models/lettings_log_spec.rb | 37 ++++ spec/models/sales_log_spec.rb | 19 ++ .../lettings/year2024/row_parser_spec.rb | 74 +++++++ .../sales/year2024/row_parser_spec.rb | 148 ++++++++++++- 40 files changed, 952 insertions(+), 52 deletions(-) create mode 100644 app/models/form/lettings/questions/nationality_all.rb create mode 100644 app/models/form/lettings/questions/nationality_all_group.rb create mode 100644 app/models/form/sales/pages/buyer1_nationality.rb delete mode 100644 app/models/form/sales/pages/nationality1.rb rename app/models/form/sales/questions/{nationality1.rb => buyer1_nationality.rb} (93%) create mode 100644 app/models/form/sales/questions/nationality_all.rb create mode 100644 app/models/form/sales/questions/nationality_all_group.rb create mode 100644 db/migrate/20240130084707_add_nationality_all.rb create mode 100644 spec/models/form/lettings/questions/nationality_all_group_spec.rb create mode 100644 spec/models/form/lettings/questions/nationality_all_spec.rb rename spec/models/form/sales/pages/{nationality1_spec.rb => buyer1_nationality_spec.rb} (58%) rename spec/models/form/sales/questions/{nationality1_spec.rb => buyer1_nationality_spec.rb} (96%) create mode 100644 spec/models/form/sales/questions/nationality_all_group_spec.rb create mode 100644 spec/models/form/sales/questions/nationality_all_spec.rb diff --git a/app/constants/global_constants.rb b/app/constants/global_constants.rb index c25bf7c92..f42af5253 100644 --- a/app/constants/global_constants.rb +++ b/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 diff --git a/app/helpers/question_view_helper.rb b/app/helpers/question_view_helper.rb index a656344ca..f280b4ee9 100644 --- a/app/helpers/question_view_helper.rb +++ b/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) - resource.locations.map(&:postcode).join(",") + 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) diff --git a/app/models/derived_variables/lettings_log_variables.rb b/app/models/derived_variables/lettings_log_variables.rb index fb174a9c1..d0aab14cb 100644 --- a/app/models/derived_variables/lettings_log_variables.rb +++ b/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 diff --git a/app/models/derived_variables/sales_log_variables.rb b/app/models/derived_variables/sales_log_variables.rb index 6532b228f..12d860492 100644 --- a/app/models/derived_variables/sales_log_variables.rb +++ b/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 diff --git a/app/models/form/lettings/pages/lead_tenant_nationality.rb b/app/models/form/lettings/pages/lead_tenant_nationality.rb index 09a25286c..9fc78644f 100644 --- a/app/models/form/lettings/pages/lead_tenant_nationality.rb +++ b/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 diff --git a/app/models/form/lettings/questions/nationality_all.rb b/app/models/form/lettings/questions/nationality_all.rb new file mode 100644 index 000000000..354622f2f --- /dev/null +++ b/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 diff --git a/app/models/form/lettings/questions/nationality_all_group.rb b/app/models/form/lettings/questions/nationality_all_group.rb new file mode 100644 index 000000000..2ba9e5cde --- /dev/null +++ b/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 diff --git a/app/models/form/sales/pages/buyer1_nationality.rb b/app/models/form/sales/pages/buyer1_nationality.rb new file mode 100644 index 000000000..6bcf12952 --- /dev/null +++ b/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 diff --git a/app/models/form/sales/pages/buyer2_nationality.rb b/app/models/form/sales/pages/buyer2_nationality.rb index bd89b2203..bbec2a105 100644 --- a/app/models/form/sales/pages/buyer2_nationality.rb +++ b/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 diff --git a/app/models/form/sales/pages/nationality1.rb b/app/models/form/sales/pages/nationality1.rb deleted file mode 100644 index 0fcc19b8f..000000000 --- a/app/models/form/sales/pages/nationality1.rb +++ /dev/null @@ -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 diff --git a/app/models/form/sales/questions/nationality1.rb b/app/models/form/sales/questions/buyer1_nationality.rb similarity index 93% rename from app/models/form/sales/questions/nationality1.rb rename to app/models/form/sales/questions/buyer1_nationality.rb index 68c2ce5ea..b30a94bc6 100644 --- a/app/models/form/sales/questions/nationality1.rb +++ b/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" diff --git a/app/models/form/sales/questions/nationality_all.rb b/app/models/form/sales/questions/nationality_all.rb new file mode 100644 index 000000000..4e2f95adb --- /dev/null +++ b/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 diff --git a/app/models/form/sales/questions/nationality_all_group.rb b/app/models/form/sales/questions/nationality_all_group.rb new file mode 100644 index 000000000..c9b1e71bc --- /dev/null +++ b/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 diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb index 34085c52a..187f7f34e 100644 --- a/app/models/form/sales/subsections/household_characteristics.rb +++ b/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), diff --git a/app/models/log.rb b/app/models/log.rb index 8814e771d..d99399da1 100644 --- a/app/models/log.rb +++ b/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 diff --git a/app/models/sales_log.rb b/app/models/sales_log.rb index 5acd409de..3f47dea80 100644 --- a/app/models/sales_log.rb +++ b/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 diff --git a/app/services/bulk_upload/lettings/year2024/row_parser.rb b/app/services/bulk_upload/lettings/year2024/row_parser.rb index 19bae0ecc..c87cd0c03 100644 --- a/app/services/bulk_upload/lettings/year2024/row_parser.rb +++ b/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 diff --git a/app/services/bulk_upload/sales/year2024/row_parser.rb b/app/services/bulk_upload/sales/year2024/row_parser.rb index 99d45aea2..037fb8eef 100644 --- a/app/services/bulk_upload/sales/year2024/row_parser.rb +++ b/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! diff --git a/app/services/csv/lettings_log_csv_service.rb b/app/services/csv/lettings_log_csv_service.rb index f1d744b5f..c853590b6 100644 --- a/app/services/csv/lettings_log_csv_service.rb +++ b/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| diff --git a/app/services/csv/sales_log_csv_service.rb b/app/services/csv/sales_log_csv_service.rb index 83c8e9cbf..a1fbc1ca9 100644 --- a/app/services/csv/sales_log_csv_service.rb +++ b/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?(/((? -<% 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, diff --git a/db/migrate/20240130084707_add_nationality_all.rb b/db/migrate/20240130084707_add_nationality_all.rb new file mode 100644 index 000000000..a273ee681 --- /dev/null +++ b/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 diff --git a/db/schema.rb b/db/schema.rb index f12d36ced..e6f2de905 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 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" diff --git a/spec/fixtures/files/lettings_log_csv_export_codes.csv b/spec/fixtures/files/lettings_log_csv_export_codes.csv index b6a35a6df..c68b53ae2 100644 --- a/spec/fixtures/files/lettings_log_csv_export_codes.csv +++ b/spec/fixtures/files/lettings_log_csv_export_codes.csv @@ -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,,,,,,,,,,,,,,,,,,,, diff --git a/spec/fixtures/files/lettings_log_csv_export_labels.csv b/spec/fixtures/files/lettings_log_csv_export_labels.csv index 293d21ca5..8722ed90c 100644 --- a/spec/fixtures/files/lettings_log_csv_export_labels.csv +++ b/spec/fixtures/files/lettings_log_csv_export_labels.csv @@ -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,,,,,,,,,,,,,,,,,,,, diff --git a/spec/fixtures/files/lettings_log_csv_export_non_support_codes.csv b/spec/fixtures/files/lettings_log_csv_export_non_support_codes.csv index 4ea7b4125..6989c0b9b 100644 --- a/spec/fixtures/files/lettings_log_csv_export_non_support_codes.csv +++ b/spec/fixtures/files/lettings_log_csv_export_non_support_codes.csv @@ -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,,,,,,,,,,,,,,,,,,,, diff --git a/spec/fixtures/files/lettings_log_csv_export_non_support_labels.csv b/spec/fixtures/files/lettings_log_csv_export_non_support_labels.csv index 6f1ca9aed..33a852a21 100644 --- a/spec/fixtures/files/lettings_log_csv_export_non_support_labels.csv +++ b/spec/fixtures/files/lettings_log_csv_export_non_support_labels.csv @@ -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,,,,,,,,,,,,,,,,,,,, diff --git a/spec/fixtures/files/sales_logs_csv_export_codes.csv b/spec/fixtures/files/sales_logs_csv_export_codes.csv index 2bfcb8fc7..ba344fed7 100644 --- a/spec/fixtures/files/sales_logs_csv_export_codes.csv +++ b/spec/fixtures/files/sales_logs_csv_export_codes.csv @@ -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 diff --git a/spec/fixtures/files/sales_logs_csv_export_labels.csv b/spec/fixtures/files/sales_logs_csv_export_labels.csv index 6d8660776..7ab05f910 100644 --- a/spec/fixtures/files/sales_logs_csv_export_labels.csv +++ b/spec/fixtures/files/sales_logs_csv_export_labels.csv @@ -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 diff --git a/spec/models/form/lettings/questions/nationality_all_group_spec.rb b/spec/models/form/lettings/questions/nationality_all_group_spec.rb new file mode 100644 index 000000000..ff8a47b59 --- /dev/null +++ b/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 diff --git a/spec/models/form/lettings/questions/nationality_all_spec.rb b/spec/models/form/lettings/questions/nationality_all_spec.rb new file mode 100644 index 000000000..07c993766 --- /dev/null +++ b/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 diff --git a/spec/models/form/sales/pages/nationality1_spec.rb b/spec/models/form/sales/pages/buyer1_nationality_spec.rb similarity index 58% rename from spec/models/form/sales/pages/nationality1_spec.rb rename to spec/models/form/sales/pages/buyer1_nationality_spec.rb index 47e291915..13b83f8f4 100644 --- a/spec/models/form/sales/pages/nationality1_spec.rb +++ b/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 diff --git a/spec/models/form/sales/pages/buyer2_nationality_spec.rb b/spec/models/form/sales/pages/buyer2_nationality_spec.rb index ba4c16b61..63bfbdb10 100644 --- a/spec/models/form/sales/pages/buyer2_nationality_spec.rb +++ b/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 diff --git a/spec/models/form/sales/questions/nationality1_spec.rb b/spec/models/form/sales/questions/buyer1_nationality_spec.rb similarity index 96% rename from spec/models/form/sales/questions/nationality1_spec.rb rename to spec/models/form/sales/questions/buyer1_nationality_spec.rb index 4b8816dbf..2e52016da 100644 --- a/spec/models/form/sales/questions/nationality1_spec.rb +++ b/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) } diff --git a/spec/models/form/sales/questions/nationality_all_group_spec.rb b/spec/models/form/sales/questions/nationality_all_group_spec.rb new file mode 100644 index 000000000..b0bfbbfc8 --- /dev/null +++ b/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 diff --git a/spec/models/form/sales/questions/nationality_all_spec.rb b/spec/models/form/sales/questions/nationality_all_spec.rb new file mode 100644 index 000000000..c228c459d --- /dev/null +++ b/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 diff --git a/spec/models/lettings_log_spec.rb b/spec/models/lettings_log_spec.rb index f2bbbe4be..5c55d87cb 100644 --- a/spec/models/lettings_log_spec.rb +++ b/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 diff --git a/spec/models/sales_log_spec.rb b/spec/models/sales_log_spec.rb index edaf4b60a..42aa64fec 100644 --- a/spec/models/sales_log_spec.rb +++ b/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 diff --git a/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb b/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb index 5f34ec80a..a37110785 100644 --- a/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb +++ b/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 }) } diff --git a/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb b/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb index 25e6a33f9..473967791 100644 --- a/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb +++ b/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) + 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 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