Skip to content
Snippets Groups Projects
Commit f91201c6 authored by Florian Joriot's avatar Florian Joriot
Browse files

On ne regarde que les avenant enfant du contrat et pas tous les autres contrats

parent 45d2d106
No related branches found
No related tags found
No related merge requests found
Pipeline #35217 passed
...@@ -288,7 +288,7 @@ class ContratAssertion extends AbstractAssertion ...@@ -288,7 +288,7 @@ class ContratAssertion extends AbstractAssertion
protected function assertSuppression(Contrat $contrat) protected function assertSuppression(Contrat $contrat)
{ {
if (!$contrat->estUnAvenant()) { if (!$contrat->estUnAvenant()) {
$devalid = $contrat->getIntervenant()->getContrat()->count() == 1; // on ne peut supprimer un contrat que si aucun avenant n'existe $devalid = $contrat->getIntervenant()->getAvenantEnfant($contrat)->count() < 1; // on ne peut supprimer un contrat que si aucun avenant n'existe
} else { } else {
$devalid = true; $devalid = true;
} }
......
...@@ -1414,6 +1414,23 @@ class Intervenant implements HistoriqueAwareInterface, ResourceInterface, Import ...@@ -1414,6 +1414,23 @@ class Intervenant implements HistoriqueAwareInterface, ResourceInterface, Import
return $contrats; return $contrats;
} }
public function getAvenantEnfant (Contrat $contratParent)
{
if (null === $this->contrat) {
return null;
}
$filter = function (Contrat $contrat) use ($contratParent) {
if($contrat->getContrat() != $contratParent){
return false;
}
return true;
};
$contrats = $this->contrat->filter($filter);
return $contrats;
}
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment