Commit 2510549e authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Prise en compte de l'éligibilité ou non à l'extraction de paie par type d'heures

parent cc5aebd0
Loading
Loading
Loading
Loading
+49 −20
Changes for data/ddl/view/V_EXPORT_PAIEMENT_WINPAIE.sql: 49 added lines, 20 removed lines.
Original line number Diff line number Diff line
@@ -51,7 +51,9 @@ FROM (SELECT i.annee_id
             si.type_paie_prime																				   type_paie_prime,
             si.mode_calcul_prime																			   mode_calcul_prime,
             t2.type_paiement																				   type_paiement
      FROM (SELECT structure_id,
      FROM (
            SELECT
              structure_id,
              structure_ids,
              periode_paiement_id,
              intervenant_id,
@@ -64,7 +66,8 @@ FROM (SELECT i.annee_id
            FROM (

                --Pour les heures payées pour les heures AA
                SELECT tp.mise_en_paiement_id    id,
                SELECT
                  tp.mise_en_paiement_id    id,
                  tp.structure_id           structure_id,
                  s.ids                     structure_ids,
                  tp.periode_paiement_id,
@@ -75,17 +78,21 @@ FROM (SELECT i.annee_id
                  tp.taux_horaire,
                  tp.taux_conges_payes,
                  'heures_payees'           type_paiement

                  FROM tbl_paiement tp
                FROM
                       tbl_paiement tp
                  JOIN structure    s ON tp.structure_id = s.id
                  JOIN centre_cout cc ON cc.id = tp.centre_cout_id
                  WHERE tp.heures_payees_aa > 0
                  JOIN type_heures th ON th.id = tp.type_heures_id
                WHERE
                  tp.heures_payees_aa > 0
                  AND tp.periode_paiement_id IS NOT NULL
                  AND th.eligible_extraction_paie = 1

                UNION ALL

                --Pour les heures payées pour les heures AC
                  SELECT tp.mise_en_paiement_id   id,
                SELECT
                  tp.mise_en_paiement_id   id,
                  tp.structure_id          structure_id,
                  s.ids                    structure_ids,
                  tp.periode_paiement_id,
@@ -96,16 +103,21 @@ FROM (SELECT i.annee_id
                  tp.taux_horaire,
                  tp.taux_conges_payes,
                  'heures_payees'          type_paiement
                  FROM tbl_paiement tp
                FROM
                       tbl_paiement tp
                  JOIN structure     s ON tp.structure_id = s.id
                  JOIN centre_cout  cc ON cc.id = tp.centre_cout_id
                  WHERE tp.heures_payees_ac > 0
                  JOIN type_heures  th ON th.id = tp.type_heures_id
                WHERE
                  tp.heures_payees_ac > 0
                  AND tp.periode_paiement_id IS NOT NULL
                  AND th.eligible_extraction_paie = 1

                UNION ALL

                --Pour les congés payées pour les heures AA
                  SELECT tp.mise_en_paiement_id    id,
                SELECT
                  tp.mise_en_paiement_id    id,
                  tp.structure_id           structure_id,
                  s.ids                     structure_ids,
                  tp.periode_paiement_id,
@@ -116,17 +128,22 @@ FROM (SELECT i.annee_id
                  tp.taux_horaire,
                  tp.taux_conges_payes,
                  'conges_payes'            type_paiement
                  FROM tbl_paiement tp
                FROM
                       tbl_paiement tp
                  JOIN structure     s ON tp.structure_id = s.id
                  JOIN centre_cout  cc ON cc.id = tp.centre_cout_id
                  WHERE tp.heures_payees_aa > 0
                  JOIN type_heures  th ON th.id = tp.type_heures_id
                WHERE
                  tp.heures_payees_aa > 0
                  AND tp.periode_paiement_id IS NOT NULL
                  AND tp.taux_conges_payes > 1
                  AND th.eligible_extraction_paie = 1

                UNION ALL

				  --Pour les congés payées pour les heures AC
                  SELECT tp.mise_en_paiement_id   id,
                SELECT
                  tp.mise_en_paiement_id   id,
                  tp.structure_id          structure_id,
                  s.ids                    structure_ids,
                  tp.periode_paiement_id,
@@ -137,14 +154,19 @@ FROM (SELECT i.annee_id
                  tp.taux_horaire,
                  tp.taux_conges_payes,
                  'conges_payes'           type_paiement
                  FROM tbl_paiement tp
                FROM
                       tbl_paiement tp
                  JOIN structure     s ON tp.structure_id = s.id
                  JOIN centre_cout  cc ON cc.id = tp.centre_cout_id
                  WHERE tp.heures_payees_ac > 0
                  JOIN type_heures  th ON th.id = tp.type_heures_id
                WHERE
                  tp.heures_payees_ac > 0
                  AND tp.periode_paiement_id IS NOT NULL
			      AND tp.taux_conges_payes > 1
			      AND th.eligible_extraction_paie = 1
            ) t1
            GROUP BY structure_id,
            GROUP BY
              structure_id,
              structure_ids,
              periode_paiement_id,
              intervenant_id,
@@ -152,12 +174,19 @@ FROM (SELECT i.annee_id
              unite_budgetaire,
              taux_horaire,
              taux_conges_payes,
                     type_paiement) t2
               JOIN (SELECT level ind, 99 max_nbu FROM dual CONNECT BY 1=1 AND LEVEL <= 11) tnbu
                    ON ceil(t2.nbu / max_nbu) >= ind
              type_paiement
      ) t2
      JOIN (
        SELECT
            level ind,
            99 max_nbu
        FROM
            dual CONNECT BY 1=1 AND LEVEL <= 11) tnbu ON ceil(t2.nbu / max_nbu) >= ind
            JOIN intervenant i ON i.id = t2.intervenant_id
            LEFT JOIN intervenant_dossier d ON i.id = d.intervenant_id AND d.histo_destruction IS NULL
            JOIN statut si ON si.id = i.statut_id
            JOIN type_intervenant ti ON ti.id = si.type_intervenant_id
               JOIN structure s ON s.id = t2.structure_id) t3
ORDER BY annee_id, type_intervenant_id, structure_id, periode_id, nom, code_origine, nbu DESC
 No newline at end of file
            JOIN structure s ON s.id = t2.structure_id
      ) t3
ORDER BY
  annee_id, type_intervenant_id, structure_id, periode_id, nom, code_origine, nbu DESC
 No newline at end of file