Merge pull request #5329 from betagouv/dev
This commit is contained in:
commit
84bd3879c2
7 changed files with 126 additions and 25 deletions
|
@ -15,4 +15,10 @@
|
|||
background-color: $orange;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
&.procedure-synthese-badge {
|
||||
color: $white;
|
||||
background-color: #6C757D;
|
||||
margin-right: 3px;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,18 @@ module Instructeurs
|
|||
.group('groupe_instructeurs.procedure_id')
|
||||
.reorder(nil)
|
||||
.count
|
||||
|
||||
@all_dossiers_counts = {}
|
||||
@all_dossiers_counts['à suivre'] = dossiers.without_followers.en_cours.count
|
||||
@all_dossiers_counts['suivis'] = current_instructeur
|
||||
.followed_dossiers
|
||||
.joins(:groupe_instructeur)
|
||||
.en_cours
|
||||
.where(groupe_instructeur_id: groupe_ids)
|
||||
.count
|
||||
@all_dossiers_counts['traités'] = dossiers.termine.count
|
||||
@all_dossiers_counts['dossiers'] = dossiers.all_state.count
|
||||
@all_dossiers_counts['archivés'] = dossiers.archived.count
|
||||
end
|
||||
|
||||
def show
|
||||
|
|
|
@ -8,11 +8,17 @@ def format_in_2_lines(pdf, label, text)
|
|||
pdf.text "\n", size: 9
|
||||
end
|
||||
|
||||
def render_box(pdf, text, x, width)
|
||||
box = ::Prawn::Text::Box.new(text || '', { document: pdf, width: width, overflow: :expand, at: [x, pdf.cursor] })
|
||||
box.render
|
||||
box.height
|
||||
end
|
||||
|
||||
def format_in_2_columns(pdf, label, text)
|
||||
pdf.text_box label, width: 200, height: 100, overflow: :expand, at: [0, pdf.cursor]
|
||||
pdf.text_box ":", width: 10, height: 100, overflow: :expand, at: [100, pdf.cursor]
|
||||
pdf.text_box text, width: 420, height: 100, overflow: :expand, at: [110, pdf.cursor]
|
||||
pdf.text "\n"
|
||||
h1 = render_box(pdf, label, 0, 100)
|
||||
h2 = render_box(pdf, ':', 100, 10)
|
||||
h3 = render_box(pdf, text, 110, pdf.bounds.width - 110)
|
||||
pdf.move_down 5 + [h1,h2,h3].max
|
||||
end
|
||||
|
||||
def add_title(pdf, title)
|
||||
|
@ -47,33 +53,32 @@ def render_siret_info(pdf, etablissement)
|
|||
end
|
||||
|
||||
def render_identite_etablissement(pdf, etablissement)
|
||||
pdf.text " - SIRET : #{etablissement.siret}"
|
||||
pdf.text " - SIRET du siège social: #{etablissement.entreprise.siret_siege_social}"
|
||||
pdf.text " - Dénomination : #{raison_sociale_or_name(etablissement)}"
|
||||
pdf.text " - Forme juridique : #{etablissement.entreprise_forme_juridique}"
|
||||
format_in_2_columns(pdf, "SIRET", etablissement.siret)
|
||||
format_in_2_columns(pdf, "SIRET du siège social", etablissement.entreprise.siret_siege_social) if etablissement.entreprise.siret_siege_social.present?
|
||||
format_in_2_columns(pdf, "Dénomination", raison_sociale_or_name(etablissement))
|
||||
format_in_2_columns(pdf, "Forme juridique ", etablissement.entreprise_forme_juridique)
|
||||
if etablissement.entreprise_capital_social.present?
|
||||
pdf.text " - Capital social : #{pretty_currency(etablissement.entreprise_capital_social)}"
|
||||
format_in_2_columns(pdf, "Capital social ", pretty_currency(etablissement.entreprise_capital_social))
|
||||
end
|
||||
pdf.text " - Libellé NAF : #{etablissement.libelle_naf}"
|
||||
pdf.text " - Code NAF : #{etablissement.naf}"
|
||||
pdf.text " - Date de création : #{try_format_date(etablissement.entreprise.date_creation)}"
|
||||
format_in_2_columns(pdf, "Libellé NAF ", etablissement.libelle_naf)
|
||||
format_in_2_columns(pdf, "Code NAF ", etablissement.naf)
|
||||
format_in_2_columns(pdf, "Date de création ", try_format_date(etablissement.entreprise.date_creation))
|
||||
if @include_infos_administration
|
||||
pdf.text " - Effectif mensuel #{try_format_mois_effectif(etablissement)} (URSSAF) : #{etablissement.entreprise_effectif_mensuel}"
|
||||
pdf.text " - Effectif moyen annuel #{etablissement.entreprise_effectif_annuel_annee} (URSSAF) : #{etablissement.entreprise_effectif_annuel}"
|
||||
format_in_2_columns(pdf, "Effectif mensuel #{try_format_mois_effectif(etablissement)} (URSSAF) ", etablissement.entreprise_effectif_mensuel)
|
||||
format_in_2_columns(pdf, "Effectif moyen annuel #{etablissement.entreprise_effectif_annuel_annee} (URSSAF) ", etablissement.entreprise_effectif_annuel)
|
||||
end
|
||||
pdf.text " - Effectif de l'organisation (INSEE) : #{effectif(etablissement)}"
|
||||
pdf.text " - Code effectif : #{etablissement.entreprise.code_effectif_entreprise}"
|
||||
pdf.text " - Numéro de TVA intracommunautaire : #{etablissement.entreprise.numero_tva_intracommunautaire}"
|
||||
pdf.text " - Adresse : #{etablissement.adresse}"
|
||||
format_in_2_columns(pdf, "Effectif (ISPF) ", effectif(etablissement))
|
||||
format_in_2_columns(pdf, "Code effectif ", etablissement.entreprise.code_effectif_entreprise)
|
||||
format_in_2_columns(pdf, "Numéro de TVA intracommunautaire ", etablissement.entreprise.numero_tva_intracommunautaire) if etablissement.entreprise.numero_tva_intracommunautaire.present?
|
||||
format_in_2_columns(pdf, "Adresse ", etablissement.adresse)
|
||||
if etablissement.association?
|
||||
pdf.text " - Numéro RNA : #{etablissement.association_rna}"
|
||||
pdf.text " - Titre : #{etablissement.association_titre}"
|
||||
pdf.text " - Objet : #{etablissement.association_objet}"
|
||||
pdf.text " - Date de création : #{try_format_date(etablissement.association_date_creation)}"
|
||||
pdf.text " - Date de publication : #{try_format_date(etablissement.association_date_publication)}"
|
||||
pdf.text " - Date de déclaration : #{try_format_date(etablissement.association_date_declaration)}"
|
||||
format_in_2_columns(pdf, "Numéro RNA ", etablissement.association_rna)
|
||||
format_in_2_columns(pdf, "Titre ", etablissement.association_titre)
|
||||
format_in_2_columns(pdf, "Objet ", etablissement.association_objet)
|
||||
format_in_2_columns(pdf, "Date de création ", try_format_date(etablissement.association_date_creation))
|
||||
format_in_2_columns(pdf, "Date de publication ", try_format_date(etablissement.association_date_publication))
|
||||
format_in_2_columns(pdf, "Date de déclaration ", try_format_date(etablissement.association_date_declaration))
|
||||
end
|
||||
pdf.text "\n"
|
||||
end
|
||||
|
||||
def render_single_champ(pdf, champ)
|
||||
|
|
6
app/views/instructeurs/procedures/_synthese.html.haml
Normal file
6
app/views/instructeurs/procedures/_synthese.html.haml
Normal file
|
@ -0,0 +1,6 @@
|
|||
- if procedures.length > 1
|
||||
.tab-title
|
||||
%span
|
||||
Synthèse des dossiers
|
||||
- all_dossiers_counts.each_with_index do |(label, dossier_count)|
|
||||
%span.badge.procedure-synthese-badge= number_with_html_delimiter(dossier_count) + ' ' + label
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
.container
|
||||
%h1.page-title Démarches
|
||||
= render partial: 'instructeurs/procedures/synthese', locals: { procedures: @procedures, all_dossiers_counts: @all_dossiers_counts }
|
||||
|
||||
= render partial: 'instructeurs/procedures/list', locals: { procedures: @procedures,
|
||||
dossiers_count_per_procedure: @dossiers_count_per_procedure,
|
||||
|
|
|
@ -134,6 +134,12 @@ describe Instructeurs::ProceduresController, type: :controller do
|
|||
it { expect(assigns(:dossiers_archived_count_per_procedure)[procedure.id]).to eq(nil) }
|
||||
it { expect(assigns(:followed_dossiers_count_per_procedure)[procedure.id]).to eq(nil) }
|
||||
it { expect(assigns(:dossiers_termines_count_per_procedure)[procedure.id]).to eq(nil) }
|
||||
|
||||
it { expect(assigns(:all_dossiers_counts)['à suivre']).to eq(0) }
|
||||
it { expect(assigns(:all_dossiers_counts)['suivis']).to eq(0) }
|
||||
it { expect(assigns(:all_dossiers_counts)['traités']).to eq(0) }
|
||||
it { expect(assigns(:all_dossiers_counts)['dossiers']).to eq(0) }
|
||||
it { expect(assigns(:all_dossiers_counts)['archivés']).to eq(0) }
|
||||
end
|
||||
|
||||
context "with not draft state on multiple procedures" do
|
||||
|
@ -164,6 +170,12 @@ describe Instructeurs::ProceduresController, type: :controller do
|
|||
it { expect(assigns(:followed_dossiers_count_per_procedure)[procedure2.id]).to eq(1) }
|
||||
it { expect(assigns(:dossiers_archived_count_per_procedure)[procedure2.id]).to eq(nil) }
|
||||
it { expect(assigns(:dossiers_termines_count_per_procedure)[procedure2.id]).to eq(1) }
|
||||
|
||||
it { expect(assigns(:all_dossiers_counts)['à suivre']).to eq(3 + 0) }
|
||||
it { expect(assigns(:all_dossiers_counts)['suivis']).to eq(0 + 1) }
|
||||
it { expect(assigns(:all_dossiers_counts)['traités']).to eq(0 + 1) }
|
||||
it { expect(assigns(:all_dossiers_counts)['dossiers']).to eq(3 + 3) }
|
||||
it { expect(assigns(:all_dossiers_counts)['archivés']).to eq(1 + 0) }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -198,6 +210,12 @@ describe Instructeurs::ProceduresController, type: :controller do
|
|||
it { expect(assigns(:dossiers_termines_count_per_procedure)[procedure.id]).to eq(10) }
|
||||
it { expect(assigns(:dossiers_count_per_procedure)[procedure.id]).to eq(4 + 6 + 10) }
|
||||
it { expect(assigns(:dossiers_archived_count_per_procedure)[procedure.id]).to eq(14) }
|
||||
|
||||
it { expect(assigns(:all_dossiers_counts)['à suivre']).to eq(4) }
|
||||
it { expect(assigns(:all_dossiers_counts)['suivis']).to eq(6) }
|
||||
it { expect(assigns(:all_dossiers_counts)['traités']).to eq(10) }
|
||||
it { expect(assigns(:all_dossiers_counts)['dossiers']).to eq(4 + 6 + 10) }
|
||||
it { expect(assigns(:all_dossiers_counts)['archivés']).to eq(14) }
|
||||
end
|
||||
|
||||
context 'when an instructeur only belongs to one of them gi' do
|
||||
|
@ -213,6 +231,12 @@ describe Instructeurs::ProceduresController, type: :controller do
|
|||
it { expect(assigns(:dossiers_termines_count_per_procedure)[procedure.id]).to eq(5) }
|
||||
it { expect(assigns(:dossiers_count_per_procedure)[procedure.id]).to eq(2 + 3 + 5) }
|
||||
it { expect(assigns(:dossiers_archived_count_per_procedure)[procedure.id]).to eq(7) }
|
||||
|
||||
it { expect(assigns(:all_dossiers_counts)['à suivre']).to eq(2) }
|
||||
it { expect(assigns(:all_dossiers_counts)['suivis']).to eq(3) }
|
||||
it { expect(assigns(:all_dossiers_counts)['traités']).to eq(5) }
|
||||
it { expect(assigns(:all_dossiers_counts)['dossiers']).to eq(2 + 3 + 5) }
|
||||
it { expect(assigns(:all_dossiers_counts)['archivés']).to eq(7) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
describe 'instructeurs/procedures/_synthese.html.haml', type: :view do
|
||||
let(:current_instructeur) { create(:instructeur) }
|
||||
let(:procedure) { create(:procedure) }
|
||||
let!(:dossier) { create(:dossier, procedure: procedure) }
|
||||
|
||||
context 'when instructeur has 2 procedures and 1 file, table is shown' do
|
||||
let(:procedure2) { create(:procedure) }
|
||||
|
||||
subject {
|
||||
render 'instructeurs/procedures/synthese.html.haml',
|
||||
all_dossiers_counts: {
|
||||
'à suivre': 0,
|
||||
'suivis': 0,
|
||||
'traités': 1,
|
||||
'dossiers': 1,
|
||||
'archivés': 0
|
||||
},
|
||||
procedures: [procedure, procedure2]
|
||||
}
|
||||
|
||||
it { is_expected.to have_text('Synthèse des dossiers') }
|
||||
it { is_expected.to have_text('suivis') }
|
||||
it { is_expected.to have_text('traités') }
|
||||
it { is_expected.to have_text('dossiers') }
|
||||
it { is_expected.to have_text('archivés') }
|
||||
end
|
||||
|
||||
context 'when instructeur has 1 procedure and 1 file, table is not shown' do
|
||||
subject {
|
||||
render 'instructeurs/procedures/synthese.html.haml',
|
||||
all_dossiers_counts: {
|
||||
'à suivre': 0,
|
||||
'suivis': 0,
|
||||
'traités': 1,
|
||||
'dossiers': 1,
|
||||
'archivés': 0
|
||||
},
|
||||
procedures: [procedure]
|
||||
}
|
||||
|
||||
it { is_expected.not_to have_text('Synthèse des dossiers') }
|
||||
it { is_expected.not_to have_text('suivis') }
|
||||
it { is_expected.not_to have_text('traités') }
|
||||
it { is_expected.not_to have_text('dossiers') }
|
||||
it { is_expected.not_to have_text('archivés') }
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue