Remove titres identite after a dossier is processed

This commit is contained in:
Paul Chavard 2020-12-08 15:57:48 +01:00
parent bd697b6252
commit 48e7822e34
4 changed files with 67 additions and 0 deletions

View file

@ -591,6 +591,7 @@ class Dossier < ApplicationRecord
end
save!
remove_titres_identite!
NotificationMailer.send_closed_notification(self).deliver_later
log_dossier_operation(instructeur, :accepter, self)
end
@ -604,6 +605,7 @@ class Dossier < ApplicationRecord
end
save!
remove_titres_identite!
NotificationMailer.send_closed_notification(self).deliver_later
log_automatic_dossier_operation(:accepter, self)
end
@ -616,6 +618,7 @@ class Dossier < ApplicationRecord
end
save!
remove_titres_identite!
NotificationMailer.send_refused_notification(self).deliver_later
log_dossier_operation(instructeur, :refuser, self)
end
@ -628,10 +631,15 @@ class Dossier < ApplicationRecord
end
save!
remove_titres_identite!
NotificationMailer.send_without_continuation_notification(self).deliver_later
log_dossier_operation(instructeur, :classer_sans_suite, self)
end
def remove_titres_identite!
champs.filter(&:titre_identite?).map(&:piece_justificative_file).each(&:purge_later)
end
def check_mandatory_champs
(champs + champs.filter(&:repetition?).flat_map(&:champs))
.filter(&:mandatory_and_blank?)