Commit 70c6b696 authored by lecluse's avatar lecluse
Browse files

#2572 #2537

Mise en paiement et Etats de paiement
parent 11aa991c
......@@ -21,9 +21,9 @@ ORDER BY
-- pour créer un nouveau rôle
select nom_usuel, prenom, source_code from personnel where nom_patronymique like '%Fafin%';
select nom_usuel, prenom, source_code from personnel where nom_patronymique like '%Ren%';
select libelle_court, libelle_long, source_code from structure where libelle_court like '%Méde%' AND niveau = 2;
select libelle_court, libelle_long, source_code from structure where libelle_court like '%Histoire%' AND niveau = 2;
select * from type_role where histo_destruction is null;
......@@ -32,13 +32,15 @@ INSERT INTO ROLE (
PERSONNEL_ID,
TYPE_ID,
SOURCE_CODE,
ID, SOURCE_ID, HISTO_CREATEUR_ID, HISTO_MODIFICATEUR_ID
ID, SOURCE_ID,
HISTO_CREATEUR_ID, HISTO_MODIFICATEUR_ID
)VALUES(
(SELECT ID FROM structure WHERE source_code = 'M17'),
(SELECT ID FROM personnel WHERE source_code ='19542'),
(SELECT ID FROM structure WHERE source_code = 'U08'),
(SELECT ID FROM personnel WHERE source_code ='93932'),
(SELECT ID FROM TYPE_ROLE WHERE code = 'gestionnaire-composante'),
'gest-19542',
ROLE_ID_SEQ.NEXTVAL, OSE_IMPORT.GET_SOURCE_ID('OSE'), 4, 4 -- laurent
'gest-93932',
ROLE_ID_SEQ.NEXTVAL, OSE_IMPORT.GET_SOURCE_ID('OSE'),
(select id from utilisateur where username='lecluse'), (select id from utilisateur where username='lecluse') -- laurent
);
--delete from role where source_code = 'gest-5064';
......
CREATE OR REPLACE VIEW V_ETAT_PAIEMENT AS
SELECT
periode_paiement_id,
structure_id,
intervenant_id,
annee_id,
centre_cout_id,
domaine_fonctionnel_id,
etat,
periode_paiement_libelle,
intervenant_code,
intervenant_nom,
intervenant_numero_insee,
centre_cout_code,
domaine_fonctionnel_libelle,
hetd,
CASE WHEN hetd > 0 THEN hetd / SUM( hetd ) OVER( PARTITION BY periode_paiement_id, intervenant_id, etat, structure_id) ELSE 0 END hetd_pourc,
ROUND( hetd * taux_horaire, 2 ) hetd_montant,
ROUND( fc_majorees * taux_horaire, 2 ) rem_fc_d714,
exercice_aa,
ROUND( exercice_aa * taux_horaire, 2 ) exercice_aa_montant,
exercice_ac,
ROUND( exercice_ac * taux_horaire, 2 ) exercice_ac_montant
FROM (
WITH dep AS ( -- détails par état de paiement
SELECT
p.id periode_paiement_id,
mis.structure_id structure_id,
i.id intervenant_id,
mis.annee_id annee_id,
cc.id centre_cout_id,
df.id domaine_fonctionnel_id,
CASE
WHEN v.id IS NULL THEN 'a-valider'
ELSE CASE
WHEN mep.date_mise_en_paiement IS NULL THEN 'a-mettre-en-paiement'
ELSE 'mis-en-paiement'
END
END etat,
p.libelle_long periode_paiement_libelle,
i.source_code intervenant_code,
i.prenom || ' ' || i.nom_usuel intervenant_nom,
TRIM( NVL(i.numero_insee,'') || ' ' || NVL(i.numero_insee_cle,'') ) intervenant_numero_insee,
cc.source_code centre_cout_code,
df.libelle domaine_fonctionnel_libelle,
CASE WHEN th.code = 'fc_majorees' THEN 0 ELSE mep.heures END hetd,
CASE WHEN th.code = 'fc_majorees' THEN mep.heures ELSE 0 END fc_majorees,
mep.heures * 4 / 10 exercice_aa,
mep.heures * 6 / 10 exercice_ac,
OSE_FORMULE.GET_TAUX_HORAIRE_HETD( NVL(mep.date_mise_en_paiement,SYSDATE) ) taux_horaire
FROM
v_mep_intervenant_structure mis
JOIN mise_en_paiement mep ON mep.id = mis.mise_en_paiement_id AND 1 = ose_divers.comprise_entre( mep.histo_creation, mep.histo_destruction )
JOIN type_heures th ON th.id = mep.type_heures_id AND 1 = ose_divers.comprise_entre( th.histo_creation, th.histo_destruction )
JOIN centre_cout cc ON cc.id = mep.centre_cout_id -- pas d'historique pour les centres de coût, qui devront tout de même apparaitre mais en erreur
JOIN intervenant i ON i.id = mis.intervenant_id AND 1 = ose_divers.comprise_entre( i.histo_creation, i.histo_destruction )
LEFT JOIN validation v ON v.id = mep.validation_id AND 1 = ose_divers.comprise_entre( v.histo_creation, v.histo_destruction )
LEFT JOIN domaine_fonctionnel df ON df.id = mis.domaine_fonctionnel_id
LEFT JOIN periode p ON p.id = mep.periode_paiement_id
)
SELECT
periode_paiement_id,
structure_id,
intervenant_id,
annee_id,
centre_cout_id,
domaine_fonctionnel_id,
etat,
periode_paiement_libelle,
intervenant_code,
intervenant_nom,
intervenant_numero_insee,
centre_cout_code,
domaine_fonctionnel_libelle,
SUM( hetd ) hetd,
SUM( fc_majorees ) fc_majorees,
SUM( exercice_aa ) exercice_aa,
SUM( exercice_ac ) exercice_ac,
taux_horaire
FROM
dep
GROUP BY
periode_paiement_id,
structure_id,
intervenant_id,
annee_id,
centre_cout_id,
domaine_fonctionnel_id,
etat,
periode_paiement_libelle,
intervenant_code,
intervenant_nom,
intervenant_numero_insee,
centre_cout_code,
domaine_fonctionnel_libelle,
taux_horaire
)
dep2
\ No newline at end of file
......@@ -16,28 +16,62 @@ return [
'action' => 'index',
],
],
/*'child_routes' => [
'saisie' => [
'child_routes' => [
'mise-en-paiement' => [
'type' => 'Literal',
'may_terminate' => false,
'options' => [
'route' => '/saisie',
'route' => '/mise-en-paiement',
'defaults' => [
'action' => 'miseEnPaiementSaisie',
'action' => 'miseEnPaiement',
'etat' => Entity\Db\MiseEnPaiement::A_METTRE_EN_PAIEMENT,
],
],
],
],*/
'etat-paiement' => [
'type' => 'Literal',
'may_terminate' => false,
'options' => [
'route' => '/etat-paiement',
'defaults' => [
'action' => 'miseEnPaiement',
'etat' => Entity\Db\MiseEnPaiement::MIS_EN_PAIEMENT,
],
],
],
],
],
],
],
'navigation' => array(
'default' => array(
'home' => array(
'pages' => array(
'gestion' => array(
'pages' => array(
'mise-en-paiement' => array(
'label' => "Mise en paiement",
'title' => "Mise en paiement",
'route' => 'paiement/mise-en-paiement',
),
'etat-paiement' => array(
'label' => "État de paiement",
'title' => "État de paiement",
'route' => 'paiement/etat-paiement',
),
),
),
),
),
),
),
'bjyauthorize' => [
'guards' => [
'BjyAuthorize\Guard\Controller' => [
[
'controller' => 'Application\Controller\Paiement',
'action' => ['index','demandeMiseEnPaiement'],
'roles' => [R_COMPOSANTE, R_ADMINISTRATEUR],
'action' => ['index','demandeMiseEnPaiement','miseEnPaiement'],
'roles' => [R_COMPOSANTE, R_ADMINISTRATEUR, R_DRH],
],
],
],
......@@ -66,11 +100,12 @@ return [
],
'service_manager' => [
'invokables' => [
'ApplicationServiceAPayer' => 'Application\Service\ServiceAPayer',
'ApplicationMiseEnPaiement' => 'Application\Service\MiseEnPaiement',
'ApplicationTypeHeures' => 'Application\Service\TypeHeures',
'ApplicationCentreCout' => 'Application\Service\CentreCout',
'MiseEnPaiementAssertion' => 'Application\\Assertion\\MiseEnPaiementAssertion',
'ApplicationServiceAPayer' => 'Application\Service\ServiceAPayer',
'ApplicationMiseEnPaiement' => 'Application\Service\MiseEnPaiement',
'ApplicationMiseEnPaiementIntervenantStructure' => 'Application\Service\MiseEnPaiementIntervenantStructure',
'ApplicationTypeHeures' => 'Application\Service\TypeHeures',
'ApplicationCentreCout' => 'Application\Service\CentreCout',
'MiseEnPaiementAssertion' => 'Application\Assertion\MiseEnPaiementAssertion',
],
],
'view_helpers' => [
......@@ -80,7 +115,7 @@ return [
],
'form_elements' => [
'invokables' => [
'MiseEnPaiementSaisie' => 'Application\Form\Paiement\MiseEnPaiementSaisieForm',
'PaiementMiseEnPaiementRechercheForm' => 'Application\Form\Paiement\MiseEnPaiementRechercheForm',
],
],
'controllers' => [
......
......@@ -144,8 +144,6 @@ return array(
'action' => array('voir', 'liste', 'saisie'),
'roles' => array(R_INTERVENANT, R_COMPOSANTE, R_ADMINISTRATEUR)
),
),
'BjyAuthorize\Guard\Controller' => array(
array(
'controller' => 'Application\Controller\VolumeHoraireReferentiel',
'action' => array('voir', 'liste', 'saisie'),
......
......@@ -49,6 +49,93 @@ class PaiementController extends AbstractActionController implements ContextProv
return compact('intervenant', 'servicesAPayer');
}
public function miseEnPaiementAction()
{
$this->initFilters();
$etat = $this->params()->fromRoute('etat');
$rechercheForm = $this->getFormMiseEnPaiementRecherche();
$recherche = new \Application\Entity\Paiement\MiseEnPaiementRecherche;
$recherche->setEtat( $etat ); // données à mettre en paiement uniquement
$rechercheForm->bind($recherche);
$qb = $this->getServiceStructure()->finderByMiseEnPaiement();
$this->getServiceMiseEnPaiement()->finderByEtat($etat, $qb);
$structures = $this->getServiceStructure()->getList($qb);
$rechercheForm->populateStructures( $structures );
if (count($structures) == 1){
$structure = current($structures);
$rechercheForm->get('structure')->setValue( $structure->getId() );
}else{
$structure = $this->context()->structureFromPost(); /* @var $structure \Application\Entity\Db\Structure */
}
$periode = null;
if ($structure){
$qb = $this->getServicePeriode()->finderByMiseEnPaiement($structure);
$this->getServiceMiseEnPaiement()->finderByEtat($etat, $qb);
$periodes = $this->getServicePeriode()->getList($qb);
$rechercheForm->populatePeriodes( $periodes );
if (count($periodes) == 1){
$periode = current($periodes);
$rechercheForm->get('periode')->setValue( $periode->getId() );
}else{
$periode = $this->context()->periodeFromPost(); /* @var $periode \Application\Entity\Db\Periode */
}
$qb = $this->getServiceIntervenant()->finderByMiseEnPaiement( $structure );
$this->getServiceMiseEnPaiement()->finderByEtat($etat, $qb);
$rechercheForm->populateIntervenants( $this->getServiceIntervenant()->getList($qb) );
}
$request = $this->getRequest();
if ($request->isPost()) {
$rechercheForm->setData($request->getPost());
$rechercheForm->isValid();
}
$etatPaiement = null;
if ( $recherche->getIntervenants()->count() > 0 ){
$etatPaiement = $this->getServiceMiseEnPaiement()->getEtatPaiement( $recherche );
}
return compact( 'rechercheForm', 'etatPaiement', 'etat' );
}
/**
* @return \Application\Form\Paiement\MiseEnPaiementRechercheForm
*/
protected function getFormMiseEnPaiementRecherche()
{
return $this->getServiceLocator()->get('FormElementManager')->get('PaiementMiseEnPaiementRechercheForm');
}
/**
* @return \Application\Service\Intervenant
*/
protected function getServiceIntervenant()
{
return $this->getServiceLocator()->get('applicationIntervenant');
}
/**
* @return \Application\Service\Periode
*/
protected function getServicePeriode()
{
return $this->getServiceLocator()->get('applicationPeriode');
}
/**
* @return \Application\Service\Structure
*/
protected function getServiceStructure()
{
return $this->getServiceLocator()->get('applicationStructure');
}
/**
* @return \Application\Service\MiseEnPaiement
*/
......
......@@ -84,6 +84,18 @@ class CentreCout implements HistoriqueAwareInterface
*/
private $typeHeures;
/**
*
* @var \Doctrine\Common\Collections\Collection
*/
private $miseEnPaiement;
public function __construct()
{
$this->typeHeures = new \Doctrine\Common\Collections\ArrayCollection();
$this->miseEnPaiement = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Set histoCreation
......@@ -423,4 +435,37 @@ class CentreCout implements HistoriqueAwareInterface
{
return $this->getActivite()->typeHeuresMatches($typeHeures) && $this->getTypeRessource()->typeHeuresMatches($typeHeures);
}
/**
* Add miseEnPaiement
*
* @param MiseEnPaiement $miseEnPaiement
* @return self
*/
public function addMiseEnPaiement(MiseEnPaiement $miseEnPaiement)
{
$this->miseEnPaiement[] = $miseEnPaiement;
return $this;
}
/**
* Remove miseEnPaiement
*
* @param MiseEnPaiement $miseEnPaiement
*/
public function removeMiseEnPaiement(MiseEnPaiement $miseEnPaiement)
{
$this->miseEnPaiement->removeElement($miseEnPaiement);
}
/**
* Get miseEnPaiement
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getMiseEnPaiement()
{
return $this->miseEnPaiement;
}
}
......@@ -288,20 +288,28 @@ abstract class Intervenant implements IntervenantInterface, HistoriqueAwareInter
* @var \Application\Entity\Db\VIndicDiffDossier
*/
private $vIndicDiffDossier;
/**
* miseEnPaiementIntervenantStructure
*
* @var MiseEnPaiementIntervenantStructure
*/
protected $miseEnPaiementIntervenantStructure;
/**
* Constructor
*/
public function __construct()
{
$this->affectation = new \Doctrine\Common\Collections\ArrayCollection();
$this->adresse = new \Doctrine\Common\Collections\ArrayCollection();
$this->validation = new \Doctrine\Common\Collections\ArrayCollection();
$this->agrement = new \Doctrine\Common\Collections\ArrayCollection();
$this->service = new \Doctrine\Common\Collections\ArrayCollection();
$this->serviceReferentiel = new \Doctrine\Common\Collections\ArrayCollection();
$this->formuleResultat = new \Doctrine\Common\Collections\ArrayCollection();
$this->formuleIntervenant = new \Doctrine\Common\Collections\ArrayCollection();
$this->affectation = new \Doctrine\Common\Collections\ArrayCollection();
$this->adresse = new \Doctrine\Common\Collections\ArrayCollection();
$this->validation = new \Doctrine\Common\Collections\ArrayCollection();
$this->agrement = new \Doctrine\Common\Collections\ArrayCollection();
$this->service = new \Doctrine\Common\Collections\ArrayCollection();
$this->serviceReferentiel = new \Doctrine\Common\Collections\ArrayCollection();
$this->formuleResultat = new \Doctrine\Common\Collections\ArrayCollection();
$this->formuleIntervenant = new \Doctrine\Common\Collections\ArrayCollection();
$this->miseEnPaiementIntervenantStructure = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
......@@ -1614,6 +1622,17 @@ abstract class Intervenant implements IntervenantInterface, HistoriqueAwareInter
}
/**
* Get miseEnPaiementIntervenantStructure
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getMiseEnPaiementIntervenantStructure()
{
return $this->miseEnPaiementIntervenantStructure;
}
/**
* Returns the string identifier of the Resource
*
......
......@@ -68,5 +68,6 @@
</inverse-join-columns>
</join-table>
</many-to-many>
<one-to-many field="miseEnPaiement" target-entity="Application\Entity\Db\MiseEnPaiement" mapped-by="centreCout" />
</entity>
</doctrine-mapping>
......@@ -110,5 +110,6 @@
<one-to-many field="formuleResultat" target-entity="Application\Entity\Db\FormuleResultat" mapped-by="intervenant" />
<one-to-many field="wfIntervenantEtape" target-entity="Application\Entity\Db\WfIntervenantEtape" mapped-by="intervenant" />
<one-to-one field="vIndicDiffDossier" target-entity="Application\Entity\Db\VIndicDiffDossier" mapped-by="intervenant" />
<one-to-many field="miseEnPaiementIntervenantStructure" target-entity="Application\Entity\Db\MiseEnPaiementIntervenantStructure" mapped-by="intervenant" />
</entity>
</doctrine-mapping>
......@@ -64,5 +64,6 @@
<join-column name="FORMULE_RES_SERVICE_REF_ID" referenced-column-name="ID"/>
</join-columns>
</many-to-one>
<one-to-many field="miseEnPaiementIntervenantStructure" target-entity="Application\Entity\Db\MiseEnPaiementIntervenantStructure" mapped-by="miseEnPaiement" />
</entity>
</doctrine-mapping>
<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="Application\Entity\Db\MiseEnPaiementIntervenantStructure" table="V_MEP_INTERVENANT_STRUCTURE" read-only="true">
<id name="id" type="integer" column="ID"></id>
<many-to-one field="miseEnPaiement" target-entity="Application\Entity\Db\MiseEnPaiement">
<join-columns>
<join-column name="MISE_EN_PAIEMENT_ID" referenced-column-name="ID"/>
</join-columns>
</many-to-one>
<many-to-one field="intervenant" target-entity="Application\Entity\Db\Intervenant">
<join-columns>
<join-column name="INTERVENANT_ID" referenced-column-name="ID"/>
</join-columns>
</many-to-one>
<many-to-one field="structure" target-entity="Application\Entity\Db\Structure">
<join-columns>
<join-column name="STRUCTURE_ID" referenced-column-name="ID"/>
</join-columns>
</many-to-one>
<many-to-one field="periode" target-entity="Application\Entity\Db\Periode">
<join-columns>
<join-column name="PERIODE_PAIEMENT_ID" referenced-column-name="ID"/>
</join-columns>
</many-to-one>
</entity>
</doctrine-mapping>
\ No newline at end of file
......@@ -34,5 +34,6 @@
<join-column name="HISTO_CREATEUR_ID" referenced-column-name="ID"/>
</join-columns>
</many-to-one>
<one-to-many field="miseEnPaiementIntervenantStructure" target-entity="Application\Entity\Db\MiseEnPaiementIntervenantStructure" mapped-by="periode" />
</entity>
</doctrine-mapping>
......@@ -70,5 +70,6 @@
<one-to-many field="service" target-entity="Application\Entity\Db\Service" mapped-by="structureEns" />
<one-to-many field="elementPedagogique" target-entity="Application\Entity\Db\ElementPedagogique" mapped-by="structure" />
<one-to-many field="centreCout" target-entity="Application\Entity\Db\CentreCout" mapped-by="structure" />
<one-to-many field="miseEnPaiementIntervenantStructure" target-entity="Application\Entity\Db\MiseEnPaiementIntervenantStructure" mapped-by="structure" />
</entity>
</doctrine-mapping>
......@@ -9,6 +9,10 @@ use Zend\Permissions\Acl\Resource\ResourceInterface;
*/
class MiseEnPaiement implements HistoriqueAwareInterface, ResourceInterface
{
const A_VALIDER = 'a-valider';
const A_METTRE_EN_PAIEMENT = 'a-mettre-en-paiement';
const MIS_EN_PAIEMENT = 'mis-en-paiement';
/**
* @var \DateTime
*/
......@@ -89,6 +93,18 @@ class MiseEnPaiement implements HistoriqueAwareInterface, ResourceInterface
*/
private $formuleResultatServiceReferentiel;
/**
* miseEnPaiementIntervenantStructure
*
* @var MiseEnPaiementIntervenantStructure
*/
protected $miseEnPaiementIntervenantStructure;
public function __construct()
{
$this->miseEnPaiementIntervenantStructure = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Set dateMiseEnPaiement
......@@ -476,6 +492,27 @@ class MiseEnPaiement implements HistoriqueAwareInterface, ResourceInterface
return $this->formuleResultatServiceReferentiel;
}
/**
* Get miseEnPaiementIntervenantStructure
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getMiseEnPaiementIntervenantStructure()
{
return $this->miseEnPaiementIntervenantStructure;
}
/**
*
* @return string
*/
public function getEtat()
{
if (! $this->getValidation()) return self::A_VALIDER;
if (! $this->getDateMiseEnPaiement()) return self::A_METTRE_EN_PAIEMENT;
return self::MIS_EN_PAIEMENT;
}
/**
* Returns the string identifier of the Resource
*
......
<?php
namespace Application\Entity\Db;
use Doctrine\ORM\Mapping as ORM;
/**
* MiseEnPaiementIntervenantStructure
*/
class MiseEnPaiementIntervenantStructure
{
/**