diff --git a/app/helpers/check_answers_helper.rb b/app/helpers/check_answers_helper.rb index 6797b00af..b4b74c2d3 100644 --- a/app/helpers/check_answers_helper.rb +++ b/app/helpers/check_answers_helper.rb @@ -12,12 +12,28 @@ module CheckAnswersHelper end def get_answer_label(question, case_log) - answer = question.prefix == "£" ? ActionController::Base.helpers.number_to_currency(question.answer_label(case_log), delimiter: ",", format: "%n") : question.answer_label(case_log) - - if answer.present? - [question.prefix, answer, question.suffix].join("") + unless question.id == "earnings" + answer = question.prefix == "£" ? ActionController::Base.helpers.number_to_currency(question.answer_label(case_log), delimiter: ",", format: "%n") : question.answer_label(case_log) + if answer.present? + [question.prefix, answer, question.suffix].join("") + else + "You didn’t answer this question".html_safe + end else - "You didn’t answer this question".html_safe + linked_question = case_log.form.get_question("incfreq") + if(question.answer_label(case_log).present? && linked_question.answer_label(case_log).present?) + suffix = case linked_question.answer_label(case_log) + when "Weekly" + " every week" + when "Monthly" + " every month" + when "Yearly" + " every year" + end + [question.prefix, question.answer_label(case_log), suffix].join("") + else + "You didn’t answer this question".html_safe + end end end end diff --git a/app/models/form.rb b/app/models/form.rb index f00507f50..d21728def 100644 --- a/app/models/form.rb +++ b/app/models/form.rb @@ -24,6 +24,10 @@ class Form pages.find { |p| p.id == id.to_s.underscore } end + def get_question(id) + questions.find { |q| q.id == id.to_s.underscore } + end + def subsection_for_page(page) subsections.find { |s| s.pages.find { |p| p.id == page.id } } end diff --git a/app/models/form/question.rb b/app/models/form/question.rb index 3510c8c38..d6dd902ea 100644 --- a/app/models/form/question.rb +++ b/app/models/form/question.rb @@ -75,6 +75,9 @@ class Form::Question else case_log[id].blank? ? "Answer" : "Change" end + if id == "earnings" + link_type = case_log[id].blank? || case_log["incfreq"].blank? ? "Answer" : "Change" + end "#{link_type} #{check_answer_label.to_s.downcase}".html_safe end diff --git a/app/views/form/_check_answers_table.html.erb b/app/views/form/_check_answers_table.html.erb index 0ba792f1f..be019eefb 100644 --- a/app/views/form/_check_answers_table.html.erb +++ b/app/views/form/_check_answers_table.html.erb @@ -1,3 +1,5 @@ + +<% unless question.id == "incfreq" %>