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
1019 B
39 lines
1019 B
class Form::Lettings::Questions::Uprn < ::Form::Question |
|
def initialize(id, hsh, page) |
|
super |
|
@id = "uprn" |
|
@copy_key = "lettings.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.property.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 => 11, 2024 => 12 }.freeze |
|
end
|
|
|