AbstractBillAccounting.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Billing;
  4. use App\Entity\Access\Access;
  5. use App\Entity\Core\File;
  6. use App\Entity\Core\Tagg;
  7. use App\Entity\Organization\Organization;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. /**
  12. * Facture ou avoir.
  13. *
  14. * @see Bill, BillCredit, AdvancePayment
  15. *
  16. * @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.
  17. */
  18. #[ORM\MappedSuperclass]
  19. #[ORM\Table(name: 'BillAccounting')]
  20. #[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
  21. #[ORM\DiscriminatorMap(
  22. [
  23. 'billaccounting' => BillAccounting::class,
  24. 'bill' => Bill::class,
  25. 'billcredit' => BillCredit::class,
  26. 'advancepayment' => AdvancePayment::class,
  27. ]
  28. )]
  29. abstract class AbstractBillAccounting
  30. {
  31. #[ORM\Id]
  32. #[ORM\Column]
  33. #[ORM\GeneratedValue]
  34. protected ?int $id = null;
  35. #[ORM\ManyToOne(targetEntity: Organization::class)]
  36. #[ORM\JoinColumn(nullable: true)]
  37. protected ?Organization $organization;
  38. /** @var Collection<int, BillLine> */
  39. #[ORM\OneToMany(targetEntity: BillLine::class, mappedBy: 'bill', cascade: ['persist'], orphanRemoval: true)]
  40. protected Collection $billLines;
  41. /** @var Collection<int, BillCredit> */
  42. #[ORM\OneToMany(targetEntity: BillCredit::class, mappedBy: 'bill', cascade: ['persist'], orphanRemoval: true)]
  43. protected Collection $billCredits;
  44. /** @var Collection<int, BillPayment> */
  45. #[ORM\OneToMany(targetEntity: BillPayment::class, mappedBy: 'bill', cascade: ['persist'], orphanRemoval: true)]
  46. protected Collection $billPayments;
  47. #[ORM\ManyToOne(inversedBy: 'billCredits')]
  48. #[ORM\JoinColumn(nullable: true)]
  49. protected ?AbstractBillAccounting $bill;
  50. /** @var Collection<int, BillingIntangibleExcludeDate> */
  51. #[ORM\OneToMany(targetEntity: BillingIntangibleExcludeDate::class, mappedBy: 'bill', cascade: ['persist'], orphanRemoval: true)]
  52. protected Collection $billingIntangibleExcludeDates;
  53. #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'bills')]
  54. #[ORM\JoinColumn(nullable: true)]
  55. protected ?Pes $pes;
  56. #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'bills')]
  57. #[ORM\JoinColumn(nullable: true)]
  58. protected ?BergerLevrault $bergerLevrault;
  59. #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'bills')]
  60. #[ORM\JoinColumn(nullable: true)]
  61. protected ?Ciril $ciril;
  62. #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'bills')]
  63. #[ORM\JoinColumn(nullable: true)]
  64. protected ?Jvs $jvs;
  65. /** @var Collection<int, Tagg> */
  66. #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'billAccountings', cascade: ['persist'])]
  67. #[ORM\JoinTable(name: 'tag_billAccounting')]
  68. #[ORM\JoinColumn(name: 'billAccounting_id', referencedColumnName: 'id')]
  69. #[ORM\InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id')]
  70. protected Collection $tags;
  71. #[ORM\ManyToOne(targetEntity: Access::class, cascade: [], inversedBy: 'bills')]
  72. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: false, onDelete: 'SET NULL')]
  73. protected Access $access;
  74. #[ORM\OneToOne(targetEntity: BillAccessDetail::class, cascade: ['persist'])]
  75. protected ?BillAccessDetail $accessDetail;
  76. #[ORM\OneToOne(targetEntity: BillPeriod::class, cascade: ['persist'])]
  77. protected ?BillPeriod $billPeriod;
  78. #[ORM\OneToOne(targetEntity: BillTotalDetail::class, cascade: ['persist'])]
  79. protected ?BillTotalDetail $totalDetail;
  80. #[ORM\OneToOne(targetEntity: File::class, cascade: ['persist'])]
  81. protected ?File $file;
  82. #[ORM\ManyToOne(targetEntity: Odyssee::class, cascade: ['persist'], inversedBy: 'bills')]
  83. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: false, onDelete: 'SET NULL')]
  84. protected Odyssee $odyssee; // TODO: sûr que c'est pas nullable?
  85. #[ORM\ManyToOne(targetEntity: Afi::class, cascade: ['persist'], inversedBy: 'bills')]
  86. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: false, onDelete: 'SET NULL')]
  87. protected Afi $afi;
  88. #[ORM\ManyToOne(targetEntity: CirilCivil::class, cascade: ['persist'], inversedBy: 'bills')]
  89. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: false, onDelete: 'SET NULL')]
  90. protected CirilCivil $cirilCivil;
  91. public function __construct()
  92. {
  93. $this->billLines = new ArrayCollection();
  94. $this->billCredits = new ArrayCollection();
  95. $this->billPayments = new ArrayCollection();
  96. $this->billingIntangibleExcludeDates = new ArrayCollection();
  97. $this->tags = new ArrayCollection();
  98. }
  99. public function getId(): ?int
  100. {
  101. return $this->id;
  102. }
  103. public function getOrganization(): ?Organization
  104. {
  105. return $this->organization;
  106. }
  107. public function setOrganization(?Organization $organization): self
  108. {
  109. $this->organization = $organization;
  110. return $this;
  111. }
  112. /**
  113. * @return Collection<int, BillLine>
  114. */
  115. public function getBillLines(): Collection
  116. {
  117. return $this->billLines;
  118. }
  119. public function addBillLine(BillLine $billLine): self
  120. {
  121. if (!$this->billLines->contains($billLine)) {
  122. $this->billLines[] = $billLine;
  123. $billLine->setBill($this);
  124. }
  125. return $this;
  126. }
  127. public function removeBillLine(BillLine $billLine): self
  128. {
  129. $this->billLines->removeElement($billLine);
  130. return $this;
  131. }
  132. /**
  133. * @return Collection<int, BillCredit>
  134. */
  135. public function getBillCredits(): Collection
  136. {
  137. return $this->billCredits;
  138. }
  139. public function addBillCredit(BillCredit $billCredit): self
  140. {
  141. if (!$this->billCredits->contains($billCredit)) {
  142. $this->billCredits[] = $billCredit;
  143. $billCredit->setBill($this);
  144. }
  145. return $this;
  146. }
  147. public function removeBillCredit(BillCredit $billCredit): self
  148. {
  149. if ($this->billCredits->removeElement($billCredit)) {
  150. // set the owning side to null (unless already changed)
  151. if ($billCredit->getBill() === $this) {
  152. $billCredit->setBill(null);
  153. }
  154. }
  155. return $this;
  156. }
  157. /**
  158. * @return Collection<int, BillPayment>
  159. */
  160. public function getBillPayments(): Collection
  161. {
  162. return $this->billPayments;
  163. }
  164. public function addBillPayment(BillPayment $billPayment): self
  165. {
  166. if (!$this->billPayments->contains($billPayment)) {
  167. $this->billPayments[] = $billPayment;
  168. $billPayment->setBill($this);
  169. }
  170. return $this;
  171. }
  172. public function removeBillPayment(BillPayment $billPayment): self
  173. {
  174. if ($this->billPayments->removeElement($billPayment)) {
  175. // set the owning side to null (unless already changed)
  176. if ($billPayment->getBill() === $this) {
  177. $billPayment->setBill(null);
  178. }
  179. }
  180. return $this;
  181. }
  182. public function getBill(): ?AbstractBillAccounting
  183. {
  184. return $this->bill;
  185. }
  186. public function setBill(?AbstractBillAccounting $bill): self
  187. {
  188. $this->bill = $bill;
  189. return $this;
  190. }
  191. /**
  192. * @return Collection<int, BillingIntangibleExcludeDate>
  193. */
  194. public function getBillingIntangibleExcludeDates(): Collection
  195. {
  196. return $this->billingIntangibleExcludeDates;
  197. }
  198. public function addBillingIntangibleExcludeDate(BillingIntangibleExcludeDate $billingIntangibleExcludeDate): self
  199. {
  200. if (!$this->billingIntangibleExcludeDates->contains($billingIntangibleExcludeDate)) {
  201. $this->billingIntangibleExcludeDates[] = $billingIntangibleExcludeDate;
  202. /* @phpstan-ignore-next-line */
  203. $billingIntangibleExcludeDate->setBill($this);
  204. }
  205. return $this;
  206. }
  207. public function removeBillingIntangibleExcludeDate(BillingIntangibleExcludeDate $billingIntangibleExcludeDate): self
  208. {
  209. if ($this->billingIntangibleExcludeDates->removeElement($billingIntangibleExcludeDate)) {
  210. // set the owning side to null (unless already changed)
  211. if ($billingIntangibleExcludeDate->getBill() === $this) {
  212. $billingIntangibleExcludeDate->setBill(null);
  213. }
  214. }
  215. return $this;
  216. }
  217. public function getPes(): ?Pes
  218. {
  219. return $this->pes;
  220. }
  221. public function setPes(?Pes $pes): self
  222. {
  223. $this->pes = $pes;
  224. return $this;
  225. }
  226. public function getBergerLevrault(): ?BergerLevrault
  227. {
  228. return $this->bergerLevrault;
  229. }
  230. public function setBergerLevrault(?BergerLevrault $bergerLevrault): self
  231. {
  232. $this->bergerLevrault = $bergerLevrault;
  233. return $this;
  234. }
  235. public function getCiril(): ?Ciril
  236. {
  237. return $this->ciril;
  238. }
  239. public function setCiril(?Ciril $ciril): self
  240. {
  241. $this->ciril = $ciril;
  242. return $this;
  243. }
  244. public function getJvs(): ?Jvs
  245. {
  246. return $this->jvs;
  247. }
  248. public function setJvs(?Jvs $jvs): self
  249. {
  250. $this->jvs = $jvs;
  251. return $this;
  252. }
  253. /**
  254. * @return Collection<int, Tagg>
  255. */
  256. public function getTags(): Collection
  257. {
  258. return $this->tags;
  259. }
  260. public function addTag(Tagg $tag): self
  261. {
  262. if (!$this->tags->contains($tag)) {
  263. $this->tags[] = $tag;
  264. $tag->addBillAccounting($this);
  265. }
  266. return $this;
  267. }
  268. public function removeTag(Tagg $tag): self
  269. {
  270. if ($this->tags->removeElement($tag)) {
  271. $tag->removeBillAccounting($this);
  272. }
  273. return $this;
  274. }
  275. public function getAccess(): Access
  276. {
  277. return $this->access;
  278. }
  279. public function setAccess(Access $access): self
  280. {
  281. $this->access = $access;
  282. return $this;
  283. }
  284. public function getAccessDetail(): BillAccessDetail
  285. {
  286. return $this->accessDetail;
  287. }
  288. public function setAccessDetail(BillAccessDetail $accessDetail): self
  289. {
  290. $this->accessDetail = $accessDetail;
  291. return $this;
  292. }
  293. public function getBillPeriod(): BillPeriod
  294. {
  295. return $this->billPeriod;
  296. }
  297. public function setBillPeriod(BillPeriod $billPeriod): self
  298. {
  299. $this->billPeriod = $billPeriod;
  300. return $this;
  301. }
  302. public function getTotalDetail(): BillTotalDetail
  303. {
  304. return $this->totalDetail;
  305. }
  306. public function setTotalDetail(BillTotalDetail $totalDetail): self
  307. {
  308. $this->totalDetail = $totalDetail;
  309. return $this;
  310. }
  311. public function getFile(): File
  312. {
  313. return $this->file;
  314. }
  315. public function setFile(File $file): self
  316. {
  317. $this->file = $file;
  318. return $this;
  319. }
  320. public function getOdyssee(): Odyssee
  321. {
  322. return $this->odyssee;
  323. }
  324. public function setOdyssee(Odyssee $odyssee): self
  325. {
  326. $this->odyssee = $odyssee;
  327. return $this;
  328. }
  329. public function getAfi(): Afi
  330. {
  331. return $this->afi;
  332. }
  333. public function setAfi(Afi $afi): self
  334. {
  335. $this->afi = $afi;
  336. return $this;
  337. }
  338. public function getCirilCivil(): CirilCivil
  339. {
  340. return $this->cirilCivil;
  341. }
  342. public function setCirilCivil(CirilCivil $cirilCivil): self
  343. {
  344. $this->cirilCivil = $cirilCivil;
  345. return $this;
  346. }
  347. }