Enrich — Acteurs fermés (enrich_acteurs_closed)¶
This DAG detects active acteurs whose SIRET is closed in the
Annuaire Entreprises (AE),
then either proposes a replacement SIRET or marks the acteur as inactive.
It first refreshes the dbt models
(dbt build --select tag:marts,tag:enrich,tag:closed), runs tests, then
generates suggestions for four mutually exclusive cohorts.
Each acteur yields one legacy Suggestion (1 suggestion per acteur, grouped
under a SuggestionCohorte per cohort).
Cohort 1 — Replaced by a SIRET from the same SIREN¶
dbt model: marts_enrich_acteurs_closed_suggest_replaced_same_siren
Input population: acteurs from marts_enrich_acteurs_closed_replaced where
the proposed SIRET shares the same SIREN as the closed acteur.
Proposal: update the acteur’s SIRET and SIREN to the replacement values,
set siret_is_closed = False, and record the replacement reason in
parent_reason.
Cohort 2 — Replaced by a SIRET from a different SIREN¶
dbt model: marts_enrich_acteurs_closed_suggest_replaced_other_siren
Input population: acteurs from marts_enrich_acteurs_closed_replaced where
the proposed SIRET belongs to a different SIREN.
Proposal: same as cohort 1 (SIRET/SIREN update, siret_is_closed = False).
Cohort 3 — Not replaced, legal unit closed¶
dbt model: marts_enrich_acteurs_closed_suggest_not_replaced_unite
Input population: candidates with a closed legal unit in AE
(unite_est_actif = FALSE) and no replacement found in
marts_enrich_acteurs_closed_replaced.
Proposal: set the acteur status to INACTIF, flag siret_is_closed = True,
with a reason indicating the SIRET is closed in AE and no replacement was
found.
Cohort 4 — Not replaced, establishment closed only¶
dbt model: marts_enrich_acteurs_closed_suggest_not_replaced_etablissement
Input population: remaining candidates — establishment closed in AE but
legal unit still active (unite_est_actif = TRUE), excluded from cohorts 1–3
(no replacement found, not already classified as fully closed at unit level).
Proposal: same as cohort 3 (INACTIF, siret_is_closed = True).