Commit 009537f3 authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Finalisation extraction des indemnités de fin de contrat par période

parent f9c7bb83
Loading
Loading
Loading
Loading
+48 −6
Changes for data/ddl/view/V_EXPORT_PAIEMENT_INDEMNITES.sql: 48 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -5,26 +5,68 @@ tp.mission_id mission_id,
		SUM((tp.heures_payees_aa+tp.heures_payees_ac)*tp.taux_horaire*tp.taux_conges_payes)  total_paie,
		SUM(tp.heures_a_payer_aa+tp.heures_a_payer_ac)         									 total_heures_a_payer,
		SUM(tp.heures_payees_aa+tp.heures_payees_ac)                                             total_heures_payees
FROM tbl_paiement tp 
WHERE tp.mission_id IS NOT NULL
GROUP BY tp.mission_id
	FROM
		tbl_paiement tp
	WHERE
		tp.mission_id IS NOT NULL
	GROUP BY
		tp.mission_id
)
SELECT
	t.annee_id           				annee_id,
	ti.id				 				type_intervenant,
	i.structure_id		 				structure_id,
	t.periode_id         				periode_id,
	t.periode_code						periode_code,
	i.id				 				intervenant_id,
	CASE
     WHEN i.numero_insee IS NULL
     THEN '''' || TRIM(d.numero_insee)
     ELSE
         '''' || TRIM(i.numero_insee)
     END								insee,
  i.nom_usuel || ',' ||i.prenom 		nom,
	s.type_paie_prime				    carte,
	--Voir comment répartir le paiement prime aa/ac
	2									code_origine,
	s.code_indemnite_prime				retenue,
	'0'                                 sens,
	s.mode_calcul_prime					mc,
	''									nbu,
	t.montant_prime						montant,
	'INDEMNITE FIN CONTRAT'				libelle,
	t.prime_id							prime_id

FROM (
	SELECT
		mp.id                               prime_id,
		MAX(m.date_fin)                     date_fin_mission_max,
		MAX(m.intervenant_id)        	    intervenant_id,
		MAX(i.annee_id)              	    annee_id,
		max(p.code) 						periode_code,
		max(p.id) 							periode_id,
		MAX(hpm.total_paie)                 paie_mission,
		MAX(hpm.total_heures_a_payer)       total_heures_a_payer,
		MAX(hpm.total_heures_payees)        total_heures_payees,
MAX(hpm.total_paie * 0.1)        montant_prime
from mission_prime mp 
		MAX(round(hpm.total_paie * 0.1,2))  montant_prime
	FROM mission_prime mp
	JOIN mission m ON mp.id = m.prime_id
	JOIN intervenant i ON i.id = m.intervenant_id
	JOIN statut s ON s.id = i.statut_id
	JOIN heures_paie_mission hpm ON hpm.mission_id = m.id
	JOIN annee a ON a.id = i.annee_id
	--On regarde la date de fin la plus éloignée des missions composants la prime, pour en déduire la période de paie au mois suivant cette date
	JOIN periode p ON p.ecart_mois = ROUND(MONTHS_BETWEEN(m.date_fin,a.date_debut))
	WHERE
	--Il faut impérativement une prime validée
	mp.declaration_id IS NOT NULL
	AND mp.validation_id IS NOT NULL
	--Il faut payer les primes uniquement pour les missions payées en totalité
	AND hpm.total_heures_a_payer = hpm.total_heures_payees
GROUP BY mp.id
 No newline at end of file
	GROUP BY
		mp.id
) t
JOIN intervenant i ON t.intervenant_id = i.id
LEFT JOIN intervenant_dossier d ON d.intervenant_id = i.id AND d.histo_destruction IS NULL
JOIN statut s ON s.id = i.statut_id
JOIN type_intervenant ti ON ti.id = s.type_intervenant_id
 No newline at end of file
+62
Changes for data/etats_sortie.php: 62 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -188,6 +188,68 @@ return [
    "LIBELLE": {
        "libelle": "Libellé"
    }
}',
    ],
    [
        'CODE'           => 'winpaie-indemnites',
        'LIBELLE'        => 'Extraction Winpaie indemnité de fin de contrat',
        'PDF_TRAITEMENT' => null,
        'AUTO_BREAK'     => false,
        'REQUETE'        => 'SELECT * FROM v_export_paiement_indemnites',
        'CSV_PARAMS'     => '{
    "ANNEE_ID": {
        "visible": false
    },
    "PRIME_ID": {
        "visible": false
    },
    "TYPE_INTERVENANT": {
        "visible": false
    },
    "STRUCTURE_ID": {
        "visible": false
    },
    "PERIODE_ID": {
        "visible": false
    },
    "PERIODE_CODE": {
        "visible": false
    },
    "INTERVENANT_ID": {
        "visible": false
    },
    "INSEE": {
        "libelle": "Insee"
    },
    "NOM": {
        "libelle": "Nom"
    },
    "CARTE": {
        "libelle": "Carte"
    },
    "CODE_ORIGINE": {
        "libelle": "Code origine"
    },
    "RETENUE": {
        "libelle": "Retenue"
    },
    "SENS": {
        "libelle": "Sens"
    },
    "MC": {
        "libelle": "MC"
    },
    "NBU": {
        "libelle": "NBU",
        "type": "float"
    },
    "MONTANT": {
        "libelle": "Montant",
        "type": "float"
    },
    "LIBELLE": {
        "libelle": "Libellé"
    }
}',
    ],
    [
+3 −3
Changes for module/Paiement/config/paiement.config.php: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ return [
                    'action'     => 'extractionPaie',
                ],
                'extraction-paie-prime' => [
                    'route'      => '/extraction-paie-prime[/:type][/:periode]',
                    'route' => '/extraction-paie-prime[/:periode]',
                    'controller' => Controller\PaiementController::class,
                    'action'     => 'extractionPaiePrime',
                ],
@@ -147,8 +147,8 @@ return [
                            'resource' => Privileges::getResourceId(Privileges::MISE_EN_PAIEMENT_EXPORT_PAIE),
                        ],
                        'extraction-paie-prime' => [
                            'label'    => "Extraction des primes étudiantes",
                            'title'    => "Export des données pour payer les primes étudiantes",
                            'label' => "Extraction des indemnités de fin de contrat",
                            'title' => "Export des données pour payer les indemnités de fin de contrat des étudiantes",
                            'route'    => 'paiement/extraction-paie-prime',
                            'resource' => Privileges::getResourceId(Privileges::MISSION_PRIME_GESTION),
                        ],
+24 −3
Changes for module/Paiement/src/Controller/PaiementController.php: 24 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -439,12 +439,19 @@ class PaiementController extends AbstractController
        $this->initFilters();
        $periode = $this->params()->fromRoute('periode');
        $periode = $this->getServicePeriode()->getRepo()->findOneBy(['code' => $periode]);
        $type = $this->params()->fromRoute('type');
        $type = $this->getServiceTypeIntervenant()->getRepo()->findOneBy(['code' => $type]);

        $annee = $this->getServiceContext()->getAnnee();
        $role  = $this->getServiceContext()->getSelectedIdentityRole();

        if (empty($periode)) {
            $qb       = $this->getServicePeriode()->getPeriodePaiement();
        if (empty($type)) {
            $types = $this->getServiceTypeIntervenant()->getList();

            return compact('types');
        } elseif (empty($periode)) {
            $qb = $this->getServicePeriode()->finderByMiseEnPaiement();
            $this->getServiceMiseEnPaiement()->finderByEtat(MiseEnPaiement::MIS_EN_PAIEMENT, $qb);
            $periodes = $this->getServicePeriode()->getList($qb);

            return compact('type', 'periodes', 'annee');
@@ -470,8 +477,22 @@ class PaiementController extends AbstractController
        $this->initFilters();
        $periode = $this->params()->fromRoute('periode');
        $annee   = $this->getServiceContext()->getAnnee();

        if (empty($periode)) {
            $periodes = $this->getServicePeriode()->getPaiement();
        } else {
            $periode   = $this->getServicePeriode()->getByCode($periode);
            $recherche = new MiseEnPaiementRecherche;
            $recherche->setAnnee($annee);
            $recherche->setPeriode($periode);
            $filters = $recherche->getFilters();

            $etatSortie = $this->getServiceEtatSortie()->getRepo()->findOneBy(['code' => 'winpaie-indemnites']);
            $csvModel   = $this->getServiceEtatSortie()->genererCsv($etatSortie, $filters, ['periode' => $periode, 'annee' => $annee]);
            $csvModel->setFilename(str_replace(' ', '_', 'ose-export-indemnite-' . strtolower($periode->getLibelleAnnuel($annee)) . '.csv'));

            return $csvModel;
        }


        return compact('periodes', 'annee');
    }
+1 −1
Changes for module/Paiement/view/paiement/paiement/extraction-paie-prime.phtml: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@
    <ul>
        <?php
        foreach ($periodes as $periode) {
            $url   = '';//$this->url('paiement/extraction-paie', ['type' => $type->getCode(), 'periode' => $periode->getCode()]);
            $url = $this->url('paiement/extraction-paie-prime', ['periode' => $periode->getCode()]);
            $title = $periode->getLibelleAnnuel($annee);
            echo '<li><a href="' . $url . '">' . $title . '</a></li>';
        }