2024-02-29 12:58:31 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Maintenance
|
|
|
|
class BackfillEffectifAnnuelAnneeTask < MaintenanceTasks::Task
|
2024-09-30 09:26:46 +02:00
|
|
|
# API entreprise: rattrape les informations d'effectif
|
|
|
|
# 2024-05-27-01 PR #10053
|
2024-02-29 12:58:31 +01:00
|
|
|
def collection
|
2024-03-08 13:09:09 +01:00
|
|
|
Etablissement.where.not(entreprise_effectif_annuel: nil).where(entreprise_effectif_annuel_annee: nil)
|
2024-02-29 12:58:31 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def process(etablissement)
|
|
|
|
year = etablissement.created_at.year - 1
|
|
|
|
procedure = (etablissement.dossier || etablissement.champ&.dossier)&.procedure
|
|
|
|
APIEntreprise::EffectifsAnnuelsJob.perform_later(etablissement.id, procedure&.id, year)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|