Browse Source

ignore organisation merge date validations if the user has not answered Q2 organisation

CLDC-4025-merge-sales-log-input-error
Samuel 2 weeks ago
parent
commit
a672b30926
  1. 1
      app/controllers/logs_controller.rb
  2. 8
      app/models/validations/sales/setup_validations.rb

1
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

8
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

Loading…
Cancel
Save