Commit 7c9ac193 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Correctiondu bug du calcul des HETD.

Les heures de service présentes sur les avenants sont maintenant en différentel et non en absolues
parent 74c88d61
Loading
Loading
Loading
Loading
+1 −1
Changes for data/ddl/view/V_CONTRAT_MAIN.sql: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ FROM
    ) "adresse",
    COALESCE(d.numero_insee,i.numero_insee)                                                       "numInsee",
    si.libelle                                                                                    "statut",
    replace(ltrim(to_char(COALESCE(fr.total,0), '999999.00')),'.',',')                            "totalHETD",
    replace(ltrim(to_char(COALESCE(c.total_hetd, fr.total,0), '999999.00')),'.',',')              "totalHETD",
    replace(ltrim(to_char(COALESCE(th.valeur,0), '999999.00')),'.',',')                           "tauxHoraireValeur",
    COALESCE(to_char(th.histo_creation, 'dd/mm/YYYY'), 'TAUX INTROUVABLE')                        "tauxHoraireDate",
    to_char(COALESCE(v.histo_creation, c.histo_creation), 'dd/mm/YYYY')                           "dateSignature",
+6 −35
Changes for data/ddl/view/V_CONTRAT_SERVICES.sql: 6 added lines, 35 removed lines.
Original line number Diff line number Diff line
CREATE OR REPLACE FORCE VIEW V_CONTRAT_SERVICES AS
SELECT
  c.contrat_id                                     contrat_id,
  c.id                                             contrat_id,
  str.libelle_court                                "serviceComposante",
  ep.code                                          "serviceCode",
  ep.libelle                                       "serviceLibelle",
  sum(vh.heures)                                   heures,
  replace(ltrim(to_char(sum(vh.heures), '999999.00')),'.',',') "serviceHeures"
FROM
  (SELECT
    c1.id contrat_id,
    c1.intervenant_id,
    c1.validation_id,
    c1.structure_id,
    c2.id all_contrat_id
  FROM
    contrat c1,
    contrat c2
    LEFT JOIN validation v ON v.id = c2.validation_id AND v.histo_destruction IS NULL
  WHERE
    c1.histo_destruction IS NULL
    AND c2.histo_destruction IS NULL
    AND c1.structure_id = c2.structure_id
    AND (
      c1.id = c2.id
      OR (v.id IS NOT NULL AND c1.contrat_id = c2.id)
      OR (v.id IS NOT NULL AND c1.contrat_id = c2.contrat_id AND c1.id > c2.id)
    )
  )                                  c
       JOIN intervenant              i ON i.id = c.intervenant_id
       JOIN type_volume_horaire    tvh ON tvh.code = 'PREVU'
       JOIN service                  s ON s.intervenant_id = i.id AND s.histo_destruction IS NULL
       JOIN volume_horaire          vh ON vh.service_id = s.id AND vh.histo_destruction IS NULL AND vh.type_volume_horaire_id = tvh.id AND vh.contrat_id = c.all_contrat_id
  LEFT JOIN validation_vol_horaire vvh ON vvh.volume_horaire_id = vh.id
  LEFT JOIN validation               v ON v.id = vvh.validation_id AND v.histo_destruction IS NULL
  LEFT JOIN validation              cv ON cv.id = c.validation_id AND cv.histo_destruction IS NULL
            contrat                  c
       JOIN structure              str ON str.id = c.structure_id
       JOIN volume_horaire          vh ON vh.contrat_id = c.id AND vh.histo_destruction IS NULL
       JOIN service                  s ON s.id = vh.service_id
  LEFT JOIN element_pedagogique     ep ON ep.id = s.element_pedagogique_id
       JOIN structure              str ON str.id = COALESCE(ep.structure_id,i.structure_id)
WHERE
  -- On récapitule tous les enseignements validés de la composante et pas seulement le différentiel...
  --AND (cv.id IS NULL OR vh.contrat_id = c.id)
  COALESCE(ep.structure_id,i.structure_id) = c.structure_id
  AND (vh.auto_validation = 1 OR v.id IS NOT NULL)
GROUP BY
  c.contrat_id, str.libelle_court, ep.code, ep.libelle
 No newline at end of file
  c.id, str.libelle_court, ep.code, ep.libelle
 No newline at end of file