diff --git a/app/models/dossier.rb b/app/models/dossier.rb index f41be6147..35531a4b9 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -896,7 +896,7 @@ class Dossier < ApplicationRecord end def previously_termine? - traitements.termine.exists? + traitements.any?(&:termine?) end def remove_titres_identite! diff --git a/app/models/traitement.rb b/app/models/traitement.rb index 0a3929b57..95612dfd6 100644 --- a/app/models/traitement.rb +++ b/app/models/traitement.rb @@ -26,4 +26,6 @@ class Traitement < ApplicationRecord self.browser_supported = BrowserSupport.supported?(browser) end end + + def termine? = state.in?(Dossier::TERMINE) end diff --git a/app/services/dossier_projection_service.rb b/app/services/dossier_projection_service.rb index 616ce055a..cd4e9cea3 100644 --- a/app/services/dossier_projection_service.rb +++ b/app/services/dossier_projection_service.rb @@ -30,7 +30,7 @@ class DossierProjectionService # - the order of the intermediary query results are unknown # - some values can be missing (if a revision added or removed them) def self.project(dossiers_ids, columns) - dossiers = Dossier.includes(:corrections, :pending_corrections).find(dossiers_ids) + dossiers = Dossier.includes(:corrections, :pending_corrections, :traitements).find(dossiers_ids) fields = columns.map do |c| if c.is_a?(Columns::ChampColumn)