Browse Source

Derive ecstat if age is under 16

pull/446/head
baarkerlounger 3 years ago
parent
commit
7d73fdea48
  1. 7
      app/models/case_log.rb
  2. 11
      spec/models/case_log_spec.rb

7
app/models/case_log.rb

@ -425,6 +425,13 @@ private
self.prevten = 30 if managing_organisation.provider_type == "LA"
end
end
(2..8).each do |idx|
if public_send("age#{idx}") && public_send("age#{idx}") < 16
self["ecstat#{idx}"] = 9
elsif public_send("ecstat#{idx}") == 9 && (public_send("age#{idx}").nil? || public_send("age#{idx}") >= 16)
self["ecstat#{idx}"] = nil
end
end
end
def process_postcode_changes!

11
spec/models/case_log_spec.rb

@ -1372,6 +1372,17 @@ RSpec.describe CaseLog do
record_from_db = ActiveRecord::Base.connection.execute("select totadult from case_logs where id=#{household_case_log.id}").to_a[0]
expect(record_from_db["totadult"]).to eq(3)
end
it "correctly derives economic status for tenants under 16" do
record_from_db = ActiveRecord::Base.connection.execute("select ecstat7 from case_logs where id=#{household_case_log.id}").to_a[0]
expect(record_from_db["ecstat7"]).to eq(9)
end
it "correctly resets economic status when age changes from under 16" do
household_case_log.update!(age7: 17)
record_from_db = ActiveRecord::Base.connection.execute("select ecstat7 from case_logs where id=#{household_case_log.id}").to_a[0]
expect(record_from_db["ecstat7"]).to eq(nil)
end
end
it "correctly derives and saves has_benefits" do

Loading…
Cancel
Save