Commit ab0b5de6 authored by Florian Joriot's avatar Florian Joriot
Browse files

Ajout de autreLibelles, totalHeures et TotalHeurePriodeEssai

Todo : reflechir si pour les missions il faut afficher dans autreLibelles "Mission (Type Mission)"
parent 1e4ce27a
Loading
Loading
Loading
Loading
Loading
+41
Changes for module/Contrat/src/Tbl/Process/ContratProcess.php: 41 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -292,8 +292,10 @@ class ContratProcess implements ProcessInterface
        foreach ($contrats as $contrat) {
            $this->calculTauxRemu($contrat);
            $this->calculTotalHETD($contrat);
            $this->calculTotalHeures($contrat);
            $this->calculTermine($contrat);
            $this->calculTauxCongesPayes($contrat);
            $this->calculAutreLibelles($contrat);
            $this->calculActif($contrat);
        }

@@ -693,6 +695,45 @@ class ContratProcess implements ProcessInterface



    public function calculAutreLibelles(Contrat $contrat): string
    {
        $libelles = [];

        foreach ($contrat->volumesHoraires as $vh) {
            if (!empty($vh->autreLibelle)) {
                // Todo : reflechir si pour les missions il faut afficher dans autreLibelles "Mission (Type Mission)"
                $libelles[$vh->autreLibelle] = $vh->autreLibelle;
            }
        }

        sort($libelles); // Tri alphabétique

        $result                 = implode(', ', $libelles);
        $contrat->autreLibelles = $result;
        return $result;
    }



    public function calculTotalHeures(Contrat $contrat): void
    {
        $totalHeures = 0;


        //On ajoute les heures du contrat pour lequel on cherche
        foreach ($contrat->volumesHoraires as $vh) {
            $totalHeures += $vh->heures;
        }

        $contrat->totalHeures = $totalHeures;
        if ($contrat->parent == null) {
            //total d'heure du contrat divisé par 10, n'est valable que sur les contrats et pas les avenants
            $contrat->totalHeuresPeriodeEssai = $totalHeures / 10;
        }
    }



    /**
     * @param array|Contrat[] $contrats
     */
+3 −1
Changes for module/Contrat/src/Tbl/Process/Model/Contrat.php: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -65,10 +65,12 @@ class Contrat
    public float $tauxRemuMajoreValeur = 0.0;

    public float $tauxCongesPayes = 1.0;

    public ?string $autreLibelles = null;

    /** @var VolumeHoraire[] */
    public array     $volumesHoraires = [];
    public float     $totalHeures = 0.0;
    public ?float $totalHeuresPeriodeEssai = null;