You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.0 KiB
39 lines
1.0 KiB
class Form::Sales::Questions::Uprn < ::Form::Question |
|
def initialize(id, hsh, page) |
|
super |
|
@id = "uprn" |
|
@copy_key = "sales.property_information.uprn.uprn" |
|
@type = "text" |
|
@width = 10 |
|
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] |
|
@inferred_check_answers_value = [ |
|
{ |
|
"condition" => { "uprn_known" => 0 }, |
|
"value" => "Not known", |
|
}, |
|
] |
|
end |
|
|
|
def unanswered_error_message |
|
I18n.t("validations.sales.property_information.uprn.invalid") |
|
end |
|
|
|
def get_extra_check_answer_value(log) |
|
return unless log.uprn_known == 1 |
|
|
|
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 |
|
|
|
QUESTION_NUMBER_FROM_YEAR = { 2023 => 14, 2024 => 15 }.freeze |
|
end
|
|
|