162 changed files with 3686 additions and 795 deletions
@ -0,0 +1,24 @@
|
||||
class Form::Lettings::Pages::Address < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "address" |
||||
@header = "Q12 - What is the property's address?" |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [ |
||||
Form::Lettings::Questions::AddressLine1.new(nil, nil, self), |
||||
Form::Lettings::Questions::AddressLine2.new(nil, nil, self), |
||||
Form::Lettings::Questions::TownOrCity.new(nil, nil, self), |
||||
Form::Lettings::Questions::County.new(nil, nil, self), |
||||
Form::Lettings::Questions::PostcodeForFullAddress.new(nil, nil, self), |
||||
] |
||||
end |
||||
|
||||
def routed_to?(log, _current_user = nil) |
||||
return false if log.uprn_known.nil? |
||||
return false if log.is_supported_housing? |
||||
|
||||
log.uprn_confirmed != 1 || log.uprn_known.zero? |
||||
end |
||||
end |
||||
@ -0,0 +1,15 @@
|
||||
class Form::Lettings::Pages::CareHomeChargesValueCheck < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "care_home_charges_value_check" |
||||
@depends_on = [{ "care_home_charge_expected_not_provided?" => true }] |
||||
@title_text = { |
||||
"translation" => "soft_validations.care_home_charges.title_text", |
||||
} |
||||
@informative_text = "" |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [Form::Lettings::Questions::CareHomeChargesValueCheck.new(nil, nil, self)] |
||||
end |
||||
end |
||||
@ -0,0 +1,28 @@
|
||||
class Form::Lettings::Pages::Uprn < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "uprn" |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [ |
||||
Form::Lettings::Questions::Uprn.new(nil, nil, self), |
||||
] |
||||
end |
||||
|
||||
def routed_to?(log, _current_user = nil) |
||||
return false if log.is_supported_housing? |
||||
|
||||
log.uprn_known == 1 |
||||
end |
||||
|
||||
def skip_text |
||||
"Enter address instead" |
||||
end |
||||
|
||||
def skip_href(log = nil) |
||||
return unless log |
||||
|
||||
"/#{log.model_name.param_key.dasherize}s/#{log.id}/address" |
||||
end |
||||
end |
||||
@ -0,0 +1,17 @@
|
||||
class Form::Lettings::Pages::UprnConfirmation < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "uprn_confirmation" |
||||
@header = "We found an address that might be this property" |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [ |
||||
Form::Lettings::Questions::UprnConfirmation.new(nil, nil, self), |
||||
] |
||||
end |
||||
|
||||
def routed_to?(log, _current_user = nil) |
||||
log.uprn.present? && log.uprn_known == 1 |
||||
end |
||||
end |
||||
@ -0,0 +1,16 @@
|
||||
class Form::Lettings::Pages::UprnKnown < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "uprn_known" |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [ |
||||
Form::Lettings::Questions::UprnKnown.new(nil, nil, self), |
||||
] |
||||
end |
||||
|
||||
def routed_to?(log, _current_user = nil) |
||||
!log.is_supported_housing? |
||||
end |
||||
end |
||||
@ -0,0 +1,38 @@
|
||||
class Form::Lettings::Questions::AddressLine1 < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "address_line1" |
||||
@check_answer_label = "Address" |
||||
@header = "Address line 1" |
||||
@type = "text" |
||||
@plain_label = true |
||||
@check_answer_label = "Q12 - Address" |
||||
end |
||||
|
||||
def hidden_in_check_answers?(log, _current_user = nil) |
||||
return true if log.uprn_known.nil? |
||||
return false if log.uprn_known&.zero? |
||||
return true if log.uprn_confirmed.nil? && log.uprn.present? |
||||
return true if log.uprn_known == 1 && log.uprn.blank? |
||||
|
||||
log.uprn_confirmed == 1 |
||||
end |
||||
|
||||
def answer_label(log, _current_user = nil) |
||||
[ |
||||
log.address_line1, |
||||
log.address_line2, |
||||
log.postcode_full, |
||||
log.town_or_city, |
||||
log.county, |
||||
].select(&:present?).join("\n") |
||||
end |
||||
|
||||
def get_extra_check_answer_value(log) |
||||
return unless log.is_la_inferred? |
||||
|
||||
la = LocalAuthority.find_by(code: log.la)&.name |
||||
|
||||
la.presence |
||||
end |
||||
end |
||||
@ -0,0 +1,13 @@
|
||||
class Form::Lettings::Questions::AddressLine2 < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "address_line2" |
||||
@header = "Address line 2 (optional)" |
||||
@type = "text" |
||||
@plain_label = true |
||||
end |
||||
|
||||
def hidden_in_check_answers?(_log = nil, _current_user = nil) |
||||
true |
||||
end |
||||
end |
||||
@ -0,0 +1,14 @@
|
||||
class Form::Lettings::Questions::CareHomeChargesValueCheck < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "carehome_charges_value_check" |
||||
@check_answer_label = "Care home charges confirmation" |
||||
@header = "Are you sure there are no care home charges?" |
||||
@type = "interruption_screen" |
||||
@check_answers_card_number = 0 |
||||
@answer_options = ANSWER_OPTIONS |
||||
@hidden_in_check_answers = { "depends_on" => [{ "carehome_charges_value_check" => 0 }, { "carehome_charges_value_check" => 1 }] } |
||||
end |
||||
|
||||
ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze |
||||
end |
||||
@ -0,0 +1,13 @@
|
||||
class Form::Lettings::Questions::County < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "county" |
||||
@header = "County (optional)" |
||||
@type = "text" |
||||
@plain_label = true |
||||
end |
||||
|
||||
def hidden_in_check_answers?(_log = nil, _current_user = nil) |
||||
true |
||||
end |
||||
end |
||||
@ -0,0 +1,25 @@
|
||||
class Form::Lettings::Questions::PostcodeForFullAddress < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "postcode_full" |
||||
@header = "Postcode" |
||||
@type = "text" |
||||
@width = 5 |
||||
@inferred_check_answers_value = [{ |
||||
"condition" => { |
||||
"pcodenk" => 1, |
||||
}, |
||||
"value" => "Not known", |
||||
}] |
||||
@inferred_answers = { |
||||
"la" => { |
||||
"is_la_inferred" => true, |
||||
}, |
||||
} |
||||
@plain_label = true |
||||
end |
||||
|
||||
def hidden_in_check_answers?(_log = nil, _current_user = nil) |
||||
true |
||||
end |
||||
end |
||||
@ -0,0 +1,13 @@
|
||||
class Form::Lettings::Questions::TownOrCity < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "town_or_city" |
||||
@header = "Town or city" |
||||
@type = "text" |
||||
@plain_label = true |
||||
end |
||||
|
||||
def hidden_in_check_answers?(_log = nil, _current_user = nil) |
||||
true |
||||
end |
||||
end |
||||
@ -0,0 +1,35 @@
|
||||
class Form::Lettings::Questions::Uprn < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "uprn" |
||||
@check_answer_label = "UPRN" |
||||
@header = "What is the property's UPRN" |
||||
@type = "text" |
||||
@hint_text = "The Unique Property Reference Number (UPRN) is a unique number system created by Ordnance Survey and used by housing providers and sectors UK-wide. For example 10010457355." |
||||
@width = 10 |
||||
@question_number = 11 |
||||
end |
||||
|
||||
def unanswered_error_message |
||||
I18n.t("validations.property.uprn.invalid") |
||||
end |
||||
|
||||
def get_extra_check_answer_value(log) |
||||
value = [ |
||||
log.address_line1, |
||||
log.address_line2, |
||||
log.town_or_city, |
||||
log.county, |
||||
log.postcode_full, |
||||
(LocalAuthority.find_by(code: log.la)&.name if log.la.present?), |
||||
].select(&:present?) |
||||
|
||||
return unless value.any? |
||||
|
||||
"\n\n#{value.join("\n")}" |
||||
end |
||||
|
||||
def hidden_in_check_answers?(log, _current_user = nil) |
||||
log.uprn_known != 1 |
||||
end |
||||
end |
||||
@ -0,0 +1,34 @@
|
||||
class Form::Lettings::Questions::UprnConfirmation < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "uprn_confirmed" |
||||
@header = "Is this the property address?" |
||||
@type = "radio" |
||||
@answer_options = ANSWER_OPTIONS |
||||
@check_answer_label = "Is this the right address?" |
||||
end |
||||
|
||||
ANSWER_OPTIONS = { |
||||
"1" => { "value" => "Yes" }, |
||||
"0" => { "value" => "No, I want to enter the address manually" }, |
||||
}.freeze |
||||
|
||||
def notification_banner(log = nil) |
||||
return unless log&.uprn |
||||
|
||||
{ |
||||
title: "UPRN: #{log.uprn}", |
||||
heading: [ |
||||
log.address_line1, |
||||
log.address_line2, |
||||
log.postcode_full, |
||||
log.town_or_city, |
||||
log.county, |
||||
].select(&:present?).join("\n"), |
||||
} |
||||
end |
||||
|
||||
def hidden_in_check_answers?(log, _current_user = nil) |
||||
log.uprn_known != 1 || log.uprn_confirmed.present? |
||||
end |
||||
end |
||||
@ -0,0 +1,21 @@
|
||||
class Form::Lettings::Questions::UprnKnown < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "uprn_known" |
||||
@check_answer_label = "UPRN known?" |
||||
@header = "Do you know the property's UPRN?" |
||||
@type = "radio" |
||||
@answer_options = ANSWER_OPTIONS |
||||
@hint_text = "The Unique Property Reference Number (UPRN) is a unique number system created by Ordnance Survey and used by housing providers and sectors UK-wide. For example 10010457355.<br><br> |
||||
You can continue without the UPRN, but it means we will need you to enter the address of the property." |
||||
end |
||||
|
||||
ANSWER_OPTIONS = { |
||||
"1" => { "value" => "Yes" }, |
||||
"0" => { "value" => "No" }, |
||||
}.freeze |
||||
|
||||
def unanswered_error_message |
||||
I18n.t("validations.property.uprn_known.invalid") |
||||
end |
||||
end |
||||
@ -0,0 +1,26 @@
|
||||
class Form::Sales::Pages::DiscountedSaleValueCheck < ::Form::Page |
||||
def initialize(id, hsh, subsection, person_index = nil) |
||||
super(id, hsh, subsection) |
||||
@depends_on = depends_on |
||||
@title_text = { |
||||
"translation" => "soft_validations.discounted_sale_value.title_text", |
||||
"arguments" => [{ "key" => "value_with_discount", "label" => false, "i18n_template" => "value_with_discount" }], |
||||
} |
||||
@informative_text = { |
||||
"translation" => "soft_validations.discounted_sale_value.informative_text", |
||||
"arguments" => [{ "key" => "mortgage_deposit_and_grant_total", "label" => false, "i18n_template" => "mortgage_deposit_and_grant_total" }], |
||||
} |
||||
@person_index = person_index |
||||
@depends_on = [ |
||||
{ |
||||
"discounted_ownership_value_invalid?" => true, |
||||
}, |
||||
] |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [ |
||||
Form::Sales::Questions::DiscountedSaleValueCheck.new(nil, nil, self), |
||||
] |
||||
end |
||||
end |
||||
@ -0,0 +1,23 @@
|
||||
class Form::Sales::Questions::DiscountedSaleValueCheck < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "discounted_sale_value_check" |
||||
@check_answer_label = "Discounted sale value confirmation" |
||||
@header = "Are you sure this is correct?" |
||||
@type = "interruption_screen" |
||||
@answer_options = { |
||||
"0" => { "value" => "Yes" }, |
||||
"1" => { "value" => "No" }, |
||||
} |
||||
@hidden_in_check_answers = { |
||||
"depends_on" => [ |
||||
{ |
||||
"discounted_sale_value_check" => 0, |
||||
}, |
||||
{ |
||||
"discounted_sale_value_check" => 1, |
||||
}, |
||||
], |
||||
} |
||||
end |
||||
end |
||||
@ -0,0 +1,5 @@
|
||||
class AddCarehomeChargesValueCheck < ActiveRecord::Migration[7.0] |
||||
def change |
||||
add_column :lettings_logs, :carehome_charges_value_check, :integer |
||||
end |
||||
end |
||||
@ -0,0 +1,5 @@
|
||||
class AddDiscountedSaleValueCheck < ActiveRecord::Migration[7.0] |
||||
def change |
||||
add_column :sales_logs, :discounted_sale_value_check, :integer |
||||
end |
||||
end |
||||
|
|
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue