src/Entity/DeviceSale.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\DeviceSaleRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Wits\PaymentBundle\Entity\PayableInterface;
  6. use Wits\PaymentBundle\Entity\Payment;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. /**
  9.  * @ORM\Entity(repositoryClass=DeviceSaleRepository::class)
  10.  */
  11. class DeviceSale implements PayableInterface
  12. {
  13.     /**
  14.      * @ORM\Id()
  15.      * @ORM\GeneratedValue()
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="float")
  21.      */
  22.     private $amount;
  23.     /**
  24.      * @ORM\Column(type="float")
  25.      */
  26.     private $commission;
  27.     /**
  28.      * @ORM\ManyToOne(targetEntity=ProspectOnStore::class, inversedBy="deviceSales")
  29.      * @ORM\JoinColumn(nullable=false)
  30.      * @Assert\NotBlank
  31.      */
  32.     private $prospectOnStore;
  33.     /**
  34.      * @ORM\OneToOne(targetEntity=Payment::class, cascade={"persist", "remove"})
  35.      */
  36.     private $payment;
  37.     /**
  38.      * @ORM\Column(type="datetime")
  39.      */
  40.     private $soldAt;
  41.     /**
  42.      * @ORM\Column(type="string", length=255, nullable=true)
  43.      */
  44.     private $description;
  45.     /**
  46.      * @ORM\OneToOne(targetEntity=Invoice::class, inversedBy="deviceSale", cascade={"persist", "remove"})
  47.      */
  48.     private $invoice;
  49.     public function getId(): ?int
  50.     {
  51.         return $this->id;
  52.     }
  53.     /**
  54.      * Représente l'entité dans le BO
  55.      * @return string
  56.      */
  57.     public function getLabel(){
  58.         return '#'.$this->getId().' ('.$this->amount.'€ | '.$this->commission.'€)';
  59.     }
  60.     public function getAmount(): ?float
  61.     {
  62.         return $this->amount;
  63.     }
  64.     public function setAmount(float $amount): self
  65.     {
  66.         $this->amount $amount;
  67.         return $this;
  68.     }
  69.     public function getCommission(): ?float
  70.     {
  71.         return $this->commission;
  72.     }
  73.     public function getCommissionTTC(): ?float
  74.     {
  75.         return $this->commission;
  76.     }
  77.     public function getCommissionHT(): ?float
  78.     {
  79.         return round($this->commission/1.2,2);
  80.     }
  81.     public function setCommission(float $commission): self
  82.     {
  83.         $this->commission $commission;
  84.         return $this;
  85.     }
  86.     public function setPercentageCommission(float $percentage): self
  87.     {
  88.         $commissionHT round($this->getAmount()*$percentage/1002);
  89.         $this->commission round($commissionHT*1.22);
  90.         return $this;
  91.     }
  92.     public function getProspectOnStore(): ?ProspectOnStore
  93.     {
  94.         return $this->prospectOnStore;
  95.     }
  96.     public function setProspectOnStore(?ProspectOnStore $prospectOnStore): self
  97.     {
  98.         $this->prospectOnStore $prospectOnStore;
  99.         return $this;
  100.     }
  101.     public function getPayment(): ?Payment
  102.     {
  103.         return $this->payment;
  104.     }
  105.     public function setPayment(?Payment $payment): self
  106.     {
  107.         $this->payment $payment;
  108.         return $this;
  109.     }
  110.     public function getSoldAt(): ?\DateTimeInterface
  111.     {
  112.         return $this->soldAt;
  113.     }
  114.     public function setSoldAt(\DateTimeInterface $soldAt): self
  115.     {
  116.         $this->soldAt $soldAt;
  117.         return $this;
  118.     }
  119.     public function getDescription(): ?string
  120.     {
  121.         return $this->description;
  122.     }
  123.     public function setDescription(?string $description): self
  124.     {
  125.         $this->description $description;
  126.         return $this;
  127.     }
  128.     public function getLineItems(): array
  129.     {
  130.         return [];
  131.     }
  132.     public function getInvoice(): ?Invoice
  133.     {
  134.         return $this->invoice;
  135.     }
  136.     public function setInvoice(?Invoice $invoice): self
  137.     {
  138.         $this->invoice $invoice;
  139.         return $this;
  140.     }
  141. }