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

Correction probleme d'heure total affiché dans le contrat

parent 138a392c
Loading
Loading
Loading
Loading
+6 −1
Changes for module/Contrat/src/Controller/ContratController.php: 6 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -176,8 +176,13 @@ class ContratController extends AbstractController
        }

        $volumeHorairesTotal = $this->getServiceTblContrat()->getVolumeTotalCreationContratByUuid($uuid);
        if($volumeHorairesTotal['contratParentId'] != null){
            $totalContratHetd = $this->getServiceTblContrat()->getTotalHetdIntervenant($uuid, $volumeHorairesTotal['contratParentId']);
        }else{
            $totalContratHetd = $volumeHorairesTotal['hetdTotal'];
        }

        $contrat = $this->getProcessusContrat()->creer($intervenant, $volumeHorairesTotal);
        $contrat = $this->getProcessusContrat()->creer($intervenant, $volumeHorairesTotal, $totalContratHetd);


        if (!$this->isAllowed($contrat, Privileges::CONTRAT_CREATION)) {
+2 −2
Changes for module/Contrat/src/Processus/ContratProcessus.php: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -131,7 +131,7 @@ class ContratProcessus extends AbstractProcessus
     *
     * @return Contrat
     */
    public function creer(Intervenant $intervenant, $volumeHoraire): Contrat
    public function creer(Intervenant $intervenant, $volumeHoraire, float $totalHetd): Contrat
    {
        $contrat = $this->getServiceContrat()->newEntity();
        /* @var $contrat Contrat */
@@ -141,7 +141,7 @@ class ContratProcessus extends AbstractProcessus
        $structure = $this->getServiceStructure()->get($volumeHoraire['structureId']);
        $contrat->setStructure($structure);

        $contrat->setTotalHetd($volumeHoraire['hetdTotal']);
        $contrat->setTotalHetd($totalHetd);
        try {
            $dateDebut = new \DateTime($volumeHoraire['dateDebut']);

+21 −0
Changes for module/Contrat/src/Service/TblContratService.php: 21 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -92,6 +92,27 @@ class TblContratService extends AbstractEntityService



    public function getTotalHetdIntervenant(string $uuid, ?string $contratParentId): ?array
    {
        $em = $this->getEntityManager();

        $sql = 'SELECT SUM(hetd) as hetdTotal
                FROM tbl_contrat tblc_all 
                WHERE (tblc_all.contrat_id = :contratParentId 
                OR tblc_all.contrat_parent_id = :contratParentId)
                AND (tblc_all.contrat_id IS NOT NULL OR tblc_all.uuid = :uuid)';


        $query = $em->createQuery($sql)
            ->setParameter('uuid', $uuid);

        $result = $query->getOneOrNullResult();
        return $result['hetdTotal'];

    }



    public function getStructureContractualise(Intervenant $intervenant)
    {
        $em = $this->getEntityManager();