No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

289 líneas
7.5KB

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