From e79c2dd0349a2197ccb5fb4934a1dad1aa71ea1a Mon Sep 17 00:00:00 2001 From: Charles Marcoin Date: Thu, 27 Jun 2024 14:00:21 +0200 Subject: [PATCH] only import codefi companies when creating a new campaign --- pkg/ops/campaignops/sql/siretsFromListe.sql | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/ops/campaignops/sql/siretsFromListe.sql b/pkg/ops/campaignops/sql/siretsFromListe.sql index 30ddf616..ea0bd211 100644 --- a/pkg/ops/campaignops/sql/siretsFromListe.sql +++ b/pkg/ops/campaignops/sql/siretsFromListe.sql @@ -1,6 +1,8 @@ -select siret -from v_summaries -where last_list=$1 and alert != 'Pas d''alerte' - and last_procol in ('in_bonis', 'continuation', 'sauvegarde', 'plan_sauvegarde') - and etat_administratif != 'F' - and first_alert; \ No newline at end of file +SELECT vs.siret +FROM v_summaries vs +INNER JOIN codefi_entreprises ce ON vs.siren = ce.siren +WHERE vs.liste = $1 + AND vs.alert != 'Pas d''alerte' + AND vs.last_procol IN ('in_bonis', 'continuation', 'sauvegarde', 'plan_sauvegarde') + AND vs.etat_administratif != 'F' + AND vs.first_alert;