Merge pull request #5492 from betagouv/5491-right-name-for-etablissement
prend en compte le nom de l'enseigne pour l'établissement
This commit is contained in:
commit
7faae3a438
10 changed files with 100 additions and 11 deletions
|
@ -9,14 +9,11 @@ module EtablissementHelper
|
|||
end
|
||||
|
||||
def raison_sociale_or_name(etablissement)
|
||||
if etablissement.association?
|
||||
etablissement.association_titre
|
||||
elsif etablissement.entreprise_raison_sociale.present?
|
||||
etablissement.entreprise_raison_sociale
|
||||
else
|
||||
etablissement.association_titre.presence ||
|
||||
etablissement.enseigne.presence ||
|
||||
etablissement.entreprise_raison_sociale.presence ||
|
||||
"#{etablissement.entreprise_nom} #{etablissement.entreprise_prenom}"
|
||||
end
|
||||
end
|
||||
|
||||
def effectif(etablissement)
|
||||
{
|
||||
|
|
|
@ -25,6 +25,7 @@ class ApiEntreprise::EtablissementAdapter < ApiEntreprise::Adapter
|
|||
:siege_social,
|
||||
:naf,
|
||||
:libelle_naf,
|
||||
:enseigne,
|
||||
:diffusable_commercialement
|
||||
]
|
||||
end
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
# code_postal :string
|
||||
# complement_adresse :string
|
||||
# diffusable_commercialement :boolean
|
||||
# enseigne :string
|
||||
# entreprise_bilans_bdf :jsonb
|
||||
# entreprise_bilans_bdf_monnaie :string
|
||||
# entreprise_capital_social :bigint
|
||||
|
@ -75,6 +76,7 @@ class Etablissement < ApplicationRecord
|
|||
association_titre,
|
||||
association_objet,
|
||||
siret,
|
||||
enseigne,
|
||||
naf,
|
||||
libelle_naf,
|
||||
adresse,
|
||||
|
@ -89,6 +91,7 @@ class Etablissement < ApplicationRecord
|
|||
['Dossier ID', :dossier_id_for_export],
|
||||
['Champ', :libelle_for_export],
|
||||
['Établissement SIRET', :siret],
|
||||
['Etablissement enseigne', :enseigne],
|
||||
['Établissement siège social', :siege_social],
|
||||
['Établissement NAF', :naf],
|
||||
['Établissement libellé NAF', :libelle_naf],
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddEnseigneToEtablissements < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
add_column :etablissements, :enseigne, :string
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2020_07_22_135121) do
|
||||
ActiveRecord::Schema.define(version: 2020_08_19_153016) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -323,6 +323,7 @@ ActiveRecord::Schema.define(version: 2020_07_22_135121) do
|
|||
t.string "entreprise_effectif_annuel_annee"
|
||||
t.jsonb "entreprise_bilans_bdf"
|
||||
t.string "entreprise_bilans_bdf_monnaie"
|
||||
t.string "enseigne"
|
||||
t.index ["dossier_id"], name: "index_etablissements_on_dossier_id"
|
||||
end
|
||||
|
||||
|
|
53
spec/fixtures/files/api_entreprise/etablissements-non-siege.json
vendored
Normal file
53
spec/fixtures/files/api_entreprise/etablissements-non-siege.json
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
"etablissement": {
|
||||
"adresse": {
|
||||
"cedex": null,
|
||||
"code_insee_localite": "31555",
|
||||
"code_postal": "31400",
|
||||
"complement_adresse": null,
|
||||
"l1": "DIRECTION INTERREGIONALE DES SERVICES PENITENTIAIRES TOULOUSE - SUD",
|
||||
"l2": "SERVICE PENITENTIAIRE D'INSERTION ET DE PROBATION, DE LA HAUTE-GARONNE",
|
||||
"l3": null,
|
||||
"l4": "109 AV DE LESPINET",
|
||||
"l5": "BP 4087",
|
||||
"l6": "31400 TOULOUSE",
|
||||
"l7": "FRANCE",
|
||||
"localite": "TOULOUSE",
|
||||
"nom_voie": "DE LESPINET",
|
||||
"numero_voie": "109",
|
||||
"type_voie": "AV"
|
||||
},
|
||||
"commune_implantation": {
|
||||
"code": "31555",
|
||||
"value": "Toulouse"
|
||||
},
|
||||
"date_creation_etablissement": 1458946800,
|
||||
"date_mise_a_jour": 1533648919,
|
||||
"diffusable_commercialement": true,
|
||||
"enseigne": "SERVICE PENITENTIAIRE D'INSERTION ET DE PROBATION, DE LA HAUTE-GARONNE",
|
||||
"etat_administratif": {
|
||||
"date_fermeture": null,
|
||||
"value": "A"
|
||||
},
|
||||
"libelle_naf": "Justice",
|
||||
"naf": "8423Z",
|
||||
"pays_implantation": {
|
||||
"code": "FR",
|
||||
"value": "FRANCE"
|
||||
},
|
||||
"region_implantation": {
|
||||
"code": "76",
|
||||
"value": "Occitanie"
|
||||
},
|
||||
"siege_social": false,
|
||||
"siret": "17310120500719",
|
||||
"tranche_effectif_salarie_etablissement": {
|
||||
"a": null,
|
||||
"code": null,
|
||||
"date_reference": null,
|
||||
"de": null,
|
||||
"intitule": null
|
||||
}
|
||||
},
|
||||
"gateway_error": false
|
||||
}
|
|
@ -1,10 +1,12 @@
|
|||
RSpec.describe EtablissementHelper, type: :helper do
|
||||
let(:code_effectif) { '00' }
|
||||
let(:raison_sociale) { 'GRTGaz' }
|
||||
let(:enseigne) { "mon enseigne" }
|
||||
let(:nom) { 'mon nom' }
|
||||
let(:prenom) { 'mon prenom' }
|
||||
let(:entreprise_params) do
|
||||
let(:etablissement_params) do
|
||||
{
|
||||
enseigne: enseigne,
|
||||
entreprise_capital_social: 123_000,
|
||||
entreprise_code_effectif_entreprise: code_effectif,
|
||||
entreprise_raison_sociale: raison_sociale,
|
||||
|
@ -12,13 +14,21 @@ RSpec.describe EtablissementHelper, type: :helper do
|
|||
entreprise_prenom: prenom
|
||||
}
|
||||
end
|
||||
let(:etablissement) { create(:etablissement, entreprise_params) }
|
||||
let(:etablissement) { create(:etablissement, etablissement_params) }
|
||||
|
||||
describe '#raison_sociale_or_name' do
|
||||
subject { raison_sociale_or_name(etablissement) }
|
||||
|
||||
context 'when etablissement is not the siege and enseigne exist' do
|
||||
let(:enseigne) { "mon enseigne" }
|
||||
it 'display enseigne' do
|
||||
expect(subject).to eq(enseigne)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when raison_sociale exist' do
|
||||
let(:raison_sociale) { 'ma super raison_sociale' }
|
||||
let(:enseigne) { nil }
|
||||
it 'display raison_sociale' do
|
||||
expect(subject).to eq(raison_sociale)
|
||||
end
|
||||
|
@ -26,6 +36,7 @@ RSpec.describe EtablissementHelper, type: :helper do
|
|||
|
||||
context 'when raison_sociale is nil' do
|
||||
let(:raison_sociale) { nil }
|
||||
let(:enseigne) { nil }
|
||||
it 'display nom and prenom' do
|
||||
expect(subject).to eq("#{nom} #{prenom}")
|
||||
end
|
||||
|
|
|
@ -8,11 +8,12 @@ describe ApiEntreprise::EtablissementAdapter do
|
|||
|
||||
context 'SIRET valide avec infos diffusables' do
|
||||
let(:siret) { '41816609600051' }
|
||||
let(:fixture) { 'spec/fixtures/files/api_entreprise/etablissements.json' }
|
||||
subject { described_class.new(siret, procedure_id).to_params }
|
||||
|
||||
before do
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/etablissements\/#{siret}?.*token=/)
|
||||
.to_return(body: File.read('spec/fixtures/files/api_entreprise/etablissements.json', status: 200))
|
||||
.to_return(body: File.read(fixture, status: 200))
|
||||
end
|
||||
|
||||
it '#to_params class est une Hash ?' do
|
||||
|
@ -75,6 +76,22 @@ describe ApiEntreprise::EtablissementAdapter do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'Attributs Etablissements pour etablissement non siege' do
|
||||
let(:siret) { '17310120500719' }
|
||||
let(:fixture) { 'spec/fixtures/files/api_entreprise/etablissements-non-siege.json' }
|
||||
it 'L\'entreprise contient bien un siret' do
|
||||
expect(subject[:siret]).to eq(siret)
|
||||
end
|
||||
|
||||
it 'L\'etablissement contient bien un siege_social à false' do
|
||||
expect(subject[:siege_social]).to eq(false)
|
||||
end
|
||||
|
||||
it 'L\'etablissement contient bien une enseigne' do
|
||||
expect(subject[:enseigne]).to eq("SERVICE PENITENTIAIRE D'INSERTION ET DE PROBATION, DE LA HAUTE-GARONNE")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'SIRET valide avec infos non diffusables' do
|
||||
|
|
|
@ -358,7 +358,7 @@ describe Champ do
|
|||
end
|
||||
let(:champ) { type_de_champ.champ.build(value: etablissement.siret, etablissement: etablissement) }
|
||||
|
||||
it { is_expected.to eq([etablissement.entreprise_siren, etablissement.entreprise_numero_tva_intracommunautaire, etablissement.entreprise_forme_juridique, etablissement.entreprise_forme_juridique_code, etablissement.entreprise_nom_commercial, etablissement.entreprise_raison_sociale, etablissement.entreprise_siret_siege_social, etablissement.entreprise_nom, etablissement.entreprise_prenom, etablissement.association_rna, etablissement.association_titre, etablissement.association_objet, etablissement.siret, etablissement.naf, etablissement.libelle_naf, etablissement.adresse, etablissement.code_postal, etablissement.localite, etablissement.code_insee_localite]) }
|
||||
it { is_expected.to eq([etablissement.entreprise_siren, etablissement.entreprise_numero_tva_intracommunautaire, etablissement.entreprise_forme_juridique, etablissement.entreprise_forme_juridique_code, etablissement.entreprise_nom_commercial, etablissement.entreprise_raison_sociale, etablissement.entreprise_siret_siege_social, etablissement.entreprise_nom, etablissement.entreprise_prenom, etablissement.association_rna, etablissement.association_titre, etablissement.association_objet, etablissement.siret, etablissement.enseigne, etablissement.naf, etablissement.libelle_naf, etablissement.adresse, etablissement.code_postal, etablissement.localite, etablissement.code_insee_localite]) }
|
||||
end
|
||||
|
||||
context 'when there is no etablissement' do
|
||||
|
|
|
@ -253,6 +253,7 @@ describe ProcedureExportService do
|
|||
"Dossier ID",
|
||||
"Champ",
|
||||
"Établissement SIRET",
|
||||
"Etablissement enseigne",
|
||||
"Établissement siège social",
|
||||
"Établissement NAF",
|
||||
"Établissement libellé NAF",
|
||||
|
|
Loading…
Reference in a new issue