Commit 7379196a authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Prise en compte des heures de mission (WIP)

parent 5516ff51
Loading
Loading
Loading
Loading
+46 −35
Original line number Diff line number Diff line
@@ -2,6 +2,8 @@

namespace Application\Entity\Db;

use Doctrine\Common\Collections\ArrayCollection;
use Enseignement\Entity\Db\Service;
use Laminas\Permissions\Acl\Resource\ResourceInterface;
use OffreFormation\Entity\Db\CentreCoutEp;
use OffreFormation\Entity\Db\TypeHeures;
@@ -9,29 +11,32 @@ use OffreFormation\Service\DomaineFonctionnelService;
use Paiement\Entity\Db\CentreCout;
use Paiement\Entity\Db\ServiceAPayerInterface;
use Paiement\Entity\Db\ServiceAPayerTrait;
use Service\Entity\Db\EtatVolumeHoraire;
use Service\Entity\Db\TypeVolumeHoraire;

/**
 * FormuleResultatService
 * @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr>
 */
class FormuleResultatService implements ServiceAPayerInterface, ResourceInterface
{
    use FormuleResultatTypesHeuresTrait;
    use ServiceAPayerTrait;

    /**
     * @var \Enseignement\Entity\Db\Service
     */
    private $service;
    private FormuleResultat $formuleResultat;

    private Service $service;


    /**
     *
     * @param TypeHeures $typeHeures
     *
     * @return CentreCout|null
     */
    public function getDefaultCentreCout(TypeHeures $typeHeures)

    public function __construct()
    {
        $this->miseEnPaiement = new ArrayCollection();
        $this->centreCout = new ArrayCollection();
    }



    public function getDefaultCentreCout(TypeHeures $typeHeures): ?CentreCout
    {
        $element = $this->getService()->getElementPedagogique();
        if (!$element) return null;
@@ -47,11 +52,7 @@ class FormuleResultatService implements ServiceAPayerInterface, ResourceInterfac



    /**
     *
     * @return DomaineFonctionnel|null
     */
    public function getDefaultDomaineFonctionnel(DomaineFonctionnelService $serviceDomaineFonctionnel = null)
    public function getDefaultDomaineFonctionnel(DomaineFonctionnelService $serviceDomaineFonctionnel = null): ?DomaineFonctionnel
    {
        $element = $this->getService()->getElementPedagogique();
        if (!$element) {
@@ -67,32 +68,21 @@ class FormuleResultatService implements ServiceAPayerInterface, ResourceInterfac



    /**
     * @return boolean
     */
    public function isDomaineFonctionnelModifiable()
    public function isDomaineFonctionnelModifiable(): bool
    {
        return $this->getService()->getElementPedagogique() === null;
    }



    /**
     * Get Service
     *
     * @return \Enseignement\Entity\Db\Service
     */
    public function getService()
    public function getService(): Service
    {
        return $this->service;
    }



    /**
     * @return Structure
     */
    public function getStructure()
    public function getStructure(): ?Structure
    {
        $service = $this->getService();
        if ($service->getElementPedagogique()) {
@@ -104,16 +94,37 @@ class FormuleResultatService implements ServiceAPayerInterface, ResourceInterfac



    /**
     * @return Intervenant
     */
    public function getIntervenant()
    public function getIntervenant(): ?Intervenant
    {
        return $this->getService()->getIntervenant();
    }



    public function getFormuleResultat(): FormuleResultat
    {
        return $this->formuleResultat;
    }



    public function isPayable(): bool
    {
        $fr = $this->getFormuleResultat();

        return $fr->getTypeVolumeHoraire()->getCode() === TypeVolumeHoraire::CODE_REALISE
            && $fr->getEtatVolumeHoraire()->getCode() === EtatVolumeHoraire::CODE_VALIDE;
    }



    public function getHeuresMission(): float
    {
        return 0;
    }



    public function getResourceId()
    {
        return 'FormuleResultatService';
+46 −35
Original line number Diff line number Diff line
@@ -2,93 +2,104 @@

namespace Application\Entity\Db;

use Doctrine\Common\Collections\ArrayCollection;
use Laminas\Permissions\Acl\Resource\ResourceInterface;
use OffreFormation\Entity\Db\TypeHeures;
use Paiement\Entity\Db\CentreCout;
use Paiement\Entity\Db\ServiceAPayerInterface;
use Paiement\Entity\Db\ServiceAPayerTrait;
use Referentiel\Entity\Db\ServiceReferentiel;
use Service\Entity\Db\EtatVolumeHoraire;
use Service\Entity\Db\TypeVolumeHoraire;

/**
 * FormuleResultatServiceReferentiel
 * @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr>
 */
class FormuleResultatServiceReferentiel implements ServiceAPayerInterface, ResourceInterface
{
    use FormuleResultatTypesHeuresTrait;
    use ServiceAPayerTrait;

    /**
     * @var \Referentiel\Entity\Db\ServiceReferentiel
     */
    private $serviceReferentiel;
    private FormuleResultat $formuleResultat;

    private ServiceReferentiel $serviceReferentiel;


    /**
     *
     * @param TypeHeures $typeHeures
     *
     * @return CentreCout|null
     */
    public function getDefaultCentreCout(TypeHeures $typeHeures)

    public function __construct()
    {
        $this->miseEnPaiement = new ArrayCollection();
        $this->centreCout = new ArrayCollection();
    }



    public function getDefaultCentreCout(TypeHeures $typeHeures): ?CentreCout
    {
        return null; // pas encore de centre de cout par défaut
    }



    /**
     *
     * @return DomaineFonctionnel|null
     */
    public function getDefaultDomaineFonctionnel()
    public function getDefaultDomaineFonctionnel(): ?DomaineFonctionnel
    {
        return $this->getServiceReferentiel()->getFonctionReferentiel()->getDomaineFonctionnel();
    }



    /**
     * @return boolean
     */
    public function isDomaineFonctionnelModifiable()
    public function isDomaineFonctionnelModifiable(): bool
    {
        return true;
    }



    /**
     * Get ServiceReferentiel
     *
     * @return \Referentiel\Entity\Db\ServiceReferentiel
     */
    public function getServiceReferentiel()
    public function getServiceReferentiel(): ServiceReferentiel
    {
        return $this->serviceReferentiel;
    }



    /**
     * @return Structure
     */
    public function getStructure()
    public function getStructure(): ?Structure
    {
        return $this->getServiceReferentiel()->getStructure();
    }



    /**
     * @return Intervenant
     */
    public function getIntervenant()
    public function getIntervenant(): ?Intervenant
    {
        return $this->getServiceReferentiel()->getIntervenant();
    }



    public function getFormuleResultat(): FormuleResultat
    {
        return $this->formuleResultat;
    }



    public function getHeuresMission(): float
    {
        return 0;
    }



    public function isPayable(): bool
    {
        $fr = $this->getFormuleResultat();

        return $fr->getTypeVolumeHoraire()->getCode() === TypeVolumeHoraire::CODE_REALISE
            && $fr->getEtatVolumeHoraire()->getCode() === EtatVolumeHoraire::CODE_VALIDE;
    }



    public function getResourceId()
    {
        return 'FormuleResultatServiceReferentiel';
+34 −129
Original line number Diff line number Diff line
@@ -6,187 +6,99 @@ use OffreFormation\Entity\Db\TypeHeures;

trait FormuleResultatTypesHeuresTrait
{
    /**
     * @var float
     */
    private $heuresServiceFi = 0.0;

    /**
     * @var float
     */
    private $heuresServiceFa = 0.0;

    /**
     * @var float
     */
    private $heuresServiceFc = 0.0;

    /**
     * @var float
     */
    private $heuresServiceReferentiel = 0.0;

    /**
     * @var float
     */
    private $heuresComplFi = 0.0;

    /**
     * @var float
     */
    private $heuresComplFa = 0.0;

    /**
     * @var float
     */
    private $heuresComplFc = 0.0;

    /**
     * @var float
     */
    private $heuresComplFcMajorees = 0.0;

    /**
     * @var float
     */
    private $heuresComplReferentiel = 0.0;

    /**
     *
     * @var float
     */
    private $total = 0.0;



    /**
     * Get heuresServiceFi
     *
     * @return float
     */
    public function getHeuresServiceFi()
    private float $heuresServiceFi = 0.0;

    private float $heuresServiceFa = 0.0;

    private float $heuresServiceFc = 0.0;

    private float $heuresServiceReferentiel = 0.0;

    private float $heuresComplFi = 0.0;

    private float $heuresComplFa = 0.0;

    private float $heuresComplFc = 0.0;

    private float $heuresComplFcMajorees = 0.0;

    private float $heuresComplReferentiel = 0.0;

    private float $total = 0.0;



    public function getHeuresServiceFi(): float
    {
        return $this->heuresServiceFi;
    }



    /**
     * Get heuresServiceFa
     *
     * @return float
     */
    public function getHeuresServiceFa()
    public function getHeuresServiceFa(): float
    {
        return $this->heuresServiceFa;
    }



    /**
     * Get heuresServiceFc
     *
     * @return float
     */
    public function getHeuresServiceFc()
    public function getHeuresServiceFc(): float
    {
        return $this->heuresServiceFc;
    }



    /**
     * Get heuresServiceReferentiel
     *
     * @return float
     */
    public function getHeuresServiceReferentiel()
    public function getHeuresServiceReferentiel(): float
    {
        return $this->heuresServiceReferentiel;
    }



    /**
     * Get heuresComplFi
     *
     * @return float
     */
    public function getHeuresComplFi()
    public function getHeuresComplFi(): float
    {
        return $this->heuresComplFi;
    }



    /**
     * Get heuresComplFa
     *
     * @return float
     */
    public function getHeuresComplFa()
    public function getHeuresComplFa(): float
    {
        return $this->heuresComplFa;
    }



    /**
     * Get heuresComplFc
     *
     * @return float
     */
    public function getHeuresComplFc()
    public function getHeuresComplFc(): float
    {
        return $this->heuresComplFc;
    }



    /**
     * Get heuresComplFcMajorees
     *
     * @return float
     */
    public function getHeuresComplFcMajorees()
    public function getHeuresComplFcMajorees(): float
    {
        return $this->heuresComplFcMajorees;
    }



    /**
     * Get heuresComplReferentiel
     *
     * @return float
     */
    public function getHeuresComplReferentiel()
    public function getHeuresComplReferentiel(): float
    {
        return $this->heuresComplReferentiel;
    }



    /**
     * Get total
     *
     * @return float
     */
    public function getTotal()
    public function getTotal(): float
    {
        return $this->total;
    }



    /**
     *
     * @param TypeHeures|null $typeHeures
     *
     * @return float
     * @throws \RuntimeException
     */
    public function getHeuresService(TypeHeures $typeHeures = null)
    public function getHeuresService(TypeHeures $typeHeures = null): float
    {
        if (null === $typeHeures) {
            return $this->getHeuresServiceFi()
@@ -210,14 +122,7 @@ trait FormuleResultatTypesHeuresTrait



    /**
     *
     * @param TypeHeures $typeHeures
     *
     * @return float
     * @throws \RuntimeException
     */
    public function getHeuresCompl(TypeHeures $typeHeures)
    public function getHeuresCompl(TypeHeures $typeHeures): float
    {
        switch ($typeHeures->getCode()) {
            case TypeHeures::FI:
+1 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
        <field name="heuresFormation" type="float" column="HEURES_FORMATION" precision="126" scale="0" nullable="true"/>
        <field name="description" type="string" column="DESCRIPTION" length="4000" nullable="true"/>
        <field name="etudiantsSuivis" type="string" column="ETUDIANTS_SUIVIS" length="4000" nullable="true"/>
        <one-to-many field="miseEnPaiement" target-entity="Paiement\Entity\Db\MiseEnPaiement" mapped-by="mission" />

        <many-to-many field="etudiants" target-entity="Application\Entity\Db\Intervenant">
            <join-table name="MISSION_ETUDIANT">
+98 −12
Original line number Diff line number Diff line
@@ -3,13 +3,21 @@
namespace Mission\Entity\Db;

use Application\Constants;
use Application\Entity\Db\DomaineFonctionnel;
use Application\Entity\Db\Intervenant;
use Application\Entity\Db\Periode;
use Application\Entity\Db\Traits\IntervenantAwareTrait;
use Application\Entity\Db\Traits\StructureAwareTrait;
use Application\Entity\Db\Validation;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Laminas\Permissions\Acl\Resource\ResourceInterface;
use OffreFormation\Entity\Db\TypeHeures;
use Paiement\Entity\Db\CentreCout;
use Paiement\Entity\Db\MiseEnPaiement;
use Paiement\Entity\Db\MiseEnPaiementListe;
use Paiement\Entity\Db\ServiceAPayerInterface;
use Paiement\Entity\Db\ServiceAPayerTrait;
use Paiement\Entity\Db\TauxRemu;
use Plafond\Interfaces\PlafondDataInterface;
use Service\Entity\Db\TypeVolumeHoraire;
@@ -18,14 +26,13 @@ use UnicaenApp\Entity\HistoriqueAwareTrait;
use UnicaenApp\Service\EntityManagerAwareInterface;
use UnicaenApp\Service\EntityManagerAwareTrait;

class Mission implements HistoriqueAwareInterface, ResourceInterface, EntityManagerAwareInterface, PlafondDataInterface
class Mission implements HistoriqueAwareInterface, ResourceInterface, EntityManagerAwareInterface, PlafondDataInterface, ServiceAPayerInterface
{
    use HistoriqueAwareTrait;
    use IntervenantAwareTrait;
    use StructureAwareTrait;
    use EntityManagerAwareTrait;

    protected ?int $id = null;
    use ServiceAPayerTrait;

    protected ?TypeMission $typeMission = null;

@@ -58,6 +65,8 @@ class Mission implements HistoriqueAwareInterface, ResourceInterface, EntityMana
        $this->etudiants = new ArrayCollection();
        $this->validations = new ArrayCollection();
        $this->volumesHoraires = new ArrayCollection();
        $this->miseEnPaiement = new ArrayCollection();
        $this->centreCout = new ArrayCollection();
    }


@@ -76,13 +85,6 @@ class Mission implements HistoriqueAwareInterface, ResourceInterface, EntityMana



    public function getId(): ?int
    {
        return $this->id;
    }



    public function getTypeMission(): ?TypeMission
    {
        return $this->typeMission;
@@ -210,7 +212,6 @@ class Mission implements HistoriqueAwareInterface, ResourceInterface, EntityMana




    public function isAutoValidation(): bool
    {
        return $this->autoValidation;
@@ -467,7 +468,7 @@ class Mission implements HistoriqueAwareInterface, ResourceInterface, EntityMana



    public function heuresRealisees(): float
    public function heuresRealisees(?bool $validees = null): float
    {
        $vhs = $this->getVolumesHorairesRealises();

@@ -475,8 +476,15 @@ class Mission implements HistoriqueAwareInterface, ResourceInterface, EntityMana

        foreach ($vhs as $vh) {
            if ($vh->estNonHistorise()) {
                if ($validees === true) {
                    if ($vh->isValide()) {
                        $heures += $vh->getHeures();
                    }
                } else {
                    $heures += $vh->getHeures();
                }

            }
        }

        return $heures;
@@ -525,4 +533,82 @@ class Mission implements HistoriqueAwareInterface, ResourceInterface, EntityMana

        return $this->isValide() && $dateOk;
    }



    public function getHeuresComplFi(): float
    {
        return 0;
    }



    public function getHeuresComplFc(): float
    {
        return 0;
    }



    public function getHeuresComplFcMajorees(): float
    {
        return 0;
    }



    public function getHeuresComplFa(): float
    {
        return 0;
    }



    public function getHeuresComplReferentiel(): float
    {
        return 0;
    }



    public function getHeuresCompl(TypeHeures $typeHeures): float
    {
        return $this->heuresRealisees(true);
    }



    public function getHeuresMission(): float
    {
        return $this->heuresRealisees(true);
    }



    public function getDefaultCentreCout(TypeHeures $typeHeures): ?CentreCout
    {
        return null;
    }



    public function getDefaultDomaineFonctionnel(): ?DomaineFonctionnel
    {
        return null;
    }



    public function isDomaineFonctionnelModifiable(): bool
    {
        return true;
    }



    public function isPayable(): bool
    {
        return $this->isValide();
    }

}
Loading