Remove legacy

Update EtablissementUpdateJob
This commit is contained in:
gregoirenovel 2018-03-19 15:40:39 +01:00
parent d99eed122d
commit a3fd271b00
2 changed files with 2 additions and 19 deletions

View file

@ -2,12 +2,9 @@ class EtablissementUpdateJob < ApplicationJob
queue_as :default
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 dossier.entreprise.present?
dossier.entreprise.destroy
end
if dossier.etablissement.present?
dossier.etablissement.destroy
end

View file

@ -1,5 +1,5 @@
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
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(exercices_params)
# This is to fill legacy models and relationships
if dossier.present?
handle_legacy_models!(params, entreprise_params, dossier, association_params)
end
params
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