src/Entity/System/Invoice.php line 18

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