Browse Source

some fixes

pull/273/head
MadeTech Dushan 3 years ago
parent
commit
6b12ed011f
  1. 27
      app/helpers/check_answers_helper.rb
  2. 1
      app/models/case_log.rb
  3. 1
      spec/factories/case_log.rb

27
app/helpers/check_answers_helper.rb

@ -12,25 +12,22 @@ module CheckAnswersHelper
end
def get_answer_label(question, case_log)
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("")
if question.id == "earnings"
linked_question = case_log.form.get_question("incfreq")
if question.answer_label(case_log).present? && linked_question.answer_label(case_log).present?
suffixes = {
"Weekly" => " every week",
"Monthly" => " every month",
"Yearly" => " every year",
}
[question.prefix, question.answer_label(case_log), suffixes[linked_question.answer_label(case_log)]].join("")
else
"<span class=\"app-!-colour-muted\">You didn’t answer this question</span>".html_safe
end
else
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("")
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
"<span class=\"app-!-colour-muted\">You didn’t answer this question</span>".html_safe
end

1
app/models/case_log.rb

@ -243,6 +243,7 @@ private
self.month = startdate.month
self.year = startdate.year
end
self.incref = 1 if net_income_known == "Tenant prefers not to say"
self.hhmemb = other_hhmemb + 1 if other_hhmemb.present?
self.renttype = RENT_TYPE_MAPPING[rent_type]
self.lettype = "#{renttype} #{needstype} #{owning_organisation[:provider_type]}" if renttype.present? && needstype.present? && owning_organisation[:provider_type].present?

1
spec/factories/case_log.rb

@ -69,6 +69,7 @@ FactoryBot.define do
offered { 2 }
wchair { "Yes" }
earnings { 68 }
incfreq { "Weekly" }
benefits { "Some" }
period { "Every 2 weeks" }
brent { 200 }

Loading…
Cancel
Save