Loading module/Contrat/src/Tbl/Process/ContratProcess.php +79 −33 Changes for module/Contrat/src/Tbl/Process/ContratProcess.php: 79 added lines, 33 removed lines. Original line number Diff line number Diff line Loading @@ -6,10 +6,12 @@ namespace Contrat\Tbl\Process; use Application\Entity\Db\Parametre; use Application\Service\Traits\AnneeServiceAwareTrait; use Application\Service\Traits\ParametresServiceAwareTrait; use Contrat\Entity\Db\TypeContrat; use Contrat\Service\TypeContratServiceAwareTrait; use Contrat\Tbl\Process\Model\Contrat; use Contrat\Tbl\Process\Model\VolumeHoraire; use Paiement\Service\TauxRemuServiceAwareTrait; use Service\Entity\Db\TypeService; use Service\Service\TypeServiceServiceAwareTrait; use Unicaen\BddAdmin\BddAwareTrait; use UnicaenTbl\Process\ProcessInterface; Loading Loading @@ -102,23 +104,22 @@ class ContratProcess implements ProcessInterface $sql = $this->getServiceBdd()->injectKey($sql, $params); $parser = $this->getBdd()->selectEach($sql); while ($data = $parser->next()) { $this->loadContratsWhile($data); $data = array_change_key_case($data, CASE_LOWER); // provisoire => migration postgres $this->loadContrat($data); } } /** * @param array $data */ public function loadContratsWhile(array $data): void public function loadContrat(array $data): Contrat { $data = array_change_key_case($data, CASE_LOWER); $intervenantId = (int)$data['intervenant_id']; $contratId = (int)$data['contrat_id']; $uuid = $this->generateUUID($intervenantId, $contratId); $contrat = $this->getContrat($intervenantId, $uuid); $this->contratHydrateFromDb($contrat, $data); return $contrat; } Loading @@ -129,6 +130,7 @@ class ContratProcess implements ProcessInterface $contrat->anneeDateDebut = new \DateTime($data['annee_date_debut']); $contrat->id = (int)$data['contrat_id']; $contrat->intervenantId = (int)$data['intervenant_id']; $contrat->anneeId = (int)$data['annee_id']; $contrat->structureId = (int)$data['structure_id'] ?: null; $parentId = (int)$data['parent_id'] ?: null; if ($parentId) { Loading Loading @@ -168,25 +170,26 @@ class ContratProcess implements ProcessInterface $sql = $this->getServiceBdd()->injectKey($sql, $params); $parser = $this->getBdd()->selectEach($sql); while ($data = $parser->next()) { $this->loadVolumesHorairesWhile($data); $data = array_change_key_case($data, CASE_LOWER); // provisoire => migration postgres $this->loadVolumeHoraire($data); } } /** * @param array $data */ public function loadVolumesHorairesWhile(array $data): void public function loadVolumeHoraire(array $data): VolumeHoraire { $data = array_change_key_case($data, CASE_LOWER); $volumeHoraire = new VolumeHoraire(); $this->volumeHoraireHydrateFromDb($volumeHoraire, $data); $intervenantId = (int)$data['intervenant_id']; $contratId = (int)$data['contrat_id'] ?: null; $volumeHoraire = new VolumeHoraire(); $this->volumeHoraireHydrateFromDb($volumeHoraire, $data); $uuid = $this->generateUUID($intervenantId, $contratId, $volumeHoraire->structureId, $volumeHoraire->missionId); $this->getContrat($intervenantId, $uuid)->volumesHoraires[] = $volumeHoraire; $contrat = $this->getContrat($intervenantId, $uuid); $volumeHoraire->setContrat($contrat); return $volumeHoraire; } Loading Loading @@ -228,6 +231,8 @@ class ContratProcess implements ProcessInterface foreach ($contrats as $contrat) { $this->calculTauxRemu($contrat); $this->calculTotalHETD($contrat); $this->calculTermine($contrat); $this->calculTauxCongesPayes($contrat); } $this->calculNumerosAvenants($contrats); Loading Loading @@ -512,6 +517,29 @@ class ContratProcess implements ProcessInterface public function calculTermine(Contrat $contrat): void { switch ($this->parametreFranchissement) { case Parametre::CONTRAT_FRANCHI_VALIDATION: $contrat->termine = $contrat->edite; case Parametre::CONTRAT_FRANCHI_DATE_RETOUR: $contrat->termine = $contrat->edite && $contrat->retourne; } } public function calculTauxCongesPayes(Contrat $contrat): void { if ($contrat->isMission) { $contrat->tauxCongesPayes = $this->parametreTauxCongesPayes; } else { $contrat->tauxCongesPayes = 1.0; } } /** * @param array|Contrat[] $contrats */ Loading Loading @@ -581,28 +609,46 @@ class ContratProcess implements ProcessInterface public function extractContratVolumeHoraire(int $intervenantId, Contrat $contrat, VolumeHoraire $vh): array public function getTypeContrat(Contrat $contrat): TypeContrat { // récup des types de contrats if (empty($contrat->parent)) { $typeContrat = $this->getServiceTypeContrat()->getContrat(); return $this->getServiceTypeContrat()->getContrat(); } else { $typeContrat = $this->getServiceTypeContrat()->getAvenant(); return $this->getServiceTypeContrat()->getAvenant(); } } // récup du type de service public function getVolumeHoraireTypeService(VolumeHoraire $vh): TypeService { if ($vh->serviceId) { $typeService = $this->getServiceTypeService()->getEnseignement(); } elseif ($vh->serviceReferentielId) { $typeService = $this->getServiceTypeService()->getReferentiel(); } elseif ($vh->missionId) { $typeService = $this->getServiceTypeService()->getMission(); return $this->getServiceTypeService()->getEnseignement(); } if ($vh->serviceReferentielId) { return $this->getServiceTypeService()->getReferentiel(); } if ($vh->missionId) { return $this->getServiceTypeService()->getMission(); } // si on est sur des contrats sans volumes horaires => enseignement // si on est sur des avenants dans volumes horaires => mission if (empty($vh->contrat->parent)) { return $this->getServiceTypeService()->getEnseignement(); } else { throw new \Exception('Impossible de déterminer le type de service pour ce volume horaire de contrat'); return $this->getServiceTypeService()->getMission(); } } public function extractContratVolumeHoraire(int $intervenantId, Contrat $contrat, VolumeHoraire $vh): array { $data = [ 'annee_id' => null, 'annee_id' => $contrat->anneeId, 'intervenant_id' => $intervenantId, 'actif' => $contrat->actif, 'structure_id' => $contrat->structureId, Loading @@ -621,18 +667,18 @@ class ContratProcess implements ProcessInterface 'mission_id' => $vh->missionId, 'service_id' => $vh->serviceId, 'service_referentiel_id' => $vh->serviceReferentielId, 'taux_conges_payes' => null, 'taux_conges_payes' => $contrat->tauxCongesPayes, 'taux_remu_date' => $contrat->tauxRemuDate?->format('Y-m-d'), 'taux_remu_id' => $contrat->tauxRemuId, 'taux_remu_majore_date' => null, 'taux_remu_majore_date' => $contrat->tauxRemuDate?->format('Y-m-d'), 'taux_remu_majore_id' => $contrat->tauxRemuMajoreId, 'taux_remu_majore_valeur' => $contrat->tauxRemuMajoreValeur, 'taux_remu_valeur' => $contrat->tauxRemuValeur, 'td' => $vh->td, 'termine' => null, 'termine' => $contrat->termine, 'tp' => $vh->tp, 'type_contrat_id' => $typeContrat->getId(), 'type_service_id' => $typeService->getId(), 'type_contrat_id' => $this->getTypeContrat($contrat)->getId(), 'type_service_id' => $this->getVolumeHoraireTypeService($vh)->getId(), 'uuid' => $contrat->uuid, 'volume_horaire_id' => $vh->volumeHoraireId, 'volume_horaire_mission_id' => $vh->volumeHoraireMissionId, Loading module/Contrat/src/Tbl/Process/Model/Contrat.php +11 Changes for module/Contrat/src/Tbl/Process/Model/Contrat.php: 11 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -3,6 +3,8 @@ namespace Contrat\Tbl\Process\Model; use Service\Entity\Db\TypeService; class Contrat { public bool $actif = false; Loading @@ -11,6 +13,10 @@ class Contrat public ?int $id = null; public ?TypeService $typeService = null; public ?int $anneeId = null; public bool $isMission = false; public ?string $uuid = null; Loading @@ -21,6 +27,7 @@ class Contrat public ?Contrat $parent = null; /** @var Contrat[] */ public array $avenants = []; public int $numeroAvenant = 0; Loading @@ -39,6 +46,8 @@ class Contrat public bool $signe = false; public bool $termine = false; //public float $hetd = 0.0; public float $totalHetd = 0.0; Loading @@ -53,6 +62,8 @@ class Contrat public float $tauxRemuMajoreValeur = 0.0; public float $tauxCongesPayes = 1.0; /** @var VolumeHoraire[] */ public array $volumesHoraires = []; Loading module/Contrat/src/Tbl/Process/Model/VolumeHoraire.php +10 Changes for module/Contrat/src/Tbl/Process/Model/VolumeHoraire.php: 10 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -4,6 +4,8 @@ namespace Contrat\Tbl\Process\Model; class VolumeHoraire { public Contrat $contrat; public ?int $anneeId = null; public ?int $structureId = null; public ?int $serviceId = null; Loading @@ -22,4 +24,12 @@ class VolumeHoraire public float $heures = 0.0; public float $hetd = 0.0; public ?string $autreLibelle = null; public function setContrat(Contrat $contrat): void { $this->contrat = $contrat; $contrat->volumesHoraires[] = $this; } } No newline at end of file Loading
module/Contrat/src/Tbl/Process/ContratProcess.php +79 −33 Changes for module/Contrat/src/Tbl/Process/ContratProcess.php: 79 added lines, 33 removed lines. Original line number Diff line number Diff line Loading @@ -6,10 +6,12 @@ namespace Contrat\Tbl\Process; use Application\Entity\Db\Parametre; use Application\Service\Traits\AnneeServiceAwareTrait; use Application\Service\Traits\ParametresServiceAwareTrait; use Contrat\Entity\Db\TypeContrat; use Contrat\Service\TypeContratServiceAwareTrait; use Contrat\Tbl\Process\Model\Contrat; use Contrat\Tbl\Process\Model\VolumeHoraire; use Paiement\Service\TauxRemuServiceAwareTrait; use Service\Entity\Db\TypeService; use Service\Service\TypeServiceServiceAwareTrait; use Unicaen\BddAdmin\BddAwareTrait; use UnicaenTbl\Process\ProcessInterface; Loading Loading @@ -102,23 +104,22 @@ class ContratProcess implements ProcessInterface $sql = $this->getServiceBdd()->injectKey($sql, $params); $parser = $this->getBdd()->selectEach($sql); while ($data = $parser->next()) { $this->loadContratsWhile($data); $data = array_change_key_case($data, CASE_LOWER); // provisoire => migration postgres $this->loadContrat($data); } } /** * @param array $data */ public function loadContratsWhile(array $data): void public function loadContrat(array $data): Contrat { $data = array_change_key_case($data, CASE_LOWER); $intervenantId = (int)$data['intervenant_id']; $contratId = (int)$data['contrat_id']; $uuid = $this->generateUUID($intervenantId, $contratId); $contrat = $this->getContrat($intervenantId, $uuid); $this->contratHydrateFromDb($contrat, $data); return $contrat; } Loading @@ -129,6 +130,7 @@ class ContratProcess implements ProcessInterface $contrat->anneeDateDebut = new \DateTime($data['annee_date_debut']); $contrat->id = (int)$data['contrat_id']; $contrat->intervenantId = (int)$data['intervenant_id']; $contrat->anneeId = (int)$data['annee_id']; $contrat->structureId = (int)$data['structure_id'] ?: null; $parentId = (int)$data['parent_id'] ?: null; if ($parentId) { Loading Loading @@ -168,25 +170,26 @@ class ContratProcess implements ProcessInterface $sql = $this->getServiceBdd()->injectKey($sql, $params); $parser = $this->getBdd()->selectEach($sql); while ($data = $parser->next()) { $this->loadVolumesHorairesWhile($data); $data = array_change_key_case($data, CASE_LOWER); // provisoire => migration postgres $this->loadVolumeHoraire($data); } } /** * @param array $data */ public function loadVolumesHorairesWhile(array $data): void public function loadVolumeHoraire(array $data): VolumeHoraire { $data = array_change_key_case($data, CASE_LOWER); $volumeHoraire = new VolumeHoraire(); $this->volumeHoraireHydrateFromDb($volumeHoraire, $data); $intervenantId = (int)$data['intervenant_id']; $contratId = (int)$data['contrat_id'] ?: null; $volumeHoraire = new VolumeHoraire(); $this->volumeHoraireHydrateFromDb($volumeHoraire, $data); $uuid = $this->generateUUID($intervenantId, $contratId, $volumeHoraire->structureId, $volumeHoraire->missionId); $this->getContrat($intervenantId, $uuid)->volumesHoraires[] = $volumeHoraire; $contrat = $this->getContrat($intervenantId, $uuid); $volumeHoraire->setContrat($contrat); return $volumeHoraire; } Loading Loading @@ -228,6 +231,8 @@ class ContratProcess implements ProcessInterface foreach ($contrats as $contrat) { $this->calculTauxRemu($contrat); $this->calculTotalHETD($contrat); $this->calculTermine($contrat); $this->calculTauxCongesPayes($contrat); } $this->calculNumerosAvenants($contrats); Loading Loading @@ -512,6 +517,29 @@ class ContratProcess implements ProcessInterface public function calculTermine(Contrat $contrat): void { switch ($this->parametreFranchissement) { case Parametre::CONTRAT_FRANCHI_VALIDATION: $contrat->termine = $contrat->edite; case Parametre::CONTRAT_FRANCHI_DATE_RETOUR: $contrat->termine = $contrat->edite && $contrat->retourne; } } public function calculTauxCongesPayes(Contrat $contrat): void { if ($contrat->isMission) { $contrat->tauxCongesPayes = $this->parametreTauxCongesPayes; } else { $contrat->tauxCongesPayes = 1.0; } } /** * @param array|Contrat[] $contrats */ Loading Loading @@ -581,28 +609,46 @@ class ContratProcess implements ProcessInterface public function extractContratVolumeHoraire(int $intervenantId, Contrat $contrat, VolumeHoraire $vh): array public function getTypeContrat(Contrat $contrat): TypeContrat { // récup des types de contrats if (empty($contrat->parent)) { $typeContrat = $this->getServiceTypeContrat()->getContrat(); return $this->getServiceTypeContrat()->getContrat(); } else { $typeContrat = $this->getServiceTypeContrat()->getAvenant(); return $this->getServiceTypeContrat()->getAvenant(); } } // récup du type de service public function getVolumeHoraireTypeService(VolumeHoraire $vh): TypeService { if ($vh->serviceId) { $typeService = $this->getServiceTypeService()->getEnseignement(); } elseif ($vh->serviceReferentielId) { $typeService = $this->getServiceTypeService()->getReferentiel(); } elseif ($vh->missionId) { $typeService = $this->getServiceTypeService()->getMission(); return $this->getServiceTypeService()->getEnseignement(); } if ($vh->serviceReferentielId) { return $this->getServiceTypeService()->getReferentiel(); } if ($vh->missionId) { return $this->getServiceTypeService()->getMission(); } // si on est sur des contrats sans volumes horaires => enseignement // si on est sur des avenants dans volumes horaires => mission if (empty($vh->contrat->parent)) { return $this->getServiceTypeService()->getEnseignement(); } else { throw new \Exception('Impossible de déterminer le type de service pour ce volume horaire de contrat'); return $this->getServiceTypeService()->getMission(); } } public function extractContratVolumeHoraire(int $intervenantId, Contrat $contrat, VolumeHoraire $vh): array { $data = [ 'annee_id' => null, 'annee_id' => $contrat->anneeId, 'intervenant_id' => $intervenantId, 'actif' => $contrat->actif, 'structure_id' => $contrat->structureId, Loading @@ -621,18 +667,18 @@ class ContratProcess implements ProcessInterface 'mission_id' => $vh->missionId, 'service_id' => $vh->serviceId, 'service_referentiel_id' => $vh->serviceReferentielId, 'taux_conges_payes' => null, 'taux_conges_payes' => $contrat->tauxCongesPayes, 'taux_remu_date' => $contrat->tauxRemuDate?->format('Y-m-d'), 'taux_remu_id' => $contrat->tauxRemuId, 'taux_remu_majore_date' => null, 'taux_remu_majore_date' => $contrat->tauxRemuDate?->format('Y-m-d'), 'taux_remu_majore_id' => $contrat->tauxRemuMajoreId, 'taux_remu_majore_valeur' => $contrat->tauxRemuMajoreValeur, 'taux_remu_valeur' => $contrat->tauxRemuValeur, 'td' => $vh->td, 'termine' => null, 'termine' => $contrat->termine, 'tp' => $vh->tp, 'type_contrat_id' => $typeContrat->getId(), 'type_service_id' => $typeService->getId(), 'type_contrat_id' => $this->getTypeContrat($contrat)->getId(), 'type_service_id' => $this->getVolumeHoraireTypeService($vh)->getId(), 'uuid' => $contrat->uuid, 'volume_horaire_id' => $vh->volumeHoraireId, 'volume_horaire_mission_id' => $vh->volumeHoraireMissionId, Loading
module/Contrat/src/Tbl/Process/Model/Contrat.php +11 Changes for module/Contrat/src/Tbl/Process/Model/Contrat.php: 11 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -3,6 +3,8 @@ namespace Contrat\Tbl\Process\Model; use Service\Entity\Db\TypeService; class Contrat { public bool $actif = false; Loading @@ -11,6 +13,10 @@ class Contrat public ?int $id = null; public ?TypeService $typeService = null; public ?int $anneeId = null; public bool $isMission = false; public ?string $uuid = null; Loading @@ -21,6 +27,7 @@ class Contrat public ?Contrat $parent = null; /** @var Contrat[] */ public array $avenants = []; public int $numeroAvenant = 0; Loading @@ -39,6 +46,8 @@ class Contrat public bool $signe = false; public bool $termine = false; //public float $hetd = 0.0; public float $totalHetd = 0.0; Loading @@ -53,6 +62,8 @@ class Contrat public float $tauxRemuMajoreValeur = 0.0; public float $tauxCongesPayes = 1.0; /** @var VolumeHoraire[] */ public array $volumesHoraires = []; Loading
module/Contrat/src/Tbl/Process/Model/VolumeHoraire.php +10 Changes for module/Contrat/src/Tbl/Process/Model/VolumeHoraire.php: 10 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -4,6 +4,8 @@ namespace Contrat\Tbl\Process\Model; class VolumeHoraire { public Contrat $contrat; public ?int $anneeId = null; public ?int $structureId = null; public ?int $serviceId = null; Loading @@ -22,4 +24,12 @@ class VolumeHoraire public float $heures = 0.0; public float $hetd = 0.0; public ?string $autreLibelle = null; public function setContrat(Contrat $contrat): void { $this->contrat = $contrat; $contrat->volumesHoraires[] = $this; } } No newline at end of file