diff --git a/app/models/derived_variables/sales_log_variables.rb b/app/models/derived_variables/sales_log_variables.rb index f662ab3df..ec8d21b30 100644 --- a/app/models/derived_variables/sales_log_variables.rb +++ b/app/models/derived_variables/sales_log_variables.rb @@ -17,6 +17,15 @@ module DerivedVariables::SalesLogVariables self.hoyear = hodate.year end self.deposit = value if outright_sale? && mortgage_not_used? + + if saledate && form.start_year_after_2024? && discounted_ownership_sale? + self.ppostcode_full = postcode_full + self.ppcodenk = 0 if postcode_full.present? + self.prevloc = la + self.is_previous_la_inferred = is_la_inferred + self.previous_la_known = la_known + end + self.pcode1, self.pcode2 = postcode_full.split if postcode_full.present? self.ppostc1, self.ppostc2 = ppostcode_full.split if ppostcode_full.present? self.totchild = total_child diff --git a/app/models/form/lettings/questions/declaration.rb b/app/models/form/lettings/questions/declaration.rb index 03fc72f4a..4805a9f1e 100644 --- a/app/models/form/lettings/questions/declaration.rb +++ b/app/models/form/lettings/questions/declaration.rb @@ -6,10 +6,17 @@ class Form::Lettings::Questions::Declaration < ::Form::Question @header = "Declaration" @type = "checkbox" @check_answers_card_number = 0 - @top_guidance_partial = "privacy_notice_tenant" - @answer_options = ANSWER_OPTIONS + @top_guidance_partial = form.start_year_after_2024? ? "privacy_notice_tenant_2024" : "privacy_notice_tenant" @question_number = 30 end - ANSWER_OPTIONS = { "declaration" => { "value" => "The tenant has seen the DLUHC privacy notice" } }.freeze + def answer_options + declaration_text = if form.start_year_after_2024? + "The tenant has seen or been given access to the DLUHC privacy notice" + else + "The tenant has seen the DLUHC privacy notice" + end + + { "declaration" => { "value" => declaration_text } }.freeze + end end diff --git a/app/models/form/lettings/subsections/household_characteristics.rb b/app/models/form/lettings/subsections/household_characteristics.rb index bb8533c12..1e442cb18 100644 --- a/app/models/form/lettings/subsections/household_characteristics.rb +++ b/app/models/form/lettings/subsections/household_characteristics.rb @@ -8,7 +8,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection def pages @pages ||= [ - Form::Lettings::Pages::Declaration.new(nil, nil, self), + (Form::Lettings::Pages::Declaration.new(nil, nil, self) unless form.start_year_after_2024?), Form::Lettings::Pages::HouseholdMembers.new(nil, nil, self), Form::Lettings::Pages::NoFemalesPregnantHouseholdLeadHhmembValueCheck.new(nil, nil, self), Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdLeadHhmembValueCheck.new(nil, nil, self), diff --git a/app/models/form/lettings/subsections/setup.rb b/app/models/form/lettings/subsections/setup.rb index 3b833927d..85af7d2c4 100644 --- a/app/models/form/lettings/subsections/setup.rb +++ b/app/models/form/lettings/subsections/setup.rb @@ -19,6 +19,7 @@ class Form::Lettings::Subsections::Setup < ::Form::Subsection Form::Lettings::Pages::RentType.new(nil, nil, self), Form::Lettings::Pages::TenantCode.new(nil, nil, self), Form::Lettings::Pages::PropertyReference.new(nil, nil, self), + (Form::Lettings::Pages::Declaration.new(nil, nil, self) if form.start_year_after_2024?), ].compact end diff --git a/app/models/form/sales/pages/last_accommodation.rb b/app/models/form/sales/pages/last_accommodation.rb index 373a20511..2d3448399 100644 --- a/app/models/form/sales/pages/last_accommodation.rb +++ b/app/models/form/sales/pages/last_accommodation.rb @@ -10,4 +10,10 @@ class Form::Sales::Pages::LastAccommodation < ::Form::Page Form::Sales::Questions::PreviousPostcode.new(nil, nil, self), ] end + + def routed_to?(log, _user) + return false if log.form.start_year_after_2024? && log.discounted_ownership_sale? + + super + end end diff --git a/app/models/form/sales/pages/last_accommodation_la.rb b/app/models/form/sales/pages/last_accommodation_la.rb index 6e4211e12..615a30196 100644 --- a/app/models/form/sales/pages/last_accommodation_la.rb +++ b/app/models/form/sales/pages/last_accommodation_la.rb @@ -13,4 +13,10 @@ class Form::Sales::Pages::LastAccommodationLa < ::Form::Page Form::Sales::Questions::Prevloc.new(nil, nil, self), ] end + + def routed_to?(log, _user) + return false if log.form.start_year_after_2024? && log.discounted_ownership_sale? + + super + end end diff --git a/app/models/form/sales/questions/privacy_notice.rb b/app/models/form/sales/questions/privacy_notice.rb index d440e414b..62eab5d8f 100644 --- a/app/models/form/sales/questions/privacy_notice.rb +++ b/app/models/form/sales/questions/privacy_notice.rb @@ -5,12 +5,17 @@ class Form::Sales::Questions::PrivacyNotice < ::Form::Question @check_answer_label = "Buyer has seen the privacy notice?" @header = "Declaration" @type = "checkbox" - @answer_options = ANSWER_OPTIONS - @top_guidance_partial = "privacy_notice_buyer" + @top_guidance_partial = form.start_year_after_2024? ? "privacy_notice_buyer_2024" : "privacy_notice_buyer" @question_number = 19 end - ANSWER_OPTIONS = { - "privacynotice" => { "value" => "The buyer has seen the DLUHC privacy notice" }, - }.freeze + def answer_options + declaration_text = if form.start_year_after_2024? + "The buyer has seen or been given access to the DLUHC privacy notice" + else + "The buyer has seen the DLUHC privacy notice" + end + + { "privacynotice" => { "value" => declaration_text } }.freeze + end end diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb index 187f7f34e..ac006b453 100644 --- a/app/models/form/sales/subsections/household_characteristics.rb +++ b/app/models/form/sales/subsections/household_characteristics.rb @@ -9,7 +9,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection def pages @pages ||= [ (Form::Sales::Pages::BuyerInterview.new(nil, nil, self) unless form.start_year_after_2024?), - Form::Sales::Pages::PrivacyNotice.new(nil, nil, self), + (Form::Sales::Pages::PrivacyNotice.new(nil, nil, self) unless form.start_year_after_2024?), Form::Sales::Pages::Age1.new(nil, nil, self), Form::Sales::Pages::RetirementValueCheck.new("age_1_retirement_value_check", nil, self, person_index: 1), Form::Sales::Pages::OldPersonsSharedOwnershipValueCheck.new("age_1_old_persons_shared_ownership_value_check", nil, self), diff --git a/app/models/form/sales/subsections/setup.rb b/app/models/form/sales/subsections/setup.rb index aef107585..49e9392bb 100644 --- a/app/models/form/sales/subsections/setup.rb +++ b/app/models/form/sales/subsections/setup.rb @@ -21,6 +21,7 @@ class Form::Sales::Subsections::Setup < ::Form::Subsection Form::Sales::Pages::JointPurchase.new(nil, nil, self), Form::Sales::Pages::NumberJointBuyers.new(nil, nil, self), (Form::Sales::Pages::BuyerInterview.new(nil, nil, self) if form.start_year_after_2024?), + (Form::Sales::Pages::PrivacyNotice.new(nil, nil, self) if form.start_year_after_2024?), ].flatten.compact end end diff --git a/app/models/form_handler.rb b/app/models/form_handler.rb index 267fa2968..32968fa53 100644 --- a/app/models/form_handler.rb +++ b/app/models/form_handler.rb @@ -50,11 +50,10 @@ class FormHandler end def ordered_sales_questions_for_all_years - sales_forms = forms.filter { |name, _form| name.end_with? "sales" }.values - ordered_questions = sales_forms.pop.questions.uniq(&:id) - question_ids = ordered_questions.map(&:id) - all_questions_from_previous_forms = sales_forms.flat_map(&:questions) - deprecated_questions_by_preceding_question_id(question_ids, all_questions_from_previous_forms).each do |preceding_question_id, deprecated_question| + 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 @@ -62,23 +61,28 @@ class FormHandler end def ordered_lettings_questions_for_all_years - lettings_forms = forms.filter { |name, _form| name.end_with? "lettings" }.values - ordered_questions = lettings_forms.pop.questions.uniq(&:id) - question_ids = ordered_questions.map(&:id) - all_questions_from_previous_forms = lettings_forms.flat_map(&:questions) - deprecated_questions_by_preceding_question_id(question_ids, all_questions_from_previous_forms).each do |preceding_question_id, deprecated_question| + 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 end - def deprecated_questions_by_preceding_question_id(current_form_question_ids, all_questions_from_previous_forms) + def deprecated_questions_by_preceding_question_id(current_form_questions, all_questions_from_previous_forms) + current_form_question_ids = current_form_questions.map(&:id) deprecated_questions = {} all_questions_from_previous_forms.each_cons(2) do |preceding_question, question| next if current_form_question_ids.include?(question.id) || deprecated_questions.values.map(&:id).include?(question.id) - deprecated_questions[preceding_question.id] = question + if question.subsection.id == preceding_question.subsection.id + deprecated_questions[preceding_question.id] = question + else + last_in_preceding_subsection = current_form_questions.rindex { |q| q.subsection.id == preceding_question.subsection.id } + deprecated_questions[current_form_questions[last_in_preceding_subsection].id] = question + end end deprecated_questions end diff --git a/app/models/validations/sales/household_validations.rb b/app/models/validations/sales/household_validations.rb index 6e10b89b5..c23a72609 100644 --- a/app/models/validations/sales/household_validations.rb +++ b/app/models/validations/sales/household_validations.rb @@ -11,15 +11,6 @@ module Validations::Sales::HouseholdValidations shared_validate_partner_count(record, 6) end - def validate_previous_postcode(record) - return unless record.postcode_full && record.ppostcode_full && record.discounted_ownership_sale? - - unless record.postcode_full == record.ppostcode_full - record.errors.add :postcode_full, :postcodes_not_matching, message: I18n.t("validations.household.postcode.discounted_ownership") - record.errors.add :ppostcode_full, :postcodes_not_matching, message: I18n.t("validations.household.postcode.discounted_ownership") - end - end - def validate_buyers_living_in_property(record) return unless record.form.start_date.year >= 2023 diff --git a/app/models/validations/sales/property_validations.rb b/app/models/validations/sales/property_validations.rb index 3a8f6a463..fc8e4759b 100644 --- a/app/models/validations/sales/property_validations.rb +++ b/app/models/validations/sales/property_validations.rb @@ -1,5 +1,6 @@ module Validations::Sales::PropertyValidations def validate_postcodes_match_if_discounted_ownership(record) + return unless record.saledate && !record.form.start_year_after_2024? return unless record.ppostcode_full.present? && record.postcode_full.present? if record.discounted_ownership_sale? && record.ppostcode_full != record.postcode_full diff --git a/app/services/bulk_upload/lettings/year2024/row_parser.rb b/app/services/bulk_upload/lettings/year2024/row_parser.rb index 5f05b6e10..28cfc1ca8 100644 --- a/app/services/bulk_upload/lettings/year2024/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2024/row_parser.rb @@ -377,8 +377,6 @@ class BulkUpload::Lettings::Year2024::RowParser validate :validate_created_by_exists, on: :after_log validate :validate_created_by_related, on: :after_log - validate :validate_declaration_acceptance, on: :after_log - validate :validate_nulls, on: :after_log validate :validate_uprn_exists_if_any_key_address_fields_are_blank, on: :after_log, unless: -> { supported_housing? } @@ -494,12 +492,6 @@ class BulkUpload::Lettings::Year2024::RowParser private - def validate_declaration_acceptance - unless field_15 == 1 - errors.add(:field_15, I18n.t("validations.declaration.missing"), category: :setup) - end - end - def validate_valid_radio_option log.attributes.each do |question_id, _v| question = log.form.get_question(question_id, log) diff --git a/app/services/bulk_upload/sales/year2024/row_parser.rb b/app/services/bulk_upload/sales/year2024/row_parser.rb index c7a5349d0..0e1ee650e 100644 --- a/app/services/bulk_upload/sales/year2024/row_parser.rb +++ b/app/services/bulk_upload/sales/year2024/row_parser.rb @@ -468,7 +468,6 @@ class BulkUpload::Sales::Year2024::RowParser validate :validate_address_fields, on: :after_log validate :validate_if_log_already_exists, on: :after_log, if: -> { FeatureToggle.bulk_upload_duplicate_log_check_enabled? } - validate :validate_data_protection_answered, on: :after_log validate :validate_buyers_organisations, on: :after_log def self.question_for_field(field) @@ -565,12 +564,6 @@ class BulkUpload::Sales::Year2024::RowParser private - def validate_data_protection_answered - unless field_18 == 1 - errors.add(:field_18, I18n.t("validations.not_answered", question: QUESTIONS[:field_18].downcase), category: :setup) - end - end - def validate_buyers_organisations organisations_fields = %i[field_66 field_67 field_68 field_69] if organisations_fields.all? { |field| attributes[field.to_s].blank? } diff --git a/app/services/exports/lettings_log_export_service.rb b/app/services/exports/lettings_log_export_service.rb index 404b9f0e6..e63219f7d 100644 --- a/app/services/exports/lettings_log_export_service.rb +++ b/app/services/exports/lettings_log_export_service.rb @@ -12,9 +12,9 @@ module Exports start_time = Time.zone.now daily_run_number = get_daily_run_number archives_for_manifest = {} - base_number = LogsExport.where(empty_export: false).maximum(:base_number) || 1 recent_export = LogsExport.order("started_at").last collection_years_to_export(collection_year).each do |collection| + base_number = LogsExport.where(empty_export: false, collection:).maximum(:base_number) || 1 export = build_export_run(collection, start_time, base_number, full_update) archives = write_export_archive(export, collection, start_time, recent_export, full_update) diff --git a/app/views/form/guidance/_privacy_notice_buyer_2024.erb b/app/views/form/guidance/_privacy_notice_buyer_2024.erb new file mode 100644 index 000000000..9977bf20b --- /dev/null +++ b/app/views/form/guidance/_privacy_notice_buyer_2024.erb @@ -0,0 +1 @@ +
Make sure the buyer has seen or been given access to <%= govuk_link_to "the Department for Levelling Up, Housing & Communities (DLUHC) privacy notice", privacy_notice_path, target: :_blank %> before completing this log. This is a legal requirement under data protection legislation.
diff --git a/app/views/form/guidance/_privacy_notice_tenant_2024.erb b/app/views/form/guidance/_privacy_notice_tenant_2024.erb new file mode 100644 index 000000000..3007c8904 --- /dev/null +++ b/app/views/form/guidance/_privacy_notice_tenant_2024.erb @@ -0,0 +1 @@ +Make sure the lead tenant has seen or been given access to <%= govuk_link_to "the Department for Levelling Up, Housing & Communities (DLUHC) privacy notice", privacy_notice_path, target: :_blank %> before completing this log. This is a legal requirement under data protection legislation.
diff --git a/spec/fixtures/files/lettings_log_csv_export_codes.csv b/spec/fixtures/files/lettings_log_csv_export_codes_23.csv similarity index 95% rename from spec/fixtures/files/lettings_log_csv_export_codes.csv rename to spec/fixtures/files/lettings_log_csv_export_codes_23.csv index c68b53ae2..873c703b0 100644 --- a/spec/fixtures/files/lettings_log_csv_export_codes.csv +++ b/spec/fixtures/files/lettings_log_csv_export_codes_23.csv @@ -1,2 +1,2 @@ -id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,old_id,old_form_id,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,postcode_known,uprn_known,uprn,uprn_confirmed,address_line1,address_line2,town_or_city,county,postcode_full,is_la_inferred,la_label,la,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,pregnancy_value_check,refused,hhtype,totchild,totelder,totadult,age1,retirement_value_check,sex1,ethnic_group,ethnic,national,nationality_all,ecstat1,details_known_2,relat2,age2,sex2,ecstat2,details_known_3,relat3,age3,sex3,ecstat3,details_known_4,relat4,age4,sex4,ecstat4,details_known_5,relat5,age5,sex5,ecstat5,details_known_6,relat6,age6,sex6,ecstat6,details_known_7,relat7,age7,sex7,ecstat7,details_known_8,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,new_old,homeless,ppcodenk,ppostcode_full,previous_la_known,is_previous_la_inferred,prevloc_label,prevloc,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,referral_value_check,net_income_known,incref,earnings,incfreq,net_income_value_check,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,wrent,rent_value_check,scharge,wscharge,pscharge,wpschrge,supcharg,wsupchrg,tcharge,wtcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall_known,tshortfall,wtshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate -,completed,,s.port@jeemayle.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,1,,,2023,DLUHC,DLUHC,1,7,0,2023-11-26,2,2,1,,2,HIJKLMN,ABCDEFG,1,0,,,fake address,,London,,NW9 5LL,false,Barnet,E09000003,0,2,6,2,2,7,1,1,3,2023-11-24,,,1,2023-11-25,,3,1,4,,2,,1,4,,1,4,0,0,2,35,,F,0,2,13,,0,0,P,32,M,6,1,R,-9,R,10,0,R,-9,R,10,,,,,,,,,,,,,,,,,,,,,1,4,1,2,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,2,7,4,,6,2,1,0,TN23 6LZ,1,false,Ashford,E07000105,1,0,1,0,0,0,0,0,1,,2,,0,0,268,1,,6,1,1,,0,2,,,,,200.0,100.0,,50.0,25.0,40.0,20.0,35.0,17.5,325.0,162.5,,,,1,0,12.0,6.0,,,,,,,,,,,,,,,,,,,, +id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,old_id,old_form_id,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,postcode_known,uprn_known,uprn,uprn_confirmed,address_line1,address_line2,town_or_city,county,postcode_full,is_la_inferred,la_label,la,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,pregnancy_value_check,refused,hhtype,totchild,totelder,totadult,age1,retirement_value_check,sex1,ethnic_group,ethnic,nationality_all,national,ecstat1,details_known_2,relat2,age2,sex2,ecstat2,details_known_3,relat3,age3,sex3,ecstat3,details_known_4,relat4,age4,sex4,ecstat4,details_known_5,relat5,age5,sex5,ecstat5,details_known_6,relat6,age6,sex6,ecstat6,details_known_7,relat7,age7,sex7,ecstat7,details_known_8,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,new_old,homeless,ppcodenk,ppostcode_full,previous_la_known,is_previous_la_inferred,prevloc_label,prevloc,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,referral_value_check,net_income_known,incref,earnings,incfreq,net_income_value_check,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,wrent,rent_value_check,scharge,wscharge,pscharge,wpschrge,supcharg,wsupchrg,tcharge,wtcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall_known,tshortfall,wtshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate +,completed,,s.port@jeemayle.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,1,,,2023,DLUHC,DLUHC,1,7,0,2023-11-26,2,2,1,,2,HIJKLMN,ABCDEFG,1,0,,,fake address,,London,,NW9 5LL,false,Barnet,E09000003,0,2,6,2,2,7,1,1,3,2023-11-24,,,1,2023-11-25,,3,1,4,,2,,1,4,,1,4,0,0,2,35,,F,0,2,,13,0,0,P,32,M,6,1,R,-9,R,10,0,R,-9,R,10,,,,,,,,,,,,,,,,,,,,,1,4,1,2,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,2,7,4,,6,2,1,0,TN23 6LZ,1,false,Ashford,E07000105,1,0,1,0,0,0,0,0,1,,2,,0,0,268,1,,6,1,1,,0,2,,,,,200.0,100.0,,50.0,25.0,40.0,20.0,35.0,17.5,325.0,162.5,,,,1,0,12.0,6.0,,,,,,,,,,,,,,,,,,,, diff --git a/spec/fixtures/files/lettings_log_csv_export_codes_24.csv b/spec/fixtures/files/lettings_log_csv_export_codes_24.csv new file mode 100644 index 000000000..82b91798f --- /dev/null +++ b/spec/fixtures/files/lettings_log_csv_export_codes_24.csv @@ -0,0 +1,2 @@ +id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,old_id,old_form_id,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,declaration,postcode_known,uprn_known,uprn,uprn_confirmed,address_line1,address_line2,town_or_city,county,postcode_full,is_la_inferred,la_label,la,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,hhmemb,pregnancy_value_check,refused,hhtype,totchild,totelder,totadult,age1,retirement_value_check,sex1,ethnic_group,ethnic,national,nationality_all,ecstat1,details_known_2,relat2,age2,sex2,ecstat2,details_known_3,relat3,age3,sex3,ecstat3,details_known_4,relat4,age4,sex4,ecstat4,details_known_5,relat5,age5,sex5,ecstat5,details_known_6,relat6,age6,sex6,ecstat6,details_known_7,relat7,age7,sex7,ecstat7,details_known_8,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,new_old,homeless,ppcodenk,ppostcode_full,previous_la_known,is_previous_la_inferred,prevloc_label,prevloc,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,referral_value_check,net_income_known,incref,earnings,incfreq,net_income_value_check,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,wrent,rent_value_check,scharge,wscharge,pscharge,wpschrge,supcharg,wsupchrg,tcharge,wtcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall_known,tshortfall,wtshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate +,completed,,s.port@jeemayle.com,false,2023-11-26T00:00:00+00:00,,2024-04-01T00:00:00+01:00,1,,,2023,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,,2,,0,0,268,1,,6,1,1,,0,2,,,,,200.0,100.0,,50.0,25.0,40.0,20.0,35.0,17.5,325.0,162.5,,,,1,0,12.0,6.0,,,,,,,,,,,,,,,,,,,, diff --git a/spec/fixtures/files/lettings_log_csv_export_labels.csv b/spec/fixtures/files/lettings_log_csv_export_labels_23.csv similarity index 96% rename from spec/fixtures/files/lettings_log_csv_export_labels.csv rename to spec/fixtures/files/lettings_log_csv_export_labels_23.csv index 8722ed90c..a9c491ed9 100644 --- a/spec/fixtures/files/lettings_log_csv_export_labels.csv +++ b/spec/fixtures/files/lettings_log_csv_export_labels_23.csv @@ -1,2 +1,2 @@ -id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,old_id,old_form_id,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,postcode_known,uprn_known,uprn,uprn_confirmed,address_line1,address_line2,town_or_city,county,postcode_full,is_la_inferred,la_label,la,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,pregnancy_value_check,refused,hhtype,totchild,totelder,totadult,age1,retirement_value_check,sex1,ethnic_group,ethnic,national,nationality_all,ecstat1,details_known_2,relat2,age2,sex2,ecstat2,details_known_3,relat3,age3,sex3,ecstat3,details_known_4,relat4,age4,sex4,ecstat4,details_known_5,relat5,age5,sex5,ecstat5,details_known_6,relat6,age6,sex6,ecstat6,details_known_7,relat7,age7,sex7,ecstat7,details_known_8,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,new_old,homeless,ppcodenk,ppostcode_full,previous_la_known,is_previous_la_inferred,prevloc_label,prevloc,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,referral_value_check,net_income_known,incref,earnings,incfreq,net_income_value_check,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,wrent,rent_value_check,scharge,wscharge,pscharge,wpschrge,supcharg,wsupchrg,tcharge,wtcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall_known,tshortfall,wtshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate -,completed,,s.port@jeemayle.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,single log,,,2023,DLUHC,DLUHC,General needs,Affordable rent general needs local authority,No,2023-11-26,Affordable Rent,Affordable Rent,Rent to Buy,,No,HIJKLMN,ABCDEFG,Yes,No,,,fake address,,London,,NW9 5LL,No,Barnet,E09000003,No,Affordable rent basis,Tenant abandoned property,No,2,House,Purpose built,Yes,3,2023-11-24,,,Yes,2023-11-25,,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,Yes,4,,Yes,4,0,0,2,35,,Female,White,Irish,Tenant prefers not to say,,Other,Yes,Partner,32,Male,Not seeking work,No,Prefers not to say,Not known,Prefers not to say,Prefers not to say,Yes,Person prefers not to say,Not known,Person prefers not to say,Person prefers not to say,,,,,,,,,,,,,,,,,,,,,Yes – the person is a current or former regular,No – they left up to and including 5 years ago,Yes,No,Yes,Fully wheelchair accessible housing,Yes,No,No,No,No,No,No,Yes,No,No,Yes,No,No,No,No,No,No,No,Less than 1 year,1 year but under 2 years,Loss of tied accommodation,,Other supported housing,2,No,Yes,TN23 6LZ,Yes,No,Ashford,E07000105,Yes,,Yes,,,,No,No,Yes,,Tenant applied directly (no referral or nomination),,Yes,No,268,Weekly,,Universal Credit housing element,Yes,All,,No,Every 2 weeks,,,,,200.0,100.0,,50.0,25.0,40.0,20.0,35.0,17.5,325.0,162.5,,,,Yes,Yes,12.0,6.0,,,,,,,,,,,,,,,,,,,, +id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,old_id,old_form_id,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,postcode_known,uprn_known,uprn,uprn_confirmed,address_line1,address_line2,town_or_city,county,postcode_full,is_la_inferred,la_label,la,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,pregnancy_value_check,refused,hhtype,totchild,totelder,totadult,age1,retirement_value_check,sex1,ethnic_group,ethnic,nationality_all,national,ecstat1,details_known_2,relat2,age2,sex2,ecstat2,details_known_3,relat3,age3,sex3,ecstat3,details_known_4,relat4,age4,sex4,ecstat4,details_known_5,relat5,age5,sex5,ecstat5,details_known_6,relat6,age6,sex6,ecstat6,details_known_7,relat7,age7,sex7,ecstat7,details_known_8,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,new_old,homeless,ppcodenk,ppostcode_full,previous_la_known,is_previous_la_inferred,prevloc_label,prevloc,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,referral_value_check,net_income_known,incref,earnings,incfreq,net_income_value_check,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,wrent,rent_value_check,scharge,wscharge,pscharge,wpschrge,supcharg,wsupchrg,tcharge,wtcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall_known,tshortfall,wtshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate +,completed,,s.port@jeemayle.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,single log,,,2023,DLUHC,DLUHC,General needs,Affordable rent general needs local authority,No,2023-11-26,Affordable Rent,Affordable Rent,Rent to Buy,,No,HIJKLMN,ABCDEFG,Yes,No,,,fake address,,London,,NW9 5LL,No,Barnet,E09000003,No,Affordable rent basis,Tenant abandoned property,No,2,House,Purpose built,Yes,3,2023-11-24,,,Yes,2023-11-25,,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,Yes,4,,Yes,4,0,0,2,35,,Female,White,Irish,,Tenant prefers not to say,Other,Yes,Partner,32,Male,Not seeking work,No,Prefers not to say,Not known,Prefers not to say,Prefers not to say,Yes,Person prefers not to say,Not known,Person prefers not to say,Person prefers not to say,,,,,,,,,,,,,,,,,,,,,Yes – the person is a current or former regular,No – they left up to and including 5 years ago,Yes,No,Yes,Fully wheelchair accessible housing,Yes,No,No,No,No,No,No,Yes,No,No,Yes,No,No,No,No,No,No,No,Less than 1 year,1 year but under 2 years,Loss of tied accommodation,,Other supported housing,2,No,Yes,TN23 6LZ,Yes,No,Ashford,E07000105,Yes,,Yes,,,,No,No,Yes,,Tenant applied directly (no referral or nomination),,Yes,No,268,Weekly,,Universal Credit housing element,Yes,All,,No,Every 2 weeks,,,,,200.0,100.0,,50.0,25.0,40.0,20.0,35.0,17.5,325.0,162.5,,,,Yes,Yes,12.0,6.0,,,,,,,,,,,,,,,,,,,, diff --git a/spec/fixtures/files/lettings_log_csv_export_labels_24.csv b/spec/fixtures/files/lettings_log_csv_export_labels_24.csv new file mode 100644 index 000000000..4ece610dd --- /dev/null +++ b/spec/fixtures/files/lettings_log_csv_export_labels_24.csv @@ -0,0 +1,2 @@ +id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,old_id,old_form_id,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,declaration,postcode_known,uprn_known,uprn,uprn_confirmed,address_line1,address_line2,town_or_city,county,postcode_full,is_la_inferred,la_label,la,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,hhmemb,pregnancy_value_check,refused,hhtype,totchild,totelder,totadult,age1,retirement_value_check,sex1,ethnic_group,ethnic,national,nationality_all,ecstat1,details_known_2,relat2,age2,sex2,ecstat2,details_known_3,relat3,age3,sex3,ecstat3,details_known_4,relat4,age4,sex4,ecstat4,details_known_5,relat5,age5,sex5,ecstat5,details_known_6,relat6,age6,sex6,ecstat6,details_known_7,relat7,age7,sex7,ecstat7,details_known_8,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,new_old,homeless,ppcodenk,ppostcode_full,previous_la_known,is_previous_la_inferred,prevloc_label,prevloc,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,referral_value_check,net_income_known,incref,earnings,incfreq,net_income_value_check,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,wrent,rent_value_check,scharge,wscharge,pscharge,wpschrge,supcharg,wsupchrg,tcharge,wtcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall_known,tshortfall,wtshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate +,completed,,s.port@jeemayle.com,false,2023-11-26T00:00:00+00:00,,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,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,,Tenant applied directly (no referral or nomination),,Yes,No,268,Weekly,,Universal Credit housing element,Yes,All,,No,Every 2 weeks,,,,,200.0,100.0,,50.0,25.0,40.0,20.0,35.0,17.5,325.0,162.5,,,,Yes,Yes,12.0,6.0,,,,,,,,,,,,,,,,,,,, diff --git a/spec/fixtures/files/lettings_log_csv_export_non_support_codes.csv b/spec/fixtures/files/lettings_log_csv_export_non_support_codes_23.csv similarity index 95% rename from spec/fixtures/files/lettings_log_csv_export_non_support_codes.csv rename to spec/fixtures/files/lettings_log_csv_export_non_support_codes_23.csv index 6989c0b9b..2cf49f785 100644 --- a/spec/fixtures/files/lettings_log_csv_export_non_support_codes.csv +++ b/spec/fixtures/files/lettings_log_csv_export_non_support_codes_23.csv @@ -1,2 +1,2 @@ -id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,uprn_known,uprn,address_line1,address_line2,town_or_city,county,postcode_full,la_label,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,refused,age1,sex1,ethnic_group,ethnic,national,nationality_all,ecstat1,relat2,age2,sex2,ecstat2,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,relat7,age7,sex7,ecstat7,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,homeless,ppcodenk,ppostcode_full,prevloc_label,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,referral_value_check,incref,earnings,incfreq,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,scharge,pscharge,supcharg,tcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate -,completed,,choreographer@owtluk.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,1,2023,DLUHC,DLUHC,1,7,0,2023-11-26,2,2,1,,2,HIJKLMN,ABCDEFG,0,,fake address,,London,,NW9 5LL,Barnet,2,6,2,2,7,1,1,3,2023-11-24,1,,1,2023-11-25,,3,1,4,,2,,1,4,1,35,F,0,2,13,,0,P,32,M,6,R,-9,R,10,R,-9,R,10,,,,,,,,,,,,,,,,,1,4,1,2,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,2,7,4,,6,1,0,TN23 6LZ,Ashford,1,0,1,0,0,0,0,0,1,,2,,0,268,1,6,1,1,,0,2,,,,,200.0,50.0,40.0,35.0,325.0,,,,1,12.0,,,,,,,,,,,,,,,,,,,, +id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,uprn_known,uprn,address_line1,address_line2,town_or_city,county,postcode_full,la_label,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,refused,age1,sex1,ethnic_group,ethnic,nationality_all,national,ecstat1,relat2,age2,sex2,ecstat2,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,relat7,age7,sex7,ecstat7,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,homeless,ppcodenk,ppostcode_full,prevloc_label,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,referral_value_check,incref,earnings,incfreq,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,scharge,pscharge,supcharg,tcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate +,completed,,choreographer@owtluk.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,1,2023,DLUHC,DLUHC,1,7,0,2023-11-26,2,2,1,,2,HIJKLMN,ABCDEFG,0,,fake address,,London,,NW9 5LL,Barnet,2,6,2,2,7,1,1,3,2023-11-24,1,,1,2023-11-25,,3,1,4,,2,,1,4,1,35,F,0,2,,13,0,P,32,M,6,R,-9,R,10,R,-9,R,10,,,,,,,,,,,,,,,,,1,4,1,2,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,2,7,4,,6,1,0,TN23 6LZ,Ashford,1,0,1,0,0,0,0,0,1,,2,,0,268,1,6,1,1,,0,2,,,,,200.0,50.0,40.0,35.0,325.0,,,,1,12.0,,,,,,,,,,,,,,,,,,,, diff --git a/spec/fixtures/files/lettings_log_csv_export_non_support_codes_24.csv b/spec/fixtures/files/lettings_log_csv_export_non_support_codes_24.csv new file mode 100644 index 000000000..c796f49d7 --- /dev/null +++ b/spec/fixtures/files/lettings_log_csv_export_non_support_codes_24.csv @@ -0,0 +1,2 @@ +id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,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,age2,sex2,ecstat2,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,relat7,age7,sex7,ecstat7,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,homeless,ppcodenk,ppostcode_full,prevloc_label,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,referral_value_check,incref,earnings,incfreq,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,scharge,pscharge,supcharg,tcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate +,completed,,choreographer@owtluk.com,false,2023-11-26T00:00:00+00:00,,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,,2,,0,268,1,6,1,1,,0,2,,,,,200.0,50.0,40.0,35.0,325.0,,,,1,12.0,,,,,,,,,,,,,,,,,,,, diff --git a/spec/fixtures/files/lettings_log_csv_export_non_support_labels.csv b/spec/fixtures/files/lettings_log_csv_export_non_support_labels_23.csv similarity index 96% rename from spec/fixtures/files/lettings_log_csv_export_non_support_labels.csv rename to spec/fixtures/files/lettings_log_csv_export_non_support_labels_23.csv index 33a852a21..2c2b63ee4 100644 --- a/spec/fixtures/files/lettings_log_csv_export_non_support_labels.csv +++ b/spec/fixtures/files/lettings_log_csv_export_non_support_labels_23.csv @@ -1,2 +1,2 @@ -id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,uprn_known,uprn,address_line1,address_line2,town_or_city,county,postcode_full,la_label,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,refused,age1,sex1,ethnic_group,ethnic,national,nationality_all,ecstat1,relat2,age2,sex2,ecstat2,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,relat7,age7,sex7,ecstat7,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,homeless,ppcodenk,ppostcode_full,prevloc_label,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,referral_value_check,incref,earnings,incfreq,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,scharge,pscharge,supcharg,tcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate -,completed,,choreographer@owtluk.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,single log,2023,DLUHC,DLUHC,General needs,Affordable rent general needs local authority,No,2023-11-26,Affordable Rent,Affordable Rent,Rent to Buy,,No,HIJKLMN,ABCDEFG,No,,fake address,,London,,NW9 5LL,Barnet,Affordable rent basis,Tenant abandoned property,No,2,House,Purpose built,Yes,3,2023-11-24,1,,Yes,2023-11-25,,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,Yes,4,Yes,35,Female,White,Irish,Tenant prefers not to say,,Other,Partner,32,Male,Not seeking work,Prefers not to say,Not known,Prefers not to say,Prefers not to say,Person prefers not to say,Not known,Person prefers not to say,Person prefers not to say,,,,,,,,,,,,,,,,,Yes – the person is a current or former regular,No – they left up to and including 5 years ago,Yes,No,Yes,Fully wheelchair accessible housing,Yes,No,No,No,No,No,No,Yes,No,No,Yes,No,No,No,No,No,No,No,Less than 1 year,1 year but under 2 years,Loss of tied accommodation,,Other supported housing,No,Yes,TN23 6LZ,Ashford,Yes,,Yes,,,,No,No,Yes,,Tenant applied directly (no referral or nomination),,No,268,Weekly,Universal Credit housing element,Yes,All,,No,Every 2 weeks,,,,,200.0,50.0,40.0,35.0,325.0,,,,Yes,12.0,,,,,,,,,,,,,,,,,,,, +id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,uprn_known,uprn,address_line1,address_line2,town_or_city,county,postcode_full,la_label,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,refused,age1,sex1,ethnic_group,ethnic,nationality_all,national,ecstat1,relat2,age2,sex2,ecstat2,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,relat7,age7,sex7,ecstat7,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,homeless,ppcodenk,ppostcode_full,prevloc_label,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,referral_value_check,incref,earnings,incfreq,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,scharge,pscharge,supcharg,tcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate +,completed,,choreographer@owtluk.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,single log,2023,DLUHC,DLUHC,General needs,Affordable rent general needs local authority,No,2023-11-26,Affordable Rent,Affordable Rent,Rent to Buy,,No,HIJKLMN,ABCDEFG,No,,fake address,,London,,NW9 5LL,Barnet,Affordable rent basis,Tenant abandoned property,No,2,House,Purpose built,Yes,3,2023-11-24,1,,Yes,2023-11-25,,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,Yes,4,Yes,35,Female,White,Irish,,Tenant prefers not to say,Other,Partner,32,Male,Not seeking work,Prefers not to say,Not known,Prefers not to say,Prefers not to say,Person prefers not to say,Not known,Person prefers not to say,Person prefers not to say,,,,,,,,,,,,,,,,,Yes – the person is a current or former regular,No – they left up to and including 5 years ago,Yes,No,Yes,Fully wheelchair accessible housing,Yes,No,No,No,No,No,No,Yes,No,No,Yes,No,No,No,No,No,No,No,Less than 1 year,1 year but under 2 years,Loss of tied accommodation,,Other supported housing,No,Yes,TN23 6LZ,Ashford,Yes,,Yes,,,,No,No,Yes,,Tenant applied directly (no referral or nomination),,No,268,Weekly,Universal Credit housing element,Yes,All,,No,Every 2 weeks,,,,,200.0,50.0,40.0,35.0,325.0,,,,Yes,12.0,,,,,,,,,,,,,,,,,,,, diff --git a/spec/fixtures/files/lettings_log_csv_export_non_support_labels_24.csv b/spec/fixtures/files/lettings_log_csv_export_non_support_labels_24.csv new file mode 100644 index 000000000..572e034cc --- /dev/null +++ b/spec/fixtures/files/lettings_log_csv_export_non_support_labels_24.csv @@ -0,0 +1,2 @@ +id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,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,age2,sex2,ecstat2,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,relat7,age7,sex7,ecstat7,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,homeless,ppcodenk,ppostcode_full,prevloc_label,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,referral_value_check,incref,earnings,incfreq,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,scharge,pscharge,supcharg,tcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate +,completed,,choreographer@owtluk.com,false,2023-11-26T00:00:00+00:00,,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,,Tenant applied directly (no referral or nomination),,No,268,Weekly,Universal Credit housing element,Yes,All,,No,Every 2 weeks,,,,,200.0,50.0,40.0,35.0,325.0,,,,Yes,12.0,,,,,,,,,,,,,,,,,,,, diff --git a/spec/fixtures/files/sales_logs_csv_export_codes_23.csv b/spec/fixtures/files/sales_logs_csv_export_codes_23.csv new file mode 100644 index 000000000..ae93dd76c --- /dev/null +++ b/spec/fixtures/files/sales_logs_csv_export_codes_23.csv @@ -0,0 +1,2 @@ +id,status,duplicate_set_id,created_at,updated_at,old_form_id,collection_start_year,creation_method,is_dpo,owning_organisation_name,managing_organisation_name,created_by,day,month,year,purchid,ownershipsch,type,othtype,companybuy,buylivein,jointpur,jointmore,beds,proptype,builtype,pcodenk,uprn,uprn_confirmed,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,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,9,X,-9,X,3,R,-9,R,10,,,,,1,1,,,0,,,1,1,1,1,,3,,1,4,5,1,1,0,10000,1,0,10000,1,4,1,,1,2,10,,,,,,,,,,,,,,,,,110000.0,,1,20000.0,5,,10,1,80000.0,,,1,100.0,,10000.0 diff --git a/spec/fixtures/files/sales_logs_csv_export_codes.csv b/spec/fixtures/files/sales_logs_csv_export_codes_24.csv similarity index 77% rename from spec/fixtures/files/sales_logs_csv_export_codes.csv rename to spec/fixtures/files/sales_logs_csv_export_codes_24.csv index ba344fed7..cdce0a509 100644 --- a/spec/fixtures/files/sales_logs_csv_export_codes.csv +++ b/spec/fixtures/files/sales_logs_csv_export_codes_24.csv @@ -1,2 +1,2 @@ -id,status,duplicate_set_id,created_at,updated_at,old_form_id,collection_start_year,creation_method,is_dpo,owning_organisation_name,managing_organisation_name,created_by,day,month,year,purchid,ownershipsch,type,othtype,companybuy,buylivein,jointpur,jointmore,noint,uprn,uprn_confirmed,address_line1,address_line2,town_or_city,county,pcode1,pcode2,la_known,la,la_label,beds,proptype,builtype,pcodenk,wchair,privacynotice,age1,sex1,ethnic_group,ethnic,national,nationality_all,ecstat1,buy1livein,relat2,age2,sex2,ethnic_group2,ethnicbuy2,nationalbuy2,nationality_all_buyer2,ecstat2,buy2livein,hholdcount,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,prevten,ppcodenk,ppostc1,ppostc2,previous_la_known,prevloc,prevloc_label,pregyrha,pregother,pregla,pregghb,pregblank,buy2living,prevtenbuy2,hhregres,hhregresstill,armedforcesspouse,disabled,wheel,income1nk,income1,inc1mort,income2nk,income2,inc2mort,hb,savingsnk,savings,prevown,prevshared,proplen,staircase,stairbought,stairowned,staircasesale,resale,exday,exmonth,exyear,hoday,homonth,hoyear,lanomagr,soctenant,frombeds,fromprop,socprevten,value,equity,mortgageused,mortgage,mortgagelender,mortgagelenderother,mortlen,extrabor,deposit,cashdis,mrent,has_mscharge,mscharge,discount,grant -,completed,,2023-12-08T00:00:00+00:00,2023-12-08T00:00:00+00:00,,2023,1,false,DLUHC,DLUHC,billyboy@eyeklaud.com,8,12,2023,,2,8,,,,1,1,2,,,Address line 1,,Town or city,,SW1A,1AA,1,E09000003,Barnet,2,1,1,0,1,1,30,X,17,17,18,,1,1,P,35,X,17,,13,,1,1,3,C,14,X,9,X,-9,X,3,R,-9,R,10,,,,,1,1,,,0,,,1,1,1,1,,3,,1,4,5,1,1,0,10000,1,0,10000,1,4,1,,1,2,10,,,,,,,,,,,,,,,,,110000.0,,1,20000.0,5,,10,1,80000.0,,,1,100.0,,10000.0 +id,status,duplicate_set_id,created_at,updated_at,old_form_id,collection_start_year,creation_method,is_dpo,owning_organisation_name,managing_organisation_name,created_by,day,month,year,purchid,ownershipsch,type,othtype,companybuy,buylivein,jointpur,jointmore,noint,privacynotice,uprn,uprn_confirmed,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,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,9,X,-9,X,3,R,-9,R,10,,,,,1,1,,,0,,,1,1,1,1,,3,,1,4,5,1,1,0,10000,1,0,10000,1,4,1,,1,2,10,,,,,,,,,,,,,,,,,110000.0,,1,20000.0,5,,10,1,80000.0,,,1,100.0,,10000.0 diff --git a/spec/fixtures/files/sales_logs_csv_export_labels_23.csv b/spec/fixtures/files/sales_logs_csv_export_labels_23.csv new file mode 100644 index 000000000..e0e986df2 --- /dev/null +++ b/spec/fixtures/files/sales_logs_csv_export_labels_23.csv @@ -0,0 +1,2 @@ +id,status,duplicate_set_id,created_at,updated_at,old_form_id,collection_start_year,creation_method,is_dpo,owning_organisation_name,managing_organisation_name,created_by,day,month,year,purchid,ownershipsch,type,othtype,companybuy,buylivein,jointpur,jointmore,beds,proptype,builtype,pcodenk,uprn,uprn_confirmed,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,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 1 prefers not to say,17,,United Kingdom,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,Buyer 2 prefers not to say,,,Buyer prefers not to say,Full-time - 30 hours or more,Yes,3,Child,14,Non-binary,Child under 16,Other,Not known,Non-binary,"In government training into work, such as New Deal",Prefers not to say,Not known,Prefers not to say,Prefers not to say,,,,,Local authority tenant,No,,,No,,,1,1,1,1,,Don't know,,Yes,Yes,No,Yes,Yes,Yes,10000,Yes,Yes,10000,Yes,"Don’t know ",No,,Yes,No,10,,,,,,,,,,,,,,,,,110000.0,,Yes,20000.0,Cambridge Building Society,,10,Yes,80000.0,,,Yes,100.0,,10000.0 diff --git a/spec/fixtures/files/sales_logs_csv_export_labels.csv b/spec/fixtures/files/sales_logs_csv_export_labels_24.csv similarity index 82% rename from spec/fixtures/files/sales_logs_csv_export_labels.csv rename to spec/fixtures/files/sales_logs_csv_export_labels_24.csv index 7ab05f910..2bd4670ec 100644 --- a/spec/fixtures/files/sales_logs_csv_export_labels.csv +++ b/spec/fixtures/files/sales_logs_csv_export_labels_24.csv @@ -1,2 +1,2 @@ -id,status,duplicate_set_id,created_at,updated_at,old_form_id,collection_start_year,creation_method,is_dpo,owning_organisation_name,managing_organisation_name,created_by,day,month,year,purchid,ownershipsch,type,othtype,companybuy,buylivein,jointpur,jointmore,noint,uprn,uprn_confirmed,address_line1,address_line2,town_or_city,county,pcode1,pcode2,la_known,la,la_label,beds,proptype,builtype,pcodenk,wchair,privacynotice,age1,sex1,ethnic_group,ethnic,national,nationality_all,ecstat1,buy1livein,relat2,age2,sex2,ethnic_group2,ethnicbuy2,nationalbuy2,nationality_all_buyer2,ecstat2,buy2livein,hholdcount,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,prevten,ppcodenk,ppostc1,ppostc2,previous_la_known,prevloc,prevloc_label,pregyrha,pregother,pregla,pregghb,pregblank,buy2living,prevtenbuy2,hhregres,hhregresstill,armedforcesspouse,disabled,wheel,income1nk,income1,inc1mort,income2nk,income2,inc2mort,hb,savingsnk,savings,prevown,prevshared,proplen,staircase,stairbought,stairowned,staircasesale,resale,exday,exmonth,exyear,hoday,homonth,hoyear,lanomagr,soctenant,frombeds,fromprop,socprevten,value,equity,mortgageused,mortgage,mortgagelender,mortgagelenderother,mortlen,extrabor,deposit,cashdis,mrent,has_mscharge,mscharge,discount,grant -,completed,,2023-12-08T00:00:00+00:00,2023-12-08T00:00:00+00:00,,2023,single log,false,DLUHC,DLUHC,billyboy@eyeklaud.com,8,12,2023,,Yes - a discounted ownership scheme,Right to Acquire (RTA),,,,Yes,Yes,Yes,,,Address line 1,,Town or city,,SW1A,1AA,1,E09000003,Barnet,2,Flat or maisonette,Purpose built,0,Yes,1,30,Non-binary,Buyer 1 prefers not to say,17,United Kingdom,,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,Buyer 2 prefers not to say,,Buyer prefers not to say,,Full-time - 30 hours or more,Yes,3,Child,14,Non-binary,Child under 16,Other,Not known,Non-binary,"In government training into work, such as New Deal",Prefers not to say,Not known,Prefers not to say,Prefers not to say,,,,,Local authority tenant,No,,,No,,,1,1,1,1,,Don't know,,Yes,Yes,No,Yes,Yes,Yes,10000,Yes,Yes,10000,Yes,"Don’t know ",No,,Yes,No,10,,,,,,,,,,,,,,,,,110000.0,,Yes,20000.0,Cambridge Building Society,,10,Yes,80000.0,,,Yes,100.0,,10000.0 +id,status,duplicate_set_id,created_at,updated_at,old_form_id,collection_start_year,creation_method,is_dpo,owning_organisation_name,managing_organisation_name,created_by,day,month,year,purchid,ownershipsch,type,othtype,companybuy,buylivein,jointpur,jointmore,noint,privacynotice,uprn,uprn_confirmed,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,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 1 prefers not to say,17,United Kingdom,,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,Buyer 2 prefers not to say,,Buyer prefers not to say,,Full-time - 30 hours or more,Yes,3,Child,14,Non-binary,Child under 16,Other,Not known,Non-binary,"In government training into work, such as New Deal",Prefers not to say,Not known,Prefers not to say,Prefers not to say,,,,,Local authority tenant,No,,,No,,,1,1,1,1,,Don't know,,Yes,Yes,No,Yes,Yes,Yes,10000,Yes,Yes,10000,Yes,"Don’t know ",No,,Yes,No,10,,,,,,,,,,,,,,,,,110000.0,,Yes,20000.0,Cambridge Building Society,,10,Yes,80000.0,,,Yes,100.0,,10000.0 diff --git a/spec/models/form/lettings/questions/declaration_spec.rb b/spec/models/form/lettings/questions/declaration_spec.rb new file mode 100644 index 000000000..4a22ea453 --- /dev/null +++ b/spec/models/form/lettings/questions/declaration_spec.rb @@ -0,0 +1,81 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Questions::Declaration, type: :model do + subject(:question) { described_class.new(question_id, question_definition, page) } + + let(:question_id) { nil } + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + let(:subsection) { instance_double(Form::Subsection) } + let(:form) { instance_double(Form) } + + before do + allow(form).to receive(:start_year_after_2024?) + allow(page).to receive(:subsection).and_return(subsection) + allow(subsection).to receive(:form).and_return(form) + end + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct id" do + expect(question.id).to eq("declaration") + end + + it "has the correct header" do + expect(question.header).to eq("Declaration") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Tenant has seen the privacy notice") + end + + it "has the correct type" do + expect(question.type).to eq("checkbox") + end + + it "is not marked as derived" do + expect(question.derived?).to be false + end + + it "has the correct hint" do + expect(question.hint_text).to be_nil + end + + context "when the form year is before 2024" do + before do + allow(form).to receive(:start_year_after_2024?).and_return(false) + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "declaration" => { "value" => "The tenant has seen the DLUHC privacy notice" }, + }) + end + + it "uses the expected top guidance partial" do + expect(question.top_guidance_partial).to eq("privacy_notice_tenant") + end + end + + context "when the form year is >= 2024" do + before do + allow(form).to receive(:start_year_after_2024?).and_return(true) + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "declaration" => { "value" => "The tenant has seen or been given access to the DLUHC privacy notice" }, + }) + end + + it "uses the expected top guidance partial" do + expect(question.top_guidance_partial).to eq("privacy_notice_tenant_2024") + end + end + + it "returns correct unanswered_error_message" do + expect(question.unanswered_error_message).to eq("You must show the DLUHC privacy notice to the tenant before you can submit this log.") + end +end diff --git a/spec/models/form/lettings/subsections/household_characteristics_spec.rb b/spec/models/form/lettings/subsections/household_characteristics_spec.rb index 4586d5592..34738ed7a 100644 --- a/spec/models/form/lettings/subsections/household_characteristics_spec.rb +++ b/spec/models/form/lettings/subsections/household_characteristics_spec.rb @@ -6,144 +6,295 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod let(:subsection_id) { nil } let(:subsection_definition) { nil } let(:section) { instance_double(Form::Lettings::Sections::Household) } + let(:form) { instance_double(Form) } + + before do + allow(section).to receive(:form).and_return(form) + end it "has correct section" do expect(household_characteristics.section).to eq(section) end - it "has correct pages" do - expect(household_characteristics.pages.map(&:id)).to eq( - %w[ - declaration - household_members - no_females_pregnant_household_lead_hhmemb_value_check - females_in_soft_age_range_in_pregnant_household_lead_hhmemb_value_check - lead_tenant_age - no_females_pregnant_household_lead_age_value_check - females_in_soft_age_range_in_pregnant_household_lead_age_value_check - age_lead_tenant_under_retirement_value_check - age_lead_tenant_over_retirement_value_check - lead_tenant_gender_identity - no_females_pregnant_household_lead_value_check - females_in_soft_age_range_in_pregnant_household_lead_value_check - gender_lead_tenant_over_retirement_value_check - lead_tenant_ethnic_group - lead_tenant_ethnic_background_arab - lead_tenant_ethnic_background_asian - lead_tenant_ethnic_background_black - lead_tenant_ethnic_background_mixed - lead_tenant_ethnic_background_white - lead_tenant_nationality - lead_tenant_working_situation - working_situation_lead_tenant_under_retirement_value_check - working_situation_lead_tenant_over_retirement_value_check - person_2_known - person_2_relationship_to_lead - person_2_age_child - person_2_age_non_child - no_females_pregnant_household_person_2_age_value_check - females_in_soft_age_range_in_pregnant_household_person_2_age_value_check - age_2_under_retirement_value_check - age_2_over_retirement_value_check - person_2_gender_identity - no_females_pregnant_household_person_2_value_check - females_in_soft_age_range_in_pregnant_household_person_2_value_check - gender_2_over_retirement_value_check - person_2_working_situation - working_situation_2_under_retirement_value_check - working_situation_2_over_retirement_value_check - person_3_known - person_3_relationship_to_lead - person_3_age_child - person_3_age_non_child - no_females_pregnant_household_person_3_age_value_check - females_in_soft_age_range_in_pregnant_household_person_3_age_value_check - age_3_under_retirement_value_check - age_3_over_retirement_value_check - person_3_gender_identity - no_females_pregnant_household_person_3_value_check - females_in_soft_age_range_in_pregnant_household_person_3_value_check - gender_3_over_retirement_value_check - person_3_working_situation - working_situation_3_under_retirement_value_check - working_situation_3_over_retirement_value_check - person_4_known - person_4_relationship_to_lead - person_4_age_child - person_4_age_non_child - no_females_pregnant_household_person_4_age_value_check - females_in_soft_age_range_in_pregnant_household_person_4_age_value_check - age_4_under_retirement_value_check - age_4_over_retirement_value_check - person_4_gender_identity - no_females_pregnant_household_person_4_value_check - females_in_soft_age_range_in_pregnant_household_person_4_value_check - gender_4_over_retirement_value_check - person_4_working_situation - working_situation_4_under_retirement_value_check - working_situation_4_over_retirement_value_check - person_5_known - person_5_relationship_to_lead - person_5_age_child - person_5_age_non_child - no_females_pregnant_household_person_5_age_value_check - females_in_soft_age_range_in_pregnant_household_person_5_age_value_check - age_5_under_retirement_value_check - age_5_over_retirement_value_check - person_5_gender_identity - no_females_pregnant_household_person_5_value_check - females_in_soft_age_range_in_pregnant_household_person_5_value_check - gender_5_over_retirement_value_check - person_5_working_situation - working_situation_5_under_retirement_value_check - working_situation_5_over_retirement_value_check - person_6_known - person_6_relationship_to_lead - person_6_age_child - person_6_age_non_child - no_females_pregnant_household_person_6_age_value_check - females_in_soft_age_range_in_pregnant_household_person_6_age_value_check - age_6_under_retirement_value_check - age_6_over_retirement_value_check - person_6_gender_identity - no_females_pregnant_household_person_6_value_check - females_in_soft_age_range_in_pregnant_household_person_6_value_check - gender_6_over_retirement_value_check - person_6_working_situation - working_situation_6_under_retirement_value_check - working_situation_6_over_retirement_value_check - person_7_known - person_7_relationship_to_lead - person_7_age_child - person_7_age_non_child - no_females_pregnant_household_person_7_age_value_check - females_in_soft_age_range_in_pregnant_household_person_7_age_value_check - age_7_under_retirement_value_check - age_7_over_retirement_value_check - person_7_gender_identity - no_females_pregnant_household_person_7_value_check - females_in_soft_age_range_in_pregnant_household_person_7_value_check - gender_7_over_retirement_value_check - person_7_working_situation - working_situation_7_under_retirement_value_check - working_situation_7_over_retirement_value_check - person_8_known - person_8_relationship_to_lead - person_8_age_child - person_8_age_non_child - no_females_pregnant_household_person_8_age_value_check - females_in_soft_age_range_in_pregnant_household_person_8_age_value_check - age_8_under_retirement_value_check - age_8_over_retirement_value_check - person_8_gender_identity - no_females_pregnant_household_person_8_value_check - females_in_soft_age_range_in_pregnant_household_person_8_value_check - gender_8_over_retirement_value_check - person_8_working_situation - working_situation_8_under_retirement_value_check - working_situation_8_over_retirement_value_check - ], - ) + context "with start year before 2024" do + before do + allow(form).to receive(:start_year_after_2024?).and_return(false) + end + + it "has correct pages" do + expect(household_characteristics.pages.map(&:id)).to eq( + %w[ + declaration + household_members + no_females_pregnant_household_lead_hhmemb_value_check + females_in_soft_age_range_in_pregnant_household_lead_hhmemb_value_check + lead_tenant_age + no_females_pregnant_household_lead_age_value_check + females_in_soft_age_range_in_pregnant_household_lead_age_value_check + age_lead_tenant_under_retirement_value_check + age_lead_tenant_over_retirement_value_check + lead_tenant_gender_identity + no_females_pregnant_household_lead_value_check + females_in_soft_age_range_in_pregnant_household_lead_value_check + gender_lead_tenant_over_retirement_value_check + lead_tenant_ethnic_group + lead_tenant_ethnic_background_arab + lead_tenant_ethnic_background_asian + lead_tenant_ethnic_background_black + lead_tenant_ethnic_background_mixed + lead_tenant_ethnic_background_white + lead_tenant_nationality + lead_tenant_working_situation + working_situation_lead_tenant_under_retirement_value_check + working_situation_lead_tenant_over_retirement_value_check + person_2_known + person_2_relationship_to_lead + person_2_age_child + person_2_age_non_child + no_females_pregnant_household_person_2_age_value_check + females_in_soft_age_range_in_pregnant_household_person_2_age_value_check + age_2_under_retirement_value_check + age_2_over_retirement_value_check + person_2_gender_identity + no_females_pregnant_household_person_2_value_check + females_in_soft_age_range_in_pregnant_household_person_2_value_check + gender_2_over_retirement_value_check + person_2_working_situation + working_situation_2_under_retirement_value_check + working_situation_2_over_retirement_value_check + person_3_known + person_3_relationship_to_lead + person_3_age_child + person_3_age_non_child + no_females_pregnant_household_person_3_age_value_check + females_in_soft_age_range_in_pregnant_household_person_3_age_value_check + age_3_under_retirement_value_check + age_3_over_retirement_value_check + person_3_gender_identity + no_females_pregnant_household_person_3_value_check + females_in_soft_age_range_in_pregnant_household_person_3_value_check + gender_3_over_retirement_value_check + person_3_working_situation + working_situation_3_under_retirement_value_check + working_situation_3_over_retirement_value_check + person_4_known + person_4_relationship_to_lead + person_4_age_child + person_4_age_non_child + no_females_pregnant_household_person_4_age_value_check + females_in_soft_age_range_in_pregnant_household_person_4_age_value_check + age_4_under_retirement_value_check + age_4_over_retirement_value_check + person_4_gender_identity + no_females_pregnant_household_person_4_value_check + females_in_soft_age_range_in_pregnant_household_person_4_value_check + gender_4_over_retirement_value_check + person_4_working_situation + working_situation_4_under_retirement_value_check + working_situation_4_over_retirement_value_check + person_5_known + person_5_relationship_to_lead + person_5_age_child + person_5_age_non_child + no_females_pregnant_household_person_5_age_value_check + females_in_soft_age_range_in_pregnant_household_person_5_age_value_check + age_5_under_retirement_value_check + age_5_over_retirement_value_check + person_5_gender_identity + no_females_pregnant_household_person_5_value_check + females_in_soft_age_range_in_pregnant_household_person_5_value_check + gender_5_over_retirement_value_check + person_5_working_situation + working_situation_5_under_retirement_value_check + working_situation_5_over_retirement_value_check + person_6_known + person_6_relationship_to_lead + person_6_age_child + person_6_age_non_child + no_females_pregnant_household_person_6_age_value_check + females_in_soft_age_range_in_pregnant_household_person_6_age_value_check + age_6_under_retirement_value_check + age_6_over_retirement_value_check + person_6_gender_identity + no_females_pregnant_household_person_6_value_check + females_in_soft_age_range_in_pregnant_household_person_6_value_check + gender_6_over_retirement_value_check + person_6_working_situation + working_situation_6_under_retirement_value_check + working_situation_6_over_retirement_value_check + person_7_known + person_7_relationship_to_lead + person_7_age_child + person_7_age_non_child + no_females_pregnant_household_person_7_age_value_check + females_in_soft_age_range_in_pregnant_household_person_7_age_value_check + age_7_under_retirement_value_check + age_7_over_retirement_value_check + person_7_gender_identity + no_females_pregnant_household_person_7_value_check + females_in_soft_age_range_in_pregnant_household_person_7_value_check + gender_7_over_retirement_value_check + person_7_working_situation + working_situation_7_under_retirement_value_check + working_situation_7_over_retirement_value_check + person_8_known + person_8_relationship_to_lead + person_8_age_child + person_8_age_non_child + no_females_pregnant_household_person_8_age_value_check + females_in_soft_age_range_in_pregnant_household_person_8_age_value_check + age_8_under_retirement_value_check + age_8_over_retirement_value_check + person_8_gender_identity + no_females_pregnant_household_person_8_value_check + females_in_soft_age_range_in_pregnant_household_person_8_value_check + gender_8_over_retirement_value_check + person_8_working_situation + working_situation_8_under_retirement_value_check + working_situation_8_over_retirement_value_check + ], + ) + end + end + + context "with start year >= 2024" do + before do + allow(form).to receive(:start_year_after_2024?).and_return(true) + end + + it "has correct pages" do + expect(household_characteristics.pages.map(&:id)).to eq( + %w[ + household_members + no_females_pregnant_household_lead_hhmemb_value_check + females_in_soft_age_range_in_pregnant_household_lead_hhmemb_value_check + lead_tenant_age + no_females_pregnant_household_lead_age_value_check + females_in_soft_age_range_in_pregnant_household_lead_age_value_check + age_lead_tenant_under_retirement_value_check + age_lead_tenant_over_retirement_value_check + lead_tenant_gender_identity + no_females_pregnant_household_lead_value_check + females_in_soft_age_range_in_pregnant_household_lead_value_check + gender_lead_tenant_over_retirement_value_check + lead_tenant_ethnic_group + lead_tenant_ethnic_background_arab + lead_tenant_ethnic_background_asian + lead_tenant_ethnic_background_black + lead_tenant_ethnic_background_mixed + lead_tenant_ethnic_background_white + lead_tenant_nationality + lead_tenant_working_situation + working_situation_lead_tenant_under_retirement_value_check + working_situation_lead_tenant_over_retirement_value_check + person_2_known + person_2_relationship_to_lead + person_2_age_child + person_2_age_non_child + no_females_pregnant_household_person_2_age_value_check + females_in_soft_age_range_in_pregnant_household_person_2_age_value_check + age_2_under_retirement_value_check + age_2_over_retirement_value_check + person_2_gender_identity + no_females_pregnant_household_person_2_value_check + females_in_soft_age_range_in_pregnant_household_person_2_value_check + gender_2_over_retirement_value_check + person_2_working_situation + working_situation_2_under_retirement_value_check + working_situation_2_over_retirement_value_check + person_3_known + person_3_relationship_to_lead + person_3_age_child + person_3_age_non_child + no_females_pregnant_household_person_3_age_value_check + females_in_soft_age_range_in_pregnant_household_person_3_age_value_check + age_3_under_retirement_value_check + age_3_over_retirement_value_check + person_3_gender_identity + no_females_pregnant_household_person_3_value_check + females_in_soft_age_range_in_pregnant_household_person_3_value_check + gender_3_over_retirement_value_check + person_3_working_situation + working_situation_3_under_retirement_value_check + working_situation_3_over_retirement_value_check + person_4_known + person_4_relationship_to_lead + person_4_age_child + person_4_age_non_child + no_females_pregnant_household_person_4_age_value_check + females_in_soft_age_range_in_pregnant_household_person_4_age_value_check + age_4_under_retirement_value_check + age_4_over_retirement_value_check + person_4_gender_identity + no_females_pregnant_household_person_4_value_check + females_in_soft_age_range_in_pregnant_household_person_4_value_check + gender_4_over_retirement_value_check + person_4_working_situation + working_situation_4_under_retirement_value_check + working_situation_4_over_retirement_value_check + person_5_known + person_5_relationship_to_lead + person_5_age_child + person_5_age_non_child + no_females_pregnant_household_person_5_age_value_check + females_in_soft_age_range_in_pregnant_household_person_5_age_value_check + age_5_under_retirement_value_check + age_5_over_retirement_value_check + person_5_gender_identity + no_females_pregnant_household_person_5_value_check + females_in_soft_age_range_in_pregnant_household_person_5_value_check + gender_5_over_retirement_value_check + person_5_working_situation + working_situation_5_under_retirement_value_check + working_situation_5_over_retirement_value_check + person_6_known + person_6_relationship_to_lead + person_6_age_child + person_6_age_non_child + no_females_pregnant_household_person_6_age_value_check + females_in_soft_age_range_in_pregnant_household_person_6_age_value_check + age_6_under_retirement_value_check + age_6_over_retirement_value_check + person_6_gender_identity + no_females_pregnant_household_person_6_value_check + females_in_soft_age_range_in_pregnant_household_person_6_value_check + gender_6_over_retirement_value_check + person_6_working_situation + working_situation_6_under_retirement_value_check + working_situation_6_over_retirement_value_check + person_7_known + person_7_relationship_to_lead + person_7_age_child + person_7_age_non_child + no_females_pregnant_household_person_7_age_value_check + females_in_soft_age_range_in_pregnant_household_person_7_age_value_check + age_7_under_retirement_value_check + age_7_over_retirement_value_check + person_7_gender_identity + no_females_pregnant_household_person_7_value_check + females_in_soft_age_range_in_pregnant_household_person_7_value_check + gender_7_over_retirement_value_check + person_7_working_situation + working_situation_7_under_retirement_value_check + working_situation_7_over_retirement_value_check + person_8_known + person_8_relationship_to_lead + person_8_age_child + person_8_age_non_child + no_females_pregnant_household_person_8_age_value_check + females_in_soft_age_range_in_pregnant_household_person_8_age_value_check + age_8_under_retirement_value_check + age_8_over_retirement_value_check + person_8_gender_identity + no_females_pregnant_household_person_8_value_check + females_in_soft_age_range_in_pregnant_household_person_8_value_check + gender_8_over_retirement_value_check + person_8_working_situation + working_situation_8_under_retirement_value_check + working_situation_8_over_retirement_value_check + ], + ) + end end it "has the correct id" do diff --git a/spec/models/form/lettings/subsections/setup_spec.rb b/spec/models/form/lettings/subsections/setup_spec.rb index d7da750a8..b31cb61c5 100644 --- a/spec/models/form/lettings/subsections/setup_spec.rb +++ b/spec/models/form/lettings/subsections/setup_spec.rb @@ -6,38 +6,45 @@ RSpec.describe Form::Lettings::Subsections::Setup, type: :model do let(:subsection_id) { nil } let(:subsection_definition) { nil } let(:section) { instance_double(Form::Lettings::Sections::Setup) } + let(:form) { instance_double(Form) } + + before do + allow(section).to receive(:form).and_return(form) + end it "has correct section" do expect(setup.section).to eq(section) end - it "has correct pages" do - expect(setup.pages.map(&:id)).to eq( - %w[ - stock_owner - managing_organisation - created_by - needs_type - scheme - location - renewal - tenancy_start_date - rent_type - tenant_code - property_reference - ], - ) - end + context "with start year before 2024" do + before do + allow(form).to receive(:start_year_after_2024?).and_return(false) + end - it "has the correct id" do - expect(setup.id).to eq("setup") + it "has correct pages" do + expect(setup.pages.map(&:id)).to eq( + %w[ + stock_owner + managing_organisation + created_by + needs_type + scheme + location + renewal + tenancy_start_date + rent_type + tenant_code + property_reference + ], + ) + end end - it "has the correct label" do - expect(setup.label).to eq("Set up this lettings log") - end + context "with start year >= 2024" do + before do + allow(form).to receive(:start_year_after_2024?).and_return(true) + end - context "when not production" do it "has correct pages" do expect(setup.pages.map(&:id)).to eq( %w[ @@ -52,8 +59,17 @@ RSpec.describe Form::Lettings::Subsections::Setup, type: :model do rent_type tenant_code property_reference + declaration ], ) end end + + it "has the correct id" do + expect(setup.id).to eq("setup") + end + + it "has the correct label" do + expect(setup.label).to eq("Set up this lettings log") + end end diff --git a/spec/models/form/sales/pages/last_accommodation_la_spec.rb b/spec/models/form/sales/pages/last_accommodation_la_spec.rb index 20daf0525..54df5a365 100644 --- a/spec/models/form/sales/pages/last_accommodation_la_spec.rb +++ b/spec/models/form/sales/pages/last_accommodation_la_spec.rb @@ -5,8 +5,22 @@ RSpec.describe Form::Sales::Pages::LastAccommodationLa, type: :model do let(:page_id) { nil } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date:)) } + let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, depends_on_met: true)) } let(:start_date) { Time.utc(2022, 4, 1) } + let(:log) { create(:sales_log, :completed, saledate: now) } + let(:now) { Time.zone.local(2023, 4, 4) } + + before do + Timecop.freeze(now) + Singleton.__init__(FormHandler) + allow(subsection).to receive(:depends_on).and_return(nil) + allow(subsection).to receive(:enabled?).and_return(true) + end + + after do + Timecop.return + Singleton.__init__(FormHandler) + end it "has correct subsection" do expect(page.subsection).to eq(subsection) @@ -33,4 +47,23 @@ RSpec.describe Form::Sales::Pages::LastAccommodationLa, type: :model do "is_previous_la_inferred" => false, }]) end + + it "is routed to" do + log.ownershipsch = 2 + expect(page).to be_routed_to(log, nil) + end + + context "with 2024 form" do + let(:now) { Time.zone.local(2024, 4, 4) } + + it "is routed to for 2024 non discounted sale logs" do + log.update!(ownershipsch: 1) + expect(page).to be_routed_to(log, nil) + end + + it "is not routed to for 2024 discounted sale logs" do + log.update!(ownershipsch: 2) + expect(page).not_to be_routed_to(log, nil) + end + end end diff --git a/spec/models/form/sales/pages/last_accommodation_spec.rb b/spec/models/form/sales/pages/last_accommodation_spec.rb index 753aa7dc8..a972d96c5 100644 --- a/spec/models/form/sales/pages/last_accommodation_spec.rb +++ b/spec/models/form/sales/pages/last_accommodation_spec.rb @@ -3,10 +3,24 @@ require "rails_helper" RSpec.describe Form::Sales::Pages::LastAccommodation, type: :model do subject(:page) { described_class.new(page_id, page_definition, subsection) } + let(:log) { create(:sales_log, :completed, saledate: now) } + let(:now) { Time.zone.local(2023, 4, 4) } + let(:page_id) { nil } let(:page_definition) { nil } let(:subsection) { instance_double(Form::Subsection) } + before do + Timecop.freeze(now) + Singleton.__init__(FormHandler) + allow(subsection).to receive(:depends_on).and_return(nil) + end + + after do + Timecop.return + Singleton.__init__(FormHandler) + end + it "has correct subsection" do expect(page.subsection).to eq(subsection) end @@ -30,4 +44,23 @@ RSpec.describe Form::Sales::Pages::LastAccommodation, type: :model do it "has correct depends_on" do expect(page.depends_on).to be_nil end + + it "is routed to" do + log.ownershipsch = 2 + expect(page).to be_routed_to(log, nil) + end + + context "with 2024 form" do + let(:now) { Time.zone.local(2024, 4, 4) } + + it "is routed to for 2024 non discounted sale logs" do + log.update!(ownershipsch: 1) + expect(page).to be_routed_to(log, nil) + end + + it "is not routed to for 2024 discounted sale logs" do + log.update!(ownershipsch: 2) + expect(page).not_to be_routed_to(log, nil) + end + end end diff --git a/spec/models/form/sales/pages/privacy_notice_spec.rb b/spec/models/form/sales/pages/privacy_notice_spec.rb index d8e25a3d8..9c2ce1a64 100644 --- a/spec/models/form/sales/pages/privacy_notice_spec.rb +++ b/spec/models/form/sales/pages/privacy_notice_spec.rb @@ -6,6 +6,12 @@ RSpec.describe Form::Sales::Pages::PrivacyNotice, type: :model do let(:page_id) { nil } let(:page_definition) { nil } let(:subsection) { instance_double(Form::Subsection) } + let(:form) { instance_double(Form) } + + before do + allow(subsection).to receive(:form).and_return(form) + allow(form).to receive(:start_year_after_2024?) + end it "has correct subsection" do expect(page.subsection).to eq(subsection) diff --git a/spec/models/form/sales/questions/privacy_notice_spec.rb b/spec/models/form/sales/questions/privacy_notice_spec.rb index 1fec22b6e..c37f6f920 100644 --- a/spec/models/form/sales/questions/privacy_notice_spec.rb +++ b/spec/models/form/sales/questions/privacy_notice_spec.rb @@ -6,6 +6,14 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do let(:question_id) { nil } let(:question_definition) { nil } let(:page) { instance_double(Form::Page) } + let(:subsection) { instance_double(Form::Subsection) } + let(:form) { instance_double(Form) } + + before do + allow(form).to receive(:start_year_after_2024?) + allow(page).to receive(:subsection).and_return(subsection) + allow(subsection).to receive(:form).and_return(form) + end it "has correct page" do expect(question.page).to eq(page) @@ -35,10 +43,36 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do expect(question.hint_text).to be_nil end - it "has the correct answer_options" do - expect(question.answer_options).to eq({ - "privacynotice" => { "value" => "The buyer has seen the DLUHC privacy notice" }, - }) + context "when the form year is before 2024" do + before do + allow(form).to receive(:start_year_after_2024?).and_return(false) + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "privacynotice" => { "value" => "The buyer has seen the DLUHC privacy notice" }, + }) + end + + it "uses the expected top guidance partial" do + expect(question.top_guidance_partial).to eq("privacy_notice_buyer") + end + end + + context "when the form year is >= 2024" do + before do + allow(form).to receive(:start_year_after_2024?).and_return(true) + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "privacynotice" => { "value" => "The buyer has seen or been given access to the DLUHC privacy notice" }, + }) + end + + it "uses the expected top guidance partial" do + expect(question.top_guidance_partial).to eq("privacy_notice_buyer_2024") + end end it "returns correct unanswered_error_message" do diff --git a/spec/models/form/sales/subsections/household_characteristics_spec.rb b/spec/models/form/sales/subsections/household_characteristics_spec.rb index 00e96450f..842dec8bc 100644 --- a/spec/models/form/sales/subsections/household_characteristics_spec.rb +++ b/spec/models/form/sales/subsections/household_characteristics_spec.rb @@ -240,7 +240,6 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model it "has correct pages" do expect(household_characteristics.pages.map(&:id)).to eq( %w[ - privacy_notice buyer_1_age age_1_retirement_value_check age_1_old_persons_shared_ownership_value_check diff --git a/spec/models/form/sales/subsections/setup_spec.rb b/spec/models/form/sales/subsections/setup_spec.rb index 2ddb64e19..eb92e3753 100644 --- a/spec/models/form/sales/subsections/setup_spec.rb +++ b/spec/models/form/sales/subsections/setup_spec.rb @@ -68,6 +68,7 @@ RSpec.describe Form::Sales::Subsections::Setup, type: :model do joint_purchase number_joint_buyers buyer_interview + privacy_notice ], ) end diff --git a/spec/models/form_handler_spec.rb b/spec/models/form_handler_spec.rb index fe340f71b..257c41b43 100644 --- a/spec/models/form_handler_spec.rb +++ b/spec/models/form_handler_spec.rb @@ -271,7 +271,7 @@ RSpec.describe FormHandler do sales_form = FormFactory.new(year: 1936, type: "sales") .with_sections([section]) .build - described_class.instance.use_fake_forms!({ only_sales: sales_form }) + described_class.instance.use_fake_forms!({ "current_sales" => sales_form }) expect(result).to(satisfy { |result| result.all? { |element| element.is_a?(Form::Question) } }) end @@ -281,7 +281,7 @@ RSpec.describe FormHandler do sales_form = FormFactory.new(year: 1936, type: "sales") .with_sections([first_section, second_section]) .build - described_class.instance.use_fake_forms!({ only_sales: sales_form }) + described_class.instance.use_fake_forms!({ "current_sales" => sales_form }) expect(result.map(&:id)).to eq %w[1 2 3 4 5] end @@ -291,7 +291,7 @@ RSpec.describe FormHandler do sales_form = FormFactory.new(year: 1945, type: "sales") .with_sections([first_section, second_section]) .build - described_class.instance.use_fake_forms!({ only_sales: sales_form }) + described_class.instance.use_fake_forms!({ "current_sales" => sales_form }) expect(result.map(&:id)).to eq %w[1 2 3 4 5 6] end @@ -305,12 +305,49 @@ RSpec.describe FormHandler do .with_sections([new_section]) .build fake_forms = { - earlier_sales: original_form, - newer_sales: new_form, + "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 @@ -322,7 +359,7 @@ RSpec.describe FormHandler do lettings_form = FormFactory.new(year: 2936, type: "lettings") .with_sections([section]) .build - described_class.instance.use_fake_forms!({ only_lettings: lettings_form }) + described_class.instance.use_fake_forms!({ "current_lettings" => lettings_form }) expect(result).to(satisfy { |result| result.all? { |element| element.is_a?(Form::Question) } }) end @@ -332,7 +369,7 @@ RSpec.describe FormHandler do lettings_form = FormFactory.new(year: 2936, type: "lettings") .with_sections([first_section, second_section]) .build - described_class.instance.use_fake_forms!({ only_lettings: lettings_form }) + described_class.instance.use_fake_forms!({ "current_lettings" => lettings_form }) expect(result.map(&:id)).to eq %w[1 2 3 4 5] end @@ -342,7 +379,7 @@ RSpec.describe FormHandler do lettings_form = FormFactory.new(year: 2945, type: "lettings") .with_sections([first_section, second_section]) .build - described_class.instance.use_fake_forms!({ only_lettings: lettings_form }) + described_class.instance.use_fake_forms!({ "current_lettings" => lettings_form }) expect(result.map(&:id)).to eq %w[1 2 3 4 5 6] end @@ -356,12 +393,49 @@ RSpec.describe FormHandler do .with_sections([new_section]) .build fake_forms = { - earlier_lettings: original_form, - newer_lettings: new_form, + "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 + + 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 "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] + end end # rubocop:enable RSpec/PredicateMatcher end diff --git a/spec/models/sales_log_spec.rb b/spec/models/sales_log_spec.rb index 42aa64fec..00792b0bd 100644 --- a/spec/models/sales_log_spec.rb +++ b/spec/models/sales_log_spec.rb @@ -657,7 +657,7 @@ RSpec.describe SalesLog, type: :model do end before do - WebMock.stub_request(:get, /api.postcodes.io\/postcodes\/CA101AA/) + WebMock.stub_request(:get, /api\.postcodes\.io\/postcodes\/CA101AA/) .to_return(status: 200, body: '{"status":200,"result":{"admin_district":"Cumberland","codes":{"admin_district":"E06000064"}}}', headers: {}) Timecop.freeze(2023, 5, 1) @@ -687,7 +687,7 @@ RSpec.describe SalesLog, type: :model do end before do - WebMock.stub_request(:get, /api.postcodes.io\/postcodes\/CA101AA/) + WebMock.stub_request(:get, /api\.postcodes\.io\/postcodes\/CA101AA/) .to_return(status: 200, body: '{"status":200,"result":{"admin_district":"Eden","codes":{"admin_district":"E07000030"}}}', headers: {}) Timecop.freeze(2023, 5, 2) @@ -703,6 +703,56 @@ RSpec.describe SalesLog, type: :model do expect(address_sales_log_23_24.la).to eq("E06000064") expect(record_from_db["la"]).to eq("E06000064") end + + it "does not set previous postcode or previous la for discounted sale" do + address_sales_log_23_24.update!(ownershipsch: 2, ppostcode_full: nil, prevloc: nil) + record_from_db = described_class.find(address_sales_log_23_24.id) + expect(address_sales_log_23_24.ppostcode_full).to eq(nil) + expect(record_from_db["ppostcode_full"]).to eq(nil) + expect(record_from_db["prevloc"]).to eq(nil) + end + end + + context "with 24/25 logs" do + let(:address_sales_log_24_25) do + described_class.create({ + owning_organisation:, + created_by: created_by_user, + ppcodenk: 1, + postcode_full: "CA10 1AA", + ppostcode_full: nil, + prevloc: nil, + saledate: Time.zone.local(2024, 5, 2), + }) + end + + before do + WebMock.stub_request(:get, /api\.postcodes\.io\/postcodes\/CA101AA/) + .to_return(status: 200, body: '{"status":200,"result":{"admin_district":"Eden","codes":{"admin_district":"E07000030"}}}', headers: {}) + + Timecop.freeze(2024, 5, 2) + Singleton.__init__(FormHandler) + end + + after do + Timecop.unfreeze + end + + it "sets previous postcode for discounted sale" do + address_sales_log_24_25.update!(ownershipsch: 2, ppostcode_full: nil) + record_from_db = described_class.find(address_sales_log_24_25.id) + expect(address_sales_log_24_25.ppostcode_full).to eq("CA10 1AA") + expect(record_from_db["ppostcode_full"]).to eq("CA10 1AA") + expect(record_from_db["prevloc"]).to eq("E06000064") + end + + it "does not set previous postcode for non discounted sale" do + address_sales_log_24_25.update!(ownershipsch: 1, ppostcode_full: nil) + record_from_db = described_class.find(address_sales_log_24_25.id) + expect(address_sales_log_24_25.ppostcode_full).to eq(nil) + expect(record_from_db["ppostcode_full"]).to eq(nil) + expect(record_from_db["prevloc"]).to eq(nil) + end end it "errors if the property postcode is emptied" do diff --git a/spec/models/validations/sales/household_validations_spec.rb b/spec/models/validations/sales/household_validations_spec.rb index 898a47fcc..deddfa8ef 100644 --- a/spec/models/validations/sales/household_validations_spec.rb +++ b/spec/models/validations/sales/household_validations_spec.rb @@ -154,64 +154,6 @@ RSpec.describe Validations::Sales::HouseholdValidations do end end - describe "previous postcode validations" do - let(:record) { build(:sales_log) } - - context "with a discounted sale" do - before do - record.ownershipsch = 2 - end - - it "adds an error when previous and current postcodes are not the same" do - record.postcode_full = "SO32 3PT" - record.ppostcode_full = "DN6 7FB" - household_validator.validate_previous_postcode(record) - expect(record.errors["postcode_full"]) - .to include(match I18n.t("validations.household.postcode.discounted_ownership")) - expect(record.errors["ppostcode_full"]) - .to include(match I18n.t("validations.household.postcode.discounted_ownership")) - end - - it "allows same postcodes" do - record.postcode_full = "SO32 3PT" - record.ppostcode_full = "SO32 3PT" - household_validator.validate_previous_postcode(record) - expect(record.errors["postcode_full"]).to be_empty - expect(record.errors["ppostcode_full"]).to be_empty - end - - it "does not add an error when postcode is missing" do - record.postcode_full = nil - record.ppostcode_full = "SO32 3PT" - household_validator.validate_previous_postcode(record) - expect(record.errors["postcode_full"]).to be_empty - expect(record.errors["ppostcode_full"]).to be_empty - end - - it "does not add an error when previous postcode is missing" do - record.postcode_full = "SO32 3PT" - record.ppostcode_full = nil - household_validator.validate_previous_postcode(record) - expect(record.errors["postcode_full"]).to be_empty - expect(record.errors["ppostcode_full"]).to be_empty - end - end - - context "without a discounted sale" do - before do - record.ownershipsch = 1 - end - - it "allows different postcodes" do - record.postcode_full = "SO32 3PT" - record.ppostcode_full = "DN6 7FB" - household_validator.validate_previous_postcode(record) - expect(record.errors["postcode_full"]).to be_empty - expect(record.errors["ppostcode_full"]).to be_empty - end - end - end - describe "validating fields about buyers living in the property" do let(:sales_log) { FactoryBot.create(:sales_log, :outright_sale_setup_complete, noint: 1, companybuy: 2, buylivein:, jointpur:, jointmore:, buy1livein:) } diff --git a/spec/models/validations/sales/property_validations_spec.rb b/spec/models/validations/sales/property_validations_spec.rb index 0152428d8..f84f65966 100644 --- a/spec/models/validations/sales/property_validations_spec.rb +++ b/spec/models/validations/sales/property_validations_spec.rb @@ -19,7 +19,7 @@ RSpec.describe Validations::Sales::PropertyValidations do end context "when ownership scheme is discounted ownership" do - let(:record) { build(:sales_log, ownershipsch: 2) } + let(:record) { build(:sales_log, ownershipsch: 2, saledate: Time.zone.local(2023, 4, 5)) } it "when ppostcode_full is not present no error is added" do record.postcode_full = "SW1A 1AA" @@ -54,6 +54,16 @@ RSpec.describe Validations::Sales::PropertyValidations do expect(record.errors["ppostcode_full"]).to include(match I18n.t("validations.property.postcode.must_match_previous")) expect(record.errors["ownershipsch"]).to include(match I18n.t("validations.property.postcode.must_match_previous")) end + + it "does not add error for 2024 log" do + record.postcode_full = "SW1A 1AA" + record.ppostcode_full = "SW1A 0AA" + record.saledate = Time.zone.local(2024, 4, 5) + property_validator.validate_postcodes_match_if_discounted_ownership(record) + expect(record.errors["postcode_full"]).to be_empty + expect(record.errors["ppostcode_full"]).to be_empty + expect(record.errors["ownershipsch"]).to be_empty + end end end diff --git a/spec/services/csv/lettings_log_csv_service_spec.rb b/spec/services/csv/lettings_log_csv_service_spec.rb index ac6d14f0f..659cadc7d 100644 --- a/spec/services/csv/lettings_log_csv_service_spec.rb +++ b/spec/services/csv/lettings_log_csv_service_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" RSpec.describe Csv::LettingsLogCsvService do before do - Timecop.freeze(fixed_time) + Timecop.freeze(now) Singleton.__init__(FormHandler) FormHandler.instance.use_real_forms! log.irproduct = 1 @@ -17,13 +17,14 @@ RSpec.describe Csv::LettingsLogCsvService do let(:form_handler_mock) { instance_double(FormHandler) } let(:organisation) { create(:organisation) } let(:fixed_time) { Time.zone.local(2023, 11, 26) } + let(:now) { Time.zone.now } let(:log) do create( :lettings_log, :completed, startdate: fixed_time, created_at: fixed_time, - updated_at: fixed_time, + updated_at: now, mrcdate: fixed_time - 1.day, voiddate: fixed_time - 2.days, propcode: "ABCDEFG", @@ -162,14 +163,32 @@ RSpec.describe Csv::LettingsLogCsvService do expect(la_label_value).to eq "Barnet" end - it "exports the CSV with all values correct" do - expected_content = CSV.read("spec/fixtures/files/lettings_log_csv_export_labels.csv") - values_to_delete = %w[id vacdays] - values_to_delete.each do |attribute| - index = csv.first.index(attribute) - csv.second[index] = nil + context "when the current form is 2024" do + let(:now) { Time.zone.local(2024, 4, 1) } + + 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 + let(:now) { Time.zone.local(2023, 11, 26) } + + it "exports the CSV with 2023 ordering and all values correct" do + expected_content = CSV.read("spec/fixtures/files/lettings_log_csv_export_labels_23.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 - expect(csv).to eq expected_content end context "when the log has a duplicate log reference" do @@ -212,14 +231,32 @@ RSpec.describe Csv::LettingsLogCsvService do expect(la_label_value).to eq "Barnet" end - it "exports the CSV with all values correct" do - expected_content = CSV.read("spec/fixtures/files/lettings_log_csv_export_codes.csv") - values_to_delete = %w[id vacdays] - values_to_delete.each do |attribute| - index = csv.first.index(attribute) - csv.second[index] = nil + context "when the current form is 2024" do + let(:now) { Time.zone.local(2024, 4, 1) } + + it "exports the CSV with all values correct" do + expected_content = CSV.read("spec/fixtures/files/lettings_log_csv_export_codes_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 + let(:now) { Time.zone.local(2023, 11, 26) } + + it "exports the CSV with all values correct" do + expected_content = CSV.read("spec/fixtures/files/lettings_log_csv_export_codes_23.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 - expect(csv).to eq expected_content end context "when the log has a duplicate log reference" do @@ -242,31 +279,67 @@ RSpec.describe Csv::LettingsLogCsvService do expect(headers).not_to include(*%w[wrent wscharge wpschrge wsupchrg wtcharge]) end - context "and exporting with labels" do - let(:export_type) { "labels" } + context "and the current form is 2024" do + let(:now) { Time.zone.local(2024, 4, 1) } - it "exports the CSV with all values correct" do - expected_content = CSV.read("spec/fixtures/files/lettings_log_csv_export_non_support_labels.csv") - values_to_delete = %w[id] - values_to_delete.each do |attribute| - index = csv.first.index(attribute) - csv.second[index] = nil + 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/lettings_log_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 + + context "and exporting values as codes" do + let(:export_type) { "codes" } + + it "exports the CSV with all values correct" do + expected_content = CSV.read("spec/fixtures/files/lettings_log_csv_export_non_support_codes_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 - expect(csv).to eq expected_content end end - context "and exporting values as codes" do - let(:export_type) { "codes" } + context "and the current form is 2023" do + let(:now) { Time.zone.local(2023, 11, 26) } - it "exports the CSV with all values correct" do - expected_content = CSV.read("spec/fixtures/files/lettings_log_csv_export_non_support_codes.csv") - values_to_delete = %w[id] - values_to_delete.each do |attribute| - index = csv.first.index(attribute) - csv.second[index] = nil + 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/lettings_log_csv_export_non_support_labels_23.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 "and exporting values as codes" do + let(:export_type) { "codes" } + + it "exports the CSV with all values correct" do + expected_content = CSV.read("spec/fixtures/files/lettings_log_csv_export_non_support_codes_23.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 - expect(csv).to eq expected_content end end end diff --git a/spec/services/csv/sales_log_csv_service_spec.rb b/spec/services/csv/sales_log_csv_service_spec.rb index bbc7af0f2..79efaf920 100644 --- a/spec/services/csv/sales_log_csv_service_spec.rb +++ b/spec/services/csv/sales_log_csv_service_spec.rb @@ -4,6 +4,7 @@ RSpec.describe Csv::SalesLogCsvService do let(:form_handler_mock) { instance_double(FormHandler) } let(:organisation) { create(:organisation) } let(:fixed_time) { Time.zone.local(2023, 12, 8) } + let(:now) { Time.zone.now } let(:user) { create(:user, email: "billyboy@eyeKLAUD.com") } let(:log) do create( @@ -12,7 +13,7 @@ RSpec.describe Csv::SalesLogCsvService do created_by: user, saledate: fixed_time, created_at: fixed_time, - updated_at: fixed_time, + updated_at: now, owning_organisation: organisation, purchid: nil, hholdcount: 3, @@ -29,11 +30,15 @@ RSpec.describe Csv::SalesLogCsvService do let(:csv) { CSV.parse(service.prepare_csv(SalesLog.all)) } before do - allow(Time).to receive(:now).and_return(fixed_time) + Timecop.freeze(now) Singleton.__init__(FormHandler) log end + after 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([]) @@ -154,14 +159,32 @@ RSpec.describe Csv::SalesLogCsvService do expect(la_label_value).to eq "Barnet" end - it "exports the CSV with all values correct" do - expected_content = CSV.read("spec/fixtures/files/sales_logs_csv_export_labels.csv") - values_to_delete = %w[id] - values_to_delete.each do |attribute| - index = csv.first.index(attribute) - csv.second[index] = nil + context "when the current form is 2024" do + let(:now) { Time.zone.local(2024, 5, 1) } + + 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 + let(:now) { Time.zone.local(2024, 1, 1) } + + 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.each do |attribute| + index = csv.first.index(attribute) + csv.second[index] = nil + end + expect(csv).to eq expected_content end - expect(csv).to eq expected_content end context "when the log has a duplicate log reference" do @@ -214,14 +237,32 @@ RSpec.describe Csv::SalesLogCsvService do expect(la_label_value).to eq "Barnet" end - it "exports the CSV with all values correct" do - expected_content = CSV.read("spec/fixtures/files/sales_logs_csv_export_codes.csv") - values_to_delete = %w[id] - values_to_delete.each do |attribute| - index = csv.first.index(attribute) - csv.second[index] = nil + context "when the current form is 2024" do + let(:now) { Time.zone.local(2024, 5, 1) } + + 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.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 + let(:now) { Time.zone.local(2024, 1, 1) } + + 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.each do |attribute| + index = csv.first.index(attribute) + csv.second[index] = nil + end + expect(csv).to eq expected_content end - expect(csv).to eq expected_content end context "when the log has a duplicate log reference" do diff --git a/spec/services/exports/lettings_log_export_service_spec.rb b/spec/services/exports/lettings_log_export_service_spec.rb index 4e76364c4..65a41df26 100644 --- a/spec/services/exports/lettings_log_export_service_spec.rb +++ b/spec/services/exports/lettings_log_export_service_spec.rb @@ -256,6 +256,32 @@ RSpec.describe Exports::LettingsLogExportService do export_service.export_xml_lettings_logs(collection_year: 2022) end + + context "and previous full exports are different for previous years" do + let(:expected_zip_filename) { "core_2021_2022_apr_mar_f0007_inc0004.zip" } + let(:expected_zip_filename2) { "core_2022_2023_apr_mar_f0001_inc0001.zip" } + + before do + LogsExport.new(started_at: Time.zone.yesterday, base_number: 7, increment_number: 3, collection: 2021).save! + end + + it "generates multiple ZIP export files with different base numbers in the filenames" do + expect(storage_service).to receive(:write_file).with(expected_zip_filename, any_args) + expect(storage_service).to receive(:write_file).with(expected_zip_filename2, any_args) + expect(Rails.logger).to receive(:info).with("Building export run for 2021") + expect(Rails.logger).to receive(:info).with("Creating core_2021_2022_apr_mar_f0007_inc0004 - 1 logs") + expect(Rails.logger).to receive(:info).with("Added core_2021_2022_apr_mar_f0007_inc0004_pt001.xml") + expect(Rails.logger).to receive(:info).with("Writing core_2021_2022_apr_mar_f0007_inc0004.zip") + expect(Rails.logger).to receive(:info).with("Building export run for 2022") + expect(Rails.logger).to receive(:info).with("Creating core_2022_2023_apr_mar_f0001_inc0001 - 1 logs") + expect(Rails.logger).to receive(:info).with("Added core_2022_2023_apr_mar_f0001_inc0001_pt001.xml") + expect(Rails.logger).to receive(:info).with("Writing core_2022_2023_apr_mar_f0001_inc0001.zip") + expect(Rails.logger).to receive(:info).with("Building export run for 2023") + expect(Rails.logger).to receive(:info).with("Creating core_2023_2024_apr_mar_f0001_inc0001 - 0 logs") + + export_service.export_xml_lettings_logs + end + end end end