Commit 99f11275 authored by Florian Joriot's avatar Florian Joriot
Browse files

remonté du nom de mission et du nom de taux dans v_contrat_main

parent ca84540c
Loading
Loading
Loading
Loading
+14 −6
Changes for data/ddl/view/V_CONTRAT_MAIN.sql: 14 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -2,6 +2,8 @@ CREATE OR REPLACE FORCE VIEW V_CONTRAT_MAIN AS
WITH hs AS (
  SELECT contrat_id, SUM(heures) "serviceTotal" FROM V_CONTRAT_SERVICES GROUP BY contrat_id
),


la AS(
        SELECT
                contrat_id,
@@ -21,6 +23,8 @@ la AS(
        )
        GROUP BY contrat_id
    )


SELECT ct.annee_id,
       ct.structure_id,
       ct.intervenant_id,
@@ -51,7 +55,8 @@ SELECT ct.annee_id,
       ct."serviceTotal",
       ct."legendeAutresHeures",
       ct."enteteAutresHeures",

       ct."missionNom",
       ct."tauxNom",
       CASE ct.est_contrat
           WHEN 1 THEN -- contrat
               'Contrat de travail'
@@ -97,9 +102,10 @@ SELECT ct.annee_id,
             COALESCE(d.numero_insee, i.numero_insee)                                                                                                      "numInsee",
             si.libelle                                                                                                                                    "statut",
             REPLACE(ltrim(to_char(COALESCE(c.total_hetd, fr.total, 0), '999999.00')), '.', ',')                                                           "totalHETD",
             REPLACE(ltrim(to_char(COALESCE(OSE_PAIEMENT.get_taux_horaire(COALESCE(tm.taux_remu_id, si.taux_remu_id,tr.id), a.date_debut), 0), '999999.00')), '.', ',')          "tauxHoraireValeur",
             COALESCE(to_char(OSE_PAIEMENT.get_taux_horaire_date(COALESCE(tm.taux_remu_id,si.taux_remu_id,tr.id), a.date_debut), 'dd/mm/YYYY'), 'TAUX INTROUVABLE')              "tauxHoraireDate",
             COALESCE(tm.taux_remu_id, si.taux_remu_id,tr.id)                                "tauxId",
             REPLACE(ltrim(to_char(COALESCE(OSE_PAIEMENT.get_taux_horaire(COALESCE(trm.id, trs.id,tr.id), a.date_debut), 0), '999999.00')), '.', ',')      "tauxHoraireValeur",
             COALESCE(to_char(OSE_PAIEMENT.get_taux_horaire_date(COALESCE(trm.id, trs.id,tr.id), a.date_debut), 'dd/mm/YYYY'), 'TAUX INTROUVABLE')         "tauxHoraireDate",
             COALESCE(trm.id, trs.id,tr.id)                                                                                                                "tauxId",
             COALESCE(trm.libelle, trs.libelle,tr.libelle)                                                                                                 "tauxNom",
             to_char(COALESCE(v.histo_creation, a.date_debut), 'dd/mm/YYYY')                                                                               "dateSignature",
             CASE
                 WHEN c.structure_id <> COALESCE(cp.structure_id, 0) THEN 'modifié'
@@ -124,14 +130,15 @@ SELECT ct.annee_id,
                 ELSE 'Autres heures' END                                                                                                                   "enteteAutresHeures",
             CASE WHEN c.contrat_id IS NULL THEN 1 ELSE 0 END                                                                                               est_contrat,
             CASE WHEN v.id IS NULL THEN 1 ELSE 0 END                                                                                                       est_projet,
             CASE WHEN LOWER(si.codes_corresp_2) = 'oui' THEN 1 ELSE 0 END                       est_atv

             CASE WHEN LOWER(si.codes_corresp_2) = 'oui' THEN 1 ELSE 0 END                                                                                  est_atv,
             tm.libelle                                                                                                                                     "missionNom"
        FROM
            contrat               c
            JOIN type_contrat         tc ON tc.id = c.type_contrat_id
            JOIN intervenant           i ON i.id = c.intervenant_id
            JOIN annee                 a ON a.id = i.annee_id
            JOIN statut               si ON si.id = i.statut_id
            LEFT JOIN taux_remu trs ON si.taux_remu_id = trs.id
            JOIN STRUCTURE             s ON s.id = c.structure_id
            LEFT JOIN intervenant_dossier   d ON d.intervenant_id = i.id AND d.histo_destruction IS NULL
            JOIN civilite            civ ON civ.id = COALESCE(d.civilite_id,i.civilite_id)
@@ -145,6 +152,7 @@ SELECT ct.annee_id,
            LEFT JOIN contrat              cp ON cp.id = c.contrat_id
            LEFT JOIN mission m on c.mission_id = m.id
            LEFT JOIN type_mission tm ON m.type_mission_id = tm.id
            LEFT JOIN taux_remu trm ON tm.taux_remu_id = trm.id
        WHERE
            c.histo_destruction IS NULL
) ct
 No newline at end of file