demarches-normaliennes/app/models/etablissement.rb

31 lines
876 B
Ruby
Raw Normal View History

2018-03-06 13:44:29 +01:00
class Etablissement < ApplicationRecord
2015-08-10 11:05:06 +02:00
belongs_to :dossier
belongs_to :entreprise
has_many :exercices, dependent: :destroy
2018-02-22 16:53:29 +01:00
accepts_nested_attributes_for :exercices
accepts_nested_attributes_for :entreprise
2018-03-06 13:44:29 +01:00
validates :dossier_id, uniqueness: true
def geo_adresse
[numero_voie, type_voie, nom_voie, complement_adresse, code_postal, localite].join(' ')
end
2017-06-22 14:58:29 +02:00
def inline_adresse
# squeeze needed because of space in excess in the data
2017-06-22 14:58:29 +02:00
"#{numero_voie} #{type_voie} #{nom_voie}, #{complement_adresse}, #{code_postal} #{localite}".squeeze(' ')
end
2018-02-22 16:53:29 +01:00
attr_accessor :entreprise_mandataires_sociaux
def mandataire_social?(france_connect_information)
if france_connect_information.present?
entreprise_mandataires_sociaux&.find do |mandataire|
france_connect_information.mandataire_social?(mandataire)
end
end
end
2015-08-10 11:05:06 +02:00
end