fetch and show effectif mensuel

- fetch and store effectif mensuel (at the creation of the dossier or
when updating a siret field

- show effectif mensuel only for instructeurs
This commit is contained in:
Christophe Robillard 2020-04-07 19:29:14 +02:00
parent 599d8e33e8
commit db3ef195ad
8 changed files with 72 additions and 3 deletions

View file

@ -23,7 +23,27 @@ class ApiEntrepriseService
rescue ApiEntreprise::API::RequestFailed
end
begin
effectifs_params = ApiEntreprise::EffectifsAdapter.new(entreprise_params[:entreprise_siren], procedure_id, *get_current_valid_month_for_effectif).to_params
etablissement_params.merge!(effectifs_params)
rescue ApiEntreprise::API::RequestFailed
end
etablissement_params.merge(entreprise_params)
end
end
private
def self.get_current_valid_month_for_effectif
today = Date.today
date_update = Date.new(today.year, today.month, 15)
if today >= date_update
[today.strftime("%Y"), today.strftime("%m")]
else
date = today - 1.month
[date.strftime("%Y"), date.strftime("%m")]
end
end
end