You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DocumentModel.php 6.6KB

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