From 9e04549e09dcfebf1b72f3fbb80dc9665b71f73f Mon Sep 17 00:00:00 2001 From: kiddhustle Date: Wed, 30 Mar 2022 15:10:33 +0100 Subject: [PATCH] CLDC-1074: dervied landlord --- app/models/case_log.rb | 3 +++ db/schema.rb | 1 + spec/fixtures/complete_case_log.json | 2 +- spec/fixtures/exports/case_logs.xml | 2 +- spec/models/case_log_spec.rb | 8 ++++++++ 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/models/case_log.rb b/app/models/case_log.rb index d3271083c..98502cf64 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -413,6 +413,9 @@ private self.prevten = 30 if managing_organisation.provider_type == "LA" end end + + self.landlord = 1 if owning_organisation.provider_type == "PRP" + self.landlord = 2 if owning_organisation.provider_type == "LA" end def process_postcode_changes! diff --git a/db/schema.rb b/db/schema.rb index 965fcee3d..008545aab 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -319,6 +319,7 @@ ActiveRecord::Schema[7.0].define(version: 202202071123100) do t.boolean "is_dpo", default: false t.boolean "is_key_contact", default: false t.string "phone" + t.boolean "is_dpo", default: false t.index ["email"], name: "index_users_on_email", unique: true t.index ["organisation_id"], name: "index_users_on_organisation_id" t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true diff --git a/spec/fixtures/complete_case_log.json b/spec/fixtures/complete_case_log.json index dcfa683d0..2089965a1 100644 --- a/spec/fixtures/complete_case_log.json +++ b/spec/fixtures/complete_case_log.json @@ -53,7 +53,7 @@ "startertenancy": 0, "tenancylength": 5, "tenancy": 3, - "landlord": "This landlord", + "landlord": 1, "la": "Barnet", "postcode_full": "NW1 5TY", "property_relet": 0, diff --git a/spec/fixtures/exports/case_logs.xml b/spec/fixtures/exports/case_logs.xml index 1e05d6dc7..3d92cb834 100644 --- a/spec/fixtures/exports/case_logs.xml +++ b/spec/fixtures/exports/case_logs.xml @@ -44,7 +44,7 @@ 0 5 3 - 1 + 2 SE26RT 7 2 diff --git a/spec/models/case_log_spec.rb b/spec/models/case_log_spec.rb index 0c751be4e..1267f61e9 100644 --- a/spec/models/case_log_spec.rb +++ b/spec/models/case_log_spec.rb @@ -192,6 +192,7 @@ RSpec.describe CaseLog do describe "derived variables" do let(:organisation) { FactoryBot.create(:organisation, provider_type: "PRP") } + let(:la_organisation) { FactoryBot.create(:organisation, provider_type: "LA") } let!(:case_log) do described_class.create({ managing_organisation: organisation, @@ -602,6 +603,13 @@ RSpec.describe CaseLog do expect(record_from_db["wtcharge"]).to eq(125.0) end + # it "correctly derives and saves landlord based on owning_organisation provider_type" do + # case_log.update!(owning_organisation: la_organisation) + # record_from_db = ActiveRecord::Base.connection.execute("select owning_organisation_id from case_logs where id=#{case_log.id}").to_a[0] + # expect(case_log.landlord).to eq(2) + # expect(record_from_db["landlord"]).to eq(2) + # end + context "when the tenant has an outstanding amount after benefits" do context "when tenant is in receipt of housing benefit" do it "correctly derives and saves weekly total shortfall" do