Browse Source

Add postcode fields to Sales Logs

CLDC-1468-add-postcode-to-sales-property-info-journey
Mo Seedat 2 years ago
parent
commit
b0f2f902ab
  1. 16
      app/models/form/sales/pages/property_postcode.rb
  2. 11
      app/models/form/sales/questions/postcode_full.rb
  3. 24
      app/models/form/sales/questions/property_postcode.rb
  4. 1
      app/models/form/sales/subsections/property_information.rb
  5. 15
      app/models/form/sales/subsections/property_postcode.rb
  6. 10
      db/migrate/20221018221143_add_postcode_to_sales_log.rb
  7. 40
      db/schema.rb

16
app/models/form/sales/pages/property_postcode.rb

@ -0,0 +1,16 @@
class Form::Sales::Pages::PropertyPostcode < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "property_postcode"
@header = ""
@description = ""
@subsection = subsection
end
def questions
@questions ||= [
Form::Sales::Questions::PropertyPostcode.new(nil, nil, self),
Form::Sales::Questions::PostcodeFull.new(nil, nil, self),
]
end
end

11
app/models/form/sales/questions/postcode_full.rb

@ -0,0 +1,11 @@
class Form::Sales::Questions::PostcodeFull < ::Form::Question
def initialize(id, hsh, page)
super
@id = "postcode_full"
@check_answer_label = "Property full postcode!!!"
@header = "The Full Postcode outer inner"
@type = "text"
@page = page
@width = 10
end
end

24
app/models/form/sales/questions/property_postcode.rb

@ -0,0 +1,24 @@
class Form::Sales::Questions::PropertyPostcode < ::Form::Question
def initialize(id, hsh, page)
super
@id = "pcodenk"
@check_answer_label = "Postcode"
@header = "Do you know the property's postcode?"
@hint_text = ""
@type = "radio"
@answer_options = ANSWER_OPTIONS
@width = 10
@page = page
@conditional_for = {
"postcode_full" => [0],
}
end
ANSWER_OPTIONS = {
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
}.freeze
end
#"sales-log-postcode-full-field"

1
app/models/form/sales/subsections/property_information.rb

@ -12,6 +12,7 @@ class Form::Sales::Subsections::PropertyInformation < ::Form::Subsection
Form::Sales::Pages::PropertyNumberOfBedrooms.new(nil, nil, self),
Form::Sales::Pages::PropertyBuildingType.new(nil, nil, self),
Form::Sales::Pages::PropertyUnitType.new(nil, nil, self),
Form::Sales::Pages::PropertyPostcode.new(nil, nil, self),
]
end
end

15
app/models/form/sales/subsections/property_postcode.rb

@ -0,0 +1,15 @@
class Form::Sales::Subsections::PropertyPostcode < ::Form::Subsection
def initialize(id, hsh, section)
super
@id = "property_postcode"
@label = "Property postcode"
@section = section
@depends_on = [{ "setup" => "completed" }]
end
def pages
@pages ||= [
Form::Sales::Pages::PropertyPostcode.new(nil, nil, self),
]
end
end

10
db/migrate/20221018221143_add_postcode_to_sales_log.rb

@ -0,0 +1,10 @@
class AddPostcodeToSalesLog < ActiveRecord::Migration[7.0]
def change
change_table :sales_logs, bulk: true do |t|
t.column :postcode_full, :string, default: nil # e.g. SE27 0HG
t.column :pcode1, :string, default: nil # Outcode e.g. SE27
t.column :pcode2, :string, default: nil # Incode e.g. 0HG
t.column :pcodenk, :boolean, default: true # Not Known
end
end
end

40
db/schema.rb

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.0].define(version: 2022_10_11_094347) do
ActiveRecord::Schema[7.0].define(version: 2022_10_18_221143) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -42,6 +42,17 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_11_094347) do
t.index ["start_year", "lettype", "beds", "la"], name: "index_la_rent_ranges_on_start_year_and_lettype_and_beds_and_la", unique: true
end
create_table "la_sales_ranges", force: :cascade do |t|
t.string "la"
t.string "la_name"
t.integer "beds"
t.integer "soft_min", null: false
t.integer "soft_max", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["beds", "la"], name: "index_la_sales_ranges_on_beds_and_la", unique: true
end
create_table "legacy_users", force: :cascade do |t|
t.string "old_user_id"
t.integer "user_id"
@ -245,6 +256,14 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_11_094347) do
t.index ["scheme_id"], name: "index_lettings_logs_on_scheme_id"
end
create_table "local_authorities", force: :cascade do |t|
t.string "ons_code", null: false
t.string "name", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["ons_code", "name"], name: "index_local_authorities_on_ons_code_and_name", unique: true
end
create_table "locations", force: :cascade do |t|
t.string "location_code"
t.string "postcode"
@ -337,12 +356,10 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_11_094347) do
t.integer "age1"
t.integer "age1_known"
t.string "sex1"
t.integer "national"
t.string "othernational"
t.integer "ethnic"
t.integer "ethnic_group"
t.integer "buy1livein"
t.integer "buylivein"
t.integer "ethnic"
t.integer "ethnic_group"
t.integer "builtype"
t.integer "proptype"
t.integer "age2"
@ -352,21 +369,28 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_11_094347) do
t.integer "noint"
t.integer "buy2livein"
t.integer "ecstat2"
t.integer "national"
t.string "othernational"
t.integer "privacynotice"
t.integer "ecstat1"
t.integer "wheel"
t.integer "hholdcount"
t.integer "age3"
t.integer "age3_known"
t.string "la"
t.integer "purchase_price"
t.integer "income1"
t.integer "income1nk"
t.integer "age4"
t.integer "age4_known"
t.integer "age5"
t.integer "age5_known"
t.integer "age6"
t.integer "age6_known"
t.integer "proplen"
t.integer "income1"
t.integer "income1nk"
t.string "postcode_full"
t.string "pcode1"
t.string "pcode2"
t.boolean "pcodenk", default: true
t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id"
t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id"
t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id"

Loading…
Cancel
Save