2018-03-06 13:44:29 +01:00
|
|
|
class Etablissement < ApplicationRecord
|
2015-08-10 11:05:06 +02:00
|
|
|
belongs_to :dossier
|
2018-03-07 17:42:31 +01:00
|
|
|
belongs_to :entreprise, dependent: :destroy
|
2015-11-16 11:23:29 +01:00
|
|
|
|
2016-06-20 13:57:57 +02:00
|
|
|
has_many :exercices, dependent: :destroy
|
2016-01-06 15:48:06 +01:00
|
|
|
|
2018-02-22 16:53:29 +01:00
|
|
|
accepts_nested_attributes_for :exercices
|
2018-03-07 17:42:02 +01:00
|
|
|
accepts_nested_attributes_for :entreprise, update_only: true
|
2018-02-22 16:53:29 +01:00
|
|
|
|
2018-03-06 13:44:29 +01:00
|
|
|
validates :dossier_id, uniqueness: true
|
2016-10-05 14:28:10 +02:00
|
|
|
|
2016-01-06 15:48:06 +01:00
|
|
|
def geo_adresse
|
2016-01-19 17:19:38 +01:00
|
|
|
[numero_voie, type_voie, nom_voie, complement_adresse, code_postal, localite].join(' ')
|
2016-01-06 15:48:06 +01:00
|
|
|
end
|
2017-06-22 14:58:29 +02:00
|
|
|
|
|
|
|
def inline_adresse
|
2018-01-15 19:14:09 +01:00
|
|
|
# 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
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|