src/Entity/InvoiceApplication.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\InvoiceApplicationRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use Symfony\Component\HttpFoundation\File\File;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  9. /**
  10.  * @ORM\Entity(repositoryClass=InvoiceApplicationRepository::class)
  11.  * @Vich\Uploadable
  12.  * @ORM\HasLifecycleCallbacks()
  13.  */
  14. class InvoiceApplication
  15. {
  16.     const STATUS_PENDING 'pending'// invoice is waiting to be seen by an admin
  17.     const STATUS_REFUSED 'refused'// invoice is refused
  18.     const STATUS_PAID 'paid'// invoice has been paid and managed
  19.     const STATUSES = [
  20.         self::STATUS_PENDING,
  21.         self::STATUS_REFUSED,
  22.         self::STATUS_PAID,
  23.     ];
  24.     /**
  25.      * @ORM\Id
  26.      * @ORM\GeneratedValue
  27.      * @ORM\Column(type="integer")
  28.      */
  29.     private $id;
  30.     /**
  31.      * @ORM\Column(type="string", length=255)
  32.      */
  33.     private $uid;
  34.     /**
  35.      * @ORM\Column(type="datetime")
  36.      */
  37.     private $start;
  38.     /**
  39.      * @ORM\Column(type="datetime")
  40.      */
  41.     private $end;
  42.     /**
  43.      * @ORM\Column(type="datetime")
  44.      */
  45.     private $createdAt;
  46.     /**
  47.      * @ORM\Column(type="datetime", nullable=true)
  48.      * @Gedmo\Timestampable(on="update")
  49.      */
  50.     private $updatedAt;
  51.     /**
  52.      * @ORM\ManyToOne(targetEntity=Specialist::class, inversedBy="invoiceApplications")
  53.      * @ORM\JoinColumn(nullable=false)
  54.      */
  55.     private $specialist;
  56.     /**
  57.      * @ORM\Column(type="string", length=50)
  58.      */
  59.     private $status self::STATUS_PENDING;
  60.     /**
  61.      * @ORM\Column(type="string", length=255, nullable=true)
  62.      */
  63.     private $pdf;
  64.     /**
  65.      * @Vich\UploadableField(mapping="specialists_invoices", fileNameProperty="pdf")
  66.      * @Assert\File(
  67.      *     mimeTypes={"application/pdf"},
  68.      *     maxSize="1M",
  69.      * )
  70.      * @var File|null
  71.      */
  72.     private $pdfFile;
  73.     /**
  74.      * @ORM\Column(type="text", nullable=true)
  75.      */
  76.     private $reason;
  77.     /**
  78.      * @ORM\Column(type="text", nullable=true)
  79.      */
  80.     private $conditions;
  81.     /**
  82.      * @ORM\Column(type="float")
  83.      */
  84.     private $totalHt;
  85.     /**
  86.      * @ORM\Column(type="boolean", options={"default": 1})
  87.      */
  88.     private $isTva true;
  89.     /**
  90.      * @ORM\Column(type="float", nullable=true)
  91.      */
  92.     private $tva;
  93.     public function __construct()
  94.     {
  95.         $this->createdAt = new \DateTime();
  96.     }
  97.     public function getId(): ?int
  98.     {
  99.         return $this->id;
  100.     }
  101.     public function getStart(): ?\DateTimeInterface
  102.     {
  103.         return $this->start;
  104.     }
  105.     public function setStart(\DateTimeInterface $start): self
  106.     {
  107.         $this->start $start;
  108.         return $this;
  109.     }
  110.     public function getEnd(): ?\DateTimeInterface
  111.     {
  112.         return $this->end;
  113.     }
  114.     public function setEnd(\DateTimeInterface $end): self
  115.     {
  116.         $this->end $end;
  117.         return $this;
  118.     }
  119.     public function getCreatedAt(): ?\DateTimeInterface
  120.     {
  121.         return $this->createdAt;
  122.     }
  123.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  124.     {
  125.         $this->createdAt $createdAt;
  126.         return $this;
  127.     }
  128.     public function getUpdatedAt(): ?\DateTimeInterface
  129.     {
  130.         return $this->updatedAt;
  131.     }
  132.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  133.     {
  134.         $this->updatedAt $updatedAt;
  135.         return $this;
  136.     }
  137.     public function getSpecialist(): ?Specialist
  138.     {
  139.         return $this->specialist;
  140.     }
  141.     public function setSpecialist(?Specialist $specialist): self
  142.     {
  143.         $this->specialist $specialist;
  144.         return $this;
  145.     }
  146.     public function getStatus(): ?string
  147.     {
  148.         return $this->status;
  149.     }
  150.     public function setStatus(string $status): self
  151.     {
  152.         $this->status $status;
  153.         return $this;
  154.     }
  155.     public function getPdf(): ?string
  156.     {
  157.         return $this->pdf;
  158.     }
  159.     public function setPdf(string $pdf): self
  160.     {
  161.         $this->pdf $pdf;
  162.         return $this;
  163.     }
  164.     public function getReason(): ?string
  165.     {
  166.         return $this->reason;
  167.     }
  168.     public function setReason(?string $reason): self
  169.     {
  170.         $this->reason $reason;
  171.         return $this;
  172.     }
  173.     /**
  174.      * @param File|null $pdfFile
  175.      * @return InvoiceApplication
  176.      */
  177.     public function setPdfFile(?File $pdfFile): InvoiceApplication
  178.     {
  179.         $this->pdfFile $pdfFile;
  180.         if ($pdfFile) {
  181.             $this->updatedAt = new \DateTime('now');
  182.         }
  183.         return $this;
  184.     }
  185.     /**
  186.      * @return File|null
  187.      */
  188.     public function getPdfFile(): ?File
  189.     {
  190.         return $this->pdfFile;
  191.     }
  192.     public function getUid(): ?string
  193.     {
  194.         return $this->uid;
  195.     }
  196.     public function setUid(string $uid): self
  197.     {
  198.         $this->uid $uid;
  199.         return $this;
  200.     }
  201.     public function getConditions(): ?string
  202.     {
  203.         return $this->conditions;
  204.     }
  205.     public function setConditions(?string $conditions): self
  206.     {
  207.         $this->conditions $conditions;
  208.         return $this;
  209.     }
  210.     public function getTotalHt(): ?float
  211.     {
  212.         return $this->totalHt;
  213.     }
  214.     public function setTotalHt(?float $totalHt): self
  215.     {
  216.         $this->totalHt $totalHt;
  217.         return $this;
  218.     }
  219.     public function getIsTva(): ?bool
  220.     {
  221.         return $this->isTva;
  222.     }
  223.     public function setIsTva(bool $isTva): self
  224.     {
  225.         $this->isTva $isTva;
  226.         return $this;
  227.     }
  228.     public function getTva(): ?float
  229.     {
  230.         return $this->tva;
  231.     }
  232.     public function setTva(?float $tva): self
  233.     {
  234.         $this->tva $tva;
  235.         return $this;
  236.     }
  237.     public function getTotalTTC(): ?int
  238.     {
  239.         $totalTTC $this->totalHt;
  240.         if($this->isTva) {
  241.             $totalTTC *= + ($this->tva 100);
  242.         }
  243.         return $totalTTC;
  244.     }
  245. }