BillAccounting.php 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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\ManyToOne(cascade: ['persist'], inversedBy: 'bills')]
  58. #[ORM\JoinColumn(nullable: true)]
  59. protected SddBank $sddBank;
  60. #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'bills')]
  61. #[ORM\JoinColumn(nullable: true)]
  62. protected SddRegie $sddRegie;
  63. #[ORM\ManyToMany( targetEntity: Tagg::class, inversedBy: 'billAccountings', cascade: ['persist'])]
  64. #[ORM\JoinTable(name: 'tag_billAccounting')]
  65. #[ORM\JoinColumn(name: 'billAccounting_id', referencedColumnName: 'id')]
  66. #[ORM\InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id')]
  67. protected $tags;
  68. public function __construct()
  69. {
  70. $this->billLines = new ArrayCollection();
  71. $this->billCredits = new ArrayCollection();
  72. $this->billPayments = new ArrayCollection();
  73. $this->billingIntangibleExcludeDates = new ArrayCollection();
  74. $this->tags = new ArrayCollection();
  75. }
  76. public function getId(): ?int
  77. {
  78. return $this->id;
  79. }
  80. public function getOrganization(): ?Organization
  81. {
  82. return $this->organization;
  83. }
  84. public function setOrganization(?Organization $organization): self
  85. {
  86. $this->organization = $organization;
  87. return $this;
  88. }
  89. /**
  90. * @return Collection<int, BillLine>
  91. */
  92. public function getBillLines(): Collection
  93. {
  94. return $this->billLines;
  95. }
  96. public function addBillLine(BillLine $billLine): self
  97. {
  98. if (!$this->billLines->contains($billLine)) {
  99. $this->billLines[] = $billLine;
  100. $billLine->setBill($this);
  101. }
  102. return $this;
  103. }
  104. public function removeBillLine(BillLine $billLine): self
  105. {
  106. if ($this->billLines->removeElement($billLine)) {
  107. // set the owning side to null (unless already changed)
  108. if ($billLine->getBill() === $this) {
  109. $billLine->setBill(null);
  110. }
  111. }
  112. return $this;
  113. }
  114. /**
  115. * @return Collection<int, BillCredit>
  116. */
  117. public function getBillCredits(): Collection
  118. {
  119. return $this->billCredits;
  120. }
  121. public function addBillCredit(BillCredit $billCredit): self
  122. {
  123. if (!$this->billCredits->contains($billCredit)) {
  124. $this->billCredits[] = $billCredit;
  125. $billCredit->setBill($this);
  126. }
  127. return $this;
  128. }
  129. public function removeBillCredit(BillCredit $billCredit): self
  130. {
  131. if ($this->billCredits->removeElement($billCredit)) {
  132. // set the owning side to null (unless already changed)
  133. if ($billCredit->getBill() === $this) {
  134. $billCredit->setBill(null);
  135. }
  136. }
  137. return $this;
  138. }
  139. /**
  140. * @return Collection<int, BillPayment>
  141. */
  142. public function getBillPayments(): Collection
  143. {
  144. return $this->billPayments;
  145. }
  146. public function addBillPayment(BillPayment $billPayment): self
  147. {
  148. if (!$this->billPayments->contains($billPayment)) {
  149. $this->billPayments[] = $billPayment;
  150. $billPayment->setBill($this);
  151. }
  152. return $this;
  153. }
  154. public function removeBillPayment(BillPayment $billPayment): self
  155. {
  156. if ($this->billPayments->removeElement($billPayment)) {
  157. // set the owning side to null (unless already changed)
  158. if ($billPayment->getBill() === $this) {
  159. $billPayment->setBill(null);
  160. }
  161. }
  162. return $this;
  163. }
  164. public function getBill(): ?self
  165. {
  166. return $this->bill;
  167. }
  168. public function setBill(?self $bill): self
  169. {
  170. $this->bill = $bill;
  171. return $this;
  172. }
  173. /**
  174. * @return Collection<int, BillingIntangibleExcludeDate>
  175. */
  176. public function getBillingIntangibleExcludeDates(): Collection
  177. {
  178. return $this->billingIntangibleExcludeDates;
  179. }
  180. public function addBillingIntangibleExcludeDate(BillingIntangibleExcludeDate $billingIntangibleExcludeDate): self
  181. {
  182. if (!$this->billingIntangibleExcludeDates->contains($billingIntangibleExcludeDate)) {
  183. $this->billingIntangibleExcludeDates[] = $billingIntangibleExcludeDate;
  184. $billingIntangibleExcludeDate->setBill($this);
  185. }
  186. return $this;
  187. }
  188. public function removeBillingIntangibleExcludeDate(BillingIntangibleExcludeDate $billingIntangibleExcludeDate): self
  189. {
  190. if ($this->billingIntangibleExcludeDates->removeElement($billingIntangibleExcludeDate)) {
  191. // set the owning side to null (unless already changed)
  192. if ($billingIntangibleExcludeDate->getBill() === $this) {
  193. $billingIntangibleExcludeDate->setBill(null);
  194. }
  195. }
  196. return $this;
  197. }
  198. public function getPes(): ?Pes
  199. {
  200. return $this->pes;
  201. }
  202. public function setPes(?Pes $pes): self
  203. {
  204. $this->pes = $pes;
  205. return $this;
  206. }
  207. public function getBergerLevrault(): ?BergerLevrault
  208. {
  209. return $this->bergerLevrault;
  210. }
  211. public function setBergerLevrault(?BergerLevrault $bergerLevrault): self
  212. {
  213. $this->bergerLevrault = $bergerLevrault;
  214. return $this;
  215. }
  216. public function getCiril(): ?Ciril
  217. {
  218. return $this->ciril;
  219. }
  220. public function setCiril(?Ciril $ciril): self
  221. {
  222. $this->ciril = $ciril;
  223. return $this;
  224. }
  225. public function getJvs(): ?Jvs
  226. {
  227. return $this->jvs;
  228. }
  229. public function setJvs(?Jvs $jvs): self
  230. {
  231. $this->jvs = $jvs;
  232. return $this;
  233. }
  234. public function getSddBank(): ?SddBank
  235. {
  236. return $this->sddBank;
  237. }
  238. public function setSddBank(?SddBank $sddBank): self
  239. {
  240. $this->sddBank = $sddBank;
  241. return $this;
  242. }
  243. public function getSddRegie(): ?SddRegie
  244. {
  245. return $this->sddRegie;
  246. }
  247. public function setSddRegie(?SddRegie $sddRegie): self
  248. {
  249. $this->sddRegie = $sddRegie;
  250. return $this;
  251. }
  252. /**
  253. * @return Collection<int, Tagg>
  254. */
  255. public function getTags(): Collection
  256. {
  257. return $this->tags;
  258. }
  259. public function addTag(Tagg $tag): self
  260. {
  261. if (!$this->tags->contains($tag)) {
  262. $this->tags[] = $tag;
  263. }
  264. return $this;
  265. }
  266. public function removeTag(Tagg $tag): self
  267. {
  268. $this->tags->removeElement($tag);
  269. return $this;
  270. }
  271. }