Browse Source

Update HB value mappings

pull/385/head
baarkerlounger 3 years ago
parent
commit
7424b048f5
  1. 2
      app/models/case_log.rb
  2. 6
      app/models/validations/financial_validations.rb
  3. 12
      config/forms/2021_2022.json
  4. 2
      spec/factories/case_log.rb
  5. 2
      spec/fixtures/exports/case_logs.xml
  6. 4
      spec/models/case_log_spec.rb
  7. 8
      spec/models/validations/financial_validations_spec.rb

2
app/models/case_log.rb

@ -38,7 +38,7 @@ class CaseLog < ApplicationRecord
OPTIONAL_FIELDS = %w[postcode_known la_known first_time_property_let_as_social_housing tenant_code propcode].freeze
RENT_TYPE_MAPPING = { 0 => 1, 1 => 2, 2 => 2, 3 => 3, 4 => 3, 5 => 3 }.freeze
RENT_TYPE_MAPPING_LABELS = { 1 => "Social Rent", 2 => "Affordable Rent", 3 => "Intermediate Rent" }.freeze
HAS_BENEFITS_OPTIONS = [0, 1, 2, 3].freeze
HAS_BENEFITS_OPTIONS = [1, 6, 8, 7].freeze
STATUS = { "not_started" => 0, "in_progress" => 1, "completed" => 2 }.freeze
NUM_OF_WEEKS_FROM_PERIOD = { 0 => 26, 1 => 13, 2 => 12, 3 => 50, 4 => 49, 5 => 48, 6 => 47, 7 => 46, 8 => 52 }.freeze
enum status: STATUS

6
app/models/validations/financial_validations.rb

@ -51,9 +51,9 @@ module Validations::FinancialValidations
end
def validate_tshortfall(record)
hb_donotknow = record.hb == 5
hb_none = record.hb == 4
hb_uc_no_hb = record.hb == 3
hb_donotknow = record.hb == 3
hb_none = record.hb == 9
hb_uc_no_hb = record.hb == 7
if record.has_hbrentshortfall? && (hb_donotknow || hb_none || hb_uc_no_hb)
record.errors.add :tshortfall, I18n.t("validations.financial.hbrentshortfall.outstanding_no_benefits")

12
config/forms/2021_2022.json

@ -4610,25 +4610,25 @@
"hint_text": "",
"type": "radio",
"answer_options": {
"0": {
"1": {
"value": "Housing benefit"
},
"1": {
"6": {
"value": "Universal Credit with housing element (excluding housing benefit)"
},
"2": {
"8": {
"value": "Housing benefit and Universal Credit (without housing element)"
},
"3": {
"7": {
"value": "Universal Credit (without housing element)"
},
"4": {
"9": {
"value": "None"
},
"divider": {
"value": true
},
"5": {
"3": {
"value": "Don’t know"
},
"6": {

2
spec/factories/case_log.rb

@ -119,7 +119,7 @@ FactoryBot.define do
majorrepairs { 1 }
la { "E09000003" }
prevloc { "E07000105" }
hb { 1 }
hb { 6 }
hbrentshortfall { 0 }
tshortfall { 12 }
postcod2 { "w3" }

2
spec/fixtures/exports/case_logs.xml vendored

@ -97,7 +97,7 @@
<majorrepairs>1</majorrepairs>
<la>E09000003</la>
<prevloc>E07000105</prevloc>
<hb>1</hb>
<hb>6</hb>
<hbrentshortfall>0</hbrentshortfall>
<postcode>NW1</postcode>
<postcod2>5TY</postcod2>

4
spec/models/case_log_spec.rb

@ -200,7 +200,7 @@ RSpec.describe CaseLog do
other_hhmemb: 6,
rent_type: 4,
needstype: 1,
hb: 0,
hb: 1,
hbrentshortfall: 1,
})
end
@ -910,8 +910,6 @@ RSpec.describe CaseLog do
end
it "correctly derives and saves has_benefits" do
case_log.reload
record_from_db = ActiveRecord::Base.connection.execute("select has_benefits from case_logs where id=#{case_log.id}").to_a[0]
expect(record_from_db["has_benefits"]).to eq(1)
end

8
spec/models/validations/financial_validations_spec.rb

@ -90,7 +90,7 @@ RSpec.describe Validations::FinancialValidations do
context "when shortfall is yes" do
it "validates that housing benefit is not none" do
record.hbrentshortfall = 0
record.hb = 4
record.hb = 9
financial_validator.validate_tshortfall(record)
expect(record.errors["tshortfall"])
.to include(match I18n.t("validations.financial.hbrentshortfall.outstanding_no_benefits"))
@ -98,7 +98,7 @@ RSpec.describe Validations::FinancialValidations do
it "validates that housing benefit is not don't know" do
record.hbrentshortfall = 0
record.hb = 5
record.hb = 3
financial_validator.validate_tshortfall(record)
expect(record.errors["tshortfall"])
.to include(match I18n.t("validations.financial.hbrentshortfall.outstanding_no_benefits"))
@ -106,7 +106,7 @@ RSpec.describe Validations::FinancialValidations do
it "validates that housing benefit is not Universal Credit without housing benefit" do
record.hbrentshortfall = 0
record.hb = 3
record.hb = 7
financial_validator.validate_tshortfall(record)
expect(record.errors["tshortfall"])
.to include(match I18n.t("validations.financial.hbrentshortfall.outstanding_no_benefits"))
@ -114,7 +114,7 @@ RSpec.describe Validations::FinancialValidations do
it "validates that housing benefit is provided" do
record.hbrentshortfall = 0
record.hb = 0
record.hb = 1
financial_validator.validate_tshortfall(record)
expect(record.errors["tshortfall"]).to be_empty
end

Loading…
Cancel
Save