Commit 44e9c77f authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Forcer l'activation de l'étape pièce justificative même sans service prévisionel

parent fa232fd3
Loading
Loading
Loading
Loading
+945 −582

File changed.

Preview size limit exceeded, changes collapsed.

+37 −35
Original line number Diff line number Diff line
CREATE OR REPLACE FORCE VIEW V_TBL_PIECE_JOINTE_DEMANDE AS
CREATE
OR REPLACE FORCE VIEW V_TBL_PIECE_JOINTE_DEMANDE AS
WITH i_h AS (
  SELECT
    s.intervenant_id,
@@ -31,16 +32,14 @@ hetd AS (
  GROUP BY
    intervenant_id
)
SELECT
  i.annee_id                      annee_id,
SELECT i.annee_id                        annee_id,
       i.code                            code_intervenant,
       i.id                              intervenant_id,
       tpj.id                            type_piece_jointe_id,
       MAX(COALESCE(i_h.heures, 0))      heures_pour_seuil,
       tpjs.obligatoire                  obligatoire,
       MAX(COALESCE(hetd.total_hetd, 0)) heures_pour_seuil_hetd
FROM
            intervenant                 i
FROM intervenant i

         LEFT JOIN intervenant_dossier d ON d.intervenant_id = i.id
    AND d.histo_destruction IS NULL
@@ -61,7 +60,8 @@ WHERE
    /*@ANNEE_ID=i.annee_id*/

  -- Seuil heure soit en HETD soit en heure ou PJ obligatoire meme avec des heures non payables
  AND ((COALESCE(tpjs.type_heure_hetd,0) = 0 AND COALESCE(i_h.heures,0) > COALESCE(tpjs.seuil_hetd,-1))
  AND (COALESCE(tpjs.seuil_hetd, 0) = 0
    OR (COALESCE(tpjs.type_heure_hetd, 0) = 0 AND COALESCE(i_h.heures, 0) > COALESCE(tpjs.seuil_hetd, -1))
    OR (tpjs.type_heure_hetd = 1 AND COALESCE(hetd.total_hetd, 0) > COALESCE(tpjs.seuil_hetd, -1))
    OR (COALESCE(i_h.heures_non_payables, 0) > 0 AND tpjs.obligatoire_hnp = 1))

@@ -69,13 +69,15 @@ WHERE
  -- Le RIB n'est demandé QUE s'il est différent!!
  AND CASE
          WHEN tpjs.changement_rib = 0 OR d.id IS NULL THEN 1
        ELSE CASE WHEN REPLACE(i.bic, ' ', '') = REPLACE(d.bic, ' ', '') AND REPLACE(i.iban, ' ', '') = REPLACE(d.iban, ' ', '') THEN 0 ELSE 1 END
          ELSE CASE
                   WHEN replace(i.bic, ' ', '') = replace(d.bic, ' ', '') AND
                        replace(i.iban, ' ', '') = replace(d.iban, ' ', '') THEN 0
                   ELSE 1 END
          END = 1

  -- Filtre FC
  AND (tpjs.fc = 0 OR i_h.fc > 0)
GROUP BY
  i.annee_id,
GROUP BY i.annee_id,
         i.id,
         i.code,
         tpj.id,