Job to fetch missing etablissement
This commit is contained in:
parent
92c195ad51
commit
d71aabd291
1 changed files with 19 additions and 0 deletions
19
app/jobs/etablissement_update_job.rb
Normal file
19
app/jobs/etablissement_update_job.rb
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
class EtablissementUpdateJob < ApplicationJob
|
||||||
|
queue_as :default
|
||||||
|
|
||||||
|
def perform(dossier, siret)
|
||||||
|
etablissement_attributes = SIRETService.fetch(siret, dossier.procedure_id, dossier)
|
||||||
|
|
||||||
|
if etablissement_attributes.present?
|
||||||
|
if dossier.entreprise.present?
|
||||||
|
dossier.entreprise.destroy
|
||||||
|
end
|
||||||
|
if dossier.etablissement.present?
|
||||||
|
dossier.etablissement.destroy
|
||||||
|
end
|
||||||
|
etablissement_attributes = ActionController::Parameters.new(etablissement_attributes).permit!
|
||||||
|
etablissement = dossier.build_etablissement(etablissement_attributes)
|
||||||
|
etablissement.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue