Commit adcbbac6 authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Finalisation PJ obligatoire même si uniquement des heures non payables

Ajout d'une case à cocher dans l'interface admin type piece jointe statut
parent 619af092
Loading
Loading
Loading
Loading
+2 −62
Original line number Diff line number Diff line
@@ -1429,70 +1429,10 @@ CREATE OR REPLACE PACKAGE BODY "UNICAEN_TBL" AS
    MERGE INTO
      TBL_PIECE_JOINTE_DEMANDE t
    USING (

      SELECT
        tv.*
      FROM
        (WITH i_h AS (
          SELECT
            s.intervenant_id,
            sum(vh.heures) heures,
            sum(ep.taux_fc) fc
          FROM
                 service               s
            JOIN type_volume_horaire tvh ON tvh.code = ''PREVU''
            JOIN volume_horaire       vh ON vh.service_id = s.id
                                        AND vh.type_volume_horaire_id = tvh.id
                                        AND vh.histo_destruction IS NULL
            JOIN element_pedagogique ep ON ep.id = s.element_pedagogique_id -- Service sur l''établissement
          WHERE
            s.histo_destruction IS NULL
            AND vh.motif_non_paiement_id IS NULL -- pas de motif de non paiement
          GROUP BY
            s.intervenant_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
        *
      FROM
                    intervenant                 i

          LEFT JOIN dossier                     d ON d.intervenant_id = i.id
                                                 AND d.histo_destruction IS NULL

               JOIN type_piece_jointe_statut tpjs ON tpjs.statut_intervenant_id = i.statut_id
                                                 AND tpjs.histo_destruction IS NULL
                                                 AND i.annee_id BETWEEN COALESCE(tpjs.annee_debut_id,i.annee_id) AND COALESCE(tpjs.annee_fin_id,i.annee_id)

               JOIN type_piece_jointe         tpj ON tpj.id = tpjs.type_piece_jointe_id
                                                 AND tpj.histo_destruction IS NULL

          LEFT JOIN                           i_h ON i_h.intervenant_id = i.id
        WHERE
          -- Gestion de l''historique
          i.histo_destruction IS NULL

          -- Seuil HETD
          AND (COALESCE(i_h.heures,0) > COALESCE(tpjs.seuil_hetd,-1))

          -- 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(i.iban, '' '', '''') = d.rib THEN 0 ELSE 1 END
              END = 1

          -- Filtre FC
          AND (tpjs.fc = 0 OR i_h.fc > 0)
        GROUP BY
          i.annee_id,
        i.id,
        i.code,
          tpj.id,
          tpjs.obligatoire) tv
        v_tbl_piece_jointe_demande
      WHERE
        ' || conds || '

+11 −0
Original line number Diff line number Diff line
@@ -152,6 +152,17 @@ return [
            'default'     => NULL,
            'commentaire' => NULL,
        ],
        'OBLIGATOIRE_HNP'       => [
            'name'        => 'OBLIGATOIRE_HNP',
            'type'        => 'bool',
            'bdd-type'    => 'NUMBER',
            'length'      => 0,
            'scale'       => '0',
            'precision'   => 1,
            'nullable'    => TRUE,
            'default'     => '0',
            'commentaire' => 'Piece jointe obligatoire même si les heures sont non payables',
        ],
        'SEUIL_HETD'            => [
            'name'        => 'SEUIL_HETD',
            'type'        => 'int',
+7 −6
Original line number Diff line number Diff line
@@ -2,7 +2,8 @@ CREATE OR REPLACE FORCE VIEW V_TBL_PIECE_JOINTE_DEMANDE AS
WITH i_h AS (
  SELECT
    s.intervenant_id,
    sum(vh.heures) heures,
    SUM(CASE WHEN vh.MOTIF_NON_PAIEMENT_ID IS NULL THEN vh.heures ELSE 0 END) heures,
    SUM(CASE WHEN vh.MOTIF_NON_PAIEMENT_ID IS NOT NULL THEN vh.heures ELSE 0 END) heures_non_payables,
    sum(ep.taux_fc) fc
  FROM
         service               s
@@ -13,7 +14,6 @@ WITH i_h AS (
    JOIN element_pedagogique ep ON ep.id = s.element_pedagogique_id -- Service sur l'établissement
  WHERE
    s.histo_destruction IS NULL
    AND vh.motif_non_paiement_id IS NULL -- pas de motif de non paiement
  GROUP BY
    s.intervenant_id
)
@@ -42,8 +42,9 @@ WHERE
  -- Gestion de l'historique
  i.histo_destruction IS NULL

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


  -- Le RIB n'est demandé QUE s'il est différent!!
  AND CASE
+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
    <field name="changementRIB" type="boolean" column="CHANGEMENT_RIB" nullable="false"/>
    <field name="fc" type="boolean" column="FC" nullable="false"/>
    <field name="dureeVie" type="integer" column="DUREE_VIE" nullable="true"/>
    <field name="obligatoireHNP" type="boolean" column="OBLIGATOIRE_HNP" nullable="false"/>
    <many-to-one field="anneeDebut" target-entity="Application\Entity\Db\Annee">
      <join-column name="ANNEE_DEBUT_ID" referenced-column-name="ID"/>
    </many-to-one>
+22 −0
Original line number Diff line number Diff line
@@ -62,6 +62,10 @@ class TypePieceJointeStatut implements HistoriqueAwareInterface
     */
    private $dureeVie;

    /**
     * @var boolean
     */
    private $obligatoireHNP;


    /**
@@ -301,6 +305,24 @@ class TypePieceJointeStatut implements HistoriqueAwareInterface
        return $this;
    }

    /**
     * @return bool
     */
    public function isObligatoireHNP()
    {
        return $this->obligatoireHNP;
    }

    /**
     * @param bool $obligatoireHNP
     */
    public function setObligatoireHNP($obligatoireHNP)
    {
        $this->obligatoireHNP = $obligatoireHNP;

        return $this;
    }



    public function __toString()
Loading