From f8f06249386e252cd2ec013edd54eb80986917ef Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Tue, 27 Sep 2022 12:56:25 +0100 Subject: [PATCH] Cldc 1430 csv export (#888) * Remove an unused ethnic_other column * remove sale_completion_date from lettings logs * Add collection start year * Remove sale_or_letting column * Rename rent_type to rent_type_detail in the export * Format dates * refactor * Fix test --- app/models/bulk_upload.rb | 1 - app/models/lettings_log.rb | 4 +++ app/models/validations/date_validations.rb | 4 --- app/services/csv/lettings_log_csv_service.rb | 32 +++++++++++++------ .../20220921111618_remove_ethnic_other.rb | 5 +++ ...20921112332_remove_sale_completion_date.rb | 5 +++ .../20220921124819_remove_sale_or_letting.rb | 5 +++ db/schema.rb | 3 -- docs/api/v1.json | 1 - spec/factories/lettings_log.rb | 1 - spec/fixtures/complete_lettings_log.json | 3 -- .../fixtures/files/lettings_logs_download.csv | 4 +-- .../lettings_logs_download_non_support.csv | 4 +-- spec/jobs/email_csv_job_spec.rb | 2 +- spec/models/lettings_log_spec.rb | 2 +- .../csv/lettings_log_csv_service_spec.rb | 6 ++-- 16 files changed, 49 insertions(+), 33 deletions(-) create mode 100644 db/migrate/20220921111618_remove_ethnic_other.rb create mode 100644 db/migrate/20220921112332_remove_sale_completion_date.rb create mode 100644 db/migrate/20220921124819_remove_sale_or_letting.rb diff --git a/app/models/bulk_upload.rb b/app/models/bulk_upload.rb index edafadbfa..183dc274e 100644 --- a/app/models/bulk_upload.rb +++ b/app/models/bulk_upload.rb @@ -184,7 +184,6 @@ class BulkUpload rent_type: row[130], irproduct_other: row[131], # data_protection: row[132], - sale_or_letting: "letting", declaration: 1, } end diff --git a/app/models/lettings_log.rb b/app/models/lettings_log.rb index c85f2d0c3..f97568f59 100644 --- a/app/models/lettings_log.rb +++ b/app/models/lettings_log.rb @@ -501,6 +501,10 @@ class LettingsLog < Log true end + def rent_type_detail + form.get_question("rent_type", self)&.label_from_value(rent_type) + end + private PIO = PostcodeService.new diff --git a/app/models/validations/date_validations.rb b/app/models/validations/date_validations.rb index f5361e5d7..18267ffdb 100644 --- a/app/models/validations/date_validations.rb +++ b/app/models/validations/date_validations.rb @@ -53,10 +53,6 @@ module Validations::DateValidations end end - def validate_sale_completion_date(record) - date_valid?("sale_completion_date", record) - end - private def first_collection_start_date diff --git a/app/services/csv/lettings_log_csv_service.rb b/app/services/csv/lettings_log_csv_service.rb index 79e333770..66a98a20f 100644 --- a/app/services/csv/lettings_log_csv_service.rb +++ b/app/services/csv/lettings_log_csv_service.rb @@ -1,6 +1,6 @@ module Csv class LettingsLogCsvService - CSV_FIELDS_TO_OMIT = %w[hhmemb net_income_value_check sale_or_letting first_time_property_let_as_social_housing renttype needstype postcode_known is_la_inferred totchild totelder totadult net_income_known is_carehome previous_la_known is_previous_la_inferred age1_known age2_known age3_known age4_known age5_known age6_known age7_known age8_known letting_allocation_unknown details_known_2 details_known_3 details_known_4 details_known_5 details_known_6 details_known_7 details_known_8 rent_type 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 vacdays la prevloc].freeze + CSV_FIELDS_TO_OMIT = %w[hhmemb net_income_value_check first_time_property_let_as_social_housing renttype needstype postcode_known is_la_inferred totchild totelder totadult net_income_known is_carehome previous_la_known is_previous_la_inferred age1_known age2_known age3_known age4_known age5_known age6_known age7_known age8_known letting_allocation_unknown details_known_2 details_known_3 details_known_4 details_known_5 details_known_6 details_known_7 details_known_8 rent_type_detail 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 vacdays la prevloc].freeze def initialize(user) @user = user @@ -13,13 +13,7 @@ module Csv LettingsLog.all.find_each do |record| csv << @attributes.map do |att| - if %w[la prevloc].include? att - label_from_value(record.send(att)) - elsif %w[la_label prevloc_label].include? att - record.form.get_question(att.remove("_label"), record)&.label_from_value(record.send(att.remove("_label"))) || label_from_value(record.send(att.remove("_label"))) - else - record.form.get_question(att, record)&.label_from_value(record.send(att)) || label_from_value(record.send(att)) - end + label_from_value(record, att) end end end @@ -27,7 +21,17 @@ module Csv private - def label_from_value(value) + def label_from_value(record, att) + if %w[la prevloc].include? att + label_from_boolean_value(record.send(att)) + elsif %w[mrcdate startdate voiddate].include? att + record.send(att)&.to_formatted_s(:govuk_date) + else + record.form.get_question(att.remove("_label"), record)&.label_from_value(record.send(att.remove("_label"))) || label_from_boolean_value(record.send(att.remove("_label"))) + end + end + + def label_from_boolean_value(value) return "Yes" if value == true return "No" if value == false @@ -35,7 +39,7 @@ module Csv end def set_csv_attributes - metadata_fields = %w[id status created_at updated_at created_by_name is_dpo owning_organisation_name managing_organisation_name] + metadata_fields = %w[id status created_at updated_at created_by_name is_dpo owning_organisation_name managing_organisation_name collection_start_year] metadata_id_fields = %w[managing_organisation_id owning_organisation_id created_by_id] scheme_and_location_ids = %w[scheme_id location_id] scheme_attributes = %w[scheme_code scheme_service_name scheme_sensitive scheme_type scheme_registered_under_care_act scheme_owning_organisation_name scheme_managing_organisation_name scheme_primary_client_group scheme_has_other_client_group scheme_secondary_client_group scheme_support_type scheme_intended_stay scheme_created_at] @@ -45,6 +49,7 @@ module Csv @attributes = (metadata_fields + intersecting_attributes + remaining_attributes - metadata_id_fields + %w[unittype_sh] + scheme_attributes + location_attributes).uniq move_la_fields + rename_attributes @attributes -= CSV_FIELDS_TO_OMIT if @user.present? && !@user.support? end @@ -81,5 +86,12 @@ module Csv end end end + + def rename_attributes + { "rent_type" => "rent_type_detail" }.each do |original_field, new_field| + @attributes.insert(@attributes.find_index(original_field), new_field) + @attributes.delete(original_field) + end + end end end diff --git a/db/migrate/20220921111618_remove_ethnic_other.rb b/db/migrate/20220921111618_remove_ethnic_other.rb new file mode 100644 index 000000000..b0140cade --- /dev/null +++ b/db/migrate/20220921111618_remove_ethnic_other.rb @@ -0,0 +1,5 @@ +class RemoveEthnicOther < ActiveRecord::Migration[7.0] + def change + remove_column :lettings_logs, :ethnic_other, :string + end +end diff --git a/db/migrate/20220921112332_remove_sale_completion_date.rb b/db/migrate/20220921112332_remove_sale_completion_date.rb new file mode 100644 index 000000000..5b344584b --- /dev/null +++ b/db/migrate/20220921112332_remove_sale_completion_date.rb @@ -0,0 +1,5 @@ +class RemoveSaleCompletionDate < ActiveRecord::Migration[7.0] + def change + remove_column :lettings_logs, :sale_completion_date, :datetime + end +end diff --git a/db/migrate/20220921124819_remove_sale_or_letting.rb b/db/migrate/20220921124819_remove_sale_or_letting.rb new file mode 100644 index 000000000..2e5853df3 --- /dev/null +++ b/db/migrate/20220921124819_remove_sale_or_letting.rb @@ -0,0 +1,5 @@ +class RemoveSaleOrLetting < ActiveRecord::Migration[7.0] + def change + remove_column :lettings_logs, :sale_or_letting, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 91b2935a7..53346ce42 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -135,7 +135,6 @@ ActiveRecord::Schema[7.0].define(version: 2022_09_27_105552) do t.integer "net_income_value_check" t.string "property_owner_organisation" t.string "property_manager_organisation" - t.string "sale_or_letting" t.string "irproduct_other" t.string "purchaser_code" t.integer "reason" @@ -148,7 +147,6 @@ ActiveRecord::Schema[7.0].define(version: 2022_09_27_105552) do t.integer "property_relet" t.datetime "mrcdate", precision: nil t.integer "incref" - t.datetime "sale_completion_date", precision: nil t.datetime "startdate", precision: nil t.integer "armedforces" t.integer "first_time_property_let_as_social_housing" @@ -190,7 +188,6 @@ ActiveRecord::Schema[7.0].define(version: 2022_09_27_105552) do t.integer "age7_known" t.integer "age8_known" t.integer "ethnic_group" - t.string "ethnic_other" t.integer "letting_allocation_unknown" t.integer "details_known_2" t.integer "details_known_3" diff --git a/docs/api/v1.json b/docs/api/v1.json index 06b0fcd4e..49ff3534f 100644 --- a/docs/api/v1.json +++ b/docs/api/v1.json @@ -392,7 +392,6 @@ "rent_type": 0, "intermediate_rent_product_name": "", "needstype": 1, - "sale_completion_date": "01/01/2020", "purchaser_code": "", "propcode": "123", "postcode": "a1", diff --git a/spec/factories/lettings_log.rb b/spec/factories/lettings_log.rb index ef519914d..48b964b84 100644 --- a/spec/factories/lettings_log.rb +++ b/spec/factories/lettings_log.rb @@ -134,7 +134,6 @@ FactoryBot.define do property_relet { 0 } mrcdate { Time.utc(2020, 5, 0o5, 10, 36, 49) } incref { 0 } - sale_completion_date { nil } startdate { Time.utc(2022, 2, 2, 10, 36, 49) } armedforces { 1 } builtype { 1 } diff --git a/spec/fixtures/complete_lettings_log.json b/spec/fixtures/complete_lettings_log.json index e5c334b79..805e65a3d 100644 --- a/spec/fixtures/complete_lettings_log.json +++ b/spec/fixtures/complete_lettings_log.json @@ -79,7 +79,6 @@ "net_income_value_check":null, "property_owner_organisation":null, "property_manager_organisation":null, - "sale_or_letting":null, "irproduct_other":"", "purchaser_code":null, "reason":42, @@ -92,7 +91,6 @@ "property_relet":null, "mrcdate":"2021-05-07T00:00:00.000+01:00", "incref":null, - "sale_completion_date":null, "startdate":"2021-06-06T00:00:00.000+01:00", "armedforces":2, "first_time_property_let_as_social_housing":0, @@ -134,7 +132,6 @@ "age7_known":null, "age8_known":null, "ethnic_group":0, - "ethnic_other":null, "letting_allocation_unknown":0, "details_known_2":0, "details_known_3":0, diff --git a/spec/fixtures/files/lettings_logs_download.csv b/spec/fixtures/files/lettings_logs_download.csv index 783482dd2..f16b5f8ad 100644 --- a/spec/fixtures/files/lettings_logs_download.csv +++ b/spec/fixtures/files/lettings_logs_download.csv @@ -1,2 +1,2 @@ -id,status,created_at,updated_at,created_by_name,is_dpo,owning_organisation_name,managing_organisation_name,needstype,renewal,startdate,rent_type,irproduct_other,tenancycode,propcode,age1,sex1,ecstat1,hhmemb,relat2,age2,sex2,retirement_value_check,ecstat2,armedforces,leftreg,illness,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_h,is_previous_la_inferred,prevloc_label,prevloc,illness_type_1,illness_type_2,is_la_inferred,la_label,la,postcode_known,postcode_full,previous_la_known,wchair,preg_occ,cbl,earnings,incfreq,net_income_value_check,benefits,hb,period,brent,scharge,pscharge,supcharg,tcharge,offered,layear,ppostcode_full,mrcdate,declaration,ethnic,national,prevten,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,reservist,startertenancy,tenancylength,tenancy,rsnvac,unittype_gn,beds,waityear,reasonpref,chr,cap,reasonother,housingneeds_f,housingneeds_g,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,property_owner_organisation,property_manager_organisation,sale_or_letting,purchaser_code,reason,majorrepairs,hbrentshortfall,property_relet,incref,sale_completion_date,first_time_property_let_as_social_housing,unitletas,builtype,voiddate,renttype,lettype,totchild,totelder,totadult,net_income_known,nocharge,is_carehome,household_charge,referral,tshortfall,chcharge,ppcodenk,age1_known,age2_known,age3_known,age4_known,age5_known,age6_known,age7_known,age8_known,ethnic_group,ethnic_other,letting_allocation_unknown,details_known_2,details_known_3,details_known_4,details_known_5,details_known_6,details_known_7,details_known_8,has_benefits,wrent,wscharge,wpschrge,wsupchrg,wtcharge,wtshortfall,refused,housingneeds,wchchrg,newprop,relat3,relat4,relat5,relat6,relat7,relat8,rent_value_check,old_form_id,lar,irproduct,old_id,joint,illness_type_0,tshortfall_known,sheltered,pregnancy_value_check,hhtype,new_old,vacdays,major_repairs_date_value_check,void_date_value_check,housingneeds_type,housingneeds_other,unittype_sh,scheme_code,scheme_service_name,scheme_sensitive,scheme_type,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_managing_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_admin_district,location_startdate -{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,Danny Rojas,No,DLUHC,DLUHC,Supported housing,,,,,,,,,,,,,,,,,,,,,,,No,,,,,No,Westminster,E09000033,,SE1 1TE,,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0,0,,0,,,,,,,,,,,,,,,,,,,,,,,,,0,,,,,,,0,,,,,,,,,,,,,,,,,,,,9,,,,,,,6,{scheme_code},{scheme_service_name},{scheme_sensitive},Missing,No,DLUHC,DLUHC,{scheme_primary_client_group},,{scheme_secondary_client_group},{scheme_support_type},{scheme_intended_stay},2022-06-05 01:00:00 +0100,{location_code},SE1 1TE,Downing Street,20,Bungalow,Fitted with equipment and adaptations,Westminster,{location_startdate} +id,status,created_at,updated_at,created_by_name,is_dpo,owning_organisation_name,managing_organisation_name,collection_start_year,needstype,renewal,startdate,rent_type_detail,irproduct_other,tenancycode,propcode,age1,sex1,ecstat1,hhmemb,relat2,age2,sex2,retirement_value_check,ecstat2,armedforces,leftreg,illness,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_h,is_previous_la_inferred,prevloc_label,prevloc,illness_type_1,illness_type_2,is_la_inferred,la_label,la,postcode_known,postcode_full,previous_la_known,wchair,preg_occ,cbl,earnings,incfreq,net_income_value_check,benefits,hb,period,brent,scharge,pscharge,supcharg,tcharge,offered,layear,ppostcode_full,mrcdate,declaration,ethnic,national,prevten,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,reservist,startertenancy,tenancylength,tenancy,rsnvac,unittype_gn,beds,waityear,reasonpref,chr,cap,reasonother,housingneeds_f,housingneeds_g,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,property_owner_organisation,property_manager_organisation,purchaser_code,reason,majorrepairs,hbrentshortfall,property_relet,incref,first_time_property_let_as_social_housing,unitletas,builtype,voiddate,renttype,lettype,totchild,totelder,totadult,net_income_known,nocharge,is_carehome,household_charge,referral,tshortfall,chcharge,ppcodenk,age1_known,age2_known,age3_known,age4_known,age5_known,age6_known,age7_known,age8_known,ethnic_group,letting_allocation_unknown,details_known_2,details_known_3,details_known_4,details_known_5,details_known_6,details_known_7,details_known_8,has_benefits,wrent,wscharge,wpschrge,wsupchrg,wtcharge,wtshortfall,refused,housingneeds,wchchrg,newprop,relat3,relat4,relat5,relat6,relat7,relat8,rent_value_check,old_form_id,lar,irproduct,old_id,joint,illness_type_0,tshortfall_known,sheltered,pregnancy_value_check,hhtype,new_old,vacdays,major_repairs_date_value_check,void_date_value_check,housingneeds_type,housingneeds_other,unittype_sh,scheme_code,scheme_service_name,scheme_sensitive,scheme_type,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_managing_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_admin_district,location_startdate +{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,Danny Rojas,No,DLUHC,DLUHC,2021,Supported housing,,2 October 2021,London Affordable Rent,,,,,,,,,,,,,,,,,,,,No,,,,,No,Westminster,E09000033,,SE1 1TE,,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,2,8,0,0,0,,0,,,,,,,,,,,,,,,,,,,,,,,,0,,,,,,,0,,,,,,,,,,,,,,,,,,,,9,1,,,,,,6,{scheme_code},{scheme_service_name},{scheme_sensitive},Missing,No,DLUHC,DLUHC,{scheme_primary_client_group},,{scheme_secondary_client_group},{scheme_support_type},{scheme_intended_stay},2022-06-05 01:00:00 +0100,{location_code},SE1 1TE,Downing Street,20,Bungalow,Fitted with equipment and adaptations,Westminster,{location_startdate} diff --git a/spec/fixtures/files/lettings_logs_download_non_support.csv b/spec/fixtures/files/lettings_logs_download_non_support.csv index a4815fb53..ae0beeee0 100644 --- a/spec/fixtures/files/lettings_logs_download_non_support.csv +++ b/spec/fixtures/files/lettings_logs_download_non_support.csv @@ -1,2 +1,2 @@ -id,status,created_at,updated_at,created_by_name,is_dpo,owning_organisation_name,managing_organisation_name,renewal,startdate,irproduct_other,tenancycode,propcode,age1,sex1,ecstat1,relat2,age2,sex2,ecstat2,armedforces,leftreg,illness,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_h,prevloc_label,illness_type_1,illness_type_2,la_label,postcode_full,wchair,preg_occ,cbl,earnings,incfreq,benefits,hb,period,brent,scharge,pscharge,supcharg,tcharge,offered,layear,ppostcode_full,mrcdate,declaration,ethnic,national,prevten,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,reservist,startertenancy,tenancylength,tenancy,rsnvac,unittype_gn,beds,waityear,reasonpref,chr,cap,reasonother,housingneeds_f,housingneeds_g,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,property_owner_organisation,property_manager_organisation,purchaser_code,reason,majorrepairs,hbrentshortfall,property_relet,incref,sale_completion_date,unitletas,builtype,voiddate,lettype,nocharge,household_charge,referral,tshortfall,chcharge,ppcodenk,ethnic_group,ethnic_other,has_benefits,refused,housingneeds,wchchrg,newprop,relat3,relat4,relat5,relat6,relat7,relat8,lar,irproduct,joint,illness_type_0,sheltered,major_repairs_date_value_check,void_date_value_check,housingneeds_type,housingneeds_other,unittype_sh,scheme_code,scheme_service_name,scheme_sensitive,scheme_type,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_managing_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_admin_district,location_startdate -{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,Danny Rojas,No,DLUHC,DLUHC,,,,,,,,,,,,,,,,,,,,,,,Westminster,SE1 1TE,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,,,,,,,,0,0,,,,,,,,,,,,,,,,,,,6,{scheme_code},{scheme_service_name},{scheme_sensitive},Missing,No,DLUHC,DLUHC,{scheme_primary_client_group},,{scheme_secondary_client_group},{scheme_support_type},{scheme_intended_stay},2022-06-05 01:00:00 +0100,{location_code},SE1 1TE,Downing Street,20,Bungalow,Fitted with equipment and adaptations,Westminster,{location_startdate} +id,status,created_at,updated_at,created_by_name,is_dpo,owning_organisation_name,managing_organisation_name,collection_start_year,renewal,startdate,irproduct_other,tenancycode,propcode,age1,sex1,ecstat1,relat2,age2,sex2,ecstat2,armedforces,leftreg,illness,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_h,prevloc_label,illness_type_1,illness_type_2,la_label,postcode_full,wchair,preg_occ,cbl,earnings,incfreq,benefits,hb,period,brent,scharge,pscharge,supcharg,tcharge,offered,layear,ppostcode_full,mrcdate,declaration,ethnic,national,prevten,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,reservist,startertenancy,tenancylength,tenancy,rsnvac,unittype_gn,beds,waityear,reasonpref,chr,cap,reasonother,housingneeds_f,housingneeds_g,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,property_owner_organisation,property_manager_organisation,purchaser_code,reason,majorrepairs,hbrentshortfall,property_relet,incref,unitletas,builtype,voiddate,lettype,nocharge,household_charge,referral,tshortfall,chcharge,ppcodenk,ethnic_group,has_benefits,refused,housingneeds,wchchrg,newprop,relat3,relat4,relat5,relat6,relat7,relat8,lar,irproduct,joint,illness_type_0,sheltered,major_repairs_date_value_check,void_date_value_check,housingneeds_type,housingneeds_other,unittype_sh,scheme_code,scheme_service_name,scheme_sensitive,scheme_type,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_managing_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_admin_district,location_startdate +{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,Danny Rojas,No,DLUHC,DLUHC,2021,,2 October 2021,,,,,,,,,,,,,,,,,,,,,Westminster,SE1 1TE,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,8,0,,,,,,,0,0,,,,,,,,,,,,,,,,,,,6,{scheme_code},{scheme_service_name},{scheme_sensitive},Missing,No,DLUHC,DLUHC,{scheme_primary_client_group},,{scheme_secondary_client_group},{scheme_support_type},{scheme_intended_stay},2022-06-05 01:00:00 +0100,{location_code},SE1 1TE,Downing Street,20,Bungalow,Fitted with equipment and adaptations,Westminster,{location_startdate} diff --git a/spec/jobs/email_csv_job_spec.rb b/spec/jobs/email_csv_job_spec.rb index 1e3860af9..aa27c421b 100644 --- a/spec/jobs/email_csv_job_spec.rb +++ b/spec/jobs/email_csv_job_spec.rb @@ -106,7 +106,7 @@ describe EmailCsvJob do it "writes answer labels rather than values" do expect_csv do |csv| - expect(csv.second[15]).to eq("Full-time – 30 hours or more") + expect(csv.second[16]).to eq("Full-time – 30 hours or more") end job.perform(user) diff --git a/spec/models/lettings_log_spec.rb b/spec/models/lettings_log_spec.rb index aeaff6b2a..6251e050f 100644 --- a/spec/models/lettings_log_spec.rb +++ b/spec/models/lettings_log_spec.rb @@ -2378,7 +2378,7 @@ RSpec.describe LettingsLog do before do Timecop.freeze(Time.utc(2022, 6, 5)) - lettings_log = FactoryBot.create(:lettings_log, needstype: 2, scheme:, location:, owning_organisation: scheme.owning_organisation, created_by: user) + lettings_log = FactoryBot.create(:lettings_log, needstype: 2, scheme:, location:, owning_organisation: scheme.owning_organisation, created_by: user, rent_type: 2, startdate: Time.zone.local(2021, 10, 2)) expected_content.sub!(/\{id\}/, lettings_log["id"].to_s) expected_content.sub!(/\{scheme_code\}/, "S#{scheme['id']}") expected_content.sub!(/\{scheme_service_name\}/, scheme["service_name"].to_s) diff --git a/spec/services/csv/lettings_log_csv_service_spec.rb b/spec/services/csv/lettings_log_csv_service_spec.rb index 36b2f857a..bc5195d84 100644 --- a/spec/services/csv/lettings_log_csv_service_spec.rb +++ b/spec/services/csv/lettings_log_csv_service_spec.rb @@ -19,10 +19,11 @@ RSpec.describe Csv::LettingsLogCsvService do is_dpo owning_organisation_name managing_organisation_name + collection_start_year needstype renewal startdate - rent_type + rent_type_detail irproduct_other tenancycode propcode @@ -172,18 +173,15 @@ RSpec.describe Csv::LettingsLogCsvService do housingneeds_h property_owner_organisation property_manager_organisation - sale_or_letting purchaser_code property_relet incref - sale_completion_date renttype lettype totchild totelder totadult nocharge - ethnic_other has_benefits wrent wscharge