Browse Source

CLDC-1074: dervied landlord

pull/444/head
kiddhustle 3 years ago
parent
commit
9e04549e09
  1. 3
      app/models/case_log.rb
  2. 1
      db/schema.rb
  3. 2
      spec/fixtures/complete_case_log.json
  4. 2
      spec/fixtures/exports/case_logs.xml
  5. 8
      spec/models/case_log_spec.rb

3
app/models/case_log.rb

@ -413,6 +413,9 @@ private
self.prevten = 30 if managing_organisation.provider_type == "LA" self.prevten = 30 if managing_organisation.provider_type == "LA"
end end
end end
self.landlord = 1 if owning_organisation.provider_type == "PRP"
self.landlord = 2 if owning_organisation.provider_type == "LA"
end end
def process_postcode_changes! def process_postcode_changes!

1
db/schema.rb

@ -319,6 +319,7 @@ ActiveRecord::Schema[7.0].define(version: 202202071123100) do
t.boolean "is_dpo", default: false t.boolean "is_dpo", default: false
t.boolean "is_key_contact", default: false t.boolean "is_key_contact", default: false
t.string "phone" t.string "phone"
t.boolean "is_dpo", default: false
t.index ["email"], name: "index_users_on_email", unique: true t.index ["email"], name: "index_users_on_email", unique: true
t.index ["organisation_id"], name: "index_users_on_organisation_id" t.index ["organisation_id"], name: "index_users_on_organisation_id"
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true

2
spec/fixtures/complete_case_log.json vendored

@ -53,7 +53,7 @@
"startertenancy": 0, "startertenancy": 0,
"tenancylength": 5, "tenancylength": 5,
"tenancy": 3, "tenancy": 3,
"landlord": "This landlord", "landlord": 1,
"la": "Barnet", "la": "Barnet",
"postcode_full": "NW1 5TY", "postcode_full": "NW1 5TY",
"property_relet": 0, "property_relet": 0,

2
spec/fixtures/exports/case_logs.xml vendored

@ -44,7 +44,7 @@
<startertenancy>0</startertenancy> <startertenancy>0</startertenancy>
<tenancylength>5</tenancylength> <tenancylength>5</tenancylength>
<tenancy>3</tenancy> <tenancy>3</tenancy>
<landlord>1</landlord> <landlord>2</landlord>
<ppostcode_full>SE26RT</ppostcode_full> <ppostcode_full>SE26RT</ppostcode_full>
<rsnvac>7</rsnvac> <rsnvac>7</rsnvac>
<unittype_gn>2</unittype_gn> <unittype_gn>2</unittype_gn>

8
spec/models/case_log_spec.rb

@ -192,6 +192,7 @@ RSpec.describe CaseLog do
describe "derived variables" do describe "derived variables" do
let(:organisation) { FactoryBot.create(:organisation, provider_type: "PRP") } let(:organisation) { FactoryBot.create(:organisation, provider_type: "PRP") }
let(:la_organisation) { FactoryBot.create(:organisation, provider_type: "LA") }
let!(:case_log) do let!(:case_log) do
described_class.create({ described_class.create({
managing_organisation: organisation, managing_organisation: organisation,
@ -602,6 +603,13 @@ RSpec.describe CaseLog do
expect(record_from_db["wtcharge"]).to eq(125.0) expect(record_from_db["wtcharge"]).to eq(125.0)
end 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 the tenant has an outstanding amount after benefits" do
context "when tenant is in receipt of housing benefit" do context "when tenant is in receipt of housing benefit" do
it "correctly derives and saves weekly total shortfall" do it "correctly derives and saves weekly total shortfall" do

Loading…
Cancel
Save