diff --git a/app/controllers/logs_controller.rb b/app/controllers/logs_controller.rb index 5576028a6..eab447835 100644 --- a/app/controllers/logs_controller.rb +++ b/app/controllers/logs_controller.rb @@ -68,6 +68,7 @@ private "owning_organisation_id" => owning_organisation_id, "assigned_to_id" => current_user.id, "managing_organisation_id" => current_user.organisation.id, + "has_selected_organisation" => false, } end diff --git a/app/models/validations/sales/setup_validations.rb b/app/models/validations/sales/setup_validations.rb index 75e79f15a..44166895c 100644 --- a/app/models/validations/sales/setup_validations.rb +++ b/app/models/validations/sales/setup_validations.rb @@ -106,10 +106,18 @@ private end def merged_owning_organisation_inactive?(record) + # if the user has not explicitly picked an organisation ignore this validation + # this is because the saledate question appears before a user can select their organisation in the 2025 form + return false unless record.has_selected_organisation + record.owning_organisation&.merge_date.present? && record.owning_organisation.merge_date <= record.saledate end def absorbing_owning_organisation_inactive?(record) + # if the user has not explicitly picked an organisation ignore this validation + # this is because the saledate question appears before a user can select their organisation in the 2025 form + return false unless record.has_selected_organisation + record.owning_organisation&.absorbed_organisations.present? && record.owning_organisation.available_from.present? && record.owning_organisation.available_from.to_date > record.saledate.to_date end end