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.
37 lines
1.5 KiB
37 lines
1.5 KiB
class Form::Lettings::Questions::Period < ::Form::Question |
|
def initialize(id, hsh, page) |
|
super |
|
@id = "period" |
|
@check_answer_label = "Frequency of household rent and charges" |
|
@header = "How often does the household pay rent and other charges?" |
|
@type = "radio" |
|
@check_answers_card_number = 0 |
|
@hint_text = "Select how often the household is charged. This may be different to how often they pay." |
|
@answer_options = ANSWER_OPTIONS |
|
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] |
|
end |
|
|
|
ANSWER_OPTIONS = { |
|
"2" => { "value" => "Every 2 weeks" }, |
|
"3" => { "value" => "Every 4 weeks" }, |
|
"4" => { "value" => "Every calendar month" }, |
|
"9" => { "value" => "Weekly for 46 weeks" }, |
|
"8" => { "value" => "Weekly for 47 weeks" }, |
|
"7" => { "value" => "Weekly for 48 weeks" }, |
|
"6" => { "value" => "Weekly for 49 weeks" }, |
|
"5" => { "value" => "Weekly for 50 weeks" }, |
|
"11" => { "value" => "Weekly for 51 weeks" }, |
|
"1" => { "value" => "Weekly for 52 weeks" }, |
|
"10" => { "value" => "Weekly for 53 weeks" }, |
|
}.freeze |
|
|
|
QUESTION_NUMBER_FROM_YEAR = { 2023 => 92, 2024 => 91 }.freeze |
|
|
|
def displayed_answer_options(log, _user) |
|
return ANSWER_OPTIONS if log.managing_organisation.nil? |
|
|
|
available_rent_periods = log.managing_organisation.rent_periods |
|
|
|
ANSWER_OPTIONS.select { |key, _| available_rent_periods.include?(key.to_i) } |
|
end |
|
end
|
|
|