From 508602fd4a861de06792c20c83cfd6e8cb6a1008 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Tue, 14 Nov 2023 16:49:50 +0100 Subject: [PATCH] fix(dossier): use traitements to send repasser_en_instruction template --- app/models/dossier.rb | 3 ++- app/models/procedure.rb | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 9e5f8628d..5a32acf74 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -1,4 +1,6 @@ class Dossier < ApplicationRecord + self.ignored_columns += [:re_instructed_at] + include DossierCloneConcern include DossierCorrectableConcern include DossierFilteringConcern @@ -974,7 +976,6 @@ class Dossier < ApplicationRecord self.sva_svr_decision_on = nil self.motivation = nil self.justificatif_motivation.purge_later - self.re_instructed_at = Time.zone.now save! rebase_later diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 25bb06d75..a3d8db109 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -594,7 +594,11 @@ class Procedure < ApplicationRecord when Dossier.states.fetch(:en_construction) initiated_mail_template when Dossier.states.fetch(:en_instruction) - dossier.re_instructed_at.present? ? re_instructed_mail_template : received_mail_template + if dossier.traitements.where(state: Dossier.states.fetch(:en_instruction)).one? + received_mail_template + else + re_instructed_mail_template + end when Dossier.states.fetch(:accepte) closed_mail_template when Dossier.states.fetch(:refuse)