Browse Source

PO fixes

pull/2077/head
Kat 2 years ago
parent
commit
d58eb6164f
  1. 2
      app/controllers/form_controller.rb
  2. 2
      app/controllers/organisations_controller.rb
  3. 2
      app/helpers/filters_helper.rb
  4. 1
      app/models/form/sales/questions/managing_organisation.rb
  5. 3
      db/seeds.rb

2
app/controllers/form_controller.rb

@ -102,7 +102,7 @@ private
result[question.id] = question_params result[question.id] = question_params
end end
if question.id == "owning_organisation_id" && @log.lettings? if question.id == "owning_organisation_id"
owning_organisation = Organisation.find(result["owning_organisation_id"]) owning_organisation = Organisation.find(result["owning_organisation_id"])
if current_user.support? && @log.managing_organisation.blank? && owning_organisation&.managing_agents&.empty? if current_user.support? && @log.managing_organisation.blank? && owning_organisation&.managing_agents&.empty?
result["managing_organisation_id"] = owning_organisation.id result["managing_organisation_id"] = owning_organisation.id

2
app/controllers/organisations_controller.rb

@ -122,7 +122,7 @@ class OrganisationsController < ApplicationController
end end
def sales_logs def sales_logs
organisation_logs = SalesLog.visible.where(owning_organisation_id: @organisation.id) organisation_logs = SalesLog.visible.filter_by_organisation(@organisation)
unpaginated_filtered_logs = filter_manager.filtered_logs(organisation_logs, search_term, session_filters) unpaginated_filtered_logs = filter_manager.filtered_logs(organisation_logs, search_term, session_filters)
respond_to do |format| respond_to do |format|

2
app/helpers/filters_helper.rb

@ -125,7 +125,7 @@ module FiltersHelper
end end
def non_support_with_multiple_owning_orgs? def non_support_with_multiple_owning_orgs?
current_user.organisation.stock_owners.count > 1 && user_lettings_path? || current_user.organisation.has_recent_absorbed_organisations? current_user.organisation.stock_owners.count > 1 || current_user.organisation.has_recent_absorbed_organisations?
end end
def non_support_with_multiple_managing_orgs? def non_support_with_multiple_managing_orgs?

1
app/models/form/sales/questions/managing_organisation.rb

@ -5,7 +5,6 @@ class Form::Sales::Questions::ManagingOrganisation < ::Form::Question
@check_answer_label = "Reported by" @check_answer_label = "Reported by"
@header = "Which organisation is reporting this sales log?" @header = "Which organisation is reporting this sales log?"
@type = "select" @type = "select"
@question_number = 2
end end
def answer_options(log = nil, user = nil) def answer_options(log = nil, user = nil)

3
db/seeds.rb

@ -200,6 +200,7 @@ unless Rails.env.test?
SalesLog.find_or_create_by!( SalesLog.find_or_create_by!(
created_by: support_user, created_by: support_user,
owning_organisation: org, owning_organisation: org,
managing_organisation: org,
saledate: Date.new(2023, 4, 1), saledate: Date.new(2023, 4, 1),
purchid: "1", purchid: "1",
ownershipsch: 1, ownershipsch: 1,
@ -211,6 +212,7 @@ unless Rails.env.test?
SalesLog.find_or_create_by!( SalesLog.find_or_create_by!(
created_by: support_user, created_by: support_user,
owning_organisation: org, owning_organisation: org,
managing_organisation: org,
saledate: Date.new(2023, 4, 1), saledate: Date.new(2023, 4, 1),
purchid: "1", purchid: "1",
ownershipsch: 2, ownershipsch: 2,
@ -222,6 +224,7 @@ unless Rails.env.test?
SalesLog.find_or_create_by!( SalesLog.find_or_create_by!(
created_by: support_user, created_by: support_user,
owning_organisation: org, owning_organisation: org,
managing_organisation: org,
saledate: Date.new(2023, 4, 1), saledate: Date.new(2023, 4, 1),
purchid: "1", purchid: "1",
ownershipsch: 3, ownershipsch: 3,

Loading…
Cancel
Save