From 780f0892c48cdf157b46d55793c4f6cf0dfc4fcf Mon Sep 17 00:00:00 2001 From: Ted Date: Fri, 29 Apr 2022 12:00:24 +0100 Subject: [PATCH 1/3] Fix other reason for leaving last settled validation --- app/models/validations/household_validations.rb | 2 +- spec/models/validations/household_validations_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/validations/household_validations.rb b/app/models/validations/household_validations.rb index 5d0f52037..34f5f5862 100644 --- a/app/models/validations/household_validations.rb +++ b/app/models/validations/household_validations.rb @@ -18,7 +18,7 @@ module Validations::HouseholdValidations record.errors.add :underoccupation_benefitcap, I18n.t("validations.household.underoccupation_benefitcap.dont_know_required") record.errors.add :reason, I18n.t("validations.household.underoccupation_benefitcap.dont_know_required") end - validate_other_field(record, 31, :reason, :reasonother) + validate_other_field(record, 20, :reason, :reasonother) if record.is_reason_permanently_decanted? && record.referral.present? && !record.is_internal_transfer? record.errors.add :referral, I18n.t("validations.household.referral.reason_permanently_decanted") diff --git a/spec/models/validations/household_validations_spec.rb b/spec/models/validations/household_validations_spec.rb index 6fdf72dc9..8d33a44f4 100644 --- a/spec/models/validations/household_validations_spec.rb +++ b/spec/models/validations/household_validations_spec.rb @@ -120,7 +120,7 @@ RSpec.describe Validations::HouseholdValidations do let(:field) { "validations.other_field_missing" } it "validates that a reason is provided" do - record.reason = 31 + record.reason = 20 record.reasonother = nil household_validator.validate_reason_for_leaving_last_settled_home(record) expect(record.errors["reasonother"]) @@ -128,7 +128,7 @@ RSpec.describe Validations::HouseholdValidations do end it "expects that a reason is provided" do - record.reason = 31 + record.reason = 20 record.reasonother = "Some unusual reason" household_validator.validate_reason_for_leaving_last_settled_home(record) expect(record.errors["reasonother"]).to be_empty From 23fe2bb219a58abbb93178ab226552cc384de9f4 Mon Sep 17 00:00:00 2001 From: Ted Date: Fri, 29 Apr 2022 16:02:25 +0100 Subject: [PATCH 2/3] Log old id --- app/models/validations/household_validations.rb | 16 ++++++++++++++++ app/services/imports/case_logs_import_service.rb | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/models/validations/household_validations.rb b/app/models/validations/household_validations.rb index 34f5f5862..21944be2a 100644 --- a/app/models/validations/household_validations.rb +++ b/app/models/validations/household_validations.rb @@ -87,6 +87,22 @@ module Validations::HouseholdValidations record.errors.add :sex1, I18n.t("validations.household.gender.male_refuge") end + # 3 Private Sector Tenancy + # 4 Tied housing or rented with job + # 7 Direct access hostel + # 9 Residential care home + # 10 Hospital + # 13 Children's home / Foster Care + # 14 Bed and breakfast + # 19 Rough Sleeping + # 21 Refuge + # 23 Mobile home / Caravan + # 24 Home Office Asylum Support + # 25 Other + # 26 Owner Occupation + # 27 Owner occupation (low-cost home ownership) + # 28 Living with Friends or Family + # 29 Prison / Approved Probation Hostel if record.is_internal_transfer? && [3, 4, 7, 9, 10, 13, 14, 19, 21, 23, 24, 25, 26, 27, 28, 29].include?(record.prevten) label = record.form.get_question("prevten", record).present? ? record.form.get_question("prevten", record).label_from_value(record.prevten) : "" record.errors.add :prevten, I18n.t("validations.household.prevten.internal_transfer", prevten: label) diff --git a/app/services/imports/case_logs_import_service.rb b/app/services/imports/case_logs_import_service.rb index ab0f41d71..99b9f9ee9 100644 --- a/app/services/imports/case_logs_import_service.rb +++ b/app/services/imports/case_logs_import_service.rb @@ -201,7 +201,7 @@ module Imports differences.push("#{key} #{value.inspect} #{case_log_value.inspect}") end end - @logger.warn "Differences found when saving log #{case_log.id}: #{differences}" unless differences.empty? + @logger.warn "Differences found when saving log #{case_log.old_id}: #{differences}" unless differences.empty? end def check_status_completed(case_log, previous_status) From d762f4ac05bc6f9cd59ba46d4b2a1e0dea1dc68a Mon Sep 17 00:00:00 2001 From: Ted Date: Fri, 29 Apr 2022 16:22:26 +0100 Subject: [PATCH 3/3] derive if ethnic has been refused from ethnic group --- app/models/case_log.rb | 5 +++++ app/services/imports/case_logs_import_service.rb | 2 +- .../case_logs/0ead17cb-1668-442d-898c-0d52879ff592.xml | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/models/case_log.rb b/app/models/case_log.rb index 5c82b93d5..252b6e360 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -320,6 +320,10 @@ class CaseLog < ApplicationRecord hb == 7 end + def ethnic_refused? + ethnic_group == 17 + end + def receives_housing_related_benefits? receives_housing_benefit_only? || receives_uc_with_housing_element_excl_housing_benefit? || receives_housing_benefit_and_universal_credit? @@ -435,6 +439,7 @@ private self.totelder = get_totelder self.totadult = get_totadult self.refused = get_refused + self.ethnic = 17 if ethnic_refused? if %i[brent scharge pscharge supcharg].any? { |f| public_send(f).present? } self.brent ||= 0 self.scharge ||= 0 diff --git a/app/services/imports/case_logs_import_service.rb b/app/services/imports/case_logs_import_service.rb index 99b9f9ee9..be1605d86 100644 --- a/app/services/imports/case_logs_import_service.rb +++ b/app/services/imports/case_logs_import_service.rb @@ -428,7 +428,7 @@ module Imports 4 when 17 # Refused - 5 + 17 end end diff --git a/spec/fixtures/softwire_imports/case_logs/0ead17cb-1668-442d-898c-0d52879ff592.xml b/spec/fixtures/softwire_imports/case_logs/0ead17cb-1668-442d-898c-0d52879ff592.xml index 34ccc8e12..9bf6b5a87 100644 --- a/spec/fixtures/softwire_imports/case_logs/0ead17cb-1668-442d-898c-0d52879ff592.xml +++ b/spec/fixtures/softwire_imports/case_logs/0ead17cb-1668-442d-898c-0d52879ff592.xml @@ -52,7 +52,7 @@ Female 6) Not Seeking Work - 1 White: English/Scottish/Welsh/Northern Irish/British + 17 Refused 1 UK national resident in UK 2