added extension bouton to en_construction dossiers bound to expire

This commit is contained in:
clemkeirua 2020-03-19 14:47:09 +01:00
parent dadbcd7ede
commit 5896aedeeb
4 changed files with 22 additions and 1 deletions

View file

@ -172,7 +172,7 @@ class Dossier < ApplicationRecord
scope :en_construction_close_to_expiration, -> do
en_construction
.joins(:procedure)
.where("dossiers.en_construction_at + (duree_conservation_dossiers_dans_ds * interval '1 month') - INTERVAL '1 month' <= now()")
.where("dossiers.en_construction_at + dossiers.en_construction_conservation_extension + (duree_conservation_dossiers_dans_ds * interval '1 month') - INTERVAL '1 month' <= now()")
end
scope :en_instruction_close_to_expiration, -> do
en_instruction
@ -310,6 +310,10 @@ class Dossier < ApplicationRecord
instruction_commencee? && retention_end_date <= Time.zone.now
end
def en_construction_close_to_expiration?
Dossier.en_construction_close_to_expiration.where(id: self).present?
end
def assign_to_groupe_instructeur(groupe_instructeur, author = nil)
if groupe_instructeur.procedure == procedure && groupe_instructeur != self.groupe_instructeur
if update(groupe_instructeur: groupe_instructeur, groupe_instructeur_updated_at: Time.zone.now)