Resend attestation for a procedure whose attestation template changed
This commit is contained in:
parent
54c08826d1
commit
bb3dcbbf22
2 changed files with 47 additions and 0 deletions
18
lib/tasks/2018_06_05_resend_attestations.rb
Normal file
18
lib/tasks/2018_06_05_resend_attestations.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
namespace :'2018_06_05_resend_attestation' do
|
||||
task set: :environment do
|
||||
procedure = Procedure.find(4247)
|
||||
dossiers = procedure.dossiers.includes(:attestation).where(state: 'accepte').select do |d|
|
||||
d.processed_at < procedure.attestation_template.updated_at
|
||||
end
|
||||
|
||||
dossiers.each do |dossier|
|
||||
attestation = dossier.attestation
|
||||
attestation.destroy
|
||||
|
||||
dossier.attestation = dossier.build_attestation
|
||||
|
||||
Mailers::ResendAttestationMailer.resend_attestation(dossier).deliver_later
|
||||
puts "Email envoyé à #{email} pour le dossier #{dossier.id}"
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue