src/Entity/System/Invoice.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\System;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6.  * Invoice
  7.  *
  8.  * @ORM\Table(name="invoice")
  9.  *
  10.  * @ORM\Entity(repositoryClass="App\Repository\System\InvoiceRepository")
  11.  */
  12. class Invoice
  13. {
  14.     public const TYPE_PDF 1;
  15.     public const TYPE_ELECTRONIC 2;
  16.     public const TYPE_EDI 3;
  17.     public const A4B_INVOICE_MIME_TYPE_PDF 'pdf';
  18.     public const A4B_INVOICE_MIME_TYPE_ELECTRONIC 'xml';
  19.     public const A4B_INVOICE_MIME_TYPE_EDI 'txt';
  20.     public const INVOICE_FILE_TYPES_INDEXED_BY_A4B_MIME_TYPE = [
  21.         self::A4B_INVOICE_MIME_TYPE_PDF => self::TYPE_PDF,
  22.         self::A4B_INVOICE_MIME_TYPE_ELECTRONIC => self::TYPE_ELECTRONIC,
  23.         self::A4B_INVOICE_MIME_TYPE_EDI => self::TYPE_EDI,
  24.     ];
  25.     /**
  26.      * @var int
  27.      *
  28.      * @ORM\Column(name="id", type="integer")
  29.      *
  30.      * @ORM\Id
  31.      *
  32.      * @ORM\GeneratedValue(strategy="AUTO")
  33.      */
  34.     private $id;
  35.     /**
  36.      * @var Customer
  37.      *
  38.      * @ORM\ManyToOne(targetEntity="Customer")
  39.      *
  40.      * @ORM\JoinColumn(name="customer_id", referencedColumnName="id_customer")
  41.      */
  42.     private $customer;
  43.     /**
  44.      * @var Order[]|ArrayCollection
  45.      *
  46.      * @ORM\ManyToMany(targetEntity="App\Entity\System\Order", indexBy="id", inversedBy="invoice")
  47.      *
  48.      * @ORM\JoinTable(name="order_invoice",
  49.      *     joinColumns={@ORM\JoinColumn(name="invoice_id", referencedColumnName="id")},
  50.      *     inverseJoinColumns={@ORM\JoinColumn(name="order_id", referencedColumnName="id_order")}
  51.      *  )
  52.      */
  53.     private $orders;
  54.     /**
  55.      * @var string
  56.      *
  57.      * @ORM\Column(name="reference", type="string", length=100)
  58.      */
  59.     private $reference;
  60.     /**
  61.      * @var float
  62.      *
  63.      * @ORM\Column(name="total", type="float")
  64.      */
  65.     private $total;
  66.     /**
  67.      * @var \DateTime
  68.      *
  69.      * @ORM\Column(name="date_add", type="datetime")
  70.      */
  71.     private $dateAdd;
  72.     /**
  73.      * @var \DateTime|null
  74.      *
  75.      * @ORM\Column(name="date_upd", type="datetime", nullable=true)
  76.      */
  77.     private $dateUpd;
  78.     /**
  79.      * @var string
  80.      *
  81.      * @ORM\Column(name="download_link", type="text", length=100)
  82.      */
  83.     private $downloadLink;
  84.     /**
  85.      * @var int
  86.      *
  87.      * @ORM\Column(name="type", type="integer", options={"default":"1"})
  88.      */
  89.     private int $type;
  90.     public function __construct()
  91.     {
  92.         $this->orders = new ArrayCollection();
  93.     }
  94.     /**
  95.      * @return int
  96.      */
  97.     public function getId(): int
  98.     {
  99.         return $this->id;
  100.     }
  101.     /**
  102.      * @param int $id
  103.      *
  104.      * @return Invoice
  105.      */
  106.     public function setId(int $id): self
  107.     {
  108.         $this->id $id;
  109.         return $this;
  110.     }
  111.     /**
  112.      * @return Customer
  113.      */
  114.     public function getCustomer(): Customer
  115.     {
  116.         return $this->customer;
  117.     }
  118.     /**
  119.      * @param Customer $customer
  120.      *
  121.      * @return Invoice
  122.      */
  123.     public function setCustomer(Customer $customer): self
  124.     {
  125.         $this->customer $customer;
  126.         return $this;
  127.     }
  128.     /**
  129.      * @return Order[]|ArrayCollection
  130.      */
  131.     public function getOrders()
  132.     {
  133.         return $this->orders;
  134.     }
  135.     /**
  136.      * @param Order[]|ArrayCollection $orders
  137.      */
  138.     public function setOrders($orders): self
  139.     {
  140.         $this->orders $orders;
  141.         return $this;
  142.     }
  143.     /**
  144.      * @return float
  145.      */
  146.     public function getTotal(): float
  147.     {
  148.         return $this->total;
  149.     }
  150.     /**
  151.      * @param float $total
  152.      *
  153.      * @return Invoice
  154.      */
  155.     public function setTotal(float $total): self
  156.     {
  157.         $this->total $total;
  158.         return $this;
  159.     }
  160.     /**
  161.      * @return \DateTime
  162.      */
  163.     public function getDateAdd()
  164.     {
  165.         return $this->dateAdd;
  166.     }
  167.     /**
  168.      * @param \DateTime $dateAdd
  169.      *
  170.      * @return Invoice
  171.      */
  172.     public function setDateAdd(\DateTime $dateAdd): self
  173.     {
  174.         $this->dateAdd $dateAdd;
  175.         return $this;
  176.     }
  177.     public function getDateUpd(): ?\DateTime
  178.     {
  179.         return $this->dateUpd;
  180.     }
  181.     /**
  182.      * @param \DateTime $dateUpd
  183.      *
  184.      * @return Invoice
  185.      */
  186.     public function setDateUpd(\DateTime $dateUpd): self
  187.     {
  188.         $this->dateUpd $dateUpd;
  189.         return $this;
  190.     }
  191.     /**
  192.      * @return string
  193.      */
  194.     public function getReference(): string
  195.     {
  196.         return $this->reference;
  197.     }
  198.     /**
  199.      * @param string $reference
  200.      *
  201.      * @return Invoice
  202.      */
  203.     public function setReference(string $reference): self
  204.     {
  205.         $this->reference $reference;
  206.         return $this;
  207.     }
  208.     /**
  209.      * @return string
  210.      */
  211.     public function getDownloadLink(): string
  212.     {
  213.         return $this->downloadLink;
  214.     }
  215.     /**
  216.      * @param string $downloadLink
  217.      *
  218.      * @return Invoice
  219.      */
  220.     public function setDownloadLink(string $downloadLink): self
  221.     {
  222.         $this->downloadLink $downloadLink;
  223.         return $this;
  224.     }
  225.     public function getType(): int
  226.     {
  227.         return $this->type;
  228.     }
  229.     public function setType(int $type): Invoice
  230.     {
  231.         $this->type $type;
  232.         return $this;
  233.     }
  234.     public static function getInvoiceType(int $type): string
  235.     {
  236.         $types = \array_flip(self::INVOICE_FILE_TYPES_INDEXED_BY_A4B_MIME_TYPE);
  237.         return $types[$type];
  238.     }
  239. }