Skip to content

Commit

Permalink
check if logement social before #2394
Browse files Browse the repository at this point in the history
  • Loading branch information
sfinx13 committed Mar 26, 2024
1 parent 25b3b9b commit b0e47f3
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/Service/Signalement/SignalementBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,8 @@ public function build(): Signalement

private function setAddressData(): void
{
$isLogementSocial = $this->isServiceSecours()
? $this->evalBoolean($this->signalementDraftRequest->getSignalementConcerneLogementSocialServiceSecours())
: $this->evalBoolean($this->signalementDraftRequest->getSignalementConcerneLogementSocialAutreTiers());

$this->signalement
->setIsLogementSocial($isLogementSocial)
->setIsLogementSocial($this->isLogementSocial())
->setAdresseOccupant($this->signalementDraftRequest->getAdresseLogementAdresseDetailNumero())
->setCpOccupant($this->signalementDraftRequest->getAdresseLogementAdresseDetailCodePostal())
->setInseeOccupant($this->signalementDraftRequest->getAdresseLogementAdresseDetailInsee())
Expand Down Expand Up @@ -414,9 +410,12 @@ private function setProprietaireData(): void
->setTelProprio($this->signalementDraftRequest->getCoordonneesBailleurTel())
->setTelProprioSecondaire($this->signalementDraftRequest->getCoordonneesBailleurTelSecondaire());

$bailleur = $this->bailleurRepository->findOneBailleurBy($bailleurNom, $this->territory->getZip());
if (null !== $bailleur) {
$this->signalement->setBailleur($bailleur);
if ($this->isLogementSocial() && $bailleurNom) {
$bailleur = $this->bailleurRepository->findOneBailleurBy($bailleurNom, $this->territory->getZip());

if (null !== $bailleur) {
$this->signalement->setBailleur($bailleur);
}
}
}
}
Expand Down Expand Up @@ -449,7 +448,7 @@ private function isTiersPro(): bool

private function evalBoolean(?string $value): ?bool
{
if (null === $value) {
if (null === $value || 'ne-sais-pas' === $value || 'nsp' === $value) {
return null;
}

Expand Down Expand Up @@ -538,4 +537,11 @@ private function resolveDateNaissanceOccupant(): ?\DateTimeImmutable

return new \DateTimeImmutable($this->signalementDraftRequest->getLogementSocialDateNaissance());
}

private function isLogementSocial(): ?bool
{
return $this->isServiceSecours()
? $this->evalBoolean($this->signalementDraftRequest->getSignalementConcerneLogementSocialServiceSecours())
: $this->evalBoolean($this->signalementDraftRequest->getSignalementConcerneLogementSocialAutreTiers());
}
}

0 comments on commit b0e47f3

Please sign in to comment.