Browse Source

CLDC-3438 Update log csv download flow (#2403)

* Filter out empty options from selected filters

* Redirect to year filter if it is not selected

* Add remaining filter questions

* Display lettings filters CYA

* Add cancel, conditionally display send email

* Refactor

* Add removed tests

* Update method name

* Add sales logs filters

* Update tests

* Set label size on filter questions

* Refactor

* Deduplicate filter views

* Rename methods

* Authenticate pages

* Update filtering per organisation

* Update routing from CYA

* lint

* Refactor check_your_answers_filters_list

* Redirect if year is not given for sales csv

* Update formatted organisations methods

* Update missing and wrong copy

* Update cancel and back buttons

* CLDC-3442 Download logs csv per year (#2404)

* Specify year in lettings csv download service

* Specify year in sales csv download service

* Define non_question_fields per year

* Tidy up missing fields and tests

* Fix request tests

* Refactor

* Add missing param

* CLDC-3348 Update sales CSV for support (#2407)

* Update sales csv for support

* CLDC-3352 Update sales CSV address order (#2410)

* Update sales support csv address ordering

* Refactor

* CLDC-3367 Rename sales support CSV fields (#2413)

* Rename sales support CSV fields

* Update sales CSV user fields order (#2416)

* CLDC-2586 Rename scheme sensitive (#2405)

* Rename scheme sensitive in lettings csv

* Rename scheme sensitive in schemes csv

* CLDC-3347 Show soft validations in support CSVs only (#2406)

* Show soft validations in support csvs only

* CLDC-3352 Update lettings CSV address order (#2409)

* Update lettings support csv address ordering

* Refactor

* CLDC-3415/3421/3422 Add lettings CSV updates (#2415)

* Add first_time_property_let_as_social_housing to coordinators csv

* Update lettings CSV user fields order

* Remove new_old from lettings CSV

* Remove duplicate rent value check from CSV (#2423)

* Refactor CSV service (#2425)

* Extract and move lettings methods

* Extract and more sales methods
pull/2428/head
kosiakkatrina 8 months ago committed by GitHub
parent
commit
0e4950c2cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      app/controllers/lettings_logs_controller.rb
  2. 64
      app/controllers/lettings_logs_filters_controller.rb
  3. 8
      app/controllers/organisations_controller.rb
  4. 6
      app/controllers/sales_logs_controller.rb
  5. 65
      app/controllers/sales_logs_filters_controller.rb
  6. 87
      app/helpers/filters_helper.rb
  7. 6
      app/jobs/email_csv_job.rb
  8. 25
      app/models/form_handler.rb
  9. 173
      app/services/csv/lettings_log_csv_service.rb
  10. 196
      app/services/csv/sales_log_csv_service.rb
  11. 4
      app/services/csv/scheme_csv_service.rb
  12. 6
      app/services/filter_manager.rb
  13. 2
      app/views/filters/_checkbox_filter.html.erb
  14. 2
      app/views/filters/_radio_filter.html.erb
  15. 31
      app/views/filters/assigned_to.html.erb
  16. 30
      app/views/filters/managed_by.html.erb
  17. 20
      app/views/filters/needstype.html.erb
  18. 30
      app/views/filters/owned_by.html.erb
  19. 20
      app/views/filters/status.html.erb
  20. 37
      app/views/filters/years.html.erb
  21. 1
      app/views/locations/_location_filters.html.erb
  22. 7
      app/views/logs/_log_filters.html.erb
  23. 44
      app/views/logs/download_csv.html.erb
  24. 2
      app/views/schemes/_scheme_filters.html.erb
  25. 1
      app/views/users/_user_filters.html.erb
  26. 18
      config/routes.rb
  27. 99
      spec/features/lettings_log_spec.rb
  28. 92
      spec/features/sales_log_spec.rb
  29. 4
      spec/fixtures/files/lettings_log_csv_export_codes_23.csv
  30. 4
      spec/fixtures/files/lettings_log_csv_export_codes_24.csv
  31. 4
      spec/fixtures/files/lettings_log_csv_export_labels_23.csv
  32. 2
      spec/fixtures/files/lettings_log_csv_export_labels_23_during_24_period.csv
  33. 4
      spec/fixtures/files/lettings_log_csv_export_labels_24.csv
  34. 4
      spec/fixtures/files/lettings_log_csv_export_non_support_codes_23.csv
  35. 4
      spec/fixtures/files/lettings_log_csv_export_non_support_codes_24.csv
  36. 4
      spec/fixtures/files/lettings_log_csv_export_non_support_labels_23.csv
  37. 4
      spec/fixtures/files/lettings_log_csv_export_non_support_labels_24.csv
  38. 2
      spec/fixtures/files/original_schemes.csv
  39. 4
      spec/fixtures/files/sales_logs_csv_export_codes_23.csv
  40. 4
      spec/fixtures/files/sales_logs_csv_export_codes_24.csv
  41. 4
      spec/fixtures/files/sales_logs_csv_export_labels_23.csv
  42. 2
      spec/fixtures/files/sales_logs_csv_export_labels_23_during_24_period.csv
  43. 4
      spec/fixtures/files/sales_logs_csv_export_labels_24.csv
  44. 2
      spec/fixtures/files/sales_logs_csv_export_non_support_labels_24.csv
  45. 2
      spec/fixtures/files/schemes_and_locations_csv_export.csv
  46. 2
      spec/fixtures/files/schemes_csv_export.csv
  47. 2
      spec/fixtures/files/updated_schemes.csv
  48. 20
      spec/jobs/email_csv_job_spec.rb
  49. 228
      spec/models/form_handler_spec.rb
  50. 24
      spec/requests/delete_logs_controller_spec.rb
  51. 117
      spec/requests/lettings_logs_controller_spec.rb
  52. 59
      spec/requests/organisations_controller_spec.rb
  53. 96
      spec/requests/sales_logs_controller_spec.rb
  54. 85
      spec/services/csv/lettings_log_csv_service_spec.rb
  55. 161
      spec/services/csv/sales_log_csv_service_spec.rb
  56. 4
      spec/services/csv/scheme_csv_service_spec.rb

6
app/controllers/lettings_logs_controller.rb

@ -88,14 +88,16 @@ class LettingsLogsController < LogsController
end
def download_csv
redirect_to filters_years_lettings_logs_path(search: search_term, codes_only: codes_only_export?) and return if session_filters["years"].blank? || session_filters["years"].count != 1
unpaginated_filtered_logs = filter_manager.filtered_logs(current_user.lettings_logs, search_term, session_filters)
render "download_csv", locals: { search_term:, count: unpaginated_filtered_logs.size, post_path: email_csv_lettings_logs_path, codes_only: codes_only_export? }
render "download_csv", locals: { search_term:, count: unpaginated_filtered_logs.size, post_path: email_csv_lettings_logs_path, codes_only: codes_only_export?, session_filters:, filter_type: "lettings_logs", download_csv_back_link: lettings_logs_path }
end
def email_csv
all_orgs = params["organisation_select"] == "all"
EmailCsvJob.perform_later(current_user, search_term, session_filters, all_orgs, nil, codes_only_export?)
EmailCsvJob.perform_later(current_user, search_term, session_filters, all_orgs, nil, codes_only_export?, "lettings", session_filters["years"].first.to_i)
redirect_to csv_confirmation_lettings_logs_path
end

64
app/controllers/lettings_logs_filters_controller.rb

@ -0,0 +1,64 @@
class LettingsLogsFiltersController < ApplicationController
before_action :lettings_session_filters, if: :current_user
before_action -> { lettings_filter_manager.serialize_filters_to_session }, if: :current_user
before_action :authenticate_user!
%w[years status needstype assigned_to owned_by managed_by].each do |filter|
define_method(filter) do
@filter_type = "lettings_logs"
@filter = filter
render "filters/#{filter}"
end
define_method("organisation_#{filter}") do
@organisation_id = params["id"]
@filter_type = "lettings_logs"
@filter = filter
render "filters/#{filter}"
end
end
%w[status needstype assigned_to owned_by managed_by].each do |filter|
define_method("update_#{filter}") do
@filter_type = "lettings_logs"
redirect_to csv_download_lettings_logs_path(search: params["search"], codes_only: params["codes_only"])
end
define_method("update_organisation_#{filter}") do
@organisation_id = params["id"]
@filter_type = "lettings_logs"
redirect_to lettings_logs_csv_download_organisation_path(params["id"], search: params["search"], codes_only: params["codes_only"])
end
end
def update_years
@filter_type = "lettings_logs"
if params["years"].nil?
redirect_to filters_years_lettings_logs_path(search: params["search"], codes_only: params["codes_only"], error: "Please select a year")
else
redirect_to csv_download_lettings_logs_path(search: params["search"], codes_only: params["codes_only"])
end
end
def update_organisation_years
@filter_type = "lettings_logs"
@organisation_id = params["id"]
if params["years"].nil?
redirect_to lettings_logs_filters_years_organisation_path(search: params["search"], codes_only: params["codes_only"], error: "Please select a year")
else
redirect_to lettings_logs_csv_download_organisation_path(params["id"], search: params["search"], codes_only: params["codes_only"])
end
end
end
private
def lettings_session_filters
params["years"] = [params["years"]] if params["years"].present?
lettings_filter_manager.session_filters
end
def lettings_filter_manager
FilterManager.new(current_user:, session:, params:, filter_type: "lettings_logs")
end

8
app/controllers/organisations_controller.rb

@ -148,11 +148,13 @@ class OrganisationsController < ApplicationController
end
def download_lettings_csv
redirect_to lettings_logs_filters_years_organisation_path(search: search_term, codes_only: codes_only_export?) and return if session_filters["years"].blank? || session_filters["years"].count != 1
organisation_logs = LettingsLog.visible.where(owning_organisation_id: @organisation.id)
unpaginated_filtered_logs = filter_manager.filtered_logs(organisation_logs, search_term, session_filters)
codes_only = params.require(:codes_only) == "true"
render "logs/download_csv", locals: { search_term:, count: unpaginated_filtered_logs.size, post_path: lettings_logs_email_csv_organisation_path, codes_only: }
render "logs/download_csv", locals: { search_term:, count: unpaginated_filtered_logs.size, post_path: lettings_logs_email_csv_organisation_path, codes_only:, session_filters:, filter_type: "lettings_logs", download_csv_back_link: lettings_logs_organisation_path(@organisation) }
end
def email_lettings_csv
@ -184,11 +186,13 @@ class OrganisationsController < ApplicationController
end
def download_sales_csv
redirect_to sales_logs_filters_years_organisation_path(search: search_term, codes_only: codes_only_export?) and return if session_filters["years"].blank? || session_filters["years"].count != 1
organisation_logs = SalesLog.visible.where(owning_organisation_id: @organisation.id)
unpaginated_filtered_logs = filter_manager.filtered_logs(organisation_logs, search_term, session_filters)
codes_only = params.require(:codes_only) == "true"
render "logs/download_csv", locals: { search_term:, count: unpaginated_filtered_logs.size, post_path: sales_logs_email_csv_organisation_path, codes_only: }
render "logs/download_csv", locals: { search_term:, count: unpaginated_filtered_logs.size, post_path: sales_logs_email_csv_organisation_path, codes_only:, session_filters:, filter_type: "sales_logs", download_csv_back_link: sales_logs_organisation_path(@organisation) }
end
def email_sales_csv

6
app/controllers/sales_logs_controller.rb

@ -62,14 +62,16 @@ class SalesLogsController < LogsController
end
def download_csv
redirect_to filters_years_sales_logs_path(search: search_term, codes_only: codes_only_export?) and return if session_filters["years"].blank? || session_filters["years"].count != 1
unpaginated_filtered_logs = filter_manager.filtered_logs(current_user.sales_logs, search_term, session_filters)
render "download_csv", locals: { search_term:, count: unpaginated_filtered_logs.size, post_path: email_csv_sales_logs_path, codes_only: codes_only_export? }
render "download_csv", locals: { search_term:, count: unpaginated_filtered_logs.size, post_path: email_csv_sales_logs_path, codes_only: codes_only_export?, session_filters:, filter_type: "sales_logs", download_csv_back_link: sales_logs_path }
end
def email_csv
all_orgs = params["organisation_select"] == "all"
EmailCsvJob.perform_later(current_user, search_term, session_filters, all_orgs, nil, codes_only_export?, "sales")
EmailCsvJob.perform_later(current_user, search_term, session_filters, all_orgs, nil, codes_only_export?, "sales", session_filters["years"].first.to_i)
redirect_to csv_confirmation_sales_logs_path
end

65
app/controllers/sales_logs_filters_controller.rb

@ -0,0 +1,65 @@
class SalesLogsFiltersController < ApplicationController
before_action :sales_session_filters, if: :current_user
before_action -> { sales_filter_manager.serialize_filters_to_session }, if: :current_user
before_action :authenticate_user!
%w[years status assigned_to owned_by managed_by].each do |filter|
define_method(filter) do
@filter_type = "sales_logs"
@filter = filter
render "filters/#{filter}"
end
define_method("organisation_#{filter}") do
@filter_type = "sales_logs"
@organisation_id = params["id"]
@filter = filter
render "filters/#{filter}"
end
end
%w[status assigned_to owned_by managed_by].each do |filter|
define_method("update_#{filter}") do
@filter_type = "sales_logs"
redirect_to csv_download_sales_logs_path(search: params["search"], codes_only: params["codes_only"])
end
define_method("update_organisation_#{filter}") do
@organisation_id = params["id"]
@filter_type = "sales_logs"
redirect_to sales_logs_csv_download_organisation_path(params["id"], search: params["search"], codes_only: params["codes_only"])
end
end
def update_years
@filter_type = "sales_logs"
if params["years"].nil?
redirect_to filters_years_sales_logs_path(search: params["search"], codes_only: params["codes_only"], error: "Please select a year")
else
redirect_to csv_download_sales_logs_path(search: params["search"], codes_only: params["codes_only"])
end
end
def update_organisation_years
@filter_type = "sales_logs"
@organisation_id = params["id"]
if params["years"].nil?
redirect_to sales_logs_filters_years_organisation_path(search: params["search"], codes_only: params["codes_only"], error: "Please select a year")
else
redirect_to sales_logs_csv_download_organisation_path(params["id"], search: params["search"], codes_only: params["codes_only"])
end
end
end
private
def sales_session_filters
params["years"] = [params["years"]] if params["years"].present?
sales_filter_manager.session_filters
end
def sales_filter_manager
FilterManager.new(current_user:, session:, params:, filter_type: "sales_logs")
end

87
app/helpers/filters_helper.rb

@ -102,6 +102,14 @@ module FiltersHelper
}
end
def collection_year_radio_options
{
current_collection_start_year.to_s => { label: year_combo(current_collection_start_year) },
previous_collection_start_year.to_s => { label: year_combo(previous_collection_start_year) },
archived_collection_start_year.to_s => { label: year_combo(archived_collection_start_year) },
}
end
def filters_applied_text(filter_type)
applied_filters_count(filter_type).zero? ? "No filters applied" : "#{pluralize(applied_filters_count(filter_type), 'filter')} applied"
end
@ -157,6 +165,41 @@ module FiltersHelper
filters_count(applied_filters(filter_type))
end
def check_your_answers_filters_list(session_filters, filter_type)
[
{ id: "years", label: "Collection year", value: formatted_years_filter(session_filters) },
{ id: "status", label: "Status", value: formatted_status_filter(session_filters) },
filter_type == "lettings_logs" ? { id: "needstype", label: "Needs type", value: formatted_needstype_filter(session_filters) } : nil,
{ id: "assigned_to", label: "Assigned to", value: formatted_assigned_to_filter(session_filters) },
{ id: "owned_by", label: "Owned by", value: formatted_owned_by_filter(session_filters) },
{ id: "managed_by", label: "Managed by", value: formatted_managed_by_filter(session_filters) },
].compact
end
def update_csv_filters_url(filter_type, filter, organisation_id)
if organisation_id.present?
send("#{filter_type}_filters_update_#{filter}_organisation_path", organisation_id)
else
send("filters_update_#{filter}_#{filter_type}_path")
end
end
def cancel_csv_filters_update_url(filter_type, search, codes_only, organisation_id)
if organisation_id.present?
send("#{filter_type}_csv_download_organisation_path", id: organisation_id, search:, codes_only:)
else
send("csv_download_#{filter_type}_path", search:, codes_only:)
end
end
def change_filter_for_csv_url(filter, filter_type, search_term, codes_only, organisation_id)
if organisation_id.present?
send("#{filter_type}_filters_#{filter[:id]}_organisation_path", organisation_id, search: search_term, codes_only:, referrer: "check_answers")
else
send("filters_#{filter[:id]}_#{filter_type}_path", search: search_term, codes_only:, referrer: "check_answers")
end
end
private
def applied_filters(filter_type)
@ -184,4 +227,48 @@ private
def year_combo(year)
"#{year}/#{year - 2000 + 1}"
end
def formatted_years_filter(session_filters)
return unanswered_filter_value if session_filters["years"].blank?
session_filters["years"].map { |year| year_combo(year.to_i) }.to_sentence
end
def formatted_status_filter(session_filters)
return unanswered_filter_value if session_filters["status"].blank?
session_filters["status"].map { |status| status_filters[status] }.to_sentence
end
def formatted_needstype_filter(session_filters)
return unanswered_filter_value if session_filters["needstypes"].blank?
session_filters["needstypes"].map { |needstype| needstype_filters[needstype] }.to_sentence
end
def formatted_assigned_to_filter(session_filters)
return unanswered_filter_value if session_filters["assigned_to"].blank?
return "All" if session_filters["assigned_to"].include?("all")
return "You" if session_filters["assigned_to"].include?("you")
user = User.find(session_filters["user"].first)
"#{user.name} (#{user.email})"
end
def formatted_owned_by_filter(session_filters)
return "All" if params["id"].blank? && (session_filters["owning_organisation"].blank? || session_filters["owning_organisation"]&.include?("all"))
session_org_id = session_filters["owning_organisation"]
Organisation.find(session_org_id || params["id"])&.name
end
def formatted_managed_by_filter(session_filters)
return "All" if session_filters["managing_organisation"].blank? || session_filters["managing_organisation"].include?("all")
Organisation.find(session_filters["managing_organisation"])&.name
end
def unanswered_filter_value
"<span class=\"app-!-colour-muted\">You didn’t answer this filter</span>".html_safe
end
end

6
app/jobs/email_csv_job.rb

@ -5,17 +5,17 @@ class EmailCsvJob < ApplicationJob
EXPIRATION_TIME = 24.hours.to_i
def perform(user, search_term = nil, filters = {}, all_orgs = false, organisation = nil, codes_only_export = false, log_type = "lettings") # rubocop:disable Style/OptionalBooleanParameter - sidekiq can't serialise named params
def perform(user, search_term = nil, filters = {}, all_orgs = false, organisation = nil, codes_only_export = false, log_type = "lettings", year = nil) # rubocop:disable Style/OptionalBooleanParameter - sidekiq can't serialise named params
export_type = codes_only_export ? "codes" : "labels"
case log_type
when "lettings"
unfiltered_logs = organisation.present? && user.support? ? LettingsLog.visible.where(owning_organisation_id: organisation.id) : user.lettings_logs.visible
filtered_logs = FilterManager.filter_logs(unfiltered_logs, search_term, filters, all_orgs, user)
csv_string = Csv::LettingsLogCsvService.new(user:, export_type:).prepare_csv(filtered_logs)
csv_string = Csv::LettingsLogCsvService.new(user:, export_type:, year:).prepare_csv(filtered_logs)
when "sales"
unfiltered_logs = organisation.present? && user.support? ? SalesLog.visible.where(owning_organisation_id: organisation.id) : user.sales_logs.visible
filtered_logs = FilterManager.filter_logs(unfiltered_logs, search_term, filters, all_orgs, user)
csv_string = Csv::SalesLogCsvService.new(user:, export_type:).prepare_csv(filtered_logs)
csv_string = Csv::SalesLogCsvService.new(user:, export_type:, year:).prepare_csv(filtered_logs)
end
filename = "#{[log_type, 'logs', organisation&.name, Time.zone.now].compact.join('-')}.csv"

25
app/models/form_handler.rb

@ -61,26 +61,13 @@ class FormHandler
@sales_forms
end
def ordered_sales_questions_for_all_years
ordered_questions = current_sales_form.questions.uniq(&:id)
all_sales_forms = forms.filter { |name, _form| name.end_with? "sales" }.values
all_questions_from_available_sales_forms = all_sales_forms.flat_map(&:questions)
deprecated_questions_by_preceding_question_id(ordered_questions, all_questions_from_available_sales_forms).each do |preceding_question_id, deprecated_question|
index_of_preceding_question = ordered_questions.index { |q| q.id == preceding_question_id }
ordered_questions.insert(index_of_preceding_question + 1, deprecated_question)
end
ordered_questions
end
def ordered_questions_for_year(year, type)
return [] unless year
def ordered_lettings_questions_for_all_years
ordered_questions = current_lettings_form.questions.uniq(&:id)
all_lettings_forms = forms.filter { |name, _form| name.end_with? "lettings" }.values
all_questions_from_available_lettings_forms = all_lettings_forms.flat_map(&:questions)
deprecated_questions_by_preceding_question_id(ordered_questions, all_questions_from_available_lettings_forms).each do |preceding_question_id, deprecated_question|
index_of_preceding_question = ordered_questions.index { |q| q.id == preceding_question_id }
ordered_questions.insert(index_of_preceding_question + 1, deprecated_question)
end
ordered_questions
form_for_year = forms[form_name_from_start_year(year, type)]
return [] unless form_for_year
form_for_year.questions.uniq(&:id)
end
def deprecated_questions_by_preceding_question_id(current_form_questions, all_questions_from_previous_forms)

173
app/services/csv/lettings_log_csv_service.rb

@ -1,8 +1,9 @@
module Csv
class LettingsLogCsvService
def initialize(user:, export_type:)
def initialize(user:, export_type:, year:)
@user = user
@export_type = export_type
@year = year
@attributes = lettings_log_attributes
end
@ -67,7 +68,7 @@ module Csv
labels: %i[scheme service_name],
codes: %i[scheme service_name],
},
scheme_sensitive: {
scheme_confidential: {
labels: %i[scheme sensitive],
codes: %i[scheme sensitive_before_type_cast],
},
@ -156,64 +157,6 @@ module Csv
voiddate
].freeze
def value(attribute, log)
attribute = "rent_type" if attribute == "rent_type_detail" # rent_type_detail is the requested column header for rent_type, so as not to confuse with renttype. It can be exported as label or code.
if CUSTOM_CALL_CHAINS.key? attribute.to_sym
call_chain = CUSTOM_CALL_CHAINS[attribute.to_sym][@export_type.to_sym]
call_chain.reduce(log) { |object, next_call| object&.public_send(next_call) }
elsif FIELDS_ALWAYS_EXPORTED_AS_CODES.include? attribute
log.public_send(attribute)
elsif FIELDS_ALWAYS_EXPORTED_AS_LABELS.key? attribute
attribute = FIELDS_ALWAYS_EXPORTED_AS_LABELS[attribute]
value = log.public_send(attribute)
get_label(value, attribute, log)
elsif SYSTEM_DATE_FIELDS.include? attribute
log.public_send(attribute)&.iso8601
elsif USER_DATE_FIELDS.include? attribute
log.public_send(attribute)&.strftime("%F")
elsif PERSON_DETAILS.any? { |key, _value| key == attribute } && (person_details_not_known?(log, attribute) || age_not_known?(log, attribute))
case @export_type
when "codes"
PERSON_DETAILS.find { |key, _value| key == attribute }[1]["refused_code"]
when "labels"
PERSON_DETAILS.find { |key, _value| key == attribute }[1]["refused_label"]
end
else
value = log.public_send(attribute)
case @export_type
when "codes"
value
when "labels"
answer_label = get_label(value, attribute, log)
answer_label || label_if_boolean_value(value) || (YES_OR_BLANK_ATTRIBUTES.include?(attribute) && value != 1 ? nil : value)
end
end
end
def get_label(value, attribute, log)
return LABELS[attribute][value] if LABELS.key?(attribute)
return conventional_yes_no_label(value) if CONVENTIONAL_YES_NO_ATTRIBUTES.include?(attribute)
return "Yes" if YES_OR_BLANK_ATTRIBUTES.include?(attribute) && value == 1
log.form
.get_question(attribute, log)
&.label_from_value(value)
end
def label_if_boolean_value(value)
return "Yes" if value == true
return "No" if value == false
end
def conventional_yes_no_label(value)
return "Yes" if value == 1
return "No" if value&.zero?
end
def yes_or_blank_label(value)
value == 1 ? "Yes" : nil
end
LETTYPE_LABELS = {
1 => "Social rent general needs private registered provider",
2 => "Social rent supported housing private registered provider",
@ -286,7 +229,6 @@ module Csv
"la" => %w[is_la_inferred la_label la],
"prevloc" => %w[is_previous_la_inferred prevloc_label prevloc],
"needstype" => %w[needstype lettype],
"prevten" => %w[prevten new_old],
"voiddate" => %w[voiddate vacdays],
"rsnvac" => %w[rsnvac newprop],
"household_charge" => %w[household_charge nocharge],
@ -300,12 +242,24 @@ module Csv
"letting_allocation_unknown" => %w[letting_allocation_none],
}.freeze
SUPPORT_ONLY_ATTRIBUTES = %w[net_income_value_check first_time_property_let_as_social_housing postcode_known is_la_inferred totchild totelder totadult net_income_known previous_la_known is_previous_la_inferred age1_known age2_known age3_known age4_known age5_known age6_known age7_known age8_known details_known_2 details_known_3 details_known_4 details_known_5 details_known_6 details_known_7 details_known_8 wrent wscharge wpschrge wsupchrg wtcharge wtshortfall rent_value_check old_form_id old_id retirement_value_check tshortfall_known pregnancy_value_check hhtype new_old la prevloc updated_by_id bulk_upload_id uprn_confirmed address_line1_input postcode_full_input address_search_value_check uprn_selection reasonother_value_check address_line1_as_entered address_line2_as_entered town_or_city_as_entered county_as_entered postcode_full_as_entered la_as_entered created_by].freeze
ORDERED_ADDRESS_FIELDS = %w[uprn address_line1 address_line2 town_or_city county postcode_full is_la_inferred la_label la uprn_known uprn_selection address_search_value_check address_line1_input postcode_full_input address_line1_as_entered address_line2_as_entered town_or_city_as_entered county_as_entered postcode_full_as_entered la_as_entered].freeze
SUPPORT_ONLY_ATTRIBUTES = %w[postcode_known is_la_inferred totchild totelder totadult net_income_known previous_la_known is_previous_la_inferred age1_known age2_known age3_known age4_known age5_known age6_known age7_known age8_known details_known_2 details_known_3 details_known_4 details_known_5 details_known_6 details_known_7 details_known_8 wrent wscharge wpschrge wsupchrg wtcharge wtshortfall old_form_id old_id tshortfall_known hhtype la prevloc updated_by_id uprn_confirmed address_line1_input postcode_full_input uprn_selection address_line1_as_entered address_line2_as_entered town_or_city_as_entered county_as_entered postcode_full_as_entered la_as_entered created_by].freeze
SCHEME_AND_LOCATION_ATTRIBUTES = %w[scheme_code scheme_service_name scheme_confidential 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].freeze
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|nationality_all_group/) }
attributes = ordered_questions.flat_map do |question|
ordered_questions = FormHandler.instance.ordered_questions_for_year(@year, "lettings")
soft_validations_attributes = soft_validations_attributes(ordered_questions)
ordered_questions.reject! { |q| q.id.match?(/age\d_known|nationality_all_group|rent_value_check/) }
attributes = insert_derived_and_related_attributes(ordered_questions)
order_address_fields_for_support(attributes)
final_attributes = non_question_fields + attributes + SCHEME_AND_LOCATION_ATTRIBUTES
@user.support? ? final_attributes : final_attributes - SUPPORT_ONLY_ATTRIBUTES - soft_validations_attributes
end
def insert_derived_and_related_attributes(ordered_questions)
ordered_questions.flat_map do |question|
if question.type == "checkbox"
question.answer_options.keys.reject { |key| key == "divider" }.map { |key|
ATTRIBUTE_MAPPINGS.fetch(key, key)
@ -314,10 +268,71 @@ module Csv
ATTRIBUTE_MAPPINGS.fetch(question.id, question.id)
end
end
non_question_fields = %w[id status duplicate_set_id assigned_to is_dpo created_at updated_by updated_at creation_method old_id old_form_id collection_start_year address_line1_as_entered address_line2_as_entered town_or_city_as_entered county_as_entered postcode_full_as_entered la_as_entered created_by]
scheme_and_location_attributes = %w[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]
final_attributes = non_question_fields + attributes + scheme_and_location_attributes
@user.support? ? final_attributes : final_attributes - SUPPORT_ONLY_ATTRIBUTES
end
def order_address_fields_for_support(attributes)
if @user.support? && @year >= 2024
first_address_field_index = attributes.find_index { |q| all_address_fields.include?(q) }
if first_address_field_index
attributes.reject! { |q| all_address_fields.include?(q) }
attributes.insert(first_address_field_index, *ORDERED_ADDRESS_FIELDS)
end
end
end
def all_address_fields
ORDERED_ADDRESS_FIELDS + %w[uprn_confirmed]
end
def non_question_fields
case @year
when 2022
%w[id status created_by assigned_to is_dpo created_at updated_by updated_at creation_method old_id old_form_id collection_start_year]
when 2023
%w[id status duplicate_set_id created_by assigned_to is_dpo created_at updated_by updated_at creation_method old_id old_form_id collection_start_year]
when 2024
%w[id status duplicate_set_id created_by assigned_to is_dpo created_at updated_by updated_at creation_method collection_start_year bulk_upload_id]
else
%w[id status duplicate_set_id created_by assigned_to is_dpo created_at updated_by updated_at creation_method collection_start_year bulk_upload_id]
end
end
def soft_validations_attributes(ordered_questions)
ordered_questions.select { |q| q.type == "interruption_screen" }.map(&:id)
end
def value(attribute, log)
attribute = "rent_type" if attribute == "rent_type_detail" # rent_type_detail is the requested column header for rent_type, so as not to confuse with renttype. It can be exported as label or code.
if CUSTOM_CALL_CHAINS.key? attribute.to_sym
call_chain = CUSTOM_CALL_CHAINS[attribute.to_sym][@export_type.to_sym]
call_chain.reduce(log) { |object, next_call| object&.public_send(next_call) }
elsif FIELDS_ALWAYS_EXPORTED_AS_CODES.include? attribute
log.public_send(attribute)
elsif FIELDS_ALWAYS_EXPORTED_AS_LABELS.key? attribute
attribute = FIELDS_ALWAYS_EXPORTED_AS_LABELS[attribute]
value = log.public_send(attribute)
get_label(value, attribute, log)
elsif SYSTEM_DATE_FIELDS.include? attribute
log.public_send(attribute)&.iso8601
elsif USER_DATE_FIELDS.include? attribute
log.public_send(attribute)&.strftime("%F")
elsif PERSON_DETAILS.any? { |key, _value| key == attribute } && (person_details_not_known?(log, attribute) || age_not_known?(log, attribute))
case @export_type
when "codes"
PERSON_DETAILS.find { |key, _value| key == attribute }[1]["refused_code"]
when "labels"
PERSON_DETAILS.find { |key, _value| key == attribute }[1]["refused_label"]
end
else
value = log.public_send(attribute)
case @export_type
when "codes"
value
when "labels"
answer_label = get_label(value, attribute, log)
answer_label || label_if_boolean_value(value) || (YES_OR_BLANK_ATTRIBUTES.include?(attribute) && value != 1 ? nil : value)
end
end
end
def person_details_not_known?(log, attribute)
@ -329,5 +344,25 @@ module Csv
age_known_field = PERSON_DETAILS.find { |key, _value| key == attribute }[1]["age_known_field"]
log[age_known_field] == 1
end
def get_label(value, attribute, log)
return LABELS[attribute][value] if LABELS.key?(attribute)
return conventional_yes_no_label(value) if CONVENTIONAL_YES_NO_ATTRIBUTES.include?(attribute)
return "Yes" if YES_OR_BLANK_ATTRIBUTES.include?(attribute) && value == 1
log.form
.get_question(attribute, log)
&.label_from_value(value)
end
def label_if_boolean_value(value)
return "Yes" if value == true
return "No" if value == false
end
def conventional_yes_no_label(value)
return "Yes" if value == 1
return "No" if value&.zero?
end
end
end

196
app/services/csv/sales_log_csv_service.rb

@ -1,14 +1,15 @@
module Csv
class SalesLogCsvService
def initialize(user:, export_type:)
def initialize(user:, export_type:, year:)
@user = user
@export_type = export_type
@year = year
@attributes = sales_log_attributes
end
def prepare_csv(logs)
CSV.generate(headers: true) do |csv|
csv << @attributes
csv << formatted_attribute_headers
logs.find_each do |log|
csv << @attributes.map { |attribute| value(attribute, log) }
@ -55,6 +56,10 @@ module Csv
labels: %i[creation_method],
codes: %i[creation_method_before_type_cast],
},
mscharge_value_check: {
labels: %i[monthly_charges_value_check],
codes: %i[monthly_charges_value_check],
},
}.freeze
PERSON_DETAILS = {}.tap { |hash|
@ -82,6 +87,139 @@ module Csv
updated_at
].freeze
ORDERED_ADDRESS_FIELDS = %w[uprn address_line1 address_line2 town_or_city county postcode_full is_la_inferred la_label la uprn_selection address_search_value_check address_line1_input postcode_full_input address_line1_as_entered address_line2_as_entered town_or_city_as_entered county_as_entered postcode_full_as_entered la_as_entered].freeze
SUPPORT_ONLY_ATTRIBUTES = %w[address_line1_as_entered address_line2_as_entered town_or_city_as_entered county_as_entered postcode_full_as_entered la_as_entered created_by value_value_check mscharge_value_check].freeze
SUPPORT_ATTRIBUTE_NAME_MAPPINGS = {
"duplicate_set_id" => "DUPLICATESET",
"bulk_upload_id" => "BULKUPLOADID",
"created_at" => "CREATEDDATE",
"updated_at" => "UPLOADDATE",
"old_form_id" => "FORM",
"collection_start_year" => "COLLECTIONYEAR",
"creation_method" => "CREATIONMETHOD",
"is_dpo" => "DATAPROTECT",
"created_by" => "CREATEDBY",
"owning_organisation_name" => "OWNINGORGNAME",
"managing_organisation_name" => "MANINGORGNAME",
"assigned_to" => "USERNAME",
"ownershipsch" => "OWNERSHIP",
"companybuy" => "COMPANY",
"buylivein" => "LIVEINBUYER",
"jointpur" => "JOINT",
"address_line1" => "ADDRESS1",
"address_line2" => "ADDRESS2",
"town_or_city" => "TOWNCITY",
"postcode_full" => "POSTCODE",
"is_la_inferred" => "ISLAINFERRED",
"la_label" => "LANAME",
"uprn_selection" => "UPRNSELECTED",
"address_line1_input" => "ADDRESS1INPUT",
"postcode_full_input" => "POSTCODEINPUT",
"address_line1_as_entered" => "BULKADDRESS1",
"address_line2_as_entered" => "BULKADDRESS2",
"town_or_city_as_entered" => "BULKTOWNCITY",
"county_as_entered" => "BULKCOUNTY",
"postcode_full_as_entered" => "BULKPOSTCODE",
"la_as_entered" => "BULKLA",
"ethnic_group" => "ETHNICGROUP1",
"nationality_all" => "NATIONALITYALL1",
"buy1livein" => "LIVEINBUYER1",
"ethnic_group2" => "ETHNICGROUP2",
"ethnicbuy2" => "ETHNIC2",
"nationality_all_buyer2" => "NATIONALITYALL2",
"buy2livein" => "LIVEINBUYER2",
"hholdcount" => "HHTYPE",
"previous_la_known" => "PREVIOUSLAKNOWN",
"prevloc_label" => "PREVLOCNAME",
"prevtenbuy2" => "PREVTEN2",
"income1nk" => "INC1NK",
"income2nk" => "INC2NK",
"staircasesale" => "STAIRCASETOSALE",
"soctenant" => "SOCTEN",
"mortlen" => "MORTLEN1",
"has_mscharge" => "HASMSCHARGE",
"nationalbuy2" => "NATIONAL2",
"uprn_confirmed" => "UPRNCONFIRMED",
}.freeze
def formatted_attribute_headers
return @attributes unless @user.support?
@attributes.map do |attribute|
SUPPORT_ATTRIBUTE_NAME_MAPPINGS[attribute] || attribute.upcase
end
end
def sales_log_attributes
ordered_questions = FormHandler.instance.ordered_questions_for_year(@year, "sales")
ordered_questions.reject! { |q| q.id.match?(/((?<!la)_known)|(_check)|(_asked)|nationality_all_group|nationality_all_buyer2_group/) }
attributes = insert_derived_and_related_attributes(ordered_questions)
order_address_fields_for_support(attributes)
final_attributes = non_question_fields + attributes
@user.support? ? final_attributes : final_attributes - SUPPORT_ONLY_ATTRIBUTES
end
def insert_derived_and_related_attributes(ordered_questions)
ordered_questions.flat_map do |question|
if question.type == "checkbox"
question.answer_options.keys
elsif attribute_mappings.key? question.id
attribute_mappings[question.id]
else
question.id
end
end
end
def attribute_mappings
mappings = {
"saledate" => %w[day month year],
"exdate" => %w[exday exmonth exyear],
"hodate" => %w[hoday homonth hoyear],
"ppostcode_full" => %w[ppostc1 ppostc2],
"la" => %w[la la_label],
"prevloc" => %w[prevloc prevloc_label],
"assigned_to_id" => %w[created_by assigned_to],
"owning_organisation_id" => %w[owning_organisation_name],
"managing_organisation_id" => %w[managing_organisation_name],
"value" => %w[value value_value_check],
"mscharge" => %w[mscharge mscharge_value_check],
}
unless @user.support? && @year >= 2024
mappings["postcode_full"] = %w[pcode1 pcode2]
end
mappings
end
def order_address_fields_for_support(attributes)
if @user.support? && @year >= 2024
first_address_field_index = attributes.find_index { |q| all_address_fields.include?(q) }
if first_address_field_index
attributes.reject! { |q| all_address_fields.include?(q) }
attributes.insert(first_address_field_index, *ORDERED_ADDRESS_FIELDS)
end
end
end
def non_question_fields
case @year
when 2022
%w[id status created_at updated_at old_form_id collection_start_year creation_method is_dpo]
when 2023
%w[id status duplicate_set_id created_at updated_at old_form_id collection_start_year creation_method is_dpo]
when 2024
%w[id status duplicate_set_id created_at updated_at collection_start_year creation_method bulk_upload_id is_dpo]
else
%w[id status duplicate_set_id created_at updated_at collection_start_year creation_method bulk_upload_id is_dpo]
end
end
def all_address_fields
ORDERED_ADDRESS_FIELDS + %w[uprn_confirmed]
end
def value(attribute, log)
if CUSTOM_CALL_CHAINS.key? attribute.to_sym
call_chain = CUSTOM_CALL_CHAINS[attribute.to_sym][@export_type.to_sym]
@ -94,7 +232,7 @@ module Csv
get_label(value, attribute, log)
elsif SYSTEM_DATE_FIELDS.include? attribute
log.public_send(attribute)&.iso8601
elsif PERSON_DETAILS.any? { |key, _value| key == attribute } && (person_details_not_known?(log, attribute) || age_not_known?(log, attribute))
elsif PERSON_DETAILS.key?(attribute) && (person_details_not_known?(log, attribute) || age_not_known?(log, attribute))
case @export_type
when "codes"
PERSON_DETAILS.find { |key, _value| key == attribute }[1]["refused_code"]
@ -113,6 +251,16 @@ module Csv
end
end
def person_details_not_known?(log, attribute)
details_known_field = PERSON_DETAILS.find { |key, _value| key == attribute }[1]["details_known_field"]
log[details_known_field] == 2 # 1 for lettings logs, 2 for sales logs
end
def age_not_known?(log, attribute)
age_known_field = PERSON_DETAILS.find { |key, _value| key == attribute }[1]["age_known_field"]
log[age_known_field] == 1
end
def get_label(value, attribute, log)
log.form
.get_question(attribute, log)
@ -123,47 +271,5 @@ module Csv
return "Yes" if value == true
return "No" if value == false
end
ATTRIBUTE_MAPPINGS = {
"saledate" => %w[day month year],
"exdate" => %w[exday exmonth exyear],
"hodate" => %w[hoday homonth hoyear],
"postcode_full" => %w[pcode1 pcode2],
"ppostcode_full" => %w[ppostc1 ppostc2],
"la" => %w[la la_label],
"prevloc" => %w[prevloc prevloc_label],
"assigned_to_id" => %w[assigned_to],
"owning_organisation_id" => %w[owning_organisation_name],
"managing_organisation_id" => %w[managing_organisation_name],
}.freeze
SUPPORT_ONLY_ATTRIBUTES = %w[address_line1_as_entered address_line2_as_entered town_or_city_as_entered county_as_entered postcode_full_as_entered la_as_entered created_by].freeze
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)|nationality_all_group|nationality_all_buyer2_group/) }
attributes = ordered_questions.flat_map do |question|
if question.type == "checkbox"
question.answer_options.keys
elsif ATTRIBUTE_MAPPINGS.key? question.id
ATTRIBUTE_MAPPINGS[question.id]
else
question.id
end
end
non_question_fields = %w[id status duplicate_set_id created_at updated_at old_form_id collection_start_year creation_method is_dpo address_line1_as_entered address_line2_as_entered town_or_city_as_entered county_as_entered postcode_full_as_entered la_as_entered created_by]
final_attributes = non_question_fields + attributes
@user.support? ? final_attributes : final_attributes - SUPPORT_ONLY_ATTRIBUTES
end
def person_details_not_known?(log, attribute)
details_known_field = PERSON_DETAILS.find { |key, _value| key == attribute }[1]["details_known_field"]
log[details_known_field] == 2 # 1 for lettings logs, 2 for sales logs
end
def age_not_known?(log, attribute)
age_known_field = PERSON_DETAILS.find { |key, _value| key == attribute }[1]["age_known_field"]
log[age_known_field] == 1
end
end
end

4
app/services/csv/scheme_csv_service.rb

@ -38,7 +38,7 @@ module Csv
"scheme_code" => "id_to_display",
"scheme_service_name" => "service_name",
"scheme_status" => "status",
"scheme_sensitive" => "sensitive",
"scheme_confidential" => "sensitive",
"scheme_registered_under_care_act" => "registered_under_care_act",
"scheme_support_services_provided_by" => "arrangement_type",
"scheme_primary_client_group" => "primary_client_group",
@ -92,7 +92,7 @@ module Csv
end
def scheme_attributes
%w[scheme_code scheme_service_name scheme_status scheme_sensitive scheme_type scheme_registered_under_care_act scheme_owning_organisation_name scheme_support_services_provided_by scheme_primary_client_group scheme_has_other_client_group scheme_secondary_client_group scheme_support_type scheme_intended_stay scheme_created_at scheme_active_dates]
%w[scheme_code scheme_service_name scheme_status scheme_confidential scheme_type scheme_registered_under_care_act scheme_owning_organisation_name scheme_support_services_provided_by scheme_primary_client_group scheme_has_other_client_group scheme_secondary_client_group scheme_support_type scheme_intended_stay scheme_created_at scheme_active_dates]
end
def location_attributes

6
app/services/filter_manager.rb

@ -83,7 +83,11 @@ class FilterManager
def deserialize_filters_from_session(specific_org)
current_filters = session[session_name_for(filter_type)]
new_filters = current_filters.present? ? JSON.parse(current_filters) : {}
new_filters = if current_filters.present?
JSON.parse(current_filters).transform_values { |value| value.is_a?(Array) ? value.reject(&:blank?) : value }
else
{}
end
if filter_type.include?("logs")
current_user.logs_filters(specific_org:).each do |filter|

2
app/views/filters/_checkbox_filter.html.erb

@ -1,4 +1,4 @@
<%= f.govuk_check_boxes_fieldset category.to_sym, legend: { text: label, size: "s" }, small: true, form_group: { classes: "app-filter__group" } do %>
<%= f.govuk_check_boxes_fieldset category.to_sym, legend: { text: label, size: }, small: true, form_group: { classes: "app-filter__group" } do %>
<% options.map do |key, option| %>
<%= f.govuk_check_box category, key.to_s,
label: { text: option },

2
app/views/filters/_radio_filter.html.erb

@ -1,4 +1,4 @@
<%= f.govuk_radio_buttons_fieldset category.to_sym, legend: { text: label, size: "s" }, small: true, form_group: { classes: "app-filter__group" } do %>
<%= f.govuk_radio_buttons_fieldset category.to_sym, legend: { text: label, size: }, small: true, form_group: { classes: "app-filter__group" } do %>
<% options.map do |key, option| %>
<%= f.govuk_radio_button category, key.to_s,
label: { text: option[:label] },

31
app/views/filters/assigned_to.html.erb

@ -0,0 +1,31 @@
<%= form_with html: { method: :get }, url: update_csv_filters_url(@filter_type, @filter, @organisation_id) do |f| %>
<%= render partial: "filters/radio_filter",
locals: {
f:,
options: {
"all": { label: "Any user" },
"you": { label: "You" },
"specific_user": {
label: "Specific user",
conditional_filter: {
type: "select",
label: "User",
category: "user",
options: assigned_to_filter_options(current_user),
},
},
},
label: "Assigned to",
category: "assigned_to",
size: "l",
} %>
<% if request.params["search"].present? %>
<%= f.hidden_field :search, value: request.params["search"] %>
<% end %>
<%= f.hidden_field :codes_only, value: request.params["codes_only"] %>
<div class="govuk-button-group">
<%= f.govuk_submit "Save changes" %>
<%= govuk_button_link_to "Cancel", cancel_csv_filters_update_url(@filter_type, request.params["search"], request.params["codes_only"], @organisation_id), secondary: true %>
</div>
<% end %>

30
app/views/filters/managed_by.html.erb

@ -0,0 +1,30 @@
<%= form_with html: { method: :get }, url: update_csv_filters_url(@filter_type, @filter, @organisation_id) do |f| %>
<%= render partial: "filters/radio_filter", locals: {
f:,
options: {
"all": { label: "Any managing organisation" },
"specific_org": {
label: "Specific managing organisation",
conditional_filter: {
type: "select",
label: "Managed by",
category: "managing_organisation",
options: managing_organisation_filter_options(current_user),
},
},
},
label: "Managed by",
category: "managing_organisation_select",
size: "l",
} %>
<% if request.params["search"].present? %>
<%= f.hidden_field :search, value: request.params["search"] %>
<% end %>
<%= f.hidden_field :codes_only, value: request.params["codes_only"] %>
<div class="govuk-button-group">
<%= f.govuk_submit "Save changes" %>
<%= govuk_button_link_to "Cancel", cancel_csv_filters_update_url(@filter_type, request.params["search"], request.params["codes_only"], @organisation_id), secondary: true %>
</div>
<% end %>

20
app/views/filters/needstype.html.erb

@ -0,0 +1,20 @@
<%= form_with html: { method: :get }, url: update_csv_filters_url(@filter_type, @filter, @organisation_id) do |f| %>
<%= render partial: "filters/checkbox_filter",
locals: {
f:,
options: needstype_filters,
label: "Needs type",
category: "needstypes",
size: "l",
} %>
<% if request.params["search"].present? %>
<%= f.hidden_field :search, value: request.params["search"] %>
<% end %>
<%= f.hidden_field :codes_only, value: request.params["codes_only"] %>
<div class="govuk-button-group">
<%= f.govuk_submit "Save changes" %>
<%= govuk_button_link_to "Cancel", cancel_csv_filters_update_url(@filter_type, request.params["search"], request.params["codes_only"], @organisation_id), secondary: true %>
</div>
<% end %>

30
app/views/filters/owned_by.html.erb

@ -0,0 +1,30 @@
<%= form_with html: { method: :get }, url: update_csv_filters_url(@filter_type, @filter, @organisation_id) do |f| %>
<%= render partial: "filters/radio_filter", locals: {
f:,
options: {
"all": { label: "Any owning organisation" },
"specific_org": {
label: "Specific owning organisation",
conditional_filter: {
type: "select",
label: "Owning Organisation",
category: "owning_organisation",
options: owning_organisation_filter_options(current_user),
},
},
},
label: "Owned by",
category: "owning_organisation_select",
size: "l",
} %>
<% if request.params["search"].present? %>
<%= f.hidden_field :search, value: request.params["search"] %>
<% end %>
<%= f.hidden_field :codes_only, value: request.params["codes_only"] %>
<div class="govuk-button-group">
<%= f.govuk_submit "Save changes" %>
<%= govuk_button_link_to "Cancel", cancel_csv_filters_update_url(@filter_type, request.params["search"], request.params["codes_only"], @organisation_id), secondary: true %>
</div>
<% end %>

20
app/views/filters/status.html.erb

@ -0,0 +1,20 @@
<%= form_with html: { method: :get }, url: update_csv_filters_url(@filter_type, @filter, @organisation_id) do |f| %>
<%= render partial: "filters/checkbox_filter",
locals: {
f:,
options: status_filters,
label: "Status",
category: "status",
size: "l",
} %>
<% if request.params["search"].present? %>
<%= f.hidden_field :search, value: request.params["search"] %>
<% end %>
<%= f.hidden_field :codes_only, value: request.params["codes_only"] %>
<div class="govuk-button-group">
<%= f.govuk_submit "Save changes" %>
<%= govuk_button_link_to "Cancel", cancel_csv_filters_update_url(@filter_type, request.params["search"], request.params["codes_only"], @organisation_id), secondary: true %>
</div>
<% end %>

37
app/views/filters/years.html.erb

@ -0,0 +1,37 @@
<%= form_with html: { method: :get }, url: update_csv_filters_url(@filter_type, @filter, @organisation_id) do |f| %>
<% if params["error"].present? %>
<div class="govuk-error-summary" data-module="govuk-error-summary">
<div role="alert">
<h2 class="govuk-error-summary__title">
There is a problem
</h2>
<div class="govuk-error-summary__body">
<ul class="govuk-list govuk-error-summary__list">
<li>
<a href="#"><%= params["error"] %></a>
</li>
</ul>
</div>
</div>
</div>
<% end %>
<%= render partial: "filters/radio_filter",
locals: {
f:,
options: collection_year_radio_options,
label: "Which financial year do you want to download data for?",
category: "years",
size: "l",
} %>
<% if request.params["search"].present? %>
<%= f.hidden_field :search, value: request.params["search"] %>
<% end %>
<%= f.hidden_field :codes_only, value: request.params["codes_only"] %>
<div class="govuk-button-group">
<%= f.govuk_submit "Save changes" %>
<%= govuk_button_link_to "Cancel", params["referrer"] == "check_answers" ? cancel_csv_filters_update_url(@filter_type, request.params["search"], request.params["codes_only"], @organisation_id) : send("#{@filter_type}_path"), secondary: true %>
</div>
<% end %>

1
app/views/locations/_location_filters.html.erb

@ -21,6 +21,7 @@
options: location_status_filters,
label: "Status",
category: "status",
size: "s",
} %>
<% if request.params["search"].present? %>

7
app/views/logs/_log_filters.html.erb

@ -22,6 +22,7 @@
options: bulk_upload_options(@bulk_upload),
label: "Bulk upload",
category: "bulk_upload_id",
size: "s",
} %>
<% end %>
@ -32,6 +33,7 @@
options: collection_year_options,
label: "Collection year",
category: "years",
size: "s",
} %>
<%= render partial: "filters/checkbox_filter",
@ -40,6 +42,7 @@
options: status_filters,
label: "Status",
category: "status",
size: "s",
} %>
<% if logs_for_both_needstypes_present?(@organisation) && user_or_org_lettings_path? %>
@ -49,6 +52,7 @@
options: needstype_filters,
label: "Needs type",
category: "needstypes",
size: "s",
} %>
<% end %>
<% end %>
@ -71,6 +75,7 @@
},
label: "Assigned to",
category: "assigned_to",
size: "s",
} %>
<% if current_user.support? || non_support_with_multiple_owning_orgs? %>
@ -90,6 +95,7 @@
},
label: "Owned by",
category: "owning_organisation_select",
size: "s",
} %>
<% end %>
@ -110,6 +116,7 @@
},
label: user_or_org_lettings_path? ? "Managed by" : "Reported by",
category: "managing_organisation_select",
size: "s",
} %>
<% end %>

44
app/views/logs/download_csv.html.erb

@ -1,16 +1,54 @@
<% content_for :title, "Download CSV" %>
<% content_for :before_content do %>
<%= govuk_back_link(href: :back) %>
<%= govuk_back_link(href: download_csv_back_link) %>
<% end %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
<% if @organisation.present? %>
<span class="govuk-caption-l"><%= @organisation.name %></span>
<% end %>
<h1 class="govuk-heading-l">Download CSV</h1>
<p class="govuk-body">We'll send a secure download link to your email address <strong><%= @current_user.email %></strong>.</p>
<p class="govuk-body">You've selected <%= count %> logs.</p>
<% if count.positive? %>
<p class="govuk-body">You've selected <%= count %> logs.</p>
<% else %>
<p class="govuk-body">You haven't selected any logs. Please check your filters</p>
<% end %>
<%= govuk_button_to "Send email", post_path, method: :post, params: { search: search_term, codes_only: } %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-three-quarters-from-desktop">
<h1 class="govuk-heading-l">
Check your filters
</h1>
<%= govuk_inset_text(text: "Amending these answers might change the amount of logs selected") %>
<%= govuk_summary_list do |summary_list| %>
<% check_your_answers_filters_list(session_filters, filter_type).each do |filter| %>
<% summary_list.with_row do |row| %>
<% row.with_key { filter[:label] } %>
<% row.with_value do %>
<%= simple_format(
filter[:value],
wrapper_tag: "span",
class: "govuk-!-margin-right-4",
) %>
<% end %>
<% row.with_action(
text: "Change",
href: change_filter_for_csv_url(filter, filter_type, search_term, codes_only, params["id"]),
) %>
<% end %>
<% end %>
<% end %>
</div>
</div>
<% if count.positive? %>
<%= govuk_button_to "Send email", post_path, method: :post, params: { search: search_term, codes_only: } %>
<% end %>
</div>
</div>

2
app/views/schemes/_scheme_filters.html.erb

@ -21,6 +21,7 @@
options: scheme_status_filters,
label: "Status",
category: "status",
size: "s",
} %>
<% if show_scheme_managing_org_filter?(current_user) %>
@ -40,6 +41,7 @@
},
label: "Owned by",
category: "owning_organisation_select",
size: "s",
} %>
<% end %>

1
app/views/users/_user_filters.html.erb

@ -21,6 +21,7 @@
options: user_status_filters,
label: "Status",
category: "status",
size: "s",
} %>
<% if request.params["search"].present? %>

18
config/routes.rb

@ -181,6 +181,14 @@ Rails.application.routes.draw do
get "merge-request", to: "organisations#merge_request"
get "deactivate", to: "organisations#deactivate"
get "reactivate", to: "organisations#reactivate"
%w[years status needstype assigned-to owned-by managed-by].each do |filter|
get "lettings-logs/filters/#{filter}", to: "lettings_logs_filters#organisation_#{filter.underscore}"
get "lettings-logs/filters/update-#{filter}", to: "lettings_logs_filters#update_organisation_#{filter.underscore}"
end
%w[years status assigned-to owned-by managed-by].each do |filter|
get "sales-logs/filters/#{filter}", to: "sales_logs_filters#organisation_#{filter.underscore}"
get "sales-logs/filters/update-#{filter}", to: "sales_logs_filters#update_organisation_#{filter.underscore}"
end
end
end
@ -214,6 +222,11 @@ Rails.application.routes.draw do
post "delete-logs-confirmation", to: "delete_logs#delete_lettings_logs_confirmation"
delete "delete-logs", to: "delete_logs#discard_lettings_logs"
%w[years status needstype assigned-to owned-by managed-by].each do |filter|
get "filters/#{filter}", to: "lettings_logs_filters##{filter.underscore}"
get "filters/update-#{filter}", to: "lettings_logs_filters#update_#{filter.underscore}"
end
resources :bulk_upload_lettings_logs, path: "bulk-upload-logs", only: %i[show update] do
collection do
get :start
@ -279,6 +292,11 @@ Rails.application.routes.draw do
post "delete-logs-confirmation", to: "delete_logs#delete_sales_logs_confirmation"
delete "delete-logs", to: "delete_logs#discard_sales_logs"
%w[years status assigned-to owned-by managed-by].each do |filter|
get "filters/#{filter}", to: "sales_logs_filters##{filter.underscore}"
get "filters/update-#{filter}", to: "sales_logs_filters#update_#{filter.underscore}"
end
resources :bulk_upload_sales_logs, path: "bulk-upload-logs" do
collection do
get :start

99
spec/features/lettings_log_spec.rb

@ -114,6 +114,105 @@ RSpec.describe "Lettings Log Features" do
end
end
context "when downloading logs" do
let(:user) { create(:user, :support, last_sign_in_at: Time.zone.now) }
let!(:lettings_log) { create(:lettings_log, :setup_completed, owning_organisation: user.organisation, tenancycode: "1") }
context "when I am signed in" do
before do
create(:lettings_log, :setup_completed, :sh, owning_organisation: user.organisation, tenancycode: "1")
allow(user).to receive(:need_two_factor_authentication?).and_return(false)
sign_in user
visit("/lettings-logs?search=1")
end
context "when no filters are selected" do
it "requires year filter to be selected for non codes download" do
click_link("Download (CSV)")
expect(page).to have_current_path("/lettings-logs/filters/years?codes_only=false&search=1")
click_button("Save changes")
expect(page).to have_selector(".govuk-error-summary__title")
expect(page).to have_content("There is a problem")
choose("years-#{lettings_log.form.start_date.year}-field", allow_label_click: true)
click_button("Save changes")
expect(page).to have_current_path("/lettings-logs/csv-download?codes_only=false&search=1")
end
it "requires year filter to be selected for codes only download" do
click_link("Download (CSV, codes only)")
expect(page).to have_current_path("/lettings-logs/filters/years?codes_only=true&search=1")
click_button("Save changes")
expect(page).to have_selector(".govuk-error-summary__title")
expect(page).to have_content("There is a problem")
choose("years-#{lettings_log.form.start_date.year}-field", allow_label_click: true)
click_button("Save changes")
expect(page).to have_current_path("/lettings-logs/csv-download?codes_only=true&search=1")
end
it "allows cancelling the download without selecting the year filter" do
click_link("Download (CSV)")
click_link(text: "Cancel")
expect(page).to have_current_path("/lettings-logs")
end
end
context "when I have selected one year filter" do
before do
visit("/lettings-logs?years[]=#{lettings_log.form.start_date.year}&search=1")
end
it "allows changing the filters and downloading the csv data" do
click_link("Download (CSV)")
expect(page).to have_current_path("/lettings-logs/csv-download?codes_only=false&search=1")
expect(page).to have_content("You've selected 2 logs")
end
it "allows updating filters" do
click_link("Download (CSV, codes only)")
expect(page).to have_content("You've selected 2 logs")
click_link("Change", href: "/lettings-logs/filters/needstype?codes_only=true&referrer=check_answers&search=1")
expect(page).to have_current_path("/lettings-logs/filters/needstype?codes_only=true&referrer=check_answers&search=1")
check("needstypes-1-field", allow_label_click: true)
click_button("Save changes")
expect(page).to have_current_path("/lettings-logs/csv-download?codes_only=true&search=1")
expect(page).to have_content("You've selected 1 logs")
click_link("Change", href: "/lettings-logs/filters/status?codes_only=true&referrer=check_answers&search=1")
check("status-not-started-field", allow_label_click: true)
click_button("Save changes")
expect(page).to have_content("You haven't selected any logs. Please check your filters")
expect(page).not_to have_button("Send email")
end
it "routes back to CYA when cancel is pressed from year question" do
click_link("Download (CSV, codes only)")
click_link("Change", href: "/lettings-logs/filters/years?codes_only=true&referrer=check_answers&search=1")
click_link(text: "Cancel")
expect(page).to have_current_path("/lettings-logs/csv-download?codes_only=true&search=1")
end
it "routes back to the filters CYA when cancel is pressed" do
click_link("Download (CSV)")
click_link("Change", href: "/lettings-logs/filters/needstype?codes_only=false&referrer=check_answers&search=1")
click_link(text: "Cancel")
expect(page).to have_current_path("/lettings-logs/csv-download?codes_only=false&search=1")
end
end
end
end
context "when the signed is user is a Support user" do
let(:organisation) { create(:organisation, name: "User org") }
let(:support_user) { create(:user, :support, last_sign_in_at: Time.zone.now, organisation:) }

92
spec/features/sales_log_spec.rb

@ -139,6 +139,98 @@ RSpec.describe "Sales Log Features" do
end
end
context "when downloading logs" do
let(:user) { create(:user, :support) }
let(:other_user) { create(:user, organisation: user.organisation) }
context "when I am signed in" do
before do
create(:sales_log, :in_progress, owning_organisation: user.organisation, assigned_to: user)
create(:sales_log, :in_progress, owning_organisation: user.organisation, assigned_to: other_user)
allow(user).to receive(:need_two_factor_authentication?).and_return(false)
sign_in user
visit("/sales-logs?search=1")
end
context "when no filters are selected" do
it "requires year filter to be selected for non codes download" do
click_link("Download (CSV)")
expect(page).to have_current_path("/sales-logs/filters/years?codes_only=false&search=1")
click_button("Save changes")
expect(page).to have_selector(".govuk-error-summary__title")
expect(page).to have_content("There is a problem")
choose("years-2023-field", allow_label_click: true)
click_button("Save changes")
expect(page).to have_current_path("/sales-logs/csv-download?codes_only=false&search=1")
end
it "requires year filter to be selected for codes only download" do
click_link("Download (CSV, codes only)")
expect(page).to have_current_path("/sales-logs/filters/years?codes_only=true&search=1")
click_button("Save changes")
expect(page).to have_selector(".govuk-error-summary__title")
expect(page).to have_content("There is a problem")
choose("years-2023-field", allow_label_click: true)
click_button("Save changes")
expect(page).to have_current_path("/sales-logs/csv-download?codes_only=true&search=1")
end
it "allows cancelling the download without selecting the year filter" do
click_link("Download (CSV)")
click_link(text: "Cancel")
expect(page).to have_current_path("/sales-logs")
end
end
context "when one year filter is selected" do
before do
check("2024")
click_button("Apply filters")
end
it "allows changing the filters and downloading the csv data" do
click_link("Download (CSV)")
expect(page).to have_current_path("/sales-logs/csv-download?codes_only=false&search=1")
expect(page).to have_content("You've selected 2 logs")
end
it "allows updating filters" do
click_link("Download (CSV, codes only)")
expect(page).to have_content("You've selected 2 logs")
click_link("Change", href: "/sales-logs/filters/assigned-to?codes_only=true&referrer=check_answers&search=1")
choose("assigned-to-you-field", allow_label_click: true)
click_button("Save changes")
expect(page).to have_content("You've selected 1 logs")
click_link("Change", href: "/sales-logs/filters/status?codes_only=true&referrer=check_answers&search=1")
check("status-not-started-field", allow_label_click: true)
click_button("Save changes")
expect(page).to have_content("You haven't selected any logs. Please check your filters")
expect(page).not_to have_button("Send email")
end
it "routes back to the filters CYA when cancel is pressed" do
click_link("Download (CSV)")
click_link("Change", href: "/sales-logs/filters/assigned-to?codes_only=false&referrer=check_answers&search=1")
click_link(text: "Cancel")
expect(page).to have_current_path("/sales-logs/csv-download?codes_only=false&search=1")
end
end
end
end
context "when signed in as a support user" do
let(:devise_notify_mailer) { DeviseNotifyMailer.new }
let(:notify_client) { instance_double(Notifications::Client) }

4
spec/fixtures/files/lettings_log_csv_export_codes_23.csv vendored

@ -1,2 +1,2 @@
id,status,duplicate_set_id,assigned_to,is_dpo,created_at,updated_by,updated_at,creation_method,old_id,old_form_id,collection_start_year,address_line1_as_entered,address_line2_as_entered,town_or_city_as_entered,county_as_entered,postcode_full_as_entered,la_as_entered,created_by,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_input,postcode_full_input,address_search_value_check,uprn_selection,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,nationality_all,national,ecstat1,details_known_2,relat2,partner_under_16_value_check,multiple_partners_value_check,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,reasonother_value_check,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,incfreq,earnings,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,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,s.port@jeemayle.com,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,1,268,,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,assigned_to,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,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,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,incfreq,earnings,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_confidential,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,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,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,1,0,TN23 6LZ,1,false,Ashford,E07000105,1,0,1,0,0,0,0,0,1,,2,,0,0,1,268,,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 assigned_to is_dpo created_at updated_by updated_at creation_method old_id old_form_id address_line1_as_entered collection_start_year address_line2_as_entered owning_organisation_name town_or_city_as_entered managing_organisation_name county_as_entered needstype postcode_full_as_entered lettype la_as_entered renewal startdate renttype renttype_detail irproduct irproduct_other lar tenancycode propcode uprn_known uprn uprn_confirmed address_line1 address_line2 town_or_city postcode_known county postcode_full is_la_inferred la_label address_line1_input la postcode_full_input first_time_property_let_as_social_housing address_search_value_check unitletas uprn_selection 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 nationality_all ecstat3 details_known_4 relat4 age4 sex4 partner_under_16_value_check ecstat4 multiple_partners_value_check 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 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 reasonother_value_check cbl cap new_old chr letting_allocation_none referral referral_value_check net_income_known incref incfreq earnings 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_confidential 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 scheme_sensitive location_local_authority location_startdate
2 completed s.port@jeemayle.com s.port@jeemayle.com false 2023-11-26T00:00:00+00:00 2023-11-26T00:00:00+00:00 1 address line 1 as entered 2023 address line 2 as entered DLUHC town or city as entered DLUHC county as entered 1 AB1 2CD 7 la as entered 0 2023-11-26 2 2 1 2 HIJKLMN ABCDEFG 0 fake address London 1 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 1 0 TN23 6LZ 1 false Ashford E07000105 1 0 1 0 0 0 0 0 2 1 2 0 0 1 268 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_codes_24.csv vendored

@ -1,2 +1,2 @@
id,status,duplicate_set_id,assigned_to,is_dpo,created_at,updated_by,updated_at,creation_method,old_id,old_form_id,collection_start_year,address_line1_as_entered,address_line2_as_entered,town_or_city_as_entered,county_as_entered,postcode_full_as_entered,la_as_entered,created_by,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,declaration,postcode_known,uprn_known,uprn,uprn_confirmed,address_line1_input,postcode_full_input,address_search_value_check,uprn_selection,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,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,partner_under_16_value_check,multiple_partners_value_check,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,reasonother_value_check,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,accessible_register,letting_allocation_none,referral,referral_value_check,net_income_known,incref,incfreq,earnings,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,,2024-04-01T00:00:00+01:00,1,,,2023,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,s.port@jeemayle.com,DLUHC,DLUHC,1,7,0,2023-11-26,2,2,1,,2,HIJKLMN,ABCDEFG,1,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,,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,0,,2,,0,0,1,268,,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,assigned_to,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,bulk_upload_id,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,declaration,uprn,address_line1,address_line2,town_or_city,county,postcode_full,is_la_inferred,la_label,la,uprn_known,uprn_selection,address_search_value_check,address_line1_input,postcode_full_input,address_line1_as_entered,address_line2_as_entered,town_or_city_as_entered,county_as_entered,postcode_full_as_entered,la_as_entered,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,hhmemb,pregnancy_value_check,refused,hhtype,totchild,totelder,totadult,age1,retirement_value_check,sex1,ethnic_group,ethnic,nationality_all,ecstat1,details_known_2,relat2,partner_under_16_value_check,multiple_partners_value_check,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,reasonother_value_check,prevten,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,accessible_register,letting_allocation_none,referral,referral_value_check,net_income_known,incref,incfreq,earnings,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_confidential,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,s.port@jeemayle.com,false,2023-11-26T00:00:00+00:00,,2024-04-01T00:00:00+01:00,1,2023,,DLUHC,DLUHC,1,7,0,2023-11-26,2,2,1,,2,HIJKLMN,ABCDEFG,1,,fake address,,London,,NW9 5LL,false,Barnet,E09000003,0,,,,,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,0,2,6,2,7,1,1,3,2023-11-24,,,1,2023-11-25,,3,1,4,,2,,4,,1,4,0,0,2,35,,F,0,2,,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,1,0,TN23 6LZ,1,false,Ashford,E07000105,1,0,1,0,0,0,0,0,1,0,,2,,0,0,1,268,,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 assigned_to is_dpo created_at updated_by updated_at old_id creation_method old_form_id collection_start_year bulk_upload_id owning_organisation_name managing_organisation_name needstype lettype renewal startdate renttype renttype_detail irproduct irproduct_other lar tenancycode propcode declaration uprn address_line1 address_line2 town_or_city county postcode_full is_la_inferred postcode_known la_label la uprn_known uprn_confirmed uprn_selection address_search_value_check address_line1_input postcode_full_input address_line1_as_entered address_line2_as_entered town_or_city_as_entered county_as_entered postcode_full_as_entered la_as_entered first_time_property_let_as_social_housing unitletas rsnvac newprop unittype_gn builtype wchair offered beds voiddate vacdays void_date_value_check majorrepairs mrcdate major_repairs_date_value_check joint startertenancy tenancy tenancyother tenancylength sheltered hhmemb pregnancy_value_check refused hhtype totchild totelder totadult age1 retirement_value_check sex1 ethnic_group ethnic nationality_all ecstat1 details_known_2 relat2 national partner_under_16_value_check multiple_partners_value_check 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 reasonother_value_check prevten homeless ppcodenk ppostcode_full previous_la_known is_previous_la_inferred new_old prevloc_label prevloc reasonpref rp_homeless rp_insan_unsat rp_medwel rp_hardship rp_dontknow cbl cap chr accessible_register letting_allocation_none referral referral_value_check net_income_known incref incfreq earnings 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_confidential SCHTYPE scheme_registered_under_care_act scheme_owning_organisation_name scheme_primary_client_group scheme_has_other_client_group scheme_sensitive 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 s.port@jeemayle.com false 2023-11-26T00:00:00+00:00 2024-04-01T00:00:00+01:00 1 2023 DLUHC DLUHC 1 7 0 2023-11-26 2 2 1 2 HIJKLMN ABCDEFG 1 fake address London NW9 5LL false 1 Barnet E09000003 0 address line 1 as entered address line 2 as entered town or city as entered county as entered AB1 2CD la as entered 0 2 6 2 7 1 1 2 3 2023-11-24 1 2023-11-25 3 1 4 2 4 1 4 0 0 2 35 F 0 2 0 0 P 13 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 1 0 TN23 6LZ 1 false 2 Ashford E07000105 1 0 1 0 0 0 0 0 1 0 2 0 0 1 268 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_23.csv vendored

@ -1,2 +1,2 @@
id,status,duplicate_set_id,assigned_to,is_dpo,created_at,updated_by,updated_at,creation_method,old_id,old_form_id,collection_start_year,address_line1_as_entered,address_line2_as_entered,town_or_city_as_entered,county_as_entered,postcode_full_as_entered,la_as_entered,created_by,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_input,postcode_full_input,address_search_value_check,uprn_selection,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,nationality_all,national,ecstat1,details_known_2,relat2,partner_under_16_value_check,multiple_partners_value_check,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,reasonother_value_check,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,incfreq,earnings,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,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,s.port@jeemayle.com,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,Weekly,268,,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,assigned_to,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,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,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,incfreq,earnings,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_confidential,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,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,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,No,Yes,TN23 6LZ,Yes,No,Ashford,E07000105,Yes,,Yes,,,,No,No,Yes,,Tenant applied directly (no referral or nomination),,Yes,No,Weekly,268,,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 assigned_to is_dpo created_at updated_by updated_at creation_method old_id old_form_id address_line1_as_entered collection_start_year address_line2_as_entered owning_organisation_name town_or_city_as_entered managing_organisation_name county_as_entered needstype postcode_full_as_entered lettype la_as_entered renewal startdate renttype renttype_detail irproduct irproduct_other lar tenancycode propcode uprn_known uprn uprn_confirmed address_line1 address_line2 town_or_city postcode_known county postcode_full is_la_inferred la_label address_line1_input la postcode_full_input first_time_property_let_as_social_housing address_search_value_check unitletas uprn_selection 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 nationality_all ecstat3 details_known_4 relat4 age4 sex4 partner_under_16_value_check ecstat4 multiple_partners_value_check 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 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 reasonother_value_check cbl cap new_old chr letting_allocation_none referral referral_value_check net_income_known incref incfreq earnings 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_confidential 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 scheme_sensitive location_local_authority location_startdate
2 completed s.port@jeemayle.com s.port@jeemayle.com false 2023-11-26T00:00:00+00:00 2023-11-26T00:00:00+00:00 single log address line 1 as entered 2023 address line 2 as entered DLUHC town or city as entered DLUHC county as entered General needs AB1 2CD Affordable rent general needs local authority la as entered No 2023-11-26 Affordable Rent Affordable Rent Rent to Buy No HIJKLMN ABCDEFG No fake address London Yes 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 No Yes TN23 6LZ Yes No Ashford E07000105 Yes Yes No No 2 Yes Tenant applied directly (no referral or nomination) Yes No Weekly 268 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

2
spec/fixtures/files/lettings_log_csv_export_labels_23_during_24_period.csv vendored

@ -1,2 +0,0 @@
id,status,duplicate_set_id,assigned_to,is_dpo,created_at,updated_by,updated_at,creation_method,old_id,old_form_id,collection_start_year,address_line1_as_entered,address_line2_as_entered,town_or_city_as_entered,county_as_entered,postcode_full_as_entered,la_as_entered,created_by,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,declaration,postcode_known,uprn_known,uprn,uprn_confirmed,address_line1_input,postcode_full_input,address_search_value_check,uprn_selection,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,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,partner_under_16_value_check,multiple_partners_value_check,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,reasonother_value_check,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,accessible_register,letting_allocation_none,referral,referral_value_check,net_income_known,incref,incfreq,earnings,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,,2024-04-01T00:00:00+01:00,single log,,,2023,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,s.port@jeemayle.com,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,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,,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,No,,Tenant applied directly (no referral or nomination),,Yes,No,Weekly,268,,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 assigned_to is_dpo created_at updated_by updated_at creation_method old_id old_form_id collection_start_year address_line1_as_entered address_line2_as_entered town_or_city_as_entered county_as_entered postcode_full_as_entered la_as_entered created_by owning_organisation_name managing_organisation_name needstype lettype renewal startdate renttype renttype_detail irproduct irproduct_other lar tenancycode propcode declaration postcode_known uprn_known uprn uprn_confirmed address_line1_input postcode_full_input address_search_value_check uprn_selection 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 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 partner_under_16_value_check multiple_partners_value_check 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 reasonother_value_check 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 accessible_register letting_allocation_none referral referral_value_check net_income_known incref incfreq earnings 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 2024-04-01T00:00:00+01:00 single log 2023 address line 1 as entered address line 2 as entered town or city as entered county as entered AB1 2CD la as entered s.port@jeemayle.com 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 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 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 No Tenant applied directly (no referral or nomination) Yes No Weekly 268 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_labels_24.csv vendored

@ -1,2 +1,2 @@
id,status,duplicate_set_id,assigned_to,is_dpo,created_at,updated_by,updated_at,creation_method,old_id,old_form_id,collection_start_year,address_line1_as_entered,address_line2_as_entered,town_or_city_as_entered,county_as_entered,postcode_full_as_entered,la_as_entered,created_by,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,declaration,postcode_known,uprn_known,uprn,uprn_confirmed,address_line1_input,postcode_full_input,address_search_value_check,uprn_selection,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,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,partner_under_16_value_check,multiple_partners_value_check,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,reasonother_value_check,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,accessible_register,letting_allocation_none,referral,referral_value_check,net_income_known,incref,incfreq,earnings,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
,in_progress,,s.port@jeemayle.com,false,2024-04-01T00:00:00+01:00,,2024-04-01T00:00:00+01:00,single log,,,2024,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,s.port@jeemayle.com,DLUHC,DLUHC,General needs,Affordable rent general needs local authority,No,2024-04-01,Affordable Rent,Affordable Rent,,,No,HIJKLMN,ABCDEFG,Yes,Yes,No,,,,,,,fake address,,London,,NW9 5LL,No,Barnet,E09000003,No,Affordable rent basis,Tenant abandoned property,No,2,House,Purpose built,Yes,3,2024-03-30,,,Yes,2024-03-31,,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,4,,Yes,4,0,0,2,35,,Female,White,Irish,,Australia,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,No,,Tenant applied directly (no referral or nomination),,Yes,No,Weekly,268,,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,assigned_to,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,bulk_upload_id,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,declaration,uprn,address_line1,address_line2,town_or_city,county,postcode_full,is_la_inferred,la_label,la,uprn_known,uprn_selection,address_search_value_check,address_line1_input,postcode_full_input,address_line1_as_entered,address_line2_as_entered,town_or_city_as_entered,county_as_entered,postcode_full_as_entered,la_as_entered,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,hhmemb,pregnancy_value_check,refused,hhtype,totchild,totelder,totadult,age1,retirement_value_check,sex1,ethnic_group,ethnic,nationality_all,ecstat1,details_known_2,relat2,partner_under_16_value_check,multiple_partners_value_check,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,reasonother_value_check,prevten,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,accessible_register,letting_allocation_none,referral,referral_value_check,net_income_known,incref,incfreq,earnings,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_confidential,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
,in_progress,,s.port@jeemayle.com,s.port@jeemayle.com,false,2024-04-01T00:00:00+01:00,,2024-04-01T00:00:00+01:00,single log,2024,,DLUHC,DLUHC,General needs,Affordable rent general needs local authority,No,2024-04-01,Affordable Rent,Affordable Rent,,,No,HIJKLMN,ABCDEFG,Yes,,fake address,,London,,NW9 5LL,No,Barnet,E09000003,No,,,,,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,No,Affordable rent basis,Tenant abandoned property,No,House,Purpose built,Yes,3,2024-03-30,,,Yes,2024-03-31,,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,4,,Yes,4,0,0,2,35,,Female,White,Irish,Australia,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,No,Yes,TN23 6LZ,Yes,No,Ashford,E07000105,Yes,,Yes,,,,No,No,Yes,No,,Tenant applied directly (no referral or nomination),,Yes,No,Weekly,268,,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 assigned_to is_dpo created_at updated_by updated_at old_id creation_method old_form_id collection_start_year bulk_upload_id owning_organisation_name managing_organisation_name needstype lettype renewal startdate renttype renttype_detail irproduct irproduct_other lar tenancycode propcode declaration uprn address_line1 address_line2 town_or_city county postcode_full is_la_inferred postcode_known la_label la uprn_known uprn_confirmed uprn_selection address_search_value_check address_line1_input postcode_full_input address_line1_as_entered address_line2_as_entered town_or_city_as_entered county_as_entered postcode_full_as_entered la_as_entered first_time_property_let_as_social_housing unitletas rsnvac newprop unittype_gn builtype wchair offered beds voiddate vacdays void_date_value_check majorrepairs mrcdate major_repairs_date_value_check joint startertenancy tenancy tenancyother tenancylength sheltered hhmemb pregnancy_value_check refused hhtype totchild totelder totadult age1 retirement_value_check sex1 ethnic_group ethnic nationality_all ecstat1 details_known_2 relat2 national partner_under_16_value_check multiple_partners_value_check 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 reasonother_value_check prevten homeless ppcodenk ppostcode_full previous_la_known is_previous_la_inferred new_old prevloc_label prevloc reasonpref rp_homeless rp_insan_unsat rp_medwel rp_hardship rp_dontknow cbl cap chr accessible_register letting_allocation_none referral referral_value_check net_income_known incref incfreq earnings 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_confidential SCHTYPE scheme_registered_under_care_act scheme_owning_organisation_name scheme_primary_client_group scheme_has_other_client_group scheme_sensitive 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 in_progress s.port@jeemayle.com s.port@jeemayle.com false 2024-04-01T00:00:00+01:00 2024-04-01T00:00:00+01:00 single log 2024 DLUHC DLUHC General needs Affordable rent general needs local authority No 2024-04-01 Affordable Rent Affordable Rent No HIJKLMN ABCDEFG Yes fake address London NW9 5LL No Yes Barnet E09000003 No address line 1 as entered address line 2 as entered town or city as entered county as entered AB1 2CD la as entered No Affordable rent basis Tenant abandoned property No House Purpose built Yes 2 3 2024-03-30 Yes 2024-03-31 Don’t know Yes Assured Shorthold Tenancy (AST) – Fixed term 2 4 Yes 4 0 0 2 35 Female White Irish Australia 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 No Yes TN23 6LZ Yes No 2 Ashford E07000105 Yes Yes No No Yes No Tenant applied directly (no referral or nomination) Yes No Weekly 268 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_23.csv vendored

@ -1,2 +1,2 @@
id,status,duplicate_set_id,assigned_to,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,nationality_all,national,ecstat1,relat2,partner_under_16_value_check,multiple_partners_value_check,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,incfreq,earnings,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,1,268,6,1,1,,0,2,,,,,200.0,50.0,40.0,35.0,325.0,,,,1,12.0,,,,,,,,,,,,,,,,,,,,
id,status,duplicate_set_id,assigned_to,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,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,majorrepairs,mrcdate,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,incref,incfreq,earnings,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,brent,scharge,pscharge,supcharg,tcharge,hbrentshortfall,tshortfall,scheme_code,scheme_service_name,scheme_confidential,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,0,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,1,268,6,1,1,,0,2,,,,200.0,50.0,40.0,35.0,325.0,1,12.0,,,,,,,,,,,,,,,,,,,,

1 id status duplicate_set_id assigned_to 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 first_time_property_let_as_social_housing unitletas rsnvac newprop offered unittype_gn builtype wchair beds voiddate void_date_value_check vacdays 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 partner_under_16_value_check ecstat2 multiple_partners_value_check 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 incref incfreq earnings hb referral_value_check has_benefits benefits household_charge nocharge period is_carehome chcharge wchchrg brent scharge pscharge supcharg tcharge carehome_charges_value_check hbrentshortfall tshortfall scheme_code scheme_service_name scheme_confidential SCHTYPE scharge_value_check scheme_registered_under_care_act pscharge_value_check scheme_owning_organisation_name supcharg_value_check scheme_primary_client_group scheme_has_other_client_group scheme_secondary_client_group scheme_support_type scheme_intended_stay scheme_sensitive 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 0 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 1 268 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_codes_24.csv vendored

@ -1,2 +1,2 @@
id,status,duplicate_set_id,assigned_to,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,declaration,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,hhmemb,refused,age1,sex1,ethnic_group,ethnic,national,nationality_all,ecstat1,relat2,partner_under_16_value_check,multiple_partners_value_check,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,accessible_register,letting_allocation_none,referral,referral_value_check,incref,incfreq,earnings,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,,2024-04-01T00:00:00+01:00,1,2023,DLUHC,DLUHC,1,7,0,2023-11-26,2,2,1,,2,HIJKLMN,ABCDEFG,1,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,,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,0,,2,,0,1,268,6,1,1,,0,2,,,,,200.0,50.0,40.0,35.0,325.0,,,,1,12.0,,,,,,,,,,,,,,,,,,,,
id,status,duplicate_set_id,assigned_to,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,bulk_upload_id,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,declaration,uprn_known,uprn,address_line1,address_line2,town_or_city,county,postcode_full,la_label,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,unittype_gn,builtype,wchair,beds,voiddate,vacdays,majorrepairs,mrcdate,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,hhmemb,refused,age1,sex1,ethnic_group,ethnic,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,accessible_register,letting_allocation_none,referral,incref,incfreq,earnings,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,brent,scharge,pscharge,supcharg,tcharge,hbrentshortfall,tshortfall,scheme_code,scheme_service_name,scheme_confidential,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
,in_progress,,choreographer@owtluk.com,false,2024-04-01T00:00:00+01:00,,2024-04-01T00:00:00+01:00,1,2024,,DLUHC,DLUHC,1,7,0,2024-04-01,2,2,1,,2,HIJKLMN,ABCDEFG,1,0,,fake address,,London,,NW9 5LL,Barnet,0,2,6,2,7,1,1,3,2024-03-30,0,1,2024-03-31,3,1,4,,2,,4,1,35,F,0,2,,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,0,,2,0,1,268,6,1,1,,0,2,,,,200.0,50.0,40.0,35.0,325.0,1,12.0,,,,,,,,,,,,,,,,,,,,

1 id status duplicate_set_id assigned_to is_dpo created_at updated_by updated_at creation_method collection_start_year bulk_upload_id owning_organisation_name managing_organisation_name needstype lettype renewal startdate renttype renttype_detail irproduct irproduct_other lar tenancycode propcode declaration uprn_known uprn address_line1 address_line2 town_or_city county postcode_full la_label first_time_property_let_as_social_housing unitletas offered rsnvac newprop unittype_gn builtype wchair beds voiddate void_date_value_check vacdays majorrepairs mrcdate major_repairs_date_value_check joint startertenancy tenancy tenancyother tenancylength sheltered hhmemb refused age1 sex1 ethnic_group ethnic nationality_all national ecstat1 relat2 age2 sex2 partner_under_16_value_check ecstat2 multiple_partners_value_check 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 accessible_register letting_allocation_none referral incref incfreq earnings hb referral_value_check has_benefits benefits household_charge nocharge period is_carehome chcharge wchchrg brent scharge pscharge supcharg tcharge carehome_charges_value_check hbrentshortfall tshortfall scheme_code scheme_service_name scheme_confidential SCHTYPE scharge_value_check scheme_registered_under_care_act pscharge_value_check scheme_owning_organisation_name supcharg_value_check scheme_primary_client_group scheme_has_other_client_group scheme_secondary_client_group scheme_support_type scheme_intended_stay scheme_sensitive 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 in_progress choreographer@owtluk.com false 2023-11-26T00:00:00+00:00 2024-04-01T00:00:00+01:00 2024-04-01T00:00:00+01:00 1 2023 2024 DLUHC DLUHC 1 7 0 2023-11-26 2024-04-01 2 2 1 2 HIJKLMN ABCDEFG 1 0 fake address London NW9 5LL Barnet 0 2 2 6 2 7 1 1 3 2023-11-24 2024-03-30 1 0 1 2023-11-25 2024-03-31 3 1 4 2 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 0 2 0 1 268 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_23.csv vendored

@ -1,2 +1,2 @@
id,status,duplicate_set_id,assigned_to,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,nationality_all,national,ecstat1,relat2,partner_under_16_value_check,multiple_partners_value_check,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,incfreq,earnings,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,Weekly,268,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,assigned_to,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,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,majorrepairs,mrcdate,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,incref,incfreq,earnings,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,brent,scharge,pscharge,supcharg,tcharge,hbrentshortfall,tshortfall,scheme_code,scheme_service_name,scheme_confidential,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,No,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,Weekly,268,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 assigned_to 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 first_time_property_let_as_social_housing unitletas rsnvac newprop offered unittype_gn builtype wchair beds voiddate void_date_value_check vacdays 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 partner_under_16_value_check ecstat2 multiple_partners_value_check 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 incref incfreq earnings hb referral_value_check has_benefits benefits household_charge nocharge period is_carehome chcharge wchchrg brent scharge pscharge supcharg tcharge carehome_charges_value_check hbrentshortfall tshortfall scheme_code scheme_service_name scheme_confidential SCHTYPE scharge_value_check scheme_registered_under_care_act pscharge_value_check scheme_owning_organisation_name supcharg_value_check scheme_primary_client_group scheme_has_other_client_group scheme_secondary_client_group scheme_support_type scheme_intended_stay scheme_sensitive 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 No 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 Weekly 268 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/lettings_log_csv_export_non_support_labels_24.csv vendored

@ -1,2 +1,2 @@
id,status,duplicate_set_id,assigned_to,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,declaration,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,hhmemb,refused,age1,sex1,ethnic_group,ethnic,national,nationality_all,ecstat1,relat2,partner_under_16_value_check,multiple_partners_value_check,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,accessible_register,letting_allocation_none,referral,referral_value_check,incref,incfreq,earnings,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,,2024-04-01T00:00:00+01: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,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,,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,No,,Tenant applied directly (no referral or nomination),,No,Weekly,268,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,assigned_to,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,bulk_upload_id,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,declaration,uprn_known,uprn,address_line1,address_line2,town_or_city,county,postcode_full,la_label,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,unittype_gn,builtype,wchair,beds,voiddate,vacdays,majorrepairs,mrcdate,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,hhmemb,refused,age1,sex1,ethnic_group,ethnic,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,accessible_register,letting_allocation_none,referral,incref,incfreq,earnings,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,brent,scharge,pscharge,supcharg,tcharge,hbrentshortfall,tshortfall,scheme_code,scheme_service_name,scheme_confidential,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
,in_progress,,choreographer@owtluk.com,false,2024-04-01T00:00:00+01:00,,2024-04-01T00:00:00+01:00,single log,2024,,DLUHC,DLUHC,General needs,Affordable rent general needs local authority,No,2024-04-01,Affordable Rent,Affordable Rent,Rent to Buy,,No,HIJKLMN,ABCDEFG,Yes,No,,fake address,,London,,NW9 5LL,Barnet,No,Affordable rent basis,Tenant abandoned property,No,House,Purpose built,Yes,3,2024-03-30,0,Yes,2024-03-31,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,4,Yes,35,Female,White,Irish,,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,No,,Tenant applied directly (no referral or nomination),No,Weekly,268,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 assigned_to is_dpo created_at updated_by updated_at creation_method collection_start_year bulk_upload_id owning_organisation_name managing_organisation_name needstype lettype renewal startdate renttype renttype_detail irproduct irproduct_other lar tenancycode propcode declaration uprn_known uprn address_line1 address_line2 town_or_city county postcode_full la_label first_time_property_let_as_social_housing unitletas offered rsnvac newprop unittype_gn builtype wchair beds voiddate void_date_value_check vacdays majorrepairs mrcdate major_repairs_date_value_check joint startertenancy tenancy tenancyother tenancylength sheltered hhmemb refused age1 sex1 ethnic_group ethnic nationality_all national ecstat1 relat2 age2 sex2 partner_under_16_value_check ecstat2 multiple_partners_value_check 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 accessible_register letting_allocation_none referral incref incfreq earnings hb referral_value_check has_benefits benefits household_charge nocharge period is_carehome chcharge wchchrg brent scharge pscharge supcharg tcharge carehome_charges_value_check hbrentshortfall tshortfall scheme_code scheme_service_name scheme_confidential SCHTYPE scharge_value_check scheme_registered_under_care_act pscharge_value_check scheme_owning_organisation_name supcharg_value_check scheme_primary_client_group scheme_has_other_client_group scheme_secondary_client_group scheme_support_type scheme_intended_stay scheme_sensitive 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 in_progress choreographer@owtluk.com false 2023-11-26T00:00:00+00:00 2024-04-01T00:00:00+01:00 2024-04-01T00:00:00+01:00 single log 2023 2024 DLUHC DLUHC General needs Affordable rent general needs local authority No 2023-11-26 2024-04-01 Affordable Rent Affordable Rent Rent to Buy No HIJKLMN ABCDEFG Yes No fake address London NW9 5LL Barnet No Affordable rent basis 2 Tenant abandoned property No House Purpose built Yes 3 2023-11-24 2024-03-30 1 0 Yes 2023-11-25 2024-03-31 Don’t know Yes Assured Shorthold Tenancy (AST) – Fixed term 2 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 No Tenant applied directly (no referral or nomination) No Weekly 268 Universal Credit housing element Yes All No Every 2 weeks 200.0 50.0 40.0 35.0 325.0 Yes 12.0

2
spec/fixtures/files/original_schemes.csv vendored

@ -1,4 +1,4 @@
scheme_code,scheme_service_name,scheme_status,scheme_sensitive,scheme_type,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_support_services_provided_by,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,scheme_active_dates
scheme_code,scheme_service_name,scheme_status,scheme_confidential,scheme_type,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_support_services_provided_by,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,scheme_active_dates
{id1},Test name,active,Yes,Housing for older people,Yes – registered care home providing nursing care,DLUHC,The same organisation that owns the housing stock,People with alcohol problems,Yes,Older people with support needs,High level,Medium stay,2021-04-01T00:00:00+01:00,"Active from 1 April 2020"
{id2},Test name,active,Yes,Housing for older people,Yes – registered care home providing nursing care,DLUHC,The same organisation that owns the housing stock,People with alcohol problems,Yes,Older people with support needs,High level,Medium stay,2021-04-01T00:00:00+01:00,"Active from 1 April 2020"
{id3},Test name,active,Yes,Housing for older people,Yes – registered care home providing nursing care,DLUHC,The same organisation that owns the housing stock,People with alcohol problems,Yes,Older people with support needs,High level,Medium stay,2021-04-01T00:00:00+01:00,"Active from 1 April 2020"

1 scheme_code scheme_service_name scheme_status scheme_sensitive scheme_confidential scheme_type scheme_registered_under_care_act scheme_owning_organisation_name scheme_support_services_provided_by scheme_primary_client_group scheme_has_other_client_group scheme_secondary_client_group scheme_support_type scheme_intended_stay scheme_created_at scheme_active_dates
2 {id1} Test name active Yes Yes Housing for older people Yes – registered care home providing nursing care DLUHC The same organisation that owns the housing stock People with alcohol problems Yes Older people with support needs High level Medium stay 2021-04-01T00:00:00+01:00 Active from 1 April 2020
3 {id2} Test name active Yes Yes Housing for older people Yes – registered care home providing nursing care DLUHC The same organisation that owns the housing stock People with alcohol problems Yes Older people with support needs High level Medium stay 2021-04-01T00:00:00+01:00 Active from 1 April 2020
4 {id3} Test name active Yes Yes Housing for older people Yes – registered care home providing nursing care DLUHC The same organisation that owns the housing stock People with alcohol problems Yes Older people with support needs High level Medium stay 2021-04-01T00:00:00+01:00 Active from 1 April 2020

4
spec/fixtures/files/sales_logs_csv_export_codes_23.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,address_line1_as_entered,address_line2_as_entered,town_or_city_as_entered,county_as_entered,postcode_full_as_entered,la_as_entered,created_by,owning_organisation_name,managing_organisation_name,assigned_to,day,month,year,purchid,ownershipsch,type,othtype,companybuy,buylivein,jointpur,jointmore,beds,proptype,builtype,pcodenk,uprn,uprn_confirmed,address_line1_input,postcode_full_input,uprn_selection,address_line1,address_line2,town_or_city,county,pcode1,pcode2,la_known,la,la_label,wchair,noint,privacynotice,age1,sex1,ethnic_group,ethnic,nationality_all,national,ecstat1,buy1livein,relat2,age2,sex2,ethnic_group2,ethnicbuy2,nationality_all_buyer2,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,2024-01-01T00:00:00+00:00,,2023,1,false,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,billyboy@eyeklaud.com,DLUHC,DLUHC,billyboy@eyeklaud.com,8,12,2023,,2,8,,,,1,1,2,1,1,0,,,,,,Address line 1,,Town or city,,SW1A,1AA,1,E09000003,Barnet,1,2,1,30,X,17,17,,18,1,1,P,35,X,17,,,13,1,1,3,C,14,X,,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,DUPLICATESET,CREATEDDATE,UPLOADDATE,FORM,COLLECTIONYEAR,CREATIONMETHOD,DATAPROTECT,OWNINGORGNAME,MANINGORGNAME,CREATEDBY,USERNAME,DAY,MONTH,YEAR,PURCHID,OWNERSHIP,TYPE,OTHTYPE,COMPANY,LIVEINBUYER,JOINT,JOINTMORE,BEDS,PROPTYPE,BUILTYPE,UPRN,UPRNCONFIRMED,ADDRESS1,ADDRESS2,TOWNCITY,COUNTY,PCODE1,PCODE2,LA,LANAME,WCHAIR,NOINT,PRIVACYNOTICE,AGE1,SEX1,ETHNICGROUP1,ETHNIC,NATIONAL,ECSTAT1,LIVEINBUYER1,RELAT2,AGE2,SEX2,ETHNICGROUP2,ETHNIC2,NATIONAL2,ECSTAT2,LIVEINBUYER2,HHTYPE,RELAT3,AGE3,SEX3,ECSTAT3,RELAT4,AGE4,SEX4,ECSTAT4,RELAT5,AGE5,SEX5,ECSTAT5,RELAT6,AGE6,SEX6,ECSTAT6,PREVTEN,PPCODENK,PPOSTC1,PPOSTC2,PREVIOUSLAKNOWN,PREVLOC,PREVLOCNAME,PREGYRHA,PREGOTHER,PREGLA,PREGGHB,PREGBLANK,BUY2LIVING,PREVTEN2,HHREGRES,HHREGRESSTILL,ARMEDFORCESSPOUSE,DISABLED,WHEEL,INC1NK,INCOME1,INC1MORT,INC2NK,INCOME2,INC2MORT,HB,SAVINGSNK,SAVINGS,PREVOWN,PREVSHARED,PROPLEN,STAIRCASE,STAIRBOUGHT,STAIROWNED,STAIRCASETOSALE,RESALE,EXDAY,EXMONTH,EXYEAR,HODAY,HOMONTH,HOYEAR,LANOMAGR,SOCTEN,FROMBEDS,FROMPROP,SOCPREVTEN,VALUE,VALUE_VALUE_CHECK,EQUITY,MORTGAGEUSED,MORTGAGE,MORTGAGELENDER,MORTGAGELENDEROTHER,MORTLEN1,EXTRABOR,DEPOSIT,CASHDIS,MRENT,HASMSCHARGE,MSCHARGE,MSCHARGE_VALUE_CHECK,DISCOUNT,GRANT
,completed,,2023-12-08T00:00:00+00:00,2024-01-01T00:00:00+00:00,,2023,1,false,DLUHC,DLUHC,billyboy@eyeklaud.com,billyboy@eyeklaud.com,8,12,2023,,2,8,,,,1,1,2,1,1,,,Address line 1,,Town or city,,SW1A,1AA,E09000003,Barnet,1,2,1,30,X,17,17,18,1,1,P,35,X,17,,13,1,1,3,C,14,X,,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 ID status STATUS duplicate_set_id DUPLICATESET created_at CREATEDDATE updated_at UPLOADDATE old_form_id FORM collection_start_year COLLECTIONYEAR creation_method CREATIONMETHOD is_dpo DATAPROTECT address_line1_as_entered OWNINGORGNAME address_line2_as_entered MANINGORGNAME town_or_city_as_entered CREATEDBY county_as_entered USERNAME postcode_full_as_entered DAY la_as_entered MONTH created_by YEAR owning_organisation_name PURCHID managing_organisation_name OWNERSHIP assigned_to TYPE day OTHTYPE month COMPANY year LIVEINBUYER purchid JOINT ownershipsch JOINTMORE type BEDS othtype PROPTYPE companybuy BUILTYPE buylivein UPRN jointpur UPRNCONFIRMED jointmore ADDRESS1 beds ADDRESS2 proptype TOWNCITY builtype COUNTY pcodenk PCODE1 uprn PCODE2 uprn_confirmed LA address_line1_input LANAME postcode_full_input WCHAIR uprn_selection NOINT address_line1 PRIVACYNOTICE address_line2 AGE1 town_or_city SEX1 county ETHNICGROUP1 pcode1 ETHNIC pcode2 NATIONAL la_known ECSTAT1 la LIVEINBUYER1 la_label RELAT2 wchair AGE2 noint SEX2 privacynotice ETHNICGROUP2 age1 ETHNIC2 sex1 NATIONAL2 ethnic_group ECSTAT2 ethnic LIVEINBUYER2 nationality_all HHTYPE national RELAT3 ecstat1 AGE3 buy1livein SEX3 relat2 ECSTAT3 age2 RELAT4 sex2 AGE4 ethnic_group2 SEX4 ethnicbuy2 ECSTAT4 nationality_all_buyer2 RELAT5 nationalbuy2 AGE5 ecstat2 SEX5 buy2livein ECSTAT5 hholdcount RELAT6 relat3 AGE6 age3 SEX6 sex3 ECSTAT6 ecstat3 PREVTEN relat4 PPCODENK age4 PPOSTC1 sex4 PPOSTC2 ecstat4 PREVIOUSLAKNOWN relat5 PREVLOC age5 PREVLOCNAME sex5 PREGYRHA ecstat5 PREGOTHER relat6 PREGLA age6 PREGGHB sex6 PREGBLANK ecstat6 BUY2LIVING prevten PREVTEN2 ppcodenk HHREGRES ppostc1 HHREGRESSTILL ppostc2 ARMEDFORCESSPOUSE previous_la_known DISABLED prevloc WHEEL prevloc_label INC1NK pregyrha INCOME1 pregother INC1MORT pregla INC2NK pregghb INCOME2 pregblank INC2MORT buy2living HB prevtenbuy2 SAVINGSNK hhregres SAVINGS hhregresstill PREVOWN armedforcesspouse PREVSHARED disabled PROPLEN wheel STAIRCASE income1nk STAIRBOUGHT income1 STAIROWNED inc1mort STAIRCASETOSALE income2nk RESALE income2 EXDAY inc2mort EXMONTH hb EXYEAR savingsnk HODAY savings HOMONTH prevown HOYEAR prevshared LANOMAGR proplen SOCTEN staircase FROMBEDS stairbought FROMPROP stairowned SOCPREVTEN staircasesale VALUE resale VALUE_VALUE_CHECK exday EQUITY exmonth MORTGAGEUSED exyear MORTGAGE hoday MORTGAGELENDER homonth MORTGAGELENDEROTHER hoyear MORTLEN1 lanomagr EXTRABOR soctenant DEPOSIT frombeds CASHDIS fromprop MRENT socprevten HASMSCHARGE value MSCHARGE equity MSCHARGE_VALUE_CHECK mortgageused DISCOUNT mortgage GRANT mortgagelender mortgagelenderother mortlen extrabor deposit cashdis mrent has_mscharge mscharge discount grant
2 completed completed 2023-12-08T00:00:00+00:00 2023-12-08T00:00:00+00:00 2024-01-01T00:00:00+00:00 2024-01-01T00:00:00+00:00 2023 2023 1 1 false false address line 1 as entered DLUHC address line 2 as entered DLUHC town or city as entered billyboy@eyeklaud.com county as entered billyboy@eyeklaud.com AB1 2CD 8 la as entered 12 billyboy@eyeklaud.com 2023 DLUHC DLUHC 2 billyboy@eyeklaud.com 8 8 12 2023 1 2 1 8 2 1 1 1 1 Address line 1 2 1 Town or city 1 0 SW1A 1AA E09000003 Barnet 1 2 Address line 1 1 30 Town or city X 17 SW1A 17 1AA 18 1 1 E09000003 1 Barnet P 1 35 2 X 1 17 30 X 13 17 1 17 1 3 18 C 1 14 1 X P 35 X X -9 17 X 3 R 13 -9 1 R 1 10 3 C 14 X 1 X 1 -9 X 3 0 R -9 R 1 10 1 1 1 3 1 1 1 4 5 0 1 1 0 1 10000 1 1 1 0 1 10000 1 3 4 1 1 4 1 5 2 1 10 1 0 10000 1 0 10000 1 4 1 1 2 10 110000.0 1 20000.0 5 10 1 80000.0 1 110000.0 100.0 1 20000.0 10000.0 5 10 1 80000.0 1 100.0 10000.0

4
spec/fixtures/files/sales_logs_csv_export_codes_24.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,address_line1_as_entered,address_line2_as_entered,town_or_city_as_entered,county_as_entered,postcode_full_as_entered,la_as_entered,created_by,owning_organisation_name,managing_organisation_name,assigned_to,day,month,year,purchid,ownershipsch,type,othtype,companybuy,buylivein,jointpur,jointmore,noint,privacynotice,uprn,uprn_confirmed,address_line1_input,postcode_full_input,uprn_selection,address_line1,address_line2,town_or_city,county,pcode1,pcode2,la_known,la,la_label,beds,proptype,builtype,pcodenk,wchair,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,2024-05-01T00:00:00+01:00,,2023,1,false,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,billyboy@eyeklaud.com,DLUHC,DLUHC,billyboy@eyeklaud.com,8,12,2023,,2,8,,,,1,1,2,1,,,,,,Address line 1,,Town or city,,SW1A,1AA,1,E09000003,Barnet,2,1,1,0,1,30,X,17,17,18,,1,1,P,35,X,17,,13,,1,1,3,C,14,X,,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,DUPLICATESET,CREATEDDATE,UPLOADDATE,COLLECTIONYEAR,CREATIONMETHOD,BULKUPLOADID,DATAPROTECT,OWNINGORGNAME,MANINGORGNAME,CREATEDBY,USERNAME,DAY,MONTH,YEAR,PURCHID,OWNERSHIP,TYPE,OTHTYPE,COMPANY,LIVEINBUYER,JOINT,JOINTMORE,NOINT,PRIVACYNOTICE,UPRN,ADDRESS1,ADDRESS2,TOWNCITY,COUNTY,POSTCODE,ISLAINFERRED,LANAME,LA,UPRNSELECTED,ADDRESS_SEARCH_VALUE_CHECK,ADDRESS1INPUT,POSTCODEINPUT,BULKADDRESS1,BULKADDRESS2,BULKTOWNCITY,BULKCOUNTY,BULKPOSTCODE,BULKLA,BEDS,PROPTYPE,BUILTYPE,WCHAIR,AGE1,SEX1,ETHNICGROUP1,ETHNIC,NATIONALITYALL1,ECSTAT1,LIVEINBUYER1,RELAT2,AGE2,SEX2,ETHNICGROUP2,ETHNIC2,NATIONALITYALL2,ECSTAT2,LIVEINBUYER2,HHTYPE,RELAT3,AGE3,SEX3,ECSTAT3,RELAT4,AGE4,SEX4,ECSTAT4,RELAT5,AGE5,SEX5,ECSTAT5,RELAT6,AGE6,SEX6,ECSTAT6,PREVTEN,PPCODENK,PPOSTC1,PPOSTC2,PREVIOUSLAKNOWN,PREVLOC,PREVLOCNAME,PREGYRHA,PREGOTHER,PREGLA,PREGGHB,PREGBLANK,BUY2LIVING,PREVTEN2,HHREGRES,HHREGRESSTILL,ARMEDFORCESSPOUSE,DISABLED,WHEEL,INC1NK,INCOME1,INC1MORT,INC2NK,INCOME2,INC2MORT,HB,SAVINGSNK,SAVINGS,PREVOWN,PREVSHARED,PROPLEN,STAIRCASE,STAIRBOUGHT,STAIROWNED,STAIRCASETOSALE,RESALE,EXDAY,EXMONTH,EXYEAR,HODAY,HOMONTH,HOYEAR,LANOMAGR,SOCTEN,FROMBEDS,FROMPROP,SOCPREVTEN,VALUE,VALUE_VALUE_CHECK,EQUITY,MORTGAGEUSED,MORTGAGE,MORTGAGELENDER,MORTGAGELENDEROTHER,MORTLEN1,EXTRABOR,DEPOSIT,CASHDIS,MRENT,HASMSCHARGE,MSCHARGE,MSCHARGE_VALUE_CHECK,DISCOUNT,GRANT
,in_progress,,2024-05-01T00:00:00+01:00,2024-05-01T00:00:00+01:00,2024,1,,false,DLUHC,DLUHC,billyboy@eyeklaud.com,billyboy@eyeklaud.com,1,5,2024,,2,8,,,,1,1,2,1,,Address line 1,,Town or city,,SW1A 1AA,false,Barnet,E09000003,,,,,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,2,1,1,1,30,X,17,17,,1,1,P,35,X,17,,,1,1,3,C,14,X,9,X,-9,X,3,R,-9,R,10,,,,,1,0,SW1A,1AA,1,E09000003,Barnet,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 ID status STATUS duplicate_set_id DUPLICATESET created_at CREATEDDATE updated_at UPLOADDATE old_form_id COLLECTIONYEAR collection_start_year CREATIONMETHOD creation_method BULKUPLOADID is_dpo DATAPROTECT address_line1_as_entered OWNINGORGNAME address_line2_as_entered MANINGORGNAME town_or_city_as_entered CREATEDBY county_as_entered USERNAME postcode_full_as_entered DAY la_as_entered MONTH created_by YEAR owning_organisation_name PURCHID managing_organisation_name OWNERSHIP assigned_to TYPE day OTHTYPE month COMPANY year LIVEINBUYER purchid JOINT ownershipsch JOINTMORE type NOINT othtype PRIVACYNOTICE companybuy UPRN buylivein ADDRESS1 jointpur ADDRESS2 jointmore TOWNCITY noint COUNTY privacynotice POSTCODE uprn ISLAINFERRED uprn_confirmed LANAME address_line1_input LA postcode_full_input UPRNSELECTED uprn_selection ADDRESS_SEARCH_VALUE_CHECK address_line1 ADDRESS1INPUT address_line2 POSTCODEINPUT town_or_city BULKADDRESS1 county BULKADDRESS2 pcode1 BULKTOWNCITY pcode2 BULKCOUNTY la_known BULKPOSTCODE la BULKLA la_label BEDS beds PROPTYPE proptype BUILTYPE builtype WCHAIR pcodenk AGE1 wchair SEX1 age1 ETHNICGROUP1 sex1 ETHNIC ethnic_group NATIONALITYALL1 ethnic ECSTAT1 national LIVEINBUYER1 nationality_all RELAT2 ecstat1 AGE2 buy1livein SEX2 relat2 ETHNICGROUP2 age2 ETHNIC2 sex2 NATIONALITYALL2 ethnic_group2 ECSTAT2 ethnicbuy2 LIVEINBUYER2 nationalbuy2 HHTYPE nationality_all_buyer2 RELAT3 ecstat2 AGE3 buy2livein SEX3 hholdcount ECSTAT3 relat3 RELAT4 age3 AGE4 sex3 SEX4 ecstat3 ECSTAT4 relat4 RELAT5 age4 AGE5 sex4 SEX5 ecstat4 ECSTAT5 relat5 RELAT6 age5 AGE6 sex5 SEX6 ecstat5 ECSTAT6 relat6 PREVTEN age6 PPCODENK sex6 PPOSTC1 ecstat6 PPOSTC2 prevten PREVIOUSLAKNOWN ppcodenk PREVLOC ppostc1 PREVLOCNAME ppostc2 PREGYRHA previous_la_known PREGOTHER prevloc PREGLA prevloc_label PREGGHB pregyrha PREGBLANK pregother BUY2LIVING pregla PREVTEN2 pregghb HHREGRES pregblank HHREGRESSTILL buy2living ARMEDFORCESSPOUSE prevtenbuy2 DISABLED hhregres WHEEL hhregresstill INC1NK armedforcesspouse INCOME1 disabled INC1MORT wheel INC2NK income1nk INCOME2 income1 INC2MORT inc1mort HB income2nk SAVINGSNK income2 SAVINGS inc2mort PREVOWN hb PREVSHARED savingsnk PROPLEN savings STAIRCASE prevown STAIRBOUGHT prevshared STAIROWNED proplen STAIRCASETOSALE staircase RESALE stairbought EXDAY stairowned EXMONTH staircasesale EXYEAR resale HODAY exday HOMONTH exmonth HOYEAR exyear LANOMAGR hoday SOCTEN homonth FROMBEDS hoyear FROMPROP lanomagr SOCPREVTEN soctenant VALUE frombeds VALUE_VALUE_CHECK fromprop EQUITY socprevten MORTGAGEUSED value MORTGAGE equity MORTGAGELENDER mortgageused MORTGAGELENDEROTHER mortgage MORTLEN1 mortgagelender EXTRABOR mortgagelenderother DEPOSIT mortlen CASHDIS extrabor MRENT deposit HASMSCHARGE cashdis MSCHARGE mrent MSCHARGE_VALUE_CHECK has_mscharge DISCOUNT mscharge GRANT discount grant
2 completed in_progress 2023-12-08T00:00:00+00:00 2024-05-01T00:00:00+01:00 2024-05-01T00:00:00+01:00 2024-05-01T00:00:00+01:00 2024 2023 1 1 false false address line 1 as entered DLUHC address line 2 as entered DLUHC town or city as entered billyboy@eyeklaud.com county as entered billyboy@eyeklaud.com AB1 2CD 1 la as entered 5 billyboy@eyeklaud.com 2024 DLUHC DLUHC 2 billyboy@eyeklaud.com 8 8 12 2023 1 2 1 8 2 1 Address line 1 1 1 Town or city 2 1 SW1A 1AA false Barnet E09000003 Address line 1 Town or city address line 1 as entered address line 2 as entered SW1A town or city as entered 1AA county as entered 1 AB1 2CD E09000003 la as entered Barnet 2 2 1 1 1 1 1 0 30 1 X 30 17 X 17 17 17 1 18 1 P 1 35 1 X P 17 35 X 17 1 1 13 3 C 1 14 1 X 3 9 C X 14 -9 X X 3 X R -9 -9 X R 3 10 R -9 R 10 1 0 SW1A 1AA 1 1 1 E09000003 Barnet 1 0 1 1 1 1 1 3 1 1 1 4 3 5 1 1 1 4 0 5 10000 1 1 1 0 0 10000 10000 1 1 4 0 1 10000 1 1 4 2 1 10 1 2 10 110000.0 1 110000.0 20000.0 5 1 20000.0 10 5 1 80000.0 10 1 80000.0 1 100.0 1 100.0 10000.0 10000.0

4
spec/fixtures/files/sales_logs_csv_export_labels_23.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,address_line1_as_entered,address_line2_as_entered,town_or_city_as_entered,county_as_entered,postcode_full_as_entered,la_as_entered,created_by,owning_organisation_name,managing_organisation_name,assigned_to,day,month,year,purchid,ownershipsch,type,othtype,companybuy,buylivein,jointpur,jointmore,beds,proptype,builtype,pcodenk,uprn,uprn_confirmed,address_line1_input,postcode_full_input,uprn_selection,address_line1,address_line2,town_or_city,county,pcode1,pcode2,la_known,la,la_label,wchair,noint,privacynotice,age1,sex1,ethnic_group,ethnic,nationality_all,national,ecstat1,buy1livein,relat2,age2,sex2,ethnic_group2,ethnicbuy2,nationality_all_buyer2,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,2024-01-01T00:00:00+00:00,,2023,single log,false,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,billyboy@eyeklaud.com,DLUHC,DLUHC,billyboy@eyeklaud.com,8,12,2023,,Yes - a discounted ownership scheme,Right to Acquire (RTA),,,,Yes,Yes,2,Flat or maisonette,Purpose built,0,,,,,,Address line 1,,Town or city,,SW1A,1AA,1,E09000003,Barnet,Yes,Yes,1,30,Non-binary,Buyer prefers not to say,17,,United Kingdom,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,Buyer prefers not to say,,,Buyer prefers not to say,Full-time - 30 hours or more,Yes,3,Child,14,Non-binary,,Other,Not known,Non-binary,In government training into work,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,DUPLICATESET,CREATEDDATE,UPLOADDATE,FORM,COLLECTIONYEAR,CREATIONMETHOD,DATAPROTECT,OWNINGORGNAME,MANINGORGNAME,CREATEDBY,USERNAME,DAY,MONTH,YEAR,PURCHID,OWNERSHIP,TYPE,OTHTYPE,COMPANY,LIVEINBUYER,JOINT,JOINTMORE,BEDS,PROPTYPE,BUILTYPE,UPRN,UPRNCONFIRMED,ADDRESS1,ADDRESS2,TOWNCITY,COUNTY,PCODE1,PCODE2,LA,LANAME,WCHAIR,NOINT,PRIVACYNOTICE,AGE1,SEX1,ETHNICGROUP1,ETHNIC,NATIONAL,ECSTAT1,LIVEINBUYER1,RELAT2,AGE2,SEX2,ETHNICGROUP2,ETHNIC2,NATIONAL2,ECSTAT2,LIVEINBUYER2,HHTYPE,RELAT3,AGE3,SEX3,ECSTAT3,RELAT4,AGE4,SEX4,ECSTAT4,RELAT5,AGE5,SEX5,ECSTAT5,RELAT6,AGE6,SEX6,ECSTAT6,PREVTEN,PPCODENK,PPOSTC1,PPOSTC2,PREVIOUSLAKNOWN,PREVLOC,PREVLOCNAME,PREGYRHA,PREGOTHER,PREGLA,PREGGHB,PREGBLANK,BUY2LIVING,PREVTEN2,HHREGRES,HHREGRESSTILL,ARMEDFORCESSPOUSE,DISABLED,WHEEL,INC1NK,INCOME1,INC1MORT,INC2NK,INCOME2,INC2MORT,HB,SAVINGSNK,SAVINGS,PREVOWN,PREVSHARED,PROPLEN,STAIRCASE,STAIRBOUGHT,STAIROWNED,STAIRCASETOSALE,RESALE,EXDAY,EXMONTH,EXYEAR,HODAY,HOMONTH,HOYEAR,LANOMAGR,SOCTEN,FROMBEDS,FROMPROP,SOCPREVTEN,VALUE,VALUE_VALUE_CHECK,EQUITY,MORTGAGEUSED,MORTGAGE,MORTGAGELENDER,MORTGAGELENDEROTHER,MORTLEN1,EXTRABOR,DEPOSIT,CASHDIS,MRENT,HASMSCHARGE,MSCHARGE,MSCHARGE_VALUE_CHECK,DISCOUNT,GRANT
,completed,,2023-12-08T00:00:00+00:00,2024-01-01T00:00:00+00:00,,2023,single log,false,DLUHC,DLUHC,billyboy@eyeklaud.com,billyboy@eyeklaud.com,8,12,2023,,Yes - a discounted ownership scheme,Right to Acquire (RTA),,,,Yes,Yes,2,Flat or maisonette,Purpose built,,,Address line 1,,Town or city,,SW1A,1AA,E09000003,Barnet,Yes,Yes,1,30,Non-binary,Buyer prefers not to say,17,United Kingdom,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,Buyer prefers not to say,,Buyer prefers not to say,Full-time - 30 hours or more,Yes,3,Child,14,Non-binary,,Other,Not known,Non-binary,In government training into work,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 ID status STATUS duplicate_set_id DUPLICATESET created_at CREATEDDATE updated_at UPLOADDATE old_form_id FORM collection_start_year COLLECTIONYEAR creation_method CREATIONMETHOD is_dpo DATAPROTECT address_line1_as_entered OWNINGORGNAME address_line2_as_entered MANINGORGNAME town_or_city_as_entered CREATEDBY county_as_entered USERNAME postcode_full_as_entered DAY la_as_entered MONTH created_by YEAR owning_organisation_name PURCHID managing_organisation_name OWNERSHIP assigned_to TYPE day OTHTYPE month COMPANY year LIVEINBUYER purchid JOINT ownershipsch JOINTMORE type BEDS othtype PROPTYPE companybuy BUILTYPE buylivein UPRN jointpur UPRNCONFIRMED jointmore ADDRESS1 beds ADDRESS2 proptype TOWNCITY builtype COUNTY pcodenk PCODE1 uprn PCODE2 uprn_confirmed LA address_line1_input LANAME postcode_full_input WCHAIR uprn_selection NOINT address_line1 PRIVACYNOTICE address_line2 AGE1 town_or_city SEX1 county ETHNICGROUP1 pcode1 ETHNIC pcode2 NATIONAL la_known ECSTAT1 la LIVEINBUYER1 la_label RELAT2 wchair AGE2 noint SEX2 privacynotice ETHNICGROUP2 age1 ETHNIC2 sex1 NATIONAL2 ethnic_group ECSTAT2 ethnic LIVEINBUYER2 nationality_all HHTYPE national RELAT3 ecstat1 AGE3 buy1livein SEX3 relat2 ECSTAT3 age2 RELAT4 sex2 AGE4 ethnic_group2 SEX4 ethnicbuy2 ECSTAT4 nationality_all_buyer2 RELAT5 nationalbuy2 AGE5 ecstat2 SEX5 buy2livein ECSTAT5 hholdcount RELAT6 relat3 AGE6 age3 SEX6 sex3 ECSTAT6 ecstat3 PREVTEN relat4 PPCODENK age4 PPOSTC1 sex4 PPOSTC2 ecstat4 PREVIOUSLAKNOWN relat5 PREVLOC age5 PREVLOCNAME sex5 PREGYRHA ecstat5 PREGOTHER relat6 PREGLA age6 PREGGHB sex6 PREGBLANK ecstat6 BUY2LIVING prevten PREVTEN2 ppcodenk HHREGRES ppostc1 HHREGRESSTILL ppostc2 ARMEDFORCESSPOUSE previous_la_known DISABLED prevloc WHEEL prevloc_label INC1NK pregyrha INCOME1 pregother INC1MORT pregla INC2NK pregghb INCOME2 pregblank INC2MORT buy2living HB prevtenbuy2 SAVINGSNK hhregres SAVINGS hhregresstill PREVOWN armedforcesspouse PREVSHARED disabled PROPLEN wheel STAIRCASE income1nk STAIRBOUGHT income1 STAIROWNED inc1mort STAIRCASETOSALE income2nk RESALE income2 EXDAY inc2mort EXMONTH hb EXYEAR savingsnk HODAY savings HOMONTH prevown HOYEAR prevshared LANOMAGR proplen SOCTEN staircase FROMBEDS stairbought FROMPROP stairowned SOCPREVTEN staircasesale VALUE resale VALUE_VALUE_CHECK exday EQUITY exmonth MORTGAGEUSED exyear MORTGAGE hoday MORTGAGELENDER homonth MORTGAGELENDEROTHER hoyear MORTLEN1 lanomagr EXTRABOR soctenant DEPOSIT frombeds CASHDIS fromprop MRENT socprevten HASMSCHARGE value MSCHARGE equity MSCHARGE_VALUE_CHECK mortgageused DISCOUNT mortgage GRANT mortgagelender mortgagelenderother mortlen extrabor deposit cashdis mrent has_mscharge mscharge discount grant
2 completed completed 2023-12-08T00:00:00+00:00 2023-12-08T00:00:00+00:00 2024-01-01T00:00:00+00:00 2024-01-01T00:00:00+00:00 2023 2023 single log single log false false address line 1 as entered DLUHC address line 2 as entered DLUHC town or city as entered billyboy@eyeklaud.com county as entered billyboy@eyeklaud.com AB1 2CD 8 la as entered 12 billyboy@eyeklaud.com 2023 DLUHC DLUHC Yes - a discounted ownership scheme billyboy@eyeklaud.com Right to Acquire (RTA) 8 12 2023 Yes Yes - a discounted ownership scheme Yes Right to Acquire (RTA) 2 Flat or maisonette Purpose built Yes Yes Address line 1 2 Flat or maisonette Town or city Purpose built 0 SW1A 1AA E09000003 Barnet Yes Yes Address line 1 1 30 Town or city Non-binary Buyer prefers not to say SW1A 17 1AA United Kingdom 1 Full-time - 30 hours or more E09000003 Yes Barnet Partner Yes 35 Yes Non-binary 1 Buyer prefers not to say 30 Non-binary Buyer prefers not to say Buyer prefers not to say Full-time - 30 hours or more 17 Yes 3 United Kingdom Child Full-time - 30 hours or more 14 Yes Non-binary Partner 35 Other Non-binary Not known Buyer prefers not to say Non-binary In government training into work Prefers not to say Buyer prefers not to say Not known Full-time - 30 hours or more Prefers not to say Yes Prefers not to say 3 Child 14 Non-binary Local authority tenant Other No Not known Non-binary In government training into work No Prefers not to say Not known Prefers not to say 1 Prefers not to say 1 1 1 Don't know Local authority tenant No Yes Yes No No Yes Yes Yes 1 10000 1 Yes 1 Yes 1 10000 Yes Don't know Don’t know No Yes Yes Yes No No Yes 10 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 110000.0 100.0 Yes 20000.0 10000.0 Cambridge Building Society 10 Yes 80000.0 Yes 100.0 10000.0

2
spec/fixtures/files/sales_logs_csv_export_labels_23_during_24_period.csv vendored

@ -1,2 +0,0 @@
id,status,duplicate_set_id,created_at,updated_at,old_form_id,collection_start_year,creation_method,is_dpo,address_line1_as_entered,address_line2_as_entered,town_or_city_as_entered,county_as_entered,postcode_full_as_entered,la_as_entered,created_by,owning_organisation_name,managing_organisation_name,assigned_to,day,month,year,purchid,ownershipsch,type,othtype,companybuy,buylivein,jointpur,jointmore,noint,privacynotice,uprn,uprn_confirmed,address_line1_input,postcode_full_input,uprn_selection,address_line1,address_line2,town_or_city,county,pcode1,pcode2,la_known,la,la_label,beds,proptype,builtype,pcodenk,wchair,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,2024-05-01T00:00:00+01:00,,2023,single log,false,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,billyboy@eyeklaud.com,DLUHC,DLUHC,billyboy@eyeklaud.com,8,12,2023,,Yes - a discounted ownership scheme,Right to Acquire (RTA),,,,Yes,Yes,Yes,1,,,,,,Address line 1,,Town or city,,SW1A,1AA,1,E09000003,Barnet,2,Flat or maisonette,Purpose built,0,Yes,30,Non-binary,Buyer prefers not to say,17,United Kingdom,,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,Buyer prefers not to say,,Buyer prefers not to say,,Full-time - 30 hours or more,Yes,3,Child,14,Non-binary,,Other,Not known,Non-binary,In government training into work,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 address_line1_as_entered address_line2_as_entered town_or_city_as_entered county_as_entered postcode_full_as_entered la_as_entered created_by owning_organisation_name managing_organisation_name assigned_to day month year purchid ownershipsch type othtype companybuy buylivein jointpur jointmore noint privacynotice uprn uprn_confirmed address_line1_input postcode_full_input uprn_selection address_line1 address_line2 town_or_city county pcode1 pcode2 la_known la la_label beds proptype builtype pcodenk wchair 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 2024-05-01T00:00:00+01:00 2023 single log false address line 1 as entered address line 2 as entered town or city as entered county as entered AB1 2CD la as entered billyboy@eyeklaud.com DLUHC DLUHC billyboy@eyeklaud.com 8 12 2023 Yes - a discounted ownership scheme Right to Acquire (RTA) Yes Yes Yes 1 Address line 1 Town or city SW1A 1AA 1 E09000003 Barnet 2 Flat or maisonette Purpose built 0 Yes 30 Non-binary Buyer prefers not to say 17 United Kingdom Full-time - 30 hours or more Yes Partner 35 Non-binary Buyer prefers not to say Buyer prefers not to say Full-time - 30 hours or more Yes 3 Child 14 Non-binary Other Not known Non-binary In government training into work 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

4
spec/fixtures/files/sales_logs_csv_export_labels_24.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,address_line1_as_entered,address_line2_as_entered,town_or_city_as_entered,county_as_entered,postcode_full_as_entered,la_as_entered,created_by,owning_organisation_name,managing_organisation_name,assigned_to,day,month,year,purchid,ownershipsch,type,othtype,companybuy,buylivein,jointpur,jointmore,noint,privacynotice,uprn,uprn_confirmed,address_line1_input,postcode_full_input,uprn_selection,address_line1,address_line2,town_or_city,county,pcode1,pcode2,la_known,la,la_label,beds,proptype,builtype,pcodenk,wchair,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
,in_progress,,2024-05-01T00:00:00+01:00,2024-05-01T00:00:00+01:00,,2024,single log,false,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,billyboy@eyeklaud.com,DLUHC,DLUHC,billyboy@eyeklaud.com,1,5,2024,,Yes - a discounted ownership scheme,Right to Acquire (RTA),,,,Yes,Yes,Yes,1,,,,,,Address line 1,,Town or city,,SW1A,1AA,1,E09000003,Barnet,2,Flat or maisonette,Purpose built,0,Yes,30,Non-binary,Buyer prefers not to say,17,,Australia,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,Buyer prefers not to say,,13,,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,Prefers not to say,Not known,Prefers not to say,Prefers not to say,,,,,Local authority tenant,Yes,SW1A,1AA,Yes,E09000003,Barnet,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,DUPLICATESET,CREATEDDATE,UPLOADDATE,COLLECTIONYEAR,CREATIONMETHOD,BULKUPLOADID,DATAPROTECT,OWNINGORGNAME,MANINGORGNAME,CREATEDBY,USERNAME,DAY,MONTH,YEAR,PURCHID,OWNERSHIP,TYPE,OTHTYPE,COMPANY,LIVEINBUYER,JOINT,JOINTMORE,NOINT,PRIVACYNOTICE,UPRN,ADDRESS1,ADDRESS2,TOWNCITY,COUNTY,POSTCODE,ISLAINFERRED,LANAME,LA,UPRNSELECTED,ADDRESS_SEARCH_VALUE_CHECK,ADDRESS1INPUT,POSTCODEINPUT,BULKADDRESS1,BULKADDRESS2,BULKTOWNCITY,BULKCOUNTY,BULKPOSTCODE,BULKLA,BEDS,PROPTYPE,BUILTYPE,WCHAIR,AGE1,SEX1,ETHNICGROUP1,ETHNIC,NATIONALITYALL1,ECSTAT1,LIVEINBUYER1,RELAT2,AGE2,SEX2,ETHNICGROUP2,ETHNIC2,NATIONALITYALL2,ECSTAT2,LIVEINBUYER2,HHTYPE,RELAT3,AGE3,SEX3,ECSTAT3,RELAT4,AGE4,SEX4,ECSTAT4,RELAT5,AGE5,SEX5,ECSTAT5,RELAT6,AGE6,SEX6,ECSTAT6,PREVTEN,PPCODENK,PPOSTC1,PPOSTC2,PREVIOUSLAKNOWN,PREVLOC,PREVLOCNAME,PREGYRHA,PREGOTHER,PREGLA,PREGGHB,PREGBLANK,BUY2LIVING,PREVTEN2,HHREGRES,HHREGRESSTILL,ARMEDFORCESSPOUSE,DISABLED,WHEEL,INC1NK,INCOME1,INC1MORT,INC2NK,INCOME2,INC2MORT,HB,SAVINGSNK,SAVINGS,PREVOWN,PREVSHARED,PROPLEN,STAIRCASE,STAIRBOUGHT,STAIROWNED,STAIRCASETOSALE,RESALE,EXDAY,EXMONTH,EXYEAR,HODAY,HOMONTH,HOYEAR,LANOMAGR,SOCTEN,FROMBEDS,FROMPROP,SOCPREVTEN,VALUE,VALUE_VALUE_CHECK,EQUITY,MORTGAGEUSED,MORTGAGE,MORTGAGELENDER,MORTGAGELENDEROTHER,MORTLEN1,EXTRABOR,DEPOSIT,CASHDIS,MRENT,HASMSCHARGE,MSCHARGE,MSCHARGE_VALUE_CHECK,DISCOUNT,GRANT
,in_progress,,2024-05-01T00:00:00+01:00,2024-05-01T00:00:00+01:00,2024,single log,,false,DLUHC,DLUHC,billyboy@eyeklaud.com,billyboy@eyeklaud.com,1,5,2024,,Yes - a discounted ownership scheme,Right to Acquire (RTA),,,,Yes,Yes,Yes,1,,Address line 1,,Town or city,,SW1A 1AA,No,Barnet,E09000003,,,,,address line 1 as entered,address line 2 as entered,town or city as entered,county as entered,AB1 2CD,la as entered,2,Flat or maisonette,Purpose built,Yes,30,Non-binary,Buyer prefers not to say,17,Australia,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,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,Prefers not to say,Not known,Prefers not to say,Prefers not to say,,,,,Local authority tenant,Yes,SW1A,1AA,Yes,E09000003,Barnet,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 ID status STATUS duplicate_set_id DUPLICATESET created_at CREATEDDATE updated_at UPLOADDATE old_form_id COLLECTIONYEAR collection_start_year CREATIONMETHOD creation_method BULKUPLOADID is_dpo DATAPROTECT address_line1_as_entered OWNINGORGNAME address_line2_as_entered MANINGORGNAME town_or_city_as_entered CREATEDBY county_as_entered USERNAME postcode_full_as_entered DAY la_as_entered MONTH created_by YEAR owning_organisation_name PURCHID managing_organisation_name OWNERSHIP assigned_to TYPE day OTHTYPE month COMPANY year LIVEINBUYER purchid JOINT ownershipsch JOINTMORE type NOINT othtype PRIVACYNOTICE companybuy UPRN buylivein ADDRESS1 jointpur ADDRESS2 jointmore TOWNCITY noint COUNTY privacynotice POSTCODE uprn ISLAINFERRED uprn_confirmed LANAME address_line1_input LA postcode_full_input UPRNSELECTED uprn_selection ADDRESS_SEARCH_VALUE_CHECK address_line1 ADDRESS1INPUT address_line2 POSTCODEINPUT town_or_city BULKADDRESS1 county BULKADDRESS2 pcode1 BULKTOWNCITY pcode2 BULKCOUNTY la_known BULKPOSTCODE la BULKLA la_label BEDS beds PROPTYPE proptype BUILTYPE builtype WCHAIR pcodenk AGE1 wchair SEX1 age1 ETHNICGROUP1 sex1 ETHNIC ethnic_group NATIONALITYALL1 ethnic ECSTAT1 national LIVEINBUYER1 nationality_all RELAT2 ecstat1 AGE2 buy1livein SEX2 relat2 ETHNICGROUP2 age2 ETHNIC2 sex2 NATIONALITYALL2 ethnic_group2 ECSTAT2 ethnicbuy2 LIVEINBUYER2 nationalbuy2 HHTYPE nationality_all_buyer2 RELAT3 ecstat2 AGE3 buy2livein SEX3 hholdcount ECSTAT3 relat3 RELAT4 age3 AGE4 sex3 SEX4 ecstat3 ECSTAT4 relat4 RELAT5 age4 AGE5 sex4 SEX5 ecstat4 ECSTAT5 relat5 RELAT6 age5 AGE6 sex5 SEX6 ecstat5 ECSTAT6 relat6 PREVTEN age6 PPCODENK sex6 PPOSTC1 ecstat6 PPOSTC2 prevten PREVIOUSLAKNOWN ppcodenk PREVLOC ppostc1 PREVLOCNAME ppostc2 PREGYRHA previous_la_known PREGOTHER prevloc PREGLA prevloc_label PREGGHB pregyrha PREGBLANK pregother BUY2LIVING pregla PREVTEN2 pregghb HHREGRES pregblank HHREGRESSTILL buy2living ARMEDFORCESSPOUSE prevtenbuy2 DISABLED hhregres WHEEL hhregresstill INC1NK armedforcesspouse INCOME1 disabled INC1MORT wheel INC2NK income1nk INCOME2 income1 INC2MORT inc1mort HB income2nk SAVINGSNK income2 SAVINGS inc2mort PREVOWN hb PREVSHARED savingsnk PROPLEN savings STAIRCASE prevown STAIRBOUGHT prevshared STAIROWNED proplen STAIRCASETOSALE staircase RESALE stairbought EXDAY stairowned EXMONTH staircasesale EXYEAR resale HODAY exday HOMONTH exmonth HOYEAR exyear LANOMAGR hoday SOCTEN homonth FROMBEDS hoyear FROMPROP lanomagr SOCPREVTEN soctenant VALUE frombeds VALUE_VALUE_CHECK fromprop EQUITY socprevten MORTGAGEUSED value MORTGAGE equity MORTGAGELENDER mortgageused MORTGAGELENDEROTHER mortgage MORTLEN1 mortgagelender EXTRABOR mortgagelenderother DEPOSIT mortlen CASHDIS extrabor MRENT deposit HASMSCHARGE cashdis MSCHARGE mrent MSCHARGE_VALUE_CHECK has_mscharge DISCOUNT mscharge GRANT discount grant
2 in_progress in_progress 2024-05-01T00:00:00+01:00 2024-05-01T00:00:00+01:00 2024-05-01T00:00:00+01:00 2024-05-01T00:00:00+01:00 2024 2024 single log single log false false address line 1 as entered DLUHC address line 2 as entered DLUHC town or city as entered billyboy@eyeklaud.com county as entered billyboy@eyeklaud.com AB1 2CD 1 la as entered 5 billyboy@eyeklaud.com 2024 DLUHC DLUHC Yes - a discounted ownership scheme billyboy@eyeklaud.com Right to Acquire (RTA) 1 5 2024 Yes Yes - a discounted ownership scheme Yes Right to Acquire (RTA) Yes 1 Address line 1 Yes Yes Town or city Yes 1 SW1A 1AA No Barnet E09000003 Address line 1 Town or city address line 1 as entered address line 2 as entered SW1A town or city as entered 1AA county as entered 1 AB1 2CD E09000003 la as entered Barnet 2 2 Flat or maisonette Flat or maisonette Purpose built Purpose built Yes 0 30 Yes Non-binary 30 Buyer prefers not to say Non-binary 17 Buyer prefers not to say Australia 17 Full-time - 30 hours or more Yes Australia Partner Full-time - 30 hours or more 35 Yes Non-binary Partner Buyer prefers not to say 35 Non-binary Buyer prefers not to say Full-time - 30 hours or more Yes 13 3 Child Full-time - 30 hours or more 14 Yes Non-binary 3 Child under 16 Child Other 14 Not known Non-binary Non-binary Child under 16 In government training into work Other Prefers not to say Not known Not known Non-binary Prefers not to say In government training into work Prefers not to say Prefers not to say Not known Prefers not to say Prefers not to say Local authority tenant Yes SW1A 1AA Local authority tenant Yes Yes E09000003 SW1A Barnet 1AA 1 Yes 1 E09000003 1 Barnet 1 1 1 Don't know 1 1 Yes Yes Don't know No Yes Yes Yes Yes Yes No 10000 Yes Yes Yes Yes Yes 10000 10000 Yes Yes Don’t know Yes No 10000 Yes Yes Don’t know No No 10 Yes No 10 110000.0 Yes 110000.0 20000.0 Cambridge Building Society Yes 20000.0 10 Cambridge Building Society Yes 80000.0 10 Yes 80000.0 Yes 100.0 Yes 100.0 10000.0 10000.0

2
spec/fixtures/files/sales_logs_csv_export_non_support_labels_24.csv vendored

@ -0,0 +1,2 @@
id,status,duplicate_set_id,created_at,updated_at,collection_start_year,creation_method,bulk_upload_id,is_dpo,owning_organisation_name,managing_organisation_name,assigned_to,day,month,year,purchid,ownershipsch,type,othtype,companybuy,buylivein,jointpur,jointmore,noint,privacynotice,uprn,uprn_confirmed,address_line1_input,postcode_full_input,uprn_selection,address_line1,address_line2,town_or_city,county,pcode1,pcode2,la,la_label,beds,proptype,builtype,wchair,age1,sex1,ethnic_group,ethnic,nationality_all,ecstat1,buy1livein,relat2,age2,sex2,ethnic_group2,ethnicbuy2,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
,in_progress,,2024-05-01T00:00:00+01:00,2024-05-01T00:00:00+01:00,2024,single log,,false,DLUHC,DLUHC,billyboy@eyeklaud.com,1,5,2024,,Yes - a discounted ownership scheme,Right to Acquire (RTA),,,,Yes,Yes,Yes,1,,,,,,Address line 1,,Town or city,,SW1A,1AA,E09000003,Barnet,2,Flat or maisonette,Purpose built,Yes,30,Non-binary,Buyer prefers not to say,17,Australia,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,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,Prefers not to say,Not known,Prefers not to say,Prefers not to say,,,,,Local authority tenant,Yes,SW1A,1AA,Yes,E09000003,Barnet,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 collection_start_year creation_method bulk_upload_id is_dpo owning_organisation_name managing_organisation_name assigned_to day month year purchid ownershipsch type othtype companybuy buylivein jointpur jointmore noint privacynotice uprn uprn_confirmed address_line1_input postcode_full_input uprn_selection address_line1 address_line2 town_or_city county pcode1 pcode2 la la_label beds proptype builtype wchair age1 sex1 ethnic_group ethnic nationality_all ecstat1 buy1livein relat2 age2 sex2 ethnic_group2 ethnicbuy2 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 in_progress 2024-05-01T00:00:00+01:00 2024-05-01T00:00:00+01:00 2024 single log false DLUHC DLUHC billyboy@eyeklaud.com 1 5 2024 Yes - a discounted ownership scheme Right to Acquire (RTA) Yes Yes Yes 1 Address line 1 Town or city SW1A 1AA E09000003 Barnet 2 Flat or maisonette Purpose built Yes 30 Non-binary Buyer prefers not to say 17 Australia Full-time - 30 hours or more Yes Partner 35 Non-binary 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 Prefers not to say Not known Prefers not to say Prefers not to say Local authority tenant Yes SW1A 1AA Yes E09000003 Barnet 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

2
spec/fixtures/files/schemes_and_locations_csv_export.csv vendored

@ -1,2 +1,2 @@
scheme_code,scheme_service_name,scheme_status,scheme_sensitive,scheme_type,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_support_services_provided_by,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,scheme_active_dates,location_code,location_postcode,location_name,location_status,location_local_authority,location_units,location_type_of_unit,location_mobility_type,location_active_dates
scheme_code,scheme_service_name,scheme_status,scheme_confidential,scheme_type,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_support_services_provided_by,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,scheme_active_dates,location_code,location_postcode,location_name,location_status,location_local_authority,location_units,location_type_of_unit,location_mobility_type,location_active_dates
,Test name,active,Yes,Housing for older people,No,DLUHC,The same organisation that owns the housing stock,People with alcohol problems,Yes,Older people with support needs,High level,Medium stay,2021-04-01T00:00:00+01:00,"Active from 1 April 2020 to 31 March 2022, Deactivated on 1 April 2022, Active from 1 April 2023",,SW1A 2AA,Downing Street,deactivating_soon,Westminster,20,Self-contained house,Fitted with equipment and adaptations,"Active from 1 April 2022 to 25 December 2023, Deactivated on 26 December 2023"

1 scheme_code scheme_service_name scheme_status scheme_sensitive scheme_confidential scheme_type scheme_registered_under_care_act scheme_owning_organisation_name scheme_support_services_provided_by scheme_primary_client_group scheme_has_other_client_group scheme_secondary_client_group scheme_support_type scheme_intended_stay scheme_created_at scheme_active_dates location_code location_postcode location_name location_status location_local_authority location_units location_type_of_unit location_mobility_type location_active_dates
2 Test name active Yes Yes Housing for older people No DLUHC The same organisation that owns the housing stock People with alcohol problems Yes Older people with support needs High level Medium stay 2021-04-01T00:00:00+01:00 Active from 1 April 2020 to 31 March 2022, Deactivated on 1 April 2022, Active from 1 April 2023 SW1A 2AA Downing Street deactivating_soon Westminster 20 Self-contained house Fitted with equipment and adaptations Active from 1 April 2022 to 25 December 2023, Deactivated on 26 December 2023

2
spec/fixtures/files/schemes_csv_export.csv vendored

@ -1,2 +1,2 @@
scheme_code,scheme_service_name,scheme_status,scheme_sensitive,scheme_type,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_support_services_provided_by,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,scheme_active_dates
scheme_code,scheme_service_name,scheme_status,scheme_confidential,scheme_type,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_support_services_provided_by,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,scheme_active_dates
,Test name,active,Yes,Housing for older people,No,DLUHC,The same organisation that owns the housing stock,People with alcohol problems,Yes,Older people with support needs,High level,Medium stay,2021-04-01T00:00:00+01:00,"Active from 1 April 2020 to 31 March 2022, Deactivated on 1 April 2022, Active from 1 April 2023"

1 scheme_code scheme_service_name scheme_status scheme_sensitive scheme_confidential scheme_type scheme_registered_under_care_act scheme_owning_organisation_name scheme_support_services_provided_by scheme_primary_client_group scheme_has_other_client_group scheme_secondary_client_group scheme_support_type scheme_intended_stay scheme_created_at scheme_active_dates
2 Test name active Yes Yes Housing for older people No DLUHC The same organisation that owns the housing stock People with alcohol problems Yes Older people with support needs High level Medium stay 2021-04-01T00:00:00+01:00 Active from 1 April 2020 to 31 March 2022, Deactivated on 1 April 2022, Active from 1 April 2023

2
spec/fixtures/files/updated_schemes.csv vendored

@ -1,4 +1,4 @@
scheme_code,scheme_service_name,scheme_status,scheme_sensitive,scheme_type,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_support_services_provided_by,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,scheme_active_dates
scheme_code,scheme_service_name,scheme_status,scheme_confidential,scheme_type,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_support_services_provided_by,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,scheme_active_dates
{id1},Updated test name,incomplete,No,Direct Access Hostel,No,Different organisation,Another registered stock owner,People with drug problems,No,Older people with support needs,Low level,Permanent,2022-04-01T00:00:00+01:00,"Active from 2 April 2020"
{id2},Test name,active,Yes,Housing for older people,Yes – registered care home providing nursing care,DLUHC,The same organisation that owns the housing stock,People with alcohol problems,Yes,Older people with support needs,High level,Medium stay,2021-04-01T00:00:00+01:00,"Active from 1 April 2020"
{id3}, ,active,Yse,Direct access Hostel,Yes – registered care home providing nursing care,non existing org,wrong answer,FD,no,lder people with support needs,high,Permanent ,2021-04-01T00:00:00+01:00,"Active from 1 April 2020"

1 scheme_code scheme_service_name scheme_status scheme_sensitive scheme_confidential scheme_type scheme_registered_under_care_act scheme_owning_organisation_name scheme_support_services_provided_by scheme_primary_client_group scheme_has_other_client_group scheme_secondary_client_group scheme_support_type scheme_intended_stay scheme_created_at scheme_active_dates
2 {id1} Updated test name incomplete No No Direct Access Hostel No Different organisation Another registered stock owner People with drug problems No Older people with support needs Low level Permanent 2022-04-01T00:00:00+01:00 Active from 2 April 2020
3 {id2} Test name active Yes Yes Housing for older people Yes – registered care home providing nursing care DLUHC The same organisation that owns the housing stock People with alcohol problems Yes Older people with support needs High level Medium stay 2021-04-01T00:00:00+01:00 Active from 1 April 2020
4 {id3} active Yse Yse Direct access Hostel Yes – registered care home providing nursing care non existing org wrong answer FD no lder people with support needs high Permanent 2021-04-01T00:00:00+01:00 Active from 1 April 2020

20
spec/jobs/email_csv_job_spec.rb

@ -54,13 +54,13 @@ describe EmailCsvJob do
job.perform(user, search_term, filters, all_orgs, organisation, codes_only_export)
end
it "creates a LettingsLogCsvService with the correct export type" do
expect(Csv::LettingsLogCsvService).to receive(:new).with(user:, export_type: "labels")
it "creates a LettingsLogCsvService with the correct export type and year" do
expect(Csv::LettingsLogCsvService).to receive(:new).with(user:, export_type: "labels", year: 2023)
codes_only = false
job.perform(user, nil, {}, nil, nil, codes_only, "lettings")
expect(Csv::LettingsLogCsvService).to receive(:new).with(user:, export_type: "codes")
job.perform(user, nil, {}, nil, nil, codes_only, "lettings", 2023)
expect(Csv::LettingsLogCsvService).to receive(:new).with(user:, export_type: "codes", year: 2024)
codes_only = true
job.perform(user, nil, {}, nil, nil, codes_only, "lettings")
job.perform(user, nil, {}, nil, nil, codes_only, "lettings", 2024)
end
it "passes the logs returned by the filter manager to the csv service" do
@ -89,13 +89,13 @@ describe EmailCsvJob do
job.perform(user, search_term, filters, all_orgs, organisation, codes_only_export, "sales")
end
it "creates a SalesLogCsvService with the correct export type" do
expect(Csv::SalesLogCsvService).to receive(:new).with(user:, export_type: "labels")
it "creates a SalesLogCsvService with the correct export type and year" do
expect(Csv::SalesLogCsvService).to receive(:new).with(user:, export_type: "labels", year: 2022)
codes_only = false
job.perform(user, nil, {}, nil, nil, codes_only, "sales")
expect(Csv::SalesLogCsvService).to receive(:new).with(user:, export_type: "codes")
job.perform(user, nil, {}, nil, nil, codes_only, "sales", 2022)
expect(Csv::SalesLogCsvService).to receive(:new).with(user:, export_type: "codes", year: 2023)
codes_only = true
job.perform(user, nil, {}, nil, nil, codes_only, "sales")
job.perform(user, nil, {}, nil, nil, codes_only, "sales", 2023)
end
it "passes the logs returned by the filter manager to the csv service" do

228
spec/models/form_handler_spec.rb

@ -262,179 +262,73 @@ RSpec.describe FormHandler do
end
end
describe "#ordered_sales_questions_for_all_years" do
let(:result) { described_class.instance.ordered_sales_questions_for_all_years }
let(:now) { Time.zone.now }
it "returns an array of questions" do
section = build(:section, :with_questions, question_ids: %w[1 2 3])
sales_form = FormFactory.new(year: 1936, type: "sales")
.with_sections([section])
.build
described_class.instance.use_fake_forms!({ "current_sales" => sales_form })
expect(result).to(satisfy { |result| result.all? { |element| element.is_a?(Form::Question) } })
end
it "does not return multiple questions with the same id" do
first_section = build(:section, :with_questions, question_ids: %w[1 2 3])
second_section = build(:section, :with_questions, question_ids: %w[2 3 4 5])
sales_form = FormFactory.new(year: 1936, type: "sales")
.with_sections([first_section, second_section])
.build
described_class.instance.use_fake_forms!({ "current_sales" => sales_form })
expect(result.map(&:id)).to eq %w[1 2 3 4 5]
end
it "returns the questions in the same order as the form" do
first_section = build(:section, :with_questions, question_ids: %w[1 2 3])
second_section = build(:section, :with_questions, question_ids: %w[4 5 6])
sales_form = FormFactory.new(year: 1945, type: "sales")
.with_sections([first_section, second_section])
.build
described_class.instance.use_fake_forms!({ "current_sales" => sales_form })
expect(result.map(&:id)).to eq %w[1 2 3 4 5 6]
end
it "inserts questions from all years in their correct positions" do
original_section = build(:section, :with_questions, question_ids: %w[1 1a_deprecated 2 3])
new_section = build(:section, :with_questions, question_ids: %w[1 2 2a_new 3])
original_form = FormFactory.new(year: 1066, type: "sales")
.with_sections([original_section])
.build
new_form = FormFactory.new(year: 1485, type: "sales")
.with_sections([new_section])
.build
fake_forms = {
"previous_sales" => original_form,
"current_sales" => new_form,
}
described_class.instance.use_fake_forms!(fake_forms)
expect(result.map(&:id)).to eq %w[1 1a_deprecated 2 2a_new 3]
end
it "inserts questions from previous years that would start a section after new questions in the previous section" do
original_first_section = build(:section)
original_first_section.subsections = [build(:subsection, :with_questions, question_ids: %w[1 2], id: "1", section: original_first_section)]
new_first_section = build(:section)
new_first_section.subsections = [build(:subsection, :with_questions, question_ids: %w[1 2 extra], id: "1", section: new_first_section)]
original_second_section = build(:section)
original_second_section.subsections = [build(:subsection, :with_questions, question_ids: %w[3 4], id: "2")]
new_second_section = build(:section)
new_second_section.subsections = [build(:subsection, :with_questions, question_ids: %w[3_new 4], id: "2")]
original_form = FormFactory.new(year: 2022, type: "sales").with_sections([original_first_section, original_second_section]).build
new_form = FormFactory.new(year: 2023, type: "sales").with_sections([new_first_section, new_second_section]).build
fake_forms = {
"current_sales" => new_form,
"previous_sales" => original_form,
}
described_class.instance.use_fake_forms!(fake_forms)
expect(result.map(&:id)).to eq %w[1 2 extra 3 3_new 4]
end
it "builds the ordering based on the current form" do
archived_section = build(:section, :with_questions, question_ids: %w[0 1 2 3])
previous_section = build(:section, :with_questions, question_ids: %w[0 1 3 2])
current_section = build(:section, :with_questions, question_ids: %w[3 2 0 1])
next_section = build(:section, :with_questions, question_ids: %w[3 2 1 0])
fake_forms = {
"current_sales" => FormFactory.new(year: 2023, type: "sales").with_sections([current_section]).build,
"previous_sales" => FormFactory.new(year: 2022, type: "sales").with_sections([previous_section]).build,
"next_sales" => FormFactory.new(year: 2021, type: "sales").with_sections([next_section]).build,
"archived_sales" => FormFactory.new(year: 2020, type: "sales").with_sections([archived_section]).build,
}
described_class.instance.use_fake_forms!(fake_forms)
expect(result.map(&:id)).to eq %w[3 2 0 1]
end
end
describe "#ordered_lettings_questions_for_all_years" do
let(:result) { described_class.instance.ordered_lettings_questions_for_all_years }
let(:now) { Time.zone.now }
it "returns an array of questions" do
section = build(:section, :with_questions, question_ids: %w[1 2 3])
lettings_form = FormFactory.new(year: 2936, type: "lettings")
.with_sections([section])
.build
described_class.instance.use_fake_forms!({ "current_lettings" => lettings_form })
expect(result).to(satisfy { |result| result.all? { |element| element.is_a?(Form::Question) } })
end
describe "#ordered_questions_for_year" do
context "with lettings" do
let(:result) { described_class.instance.ordered_questions_for_year(2936, "lettings") }
let(:now) { Time.zone.local(2936, 5, 1) }
it "returns an array of questions" do
section = build(:section, :with_questions, question_ids: %w[1 2 3])
lettings_form = FormFactory.new(year: 2936, type: "lettings")
.with_sections([section])
.build
described_class.instance.use_fake_forms!({ "current_lettings" => lettings_form })
expect(result).to(satisfy { |result| result.all? { |element| element.is_a?(Form::Question) } })
end
it "does not return multiple questions with the same id" do
first_section = build(:section, :with_questions, question_ids: %w[1 2 3])
second_section = build(:section, :with_questions, question_ids: %w[2 3 4 5])
lettings_form = FormFactory.new(year: 2936, type: "lettings")
.with_sections([first_section, second_section])
.build
described_class.instance.use_fake_forms!({ "current_lettings" => lettings_form })
expect(result.map(&:id)).to eq %w[1 2 3 4 5]
end
it "does not return multiple questions with the same id" do
first_section = build(:section, :with_questions, question_ids: %w[1 2 3])
second_section = build(:section, :with_questions, question_ids: %w[2 3 4 5])
lettings_form = FormFactory.new(year: 2936, type: "lettings")
.with_sections([first_section, second_section])
.build
described_class.instance.use_fake_forms!({ "current_lettings" => lettings_form })
expect(result.map(&:id)).to eq %w[1 2 3 4 5]
end
it "returns the questions in the same order as the form" do
first_section = build(:section, :with_questions, question_ids: %w[1 2 3])
second_section = build(:section, :with_questions, question_ids: %w[4 5 6])
lettings_form = FormFactory.new(year: 2945, type: "lettings")
.with_sections([first_section, second_section])
.build
described_class.instance.use_fake_forms!({ "current_lettings" => lettings_form })
expect(result.map(&:id)).to eq %w[1 2 3 4 5 6]
it "returns the questions in the same order as the form" do
first_section = build(:section, :with_questions, question_ids: %w[1 2 3])
second_section = build(:section, :with_questions, question_ids: %w[4 5 6])
lettings_form = FormFactory.new(year: 2936, type: "lettings")
.with_sections([first_section, second_section])
.build
described_class.instance.use_fake_forms!({ "current_lettings" => lettings_form })
expect(result.map(&:id)).to eq %w[1 2 3 4 5 6]
end
end
it "inserts questions from all years in their correct positions" do
original_section = build(:section, :with_questions, question_ids: %w[1 1a_deprecated 2 3])
new_section = build(:section, :with_questions, question_ids: %w[1 2 2a_new 3])
original_form = FormFactory.new(year: 2066, type: "lettings")
.with_sections([original_section])
.build
new_form = FormFactory.new(year: 2485, type: "lettings")
.with_sections([new_section])
.build
fake_forms = {
"previous_lettings" => original_form,
"current_lettings" => new_form,
}
described_class.instance.use_fake_forms!(fake_forms)
expect(result.map(&:id)).to eq %w[1 1a_deprecated 2 2a_new 3]
end
context "with sales" do
let(:result) { described_class.instance.ordered_questions_for_year(2936, "sales") }
let(:now) { Time.zone.local(2936, 5, 1) }
it "returns an array of questions" do
section = build(:section, :with_questions, question_ids: %w[1 2 3])
sales_form = FormFactory.new(year: 2936, type: "sales")
.with_sections([section])
.build
described_class.instance.use_fake_forms!({ "current_sales" => sales_form })
expect(result).to(satisfy { |result| result.all? { |element| element.is_a?(Form::Question) } })
end
it "inserts questions from previous years that would start a section after new questions in the previous section" do
original_first_section = build(:section)
original_first_section.subsections = [build(:subsection, :with_questions, question_ids: %w[1 2], id: "1", section: original_first_section)]
new_first_section = build(:section)
new_first_section.subsections = [build(:subsection, :with_questions, question_ids: %w[1 2 extra], id: "1", section: new_first_section)]
original_second_section = build(:section)
original_second_section.subsections = [build(:subsection, :with_questions, question_ids: %w[3 4], id: "2")]
new_second_section = build(:section)
new_second_section.subsections = [build(:subsection, :with_questions, question_ids: %w[3_new 4], id: "2")]
original_form = FormFactory.new(year: 2023, type: "lettings").with_sections([original_first_section, original_second_section]).build
new_form = FormFactory.new(year: 2024, type: "lettings").with_sections([new_first_section, new_second_section]).build
fake_forms = {
"current_lettings" => new_form,
"previous_lettings" => original_form,
}
described_class.instance.use_fake_forms!(fake_forms)
expect(result.map(&:id)).to eq %w[1 2 extra 3 3_new 4]
end
it "does not return multiple questions with the same id" do
first_section = build(:section, :with_questions, question_ids: %w[1 2 3])
second_section = build(:section, :with_questions, question_ids: %w[2 3 4 5])
sales_form = FormFactory.new(year: 2936, type: "sales")
.with_sections([first_section, second_section])
.build
described_class.instance.use_fake_forms!({ "current_sales" => sales_form })
expect(result.map(&:id)).to eq %w[1 2 3 4 5]
end
it "builds the ordering based on the current form" do
archived_section = build(:section, :with_questions, question_ids: %w[0 1 2 3])
previous_section = build(:section, :with_questions, question_ids: %w[0 1 3 2])
current_section = build(:section, :with_questions, question_ids: %w[3 2 0 1])
next_section = build(:section, :with_questions, question_ids: %w[3 2 1 0])
fake_forms = {
"current_lettings" => FormFactory.new(year: 2023, type: "sales").with_sections([current_section]).build,
"previous_lettings" => FormFactory.new(year: 2022, type: "sales").with_sections([previous_section]).build,
"next_lettings" => FormFactory.new(year: 2021, type: "sales").with_sections([next_section]).build,
"archived_lettings" => FormFactory.new(year: 2020, type: "sales").with_sections([archived_section]).build,
}
described_class.instance.use_fake_forms!(fake_forms)
expect(result.map(&:id)).to eq %w[3 2 0 1]
it "returns the questions in the same order as the form" do
first_section = build(:section, :with_questions, question_ids: %w[1 2 3])
second_section = build(:section, :with_questions, question_ids: %w[4 5 6])
sales_form = FormFactory.new(year: 2936, type: "sales")
.with_sections([first_section, second_section])
.build
described_class.instance.use_fake_forms!({ "current_sales" => sales_form })
expect(result.map(&:id)).to eq %w[1 2 3 4 5 6]
end
end
end
# rubocop:enable RSpec/PredicateMatcher

24
spec/requests/delete_logs_controller_spec.rb

@ -20,8 +20,7 @@ RSpec.describe "DeleteLogs", type: :request do
it "calls the filter service with the filters in the session and the search term from the query params" do
search = "Schrödinger's cat"
logs_filters = {
"years" => [""],
"status" => ["", "in_progress"],
"status" => %w[in_progress],
"assigned_to" => "all",
}
get lettings_logs_path(logs_filters) # adds the filters to the session
@ -69,8 +68,7 @@ RSpec.describe "DeleteLogs", type: :request do
it "calls the filter service with the filters in the session and the search term from the query params" do
search = "Schrödinger's cat"
logs_filters = {
"years" => [""],
"status" => ["", "in_progress"],
"status" => %w[in_progress],
"assigned_to" => "all",
}
get lettings_logs_path(logs_filters) # adds the filters to the session
@ -307,8 +305,7 @@ RSpec.describe "DeleteLogs", type: :request do
it "calls the filter service with the filters in the session and the search term from the query params" do
search = "Schrödinger's cat"
logs_filters = {
"years" => [""],
"status" => ["", "in_progress"],
"status" => %w[in_progress],
"assigned_to" => "all",
}
get sales_logs_path(logs_filters) # adds the filters to the session
@ -356,8 +353,7 @@ RSpec.describe "DeleteLogs", type: :request do
it "calls the filter service with the filters in the session and the search term from the query params" do
search = "Schrödinger's cat"
logs_filters = {
"years" => [""],
"status" => ["", "in_progress"],
"status" => %w[in_progress],
"assigned_to" => "all",
}
get sales_logs_path(logs_filters) # adds the filters to the session
@ -598,8 +594,7 @@ RSpec.describe "DeleteLogs", type: :request do
it "calls the filter service with the filters in the session and the search term from the query params" do
search = "Schrödinger's cat"
logs_filters = {
"years" => [""],
"status" => ["", "in_progress"],
"status" => %w[in_progress],
"assigned_to" => "all",
}
get lettings_logs_path(logs_filters) # adds the filters to the session
@ -647,8 +642,7 @@ RSpec.describe "DeleteLogs", type: :request do
it "calls the filter service with the filters in the session and the search term from the query params" do
search = "Schrödinger's cat"
logs_filters = {
"years" => [""],
"status" => ["", "in_progress"],
"status" => %w[in_progress],
"assigned_to" => "all",
}
get lettings_logs_path(logs_filters) # adds the filters to the session
@ -823,8 +817,7 @@ RSpec.describe "DeleteLogs", type: :request do
it "calls the filter service with the filters in the session and the search term from the query params" do
search = "Schrödinger's cat"
logs_filters = {
"years" => [""],
"status" => ["", "in_progress"],
"status" => %w[in_progress],
"assigned_to" => "all",
}
get sales_logs_path(logs_filters) # adds the filters to the session
@ -872,8 +865,7 @@ RSpec.describe "DeleteLogs", type: :request do
it "calls the filter service with the filters in the session and the search term from the query params" do
search = "Schrödinger's cat"
logs_filters = {
"years" => [""],
"status" => ["", "in_progress"],
"status" => %w[in_progress],
"assigned_to" => "all",
}
get sales_logs_path(logs_filters) # adds the filters to the session

117
spec/requests/lettings_logs_controller_spec.rb

@ -1400,22 +1400,65 @@ RSpec.describe LettingsLogsController, type: :request do
context "when requesting CSV download" do
let(:headers) { { "Accept" => "text/html" } }
let(:search_term) { "foo" }
let!(:lettings_log) { create(:lettings_log, :setup_completed, assigned_to: user, owning_organisation: user.organisation, tenancycode: search_term) }
before do
sign_in user
get "/lettings-logs/csv-download?search=#{search_term}&codes_only=false", headers:
end
it "returns http success" do
expect(response).to have_http_status(:success)
context "when there is 1 year selected in the filters" do
before do
get "/lettings-logs/csv-download?years[]=#{lettings_log.form.start_date.year}&search=#{search_term}&codes_only=false", headers:
end
it "returns http success" do
expect(response).to have_http_status(:success)
end
it "shows a confirmation button" do
expect(page).to have_button("Send email")
end
it "includes the search term" do
expect(page).to have_field("search", type: "hidden", with: search_term)
end
it "allows updating log filters" do
expect(page).to have_content("Check your filters")
expect(page).to have_link("Change", count: 6)
expect(page).to have_link("Change", href: "/lettings-logs/filters/years?codes_only=false&referrer=check_answers&search=#{search_term}")
expect(page).to have_link("Change", href: "/lettings-logs/filters/assigned-to?codes_only=false&referrer=check_answers&search=#{search_term}")
expect(page).to have_link("Change", href: "/lettings-logs/filters/owned-by?codes_only=false&referrer=check_answers&search=#{search_term}")
expect(page).to have_link("Change", href: "/lettings-logs/filters/managed-by?codes_only=false&referrer=check_answers&search=#{search_term}")
expect(page).to have_link("Change", href: "/lettings-logs/filters/status?codes_only=false&referrer=check_answers&search=#{search_term}")
expect(page).to have_link("Change", href: "/lettings-logs/filters/needstype?codes_only=false&referrer=check_answers&search=#{search_term}")
end
end
it "shows a confirmation button" do
expect(page).to have_button("Send email")
context "when there are no years selected in the filters" do
before do
get "/lettings-logs/csv-download?search=#{search_term}&codes_only=false", headers:
end
it "redirects to the year filter question" do
expect(response).to redirect_to("/lettings-logs/filters/years?codes_only=false&search=#{search_term}")
follow_redirect!
expect(page).to have_content("Which financial year do you want to download data for?")
expect(page).to have_button("Save changes")
end
end
it "includes the search term" do
expect(page).to have_field("search", type: "hidden", with: search_term)
context "when there are multiple years selected in the filters" do
before do
get "/lettings-logs/csv-download?years[]=2021&years[]=2022&search=#{search_term}&codes_only=false", headers:
end
it "redirects to the year filter question" do
expect(response).to redirect_to("/lettings-logs/filters/years?codes_only=false&search=#{search_term}")
follow_redirect!
expect(page).to have_content("Which financial year do you want to download data for?")
expect(page).to have_button("Save changes")
end
end
end
@ -1739,6 +1782,7 @@ RSpec.describe LettingsLogsController, type: :request do
let(:page) { Capybara::Node::Simple.new(response.body) }
let(:user) { FactoryBot.create(:user) }
let(:headers) { { "Accept" => "text/html" } }
let!(:lettings_log) { create(:lettings_log, :setup_completed, assigned_to: user) }
before do
allow(user).to receive(:need_two_factor_authentication?).and_return(false)
@ -1746,24 +1790,29 @@ RSpec.describe LettingsLogsController, type: :request do
end
it "renders a page with the correct header" do
get "/lettings-logs/csv-download?codes_only=false", headers:, params: {}
get "/lettings-logs/csv-download?years[]=#{lettings_log.form.start_date.year}&codes_only=false", headers:, params: {}
header = page.find_css("h1")
expect(header.text).to include("Download CSV")
end
it "renders a form with the correct target containing a button with the correct text" do
get "/lettings-logs/csv-download?codes_only=false", headers:, params: {}
get "/lettings-logs/csv-download?years[]=#{lettings_log.form.start_date.year}&codes_only=false", headers:, params: {}
form = page.find("form.button_to")
expect(form[:method]).to eq("post")
expect(form[:action]).to eq("/lettings-logs/email-csv")
expect(form).to have_button("Send email")
end
it "when query string contains search parameter, form contains hidden field with correct value" do
search_term = "blam"
get "/lettings-logs/csv-download?codes_only=false&search=#{search_term}", headers:, params: {}
hidden_field = page.find("form.button_to").find_field("search", type: "hidden")
expect(hidden_field.value).to eq(search_term)
context "when query string contains search parameter" do
let(:search_term) { "blam" }
let!(:lettings_log) { create(:lettings_log, :setup_completed, assigned_to: user, tenancycode: search_term) }
it "contains hidden field with correct value" do
get "/lettings-logs/csv-download?years[]=#{lettings_log.form.start_date.year}&codes_only=false&search=#{search_term}", headers:, params: {}
expect(page).to have_button("Send email")
hidden_field = page.find("form.button_to").find_field("search", type: "hidden")
expect(hidden_field.value).to eq(search_term)
end
end
context "when the user is a data coordinator" do
@ -1771,7 +1820,7 @@ RSpec.describe LettingsLogsController, type: :request do
it "when codes_only query parameter is false, form contains hidden field with correct value" do
codes_only = false
get "/lettings-logs/csv-download?codes_only=#{codes_only}", headers:, params: {}
get "/lettings-logs/csv-download?years[]=#{lettings_log.form.start_date.year}&codes_only=#{codes_only}", headers:, params: {}
hidden_field = page.find("form.button_to").find_field("codes_only", type: "hidden")
expect(hidden_field.value).to eq(codes_only.to_s)
end
@ -1786,7 +1835,7 @@ RSpec.describe LettingsLogsController, type: :request do
context "when the user is a data provider" do
it "when codes_only query parameter is false, form contains hidden field with correct value" do
codes_only = false
get "/lettings-logs/csv-download?codes_only=#{codes_only}", headers:, params: {}
get "/lettings-logs/csv-download?years[]=#{lettings_log.form.start_date.year}&codes_only=#{codes_only}", headers:, params: {}
hidden_field = page.find("form.button_to").find_field("codes_only", type: "hidden")
expect(hidden_field.value).to eq(codes_only.to_s)
end
@ -1803,14 +1852,14 @@ RSpec.describe LettingsLogsController, type: :request do
it "when codes_only query parameter is false, form contains hidden field with correct value" do
codes_only = false
get "/lettings-logs/csv-download?codes_only=#{codes_only}", headers:, params: {}
get "/lettings-logs/csv-download?years[]=#{lettings_log.form.start_date.year}&codes_only=#{codes_only}", headers:, params: {}
hidden_field = page.find("form.button_to").find_field("codes_only", type: "hidden")
expect(hidden_field.value).to eq(codes_only.to_s)
end
it "when codes_only query parameter is true, form contains hidden field with correct value" do
codes_only = true
get "/lettings-logs/csv-download?codes_only=#{codes_only}", headers:, params: {}
get "/lettings-logs/csv-download?years[]=#{lettings_log.form.start_date.year}&codes_only=#{codes_only}", headers:, params: {}
hidden_field = page.find("form.button_to").find_field("codes_only", type: "hidden")
expect(hidden_field.value).to eq(codes_only.to_s)
end
@ -1843,42 +1892,42 @@ RSpec.describe LettingsLogsController, type: :request do
it "creates an E-mail job" do
expect {
post "/lettings-logs/email-csv?codes_only=true", headers:, params: {}
}.to enqueue_job(EmailCsvJob).with(user, nil, {}, false, nil, true)
post "/lettings-logs/email-csv?years[]=2023&codes_only=true", headers:, params: {}
}.to enqueue_job(EmailCsvJob).with(user, nil, { "years" => %w[2023] }, false, nil, true, "lettings", 2023)
end
it "redirects to the confirmation page" do
post "/lettings-logs/email-csv?codes_only=true", headers:, params: {}
post "/lettings-logs/email-csv?years[]=2023&codes_only=true", headers:, params: {}
expect(response).to redirect_to(csv_confirmation_lettings_logs_path)
end
it "passes the search term" do
expect {
post "/lettings-logs/email-csv?search=#{lettings_log.id}&codes_only=false", headers:, params: {}
}.to enqueue_job(EmailCsvJob).with(user, lettings_log.id.to_s, {}, false, nil, false)
post "/lettings-logs/email-csv?years[]=2023&search=#{lettings_log.id}&codes_only=false", headers:, params: {}
}.to enqueue_job(EmailCsvJob).with(user, lettings_log.id.to_s, { "years" => %w[2023] }, false, nil, false, "lettings", 2023)
end
it "passes filter parameters" do
expect {
post "/lettings-logs/email-csv?status[]=completed&codes_only=true", headers:, params: {}
}.to enqueue_job(EmailCsvJob).with(user, nil, { "status" => %w[completed] }, false, nil, true)
post "/lettings-logs/email-csv?years[]=2023&status[]=completed&codes_only=true", headers:, params: {}
}.to enqueue_job(EmailCsvJob).with(user, nil, { "status" => %w[completed], "years" => %w[2023] }, false, nil, true, "lettings", 2023)
end
it "passes export type flag" do
expect {
post "/lettings-logs/email-csv?codes_only=true", headers:, params: {}
}.to enqueue_job(EmailCsvJob).with(user, nil, {}, false, nil, true)
post "/lettings-logs/email-csv?years[]=2023&codes_only=true", headers:, params: {}
}.to enqueue_job(EmailCsvJob).with(user, nil, { "years" => %w[2023] }, false, nil, true, "lettings", 2023)
expect {
post "/lettings-logs/email-csv?codes_only=false", headers:, params: {}
}.to enqueue_job(EmailCsvJob).with(user, nil, {}, false, nil, false)
post "/lettings-logs/email-csv?years[]=2023&codes_only=false", headers:, params: {}
}.to enqueue_job(EmailCsvJob).with(user, nil, { "years" => %w[2023] }, false, nil, false, "lettings", 2023)
end
it "passes a combination of search term, export type and filter parameters" do
postcode = "XX1 1TG"
expect {
post "/lettings-logs/email-csv?status[]=completed&search=#{postcode}&codes_only=false", headers:, params: {}
}.to enqueue_job(EmailCsvJob).with(user, postcode, { "status" => %w[completed] }, false, nil, false)
post "/lettings-logs/email-csv?years[]=2023&status[]=completed&search=#{postcode}&codes_only=false", headers:, params: {}
}.to enqueue_job(EmailCsvJob).with(user, postcode, { "status" => %w[completed], "years" => %w[2023] }, false, nil, false, "lettings", 2023)
end
context "when the user is not a support user" do
@ -1887,13 +1936,13 @@ RSpec.describe LettingsLogsController, type: :request do
it "has permission to download human readable csv" do
codes_only_export = false
expect {
post "/lettings-logs/email-csv?codes_only=#{codes_only_export}", headers:, params: {}
}.to enqueue_job(EmailCsvJob).with(user, nil, {}, false, nil, false)
post "/lettings-logs/email-csv?years[]=2023&codes_only=#{codes_only_export}", headers:, params: {}
}.to enqueue_job(EmailCsvJob).with(user, nil, { "years" => %w[2023] }, false, nil, false, "lettings", 2023)
end
it "is not authorized to download codes only csv" do
codes_only_export = true
post "/lettings-logs/email-csv?codes_only=#{codes_only_export}", headers:, params: {}
post "/lettings-logs/email-csv?years[]=2023&codes_only=#{codes_only_export}", headers:, params: {}
expect(response).to have_http_status(:unauthorized)
end
end

59
spec/requests/organisations_controller_spec.rb

@ -1589,7 +1589,7 @@ RSpec.describe OrganisationsController, type: :request do
let(:tenancycode) { "42" }
before do
create(:lettings_log, owning_organisation: organisation, tenancycode:)
create(:lettings_log, :in_progress, owning_organisation: organisation, tenancycode:)
end
context "when there is at least one log visible" do
@ -1625,16 +1625,24 @@ RSpec.describe OrganisationsController, type: :request do
context "when you download the CSV" do
let(:other_organisation) { create(:organisation) }
let!(:lettings_logs) { create_list(:lettings_log, 2, :in_progress, owning_organisation: organisation) }
before do
create_list(:lettings_log, 2, owning_organisation: organisation)
create(:lettings_log, owning_organisation: organisation, status: "pending", skip_update_status: true)
create_list(:lettings_log, 2, owning_organisation: other_organisation)
create(:lettings_log, :in_progress, owning_organisation: organisation, status: "pending", skip_update_status: true)
create_list(:lettings_log, 2, :in_progress, owning_organisation: other_organisation)
end
it "only includes logs from that organisation" do
get "/organisations/#{organisation.id}/lettings-logs/csv-download?codes_only=false"
context "when no year filters are applied" do
it "redirects to years filter page" do
get "/organisations/#{organisation.id}/lettings-logs/csv-download?codes_only=false"
expect(response).to redirect_to("/organisations/#{organisation.id}/lettings-logs/filters/years?codes_only=false")
follow_redirect!
expect(page).to have_button("Save changes")
end
end
it "only includes logs from that organisation" do
get "/organisations/#{organisation.id}/lettings-logs/csv-download?years[]=#{lettings_logs[0].form.start_date.year}&codes_only=false"
expect(page).to have_text("You've selected 3 logs.")
end
@ -1669,7 +1677,7 @@ RSpec.describe OrganisationsController, type: :request do
context "when they view the sales logs tab" do
before do
create(:sales_log, owning_organisation: organisation)
create(:sales_log, :in_progress, owning_organisation: organisation)
end
it "has CSV download buttons with the correct paths if at least 1 log exists" do
@ -1680,15 +1688,16 @@ RSpec.describe OrganisationsController, type: :request do
context "when you download the CSV" do
let(:other_organisation) { create(:organisation) }
let(:sales_logs_start_year) { organisation.owned_sales_logs.first.form.start_date.year }
before do
create_list(:sales_log, 2, owning_organisation: organisation)
create(:sales_log, owning_organisation: organisation, status: "pending", skip_update_status: true)
create_list(:sales_log, 2, owning_organisation: other_organisation)
create_list(:sales_log, 2, :in_progress, owning_organisation: organisation)
create(:sales_log, :in_progress, owning_organisation: organisation, status: "pending", skip_update_status: true)
create_list(:sales_log, 2, :in_progress, owning_organisation: other_organisation)
end
it "only includes logs from that organisation" do
get "/organisations/#{organisation.id}/sales-logs/csv-download?codes_only=false"
get "/organisations/#{organisation.id}/sales-logs/csv-download?years[]=#{sales_logs_start_year}&codes_only=false"
expect(page).to have_text("You've selected 3 logs.")
end
@ -1720,14 +1729,17 @@ RSpec.describe OrganisationsController, type: :request do
end
describe "GET #download_lettings_csv" do
let(:search_term) { "blam" }
let!(:lettings_log) { create(:lettings_log, :setup_completed, owning_organisation: organisation, tenancycode: search_term) }
it "renders a page with the correct header" do
get "/organisations/#{organisation.id}/lettings-logs/csv-download?codes_only=false", headers:, params: {}
get "/organisations/#{organisation.id}/lettings-logs/csv-download?years[]=#{lettings_log.form.start_date.year}&codes_only=false", headers:, params: {}
header = page.find_css("h1")
expect(header.text).to include("Download CSV")
end
it "renders a form with the correct target containing a button with the correct text" do
get "/organisations/#{organisation.id}/lettings-logs/csv-download?codes_only=false", headers:, params: {}
get "/organisations/#{organisation.id}/lettings-logs/csv-download?years[]=#{lettings_log.form.start_date.year}&codes_only=false", headers:, params: {}
form = page.find("form.button_to")
expect(form[:method]).to eq("post")
expect(form[:action]).to eq("/organisations/#{organisation.id}/lettings-logs/email-csv")
@ -1736,35 +1748,37 @@ RSpec.describe OrganisationsController, type: :request do
it "when codes_only query parameter is false, form contains hidden field with correct value" do
codes_only = false
get "/organisations/#{organisation.id}/lettings-logs/csv-download?codes_only=#{codes_only}", headers:, params: {}
get "/organisations/#{organisation.id}/lettings-logs/csv-download?years[]=#{lettings_log.form.start_date.year}&codes_only=#{codes_only}", headers:, params: {}
hidden_field = page.find("form.button_to").find_field("codes_only", type: "hidden")
expect(hidden_field.value).to eq(codes_only.to_s)
end
it "when codes_only query parameter is true, form contains hidden field with correct value" do
codes_only = true
get "/organisations/#{organisation.id}/lettings-logs/csv-download?codes_only=#{codes_only}", headers:, params: {}
get "/organisations/#{organisation.id}/lettings-logs/csv-download?years[]=#{lettings_log.form.start_date.year}&codes_only=#{codes_only}", headers:, params: {}
hidden_field = page.find("form.button_to").find_field("codes_only", type: "hidden")
expect(hidden_field.value).to eq(codes_only.to_s)
end
it "when query string contains search parameter, form contains hidden field with correct value" do
search_term = "blam"
get "/organisations/#{organisation.id}/lettings-logs/csv-download?codes_only=true&search=#{search_term}", headers:, params: {}
get "/organisations/#{organisation.id}/lettings-logs/csv-download?years[]=#{lettings_log.form.start_date.year}&codes_only=true&search=#{search_term}", headers:, params: {}
hidden_field = page.find("form.button_to").find_field("search", type: "hidden")
expect(hidden_field.value).to eq(search_term)
end
end
describe "GET #download_sales_csv" do
let(:search_term) { "blam" }
let!(:sales_log) { create(:sales_log, :in_progress, owning_organisation: organisation, purchid: search_term) }
it "renders a page with the correct header" do
get "/organisations/#{organisation.id}/sales-logs/csv-download?codes_only=false", headers:, params: {}
get "/organisations/#{organisation.id}/sales-logs/csv-download?years[]=#{sales_log.form.start_date.year}&codes_only=false", headers:, params: {}
header = page.find_css("h1")
expect(header.text).to include("Download CSV")
end
it "renders a form with the correct target containing a button with the correct text" do
get "/organisations/#{organisation.id}/sales-logs/csv-download?codes_only=false", headers:, params: {}
get "/organisations/#{organisation.id}/sales-logs/csv-download?years[]=#{sales_log.form.start_date.year}&codes_only=false", headers:, params: {}
form = page.find("form.button_to")
expect(form[:method]).to eq("post")
expect(form[:action]).to eq("/organisations/#{organisation.id}/sales-logs/email-csv")
@ -1773,21 +1787,20 @@ RSpec.describe OrganisationsController, type: :request do
it "when codes_only query parameter is false, form contains hidden field with correct value" do
codes_only = false
get "/organisations/#{organisation.id}/sales-logs/csv-download?codes_only=#{codes_only}", headers:, params: {}
get "/organisations/#{organisation.id}/sales-logs/csv-download?years[]=#{sales_log.form.start_date.year}&codes_only=#{codes_only}", headers:, params: {}
hidden_field = page.find("form.button_to").find_field("codes_only", type: "hidden")
expect(hidden_field.value).to eq(codes_only.to_s)
end
it "when codes_only query parameter is true, form contains hidden field with correct value" do
codes_only = true
get "/organisations/#{organisation.id}/sales-logs/csv-download?codes_only=#{codes_only}", headers:, params: {}
get "/organisations/#{organisation.id}/sales-logs/csv-download?years[]=#{sales_log.form.start_date.year}&codes_only=#{codes_only}", headers:, params: {}
hidden_field = page.find("form.button_to").find_field("codes_only", type: "hidden")
expect(hidden_field.value).to eq(codes_only.to_s)
end
it "when query string contains search parameter, form contains hidden field with correct value" do
search_term = "blam"
get "/organisations/#{organisation.id}/sales-logs/csv-download?codes_only=true&search=#{search_term}", headers:, params: {}
get "/organisations/#{organisation.id}/sales-logs/csv-download?years[]=#{sales_log.form.start_date.year}&codes_only=true&search=#{search_term}", headers:, params: {}
hidden_field = page.find("form.button_to").find_field("search", type: "hidden")
expect(hidden_field.value).to eq(search_term)
end

96
spec/requests/sales_logs_controller_spec.rb

@ -965,24 +965,70 @@ RSpec.describe SalesLogsController, type: :request do
let(:codes_only) { false }
before do
create(:sales_log, :in_progress, assigned_to: user, purchid: search_term)
allow(user).to receive(:need_two_factor_authentication?).and_return(false)
sign_in user
get "/sales-logs/csv-download?search=#{search_term}&codes_only=#{codes_only}", headers:
end
it "returns http success" do
expect(response).to have_http_status(:success)
context "when there is 1 year selected in the filters" do
before do
get "/sales-logs/csv-download?years[]=2023&search=#{search_term}&codes_only=#{codes_only}", headers:
end
it "returns http success" do
expect(response).to have_http_status(:success)
end
it "shows a confirmation button" do
expect(page).to have_button("Send email")
end
it "allows updating log filters" do
expect(page).to have_content("Check your filters")
expect(page).to have_link("Change", count: 5)
expect(page).to have_link("Change", href: "/sales-logs/filters/years?codes_only=false&referrer=check_answers&search=#{search_term}")
expect(page).to have_link("Change", href: "/sales-logs/filters/assigned-to?codes_only=false&referrer=check_answers&search=#{search_term}")
expect(page).to have_link("Change", href: "/sales-logs/filters/owned-by?codes_only=false&referrer=check_answers&search=#{search_term}")
expect(page).to have_link("Change", href: "/sales-logs/filters/managed-by?codes_only=false&referrer=check_answers&search=#{search_term}")
expect(page).to have_link("Change", href: "/sales-logs/filters/status?codes_only=false&referrer=check_answers&search=#{search_term}")
end
it "has a hidden field with the search term" do
expect(page).to have_field("search", type: "hidden", with: search_term)
end
end
it "shows a confirmation button" do
expect(page).to have_button("Send email")
context "when there are no years selected in the filters" do
before do
get "/sales-logs/csv-download?search=#{search_term}&codes_only=false", headers:
end
it "redirects to the year filter question" do
expect(response).to redirect_to("/sales-logs/filters/years?codes_only=false&search=#{search_term}")
follow_redirect!
expect(page).to have_content("Which financial year do you want to download data for?")
expect(page).to have_button("Save changes")
end
end
it "has a hidden field with the search term" do
expect(page).to have_field("search", type: "hidden", with: search_term)
context "when there are multiple years selected in the filters" do
before do
get "/sales-logs/csv-download?years[]=2021&years[]=2022&search=#{search_term}&codes_only=false", headers:
end
it "redirects to the year filter question" do
expect(response).to redirect_to("/sales-logs/filters/years?codes_only=false&search=#{search_term}")
follow_redirect!
expect(page).to have_content("Which financial year do you want to download data for?")
expect(page).to have_button("Save changes")
end
end
context "when user is not support" do
before do
get "/sales-logs/csv-download?years[]=2023&search=#{search_term}&codes_only=#{codes_only}", headers:
end
context "and export type is not codes only" do
it "has a hidden field with the export type" do
expect(page).to have_field("codes_only", type: "hidden", with: codes_only)
@ -1001,6 +1047,10 @@ RSpec.describe SalesLogsController, type: :request do
context "when user is support" do
let(:user) { FactoryBot.create(:user, :support) }
before do
get "/sales-logs/csv-download?years[]=2023&search=#{search_term}&codes_only=#{codes_only}", headers:
end
context "and export type is not codes only" do
it "has a hidden field with the export type" do
expect(page).to have_field("codes_only", type: "hidden", with: codes_only)
@ -1050,42 +1100,42 @@ RSpec.describe SalesLogsController, type: :request do
it "creates an E-mail job with the correct log type" do
expect {
post "/sales-logs/email-csv?codes_only=true", headers:, params: {}
}.to enqueue_job(EmailCsvJob).with(user, nil, {}, false, nil, true, "sales")
post "/sales-logs/email-csv?years[]=2023&codes_only=true", headers:, params: {}
}.to enqueue_job(EmailCsvJob).with(user, nil, { "years" => %w[2023] }, false, nil, true, "sales", 2023)
end
it "redirects to the confirmation page" do
post "/sales-logs/email-csv?codes_only=true", headers:, params: {}
post "/sales-logs/email-csv?years[]=2023&codes_only=true", headers:, params: {}
expect(response).to redirect_to(csv_confirmation_sales_logs_path)
end
it "passes the search term" do
expect {
post "/sales-logs/email-csv?search=#{sales_log.id}&codes_only=false", headers:, params: {}
}.to enqueue_job(EmailCsvJob).with(user, sales_log.id.to_s, {}, false, nil, false, "sales")
post "/sales-logs/email-csv?search=#{sales_log.id}&years[]=2023&codes_only=false", headers:, params: {}
}.to enqueue_job(EmailCsvJob).with(user, sales_log.id.to_s, { "years" => %w[2023] }, false, nil, false, "sales", 2023)
end
it "passes filter parameters" do
expect {
post "/sales-logs/email-csv?status[]=completed&codes_only=true", headers:, params: {}
}.to enqueue_job(EmailCsvJob).with(user, nil, { "status" => %w[completed] }, false, nil, true, "sales")
post "/sales-logs/email-csv?years[]=2023&status[]=completed&codes_only=true", headers:, params: {}
}.to enqueue_job(EmailCsvJob).with(user, nil, { "status" => %w[completed], "years" => %w[2023] }, false, nil, true, "sales", 2023)
end
it "passes export type flag" do
expect {
post "/sales-logs/email-csv?codes_only=true", headers:, params: {}
}.to enqueue_job(EmailCsvJob).with(user, nil, {}, false, nil, true, "sales")
post "/sales-logs/email-csv?years[]=2023&codes_only=true", headers:, params: {}
}.to enqueue_job(EmailCsvJob).with(user, nil, { "years" => %w[2023] }, false, nil, true, "sales", 2023)
expect {
post "/sales-logs/email-csv?codes_only=false", headers:, params: {}
}.to enqueue_job(EmailCsvJob).with(user, nil, {}, false, nil, false, "sales")
post "/sales-logs/email-csv?years[]=2023&codes_only=false", headers:, params: {}
}.to enqueue_job(EmailCsvJob).with(user, nil, { "years" => %w[2023] }, false, nil, false, "sales", 2023)
end
it "passes a combination of search term, export type and filter parameters" do
postcode = "XX1 1TG"
expect {
post "/sales-logs/email-csv?status[]=completed&search=#{postcode}&codes_only=false", headers:, params: {}
}.to enqueue_job(EmailCsvJob).with(user, postcode, { "status" => %w[completed] }, false, nil, false, "sales")
post "/sales-logs/email-csv?years[]=2023&status[]=completed&search=#{postcode}&codes_only=false", headers:, params: {}
}.to enqueue_job(EmailCsvJob).with(user, postcode, { "status" => %w[completed], "years" => %w[2023] }, false, nil, false, "sales", 2023)
end
context "when the user is not a support user" do
@ -1094,13 +1144,13 @@ RSpec.describe SalesLogsController, type: :request do
it "has permission to download human readable csv" do
codes_only_export = false
expect {
post "/sales-logs/email-csv?codes_only=#{codes_only_export}", headers:, params: {}
}.to enqueue_job(EmailCsvJob).with(user, nil, {}, false, nil, false, "sales")
post "/sales-logs/email-csv?years[]=2023&codes_only=#{codes_only_export}", headers:, params: {}
}.to enqueue_job(EmailCsvJob).with(user, nil, { "years" => %w[2023] }, false, nil, false, "sales", 2023)
end
it "is not authorized to download codes only csv" do
codes_only_export = true
post "/sales-logs/email-csv?codes_only=#{codes_only_export}", headers:, params: {}
post "/sales-logs/email-csv?years[]=2023&codes_only=#{codes_only_export}", headers:, params: {}
expect(response).to have_http_status(:unauthorized)
end
end

85
spec/services/csv/lettings_log_csv_service_spec.rb

@ -50,19 +50,13 @@ RSpec.describe Csv::LettingsLogCsvService do
)
end
let(:user) { create(:user, :support, email: "s.port@jeemayle.com") }
let(:service) { described_class.new(user:, export_type:) }
let(:service) { described_class.new(user:, export_type:, year:) }
let(:export_type) { "labels" }
let(:year) { 2024 }
let(:csv) { CSV.parse(service.prepare_csv(LettingsLog.where(id: logs.map(&:id)))) }
let(:logs) { [log] }
let(:headers) { csv.first }
it "calls the form handler to get all questions in order when initialized" do
allow(FormHandler).to receive(:instance).and_return(form_handler_mock)
allow(form_handler_mock).to receive(:ordered_lettings_questions_for_all_years).and_return([])
service
expect(form_handler_mock).to have_received(:ordered_lettings_questions_for_all_years)
end
it "returns a string" do
result = service.prepare_csv(LettingsLog.all)
expect(result).to be_a String
@ -72,21 +66,28 @@ RSpec.describe Csv::LettingsLogCsvService do
expect(csv.first.first).to eq "id"
end
context "when stubbing :ordered_lettings_questions_for_all_years" do
context "when stubbing :ordered_questions_for_year" do
let(:lettings_form) do
FormFactory.new(year: 2050, type: "lettings")
.with_sections([build(:section, :with_questions, question_ids:, questions:)])
.build
end
let(:question_ids) { nil }
let(:question_ids) { [] }
let(:questions) { nil }
let(:year) { 2050 }
before do
allow(FormHandler).to receive(:instance).and_return(form_handler_mock)
allow(form_handler_mock).to receive(:form_name_from_start_year)
allow(form_handler_mock).to receive(:get_form).and_return(lettings_form)
allow(form_handler_mock).to receive(:ordered_lettings_questions_for_all_years).and_return(lettings_form.questions)
allow(form_handler_mock).to receive(:lettings_in_crossover_period?).and_return false
allow(form_handler_mock).to receive(:ordered_questions_for_year).and_return(lettings_form.questions)
end
it "calls the form handler to get all questions for the specified year" do
allow(FormHandler).to receive(:instance).and_return(form_handler_mock)
allow(form_handler_mock).to receive(:ordered_questions_for_year).and_return([])
service.prepare_csv(LettingsLog.all)
expect(form_handler_mock).to have_received(:ordered_questions_for_year).with(2050, "lettings")
end
context "when it returns questions with particular ids" do
@ -124,11 +125,11 @@ RSpec.describe Csv::LettingsLogCsvService do
end
it "adds log attributes not related to questions to the headers" do
expect(headers.first(5)).to eq %w[id status duplicate_set_id assigned_to is_dpo]
expect(headers.first(5)).to eq %w[id status duplicate_set_id created_by assigned_to]
end
it "adds attributes related to associated schemes and locations to the headers" do
expect(headers).to include(*%w[scheme_service_name scheme_sensitive SCHTYPE scheme_registered_under_care_act])
expect(headers).to include(*%w[scheme_service_name scheme_confidential SCHTYPE scheme_registered_under_care_act])
expect(headers.last(5)).to eq %w[location_units location_type_of_unit location_mobility_type location_local_authority location_startdate]
end
@ -169,42 +170,28 @@ RSpec.describe Csv::LettingsLogCsvService do
expect(la_label_value).to eq "Barnet"
end
context "when the current form is 2024" do
context "when the requested form is 2024" do
let(:year) { 2024 }
let(:now) { Time.zone.local(2024, 4, 1) }
let(:fixed_time) { Time.zone.local(2024, 4, 1) }
context "and the log is for 2024 collection period" do
let(:fixed_time) { Time.zone.local(2024, 4, 1) }
before do
log.update!(national: nil)
log.update!(nationality_all: 36)
end
it "exports the CSV with 2024 ordering and all values correct" do
expected_content = CSV.read("spec/fixtures/files/lettings_log_csv_export_labels_24.csv")
values_to_delete = %w[id vacdays]
values_to_delete.each do |attribute|
index = csv.first.index(attribute)
csv.second[index] = nil
end
expect(csv).to eq expected_content
end
before do
log.update!(nationality_all: 36)
end
context "and the log is for 2023 collection period" do
it "exports the CSV with 2024 ordering and all values correct" do
expected_content = CSV.read("spec/fixtures/files/lettings_log_csv_export_labels_23_during_24_period.csv")
values_to_delete = %w[id vacdays]
values_to_delete.each do |attribute|
index = csv.first.index(attribute)
csv.second[index] = nil
end
expect(csv).to eq expected_content
it "exports the CSV with 2024 ordering and all values correct" do
expected_content = CSV.read("spec/fixtures/files/lettings_log_csv_export_labels_24.csv")
values_to_delete = %w[id vacdays]
values_to_delete.each do |attribute|
index = csv.first.index(attribute)
csv.second[index] = nil
end
expect(csv).to eq expected_content
end
end
context "when the current form is 2023" do
context "when the requested form is 2023" do
let(:year) { 2023 }
let(:now) { Time.zone.local(2023, 11, 26) }
it "exports the CSV with 2023 ordering and all values correct" do
@ -258,7 +245,8 @@ RSpec.describe Csv::LettingsLogCsvService do
expect(la_label_value).to eq "Barnet"
end
context "when the current form is 2024" do
context "when the requested form is 2024" do
let(:year) { 2024 }
let(:now) { Time.zone.local(2024, 4, 1) }
it "exports the CSV with all values correct" do
@ -272,7 +260,8 @@ RSpec.describe Csv::LettingsLogCsvService do
end
end
context "when the current form is 2023" do
context "when the requested form is 2023" do
let(:year) { 2023 }
let(:now) { Time.zone.local(2023, 11, 26) }
it "exports the CSV with all values correct" do
@ -306,8 +295,10 @@ RSpec.describe Csv::LettingsLogCsvService do
expect(headers).not_to include(*%w[wrent wscharge wpschrge wsupchrg wtcharge])
end
context "and the current form is 2024" do
context "and the requested form is 2024" do
let(:year) { 2024 }
let(:now) { Time.zone.local(2024, 4, 1) }
let(:fixed_time) { Time.zone.local(2024, 4, 1) }
context "and exporting with labels" do
let(:export_type) { "labels" }
@ -338,8 +329,10 @@ RSpec.describe Csv::LettingsLogCsvService do
end
end
context "and the current form is 2023" do
context "and the requested form is 2023" do
let(:year) { 2023 }
let(:now) { Time.zone.local(2023, 11, 26) }
let(:fixed_time) { Time.zone.local(2023, 11, 26) }
context "and exporting with labels" do
let(:export_type) { "labels" }

161
spec/services/csv/sales_log_csv_service_spec.rb

@ -32,8 +32,9 @@ RSpec.describe Csv::SalesLogCsvService do
la_as_entered: "la as entered",
)
end
let(:service) { described_class.new(user:, export_type: "labels") }
let(:service) { described_class.new(user:, export_type: "labels", year:) }
let(:csv) { CSV.parse(service.prepare_csv(SalesLog.all)) }
let(:year) { 2024 }
before do
Timecop.freeze(now)
@ -45,36 +46,37 @@ RSpec.describe Csv::SalesLogCsvService do
Timecop.return
end
it "calls the form handler to get all questions in order when initialized" do
allow(FormHandler).to receive(:instance).and_return(form_handler_mock)
allow(form_handler_mock).to receive(:ordered_sales_questions_for_all_years).and_return([])
service
expect(form_handler_mock).to have_received(:ordered_sales_questions_for_all_years)
end
it "returns a string" do
result = service.prepare_csv(SalesLog.all)
expect(result).to be_a String
end
it "returns a csv with headers" do
expect(csv.first.first).to eq "id"
expect(csv.first.first).to eq "ID"
end
context "when stubbing :ordered_sales_questions_for_all_years" do
context "when stubbing :ordered_questions_for_year" do
let(:sales_form) do
FormFactory.new(year: 1936, type: "sales")
.with_sections([build(:section, :with_questions, question_ids:, questions:)])
.build
end
let(:question_ids) { nil }
let(:question_ids) { [] }
let(:questions) { nil }
let(:year) { 1936 }
before do
allow(FormHandler).to receive(:instance).and_return(form_handler_mock)
allow(form_handler_mock).to receive(:form_name_from_start_year)
allow(form_handler_mock).to receive(:get_form).and_return(sales_form)
allow(form_handler_mock).to receive(:ordered_sales_questions_for_all_years).and_return(sales_form.questions)
allow(form_handler_mock).to receive(:ordered_questions_for_year).and_return(sales_form.questions)
end
it "calls the form handler to get all questions in order when initialized" do
allow(FormHandler).to receive(:instance).and_return(form_handler_mock)
allow(form_handler_mock).to receive(:ordered_questions_for_year).and_return([])
service
expect(form_handler_mock).to have_received(:ordered_questions_for_year).with(1936, "sales")
end
context "when it returns questions with particular ids" do
@ -82,13 +84,13 @@ RSpec.describe Csv::SalesLogCsvService do
it "includes log attributes related to questions to the headers" do
headers = csv.first
expect(headers).to include(*question_ids.first(3))
expect(headers).to include(*%w[TYPE AGE1 LIVEINBUYER1])
end
it "removes some log attributes related to questions from the headers and replaces them with their derived values in the correct order" do
headers = csv.first
expect(headers).not_to include "exdate"
expect(headers.last(4)).to eq %w[buy1livein exday exmonth exyear]
expect(headers).not_to include "EXDATE"
expect(headers.last(4)).to eq %w[LIVEINBUYER1 EXDAY EXMONTH EXYEAR]
end
end
@ -113,14 +115,14 @@ RSpec.describe Csv::SalesLogCsvService do
it "does not add the id of checkbox questions, but adds the related attributes of the log in the correct order" do
headers = csv.first
expect(headers.last(4)).to eq %w[ownershipsch pregyrha pregother type]
expect(headers.last(4)).to eq %w[OWNERSHIP PREGYRHA PREGOTHER TYPE]
end
end
end
it "includes attributes not related to questions to the headers" do
headers = csv.first
expect(headers).to include(*%w[id status created_at updated_at old_form_id])
expect(headers).to include(*%w[ID STATUS CREATEDDATE UPLOADDATE])
end
it "returns a csv with the correct number of logs" do
@ -131,81 +133,69 @@ RSpec.describe Csv::SalesLogCsvService do
end
context "when exporting with human readable labels" do
let(:year) { 2023 }
it "gives answers to radio questions as their labels" do
national_column_index = csv.first.index("national")
national_column_index = csv.first.index("NATIONAL")
national_value = csv.second[national_column_index]
expect(national_value).to eq "United Kingdom"
relat2_column_index = csv.first.index("relat2")
relat2_column_index = csv.first.index("RELAT2")
relat2_value = csv.second[relat2_column_index]
expect(relat2_value).to eq "Partner"
end
it "gives answers to free input questions as the user input" do
age1_column_index = csv.first.index("age1")
age1_column_index = csv.first.index("AGE1")
age1_value = csv.second[age1_column_index]
expect(age1_value).to eq 30.to_s
postcode_part1, postcode_part2 = log.postcode_full.split
postcode_part1_column_index = csv.first.index("pcode1")
postcode_part1_column_index = csv.first.index("PCODE1")
postcode_part1_value = csv.second[postcode_part1_column_index]
expect(postcode_part1_value).to eq postcode_part1
postcode_part2_column_index = csv.first.index("pcode2")
postcode_part2_column_index = csv.first.index("PCODE2")
postcode_part2_value = csv.second[postcode_part2_column_index]
expect(postcode_part2_value).to eq postcode_part2
end
it "exports the code for the local authority under the heading 'la'" do
la_column_index = csv.first.index("la")
la_column_index = csv.first.index("LA")
la_value = csv.second[la_column_index]
expect(la_value).to eq "E09000003"
end
it "exports the label for the local authority under the heading 'la_label'" do
la_label_column_index = csv.first.index("la_label")
la_label_column_index = csv.first.index("LANAME")
la_label_value = csv.second[la_label_column_index]
expect(la_label_value).to eq "Barnet"
end
context "when the current form is 2024" do
context "when the requested form is 2024" do
let(:now) { Time.zone.local(2024, 5, 1) }
let(:year) { 2024 }
let(:fixed_time) { Time.zone.local(2024, 5, 1) }
context "and the log is for 2024 collection period" do
let(:fixed_time) { Time.zone.local(2024, 5, 1) }
before do
log.update!(national: nil)
log.update!(nationality_all: 36)
end
it "exports the CSV with the 2024 ordering and all values correct" do
expected_content = CSV.read("spec/fixtures/files/sales_logs_csv_export_labels_24.csv")
values_to_delete = %w[id]
values_to_delete.each do |attribute|
index = csv.first.index(attribute)
csv.second[index] = nil
end
expect(csv).to eq expected_content
end
before do
log.update!(nationality_all: 36)
end
context "and the log is for 2023 collection period" do
it "exports the CSV with the 2024 ordering and all values correct" do
expected_content = CSV.read("spec/fixtures/files/sales_logs_csv_export_labels_23_during_24_period.csv")
values_to_delete = %w[id]
values_to_delete.each do |attribute|
index = csv.first.index(attribute)
csv.second[index] = nil
end
expect(csv).to eq expected_content
it "exports the CSV with the 2024 ordering and all values correct" do
expected_content = CSV.read("spec/fixtures/files/sales_logs_csv_export_labels_24.csv")
values_to_delete = %w[ID]
values_to_delete.each do |attribute|
index = csv.first.index(attribute)
csv.second[index] = nil
end
expect(csv).to eq expected_content
end
end
context "when the current form is 2023" do
context "when the requested form is 2023" do
let(:now) { Time.zone.local(2024, 1, 1) }
let(:year) { 2023 }
it "exports the CSV with the 2023 ordering and all values correct" do
expected_content = CSV.read("spec/fixtures/files/sales_logs_csv_export_labels_23.csv")
values_to_delete = %w[id]
values_to_delete = %w[ID]
values_to_delete.each do |attribute|
index = csv.first.index(attribute)
csv.second[index] = nil
@ -220,7 +210,7 @@ RSpec.describe Csv::SalesLogCsvService do
end
it "exports the id for under the heading 'duplicate_set_id'" do
duplicate_set_id_column_index = csv.first.index("duplicate_set_id")
duplicate_set_id_column_index = csv.first.index("DUPLICATESET")
duplicate_set_id_value = csv.second[duplicate_set_id_column_index]
expect(duplicate_set_id_value).to eq "12312"
end
@ -228,48 +218,51 @@ RSpec.describe Csv::SalesLogCsvService do
end
context "when exporting values as codes" do
let(:service) { described_class.new(user:, export_type: "codes") }
let(:service) { described_class.new(user:, export_type: "codes", year:) }
let(:year) { 2023 }
it "gives answers to radio questions as their codes" do
national_column_index = csv.first.index("national")
national_column_index = csv.first.index("NATIONAL")
national_value = csv.second[national_column_index]
expect(national_value).to eq 18.to_s
relat2_column_index = csv.first.index("relat2")
relat2_column_index = csv.first.index("RELAT2")
relat2_value = csv.second[relat2_column_index]
expect(relat2_value).to eq "P"
end
it "gives answers to free input questions as the user input" do
age1_column_index = csv.first.index("age1")
age1_column_index = csv.first.index("AGE1")
age1_value = csv.second[age1_column_index]
expect(age1_value).to eq 30.to_s
postcode_part1, postcode_part2 = log.postcode_full.split
postcode_part1_column_index = csv.first.index("pcode1")
postcode_part1_column_index = csv.first.index("PCODE1")
postcode_part1_value = csv.second[postcode_part1_column_index]
expect(postcode_part1_value).to eq postcode_part1
postcode_part2_column_index = csv.first.index("pcode2")
postcode_part2_column_index = csv.first.index("PCODE2")
postcode_part2_value = csv.second[postcode_part2_column_index]
expect(postcode_part2_value).to eq postcode_part2
end
it "exports the code for the local authority under the heading 'la'" do
la_column_index = csv.first.index("la")
la_column_index = csv.first.index("LA")
la_value = csv.second[la_column_index]
expect(la_value).to eq "E09000003"
end
it "exports the label for the local authority under the heading 'la_label'" do
la_label_column_index = csv.first.index("la_label")
la_label_column_index = csv.first.index("LANAME")
la_label_value = csv.second[la_label_column_index]
expect(la_label_value).to eq "Barnet"
end
context "when the current form is 2024" do
context "when the requested form is 2024" do
let(:now) { Time.zone.local(2024, 5, 1) }
let(:fixed_time) { Time.zone.local(2024, 5, 1) }
let(:year) { 2024 }
it "exports the CSV with all values correct" do
expected_content = CSV.read("spec/fixtures/files/sales_logs_csv_export_codes_24.csv")
values_to_delete = %w[id]
values_to_delete = %w[ID]
values_to_delete.each do |attribute|
index = csv.first.index(attribute)
csv.second[index] = nil
@ -278,12 +271,13 @@ RSpec.describe Csv::SalesLogCsvService do
end
end
context "when the current form is 2023" do
context "when the requested form is 2023" do
let(:now) { Time.zone.local(2024, 1, 1) }
let(:year) { 2023 }
it "exports the CSV with all values correct" do
expected_content = CSV.read("spec/fixtures/files/sales_logs_csv_export_codes_23.csv")
values_to_delete = %w[id]
values_to_delete = %w[ID]
values_to_delete.each do |attribute|
index = csv.first.index(attribute)
csv.second[index] = nil
@ -298,10 +292,43 @@ RSpec.describe Csv::SalesLogCsvService do
end
it "exports the id for under the heading 'duplicate_set_id'" do
duplicate_set_id_column_index = csv.first.index("duplicate_set_id")
duplicate_set_id_column_index = csv.first.index("DUPLICATESET")
duplicate_set_id_value = csv.second[duplicate_set_id_column_index]
expect(duplicate_set_id_value).to eq "12312"
end
end
end
context "when the user is not a support user" do
let(:user) { create(:user, email: "billyboy@eyeklaud.com") }
let(:headers) { csv.first }
it "does not include certain attributes in the headers" do
expect(headers).not_to include(*%w[address_line1_as_entered address_line2_as_entered town_or_city_as_entered county_as_entered postcode_full_as_entered la_as_entered created_by value_value_check monthly_charges_value_check])
end
context "and the requested form is 2024" do
let(:year) { 2024 }
let(:now) { Time.zone.local(2024, 5, 1) }
let(:fixed_time) { Time.zone.local(2024, 5, 1) }
before do
log.update!(nationality_all: 36)
end
context "and exporting with labels" do
let(:export_type) { "labels" }
it "exports the CSV with all values correct" do
expected_content = CSV.read("spec/fixtures/files/sales_logs_csv_export_non_support_labels_24.csv")
values_to_delete = %w[id]
values_to_delete.each do |attribute|
index = csv.first.index(attribute)
csv.second[index] = nil
end
expect(csv).to eq expected_content
end
end
end
end
end

4
spec/services/csv/scheme_csv_service_spec.rb

@ -36,7 +36,7 @@ RSpec.describe Csv::SchemeCsvService do
context "when download type is schemes" do
let(:download_type) { "schemes" }
let(:scheme_attributes) { %w[scheme_code scheme_service_name scheme_status scheme_sensitive scheme_type scheme_registered_under_care_act scheme_owning_organisation_name scheme_support_services_provided_by scheme_primary_client_group scheme_has_other_client_group scheme_secondary_client_group scheme_support_type scheme_intended_stay scheme_created_at scheme_active_dates] }
let(:scheme_attributes) { %w[scheme_code scheme_service_name scheme_status scheme_confidential scheme_type scheme_registered_under_care_act scheme_owning_organisation_name scheme_support_services_provided_by scheme_primary_client_group scheme_has_other_client_group scheme_secondary_client_group scheme_support_type scheme_intended_stay scheme_created_at scheme_active_dates] }
it "has the correct headers" do
expect(headers).to eq(scheme_attributes)
@ -107,7 +107,7 @@ RSpec.describe Csv::SchemeCsvService do
end
context "when download type is combined" do
let(:combined_attributes) { %w[scheme_code scheme_service_name scheme_status scheme_sensitive scheme_type scheme_registered_under_care_act scheme_owning_organisation_name scheme_support_services_provided_by scheme_primary_client_group scheme_has_other_client_group scheme_secondary_client_group scheme_support_type scheme_intended_stay scheme_created_at scheme_active_dates location_code location_postcode location_name location_status location_local_authority location_units location_type_of_unit location_mobility_type location_active_dates] }
let(:combined_attributes) { %w[scheme_code scheme_service_name scheme_status scheme_confidential scheme_type scheme_registered_under_care_act scheme_owning_organisation_name scheme_support_services_provided_by scheme_primary_client_group scheme_has_other_client_group scheme_secondary_client_group scheme_support_type scheme_intended_stay scheme_created_at scheme_active_dates location_code location_postcode location_name location_status location_local_authority location_units location_type_of_unit location_mobility_type location_active_dates] }
before do
scheme

Loading…
Cancel
Save