Use new models in controllers and views
This commit is contained in:
parent
753a81c2d3
commit
d99eed122d
15 changed files with 44 additions and 61 deletions
|
@ -130,7 +130,7 @@ class Users::DescriptionController < UsersController
|
|||
@dossier ||= current_user_dossier
|
||||
|
||||
if (@dossier.procedure.for_individual? && @dossier.individual.nil?) ||
|
||||
(!@dossier.procedure.for_individual? && @dossier.entreprise.nil?)
|
||||
(!@dossier.procedure.for_individual? && @dossier.etablissement.nil?)
|
||||
redirect_to url_for(users_dossier_path(@dossier.id))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -112,7 +112,7 @@ class Users::DossiersController < UsersController
|
|||
|
||||
update_current_user_siret!(siret)
|
||||
|
||||
etablissement_attributes = ApiEntrepriseService.get_etablissement_params_for_siret(siret, @facade.dossier.procedure_id, @facade.dossier)
|
||||
etablissement_attributes = ApiEntrepriseService.get_etablissement_params_for_siret(siret, @facade.dossier.procedure_id)
|
||||
|
||||
if etablissement_attributes.present?
|
||||
etablissement_attributes = ActionController::Parameters.new(etablissement_attributes).permit!
|
||||
|
|
|
@ -13,10 +13,6 @@ class DossierFacades
|
|||
@dossier.ordered_champs
|
||||
end
|
||||
|
||||
def entreprise
|
||||
@dossier.entreprise.decorate if @dossier.entreprise.present? && @dossier.entreprise.siren.present?
|
||||
end
|
||||
|
||||
def etablissement
|
||||
@dossier.etablissement
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
.col-lg-4.col-md-4.col-sm-4.col-xs-4.action
|
||||
Renseigner un SIRET
|
||||
|
||||
- if @facade.entreprise.present?
|
||||
- if @facade.etablissement.present?
|
||||
.default-data-block
|
||||
.row.show-block.infos#infos_entreprise
|
||||
.header
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
.col-md-12.col-sm-12.col-xs-12.col-xs-12
|
||||
%h4
|
||||
= @facade.entreprise.raison_sociale_or_name
|
||||
= raison_sociale_or_name(@facade.etablissement)
|
||||
.row.split-row
|
||||
.col-xs-12.split-hr
|
||||
.row
|
||||
|
@ -9,13 +9,13 @@
|
|||
.row
|
||||
.col-xs-4.entreprise-label Siret :
|
||||
.col-xs-8.entreprise-info= @facade.etablissement.siret
|
||||
- if @facade.etablissement.siret != @facade.entreprise.siret_siege_social
|
||||
- if @facade.etablissement.siret != @facade.etablissement.entreprise.siret_siege_social
|
||||
.row
|
||||
.col-xs-4.entreprise-label SIRET siège social :
|
||||
.col-xs-8.entreprise-info= @facade.entreprise.siret_siege_social
|
||||
.col-xs-8.entreprise-info= @facade.etablissement.entreprise.siret_siege_social
|
||||
.row
|
||||
.col-xs-4.entreprise-label Forme juridique :
|
||||
.col-xs-8.entreprise-info= @facade.entreprise.forme_juridique
|
||||
.col-xs-8.entreprise-info= @facade.etablissement.entreprise.forme_juridique
|
||||
.row
|
||||
.col-xs-4.entreprise-label Libellé naf :
|
||||
.col-xs-8.entreprise-info= @facade.etablissement.libelle_naf
|
||||
|
@ -24,16 +24,16 @@
|
|||
.col-xs-8.entreprise-info= @facade.etablissement.naf
|
||||
.row
|
||||
.col-xs-4.entreprise-label Date de création :
|
||||
.col-xs-8.entreprise-info= Time.at(@facade.entreprise.date_creation).localtime.strftime "%d-%m-%Y"
|
||||
.col-xs-8.entreprise-info= @facade.etablissement.entreprise.date_creation&.strftime("%d-%m-%Y")
|
||||
.row
|
||||
.col-xs-4.entreprise-label Effectif organisation :
|
||||
.col-xs-8.entreprise-info= @facade.entreprise.effectif
|
||||
.col-xs-8.entreprise-info= effectif(@facade.etablissement)
|
||||
.row
|
||||
.col-xs-4.entreprise-label Code effectif :
|
||||
.col-xs-8.entreprise-info= @facade.entreprise.code_effectif_entreprise
|
||||
.col-xs-8.entreprise-info= @facade.etablissement.entreprise.code_effectif_entreprise
|
||||
.row
|
||||
.col-xs-4.entreprise-label Numéro TVA intracommunautaire :
|
||||
.col-xs-8.entreprise-info= @facade.entreprise.numero_tva_intracommunautaire
|
||||
.col-xs-8.entreprise-info= @facade.etablissement.entreprise.numero_tva_intracommunautaire
|
||||
|
||||
.row
|
||||
.col-xs-4.entreprise-label Adresse :
|
||||
|
@ -42,7 +42,7 @@
|
|||
= line
|
||||
.row
|
||||
.col-xs-4.entreprise-label Capital social :
|
||||
.col-xs-8.entreprise-info= @facade.entreprise.pretty_capital_social
|
||||
.col-xs-8.entreprise-info= pretty_currency(@facade.etablissement.entreprise.capital_social)
|
||||
|
||||
.row
|
||||
.col-xs-4.entreprise-label Exercices :
|
||||
|
@ -55,5 +55,5 @@
|
|||
|
||||
.row.split-row
|
||||
.col-xs-12.split-hr
|
||||
- if @facade.entreprise.rna_information.present?
|
||||
- if @facade.etablissement.association?
|
||||
= render partial: '/dossiers/infos_rna'
|
||||
|
|
|
@ -2,21 +2,21 @@
|
|||
.col-lg-6.col-md-6.col-sm-6.col-xs-6
|
||||
%dl.dl-horizontal
|
||||
%dt Association ID :
|
||||
%dd.text-success= @facade.entreprise.rna_information.association_id
|
||||
%dd.text-success= @facade.etablissement.association_rna
|
||||
|
||||
%dt Titre :
|
||||
%dd= @facade.entreprise.rna_information.titre
|
||||
%dd= @facade.etablissement.association_titre
|
||||
|
||||
%dt Objet :
|
||||
%dd= @facade.entreprise.rna_information.objet
|
||||
%dd= @facade.etablissement.association_objet
|
||||
|
||||
.col-lg-6.col-md-6.col-sm-6.col-xs-6
|
||||
%dl.dl-horizontal
|
||||
%dt Date création :
|
||||
%dd= @facade.entreprise.rna_information.date_creation
|
||||
%dd= @facade.etablissement.association_date_creation&.strftime("%d/%m/%Y")
|
||||
|
||||
%dt Capital publication :
|
||||
%dd= @facade.entreprise.rna_information.date_publication
|
||||
%dd= @facade.etablissement.association_date_publication&.strftime("%d/%m/%Y")
|
||||
|
||||
%dt Capital déclaration :
|
||||
%dd= @facade.entreprise.rna_information.date_declaration
|
||||
%dd= @facade.etablissement.association_date_declaration&.strftime("%d/%m/%Y")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
.col-xs-3.center
|
||||
%h3 Ma procédure
|
||||
|
||||
#logos.center{ class: (@facade.entreprise.nil? ? '' : 'mask') }
|
||||
#logos.center{ class: (@facade.etablissement.nil? ? '' : 'mask') }
|
||||
- if @facade.procedure.euro_flag
|
||||
#euro_flag.flag
|
||||
= image_tag('drapeau_europe.png')
|
||||
|
@ -15,7 +15,7 @@
|
|||
%h2#titre-procedure.text-info
|
||||
= @facade.procedure.libelle
|
||||
|
||||
#description_procedure{ style: 'width: 95%;', class: (@facade.entreprise.nil? ? '' : 'mask') }
|
||||
#description_procedure{ style: 'width: 95%;', class: (@facade.etablissement.nil? ? '' : 'mask') }
|
||||
= h simple_format(@facade.procedure.description)
|
||||
|
||||
- if @facade.procedure.lien_site_web.present?
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
%h3
|
||||
Mes informations
|
||||
%br
|
||||
- if @facade.entreprise.present?
|
||||
- if @facade.etablissement.present?
|
||||
.center{ style: 'margin-left: -5%;' }
|
||||
Vous êtes authentifié avec le SIRET
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
|||
|
||||
.etape.etapes-informations.col-xs-9
|
||||
.row
|
||||
- if @facade.entreprise.nil?
|
||||
- if @facade.etablissement.nil?
|
||||
#new_siret{ style: 'margin-left: 20%; margin-top: 5%;' }
|
||||
= form_for @facade.dossier, html: { class: 'form-inline' }, url: users_dossier_siret_informations_path(dossier_id: @facade.dossier.id), method: :post, remote: true do |f|
|
||||
.form-group.form-group-lg
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
%tbody
|
||||
%tr
|
||||
%th.libelle Dénomination :
|
||||
%td= etablissement.entreprise_raison_sociale_or_name
|
||||
%td= raison_sociale_or_name(etablissement)
|
||||
%tr
|
||||
%th.libelle SIRET :
|
||||
%td= etablissement.entreprise_siret_siege_social
|
||||
%td= etablissement.entreprise.siret_siege_social
|
||||
%tr
|
||||
%th.libelle Forme juridique :
|
||||
%td= sanitize(etablissement.entreprise_forme_juridique)
|
||||
%td= sanitize(etablissement.entreprise.forme_juridique)
|
||||
%tr
|
||||
%th.libelle Libellé NAF :
|
||||
%td= etablissement.libelle_naf
|
||||
|
@ -17,16 +17,16 @@
|
|||
%td= etablissement.naf
|
||||
%tr
|
||||
%th.libelle Date de création :
|
||||
%td= etablissement.entreprise_date_creation&.strftime("%d/%m/%Y")
|
||||
%td= etablissement.entreprise.date_creation&.strftime("%d/%m/%Y")
|
||||
%tr
|
||||
%th.libelle Effectif de l'organisation :
|
||||
%td= etablissement.entreprise_effectif
|
||||
%td= effectif(etablissement)
|
||||
%tr
|
||||
%th.libelle Code effectif :
|
||||
%td= etablissement.entreprise_code_effectif_entreprise
|
||||
%td= etablissement.entreprise.code_effectif_entreprise
|
||||
%tr
|
||||
%th.libelle Numéro de TVA intracommunautaire :
|
||||
%td= etablissement.entreprise_numero_tva_intracommunautaire
|
||||
%td= etablissement.entreprise.numero_tva_intracommunautaire
|
||||
%tr
|
||||
%th.libelle Adresse :
|
||||
%td
|
||||
|
@ -35,7 +35,7 @@
|
|||
%br
|
||||
%tr
|
||||
%th.libelle Capital social :
|
||||
%td= pretty_currency(etablissement.entreprise_capital_social)
|
||||
%td= pretty_currency(etablissement.entreprise.capital_social)
|
||||
%tr
|
||||
%th.libelle Exercices :
|
||||
%td
|
||||
|
@ -43,7 +43,7 @@
|
|||
= "#{exercice.date_fin_exercice.year} : "
|
||||
= pretty_currency(exercice.ca)
|
||||
%br
|
||||
- if etablissement.association_rna.present?
|
||||
- if etablissement.association?
|
||||
%tr
|
||||
%th.libelle Numéro RNA :
|
||||
%td= etablissement.association_rna
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
.etablissement-titre
|
||||
= etablissement.titre
|
||||
= raison_sociale_or_name(etablissement)
|
||||
= etablissement.entreprise_forme_juridique
|
||||
- if etablissement.entreprise_capital_social.present?
|
||||
au capital social de
|
||||
= number_to_currency(etablissement.entreprise_capital_social)
|
||||
= pretty_currency(etablissement.entreprise_capital_social)
|
||||
|
|
|
@ -173,7 +173,7 @@ describe API::V1::DossiersController do
|
|||
it { expect(subject[:raison_sociale]).to eq('GRTGAZ') }
|
||||
it { expect(subject[:siret_siege_social]).to eq('44011762001530') }
|
||||
it { expect(subject[:code_effectif_entreprise]).to eq('51') }
|
||||
it { expect(subject[:date_creation]).to eq('2016-01-28T10:16:29.000Z') }
|
||||
it { expect(subject[:date_creation]).to eq('1990-04-24T00:00:00.000+00:00') }
|
||||
it { expect(subject.keys).to match_array(field_list) }
|
||||
end
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ RSpec.describe Users::CarteController, type: :controller do
|
|||
let(:invite_by_user) { create :user, email: 'invite@plop.com' }
|
||||
|
||||
let(:dossier_with_no_carto) { create(:dossier) }
|
||||
let!(:entreprise) { create(:entreprise, dossier: dossier) }
|
||||
let!(:etablissement) { create(:etablissement, dossier: dossier) }
|
||||
let(:bad_dossier_id) { Dossier.count + 1000 }
|
||||
let(:adresse) { etablissement.geo_adresse }
|
||||
|
|
|
@ -16,7 +16,7 @@ shared_examples 'description_controller_spec' do
|
|||
|
||||
context 'when all is ok' do
|
||||
before do
|
||||
dossier.entreprise = create :entreprise
|
||||
dossier.etablissement = create(:etablissement)
|
||||
get :show, params: { dossier_id: dossier_id }
|
||||
end
|
||||
|
||||
|
@ -85,8 +85,8 @@ shared_examples 'description_controller_spec' do
|
|||
describe 'before action check_starter_dossier_informations' do
|
||||
subject { get :show, params: { dossier_id: dossier_id } }
|
||||
|
||||
context 'when dossier does not have an enterprise datas' do
|
||||
it { expect(dossier.entreprise).to be_nil }
|
||||
context 'when dossier does not have an etablissement datas' do
|
||||
it { expect(dossier.etablissement).to be_nil }
|
||||
it { expect(subject).to redirect_to "/users/dossiers/#{dossier.id}" }
|
||||
end
|
||||
|
||||
|
|
|
@ -212,15 +212,6 @@ describe Users::DossiersController, type: :controller do
|
|||
expect { subject }.to change { Dossier.count }.by(0)
|
||||
end
|
||||
|
||||
it 'creates entreprise' do
|
||||
expect { subject }.to change { Entreprise.count }.by(1)
|
||||
end
|
||||
|
||||
it 'links entreprise to dossier' do
|
||||
subject
|
||||
expect(Entreprise.last.dossier).to eq(Dossier.last)
|
||||
end
|
||||
|
||||
it "links dossier to user" do
|
||||
subject
|
||||
expect(Dossier.last.user).to eq(user)
|
||||
|
@ -237,7 +228,7 @@ describe Users::DossiersController, type: :controller do
|
|||
|
||||
it 'links etablissement to entreprise' do
|
||||
subject
|
||||
expect(Etablissement.last.entreprise).to eq(Entreprise.last)
|
||||
expect(Etablissement.last.entreprise).to be_truthy
|
||||
end
|
||||
|
||||
it 'creates exercices for dossier' do
|
||||
|
@ -267,8 +258,9 @@ describe Users::DossiersController, type: :controller do
|
|||
let(:rna_status) { 404 }
|
||||
let(:rna_body) { '' }
|
||||
|
||||
it 'not creates rna information for entreprise' do
|
||||
expect { subject }.to change { RNAInformation.count }.by(0)
|
||||
it 'not creates association information for etablissement' do
|
||||
subject
|
||||
expect(Dossier.last.etablissement.association?).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -277,12 +269,8 @@ describe Users::DossiersController, type: :controller do
|
|||
let(:rna_body) { File.read('spec/support/files/rna.json') }
|
||||
|
||||
it 'creates rna information for entreprise' do
|
||||
expect { subject }.to change { RNAInformation.count }.by(1)
|
||||
end
|
||||
|
||||
it 'links rna informations to entreprise' do
|
||||
subject
|
||||
expect(RNAInformation.last.entreprise).to eq(Entreprise.last)
|
||||
expect(Dossier.last.etablissement.association?).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ describe 'new_gestionnaire/dossiers/show.html.haml', type: :view do
|
|||
context "when dossier was created by an etablissement" do
|
||||
let(:etablissement) { create(:etablissement) }
|
||||
|
||||
it { expect(rendered).to include(etablissement.entreprise_raison_sociale_or_name) }
|
||||
it { expect(rendered).to include(etablissement.entreprise_raison_sociale) }
|
||||
it { expect(rendered).to include(etablissement.entreprise_siret_siege_social) }
|
||||
it { expect(rendered).to include(etablissement.entreprise_forme_juridique) }
|
||||
|
||||
|
|
Loading…
Reference in a new issue