Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

270 Zeilen
6.9KB

  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 getMerchant(): ?Merchant
  72. {
  73. return $this->merchant;
  74. }
  75. public function setMerchant(?Merchant $merchant): self
  76. {
  77. $this->merchant = $merchant;
  78. return $this;
  79. }
  80. public function getLabel()
  81. {
  82. if($this->getType() == self::TYPE_INVOICE) {
  83. return 'Facture' ;
  84. }
  85. elseif($this->getType() == self::TYPE_QUOTATION) {
  86. return 'Devis' ;
  87. }
  88. elseif($this->getType() == self::TYPE_PURCHASE_ORDER) {
  89. return 'Bon de commande' ;
  90. }
  91. elseif($this->getType() == self::TYPE_DELIVERY_NOTE) {
  92. return 'Bon de livraison' ;
  93. }
  94. }
  95. public function getType(): ?string
  96. {
  97. return $this->type;
  98. }
  99. public function setType(string $type): self
  100. {
  101. $this->type = $type;
  102. return $this;
  103. }
  104. public function getReference(): ?string
  105. {
  106. return $this->reference;
  107. }
  108. public function setReference(?string $reference): self
  109. {
  110. $this->reference = $reference;
  111. return $this;
  112. }
  113. public function getLogo(): ?string
  114. {
  115. return $this->logo;
  116. }
  117. public function setLogo(string $logo): self
  118. {
  119. $this->logo = $logo;
  120. return $this;
  121. }
  122. public function getMerchantAddress(): ?Address
  123. {
  124. return $this->merchantAddress;
  125. }
  126. public function setMerchantAddress(?Address $merchantAddress): self
  127. {
  128. $this->merchantAddress = $merchantAddress;
  129. return $this;
  130. }
  131. public function getBuyerAddress(): ?Address
  132. {
  133. return $this->buyerAddress;
  134. }
  135. public function setBuyerAddress(?Address $buyerAddress): self
  136. {
  137. $this->buyerAddress = $buyerAddress;
  138. return $this;
  139. }
  140. public function getMerchantAddressText(): ?string
  141. {
  142. return $this->merchantAddressText;
  143. }
  144. public function setMerchantAddressText(string $merchantAddressText): self
  145. {
  146. $this->merchantAddressText = $merchantAddressText;
  147. return $this;
  148. }
  149. public function getBuyerAddressText(): ?string
  150. {
  151. return $this->buyerAddressText;
  152. }
  153. public function setBuyerAddressText(?string $buyerAddressText): self
  154. {
  155. $this->buyerAddressText = $buyerAddressText;
  156. return $this;
  157. }
  158. public function getDeliveryAddressText(): ?string
  159. {
  160. return $this->deliveryAddressText;
  161. }
  162. public function setDeliveryAddressText(?string $deliveryAddressText): self
  163. {
  164. $this->deliveryAddressText = $deliveryAddressText;
  165. return $this;
  166. }
  167. public function getIsSent(): ?bool
  168. {
  169. return $this->isSent;
  170. }
  171. public function setIsSent(?bool $isSent): self
  172. {
  173. $this->isSent = $isSent;
  174. return $this;
  175. }
  176. /**
  177. * @return Collection|OrderShop[]
  178. */
  179. public function getOrderShops(): Collection
  180. {
  181. return $this->orderShops;
  182. }
  183. public function addOrderShop(OrderShop $orderShop): self
  184. {
  185. if (!$this->orderShops->contains($orderShop)) {
  186. $this->orderShops[] = $orderShop;
  187. $orderShop->addDocument($this);
  188. }
  189. return $this;
  190. }
  191. public function removeOrderShop(OrderShop $orderShop): self
  192. {
  193. if ($this->orderShops->contains($orderShop)) {
  194. $this->orderShops->removeElement($orderShop);
  195. $orderShop->removeDocument($this);
  196. }
  197. return $this;
  198. }
  199. public function getOrderRefund(): ?OrderRefund
  200. {
  201. return $this->orderRefund;
  202. }
  203. public function setOrderRefund(OrderRefund $orderRefund): self
  204. {
  205. $this->orderRefund = $orderRefund;
  206. // set the owning side of the relation if necessary
  207. if ($orderRefund->getDocument() !== $this) {
  208. $orderRefund->setDocument($this);
  209. }
  210. return $this;
  211. }
  212. }