From 7e70d066d55915290d286027ed770510695ca890 Mon Sep 17 00:00:00 2001 From: Kat Date: Mon, 11 Dec 2023 09:30:05 +0000 Subject: [PATCH] Update question header and filters conditions --- app/helpers/filters_helper.rb | 9 ++++++--- app/models/form/sales/questions/managing_organisation.rb | 2 +- app/views/logs/_log_filters.html.erb | 2 +- .../form/sales/questions/managing_organisation_spec.rb | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/helpers/filters_helper.rb b/app/helpers/filters_helper.rb index 94c5a6eca..5726b5994 100644 --- a/app/helpers/filters_helper.rb +++ b/app/helpers/filters_helper.rb @@ -125,11 +125,14 @@ module FiltersHelper end def non_support_with_multiple_owning_orgs? - current_user.organisation.stock_owners.count > 1 || current_user.organisation.has_recent_absorbed_organisations? + return true if current_user.organisation.stock_owners.count > 1 + return true if current_user.organisation.stock_owners.count.positive? && current_user.organisation.holds_own_stock? + + current_user.organisation.has_recent_absorbed_organisations? end - def non_support_with_multiple_managing_orgs? - current_user.organisation.managing_agents.count > 1 || current_user.organisation.has_recent_absorbed_organisations? + def non_support_with_managing_orgs? + current_user.organisation.managing_agents.count >= 1 || current_user.organisation.has_recent_absorbed_organisations? end def user_lettings_path? diff --git a/app/models/form/sales/questions/managing_organisation.rb b/app/models/form/sales/questions/managing_organisation.rb index 42e1dfd38..818819084 100644 --- a/app/models/form/sales/questions/managing_organisation.rb +++ b/app/models/form/sales/questions/managing_organisation.rb @@ -3,7 +3,7 @@ class Form::Sales::Questions::ManagingOrganisation < ::Form::Question super @id = "managing_organisation_id" @check_answer_label = "Reported by" - @header = "Which organisation is reporting this sales log?" + @header = "Which organisation is reporting this sale?" @type = "select" end diff --git a/app/views/logs/_log_filters.html.erb b/app/views/logs/_log_filters.html.erb index 0bfb5d3b8..16053c805 100644 --- a/app/views/logs/_log_filters.html.erb +++ b/app/views/logs/_log_filters.html.erb @@ -93,7 +93,7 @@ } %> <% end %> - <% if (current_user.support? || non_support_with_multiple_managing_orgs?) && (user_or_org_lettings_path? || FeatureToggle.sales_managing_organisation_enabled?) %> + <% if (current_user.support? || non_support_with_managing_orgs?) && (user_or_org_lettings_path? || FeatureToggle.sales_managing_organisation_enabled?) %> <%= render partial: "filters/radio_filter", locals: { f:, options: { diff --git a/spec/models/form/sales/questions/managing_organisation_spec.rb b/spec/models/form/sales/questions/managing_organisation_spec.rb index a6dd23d59..98f459b24 100644 --- a/spec/models/form/sales/questions/managing_organisation_spec.rb +++ b/spec/models/form/sales/questions/managing_organisation_spec.rb @@ -18,7 +18,7 @@ RSpec.describe Form::Sales::Questions::ManagingOrganisation, type: :model do end it "has the correct header" do - expect(question.header).to eq("Which organisation is reporting this sales log?") + expect(question.header).to eq("Which organisation is reporting this sale?") end it "has the correct check_answer_label" do