Browse Source

Update needstype values in our JSON form

pull/470/head
Stéphane Meny 3 years ago
parent
commit
8162768cf3
No known key found for this signature in database
GPG Key ID: 9D0AFEA988527923
  1. 4
      app/models/case_log.rb
  2. 2
      app/models/validations/financial_validations.rb
  3. 48
      config/forms/2021_2022.json
  4. 2
      spec/fixtures/exports/case_logs.xml
  5. 14
      spec/models/case_log_spec.rb
  6. 4
      spec/models/validations/financial_validations_spec.rb

4
app/models/case_log.rb

@ -161,8 +161,8 @@ class CaseLog < ApplicationRecord
end
def is_supported_housing?
# 0: Supported Housing
!!needstype&.zero?
# 2: Supported Housing
needstype == 2
end
def has_hbrentshortfall?

2
app/models/validations/financial_validations.rb

@ -116,7 +116,7 @@ private
}.freeze
LANDLORD_VALUES = { 1 => :this_landlord, 2 => :other_landlord }.freeze
NEEDSTYPE_VALUES = { 0 => :supported_housing, 1 => :general_needs }.freeze
NEEDSTYPE_VALUES = { 2 => :supported_housing, 1 => :general_needs }.freeze
def validate_charges(record)
%i[scharge pscharge supcharg].each do |charge|

48
config/forms/2021_2022.json

@ -22,7 +22,7 @@
"1": {
"value": "General needs"
},
"0": {
"2": {
"value": "Supported housing"
}
}
@ -1090,7 +1090,7 @@
},
"depends_on": [
{
"needstype": 0
"needstype": 2
}
]
}
@ -3587,7 +3587,7 @@
"depends_on": [
{
"renewal": 1,
"needstype": 0
"needstype": 2
}
]
},
@ -4383,7 +4383,7 @@
"depends_on": [
{
"managing_organisation.provider_type": "LA",
"needstype": 0,
"needstype": 2,
"renewal": 0
}
]
@ -4443,7 +4443,7 @@
"depends_on": [
{
"managing_organisation.provider_type": "PRP",
"needstype": 0,
"needstype": 2,
"renewal": 0
}
]
@ -4658,7 +4658,7 @@
},
"depends_on": [
{
"needstype": 0
"needstype": 2
}
]
},
@ -4748,62 +4748,62 @@
"depends_on": [
{
"period": 1,
"needstype": 0,
"needstype": 2,
"household_charge": 0
},
{
"period": 1,
"needstype": 0,
"needstype": 2,
"household_charge": null
},
{
"period": 5,
"needstype": 0,
"needstype": 2,
"household_charge": 0
},
{
"period": 5,
"needstype": 0,
"needstype": 2,
"household_charge": null
},
{
"period": 6,
"needstype": 0,
"needstype": 2,
"household_charge": 0
},
{
"period": 6,
"needstype": 0,
"needstype": 2,
"household_charge": null
},
{
"period": 7,
"needstype": 0,
"needstype": 2,
"household_charge": 0
},
{
"period": 7,
"needstype": 0,
"needstype": 2,
"household_charge": null
},
{
"period": 8,
"needstype": 0,
"needstype": 2,
"household_charge": 0
},
{
"period": 8,
"needstype": 0,
"needstype": 2,
"household_charge": null
},
{
"period": 9,
"needstype": 0,
"needstype": 2,
"household_charge": 0
},
{
"period": 9,
"needstype": 0,
"needstype": 2,
"household_charge": null
}
]
@ -4845,12 +4845,12 @@
"depends_on": [
{
"period": 2,
"needstype": 0,
"needstype": 2,
"household_charge": 0
},
{
"period": 2,
"needstype": 0,
"needstype": 2,
"household_charge": null
}
]
@ -4892,12 +4892,12 @@
"depends_on": [
{
"period": 3,
"needstype": 0,
"needstype": 2,
"household_charge": 0
},
{
"period": 3,
"needstype": 0,
"needstype": 2,
"household_charge": null
}
]
@ -4939,12 +4939,12 @@
"depends_on": [
{
"period": 4,
"needstype": 0,
"needstype": 2,
"household_charge": 0
},
{
"period": 4,
"needstype": 0,
"needstype": 2,
"household_charge": null
}
]

2
spec/fixtures/exports/case_logs.xml vendored

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

14
spec/models/case_log_spec.rb

@ -255,7 +255,7 @@ RSpec.describe CaseLog do
before { case_log.owning_organisation.update!(provider_type: 2) }
context "when the rent type is intermediate rent and supported housing" do
it "correctly derives and saves lettype" do
case_log.update!(rent_type: 4, needstype: 0)
case_log.update!(rent_type: 4, needstype: 2)
record_from_db = ActiveRecord::Base.connection.execute("select lettype from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.lettype).to eq(10)
expect(record_from_db["lettype"]).to eq(10)
@ -273,7 +273,7 @@ RSpec.describe CaseLog do
context "when the rent type is affordable rent and supported housing" do
it "correctly derives and saves lettype" do
case_log.update!(rent_type: 2, needstype: 0)
case_log.update!(rent_type: 2, needstype: 2)
record_from_db = ActiveRecord::Base.connection.execute("select lettype from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.lettype).to eq(6)
expect(record_from_db["lettype"]).to eq(6)
@ -291,7 +291,7 @@ RSpec.describe CaseLog do
context "when the rent type is social rent and supported housing" do
it "correctly derives and saves lettype" do
case_log.update!(rent_type: 0, needstype: 0)
case_log.update!(rent_type: 0, needstype: 2)
record_from_db = ActiveRecord::Base.connection.execute("select lettype from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.lettype).to eq(2)
expect(record_from_db["lettype"]).to eq(2)
@ -1051,7 +1051,7 @@ RSpec.describe CaseLog do
context "when the rent type is intermediate rent and supported housing" do
it "correctly derives and saves lettype" do
case_log.update!(rent_type: 4, needstype: 0)
case_log.update!(rent_type: 4, needstype: 2)
record_from_db = ActiveRecord::Base.connection.execute("select lettype from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.lettype).to eq(12)
expect(record_from_db["lettype"]).to eq(12)
@ -1069,7 +1069,7 @@ RSpec.describe CaseLog do
context "when the rent type is affordable rent and supported housing" do
it "correctly derives and saves lettype" do
case_log.update!(rent_type: 2, needstype: 0)
case_log.update!(rent_type: 2, needstype: 2)
record_from_db = ActiveRecord::Base.connection.execute("select lettype from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.lettype).to eq(8)
expect(record_from_db["lettype"]).to eq(8)
@ -1087,7 +1087,7 @@ RSpec.describe CaseLog do
context "when the rent type is social rent and supported housing" do
it "correctly derives and saves lettype" do
case_log.update!(rent_type: 0, needstype: 0)
case_log.update!(rent_type: 0, needstype: 2)
record_from_db = ActiveRecord::Base.connection.execute("select lettype from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.lettype).to eq(4)
expect(record_from_db["lettype"]).to eq(4)
@ -1477,7 +1477,7 @@ RSpec.describe CaseLog do
described_class.create({
managing_organisation: owning_organisation,
owning_organisation:,
needstype: 0,
needstype: 2,
})
end

4
spec/models/validations/financial_validations_spec.rb

@ -301,7 +301,7 @@ RSpec.describe Validations::FinancialValidations do
context "when needstype is supported housing" do
before do
record.needstype = 0
record.needstype = 2
record.landlord = 1
end
@ -497,7 +497,7 @@ RSpec.describe Validations::FinancialValidations do
context "when needstype is supported housing" do
before do
record.needstype = 0
record.needstype = 2
record.landlord = 2
end

Loading…
Cancel
Save