Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

284 linhas
6.6KB

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