2024-02-29 12:58:31 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Maintenance
|
|
|
|
class BackfillEffectifAnnuelAnneeTask < MaintenanceTasks::Task
|
|
|
|
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
|