From da1100ec123b815c9bf60829ccc32ac99e68699e Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Mon, 3 Apr 2023 15:10:29 +0100 Subject: [PATCH] feat: fix subsection count bug --- app/helpers/tasklist_helper.rb | 2 +- .../form/sales/subsections/discounted_ownership_scheme.rb | 2 +- app/models/form/sales/subsections/outright_sale.rb | 2 +- app/models/form/sales/subsections/shared_ownership_scheme.rb | 2 +- app/views/logs/edit.html.erb | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/helpers/tasklist_helper.rb b/app/helpers/tasklist_helper.rb index 30112894f..9487d13a5 100644 --- a/app/helpers/tasklist_helper.rb +++ b/app/helpers/tasklist_helper.rb @@ -6,7 +6,7 @@ module TasklistHelper end def get_subsections_count(log, status = :all) - return log.form.subsections.count { |subsection| subsection.applicable_questions(log).count.positive? } if status == :all + return log.form.subsections.count { |subsection| subsection.displayed_in_tasklist?(log) } if status == :all log.form.subsections.count { |subsection| subsection.status(log) == status && subsection.applicable_questions(log).count.positive? } end diff --git a/app/models/form/sales/subsections/discounted_ownership_scheme.rb b/app/models/form/sales/subsections/discounted_ownership_scheme.rb index cab732bc7..09813339d 100644 --- a/app/models/form/sales/subsections/discounted_ownership_scheme.rb +++ b/app/models/form/sales/subsections/discounted_ownership_scheme.rb @@ -41,6 +41,6 @@ class Form::Sales::Subsections::DiscountedOwnershipScheme < ::Form::Subsection end def displayed_in_tasklist?(log) - log.ownershipsch == 2 + log.ownershipsch.nil? || log.ownershipsch == 2 end end diff --git a/app/models/form/sales/subsections/outright_sale.rb b/app/models/form/sales/subsections/outright_sale.rb index d29dc5759..4af89d317 100644 --- a/app/models/form/sales/subsections/outright_sale.rb +++ b/app/models/form/sales/subsections/outright_sale.rb @@ -26,7 +26,7 @@ class Form::Sales::Subsections::OutrightSale < ::Form::Subsection end def displayed_in_tasklist?(log) - log.ownershipsch == 3 + log.ownershipsch.nil? || log.ownershipsch == 3 end def leasehold_charge_pages diff --git a/app/models/form/sales/subsections/shared_ownership_scheme.rb b/app/models/form/sales/subsections/shared_ownership_scheme.rb index afd13ec47..b122faf63 100644 --- a/app/models/form/sales/subsections/shared_ownership_scheme.rb +++ b/app/models/form/sales/subsections/shared_ownership_scheme.rb @@ -46,6 +46,6 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection end def displayed_in_tasklist?(log) - log.ownershipsch == 1 + log.ownershipsch.nil? || log.ownershipsch == 1 end end diff --git a/app/views/logs/edit.html.erb b/app/views/logs/edit.html.erb index e1321143b..1be928656 100644 --- a/app/views/logs/edit.html.erb +++ b/app/views/logs/edit.html.erb @@ -11,7 +11,7 @@ <% if @log.status == "in_progress" %> -

<%= get_subsections_count(@log, :completed) %> of <%= get_subsections_count(@log, :all) %> sections completed.

+

<%= get_subsections_count(@log, :completed) %> of <%= get_subsections_count(@log, :all) %> subsections completed.

<% next_incomplete_section = get_next_incomplete_section(@log) %>