chore(administrateur): destroy procedure if no administrateur and no dossier

This commit is contained in:
Eric Leroy-Terquem 2024-03-15 14:32:53 +01:00
parent ca413a1035
commit eae149f49d

View file

@ -82,6 +82,10 @@ class Administrateur < ApplicationRecord
next_administrateur = procedure.administrateurs.where.not(id: self.id).first
procedure.service.update(administrateur: next_administrateur)
if (procedure.administrateurs.count == 1 && procedure.dossiers.empty?)
procedure.destroy
end
end
services.each do |service|