feat(sva): pending correction email mention sva/svr

This commit is contained in:
Colin Darie 2023-06-26 16:03:58 +02:00
parent 4c46a2f8da
commit e1b21f980f
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4
9 changed files with 103 additions and 8 deletions

View file

@ -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|

View file

@ -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

View file

@ -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 ?

View file

@ -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 ?

View file

@ -3,8 +3,16 @@ en:
dossier_mailer:
notify_pending_correction:
subject: You need to modify your file no. %{dossier_id} « %{libelle_demarche} »
correction:
explanation_html:
In order to continue its instruction, <strong>an instructor requested you to edit information</strong> 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, <strong>an instructor requested you to complete</strong> 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

View file

@ -3,8 +3,16 @@ fr:
dossier_mailer:
notify_pending_correction:
subject: Vous devez corriger votre dossier nº %{dossier_id} « %{libelle_demarche} »
correction:
explanation_html:
Afin de poursuivre son instruction, <strong>un instructeur vous demande dapporter des corrections</strong> à votre dossier nº %{dossier_id} de la démarche « %{libelle_demarche} ».
sva_svr:
Dans le cadre du principe du « %{rule_name} », le délai dinstruction est suspendu jusquà ce que vous déposiez les corrections demandées.
incomplete:
explanation_html:
Afin de commencer son instruction, <strong>un instructeur vous demande de compléter</strong> votre dossier nº %{dossier_id} de la démarche « %{libelle_demarche} ».
sva_svr:
Dans le cadre du principe du « %{rule_name} », le délai dinstruction 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.

View file

@ -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

View file

@ -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

View file

@ -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