|
|
|
@ -272,10 +272,7 @@ module Csv |
|
|
|
|
|
|
|
|
|
|
|
YES_OR_BLANK_ATTRIBUTES = %w[declaration rp_homeless rp_insan_unsat rp_medwel rp_hardship rp_dontknow].freeze |
|
|
|
YES_OR_BLANK_ATTRIBUTES = %w[declaration rp_homeless rp_insan_unsat rp_medwel rp_hardship rp_dontknow].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 |
|
|
|
ATTRIBUTE_MAPPINGS = { |
|
|
|
|
|
|
|
|
|
|
|
def attribute_mappings |
|
|
|
|
|
|
|
mappings = { |
|
|
|
|
|
|
|
"owning_organisation_id" => %w[owning_organisation_name], |
|
|
|
"owning_organisation_id" => %w[owning_organisation_name], |
|
|
|
"managing_organisation_id" => %w[managing_organisation_name], |
|
|
|
"managing_organisation_id" => %w[managing_organisation_name], |
|
|
|
"assigned_to_id" => [], |
|
|
|
"assigned_to_id" => [], |
|
|
|
@ -302,13 +299,9 @@ module Csv |
|
|
|
"chcharge" => %w[chcharge wchchrg], |
|
|
|
"chcharge" => %w[chcharge wchchrg], |
|
|
|
"tshortfall" => %w[tshortfall wtshortfall], |
|
|
|
"tshortfall" => %w[tshortfall wtshortfall], |
|
|
|
"letting_allocation_unknown" => %w[letting_allocation_none], |
|
|
|
"letting_allocation_unknown" => %w[letting_allocation_none], |
|
|
|
} |
|
|
|
}.freeze |
|
|
|
|
|
|
|
|
|
|
|
if @user.support? && @year >= 2024 |
|
|
|
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 |
|
|
|
mappings["declaration"] = %w[declaration] + ORDERED_ADDRESS_FIELDS |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
mappings |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SUPPORT_ONLY_ATTRIBUTES = %w[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 old_form_id old_id tshortfall_known hhtype new_old 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 |
|
|
|
SUPPORT_ONLY_ATTRIBUTES = %w[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 old_form_id old_id tshortfall_known hhtype new_old 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 |
|
|
|
|
|
|
|
|
|
|
|
@ -319,14 +312,20 @@ module Csv |
|
|
|
def lettings_log_attributes |
|
|
|
def lettings_log_attributes |
|
|
|
ordered_questions = FormHandler.instance.ordered_questions_for_year(@year, "lettings") |
|
|
|
ordered_questions = FormHandler.instance.ordered_questions_for_year(@year, "lettings") |
|
|
|
ordered_questions.reject! { |q| q.id.match?(/age\d_known|nationality_all_group/) } |
|
|
|
ordered_questions.reject! { |q| q.id.match?(/age\d_known|nationality_all_group/) } |
|
|
|
ordered_questions.reject! { |q| all_address_fields.include?(q.id) } if @user.support? && @year >= 2024 |
|
|
|
|
|
|
|
attributes = ordered_questions.flat_map do |question| |
|
|
|
attributes = ordered_questions.flat_map do |question| |
|
|
|
if question.type == "checkbox" |
|
|
|
if question.type == "checkbox" |
|
|
|
question.answer_options.keys.reject { |key| key == "divider" }.map { |key| |
|
|
|
question.answer_options.keys.reject { |key| key == "divider" }.map { |key| |
|
|
|
attribute_mappings.fetch(key, key) |
|
|
|
ATTRIBUTE_MAPPINGS.fetch(key, key) |
|
|
|
}.flatten |
|
|
|
}.flatten |
|
|
|
else |
|
|
|
else |
|
|
|
attribute_mappings.fetch(question.id, question.id) |
|
|
|
ATTRIBUTE_MAPPINGS.fetch(question.id, question.id) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
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 |
|
|
|
end |
|
|
|
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] |
|
|
|
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] |
|
|
|
|