Commit 91d33bef authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Correction bug qui pouvait bloquer la vue lors du calcul des formules

parent 9721186e
Loading
Loading
Loading
Loading
+25 −11
Changes for data/ddl/view/V_FORMULE_VOLUME_HORAIRE.sql: 25 added lines, 11 removed lines.
Original line number Diff line number Diff line
@@ -47,8 +47,8 @@ SELECT
  str.code                                                             structure_code,
  CASE WHEN COALESCE(str.id,0) = COALESCE(i.structure_id,0)      THEN 1 ELSE 0 END structure_is_affectation,
  CASE WHEN COALESCE(str.id,0) = COALESCE(to_number(p.valeur),0) THEN 1 ELSE 0 END structure_is_univ,
  MAX(COALESCE( m.ponderation_service_du, 1))                          ponderation_service_du,
  MAX(COALESCE( m.ponderation_service_compl, 1))                       ponderation_service_compl,
  ep.ponderation_service_du                                            ponderation_service_du,
  ep.ponderation_service_compl                                         ponderation_service_compl,
  COALESCE(tf.service_statutaire,1)                                    service_statutaire,

  vh.heures                                                            heures,
@@ -66,13 +66,32 @@ FROM
       JOIN v_volume_horaire_etat    vhe ON vhe.volume_horaire_id = vh.id
       JOIN type_volume_horaire      tvh ON tvh.id = vh.type_volume_horaire_id

  LEFT JOIN element_pedagogique       ep ON ep.id = s.element_pedagogique_id
  LEFT JOIN (
    SELECT
      ep.id,
      ep.structure_id,
      ep.etape_id,
      ep.taux_fi,
      ep.taux_fa,
      ep.taux_fc,
      MAX(COALESCE( m.ponderation_service_du, 1))                          ponderation_service_du,
      MAX(COALESCE( m.ponderation_service_compl, 1))                       ponderation_service_compl
    FROM
      element_pedagogique ep
      LEFT JOIN element_modulateur        em ON em.element_id = ep.id
                                            AND em.histo_destruction IS NULL
      LEFT JOIN modulateur                 m ON m.id = em.modulateur_id
    GROUP BY
      ep.id,
      ep.structure_id,
      ep.etape_id,
      ep.taux_fi,
      ep.taux_fa,
      ep.taux_fc
  )                                   ep ON ep.id = s.element_pedagogique_id
  LEFT JOIN structure                str ON str.id = ep.structure_id
  LEFT JOIN etape                      e ON e.id = ep.etape_id
  LEFT JOIN type_formation            tf ON tf.id = e.type_formation_id
  LEFT JOIN element_modulateur        em ON em.element_id = s.element_pedagogique_id
                                        AND em.histo_destruction IS NULL
  LEFT JOIN modulateur                 m ON m.id = em.modulateur_id
  LEFT JOIN type_intervention_statut tis ON tis.type_intervention_id = ti.id AND tis.statut_id = i.statut_id
WHERE
  vh.histo_destruction IS NULL
@@ -80,11 +99,6 @@ WHERE
  AND vh.heures <> 0
  AND vh.motif_non_paiement_id IS NULL
  AND s.intervenant_id = COALESCE( OSE_FORMULE.GET_INTERVENANT_ID, s.intervenant_id )
GROUP BY
  vh.id, s.id, s.intervenant_id, ti.id, vh.type_volume_horaire_id, vhe.etat_volume_horaire_id, tvh.code,
  ep.id, ep.taux_fi, ep.taux_fa, ep.taux_fc, str.id, str.code, tf.service_statutaire, vh.heures,
  vh.horaire_debut, vh.horaire_fin, tis.taux_hetd_service, tis.taux_hetd_complementaire,
  ti.code, ti.taux_hetd_service, ti.taux_hetd_complementaire, i.structure_id, p.valeur

UNION ALL