diff --git a/app/models/derived_variables/lettings_log_variables.rb b/app/models/derived_variables/lettings_log_variables.rb index 526963d9c..7d664e48f 100644 --- a/app/models/derived_variables/lettings_log_variables.rb +++ b/app/models/derived_variables/lettings_log_variables.rb @@ -46,6 +46,8 @@ module DerivedVariables::LettingsLogVariables self.referral = 1 self.waityear = 2 self.offered = 0 + self.voiddate = startdate + self.first_time_property_let_as_social_housing = 0 if is_general_needs? # fixed term self.prevten = 32 if managing_organisation&.provider_type == "PRP" @@ -61,7 +63,6 @@ module DerivedVariables::LettingsLogVariables if is_supported_housing? && location self.wchair = location.mobility_type_before_type_cast == "W" ? 1 : 2 end - self.voiddate = startdate if is_renewal? self.vacdays = property_vacant_days set_housingneeds_fields if housingneeds? diff --git a/lib/tasks/data_export.rake b/lib/tasks/data_export.rake index 17f258293..a86712d83 100644 --- a/lib/tasks/data_export.rake +++ b/lib/tasks/data_export.rake @@ -11,21 +11,3 @@ namespace :core do DataExportXmlJob.perform_later(full_update:) end end - -namespace :illness_type_0 do - desc "Export log data where illness_type_0 == 1" - task export: :environment do |_task| - logs = LettingsLog.where(illness_type_0: 1, status: "completed").includes(created_by: :organisation) - puts "log_id,created_by_id,organisation_id,organisation_name,startdate" - - logs.each do |log| - puts [ - log.id, - log.created_by_id, - log.created_by.organisation.id, - log.created_by.organisation.name, - log.startdate&.strftime("%d/%m/%Y"), - ].join(",") - end - end -end diff --git a/spec/models/lettings_log_spec.rb b/spec/models/lettings_log_spec.rb index 2aee5ddcf..d4bbd8378 100644 --- a/spec/models/lettings_log_spec.rb +++ b/spec/models/lettings_log_spec.rb @@ -1459,6 +1459,15 @@ RSpec.describe LettingsLog do expect(record_from_db["vacdays"]).to eq(0) expect(lettings_log["vacdays"]).to eq(0) end + + it "correctly derives and saves first_time_property_let_as_social_housing" do + record_from_db = ActiveRecord::Base.connection.execute( + "select first_time_property_let_as_social_housing" \ + " from lettings_logs where id=#{lettings_log.id}", + ).to_a[0] + expect(record_from_db["first_time_property_let_as_social_housing"]).to eq(0) + expect(lettings_log["first_time_property_let_as_social_housing"]).to eq(0) + end end context "when answering the household characteristics questions" do