src/Entity/Facture.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\FactureRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassFactureRepository::class)]
  9. class Facture
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\Column(length255)]
  16.     private ?string $type null;
  17.     #[ORM\Column(length255nullabletrue)]
  18.     private ?string $statutPaiement null;
  19.     #[ORM\Column]
  20.     private ?float $montantTotal null;
  21.     #[ORM\ManyToOne(inversedBy'factures')]
  22.     private ?Vente $vente null;
  23.     #[ORM\OneToMany(mappedBy'facture'targetEntityEcheance::class)]
  24.     private Collection $echeance;
  25.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  26.     private ?\DateTimeInterface $createdAt null;
  27.     #[ORM\ManyToOne(inversedBy'facture')]
  28.     private ?Client $client null;
  29.     #[ORM\Column(nullabletrue)]
  30.     private ?float $montantPaye null;
  31.     #[ORM\Column(length255nullabletrue)]
  32.     private ?string $TypePaiement null;
  33.     public function __construct()
  34.     {
  35.         $this->createdAt = new \DateTime();
  36.         $this->echeance = new ArrayCollection();
  37.     }
  38.     public function getId(): ?int
  39.     {
  40.         return $this->id;
  41.     }
  42.     public function getType(): ?string
  43.     {
  44.         return $this->type;
  45.     }
  46.     public function setType(string $type): static
  47.     {
  48.         $this->type $type;
  49.         return $this;
  50.     }
  51.     public function getStatutPaiement(): ?string
  52.     {
  53.         return $this->statutPaiement;
  54.     }
  55.     public function setStatutPaiement(?string $statutPaiement): static
  56.     {
  57.         $this->statutPaiement $statutPaiement;
  58.         return $this;
  59.     }
  60.     public function getMontantTotal(): ?float
  61.     {
  62.         return $this->montantTotal;
  63.     }
  64.     public function setMontantTotal(float $montantTotal): static
  65.     {
  66.         $this->montantTotal $montantTotal;
  67.         return $this;
  68.     }
  69.     public function getVente(): ?Vente
  70.     {
  71.         return $this->vente;
  72.     }
  73.     public function setVente(?Vente $vente): static
  74.     {
  75.         $this->vente $vente;
  76.         return $this;
  77.     }
  78.     /**
  79.      * @return Collection<int, Echeance>
  80.      */
  81.     public function getEcheance(): Collection
  82.     {
  83.         return $this->echeance;
  84.     }
  85.     public function addEcheance(Echeance $echeance): static
  86.     {
  87.         if (!$this->echeance->contains($echeance)) {
  88.             $this->echeance->add($echeance);
  89.             $echeance->setFacture($this);
  90.         }
  91.         return $this;
  92.     }
  93.     public function removeEcheance(Echeance $echeance): static
  94.     {
  95.         if ($this->echeance->removeElement($echeance)) {
  96.             // set the owning side to null (unless already changed)
  97.             if ($echeance->getFacture() === $this) {
  98.                 $echeance->setFacture(null);
  99.             }
  100.         }
  101.         return $this;
  102.     }
  103.     public function getCreatedAt(): ?\DateTimeInterface
  104.     {
  105.         return $this->createdAt;
  106.     }
  107.     public function setCreatedAt(\DateTimeInterface $createdAt): static
  108.     {
  109.         $this->createdAt $createdAt;
  110.         return $this;
  111.     }
  112.     public function getClient(): ?Client
  113.     {
  114.         return $this->client;
  115.     }
  116.     public function setClient(?Client $client): static
  117.     {
  118.         $this->client $client;
  119.         return $this;
  120.     }
  121.     public function getMontantPaye(): ?float
  122.     {
  123.         return $this->montantPaye;
  124.     }
  125.     public function setMontantPaye(?float $montantPaye): static
  126.     {
  127.         $this->montantPaye $montantPaye;
  128.         return $this;
  129.     }
  130.     public function calculerMontantPaye(): float
  131.     {
  132.         $montantPaye 0;
  133.         foreach ($this->echeance as $echeance) {
  134.             if ($echeance->isIsPaid()) {
  135.                 $montantPaye += $echeance->getAmount();
  136.             }
  137.         }
  138.         return $montantPaye;
  139.     }
  140.     public function getResteAPayer(): float
  141.     {
  142.         return $this->montantTotal $this->calculerMontantPaye();
  143.     }
  144.     public function getTypePaiement(): ?string
  145.     {
  146.         return $this->TypePaiement;
  147.     }
  148.     public function setTypePaiement(?string $TypePaiement): static
  149.     {
  150.         $this->TypePaiement $TypePaiement;
  151.         return $this;
  152.     }
  153. }