src/Entity/AdminFinance/Bank/BankCompte.php line 13

  1. <?php
  2. namespace App\Entity\AdminFinance\Bank;
  3. use App\Entity\AdminFinance\Vehicule\VehiculeMouvement;
  4. use App\Entity\AdminFinance\Bank\BankMouvement;
  5. use App\Repository\AdminFinance\Bank\BankCompteRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. #[ORM\Entity(repositoryClassBankCompteRepository::class)]
  10. class BankCompte
  11. {
  12.     const COMPTE_COURANT        1;
  13.     const COMPTE_LIVRET         2;
  14.     const COMPTE_BOURSE         5;
  15.     const COMPTE_CREDIT         7;
  16.     const COMPTE_PROFESSIONNEL  9;
  17.     
  18.     #[ORM\Id]
  19.     #[ORM\GeneratedValue]
  20.     #[ORM\Column]
  21.     private ?int $id null;
  22.     #[ORM\Column(length50)]
  23.     private ?string $nom null;
  24.     #[ORM\Column]
  25.     private $type;
  26.     #[ORM\Column]
  27.     private $solde;
  28.     #[ORM\OneToMany(targetEntity:BankMouvement::class, mappedBy'compteDebit')]
  29.     private $mouvementDebit;
  30.     #[ORM\OneToMany(targetEntity:BankMouvement::class, mappedBy'compteCredit')]
  31.     private $mouvementCredit;
  32.     #[ORM\OneToMany(targetEntity:BankPrelevement::class, mappedBy'compteDebit')]
  33.     private $prelevements;
  34.     
  35.     #[ORM\OneToMany(targetEntity:VehiculeMouvement::class, mappedBy'compteDebit')]
  36.     private $vehiculeMouvementDebit;
  37.     
  38.     #[ORM\Column]
  39.     private $etat;
  40.     public function __construct()
  41.     {
  42.         $this->mouvementDebit = new ArrayCollection();
  43.         $this->mouvementCredit = new ArrayCollection();
  44.         $this->prelevements = new ArrayCollection();
  45.         $this->vehiculeMouvementDebit = new ArrayCollection();
  46.     }
  47.     public function getId(): ?int
  48.     {
  49.         return $this->id;
  50.     }
  51.     public function getNom(): ?string
  52.     {
  53.         return $this->nom;
  54.     }
  55.     public function setNom(string $nom): self
  56.     {
  57.         $this->nom $nom;
  58.         return $this;
  59.     }
  60.     public function getType(): ?int
  61.     {
  62.         return $this->type;
  63.     }
  64.     public function setType(int $type): self
  65.     {
  66.         $this->type $type;
  67.         return $this;
  68.     }
  69.     public function getSolde(): ?float
  70.     {
  71.         return $this->solde;
  72.     }
  73.     public function setSolde(float $solde): self
  74.     {
  75.         $this->solde $solde;
  76.         return $this;
  77.     }
  78.     /**
  79.      * @return Collection|BankMouvement[]
  80.      */
  81.     public function getMouvementDebit(): Collection
  82.     {
  83.         return $this->mouvementDebit;
  84.     }
  85.     public function addMouvementDebit(?BankMouvement $mouvementDebit): self
  86.     {
  87.         if (!$this->mouvementDebit->contains($mouvementDebit)) {
  88.             $this->mouvementDebit[] = $mouvementDebit;
  89.             $mouvementDebit->setCompteDebit($this);
  90.         }
  91.         return $this;
  92.     }
  93.     public function removeMouvementDebit(?BankMouvement $mouvementDebit): self
  94.     {
  95.         if ($this->mouvementDebit->contains($mouvementDebit)) {
  96.             $this->mouvementDebit->removeElement($mouvementDebit);
  97.             // set the owning side to null (unless already changed)
  98.             if ($mouvementDebit->getCompteDebit() === $this) {
  99.                 $mouvementDebit->setCompteDebit(null);
  100.             }
  101.         }
  102.         return $this;
  103.     }
  104.     /**
  105.      * @return Collection|BankMouvement[]
  106.      */
  107.     public function getMouvementCredit(): Collection
  108.     {
  109.         return $this->mouvementCredit;
  110.     }
  111.     public function addMouvementCredit(BankMouvement $mouvementCredit): self
  112.     {
  113.         if (!$this->mouvementCredit->contains($mouvementCredit)) {
  114.             $this->mouvementCredit[] = $mouvementCredit;
  115.             $mouvementCredit->setCompteCredit($this);
  116.         }
  117.         return $this;
  118.     }
  119.     public function removeMouvementCredit(BankMouvement $mouvementCredit): self
  120.     {
  121.         if ($this->mouvementCredit->contains($mouvementCredit)) {
  122.             $this->mouvementCredit->removeElement($mouvementCredit);
  123.             // set the owning side to null (unless already changed)
  124.             if ($mouvementCredit->getCompteCredit() === $this) {
  125.                 $mouvementCredit->setCompteCredit(null);
  126.             }
  127.         }
  128.         return $this;
  129.     }
  130.     
  131.     /**
  132.      * @return Collection|VehiculeMouvement[]
  133.      */
  134.     public function getVehiculeMouvementDebit(): Collection
  135.     {
  136.         return $this->vehiculeMouvementDebit;
  137.     }
  138.     public function __toString(): string
  139.     {
  140.         return $this->getNom();
  141.     }
  142.     public function getSoldeRestant(): ?float
  143.     {
  144.         $soldeRestant $this->getSolde();
  145.         foreach($this->getMouvementDebit() as $mvt) {
  146.             if($mvt->getDateOperation() !== null && $mvt->getDateOperation()->getTimestamp() <= (time()+45*24*60*60)) {
  147.                 $soldeRestant $soldeRestant $mvt->getMontant();
  148.             }
  149.         }
  150.         foreach($this->getMouvementCredit() as $mvt) {
  151.             if($mvt->getDateOperation() !== null && $mvt->getDateOperation()->getTimestamp() <= (time()+45*24*60*60)) {
  152.                 $soldeRestant $soldeRestant $mvt->getMontant();
  153.             }
  154.         }
  155.         foreach($this->getVehiculeMouvementDebit() as $mvt) {
  156.             if($mvt->getDate() !== null && $mvt->getDate()->getTimestamp() <= (time()+45*24*60*60)) {
  157.                 $soldeRestant $soldeRestant $mvt->getMontant();
  158.             }
  159.         }
  160.         return $soldeRestant;
  161.     }
  162.     
  163.     public function getSoldeBancaire(\DateTime $date null): ?float
  164.     {
  165.         $soldeRestant $this->getSolde();
  166.         foreach($this->getMouvementDebit() as $mvt) {
  167.             if($mvt->isChecked() && ($date == null || $mvt->getDateOperation()->getTimestamp() <= $date->getTimestamp())) {
  168.                 $soldeRestant $soldeRestant $mvt->getMontant();
  169.             }
  170.         }
  171.         foreach($this->getMouvementCredit() as $mvt) {
  172.             if($mvt->isChecked() && ($date == null || $mvt->getDateOperation()->getTimestamp() <= $date->getTimestamp())) {
  173.                 $soldeRestant $soldeRestant $mvt->getMontant();
  174.             }
  175.         }
  176.         foreach($this->getVehiculeMouvementDebit() as $mvt) {
  177.             if($mvt->getChecked() && ($date == null || $mvt->getDate()->getTimestamp() <= $date->getTimestamp())) {
  178.                 $soldeRestant $soldeRestant $mvt->getMontant();
  179.             }
  180.         }
  181.  
  182.         return $soldeRestant;
  183.     }
  184.     
  185.     /**
  186.      * @return Collection|BankPrelevement[]
  187.      */
  188.     public function getPrelevements(): Collection
  189.     {
  190.         return $this->prelevements;
  191.     }
  192.     public function addPrelevement(BankPrelevement $prelevement): self
  193.     {
  194.         if (!$this->prelevements->contains($prelevement)) {
  195.             $this->prelevements[] = $prelevement;
  196.             //$prelevement->setCompte($this);
  197.         }
  198.         return $this;
  199.     }
  200.     public function removePrelevement(BankPrelevement $prelevement): self
  201.     {
  202.         if ($this->prelevements->contains($prelevement)) {
  203.             $this->prelevements->removeElement($prelevement);
  204.             // set the owning side to null (unless already changed)
  205.             /*if ($prelevement->getCompte() === $this) {
  206.                 $prelevement->setCompte(null);
  207.             }*/
  208.         }
  209.         return $this;
  210.     }
  211.     public function addVehiculeMouvementDebit(VehiculeMouvement $vehiculeMouvementDebit): self
  212.     {
  213.         if (!$this->vehiculeMouvementDebit->contains($vehiculeMouvementDebit)) {
  214.             $this->vehiculeMouvementDebit->add($vehiculeMouvementDebit);
  215.             $vehiculeMouvementDebit->setCompteDebit($this);
  216.         }
  217.         return $this;
  218.     }
  219.     public function removeVehiculeMouvementDebit(VehiculeMouvement $vehiculeMouvementDebit): self
  220.     {
  221.         if ($this->vehiculeMouvementDebit->removeElement($vehiculeMouvementDebit)) {
  222.             // set the owning side to null (unless already changed)
  223.             if ($vehiculeMouvementDebit->getCompteDebit() === $this) {
  224.                 $vehiculeMouvementDebit->setCompteDebit(null);
  225.             }
  226.         }
  227.         return $this;
  228.     }
  229.     /**
  230.      * Get the value of etat
  231.      */ 
  232.     public function getEtat(): bool
  233.     {
  234.         return $this->etat;
  235.     }
  236.     /**
  237.      * Set the value of etat
  238.      *
  239.      * @return  self
  240.      */ 
  241.     public function setEtat(bool $etat)
  242.     {
  243.         $this->etat $etat;
  244.         return $this;
  245.     }
  246. }