Document.php 7.0KB

4 jaren geleden
4 jaren geleden
4 jaren geleden
4 jaren geleden
4 jaren geleden
4 jaren geleden
4 jaren geleden
4 jaren geleden
4 jaren geleden
4 jaren geleden
4 jaren geleden
4 jaren geleden
4 jaren geleden
4 jaren geleden
4 jaren geleden
4 jaren geleden
4 jaren geleden
4 jaren geleden
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <?php
  2. namespace Lc\ShopBundle\Model;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Lc\ShopBundle\Context\FilterMerchantInterface;
  7. /**
  8. * @ORM\MappedSuperclass()
  9. */
  10. abstract class Document extends AbstractDocumentEntity implements FilterMerchantInterface
  11. {
  12. const TYPE_INVOICE = 'invoice';
  13. const TYPE_QUOTATION = 'quotation';
  14. const TYPE_PURCHASE_ORDER = 'purchase-order';
  15. const TYPE_DELIVERY_NOTE = 'delivery-note';
  16. /**
  17. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface")
  18. * @ORM\JoinColumn(nullable=false)
  19. */
  20. protected $merchant;
  21. /**
  22. * @ORM\Column(type="string", length=64)
  23. */
  24. protected $type;
  25. /**
  26. * @ORM\Column(type="string", length=128, nullable=true)
  27. */
  28. protected $reference;
  29. /**
  30. * @ORM\Column(type="string", length=255, nullable=true)
  31. */
  32. protected $logo;
  33. /**
  34. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\AddressInterface")
  35. * @ORM\JoinColumn(nullable=false)
  36. */
  37. protected $merchantAddress;
  38. /**
  39. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\AddressInterface")
  40. * @ORM\JoinColumn(nullable=false)
  41. */
  42. protected $buyerAddress;
  43. /**
  44. * @ORM\Column(type="text")
  45. */
  46. protected $merchantAddressText;
  47. /**
  48. * @ORM\Column(type="text",nullable=true)
  49. */
  50. protected $buyerAddressText;
  51. /**
  52. * @ORM\Column(type="text", nullable=true)
  53. */
  54. protected $deliveryAddressText;
  55. /**
  56. * @ORM\Column(type="boolean", nullable=true)
  57. */
  58. protected $isSent;
  59. /**
  60. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", mappedBy="documents")
  61. */
  62. protected $orderShops;
  63. /**
  64. * @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\OrderRefundInterface", mappedBy="document", cascade={"persist", "remove"})
  65. */
  66. protected $orderRefund;
  67. public function __construct()
  68. {
  69. $this->orderShops = new ArrayCollection();
  70. }
  71. public function __toString()
  72. {
  73. return $this->getReference();
  74. }
  75. public function getMerchant(): ?Merchant
  76. {
  77. return $this->merchant;
  78. }
  79. public function setMerchant(?Merchant $merchant): self
  80. {
  81. $this->merchant = $merchant;
  82. return $this;
  83. }
  84. public function getLabel()
  85. {
  86. if ($this->getType() == self::TYPE_INVOICE) {
  87. return 'Facture';
  88. } elseif ($this->getType() == self::TYPE_QUOTATION) {
  89. return 'Devis';
  90. } elseif ($this->getType() == self::TYPE_PURCHASE_ORDER) {
  91. return 'Bon de commande';
  92. } elseif ($this->getType() == self::TYPE_DELIVERY_NOTE) {
  93. return 'Bon de livraison';
  94. }
  95. }
  96. public function getType(): ?string
  97. {
  98. return $this->type;
  99. }
  100. public function setType(string $type): self
  101. {
  102. $this->type = $type;
  103. return $this;
  104. }
  105. public function getReference(): ?string
  106. {
  107. return $this->reference;
  108. }
  109. public function setReference(?string $reference): self
  110. {
  111. $this->reference = $reference;
  112. return $this;
  113. }
  114. public function getLogo(): ?string
  115. {
  116. return $this->logo;
  117. }
  118. public function setLogo(string $logo): self
  119. {
  120. $this->logo = $logo;
  121. return $this;
  122. }
  123. public function getMerchantAddress(): ?Address
  124. {
  125. return $this->merchantAddress;
  126. }
  127. public function setMerchantAddress(?Address $merchantAddress): self
  128. {
  129. $this->merchantAddress = $merchantAddress;
  130. return $this;
  131. }
  132. public function getBuyerAddress(): ?Address
  133. {
  134. return $this->buyerAddress;
  135. }
  136. public function setBuyerAddress(?Address $buyerAddress): self
  137. {
  138. $this->buyerAddress = $buyerAddress;
  139. return $this;
  140. }
  141. public function getMerchantAddressText(): ?string
  142. {
  143. return $this->merchantAddressText;
  144. }
  145. public function setMerchantAddressText(string $merchantAddressText): self
  146. {
  147. $this->merchantAddressText = $merchantAddressText;
  148. return $this;
  149. }
  150. public function getBuyerAddressText(): ?string
  151. {
  152. return $this->buyerAddressText;
  153. }
  154. public function setBuyerAddressText(?string $buyerAddressText): self
  155. {
  156. $this->buyerAddressText = $buyerAddressText;
  157. return $this;
  158. }
  159. public function getDeliveryAddressText(): ?string
  160. {
  161. return $this->deliveryAddressText;
  162. }
  163. public function setDeliveryAddressText(?string $deliveryAddressText): self
  164. {
  165. $this->deliveryAddressText = $deliveryAddressText;
  166. return $this;
  167. }
  168. public function getIsSent(): ?bool
  169. {
  170. return $this->isSent;
  171. }
  172. public function setIsSent(?bool $isSent): self
  173. {
  174. $this->isSent = $isSent;
  175. return $this;
  176. }
  177. /**
  178. * @return Collection|OrderShop[]
  179. */
  180. public function getOrderShops(): Collection
  181. {
  182. return $this->orderShops;
  183. }
  184. public function addOrderShop(OrderShop $orderShop): self
  185. {
  186. if (!$this->orderShops->contains($orderShop)) {
  187. $this->orderShops[] = $orderShop;
  188. $orderShop->addDocument($this);
  189. }
  190. return $this;
  191. }
  192. public function removeOrderShop(OrderShop $orderShop): self
  193. {
  194. if ($this->orderShops->contains($orderShop)) {
  195. $this->orderShops->removeElement($orderShop);
  196. $orderShop->removeDocument($this);
  197. }
  198. return $this;
  199. }
  200. public function getOrderRefund(): ?OrderRefund
  201. {
  202. return $this->orderRefund;
  203. }
  204. public function setOrderRefund(OrderRefund $orderRefund): self
  205. {
  206. $this->orderRefund = $orderRefund;
  207. // set the owning side of the relation if necessary
  208. if ($orderRefund->getDocument() !== $this) {
  209. $orderRefund->setDocument($this);
  210. }
  211. return $this;
  212. }
  213. }