Rake task to change siret number
This commit is contained in:
parent
93183aae64
commit
da2333ca3e
1 changed files with 22 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue