diff --git a/app/mailers/dossier_mailer.rb b/app/mailers/dossier_mailer.rb
index 854fae5e6..27da3c9d7 100644
--- a/app/mailers/dossier_mailer.rb
+++ b/app/mailers/dossier_mailer.rb
@@ -53,6 +53,8 @@ class DossierMailer < ApplicationMailer
@dossier = dossier
@service = dossier.procedure.service
@logo_url = attach_logo(dossier.procedure)
+ @correction = commentaire.dossier_correction
+
@subject = default_i18n_subject(dossier_id: dossier.id, libelle_demarche: dossier.procedure.libelle)
mail(to: dossier.user_email_for(:notification), subject: @subject) do |format|
diff --git a/app/views/dossier_mailer/notify_pending_correction.html.haml b/app/views/dossier_mailer/notify_pending_correction.html.haml
index 6a576b6dd..a0163ab8e 100644
--- a/app/views/dossier_mailer/notify_pending_correction.html.haml
+++ b/app/views/dossier_mailer/notify_pending_correction.html.haml
@@ -3,10 +3,13 @@
%p= t(:hello, scope: [:views, :shared, :greetings])
-%p= t('.explanation_html', dossier_id: @dossier.id, libelle_demarche: @dossier.procedure.libelle)
+%p= t(".#{@correction.kind}.explanation_html", dossier_id: @dossier.id, libelle_demarche: @dossier.procedure.libelle)
%p= t('.link')
= round_button(t('.access_message'), messagerie_dossier_url(@dossier), :primary)
+- if @dossier.sva_svr_decision_on.present?
+ %p= t(".#{@correction.kind}.sva_svr", rule_name: t(@dossier.procedure.sva? ? :sva : :svr, scope: 'shared.procedures.sva_svr_rule_name'))
+
= render 'layouts/mailers/signature', service: @service
- content_for :footer do
diff --git a/config/locales/en.yml b/config/locales/en.yml
index a6f49c516..302f01ebc 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -837,6 +837,9 @@ en:
dossiers_count: "Nb files"
weekly_distribution: "Weekly distribution"
weekly_distribution_details: "in the last 6 months"
+ sva_svr_rule_name:
+ sva: "Silence Vaut Accord"
+ svr: "Silence Vaut Rejet"
procedure_description:
estimated_fill_duration: "Estimated fill time: %{estimated_minutes} mn"
estimated_fill_duration_title: What is the procedure estimated fill time ?
diff --git a/config/locales/fr.yml b/config/locales/fr.yml
index d1cd2a820..9176039e5 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -891,6 +891,9 @@ fr:
dossiers_count: "Nb dossiers"
weekly_distribution: "Répartition par semaine"
weekly_distribution_details: "au cours des 6 derniers mois"
+ sva_svr_rule_name:
+ sva: "Silence Vaut Accord"
+ svr: "Silence Vaut Rejet"
procedure_description:
estimated_fill_duration: "Temps de remplissage estimé : %{estimated_minutes} mn"
estimated_fill_duration_title: Quelle est la durée de remplissage de la démarche ?
diff --git a/config/locales/views/dossier_mailer/notify_pending_correction/en.yml b/config/locales/views/dossier_mailer/notify_pending_correction/en.yml
index c2bca39ce..cd749d2df 100644
--- a/config/locales/views/dossier_mailer/notify_pending_correction/en.yml
+++ b/config/locales/views/dossier_mailer/notify_pending_correction/en.yml
@@ -3,8 +3,16 @@ en:
dossier_mailer:
notify_pending_correction:
subject: You need to modify your file no. %{dossier_id} « %{libelle_demarche} »
- explanation_html:
- In order to continue its instruction, an instructor requested you to edit information to your file no. %{dossier_id} of the « %{libelle_demarche} » procedure.
+ correction:
+ explanation_html:
+ In order to continue its instruction, an instructor requested you to edit information to your file no. %{dossier_id} of the « %{libelle_demarche} » procedure.
+ sva_svr:
+ As part of the « %{rule_name} » principle, the instruction period is suspended until you submit the requested corrections.
+ incomplete:
+ explanation_html:
+ In order to continue its instruction, an instructor requested you to complete your file no. %{dossier_id} of the « %{libelle_demarche} » procedure.
+ sva_svr:
+ As part of the « %{rule_name} » principle, the instruction period will be reset upon receipt of your complete file.
link:
Check your file's mailbox to see what changes need to be made, then edit the file directly on the website.
access_message: Open the mailbox
diff --git a/config/locales/views/dossier_mailer/notify_pending_correction/fr.yml b/config/locales/views/dossier_mailer/notify_pending_correction/fr.yml
index b44025ce5..8d8dcd161 100644
--- a/config/locales/views/dossier_mailer/notify_pending_correction/fr.yml
+++ b/config/locales/views/dossier_mailer/notify_pending_correction/fr.yml
@@ -3,8 +3,16 @@ fr:
dossier_mailer:
notify_pending_correction:
subject: Vous devez corriger votre dossier nº %{dossier_id} « %{libelle_demarche} »
- explanation_html:
- Afin de poursuivre son instruction, un instructeur vous demande d’apporter des corrections à votre dossier nº %{dossier_id} de la démarche « %{libelle_demarche} ».
+ correction:
+ explanation_html:
+ Afin de poursuivre son instruction, un instructeur vous demande d’apporter des corrections à votre dossier nº %{dossier_id} de la démarche « %{libelle_demarche} ».
+ sva_svr:
+ Dans le cadre du principe du « %{rule_name} », le délai d’instruction est suspendu jusqu’à ce que vous déposiez les corrections demandées.
+ incomplete:
+ explanation_html:
+ Afin de commencer son instruction, un instructeur vous demande de compléter votre dossier nº %{dossier_id} de la démarche « %{libelle_demarche} ».
+ sva_svr:
+ Dans le cadre du principe du « %{rule_name} », le délai d’instruction sera réinitialisé à réception de votre dossier complet.
link:
Consultez la messagerie de votre dossier pour prendre connaissance des modifications à effectuer,
puis modifiez le dossier directement sur le site.
diff --git a/spec/factories/procedure.rb b/spec/factories/procedure.rb
index 1633bfdfc..6da87a671 100644
--- a/spec/factories/procedure.rb
+++ b/spec/factories/procedure.rb
@@ -416,6 +416,10 @@ FactoryBot.define do
trait :sva do
sva_svr { SVASVRConfiguration.new(decision: :sva).attributes }
end
+
+ trait :svr do
+ sva_svr { SVASVRConfiguration.new(decision: :svr).attributes }
+ end
end
end
diff --git a/spec/mailers/dossier_mailer_spec.rb b/spec/mailers/dossier_mailer_spec.rb
index 5f15ece6b..b69326f82 100644
--- a/spec/mailers/dossier_mailer_spec.rb
+++ b/spec/mailers/dossier_mailer_spec.rb
@@ -228,4 +228,53 @@ RSpec.describe DossierMailer, type: :mailer do
it { expect(subject.body).to include(dossier.procedure.libelle) }
it { expect(subject.body).to include("Suite à cette modification, vous ne suivez plus ce dossier.") }
end
+
+ describe '.notify_pending_correction' do
+ let(:procedure) { create(:procedure) }
+ let(:dossier) { create(:dossier, :en_construction, procedure:, sva_svr_decision_on:) }
+ let(:sva_svr_decision_on) { nil }
+ let(:kind) { :correction }
+ let(:commentaire) { create(:commentaire, dossier:) }
+
+ subject {
+ dossier.flag_as_pending_correction!(commentaire, kind)
+ described_class.with(commentaire:).notify_pending_correction
+ }
+
+ context 'kind is correction' do
+ it { expect(subject.subject).to eq("Vous devez corriger votre dossier nº #{dossier.id} « #{dossier.procedure.libelle} »") }
+ it { expect(subject.body).to include("apporter des corrections") }
+ it { expect(subject.body).not_to include("Silence") }
+ end
+
+ context 'sva with kind is correction' do
+ let(:sva_svr_decision_on) { Date.tomorrow }
+ let(:procedure) { create(:procedure, :sva) }
+
+ it { expect(subject.subject).to eq("Vous devez corriger votre dossier nº #{dossier.id} « #{dossier.procedure.libelle} »") }
+ it { expect(subject.body).to include("apporter des corrections") }
+ it { expect(subject.body).to include("Silence Vaut Accord") }
+ it { expect(subject.body).to include("suspendu") }
+ end
+
+ context 'sva with kind is incomplete' do
+ let(:sva_svr_decision_on) { Date.tomorrow }
+ let(:kind) { :incomplete }
+ let(:procedure) { create(:procedure, :sva) }
+
+ it { expect(subject.body).to include("compléter") }
+ it { expect(subject.body).to include("Silence Vaut Accord") }
+ it { expect(subject.body).to include("réinitialisé") }
+ end
+
+ context 'svr with kind is incomplete' do
+ let(:sva_svr_decision_on) { Date.tomorrow }
+ let(:kind) { :incomplete }
+ let(:procedure) { create(:procedure, :svr) }
+
+ it { expect(subject.body).to include("compléter") }
+ it { expect(subject.body).to include("Silence Vaut Rejet") }
+ it { expect(subject.body).to include("réinitialisé") }
+ end
+ end
end
diff --git a/spec/mailers/previews/dossier_mailer_preview.rb b/spec/mailers/previews/dossier_mailer_preview.rb
index 2066e4bf3..5b29ff27e 100644
--- a/spec/mailers/previews/dossier_mailer_preview.rb
+++ b/spec/mailers/previews/dossier_mailer_preview.rb
@@ -9,7 +9,13 @@ class DossierMailerPreview < ActionMailer::Preview
end
def notify_pending_correction
- DossierMailer.with(dossier: dossier_en_construction).notify_pending_correction
+ commentaire = commentaire(on: dossier_en_construction(sva_svr_decision: :sva)).tap { _1.build_dossier_correction(kind: :correction) }
+ DossierMailer.with(commentaire:).notify_pending_correction
+ end
+
+ def notify_pending_correction_sva_correction
+ commentaire = commentaire(on: dossier_en_construction(sva_svr_decision: :sva)).tap { _1.build_dossier_correction(kind: :correction) }
+ DossierMailer.with(commentaire:).notify_pending_correction
end
def notify_revert_to_instruction
@@ -99,8 +105,17 @@ class DossierMailerPreview < ActionMailer::Preview
Dossier.new(id: 47882, state: :en_instruction, procedure: procedure, user: user)
end
- def dossier_en_construction
- Dossier.new(id: 47882, state: :en_construction, procedure: procedure, user: user)
+ def dossier_en_construction(sva_svr_decision: nil)
+ local_procedure = procedure
+
+ dossier = Dossier.new(id: 47882, state: :en_construction, procedure: local_procedure, user: user)
+
+ if sva_svr_decision
+ local_procedure.sva_svr = { decision: sva_svr_decision, period: 2, unit: :months }
+ dossier.sva_svr_decision_on = 10.days.from_now.to_date
+ end
+
+ dossier
end
def dossier_accepte