Merge pull request #2774 from betagouv/frederic/support_change_siret

Rake task to change siret number
This commit is contained in:
Frederic Merizen 2018-10-06 14:04:34 +02:00 committed by GitHub
commit 48b78e95f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -48,4 +48,26 @@ namespace :support do
user.dossiers.each(&:delete_and_keep_track)
user.destroy
end
desc <<~EOD
Change the SIRET for a given dossier (specified by DOSSIER_ID)
EOD
task update_dossier_siret: :environment do
siret_number = ENV['SIRET']
dossier_id = ENV['DOSSIER_ID']
if siret_number.nil?
fail "Must specify a SIRET"
end
siret_number = siret_number.dup # Unfreeze the string
siret = Siret.new(siret: siret_number)
if siret.invalid?
fail siret.errors.full_messages.to_sentence
end
dossier = Dossier.find(dossier_id)
EtablissementUpdateJob.perform_now(dossier, siret_number)
end
end