diff --git a/app/models/case_log.rb b/app/models/case_log.rb
index bfcf09913..11b22da07 100644
--- a/app/models/case_log.rb
+++ b/app/models/case_log.rb
@@ -142,8 +142,9 @@ class CaseLog < ApplicationRecord
enum nocharge: POLAR, _suffix: true
enum referral: REFERRAL, _suffix: true
enum declaration: POLAR, _suffix: true
+ enum providertype: PROVIDER_TYPE, _suffix: true
- AUTOGENERATED_FIELDS = %w[id status created_at updated_at discarded_at].freeze
+ AUTOGENERATED_FIELDS = %w[id status created_at updated_at discarded_at providertype].freeze
def form
FormHandler.instance.get_form(form_name)
@@ -255,6 +256,7 @@ private
self.layear = "Less than 1 year" if renewal == "Yes"
self.underoccupation_benefitcap = "No" if renewal == "Yes" && year == 2021
self.homeless = "No" if renewal == "Yes"
+ self.providertype = owning_organisation.provider_type
end
def process_postcode_changes!
diff --git a/app/models/constants/case_log.rb b/app/models/constants/case_log.rb
index 3a2593314..9efd889fd 100644
--- a/app/models/constants/case_log.rb
+++ b/app/models/constants/case_log.rb
@@ -1125,4 +1125,9 @@ module Constants::CaseLog
"Other"].freeze
OPTIONAL_FIELDS = %w[postcode_known la_known first_time_property_let_as_social_housing tenant_code propcode].freeze
+
+ PROVIDER_TYPE = {
+ "LA" => 1,
+ "PRP" => 2,
+ }.freeze
end
diff --git a/db/migrate/20220209164758_add_providertype.rb b/db/migrate/20220209164758_add_providertype.rb
new file mode 100644
index 000000000..1a0fe8a91
--- /dev/null
+++ b/db/migrate/20220209164758_add_providertype.rb
@@ -0,0 +1,7 @@
+class AddProvidertype < ActiveRecord::Migration[7.0]
+ def change
+ change_table :case_logs, bulk: true do |t|
+ t.column :providertype, :integer
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 891c11299..b64253b2c 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,8 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 202202071123100) do
-
+ActiveRecord::Schema[7.0].define(version: 202202071123100) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -21,8 +20,8 @@ ActiveRecord::Schema.define(version: 202202071123100) do
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
- t.datetime "created_at", precision: 6, null: false
- t.datetime "updated_at", precision: 6, null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.integer "second_factor_attempts_count", default: 0
t.string "encrypted_otp_secret_key"
t.string "encrypted_otp_secret_key_iv"
@@ -36,8 +35,8 @@ ActiveRecord::Schema.define(version: 202202071123100) do
create_table "case_logs", force: :cascade do |t|
t.integer "status", default: 0
- t.datetime "created_at", precision: 6, null: false
- t.datetime "updated_at", precision: 6, null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.string "tenant_code"
t.integer "age1"
t.string "sex1"
@@ -191,6 +190,7 @@ ActiveRecord::Schema.define(version: 202202071123100) do
t.decimal "tshortfall", precision: 10, scale: 2
t.decimal "chcharge", precision: 10, scale: 2
t.integer "declaration"
+ t.integer "providertype"
t.index ["managing_organisation_id"], name: "index_case_logs_on_managing_organisation_id"
t.index ["owning_organisation_id"], name: "index_case_logs_on_owning_organisation_id"
end
@@ -206,8 +206,8 @@ ActiveRecord::Schema.define(version: 202202071123100) do
t.boolean "holds_own_stock"
t.string "other_stock_owners"
t.string "managing_agents"
- t.datetime "created_at", precision: 6, null: false
- t.datetime "updated_at", precision: 6, null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.boolean "active"
t.integer "old_association_type"
t.string "software_supplier_id"
@@ -233,8 +233,8 @@ ActiveRecord::Schema.define(version: 202202071123100) do
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
- t.datetime "created_at", precision: 6, null: false
- t.datetime "updated_at", precision: 6, null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.string "name"
t.bigint "organisation_id"
t.integer "sign_in_count", default: 0, null: false
@@ -256,7 +256,7 @@ ActiveRecord::Schema.define(version: 202202071123100) do
t.string "event", null: false
t.string "whodunnit"
t.text "object"
- t.datetime "created_at", precision: 6
+ t.datetime "created_at"
t.index ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id"
end
diff --git a/spec/fixtures/exports/case_logs.xml b/spec/fixtures/exports/case_logs.xml
index 6653465bb..79810cc89 100644
--- a/spec/fixtures/exports/case_logs.xml
+++ b/spec/fixtures/exports/case_logs.xml
@@ -158,6 +158,7 @@