Use conservation_extension instead of en_construction_conservation_extension
This commit is contained in:
parent
109e5e74b2
commit
8a74438dc1
7 changed files with 47 additions and 18 deletions
|
@ -32,6 +32,7 @@
|
|||
# user_id :integer
|
||||
#
|
||||
class Dossier < ApplicationRecord
|
||||
self.ignored_columns = [:en_construction_conservation_extension]
|
||||
include DossierFilteringConcern
|
||||
|
||||
include Discard::Model
|
||||
|
@ -256,21 +257,22 @@ class Dossier < ApplicationRecord
|
|||
scope :brouillon_close_to_expiration, -> do
|
||||
state_brouillon
|
||||
.joins(:procedure)
|
||||
.where("dossiers.created_at + (duree_conservation_dossiers_dans_ds * INTERVAL '1 month') - INTERVAL :expires_in < :now", { now: Time.zone.now, expires_in: INTERVAL_BEFORE_EXPIRATION })
|
||||
.where("dossiers.created_at + dossiers.conservation_extension + (duree_conservation_dossiers_dans_ds * INTERVAL '1 month') - INTERVAL :expires_in < :now", { now: Time.zone.now, expires_in: INTERVAL_BEFORE_EXPIRATION })
|
||||
end
|
||||
scope :en_construction_close_to_expiration, -> do
|
||||
state_en_construction
|
||||
.joins(:procedure)
|
||||
.where("dossiers.en_construction_at + dossiers.en_construction_conservation_extension + (duree_conservation_dossiers_dans_ds * INTERVAL '1 month') - INTERVAL :expires_in < :now", { now: Time.zone.now, expires_in: INTERVAL_BEFORE_EXPIRATION })
|
||||
.where("dossiers.en_construction_at + dossiers.conservation_extension + (duree_conservation_dossiers_dans_ds * INTERVAL '1 month') - INTERVAL :expires_in < :now", { now: Time.zone.now, expires_in: INTERVAL_BEFORE_EXPIRATION })
|
||||
end
|
||||
scope :en_instruction_close_to_expiration, -> do
|
||||
state_en_instruction
|
||||
.joins(:procedure)
|
||||
.where("dossiers.en_instruction_at + (duree_conservation_dossiers_dans_ds * INTERVAL '1 month') - INTERVAL :expires_in < :now", { now: Time.zone.now, expires_in: INTERVAL_BEFORE_EXPIRATION })
|
||||
end
|
||||
def self.termine_close_to_expiration
|
||||
dossier_ids = Traitement.termine_close_to_expiration.pluck(:dossier_id).uniq
|
||||
Dossier.where(id: dossier_ids)
|
||||
scope :termine_close_to_expiration, -> do
|
||||
state_termine
|
||||
.joins(:procedure)
|
||||
.where(id: Traitement.termine_close_to_expiration.pluck(:dossier_id).uniq)
|
||||
end
|
||||
|
||||
scope :brouillon_expired, -> do
|
||||
|
@ -454,7 +456,15 @@ class Dossier < ApplicationRecord
|
|||
end
|
||||
|
||||
def en_construction_close_to_expiration?
|
||||
Dossier.en_construction_close_to_expiration.where(id: self).present?
|
||||
self.class.en_construction_close_to_expiration.exists?(id: self)
|
||||
end
|
||||
|
||||
def brouillon_close_to_expiration?
|
||||
self.class.brouillon_close_to_expiration.exists?(id: self)
|
||||
end
|
||||
|
||||
def close_to_expiration?
|
||||
en_construction_close_to_expiration? || brouillon_close_to_expiration?
|
||||
end
|
||||
|
||||
def show_groupe_instructeur_details?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue