|
|
@ -133,7 +133,7 @@ class CaseLog < ApplicationRecord |
|
|
|
enum postcode_known: POLAR, _suffix: true |
|
|
|
enum postcode_known: POLAR, _suffix: true |
|
|
|
enum la_known: POLAR, _suffix: true |
|
|
|
enum la_known: POLAR, _suffix: true |
|
|
|
|
|
|
|
|
|
|
|
AUTOGENERATED_FIELDS = %w[id status created_at updated_at discarded_at renttype lettype is_la_inferred totchild totelder].freeze |
|
|
|
AUTOGENERATED_FIELDS = %w[id status created_at updated_at discarded_at renttype lettype is_la_inferred totchild totelder totadult].freeze |
|
|
|
OPTIONAL_FIELDS = %w[postcode_known |
|
|
|
OPTIONAL_FIELDS = %w[postcode_known |
|
|
|
la_known |
|
|
|
la_known |
|
|
|
first_time_property_let_as_social_housing].freeze |
|
|
|
first_time_property_let_as_social_housing].freeze |
|
|
@ -215,6 +215,7 @@ private |
|
|
|
self.la = get_la(property_postcode) |
|
|
|
self.la = get_la(property_postcode) |
|
|
|
self.totchild = get_totchild |
|
|
|
self.totchild = get_totchild |
|
|
|
self.totelder = get_totelder |
|
|
|
self.totelder = get_totelder |
|
|
|
|
|
|
|
self.totadult = get_totadult |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def get_totelder |
|
|
|
def get_totelder |
|
|
@ -227,6 +228,17 @@ private |
|
|
|
relationships.count("Child - includes young adult and grown-up") |
|
|
|
relationships.count("Child - includes young adult and grown-up") |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_totadult |
|
|
|
|
|
|
|
total = !age1.nil? && age1 >= 16 && age1 < 60 ? 1 : 0 |
|
|
|
|
|
|
|
total + (2..8).count do |i| |
|
|
|
|
|
|
|
# rubocop:disable Style/EvalWithLocation, Security/Eval:: |
|
|
|
|
|
|
|
age = eval("age#{i}") |
|
|
|
|
|
|
|
relat = eval("relat#{i}") |
|
|
|
|
|
|
|
# rubocop:enable Style/EvalWithLocation, Security/Eval:: |
|
|
|
|
|
|
|
!age.nil? && ((age >= 16 && age < 18 && %w[Partner Other].include?(relat)) || age >= 18 && age < 60) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def get_la(postcode) |
|
|
|
def get_la(postcode) |
|
|
|
if postcode.present? |
|
|
|
if postcode.present? |
|
|
|
postcode_lookup = PIO.lookup(postcode) |
|
|
|
postcode_lookup = PIO.lookup(postcode) |
|
|
|