Browse Source

CLDC-959: add multiple tenant flow

pull/320/head
kiddhustle 3 years ago
parent
commit
7c228417a8
  1. 1
      app/models/case_log.rb
  2. 10
      app/services/exports/case_log_export_service.rb
  3. 4
      app/views/form/page.html.erb
  4. 1080
      config/forms/2021_2022.json
  5. 14
      db/migrate/20220211155138_add_age_known_to_case_logs.rb
  6. 5
      db/migrate/20220215123519_add_ethnic_group.rb
  7. 5
      db/migrate/20220215142327_add_ethnic_other.rb
  8. 13
      db/migrate/20220216114345_add_details_known_to_case_logs.rb
  9. 35
      db/schema.rb
  10. 19
      spec/fixtures/exports/case_logs.xml

1
app/models/case_log.rb

@ -297,6 +297,7 @@ private
self.has_benefits = get_has_benefits
self.nocharge = household_charge&.zero? ? 1 : 0
self.underoccupation_benefitcap = 3 if renewal == 1 && year == 2021
self.ethnic = ethnic || ethnic_group
if is_renewal?
self.homeless = 2
self.referral = 0

10
app/services/exports/case_log_export_service.rb

@ -36,6 +36,12 @@ module Exports
@storage_service.write_file(file_path, string_io)
end
def is_omitted_field?(field_name)
omitted_attrs = %w[ethnic_group]
pattern_age = /age\d_known/
field_name.starts_with?("details_known_") || pattern_age.match(field_name) || omitted_attrs.include?(field_name) ? true : false
end
private
def retrieve_case_logs
@ -50,10 +56,14 @@ module Exports
form = doc.create_element("form")
doc.at("forms") << form
case_log.attributes.each do |key, _|
if is_omitted_field?(key)
next
else
value = case_log.read_attribute_before_type_cast(key)
form << doc.create_element(key, value)
end
end
end
doc.write_xml_to(StringIO.new, encoding: "UTF-8")
end

4
app/views/form/page.html.erb

@ -48,9 +48,9 @@
<%= f.hidden_field :page, value: @page.id %>
<% if @case_log.form.is_last_question?(@page, @subsection, @case_log) %>
<%= f.govuk_submit "Submit lettings log" %>
<%= f.govuk_submit "Submit lettings log", accesskey: "s" %>
<%else %>
<%= f.govuk_submit "Save and continue" %>
<%= f.govuk_submit "Save and continue", accesskey: "s" %>
<%end %>
</div>
</div>

1080
config/forms/2021_2022.json

File diff suppressed because it is too large Load Diff

14
db/migrate/20220211155138_add_age_known_to_case_logs.rb

@ -0,0 +1,14 @@
class AddAgeKnownToCaseLogs < ActiveRecord::Migration[7.0]
def change
change_table :case_logs, bulk: true do |t|
t.column :age1_known, :integer
t.column :age2_known, :integer
t.column :age3_known, :integer
t.column :age4_known, :integer
t.column :age5_known, :integer
t.column :age6_known, :integer
t.column :age7_known, :integer
t.column :age8_known, :integer
end
end
end

5
db/migrate/20220215123519_add_ethnic_group.rb

@ -0,0 +1,5 @@
class AddEthnicGroup < ActiveRecord::Migration[7.0]
def change
add_column :case_logs, :ethnic_group, :integer
end
end

5
db/migrate/20220215142327_add_ethnic_other.rb

@ -0,0 +1,5 @@
class AddEthnicOther < ActiveRecord::Migration[7.0]
def change
add_column :case_logs, :ethnic_other, :string
end
end

13
db/migrate/20220216114345_add_details_known_to_case_logs.rb

@ -0,0 +1,13 @@
class AddDetailsKnownToCaseLogs < ActiveRecord::Migration[7.0]
def change
change_table :case_logs, bulk: true do |t|
t.column :details_known_2, :integer
t.column :details_known_3, :integer
t.column :details_known_4, :integer
t.column :details_known_5, :integer
t.column :details_known_6, :integer
t.column :details_known_7, :integer
t.column :details_known_8, :integer
end
end
end

35
db/schema.rb

@ -45,24 +45,32 @@ ActiveRecord::Schema[7.0].define(version: 202202071123100) do
t.datetime "updated_at", null: false
t.string "tenant_code"
t.integer "age1"
t.string "sex1"
t.integer "ethnic"
t.integer "national"
t.integer "prevten"
t.integer "ecstat1"
t.integer "hhmemb"
t.integer "age2"
t.string "sex2"
t.integer "ecstat2"
t.integer "age3"
t.string "sex3"
t.integer "ecstat3"
t.integer "age4"
t.string "sex4"
t.integer "ecstat4"
t.integer "age5"
t.string "sex5"
t.integer "ecstat5"
t.integer "age6"
t.string "sex6"
t.integer "ecstat6"
t.integer "age7"
t.string "sex7"
t.integer "ecstat7"
t.integer "age8"
t.string "sex8"
t.integer "ecstat8"
t.integer "homeless"
t.integer "underoccupation_benefitcap"
@ -149,6 +157,7 @@ ActiveRecord::Schema[7.0].define(version: 202202071123100) do
t.datetime "property_void_date", precision: nil
t.bigint "owning_organisation_id"
t.bigint "managing_organisation_id"
t.integer "renttype"
t.integer "needstype"
t.integer "lettype"
t.integer "postcode_known"
@ -177,16 +186,24 @@ ActiveRecord::Schema[7.0].define(version: 202202071123100) do
t.integer "previous_postcode_known"
t.integer "previous_la_known"
t.boolean "is_previous_la_inferred"
t.integer "age1_known"
t.integer "age2_known"
t.integer "age3_known"
t.integer "age4_known"
t.integer "age5_known"
t.integer "age6_known"
t.integer "age7_known"
t.integer "age8_known"
t.integer "ethnic_group"
t.string "ethnic_other"
t.integer "letting_allocation_unknown"
t.integer "renttype"
t.string "sex1"
t.string "sex2"
t.string "sex3"
t.string "sex4"
t.string "sex5"
t.string "sex6"
t.string "sex7"
t.string "sex8"
t.integer "details_known_2"
t.integer "details_known_3"
t.integer "details_known_4"
t.integer "details_known_5"
t.integer "details_known_6"
t.integer "details_known_7"
t.integer "details_known_8"
t.integer "relat2"
t.integer "relat3"
t.integer "relat4"

19
spec/fixtures/exports/case_logs.xml vendored

@ -7,24 +7,32 @@
<updated_at>2022-02-08 16:52:15 UTC</updated_at>
<tenant_code>BZ737</tenant_code>
<age1>35</age1>
<sex1>F</sex1>
<ethnic>2</ethnic>
<national>4</national>
<prevten>2</prevten>
<ecstat1>0</ecstat1>
<hhmemb>2</hhmemb>
<age2>32</age2>
<sex2>M</sex2>
<ecstat2>5</ecstat2>
<age3/>
<sex3/>
<ecstat3/>
<age4/>
<sex4/>
<ecstat4/>
<age5/>
<sex5/>
<ecstat5/>
<age6/>
<sex6/>
<ecstat6/>
<age7/>
<sex7/>
<ecstat7/>
<age8/>
<sex8/>
<ecstat8/>
<homeless>1</homeless>
<underoccupation_benefitcap>0</underoccupation_benefitcap>
@ -111,6 +119,7 @@
<property_void_date>2019-11-03 00:00:00 UTC</property_void_date>
<owning_organisation_id>{owning_org_id}</owning_organisation_id>
<managing_organisation_id>{managing_org_id}</managing_organisation_id>
<renttype>2</renttype>
<needstype>1</needstype>
<lettype>5</lettype>
<postcode_known>1</postcode_known>
@ -139,16 +148,8 @@
<previous_postcode_known>1</previous_postcode_known>
<previous_la_known/>
<is_previous_la_inferred>false</is_previous_la_inferred>
<ethnic_other/>
<letting_allocation_unknown/>
<renttype>2</renttype>
<sex1>F</sex1>
<sex2>M</sex2>
<sex3/>
<sex4/>
<sex5/>
<sex6/>
<sex7/>
<sex8/>
<relat2>0</relat2>
<relat3/>
<relat4/>

Loading…
Cancel
Save