BillAccounting.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Billing;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use App\Entity\Core\Tagg;
  6. use App\Entity\Organization\Organization;
  7. use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Doctrine\Common\Collections\Collection;
  11. /**
  12. * @todo : A la suite de la migration, il faut supprimer le nom de la table pour avoir une table BillAccounting, et supprimer l'attribut discr.
  13. * Classe ... qui ...
  14. */
  15. #[Auditable]
  16. #[ORM\Entity]
  17. #[ApiResource(
  18. collectionOperations:[],
  19. itemOperations: [
  20. "get" => ["security" => "is_granted('ROLE_ADMIN') and object.getOrganization().getId() == user.getOrganization().getId()"]
  21. ]
  22. )]
  23. class BillAccounting
  24. {
  25. #[ORM\Id]
  26. #[ORM\Column]
  27. #[ORM\GeneratedValue]
  28. protected ?int $id = null;
  29. #[ORM\Column(length: 255, nullable: false)]
  30. protected string $discr = 'billaccounting';
  31. #[ORM\ManyToOne]
  32. #[ORM\JoinColumn(nullable: true)]
  33. protected Organization $organization;
  34. #[ORM\OneToMany(mappedBy: 'bill',targetEntity: BillLine::class, cascade: ['persist'], orphanRemoval: true)]
  35. protected Collection $billLines;
  36. #[ORM\OneToMany(mappedBy: 'bill',targetEntity: BillCredit::class, cascade: ['persist'], orphanRemoval: true)]
  37. protected Collection $billCredits;
  38. #[ORM\OneToMany(mappedBy: 'bill',targetEntity: BillPayment::class, cascade: ['persist'], orphanRemoval: true)]
  39. protected Collection $billPayments;
  40. #[ORM\ManyToOne(inversedBy: 'billCredits')]
  41. #[ORM\JoinColumn(nullable: true)]
  42. protected BillAccounting $bill;
  43. #[ORM\OneToMany(mappedBy: 'bill',targetEntity: BillingIntangibleExcludeDate::class, cascade: ['persist'], orphanRemoval: true)]
  44. protected Collection $billingIntangibleExcludeDates;
  45. #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'bills')]
  46. #[ORM\JoinColumn(nullable: true)]
  47. protected Pes $pes;
  48. #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'bills')]
  49. #[ORM\JoinColumn(nullable: true)]
  50. protected BergerLevrault $bergerLevrault;
  51. #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'bills')]
  52. #[ORM\JoinColumn(nullable: true)]
  53. protected Ciril $ciril;
  54. #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'bills')]
  55. #[ORM\JoinColumn(nullable: true)]
  56. protected Jvs $jvs;
  57. #[ORM\ManyToMany( targetEntity: Tagg::class, inversedBy: 'billAccountings', cascade: ['persist'])]
  58. #[ORM\JoinTable(name: 'tag_billAccounting')]
  59. #[ORM\JoinColumn(name: 'billAccounting_id', referencedColumnName: 'id')]
  60. #[ORM\InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id')]
  61. protected $tags;
  62. public function __construct()
  63. {
  64. $this->billLines = new ArrayCollection();
  65. $this->billCredits = new ArrayCollection();
  66. $this->billPayments = new ArrayCollection();
  67. $this->billingIntangibleExcludeDates = new ArrayCollection();
  68. $this->tags = new ArrayCollection();
  69. }
  70. public function getId(): ?int
  71. {
  72. return $this->id;
  73. }
  74. public function getOrganization(): ?Organization
  75. {
  76. return $this->organization;
  77. }
  78. public function setOrganization(?Organization $organization): self
  79. {
  80. $this->organization = $organization;
  81. return $this;
  82. }
  83. /**
  84. * @return Collection<int, BillLine>
  85. */
  86. public function getBillLines(): Collection
  87. {
  88. return $this->billLines;
  89. }
  90. public function addBillLine(BillLine $billLine): self
  91. {
  92. if (!$this->billLines->contains($billLine)) {
  93. $this->billLines[] = $billLine;
  94. $billLine->setBill($this);
  95. }
  96. return $this;
  97. }
  98. public function removeBillLine(BillLine $billLine): self
  99. {
  100. if ($this->billLines->removeElement($billLine)) {
  101. // set the owning side to null (unless already changed)
  102. if ($billLine->getBill() === $this) {
  103. $billLine->setBill(null);
  104. }
  105. }
  106. return $this;
  107. }
  108. /**
  109. * @return Collection<int, BillCredit>
  110. */
  111. public function getBillCredits(): Collection
  112. {
  113. return $this->billCredits;
  114. }
  115. public function addBillCredit(BillCredit $billCredit): self
  116. {
  117. if (!$this->billCredits->contains($billCredit)) {
  118. $this->billCredits[] = $billCredit;
  119. $billCredit->setBill($this);
  120. }
  121. return $this;
  122. }
  123. public function removeBillCredit(BillCredit $billCredit): self
  124. {
  125. if ($this->billCredits->removeElement($billCredit)) {
  126. // set the owning side to null (unless already changed)
  127. if ($billCredit->getBill() === $this) {
  128. $billCredit->setBill(null);
  129. }
  130. }
  131. return $this;
  132. }
  133. /**
  134. * @return Collection<int, BillPayment>
  135. */
  136. public function getBillPayments(): Collection
  137. {
  138. return $this->billPayments;
  139. }
  140. public function addBillPayment(BillPayment $billPayment): self
  141. {
  142. if (!$this->billPayments->contains($billPayment)) {
  143. $this->billPayments[] = $billPayment;
  144. $billPayment->setBill($this);
  145. }
  146. return $this;
  147. }
  148. public function removeBillPayment(BillPayment $billPayment): self
  149. {
  150. if ($this->billPayments->removeElement($billPayment)) {
  151. // set the owning side to null (unless already changed)
  152. if ($billPayment->getBill() === $this) {
  153. $billPayment->setBill(null);
  154. }
  155. }
  156. return $this;
  157. }
  158. public function getBill(): ?self
  159. {
  160. return $this->bill;
  161. }
  162. public function setBill(?self $bill): self
  163. {
  164. $this->bill = $bill;
  165. return $this;
  166. }
  167. /**
  168. * @return Collection<int, BillingIntangibleExcludeDate>
  169. */
  170. public function getBillingIntangibleExcludeDates(): Collection
  171. {
  172. return $this->billingIntangibleExcludeDates;
  173. }
  174. public function addBillingIntangibleExcludeDate(BillingIntangibleExcludeDate $billingIntangibleExcludeDate): self
  175. {
  176. if (!$this->billingIntangibleExcludeDates->contains($billingIntangibleExcludeDate)) {
  177. $this->billingIntangibleExcludeDates[] = $billingIntangibleExcludeDate;
  178. $billingIntangibleExcludeDate->setBill($this);
  179. }
  180. return $this;
  181. }
  182. public function removeBillingIntangibleExcludeDate(BillingIntangibleExcludeDate $billingIntangibleExcludeDate): self
  183. {
  184. if ($this->billingIntangibleExcludeDates->removeElement($billingIntangibleExcludeDate)) {
  185. // set the owning side to null (unless already changed)
  186. if ($billingIntangibleExcludeDate->getBill() === $this) {
  187. $billingIntangibleExcludeDate->setBill(null);
  188. }
  189. }
  190. return $this;
  191. }
  192. public function getPes(): ?Pes
  193. {
  194. return $this->pes;
  195. }
  196. public function setPes(?Pes $pes): self
  197. {
  198. $this->pes = $pes;
  199. return $this;
  200. }
  201. public function getBergerLevrault(): ?BergerLevrault
  202. {
  203. return $this->bergerLevrault;
  204. }
  205. public function setBergerLevrault(?BergerLevrault $bergerLevrault): self
  206. {
  207. $this->bergerLevrault = $bergerLevrault;
  208. return $this;
  209. }
  210. public function getCiril(): ?Ciril
  211. {
  212. return $this->ciril;
  213. }
  214. public function setCiril(?Ciril $ciril): self
  215. {
  216. $this->ciril = $ciril;
  217. return $this;
  218. }
  219. public function getJvs(): ?Jvs
  220. {
  221. return $this->jvs;
  222. }
  223. public function setJvs(?Jvs $jvs): self
  224. {
  225. $this->jvs = $jvs;
  226. return $this;
  227. }
  228. /**
  229. * @return Collection<int, Tagg>
  230. */
  231. public function getTags(): Collection
  232. {
  233. return $this->tags;
  234. }
  235. public function addTag(Tagg $tag): self
  236. {
  237. if (!$this->tags->contains($tag)) {
  238. $this->tags[] = $tag;
  239. }
  240. return $this;
  241. }
  242. public function removeTag(Tagg $tag): self
  243. {
  244. $this->tags->removeElement($tag);
  245. return $this;
  246. }
  247. }