Commit 025506df authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

wip tbl contrat extractContratVolumeHoraire

nouveau service pour les types de contrats
parent 11447a2b
Loading
Loading
Loading
Loading
Loading
+60 −3
Changes for module/Contrat/src/Tbl/Process/ContratProcess.php: 60 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -6,9 +6,11 @@ namespace Contrat\Tbl\Process;
use Application\Entity\Db\Parametre;
use Application\Service\Traits\AnneeServiceAwareTrait;
use Application\Service\Traits\ParametresServiceAwareTrait;
use Contrat\Service\TypeContratServiceAwareTrait;
use Contrat\Tbl\Process\Model\Contrat;
use Contrat\Tbl\Process\Model\VolumeHoraire;
use Paiement\Service\TauxRemuServiceAwareTrait;
use Service\Service\TypeServiceServiceAwareTrait;
use Unicaen\BddAdmin\BddAwareTrait;
use UnicaenTbl\Process\ProcessInterface;
use UnicaenTbl\Service\BddServiceAwareTrait;
@@ -21,6 +23,8 @@ class ContratProcess implements ProcessInterface
    use AnneeServiceAwareTrait;
    use ParametresServiceAwareTrait;
    use TauxRemuServiceAwareTrait;
    use TypeContratServiceAwareTrait;
    use TypeServiceServiceAwareTrait;

    private string $parametreAvenant;

@@ -579,9 +583,61 @@ class ContratProcess implements ProcessInterface

    public function extractContratVolumeHoraire(int $intervenantId, Contrat $contrat, VolumeHoraire $vh): array
    {
        $data = [];
        // récup des types de contrats
        if (empty($contrat->parent)) {
            $typeContrat = $this->getServiceTypeContrat()->getContrat();
        } else {
            $typeContrat = $this->getServiceTypeContrat()->getAvenant();
        }

        /* TODO process data */
        // récup du type de service
        if ($vh->serviceId) {
            $typeService = $this->getServiceTypeService()->getEnseignement();
        } elseif ($vh->serviceReferentielId) {
            $typeService = $this->getServiceTypeService()->getReferentiel();
        } elseif ($vh->missionId) {
            $typeService = $this->getServiceTypeService()->getMission();
        } else {
            throw new \Exception('Impossible de déterminer le type de service pour ce volume horaire de contrat');
        }

        $data = [
            'annee_id'                  => null,
            'intervenant_id'            => $intervenantId,
            'actif'                     => $contrat->actif,
            'structure_id'              => $contrat->structureId,
            'edite'                     => $contrat->edite,
            'signe'                     => $contrat->signe,
            'autre_libelle'             => $vh->autreLibelle,
            'autres'                    => $vh->autres,
            'cm'                        => $vh->cm,
            'contrat_id'                => $contrat->id,
            'contrat_parent_id'         => $contrat->parent?->id,
            'date_creation'             => $contrat->histoCreation?->format('Y-m-d'),
            'date_debut'                => $contrat->debutValidite?->format('Y-m-d'),
            'date_fin'                  => $contrat->finValidite?->format('Y-m-d'),
            'hetd'                      => $vh->hetd,
            'heures'                    => $vh->heures,
            'mission_id'                => $vh->missionId,
            'service_id'                => $vh->serviceId,
            'service_referentiel_id'    => $vh->serviceReferentielId,
            'taux_conges_payes'         => null,
            'taux_remu_date'            => $contrat->tauxRemuDate?->format('Y-m-d'),
            'taux_remu_id'              => $contrat->tauxRemuId,
            'taux_remu_majore_date'     => null,
            'taux_remu_majore_id'       => $contrat->tauxRemuMajoreId,
            'taux_remu_majore_valeur'   => $contrat->tauxRemuMajoreValeur,
            'taux_remu_valeur'          => $contrat->tauxRemuValeur,
            'td'                        => $vh->td,
            'termine'                   => null,
            'tp'                        => $vh->tp,
            'type_contrat_id'           => $typeContrat->getId(),
            'type_service_id'           => $typeService->getId(),
            'uuid'                      => $contrat->uuid,
            'volume_horaire_id'         => $vh->volumeHoraireId,
            'volume_horaire_mission_id' => $vh->volumeHoraireMissionId,
            'volume_horaire_ref_id'     => $vh->volumeHoraireRefId,
        ];

        return $data;
    }
@@ -594,7 +650,8 @@ class ContratProcess implements ProcessInterface
        foreach ($this->intervenants as $intervenantId => $contrats) {
            foreach ($contrats as $uuid => $contrat) {
                foreach ($contrat->volumesHoraires as $volumeHoraire) {
                    $this->tblData[] = $this->extractContratVolumeHoraire($intervenantId, $contrat, $volumeHoraire);
                    $ligne           = $this->extractContratVolumeHoraire($intervenantId, $contrat, $volumeHoraire);
                    $this->tblData[] = array_change_key_case($ligne, CASE_UPPER);
                }
            }
        }
+2
Changes for module/Contrat/src/Tbl/Process/Model/Contrat.php: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -142,7 +142,9 @@ class Contrat

    public function setParent(Contrat $parent): void
    {
        if ($this->parent !== $parent) {
            $this->parent = $parent;
            $parent->avenants[] = $this;
        }
    }
}
 No newline at end of file
+1
Changes for module/Service/config/module.config.php: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -282,6 +282,7 @@ return [
    ],

    'services' => [
        Service\TypeServiceService::class              => Service\TypeServiceServiceFactory::class,
        Service\EtatVolumeHoraireService::class        => InvokableFactory::class,
        Service\TypeVolumeHoraireService::class        => InvokableFactory::class,
        Service\CampagneSaisieService::class           => InvokableFactory::class,
+x+80
Changes for module/Service/src/Service/TypeServiceService.php: 80 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Service\Service;


use Application\Service\AbstractEntityService;
use Service\Entity\Db\TypeService;

/**
 * Description of TypeServiceService
 *
 * @author Laurent Lécluse <laurent.lecluse at unicaen.fr>
 */
class TypeServiceService extends AbstractEntityService
{
    private array $cache = [];



    /**
     * Retourne la classe des entités
     *
     * @return string
     * @throws \RuntimeException
     */
    public function getEntityClass()
    {
        return TypeService::class;
    }



    /**
     * Retourne l'alias d'entité courante
     *
     * @return string
     */
    public function getAlias()
    {
        return 'tsrv';
    }



    public function getEnseignement()
    {
        return $this->getByCode(TypeService::CODE_ENSEIGNEMENT);
    }



    public function getReferentiel()
    {
        return $this->getByCode(TypeService::CODE_REFERENTIEL);
    }



    public function getMission()
    {
        return $this->getByCode(TypeService::CODE_MISSION);
    }



    /**
     *
     * @param string $code
     *
     * @return TypeService
     */
    public function getByCode($code)
    {
        if (!isset($this->cache[$code])) {
            $this->cache[$code] = $this->getRepo()->findOneBy(['code' => $code]);
        }

        return $this->cache[$code];
    }
}
 No newline at end of file
+x+39
Changes for module/Service/src/Service/TypeServiceServiceAwareTrait.php: 39 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Service\Service;


/**
 * Description of TypeServiceServiceAwareTrait
 *
 * @author UnicaenCode
 */
trait TypeServiceServiceAwareTrait
{
    protected ?TypeServiceService $serviceTypeService = null;



    /**
     * @param TypeServiceService $serviceTypeService
     *
     * @return self
     */
    public function setServiceTypeService(?TypeServiceService $serviceTypeService)
    {
        $this->serviceTypeService = $serviceTypeService;

        return $this;
    }



    public function getServiceTypeService(): ?TypeServiceService
    {
        if (empty($this->serviceTypeService)) {
            $this->serviceTypeService = \AppAdmin::container()->get(TypeServiceService::class);
        }

        return $this->serviceTypeService;
    }
}
 No newline at end of file
Loading