Remove legacy
Update EtablissementUpdateJob
This commit is contained in:
parent
d99eed122d
commit
a3fd271b00
2 changed files with 2 additions and 19 deletions
|
@ -2,12 +2,9 @@ class EtablissementUpdateJob < ApplicationJob
|
||||||
queue_as :default
|
queue_as :default
|
||||||
|
|
||||||
def perform(dossier, siret)
|
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 etablissement_attributes.present?
|
||||||
if dossier.entreprise.present?
|
|
||||||
dossier.entreprise.destroy
|
|
||||||
end
|
|
||||||
if dossier.etablissement.present?
|
if dossier.etablissement.present?
|
||||||
dossier.etablissement.destroy
|
dossier.etablissement.destroy
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class ApiEntrepriseService
|
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
|
etablissement_params = ApiEntreprise::EtablissementAdapter.new(siret, procedure_id).to_params
|
||||||
entreprise_params = ApiEntreprise::EntrepriseAdapter.new(siret, procedure_id).to_params
|
entreprise_params = ApiEntreprise::EntrepriseAdapter.new(siret, procedure_id).to_params
|
||||||
|
|
||||||
|
@ -12,21 +12,7 @@ class ApiEntrepriseService
|
||||||
.merge(association_params.transform_keys { |k| "association_#{k}" })
|
.merge(association_params.transform_keys { |k| "association_#{k}" })
|
||||||
.merge(exercices_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
|
params
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
Loading…
Reference in a new issue