src/Entity/AdminFinance/Bank/BankCompte.php line 13
<?phpnamespace App\Entity\AdminFinance\Bank;use App\Entity\AdminFinance\Vehicule\VehiculeMouvement;use App\Entity\AdminFinance\Bank\BankMouvement;use App\Repository\AdminFinance\Bank\BankCompteRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: BankCompteRepository::class)]class BankCompte{const COMPTE_COURANT = 1;const COMPTE_LIVRET = 2;const COMPTE_BOURSE = 5;const COMPTE_CREDIT = 7;const COMPTE_PROFESSIONNEL = 9;#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\Column(length: 50)]private ?string $nom = null;#[ORM\Column]private $type;#[ORM\Column]private $solde;#[ORM\OneToMany(targetEntity:BankMouvement::class, mappedBy: 'compteDebit')]private $mouvementDebit;#[ORM\OneToMany(targetEntity:BankMouvement::class, mappedBy: 'compteCredit')]private $mouvementCredit;#[ORM\OneToMany(targetEntity:BankPrelevement::class, mappedBy: 'compteDebit')]private $prelevements;#[ORM\OneToMany(targetEntity:VehiculeMouvement::class, mappedBy: 'compteDebit')]private $vehiculeMouvementDebit;#[ORM\Column]private $etat;public function __construct(){$this->mouvementDebit = new ArrayCollection();$this->mouvementCredit = new ArrayCollection();$this->prelevements = new ArrayCollection();$this->vehiculeMouvementDebit = new ArrayCollection();}public function getId(): ?int{return $this->id;}public function getNom(): ?string{return $this->nom;}public function setNom(string $nom): self{$this->nom = $nom;return $this;}public function getType(): ?int{return $this->type;}public function setType(int $type): self{$this->type = $type;return $this;}public function getSolde(): ?float{return $this->solde;}public function setSolde(float $solde): self{$this->solde = $solde;return $this;}/*** @return Collection|BankMouvement[]*/public function getMouvementDebit(): Collection{return $this->mouvementDebit;}public function addMouvementDebit(?BankMouvement $mouvementDebit): self{if (!$this->mouvementDebit->contains($mouvementDebit)) {$this->mouvementDebit[] = $mouvementDebit;$mouvementDebit->setCompteDebit($this);}return $this;}public function removeMouvementDebit(?BankMouvement $mouvementDebit): self{if ($this->mouvementDebit->contains($mouvementDebit)) {$this->mouvementDebit->removeElement($mouvementDebit);// set the owning side to null (unless already changed)if ($mouvementDebit->getCompteDebit() === $this) {$mouvementDebit->setCompteDebit(null);}}return $this;}/*** @return Collection|BankMouvement[]*/public function getMouvementCredit(): Collection{return $this->mouvementCredit;}public function addMouvementCredit(BankMouvement $mouvementCredit): self{if (!$this->mouvementCredit->contains($mouvementCredit)) {$this->mouvementCredit[] = $mouvementCredit;$mouvementCredit->setCompteCredit($this);}return $this;}public function removeMouvementCredit(BankMouvement $mouvementCredit): self{if ($this->mouvementCredit->contains($mouvementCredit)) {$this->mouvementCredit->removeElement($mouvementCredit);// set the owning side to null (unless already changed)if ($mouvementCredit->getCompteCredit() === $this) {$mouvementCredit->setCompteCredit(null);}}return $this;}/*** @return Collection|VehiculeMouvement[]*/public function getVehiculeMouvementDebit(): Collection{return $this->vehiculeMouvementDebit;}public function __toString(): string{return $this->getNom();}public function getSoldeRestant(): ?float{$soldeRestant = $this->getSolde();foreach($this->getMouvementDebit() as $mvt) {if($mvt->getDateOperation() !== null && $mvt->getDateOperation()->getTimestamp() <= (time()+45*24*60*60)) {$soldeRestant = $soldeRestant - $mvt->getMontant();}}foreach($this->getMouvementCredit() as $mvt) {if($mvt->getDateOperation() !== null && $mvt->getDateOperation()->getTimestamp() <= (time()+45*24*60*60)) {$soldeRestant = $soldeRestant + $mvt->getMontant();}}foreach($this->getVehiculeMouvementDebit() as $mvt) {if($mvt->getDate() !== null && $mvt->getDate()->getTimestamp() <= (time()+45*24*60*60)) {$soldeRestant = $soldeRestant - $mvt->getMontant();}}return $soldeRestant;}public function getSoldeBancaire(\DateTime $date = null): ?float{$soldeRestant = $this->getSolde();foreach($this->getMouvementDebit() as $mvt) {if($mvt->isChecked() && ($date == null || $mvt->getDateOperation()->getTimestamp() <= $date->getTimestamp())) {$soldeRestant = $soldeRestant - $mvt->getMontant();}}foreach($this->getMouvementCredit() as $mvt) {if($mvt->isChecked() && ($date == null || $mvt->getDateOperation()->getTimestamp() <= $date->getTimestamp())) {$soldeRestant = $soldeRestant + $mvt->getMontant();}}foreach($this->getVehiculeMouvementDebit() as $mvt) {if($mvt->getChecked() && ($date == null || $mvt->getDate()->getTimestamp() <= $date->getTimestamp())) {$soldeRestant = $soldeRestant - $mvt->getMontant();}}return $soldeRestant;}/*** @return Collection|BankPrelevement[]*/public function getPrelevements(): Collection{return $this->prelevements;}public function addPrelevement(BankPrelevement $prelevement): self{if (!$this->prelevements->contains($prelevement)) {$this->prelevements[] = $prelevement;//$prelevement->setCompte($this);}return $this;}public function removePrelevement(BankPrelevement $prelevement): self{if ($this->prelevements->contains($prelevement)) {$this->prelevements->removeElement($prelevement);// set the owning side to null (unless already changed)/*if ($prelevement->getCompte() === $this) {$prelevement->setCompte(null);}*/}return $this;}public function addVehiculeMouvementDebit(VehiculeMouvement $vehiculeMouvementDebit): self{if (!$this->vehiculeMouvementDebit->contains($vehiculeMouvementDebit)) {$this->vehiculeMouvementDebit->add($vehiculeMouvementDebit);$vehiculeMouvementDebit->setCompteDebit($this);}return $this;}public function removeVehiculeMouvementDebit(VehiculeMouvement $vehiculeMouvementDebit): self{if ($this->vehiculeMouvementDebit->removeElement($vehiculeMouvementDebit)) {// set the owning side to null (unless already changed)if ($vehiculeMouvementDebit->getCompteDebit() === $this) {$vehiculeMouvementDebit->setCompteDebit(null);}}return $this;}/*** Get the value of etat*/public function getEtat(): bool{return $this->etat;}/*** Set the value of etat** @return self*/public function setEtat(bool $etat){$this->etat = $etat;return $this;}}