From 7424b048f56ae913a296f76e28101fedc1668308 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Mon, 14 Mar 2022 13:26:27 +0000 Subject: [PATCH] Update HB value mappings --- app/models/case_log.rb | 2 +- app/models/validations/financial_validations.rb | 6 +++--- config/forms/2021_2022.json | 12 ++++++------ spec/factories/case_log.rb | 2 +- spec/fixtures/exports/case_logs.xml | 2 +- spec/models/case_log_spec.rb | 4 +--- .../models/validations/financial_validations_spec.rb | 8 ++++---- 7 files changed, 17 insertions(+), 19 deletions(-) diff --git a/app/models/case_log.rb b/app/models/case_log.rb index 1a66ee7eb..a1d7a28ea 100644 --- a/app/models/case_log.rb +++ b/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 diff --git a/app/models/validations/financial_validations.rb b/app/models/validations/financial_validations.rb index 75f1e475d..7721ce9f7 100644 --- a/app/models/validations/financial_validations.rb +++ b/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") diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json index 3e74fd27a..9c19c9cd2 100644 --- a/config/forms/2021_2022.json +++ b/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": { diff --git a/spec/factories/case_log.rb b/spec/factories/case_log.rb index a7d9eb49a..1c2d41850 100644 --- a/spec/factories/case_log.rb +++ b/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" } diff --git a/spec/fixtures/exports/case_logs.xml b/spec/fixtures/exports/case_logs.xml index 0b6039cc9..63cfe21fe 100644 --- a/spec/fixtures/exports/case_logs.xml +++ b/spec/fixtures/exports/case_logs.xml @@ -97,7 +97,7 @@ 1 E09000003 E07000105 - 1 + 6 0 NW1 5TY diff --git a/spec/models/case_log_spec.rb b/spec/models/case_log_spec.rb index dd28b3cf0..a70aecc7b 100644 --- a/spec/models/case_log_spec.rb +++ b/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 diff --git a/spec/models/validations/financial_validations_spec.rb b/spec/models/validations/financial_validations_spec.rb index 7528bef98..d75df4f91 100644 --- a/spec/models/validations/financial_validations_spec.rb +++ b/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