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).


Shared pipeline — candidates and replacements

Candidates

dbt model: marts_enrich_acteurs_closed_candidates

Input population: active acteurs from base_vueacteur with a valid SIRET (14 numeric digits), visible on the map or in opendata (est_dans_carte or est_dans_opendata), joined with int_ae_etablissement where the establishment is closed (est_actif = FALSE, i.e. etat_administratif != 'A' in AE).

The legal unit (unite_est_actif) is not filtered at this stage, so that replacements within the same company can still be found even when the unit is closed.


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 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).