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