Browse Source

Merge pull request #537 from communitiesuk/import_fixes

Import Fixes
pull/539/head
baarkerlounger 3 years ago committed by GitHub
parent
commit
405d8be3ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      app/models/case_log.rb
  2. 18
      app/models/validations/household_validations.rb
  3. 4
      app/services/imports/case_logs_import_service.rb
  4. 2
      spec/fixtures/softwire_imports/case_logs/0ead17cb-1668-442d-898c-0d52879ff592.xml
  5. 4
      spec/models/validations/household_validations_spec.rb

5
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

18
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")
@ -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)

4
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)
@ -428,7 +428,7 @@ module Imports
4
when 17
# Refused
5
17
end
end

2
spec/fixtures/softwire_imports/case_logs/0ead17cb-1668-442d-898c-0d52879ff592.xml vendored

@ -52,7 +52,7 @@
<P1AR/>
<P1Sex override-field="">Female</P1Sex>
<P1Eco>6) Not Seeking Work</P1Eco>
<P1Eth>1 White: English/Scottish/Welsh/Northern Irish/British</P1Eth>
<P1Eth>17 Refused</P1Eth>
<P1Nat>1 UK national resident in UK</P1Nat>
<P2Age override-field="">2</P2Age>
<P2AR/>

4
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

Loading…
Cancel
Save