Merge pull request #1838 from tchak/entreprise-association-object
Expose entreprise and association on etablissement
This commit is contained in:
commit
0635b50d70
48 changed files with 261 additions and 299 deletions
|
@ -234,18 +234,22 @@ module NewGestionnaire
|
|||
.includes(relation)
|
||||
.where("champs.type_de_champ_id = ?", filter['column'].to_i)
|
||||
.where("champs.value LIKE ?", "%#{filter['value']}%")
|
||||
|
||||
when 'user', 'etablissement', 'entreprise'
|
||||
when 'entreprise'
|
||||
table = 'etablissement'
|
||||
if filter['column'] == 'date_creation'
|
||||
date = filter['value'].to_date rescue nil
|
||||
dossiers
|
||||
.includes(filter['table'])
|
||||
.where("#{filter['table'].pluralize}.#{filter['column']} = ?", date)
|
||||
.includes(table)
|
||||
.where("#{table.pluralize}.entreprise_#{filter['column']} = ?", date)
|
||||
else
|
||||
dossiers
|
||||
.includes(filter['table'])
|
||||
.where("#{filter['table'].pluralize}.#{filter['column']} LIKE ?", "%#{filter['value']}%")
|
||||
.includes(table)
|
||||
.where("#{table.pluralize}.entreprise_#{filter['column']} LIKE ?", "%#{filter['value']}%")
|
||||
end
|
||||
when 'user', 'etablissement'
|
||||
dossiers
|
||||
.includes(filter['table'])
|
||||
.where("#{filter['table'].pluralize}.#{filter['column']} LIKE ?", "%#{filter['value']}%")
|
||||
end.pluck(:id)
|
||||
end.reduce(:&)
|
||||
end
|
||||
|
|
|
@ -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!
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
class EntrepriseDecorator < Draper::Decorator
|
||||
delegate_all
|
||||
|
||||
def raison_sociale_or_name
|
||||
raison_sociale.presence || "#{nom} #{prenom}"
|
||||
end
|
||||
|
||||
def effectif
|
||||
{
|
||||
'NN' => "Unités non employeuses (pas de salarié au cours de l'année de référence et pas d'effectif au 31/12).",
|
||||
'00' => "0 salarié (n'ayant pas d'effectif au 31/12 mais ayant employé des salariés au cours de l'année de référence)",
|
||||
'01' => '1 ou 2 salariés',
|
||||
'02' => '3 à 5 salariés',
|
||||
'03' => '6 à 9 salariés',
|
||||
'11' => '10 à 19 salariés',
|
||||
'12' => '20 à 49 salariés',
|
||||
'21' => '50 à 99 salariés',
|
||||
'22' => '100 à 199 salariés',
|
||||
'31' => '200 à 249 salariés',
|
||||
'32' => '250 à 499 salariés',
|
||||
'41' => '500 à 999 salariés',
|
||||
'42' => '1 000 à 1 999 salariés',
|
||||
'51' => '2 000 à 4 999 salariés',
|
||||
'52' => '5 000 à 9 999 salariés',
|
||||
'53' => '10 000 salariés et plus'
|
||||
}[code_effectif_entreprise]
|
||||
end
|
||||
|
||||
def pretty_capital_social
|
||||
h.number_to_currency(capital_social, delimiter: ' ', unit: '€', format: '%n %u')
|
||||
end
|
||||
end
|
|
@ -1,3 +0,0 @@
|
|||
class EtablissementDecorator < Draper::Decorator
|
||||
delegate_all
|
||||
end
|
|
@ -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
|
||||
|
|
|
@ -2,4 +2,35 @@ module EtablissementHelper
|
|||
def pretty_currency(capital_social)
|
||||
number_to_currency(capital_social, locale: :fr)
|
||||
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.entreprise_nom} #{etablissement.entreprise_prenom}"
|
||||
end
|
||||
end
|
||||
|
||||
def effectif(etablissement)
|
||||
{
|
||||
'NN' => "Unités non employeuses (pas de salarié au cours de l'année de référence et pas d'effectif au 31/12).",
|
||||
'00' => "0 salarié (n'ayant pas d'effectif au 31/12 mais ayant employé des salariés au cours de l'année de référence)",
|
||||
'01' => '1 ou 2 salariés',
|
||||
'02' => '3 à 5 salariés',
|
||||
'03' => '6 à 9 salariés',
|
||||
'11' => '10 à 19 salariés',
|
||||
'12' => '20 à 49 salariés',
|
||||
'21' => '50 à 99 salariés',
|
||||
'22' => '100 à 199 salariés',
|
||||
'31' => '200 à 249 salariés',
|
||||
'32' => '250 à 499 salariés',
|
||||
'41' => '500 à 999 salariés',
|
||||
'42' => '1 000 à 1 999 salariés',
|
||||
'51' => '2 000 à 4 999 salariés',
|
||||
'52' => '5 000 à 9 999 salariés',
|
||||
'53' => '10 000 salariés et plus'
|
||||
}[etablissement.entreprise_code_effectif_entreprise]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,12 +2,9 @@ class EtablissementUpdateJob < ApplicationJob
|
|||
queue_as :default
|
||||
|
||||
def perform(dossier, siret)
|
||||
etablissement_attributes = ApiEntrepriseService.get_etablissement_params_for_siret(siret, dossier.procedure_id, dossier)
|
||||
etablissement_attributes = ApiEntrepriseService.get_etablissement_params_for_siret(siret, dossier.procedure_id)
|
||||
|
||||
if etablissement_attributes.present?
|
||||
if dossier.entreprise.present?
|
||||
dossier.entreprise.destroy
|
||||
end
|
||||
if dossier.etablissement.present?
|
||||
dossier.etablissement.destroy
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ class ApiEntreprise::EntrepriseAdapter < ApiEntreprise::Adapter
|
|||
def process_params
|
||||
params = data_source[:entreprise].slice(*attr_to_fetch)
|
||||
params[:date_creation] = Time.at(params[:date_creation]).to_datetime
|
||||
params
|
||||
params.transform_keys { |k| :"entreprise_#{k}" }
|
||||
end
|
||||
|
||||
def attr_to_fetch
|
||||
|
|
|
@ -9,7 +9,7 @@ class ApiEntreprise::RNAAdapter < ApiEntreprise::Adapter
|
|||
if data_source[:association][:id].present?
|
||||
params = data_source[:association].slice(*attr_to_fetch)
|
||||
params[:rna] = data_source[:association][:id]
|
||||
params
|
||||
params.transform_keys { |k| :"association_#{k}" }
|
||||
else
|
||||
{}
|
||||
end
|
||||
|
|
|
@ -107,7 +107,7 @@ module TagsSubstitutionConcern
|
|||
{
|
||||
libelle: 'adresse',
|
||||
description: '',
|
||||
lambda: -> (e) { e&.etablissement&.inline_adresse },
|
||||
target: :inline_adresse,
|
||||
available_for_states: Dossier::SOUMIS
|
||||
}
|
||||
]
|
||||
|
@ -187,7 +187,7 @@ module TagsSubstitutionConcern
|
|||
tags_and_datas = [
|
||||
[dossier_tags, dossier],
|
||||
[INDIVIDUAL_TAGS, dossier.individual],
|
||||
[ENTREPRISE_TAGS, dossier.entreprise]
|
||||
[ENTREPRISE_TAGS, dossier.etablissement&.entreprise]
|
||||
]
|
||||
|
||||
tags_and_datas
|
||||
|
|
|
@ -14,7 +14,6 @@ class Dossier < ApplicationRecord
|
|||
SOUMIS = EN_CONSTRUCTION_OU_INSTRUCTION + TERMINE
|
||||
|
||||
has_one :etablissement, dependent: :destroy
|
||||
has_one :entreprise, dependent: :destroy
|
||||
has_one :individual, dependent: :destroy
|
||||
has_one :attestation
|
||||
has_many :cerfa, dependent: :destroy
|
||||
|
@ -56,7 +55,7 @@ class Dossier < ApplicationRecord
|
|||
scope :en_construction, -> { not_archived.state_en_construction }
|
||||
scope :en_instruction, -> { not_archived.state_en_instruction }
|
||||
scope :termine, -> { not_archived.state_termine }
|
||||
scope :downloadable_sorted, -> { state_not_brouillon.includes(:entreprise, :etablissement, :champs, :champs_private).order(en_construction_at: 'asc') }
|
||||
scope :downloadable_sorted, -> { state_not_brouillon.includes(:etablissement, :champs, :champs_private).order(en_construction_at: 'asc') }
|
||||
scope :en_cours, -> { not_archived.state_en_construction_ou_instruction }
|
||||
scope :without_followers, -> { left_outer_joins(:follows).where(follows: { id: nil }) }
|
||||
scope :followed_by, -> (gestionnaire) { joins(:follows).where(follows: { gestionnaire: gestionnaire }) }
|
||||
|
@ -64,8 +63,7 @@ class Dossier < ApplicationRecord
|
|||
|
||||
accepts_nested_attributes_for :individual
|
||||
|
||||
delegate :siren, to: :entreprise
|
||||
delegate :siret, to: :etablissement, allow_nil: true
|
||||
delegate :siret, :siren, to: :etablissement, allow_nil: true
|
||||
delegate :types_de_piece_justificative, to: :procedure
|
||||
delegate :types_de_champ, to: :procedure
|
||||
delegate :france_connect_information, to: :user
|
||||
|
@ -220,7 +218,7 @@ class Dossier < ApplicationRecord
|
|||
when 'france_connect_information'
|
||||
self.user.france_connect_information&.send(column)
|
||||
when 'entreprise'
|
||||
self.entreprise&.send(column)
|
||||
self.etablissement&.send(:"entreprise_#{column}")
|
||||
when 'etablissement'
|
||||
self.etablissement&.send(column)
|
||||
when 'type_de_champ'
|
||||
|
@ -235,8 +233,8 @@ class Dossier < ApplicationRecord
|
|||
end
|
||||
|
||||
def owner_name
|
||||
if entreprise.present?
|
||||
entreprise.raison_sociale
|
||||
if etablissement.present?
|
||||
etablissement.entreprise_raison_sociale
|
||||
elsif individual.present?
|
||||
"#{individual.nom} #{individual.prenom}"
|
||||
end
|
||||
|
@ -298,8 +296,8 @@ class Dossier < ApplicationRecord
|
|||
|
||||
def export_etablissement_data
|
||||
if etablissement.present?
|
||||
etablissement_attr = EtablissementCsvSerializer.new(self.etablissement).attributes.transform_keys { |k| "etablissement.#{k}".parameterize.underscore.to_sym }
|
||||
entreprise_attr = EntrepriseSerializer.new(self.entreprise).attributes.transform_keys { |k| "entreprise.#{k}".parameterize.underscore.to_sym }
|
||||
etablissement_attr = EtablissementCsvSerializer.new(etablissement).attributes.transform_keys { |k| "etablissement.#{k}".parameterize.underscore.to_sym }
|
||||
entreprise_attr = EntrepriseSerializer.new(etablissement.entreprise).attributes.transform_keys { |k| "entreprise.#{k}".parameterize.underscore.to_sym }
|
||||
else
|
||||
etablissement_attr = EtablissementSerializer.new(Etablissement.new).attributes.transform_keys { |k| "etablissement.#{k}".parameterize.underscore.to_sym }
|
||||
entreprise_attr = EntrepriseSerializer.new(Entreprise.new).attributes.transform_keys { |k| "entreprise.#{k}".parameterize.underscore.to_sym }
|
||||
|
|
|
@ -1,16 +1,20 @@
|
|||
class Entreprise < ApplicationRecord
|
||||
belongs_to :dossier
|
||||
has_one :etablissement
|
||||
has_one :rna_information, dependent: :destroy
|
||||
|
||||
validates :siren, presence: true
|
||||
validates :dossier_id, uniqueness: true
|
||||
|
||||
accepts_nested_attributes_for :rna_information, update_only: true
|
||||
|
||||
before_save :default_values
|
||||
|
||||
def default_values
|
||||
self.raison_sociale ||= ''
|
||||
class Entreprise < Hashie::Dash
|
||||
def read_attribute_for_serialization(attribute)
|
||||
self[attribute]
|
||||
end
|
||||
|
||||
property :siren
|
||||
property :capital_social
|
||||
property :numero_tva_intracommunautaire
|
||||
property :forme_juridique
|
||||
property :forme_juridique_code
|
||||
property :nom_commercial
|
||||
property :raison_sociale
|
||||
property :siret_siege_social
|
||||
property :code_effectif_entreprise
|
||||
property :date_creation
|
||||
property :nom
|
||||
property :prenom
|
||||
|
||||
property :inline_adresse
|
||||
end
|
||||
|
|
|
@ -1,18 +1,20 @@
|
|||
class Etablissement < ApplicationRecord
|
||||
belongs_to :dossier
|
||||
belongs_to :entreprise, dependent: :destroy
|
||||
|
||||
has_one :champ, class_name: 'Champs::SiretChamp'
|
||||
has_many :exercices, dependent: :destroy
|
||||
|
||||
accepts_nested_attributes_for :exercices
|
||||
accepts_nested_attributes_for :entreprise, update_only: true
|
||||
|
||||
validates :siret, presence: true
|
||||
validates :dossier_id, uniqueness: { allow_nil: true }
|
||||
|
||||
validate :validate_signature
|
||||
|
||||
def siren
|
||||
entreprise_siren
|
||||
end
|
||||
|
||||
def geo_adresse
|
||||
[numero_voie, type_voie, nom_voie, complement_adresse, code_postal, localite].join(' ')
|
||||
end
|
||||
|
@ -22,10 +24,6 @@ class Etablissement < ApplicationRecord
|
|||
"#{numero_voie} #{type_voie} #{nom_voie}, #{complement_adresse}, #{code_postal} #{localite}".squeeze(' ')
|
||||
end
|
||||
|
||||
def titre
|
||||
entreprise_raison_sociale || association_titre
|
||||
end
|
||||
|
||||
def verify
|
||||
SignatureService.verify(signature, message_for_signature)
|
||||
end
|
||||
|
@ -36,29 +34,26 @@ class Etablissement < ApplicationRecord
|
|||
|
||||
attr_accessor :signature
|
||||
|
||||
def entreprise_raison_sociale_or_name
|
||||
entreprise_raison_sociale.presence || "#{entreprise_nom} #{entreprise_prenom}"
|
||||
def association?
|
||||
association_rna.present?
|
||||
end
|
||||
|
||||
def entreprise_effectif
|
||||
{
|
||||
'NN' => "Unités non employeuses (pas de salarié au cours de l'année de référence et pas d'effectif au 31/12).",
|
||||
'00' => "0 salarié (n'ayant pas d'effectif au 31/12 mais ayant employé des salariés au cours de l'année de référence)",
|
||||
'01' => '1 ou 2 salariés',
|
||||
'02' => '3 à 5 salariés',
|
||||
'03' => '6 à 9 salariés',
|
||||
'11' => '10 à 19 salariés',
|
||||
'12' => '20 à 49 salariés',
|
||||
'21' => '50 à 99 salariés',
|
||||
'22' => '100 à 199 salariés',
|
||||
'31' => '200 à 249 salariés',
|
||||
'32' => '250 à 499 salariés',
|
||||
'41' => '500 à 999 salariés',
|
||||
'42' => '1 000 à 1 999 salariés',
|
||||
'51' => '2 000 à 4 999 salariés',
|
||||
'52' => '5 000 à 9 999 salariés',
|
||||
'53' => '10 000 salariés et plus'
|
||||
}[entreprise_code_effectif_entreprise]
|
||||
def entreprise
|
||||
Entreprise.new(
|
||||
siren: entreprise_siren,
|
||||
capital_social: entreprise_capital_social,
|
||||
numero_tva_intracommunautaire: entreprise_numero_tva_intracommunautaire,
|
||||
forme_juridique: entreprise_forme_juridique,
|
||||
forme_juridique_code: entreprise_forme_juridique_code,
|
||||
nom_commercial: entreprise_nom_commercial,
|
||||
raison_sociale: entreprise_raison_sociale,
|
||||
siret_siege_social: entreprise_siret_siege_social,
|
||||
code_effectif_entreprise: entreprise_code_effectif_entreprise,
|
||||
date_creation: entreprise_date_creation,
|
||||
nom: entreprise_nom,
|
||||
prenom: entreprise_prenom,
|
||||
inline_adresse: inline_adresse
|
||||
)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -2,8 +2,4 @@ class Exercice < ApplicationRecord
|
|||
belongs_to :etablissement
|
||||
|
||||
validates :ca, presence: true, allow_blank: false, allow_nil: false
|
||||
|
||||
def date_fin_exercice
|
||||
super || dateFinExercice
|
||||
end
|
||||
end
|
||||
|
|
|
@ -285,12 +285,12 @@ class Procedure < ApplicationRecord
|
|||
|
||||
if !for_individual || (for_individual && individual_with_siret)
|
||||
fields << [
|
||||
field_hash('SIREN', 'entreprise', 'siren'),
|
||||
field_hash('Forme juridique', 'entreprise', 'forme_juridique'),
|
||||
field_hash('Nom commercial', 'entreprise', 'nom_commercial'),
|
||||
field_hash('Raison sociale', 'entreprise', 'raison_sociale'),
|
||||
field_hash('SIRET siège social', 'entreprise', 'siret_siege_social'),
|
||||
field_hash('Date de création', 'entreprise', 'date_creation')
|
||||
field_hash('SIREN', 'etablissement', 'entreprise_siren'),
|
||||
field_hash('Forme juridique', 'etablissement', 'entreprise_forme_juridique'),
|
||||
field_hash('Nom commercial', 'etablissement', 'entreprise_nom_commercial'),
|
||||
field_hash('Raison sociale', 'etablissement', 'entreprise_raison_sociale'),
|
||||
field_hash('SIRET siège social', 'etablissement', 'entreprise_siret_siege_social'),
|
||||
field_hash('Date de création', 'etablissement', 'entreprise_date_creation')
|
||||
]
|
||||
|
||||
fields << [
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
class RNAInformation < ApplicationRecord
|
||||
belongs_to :entreprise
|
||||
|
||||
validates :association_id, presence: true, allow_blank: false, allow_nil: false
|
||||
|
||||
def rna=(id)
|
||||
write_attribute(:association_id, id)
|
||||
end
|
||||
end
|
|
@ -34,6 +34,10 @@ class DossierSerializer < ActiveModel::Serializer
|
|||
object.user.try(:email)
|
||||
end
|
||||
|
||||
def entreprise
|
||||
object.etablissement&.entreprise
|
||||
end
|
||||
|
||||
def state
|
||||
case object.state
|
||||
when 'en_construction'
|
||||
|
|
|
@ -11,4 +11,8 @@ class EntrepriseSerializer < ActiveModel::Serializer
|
|||
:date_creation,
|
||||
:nom,
|
||||
:prenom
|
||||
|
||||
def date_creation
|
||||
object.date_creation ? object.date_creation.to_datetime : nil
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class ApiEntrepriseService
|
||||
def self.get_etablissement_params_for_siret(siret, procedure_id, dossier = nil)
|
||||
def self.get_etablissement_params_for_siret(siret, procedure_id)
|
||||
etablissement_params = ApiEntreprise::EtablissementAdapter.new(siret, procedure_id).to_params
|
||||
entreprise_params = ApiEntreprise::EntrepriseAdapter.new(siret, procedure_id).to_params
|
||||
|
||||
|
@ -8,25 +8,11 @@ class ApiEntrepriseService
|
|||
exercices_params = ApiEntreprise::ExercicesAdapter.new(siret, procedure_id).to_params
|
||||
|
||||
params = etablissement_params
|
||||
.merge(entreprise_params.transform_keys { |k| "entreprise_#{k}" })
|
||||
.merge(association_params.transform_keys { |k| "association_#{k}" })
|
||||
.merge(entreprise_params)
|
||||
.merge(association_params)
|
||||
.merge(exercices_params)
|
||||
|
||||
# This is to fill legacy models and relationships
|
||||
if dossier.present?
|
||||
handle_legacy_models!(params, entreprise_params, dossier, association_params)
|
||||
end
|
||||
|
||||
params
|
||||
end
|
||||
end
|
||||
|
||||
def self.handle_legacy_models!(params, entreprise_params, dossier, association_params)
|
||||
params[:entreprise_attributes] = entreprise_params.merge(
|
||||
{
|
||||
dossier: dossier,
|
||||
rna_information_attributes: association_params.presence
|
||||
}.compact
|
||||
)
|
||||
end
|
||||
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)
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
class UpdateSearchesToVersion3 < ActiveRecord::Migration[5.2]
|
||||
def up
|
||||
replace_view :searches, version: 3
|
||||
end
|
||||
|
||||
def down
|
||||
replace_view :searches, version: 2
|
||||
end
|
||||
end
|
|
@ -609,15 +609,13 @@ ActiveRecord::Schema.define(version: 2018_05_22_142109) do
|
|||
|
||||
create_view "searches", sql_definition: <<-SQL
|
||||
SELECT dossiers.id AS dossier_id,
|
||||
(((((((((((((((((((((((((((((((((((((((((((((((((((((((COALESCE(users.email, ''::character varying))::text || ' '::text) || (COALESCE(france_connect_informations.given_name, ''::character varying))::text) || ' '::text) || (COALESCE(france_connect_informations.family_name, ''::character varying))::text) || ' '::text) || (COALESCE(cerfas.content, ''::character varying))::text) || ' '::text) || (COALESCE(champs.value, ''::character varying))::text) || ' '::text) || (COALESCE(drop_down_lists.value, ''::character varying))::text) || ' '::text) || (COALESCE(entreprises.siren, ''::character varying))::text) || ' '::text) || (COALESCE(entreprises.numero_tva_intracommunautaire, ''::character varying))::text) || ' '::text) || (COALESCE(entreprises.forme_juridique, ''::character varying))::text) || ' '::text) || (COALESCE(entreprises.forme_juridique_code, ''::character varying))::text) || ' '::text) || (COALESCE(entreprises.nom_commercial, ''::character varying))::text) || ' '::text) || (COALESCE(entreprises.raison_sociale, ''::character varying))::text) || ' '::text) || (COALESCE(entreprises.siret_siege_social, ''::character varying))::text) || ' '::text) || (COALESCE(entreprises.nom, ''::character varying))::text) || ' '::text) || (COALESCE(entreprises.prenom, ''::character varying))::text) || ' '::text) || (COALESCE(rna_informations.association_id, ''::character varying))::text) || ' '::text) || (COALESCE(rna_informations.titre, ''::character varying))::text) || ' '::text) || COALESCE(rna_informations.objet, ''::text)) || ' '::text) || (COALESCE(etablissements.siret, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.naf, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.libelle_naf, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.adresse, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.code_postal, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.localite, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.code_insee_localite, ''::character varying))::text) || ' '::text) || (COALESCE(individuals.nom, ''::character varying))::text) || ' '::text) || (COALESCE(individuals.prenom, ''::character varying))::text) || ' '::text) || (COALESCE(pieces_justificatives.content, ''::character varying))::text) AS term
|
||||
FROM ((((((((((dossiers
|
||||
(((((((((((((((((((((((((((((((((((((((((((((((((((((((COALESCE(users.email, ''::character varying))::text || ' '::text) || (COALESCE(france_connect_informations.given_name, ''::character varying))::text) || ' '::text) || (COALESCE(france_connect_informations.family_name, ''::character varying))::text) || ' '::text) || (COALESCE(cerfas.content, ''::character varying))::text) || ' '::text) || (COALESCE(champs.value, ''::character varying))::text) || ' '::text) || (COALESCE(drop_down_lists.value, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_siren, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_numero_tva_intracommunautaire, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_forme_juridique, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_forme_juridique_code, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_nom_commercial, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_raison_sociale, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_siret_siege_social, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_nom, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_prenom, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.association_rna, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.association_titre, ''::character varying))::text) || ' '::text) || COALESCE(etablissements.association_objet, ''::text)) || ' '::text) || (COALESCE(etablissements.siret, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.naf, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.libelle_naf, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.adresse, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.code_postal, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.localite, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.code_insee_localite, ''::character varying))::text) || ' '::text) || (COALESCE(individuals.nom, ''::character varying))::text) || ' '::text) || (COALESCE(individuals.prenom, ''::character varying))::text) || ' '::text) || (COALESCE(pieces_justificatives.content, ''::character varying))::text) AS term
|
||||
FROM ((((((((dossiers
|
||||
JOIN users ON ((users.id = dossiers.user_id)))
|
||||
LEFT JOIN france_connect_informations ON ((france_connect_informations.user_id = dossiers.user_id)))
|
||||
LEFT JOIN cerfas ON ((cerfas.dossier_id = dossiers.id)))
|
||||
LEFT JOIN champs ON ((champs.dossier_id = dossiers.id)))
|
||||
LEFT JOIN drop_down_lists ON ((drop_down_lists.type_de_champ_id = champs.type_de_champ_id)))
|
||||
LEFT JOIN entreprises ON ((entreprises.dossier_id = dossiers.id)))
|
||||
LEFT JOIN rna_informations ON ((rna_informations.entreprise_id = entreprises.id)))
|
||||
LEFT JOIN etablissements ON ((etablissements.dossier_id = dossiers.id)))
|
||||
LEFT JOIN individuals ON ((individuals.dossier_id = dossiers.id)))
|
||||
LEFT JOIN pieces_justificatives ON ((pieces_justificatives.dossier_id = dossiers.id)));
|
||||
|
|
41
db/views/searches_v03.sql
Normal file
41
db/views/searches_v03.sql
Normal file
|
@ -0,0 +1,41 @@
|
|||
-- this version merges all possible search terms together, complicating the
|
||||
-- view, but enables searching for multiple terms from multiple tables at once.
|
||||
|
||||
SELECT dossiers.id AS dossier_id,
|
||||
COALESCE(users.email, '') || ' ' ||
|
||||
COALESCE(france_connect_informations.given_name, '') || ' ' ||
|
||||
COALESCE(france_connect_informations.family_name, '') || ' ' ||
|
||||
COALESCE(cerfas.content, '') || ' ' ||
|
||||
COALESCE(champs.value, '') || ' ' ||
|
||||
COALESCE(drop_down_lists.value, '') || ' ' ||
|
||||
COALESCE(etablissements.entreprise_siren, '') || ' ' ||
|
||||
COALESCE(etablissements.entreprise_numero_tva_intracommunautaire, '') || ' ' ||
|
||||
COALESCE(etablissements.entreprise_forme_juridique, '') || ' ' ||
|
||||
COALESCE(etablissements.entreprise_forme_juridique_code, '') || ' ' ||
|
||||
COALESCE(etablissements.entreprise_nom_commercial, '') || ' ' ||
|
||||
COALESCE(etablissements.entreprise_raison_sociale, '') || ' ' ||
|
||||
COALESCE(etablissements.entreprise_siret_siege_social, '') || ' ' ||
|
||||
COALESCE(etablissements.entreprise_nom, '') || ' ' ||
|
||||
COALESCE(etablissements.entreprise_prenom, '') || ' ' ||
|
||||
COALESCE(etablissements.association_rna, '') || ' ' ||
|
||||
COALESCE(etablissements.association_titre, '') || ' ' ||
|
||||
COALESCE(etablissements.association_objet, '') || ' ' ||
|
||||
COALESCE(etablissements.siret, '') || ' ' ||
|
||||
COALESCE(etablissements.naf, '') || ' ' ||
|
||||
COALESCE(etablissements.libelle_naf, '') || ' ' ||
|
||||
COALESCE(etablissements.adresse, '') || ' ' ||
|
||||
COALESCE(etablissements.code_postal, '') || ' ' ||
|
||||
COALESCE(etablissements.localite, '') || ' ' ||
|
||||
COALESCE(etablissements.code_insee_localite, '') || ' ' ||
|
||||
COALESCE(individuals.nom, '') || ' ' ||
|
||||
COALESCE(individuals.prenom, '') || ' ' ||
|
||||
COALESCE(pieces_justificatives.content, '') AS term
|
||||
FROM dossiers
|
||||
INNER JOIN users ON users.id = dossiers.user_id
|
||||
LEFT JOIN france_connect_informations ON france_connect_informations.user_id = dossiers.user_id
|
||||
LEFT JOIN cerfas ON cerfas.dossier_id = dossiers.id
|
||||
LEFT JOIN champs ON champs.dossier_id = dossiers.id
|
||||
LEFT JOIN drop_down_lists ON drop_down_lists.type_de_champ_id = champs.type_de_champ_id
|
||||
LEFT JOIN etablissements ON etablissements.dossier_id = dossiers.id
|
||||
LEFT JOIN individuals ON individuals.dossier_id = dossiers.id
|
||||
LEFT JOIN pieces_justificatives ON pieces_justificatives.dossier_id = dossiers.id
|
|
@ -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
|
||||
|
|
|
@ -14,8 +14,6 @@ FactoryBot.define do
|
|||
trait :with_entreprise do
|
||||
after(:build) do |dossier, _evaluator|
|
||||
etablissement = create(:etablissement)
|
||||
entreprise = create(:entreprise, etablissement: etablissement)
|
||||
dossier.entreprise = entreprise
|
||||
dossier.etablissement = etablissement
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
FactoryBot.define do
|
||||
factory :entreprise do
|
||||
siren '440117620'
|
||||
capital_social 537_100_000
|
||||
numero_tva_intracommunautaire 'FR27440117620'
|
||||
forme_juridique 'SA à conseil d\'administration (s.a.i.)'
|
||||
forme_juridique_code '5599'
|
||||
nom_commercial 'GRTGAZ'
|
||||
raison_sociale 'GRTGAZ'
|
||||
siret_siege_social '44011762001530'
|
||||
code_effectif_entreprise '51'
|
||||
date_creation Time.at(1453976189).to_datetime
|
||||
end
|
||||
end
|
|
@ -1,11 +0,0 @@
|
|||
FactoryBot.define do
|
||||
factory :rna_information do
|
||||
association_id "W072000535"
|
||||
titre "ASSOCIATION POUR LA PROMOTION DE SPECTACLES AU CHATEAU DE ROCHEMAURE"
|
||||
objet "mise en oeuvre et réalisation de spectacles au chateau de rochemaure"
|
||||
date_creation "1990-04-24"
|
||||
date_declaration "2014-11-28"
|
||||
date_publication "1990-05-16"
|
||||
association :entreprise, factory: [:entreprise]
|
||||
end
|
||||
end
|
|
@ -1,29 +1,29 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe EntrepriseDecorator do
|
||||
RSpec.describe EtablissementHelper, type: :helper do
|
||||
let(:code_effectif) { '00' }
|
||||
let(:raison_sociale) { 'GRTGaz' }
|
||||
let(:nom) { 'mon nom' }
|
||||
let(:prenom) { 'mon prenom' }
|
||||
let(:entreprise_params) do
|
||||
{
|
||||
capital_social: 123_000,
|
||||
code_effectif_entreprise: code_effectif,
|
||||
raison_sociale: raison_sociale,
|
||||
nom: nom,
|
||||
prenom: prenom
|
||||
entreprise_capital_social: 123_000,
|
||||
entreprise_code_effectif_entreprise: code_effectif,
|
||||
entreprise_raison_sociale: raison_sociale,
|
||||
entreprise_nom: nom,
|
||||
entreprise_prenom: prenom
|
||||
}
|
||||
end
|
||||
let(:entreprise) { create(:entreprise, entreprise_params) }
|
||||
subject { entreprise.decorate }
|
||||
let(:etablissement) { create(:etablissement, entreprise_params) }
|
||||
|
||||
describe '#raison_sociale_or_name' do
|
||||
subject { super().raison_sociale_or_name }
|
||||
subject { raison_sociale_or_name(etablissement) }
|
||||
|
||||
context 'when raison_sociale exist' do
|
||||
let(:raison_sociale) { 'ma super raison_sociale' }
|
||||
it 'display raison_sociale' do
|
||||
expect(subject).to eq(raison_sociale)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when raison_sociale is nil' do
|
||||
let(:raison_sociale) { nil }
|
||||
it 'display nom and prenom' do
|
||||
|
@ -33,20 +33,22 @@ describe EntrepriseDecorator do
|
|||
end
|
||||
|
||||
describe '#effectif' do
|
||||
subject { super().effectif }
|
||||
subject { effectif(etablissement) }
|
||||
|
||||
context 'when code_effectif is 00' do
|
||||
let(:code_effectif) { '01' }
|
||||
it { is_expected.to eq('1 ou 2 salariés') }
|
||||
end
|
||||
|
||||
context 'when code_effectif is 32' do
|
||||
let(:code_effectif) { '32' }
|
||||
it { is_expected.to eq('250 à 499 salariés') }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#pretty_capital_social' do
|
||||
it 'pretty display capital_social' do
|
||||
expect(subject.pretty_capital_social).to eq('123 000,00 €')
|
||||
end
|
||||
describe '#pretty_currency' do
|
||||
subject { pretty_currency(etablissement.entreprise_capital_social) }
|
||||
|
||||
it { is_expected.to eq('123 000,00 €') }
|
||||
end
|
||||
end
|
|
@ -17,51 +17,51 @@ describe ApiEntreprise::EntrepriseAdapter do
|
|||
|
||||
context 'Attributs Entreprises' do
|
||||
it 'L\'entreprise contient bien un siren' do
|
||||
expect(subject[:siren]).to eq(siren)
|
||||
expect(subject[:entreprise_siren]).to eq(siren)
|
||||
end
|
||||
|
||||
it 'L\'entreprise contient bien un capital_social' do
|
||||
expect(subject[:capital_social]).to eq(462308)
|
||||
expect(subject[:entreprise_capital_social]).to eq(462308)
|
||||
end
|
||||
|
||||
it 'L\'entreprise contient bien un numero_tva_intracommunautaire' do
|
||||
expect(subject[:numero_tva_intracommunautaire]).to eq('FR16418166096')
|
||||
expect(subject[:entreprise_numero_tva_intracommunautaire]).to eq('FR16418166096')
|
||||
end
|
||||
|
||||
it 'L\'entreprise contient bien une forme_juridique' do
|
||||
expect(subject[:forme_juridique]).to eq('SA à directoire (s.a.i.)')
|
||||
expect(subject[:entreprise_forme_juridique]).to eq('SA à directoire (s.a.i.)')
|
||||
end
|
||||
|
||||
it 'L\'entreprise contient bien un forme_juridique_code' do
|
||||
expect(subject[:forme_juridique_code]).to eq('5699')
|
||||
expect(subject[:entreprise_forme_juridique_code]).to eq('5699')
|
||||
end
|
||||
|
||||
it 'L\'entreprise contient bien un nom_commercial' do
|
||||
expect(subject[:nom_commercial]).to eq('OCTO-TECHNOLOGY')
|
||||
expect(subject[:entreprise_nom_commercial]).to eq('OCTO-TECHNOLOGY')
|
||||
end
|
||||
|
||||
it 'L\'entreprise contient bien une raison_sociale' do
|
||||
expect(subject[:raison_sociale]).to eq('OCTO-TECHNOLOGY')
|
||||
expect(subject[:entreprise_raison_sociale]).to eq('OCTO-TECHNOLOGY')
|
||||
end
|
||||
|
||||
it 'L\'entreprise contient bien un siret_siege_social' do
|
||||
expect(subject[:siret_siege_social]).to eq('41816609600051')
|
||||
expect(subject[:entreprise_siret_siege_social]).to eq('41816609600051')
|
||||
end
|
||||
|
||||
it 'L\'entreprise contient bien un code_effectif_entreprise' do
|
||||
expect(subject[:code_effectif_entreprise]).to eq('31')
|
||||
expect(subject[:entreprise_code_effectif_entreprise]).to eq('31')
|
||||
end
|
||||
|
||||
it 'L\'entreprise contient bien une date_creation' do
|
||||
expect(subject[:date_creation]).to eq('Wed, 01 Apr 1998 00:00:00.000000000 +0200')
|
||||
expect(subject[:entreprise_date_creation]).to eq('Wed, 01 Apr 1998 00:00:00.000000000 +0200')
|
||||
end
|
||||
|
||||
it 'L\'entreprise contient bien un nom' do
|
||||
expect(subject[:nom]).to eq('test_nom')
|
||||
expect(subject[:entreprise_nom]).to eq('test_nom')
|
||||
end
|
||||
|
||||
it 'L\'entreprise contient bien un prenom' do
|
||||
expect(subject[:prenom]).to eq('test_prenom')
|
||||
expect(subject[:entreprise_prenom]).to eq('test_prenom')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -25,16 +25,16 @@ describe ApiEntreprise::RNAAdapter do
|
|||
it { expect(subject).to be_an_instance_of(Hash) }
|
||||
|
||||
describe 'Attributs Associations' do
|
||||
it { expect(subject[:rna]).to eq('W595001988') }
|
||||
it { expect(subject[:association_rna]).to eq('W595001988') }
|
||||
|
||||
it { expect(subject[:titre]).to eq('UN SUR QUATRE') }
|
||||
it { expect(subject[:association_titre]).to eq('UN SUR QUATRE') }
|
||||
|
||||
it { expect(subject[:objet]).to eq("valoriser, transmettre et partager auprès des publics les plus larges possibles, les bienfaits de l'immigration, la richesse de la diversité et la curiosité de l'autre autrement") }
|
||||
it { expect(subject[:association_objet]).to eq("valoriser, transmettre et partager auprès des publics les plus larges possibles, les bienfaits de l'immigration, la richesse de la diversité et la curiosité de l'autre autrement") }
|
||||
|
||||
it { expect(subject[:date_creation]).to eq('2014-01-23') }
|
||||
it { expect(subject[:association_date_creation]).to eq('2014-01-23') }
|
||||
|
||||
it { expect(subject[:date_declaration]).to eq('2014-01-24') }
|
||||
it { expect(subject[:association_date_declaration]).to eq('2014-01-24') }
|
||||
|
||||
it { expect(subject[:date_publication]).to eq('2014-02-08') }
|
||||
it { expect(subject[:association_date_publication]).to eq('2014-02-08') }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -98,11 +98,10 @@ describe AttestationTemplate, type: :model do
|
|||
end
|
||||
let(:for_individual) { false }
|
||||
let(:individual) { nil }
|
||||
let(:etablissement) { nil }
|
||||
let(:entreprise) { create(:entreprise, etablissement: etablissement) }
|
||||
let(:etablissement) { create(:etablissement) }
|
||||
let(:types_de_champ) { [] }
|
||||
let(:types_de_champ_private) { [] }
|
||||
let!(:dossier) { create(:dossier, procedure: procedure, individual: individual, entreprise: entreprise) }
|
||||
let!(:dossier) { create(:dossier, procedure: procedure, individual: individual, etablissement: etablissement) }
|
||||
let(:template_title) { 'title' }
|
||||
let(:template_body) { 'body' }
|
||||
let(:attestation_template) do
|
||||
|
|
|
@ -30,9 +30,8 @@ describe TagsSubstitutionConcern, type: :model do
|
|||
|
||||
describe 'replace_tags' do
|
||||
let(:individual) { nil }
|
||||
let(:etablissement) { nil }
|
||||
let(:entreprise) { create(:entreprise, etablissement: etablissement) }
|
||||
let!(:dossier) { create(:dossier, procedure: procedure, individual: individual, entreprise: entreprise) }
|
||||
let(:etablissement) { create(:etablissement) }
|
||||
let!(:dossier) { create(:dossier, procedure: procedure, individual: individual, etablissement: etablissement) }
|
||||
|
||||
before { Timecop.freeze(Time.now) }
|
||||
|
||||
|
@ -61,7 +60,7 @@ describe TagsSubstitutionConcern, type: :model do
|
|||
let(:etablissement) { create(:etablissement) }
|
||||
|
||||
let(:expected_text) do
|
||||
"#{entreprise.siren} #{entreprise.numero_tva_intracommunautaire} #{entreprise.siret_siege_social} #{entreprise.raison_sociale} #{etablissement.inline_adresse}"
|
||||
"#{etablissement.entreprise_siren} #{etablissement.entreprise_numero_tva_intracommunautaire} #{etablissement.entreprise_siret_siege_social} #{etablissement.entreprise_raison_sociale} #{etablissement.inline_adresse}"
|
||||
end
|
||||
|
||||
it { is_expected.to eq(expected_text) }
|
||||
|
|
|
@ -27,8 +27,6 @@ describe Dossier do
|
|||
|
||||
describe 'methods' do
|
||||
let(:dossier) { create(:dossier, :with_entreprise, user: user) }
|
||||
|
||||
let(:entreprise) { dossier.entreprise }
|
||||
let(:etablissement) { dossier.etablissement }
|
||||
|
||||
subject { dossier }
|
||||
|
@ -200,7 +198,7 @@ describe Dossier do
|
|||
it { expect(subject[:entreprise_raison_sociale]).to eq('GRTGAZ') }
|
||||
it { expect(subject[:entreprise_siret_siege_social]).to eq('44011762001530') }
|
||||
it { expect(subject[:entreprise_code_effectif_entreprise]).to eq('51') }
|
||||
it { expect(subject[:entreprise_date_creation]).to eq('Thu, 28 Jan 2016 10:16:29 UTC +00:0') }
|
||||
it { expect(subject[:entreprise_date_creation]).to eq('1990-04-24T00:00:00+00:00') }
|
||||
it { expect(subject[:entreprise_nom]).to be_nil }
|
||||
it { expect(subject[:entreprise_prenom]).to be_nil }
|
||||
|
||||
|
@ -311,7 +309,7 @@ describe Dossier do
|
|||
"GRTGAZ",
|
||||
"44011762001530",
|
||||
"51",
|
||||
dossier.entreprise.date_creation,
|
||||
"1990-04-24T00:00:00+00:00",
|
||||
nil,
|
||||
nil
|
||||
]
|
||||
|
@ -325,22 +323,16 @@ describe Dossier do
|
|||
|
||||
describe '#reset!' do
|
||||
let!(:dossier) { create :dossier, :with_entreprise, autorisation_donnees: true }
|
||||
let!(:rna_information) { create :rna_information, entreprise: dossier.entreprise }
|
||||
let!(:exercice) { create :exercice, etablissement: dossier.etablissement }
|
||||
|
||||
subject { dossier.reset! }
|
||||
|
||||
it { expect(dossier.entreprise).not_to be_nil }
|
||||
it { expect(dossier.etablissement).not_to be_nil }
|
||||
it { expect(dossier.etablissement.exercices).not_to be_empty }
|
||||
it { expect(dossier.etablissement.exercices.size).to eq 1 }
|
||||
it { expect(dossier.entreprise.rna_information).not_to be_nil }
|
||||
it { expect(dossier.autorisation_donnees).to be_truthy }
|
||||
|
||||
it { expect { subject }.to change(RNAInformation, :count).by(-1) }
|
||||
it { expect { subject }.to change(Exercice, :count).by(-1) }
|
||||
|
||||
it { expect { subject }.to change(Entreprise, :count).by(-1) }
|
||||
it { expect { subject }.to change(Etablissement, :count).by(-1) }
|
||||
|
||||
context 'when method reset! is call' do
|
||||
|
@ -349,7 +341,6 @@ describe Dossier do
|
|||
dossier.reload
|
||||
end
|
||||
|
||||
it { expect(dossier.entreprise).to be_nil }
|
||||
it { expect(dossier.etablissement).to be_nil }
|
||||
it { expect(dossier.autorisation_donnees).to be_falsey }
|
||||
end
|
||||
|
@ -766,7 +757,7 @@ describe Dossier do
|
|||
it { expect(dossier.get_value('self', 'created_at')).to eq(dossier.created_at) }
|
||||
it { expect(dossier.get_value('user', 'email')).to eq(user.email) }
|
||||
it { expect(dossier.get_value('france_connect_information', 'gender')).to eq(user.france_connect_information.gender) }
|
||||
it { expect(dossier.get_value('entreprise', 'siren')).to eq(dossier.entreprise.siren) }
|
||||
it { expect(dossier.get_value('entreprise', 'siren')).to eq(dossier.etablissement.entreprise_siren) }
|
||||
it { expect(dossier.get_value('etablissement', 'siret')).to eq(dossier.etablissement.siret) }
|
||||
it { expect(dossier.get_value('type_de_champ', @champ_public.type_de_champ.id.to_s)).to eq(dossier.champs.first.value) }
|
||||
it { expect(dossier.get_value('type_de_champ_private', @champ_private.type_de_champ.id.to_s)).to eq(dossier.champs_private.first.value) }
|
||||
|
@ -834,7 +825,7 @@ describe Dossier do
|
|||
subject { dossier.owner_name }
|
||||
|
||||
context 'when there is no entreprise or individual' do
|
||||
let(:dossier) { create(:dossier, individual: nil, entreprise: nil, procedure: procedure) }
|
||||
let(:dossier) { create(:dossier, individual: nil, procedure: procedure) }
|
||||
|
||||
it { is_expected.to be_nil }
|
||||
end
|
||||
|
@ -842,7 +833,7 @@ describe Dossier do
|
|||
context 'when there is entreprise' do
|
||||
let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure) }
|
||||
|
||||
it { is_expected.to eq(dossier.entreprise.raison_sociale) }
|
||||
it { is_expected.to eq(dossier.etablissement.entreprise_raison_sociale) }
|
||||
end
|
||||
|
||||
context 'when there is an individual' do
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Entreprise do
|
||||
end
|
|
@ -559,12 +559,12 @@ describe Procedure do
|
|||
{ "label" => 'Civilité (FC)', "table" => 'france_connect_information', "column" => 'gender' },
|
||||
{ "label" => 'Prénom (FC)', "table" => 'france_connect_information', "column" => 'given_name' },
|
||||
{ "label" => 'Nom (FC)', "table" => 'france_connect_information', "column" => 'family_name' },
|
||||
{ "label" => 'SIREN', "table" => 'entreprise', "column" => 'siren' },
|
||||
{ "label" => 'Forme juridique', "table" => 'entreprise', "column" => 'forme_juridique' },
|
||||
{ "label" => 'Nom commercial', "table" => 'entreprise', "column" => 'nom_commercial' },
|
||||
{ "label" => 'Raison sociale', "table" => 'entreprise', "column" => 'raison_sociale' },
|
||||
{ "label" => 'SIRET siège social', "table" => 'entreprise', "column" => 'siret_siege_social' },
|
||||
{ "label" => 'Date de création', "table" => 'entreprise', "column" => 'date_creation' },
|
||||
{ "label" => 'SIREN', "table" => 'etablissement', "column" => 'entreprise_siren' },
|
||||
{ "label" => 'Forme juridique', "table" => 'etablissement', "column" => 'entreprise_forme_juridique' },
|
||||
{ "label" => 'Nom commercial', "table" => 'etablissement', "column" => 'entreprise_nom_commercial' },
|
||||
{ "label" => 'Raison sociale', "table" => 'etablissement', "column" => 'entreprise_raison_sociale' },
|
||||
{ "label" => 'SIRET siège social', "table" => 'etablissement', "column" => 'entreprise_siret_siege_social' },
|
||||
{ "label" => 'Date de création', "table" => 'etablissement', "column" => 'entreprise_date_creation' },
|
||||
{ "label" => 'SIRET', "table" => 'etablissement', "column" => 'siret' },
|
||||
{ "label" => 'Libellé NAF', "table" => 'etablissement', "column" => 'libelle_naf' },
|
||||
{ "label" => 'Code postal', "table" => 'etablissement', "column" => 'code_postal' },
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe RNAInformation do
|
||||
end
|
|
@ -28,9 +28,9 @@ describe Search do
|
|||
let!(:dossier_3) { create(:dossier, state: 'en_construction', procedure: procedure_2, user: create(:user, email: 'peace@clap.fr')) }
|
||||
let!(:dossier_archived) { create(:dossier, state: 'en_construction', procedure: procedure_1, archived: true, user: create(:user, email: 'brouillonArchived@clap.fr')) }
|
||||
|
||||
let!(:etablissement_1) { create(:etablissement, entreprise: create(:entreprise, raison_sociale: 'OCTO Academy', dossier: dossier_1), dossier: dossier_1, siret: '41636169600051') }
|
||||
let!(:etablissement_2) { create(:etablissement, entreprise: create(:entreprise, raison_sociale: 'Plop octo', dossier: dossier_2), dossier: dossier_2, siret: '41816602300012') }
|
||||
let!(:etablissement_3) { create(:etablissement, entreprise: create(:entreprise, raison_sociale: 'OCTO Technology', dossier: dossier_3), dossier: dossier_3, siret: '41816609600051') }
|
||||
let!(:etablissement_1) { create(:etablissement, entreprise_raison_sociale: 'OCTO Academy', dossier: dossier_1, siret: '41636169600051') }
|
||||
let!(:etablissement_2) { create(:etablissement, entreprise_raison_sociale: 'Plop octo', dossier: dossier_2, siret: '41816602300012') }
|
||||
let!(:etablissement_3) { create(:etablissement, entreprise_raison_sociale: 'OCTO Technology', dossier: dossier_3, siret: '41816609600051') }
|
||||
|
||||
describe 'search is empty' do
|
||||
let(:terms) { '' }
|
||||
|
|
|
@ -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