BillAccounting.php 8.0 KB

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