Commit 7cb49342 authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Refactoring de l'indicateur 330 : Donne maintenant uniquement les intervenants...

Refactoring de l'indicateur 330 : Donne maintenant uniquement les intervenants en attente d'un avenant
parent 46153b70
Loading
Loading
Loading
Loading
+14 −6
Original line number Diff line number Diff line
CREATE OR REPLACE FORCE VIEW V_INDICATEUR_330 AS
WITH has_contrat AS (
  SELECT DISTINCT
    intervenant_id
    i.id            intervenant_id,
    i.annee_id      annee_id,
    c.structure_id  structure_id
  FROM
    tbl_contrat
  	intervenant i
  	JOIN contrat c ON c.intervenant_id = i.iD
  WHERE
    edite > 0
    c.type_contrat_id = 1 --a déjà un contrat de type 'CONTRAT'
    AND c.histo_destruction IS NULL
  	AND i.histo_destruction IS NULL
)
SELECT
  rownum id,
@@ -13,10 +18,13 @@ SELECT
  w.intervenant_id,
  w.structure_id
FROM
  tbl_workflow w
  JOIN has_contrat hc ON hc.intervenant_id = w.intervenant_id
	intervenant i
	JOIN tbl_workflow w ON w.intervenant_id = i.id
	JOIN has_contrat hc ON hc.intervenant_id = i.id
	LEFT JOIN contrat c ON c.intervenant_id = i.id AND c.structure_id = w.structure_id AND c.histo_destruction IS NULL
WHERE
  w.atteignable = 1
  AND w.etape_code = 'CONTRAT'
  AND w.objectif > 0
  AND w.realisation < w.objectif
  AND c.id IS NULL
 No newline at end of file