diff --git a/app/models/procedure_presentation.rb b/app/models/procedure_presentation.rb index 1e55d8c13..03b75eefe 100644 --- a/app/models/procedure_presentation.rb +++ b/app/models/procedure_presentation.rb @@ -16,6 +16,7 @@ class ProcedurePresentation < ApplicationRecord def fields fields = [ field_hash('Créé le', 'self', 'created_at'), + field_hash('En construction le', 'self', 'en_construction_at'), field_hash('Mis à jour le', 'self', 'updated_at'), field_hash('Demandeur', 'user', 'email') ] diff --git a/app/views/dossiers/_infos_entreprise.html.haml b/app/views/dossiers/_infos_entreprise.html.haml index f07f3e90c..a4c5e6311 100644 --- a/app/views/dossiers/_infos_entreprise.html.haml +++ b/app/views/dossiers/_infos_entreprise.html.haml @@ -47,11 +47,7 @@ .row .col-xs-4.entreprise-label Exercices : .col-xs-8.entreprise-info - - @facade.etablissement.exercices.each_with_index do |exercice, index| - %strong - = "#{exercice.date_fin_exercice.year} : " - = number_to_currency(exercice.ca) - %br + les exercices comptables des trois dernières années sont joints à votre dossier. .row.split-row .col-xs-12.split-hr diff --git a/app/views/new_gestionnaire/avis/show.html.haml b/app/views/new_gestionnaire/avis/show.html.haml index 225e0c6f3..b2c53c6a8 100644 --- a/app/views/new_gestionnaire/avis/show.html.haml +++ b/app/views/new_gestionnaire/avis/show.html.haml @@ -2,4 +2,4 @@ = render partial: 'header', locals: { avis: @avis, dossier: @dossier } -= render partial: 'shared/dossiers/demande', locals: { dossier: @dossier, demande_seen_at: nil } += render partial: 'shared/dossiers/demande', locals: { dossier: @dossier, demande_seen_at: nil, profile: 'instructeur' } diff --git a/app/views/new_gestionnaire/dossiers/print.html.haml b/app/views/new_gestionnaire/dossiers/print.html.haml index 4e0c5e62f..3bf327b69 100644 --- a/app/views/new_gestionnaire/dossiers/print.html.haml +++ b/app/views/new_gestionnaire/dossiers/print.html.haml @@ -6,7 +6,7 @@ = render partial: "shared/dossiers/user_infos", locals: { user: @dossier.user } - if @dossier.etablissement.present? - = render partial: "shared/dossiers/identite_entreprise", locals: { etablissement: @dossier.etablissement } + = render partial: "shared/dossiers/identite_entreprise", locals: { etablissement: @dossier.etablissement, profile: 'instructeur' } - if @dossier.individual.present? = render partial: "shared/dossiers/identite_individual", locals: { individual: @dossier.individual } @@ -15,7 +15,7 @@ - champs = @dossier.champs.decorate - if champs.any? - = render partial: "shared/dossiers/champs", locals: { champs: champs, dossier: @dossier, demande_seen_at: nil } + = render partial: "shared/dossiers/champs", locals: { champs: champs, dossier: @dossier, demande_seen_at: nil, profile: 'instructeur' } - if @dossier.procedure.use_api_carto %h3 Cartographie diff --git a/app/views/new_gestionnaire/dossiers/show.html.haml b/app/views/new_gestionnaire/dossiers/show.html.haml index 694aea923..cb5a2a4a3 100644 --- a/app/views/new_gestionnaire/dossiers/show.html.haml +++ b/app/views/new_gestionnaire/dossiers/show.html.haml @@ -2,4 +2,4 @@ = render partial: "header", locals: { dossier: @dossier } -= render partial: "shared/dossiers/demande", locals: { dossier: @dossier, demande_seen_at: @demande_seen_at } += render partial: "shared/dossiers/demande", locals: { dossier: @dossier, demande_seen_at: @demande_seen_at, profile: 'instructeur' } diff --git a/app/views/new_user/dossiers/demande.html.haml b/app/views/new_user/dossiers/demande.html.haml index 623a8ac54..b29f8db7f 100644 --- a/app/views/new_user/dossiers/demande.html.haml +++ b/app/views/new_user/dossiers/demande.html.haml @@ -6,7 +6,7 @@ #dossier-show = render partial: 'new_user/dossiers/show/header', locals: { dossier: @dossier } - = render partial: 'shared/dossiers/demande', locals: { dossier: @dossier, demande_seen_at: nil } + = render partial: 'shared/dossiers/demande', locals: { dossier: @dossier, demande_seen_at: nil, profile: 'usager' } .container - if !@dossier.read_only? diff --git a/app/views/shared/dossiers/_champs.html.haml b/app/views/shared/dossiers/_champs.html.haml index ca2cc3025..eee34dde3 100644 --- a/app/views/shared/dossiers/_champs.html.haml +++ b/app/views/shared/dossiers/_champs.html.haml @@ -55,7 +55,7 @@ %td.rich-text %span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) } - if c.etablissement.present? - = render partial: "shared/dossiers/identite_entreprise", locals: { etablissement: c.etablissement } + = render partial: "shared/dossiers/identite_entreprise", locals: { etablissement: c.etablissement, profile: profile } - else %th.libelle = "#{c.libelle} :" diff --git a/app/views/shared/dossiers/_demande.html.haml b/app/views/shared/dossiers/_demande.html.haml index e5595e499..9e7e572af 100644 --- a/app/views/shared/dossiers/_demande.html.haml +++ b/app/views/shared/dossiers/_demande.html.haml @@ -4,7 +4,7 @@ = render partial: "shared/dossiers/user_infos", locals: { user: dossier.user } - if dossier.etablissement.present? - = render partial: "shared/dossiers/identite_entreprise", locals: { etablissement: dossier.etablissement } + = render partial: "shared/dossiers/identite_entreprise", locals: { etablissement: dossier.etablissement, profile: profile } - if dossier.individual.present? = render partial: "shared/dossiers/identite_individual", locals: { individual: dossier.individual } @@ -13,7 +13,7 @@ - champs = dossier.champs.includes(:type_de_champ).decorate - if champs.any? .card - = render partial: "shared/dossiers/champs", locals: { champs: champs, demande_seen_at: demande_seen_at } + = render partial: "shared/dossiers/champs", locals: { champs: champs, demande_seen_at: demande_seen_at, profile: profile } - if dossier.procedure.use_api_carto .tab-title Cartographie diff --git a/app/views/shared/dossiers/_identite_entreprise.html.haml b/app/views/shared/dossiers/_identite_entreprise.html.haml index 8dfe73487..87be8390f 100644 --- a/app/views/shared/dossiers/_identite_entreprise.html.haml +++ b/app/views/shared/dossiers/_identite_entreprise.html.haml @@ -44,10 +44,14 @@ %tr %th.libelle Exercices : %td - - etablissement.exercices.each_with_index do |exercice, index| - = "#{exercice.date_fin_exercice.year} : " - = pretty_currency(exercice.ca) - %br + - if profile == 'instructeur' + - etablissement.exercices.each_with_index do |exercice, index| + = "#{exercice.date_fin_exercice.year} : " + = pretty_currency(exercice.ca) + %br + - elsif etablissement.exercices.present? + = t('activemodel.models.exercices_summary', count: etablissement.exercices.count) + - if etablissement.association? %tr %th.libelle Numéro RNA : diff --git a/config/locales/models/siret/fr.yml b/config/locales/models/siret/fr.yml index 1a62a04d5..4e54f43c3 100644 --- a/config/locales/models/siret/fr.yml +++ b/config/locales/models/siret/fr.yml @@ -2,6 +2,9 @@ fr: activemodel: models: siret: 'SIRET' + exercices_summary: + one: L’exercice comptable de l’année dernière a été joint à votre dossier. + other: "Les exercices comptables des %{count} dernières années ont été joints à votre dossier." errors: models: siret: diff --git a/spec/models/procedure_presentation_spec.rb b/spec/models/procedure_presentation_spec.rb index f85d9de97..d4951f386 100644 --- a/spec/models/procedure_presentation_spec.rb +++ b/spec/models/procedure_presentation_spec.rb @@ -58,6 +58,7 @@ describe ProcedurePresentation do let(:expected) { [ { "label" => 'Créé le', "table" => 'self', "column" => 'created_at' }, + { "label" => 'En construction le', "table" => 'self', "column" => 'en_construction_at' }, { "label" => 'Mis à jour le', "table" => 'self', "column" => 'updated_at' }, { "label" => 'Demandeur', "table" => 'user', "column" => 'email' }, { "label" => 'SIREN', "table" => 'etablissement', "column" => 'entreprise_siren' }, @@ -129,13 +130,29 @@ describe ProcedurePresentation do context 'for self table' do let(:table) { 'self' } - let(:column) { 'updated_at' } # All other columns work the same, no extra test required - let(:dossier) { create(:dossier, procedure: procedure) } + context 'for created_at column' do + let(:column) { 'created_at' } + let(:dossier) { Timecop.freeze(DateTime.new(1992, 3, 22)) { create(:dossier, procedure: procedure) } } - before { dossier.touch(time: DateTime.new(2018, 9, 25)) } + it { is_expected.to eq(DateTime.new(1992, 3, 22)) } + end - it { is_expected.to eq(DateTime.new(2018, 9, 25)) } + context 'for en_construction_at column' do + let(:column) { 'en_construction_at' } + let(:dossier) { create(:dossier, :en_construction, procedure: procedure, en_construction_at: DateTime.new(2018, 10, 17)) } + + it { is_expected.to eq(DateTime.new(2018, 10, 17)) } + end + + context 'for updated_at column' do + let(:column) { 'updated_at' } + let(:dossier) { create(:dossier, procedure: procedure) } + + before { dossier.touch(time: DateTime.new(2018, 9, 25)) } + + it { is_expected.to eq(DateTime.new(2018, 9, 25)) } + end end context 'for user table' do @@ -240,18 +257,36 @@ describe ProcedurePresentation do context 'for self table' do let(:table) { 'self' } - let(:column) { 'updated_at' } # All other columns work the same, no extra test required let(:order) { 'asc' } # Desc works the same, no extra test required - let(:recent_dossier) { create(:dossier, procedure: procedure) } - let(:older_dossier) { create(:dossier, procedure: procedure) } + context 'for created_at column' do + let(:column) { 'created_at' } + let!(:recent_dossier) { Timecop.freeze(DateTime.new(2018, 10, 17)) { create(:dossier, procedure: procedure) } } + let!(:older_dossier) { Timecop.freeze(DateTime.new(2003, 11, 11)) { create(:dossier, procedure: procedure) } } - before do - recent_dossier.touch(time: DateTime.new(2018, 9, 25)) - older_dossier.touch(time: DateTime.new(2018, 5, 13)) + it { is_expected.to eq([older_dossier, recent_dossier].map(&:id)) } end - it { is_expected.to eq([older_dossier, recent_dossier].map(&:id)) } + context 'for en_construction_at column' do + let(:column) { 'en_construction_at' } + let!(:recent_dossier) { create(:dossier, :en_construction, procedure: procedure, en_construction_at: DateTime.new(2018, 10, 17)) } + let!(:older_dossier) { create(:dossier, :en_construction, procedure: procedure, en_construction_at: DateTime.new(2013, 1, 1)) } + + it { is_expected.to eq([older_dossier, recent_dossier].map(&:id)) } + end + + context 'for updated_at column' do + let(:column) { 'updated_at' } + let(:recent_dossier) { create(:dossier, procedure: procedure) } + let(:older_dossier) { create(:dossier, procedure: procedure) } + + before do + recent_dossier.touch(time: DateTime.new(2018, 9, 25)) + older_dossier.touch(time: DateTime.new(2018, 5, 13)) + end + + it { is_expected.to eq([older_dossier, recent_dossier].map(&:id)) } + end end context 'for type_de_champ table' do @@ -341,6 +376,14 @@ describe ProcedurePresentation do it { is_expected.to contain_exactly(kept_dossier.id) } end + context 'for en_construction_at column' do + let!(:kept_dossier) { create(:dossier, :en_construction, procedure: procedure, en_construction_at: DateTime.new(2018, 10, 17)) } + let!(:discarded_dossier) { create(:dossier, :en_construction, procedure: procedure, en_construction_at: DateTime.new(2013, 1, 1)) } + let(:filter) { [{ 'table' => 'self', 'column' => 'en_construction_at', 'value' => '17/10/2018' }] } + + it { is_expected.to contain_exactly(kept_dossier.id) } + end + context 'for updated_at column' do let(:kept_dossier) { create(:dossier, procedure: procedure) } let(:discarded_dossier) { create(:dossier, procedure: procedure) } diff --git a/spec/views/shared/dossiers/_demande.html.haml_spec.rb b/spec/views/shared/dossiers/_demande.html.haml_spec.rb index d8c507fce..7cbfddb54 100644 --- a/spec/views/shared/dossiers/_demande.html.haml_spec.rb +++ b/spec/views/shared/dossiers/_demande.html.haml_spec.rb @@ -9,7 +9,7 @@ describe 'shared/dossiers/demande.html.haml', type: :view do sign_in current_gestionnaire end - subject! { render 'shared/dossiers/demande.html.haml', dossier: dossier, demande_seen_at: nil } + subject! { render 'shared/dossiers/demande.html.haml', dossier: dossier, demande_seen_at: nil, profile: 'usager' } context 'when dossier was created by an etablissement' do let(:etablissement) { create(:etablissement) } diff --git a/spec/views/shared/dossiers/_identite_entreprise.html.haml_spec.rb b/spec/views/shared/dossiers/_identite_entreprise.html.haml_spec.rb index f80e4eee8..91189a6e2 100644 --- a/spec/views/shared/dossiers/_identite_entreprise.html.haml_spec.rb +++ b/spec/views/shared/dossiers/_identite_entreprise.html.haml_spec.rb @@ -1,5 +1,5 @@ describe 'shared/dossiers/identite_entreprise.html.haml', type: :view do - before { render 'shared/dossiers/identite_entreprise.html.haml', etablissement: etablissement } + before { render 'shared/dossiers/identite_entreprise.html.haml', etablissement: etablissement, profile: 'usager' } context "there is an association" do let(:etablissement) { create(:etablissement, :is_association) }