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. #[ORM\OneToMany(mappedBy: 'bill', targetEntity: BillLine::class, cascade: ['persist'], orphanRemoval: true)]
  39. protected Collection $billLines;
  40. #[ORM\OneToMany(mappedBy: 'bill', targetEntity: BillCredit::class, cascade: ['persist'], orphanRemoval: true)]
  41. protected Collection $billCredits;
  42. #[ORM\OneToMany(mappedBy: 'bill', targetEntity: BillPayment::class, cascade: ['persist'], orphanRemoval: true)]
  43. protected Collection $billPayments;
  44. #[ORM\ManyToOne(inversedBy: 'billCredits')]
  45. #[ORM\JoinColumn(nullable: true)]
  46. protected BillAccounting $bill;
  47. #[ORM\OneToMany(mappedBy: 'bill', targetEntity: BillingIntangibleExcludeDate::class, cascade: ['persist'], orphanRemoval: true)]
  48. protected Collection $billingIntangibleExcludeDates;
  49. #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'bills')]
  50. #[ORM\JoinColumn(nullable: true)]
  51. protected Pes $pes;
  52. #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'bills')]
  53. #[ORM\JoinColumn(nullable: true)]
  54. protected BergerLevrault $bergerLevrault;
  55. #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'bills')]
  56. #[ORM\JoinColumn(nullable: true)]
  57. protected Ciril $ciril;
  58. #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'bills')]
  59. #[ORM\JoinColumn(nullable: true)]
  60. protected Jvs $jvs;
  61. #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'billAccountings', cascade: ['persist'])]
  62. #[ORM\JoinTable(name: 'tag_billAccounting')]
  63. #[ORM\JoinColumn(name: 'billAccounting_id', referencedColumnName: 'id')]
  64. #[ORM\InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id')]
  65. protected Collection $tags;
  66. #[ORM\ManyToOne(targetEntity: Access::class, cascade: [], inversedBy: 'bills')]
  67. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: false, onDelete: 'SET NULL')]
  68. protected Access $access;
  69. #[ORM\OneToOne(targetEntity: BillAccessDetail::class, cascade: ['persist'])]
  70. protected BillAccessDetail $accessDetail;
  71. #[ORM\OneToOne(targetEntity: BillPeriod::class, cascade: ['persist'])]
  72. protected BillPeriod $billPeriod;
  73. #[ORM\OneToOne(targetEntity: BillTotalDetail::class, cascade: ['persist'])]
  74. protected BillTotalDetail $totalDetail;
  75. #[ORM\OneToOne(targetEntity: File::class, cascade: ['persist'])]
  76. protected File $file;
  77. #[ORM\ManyToOne(targetEntity: Odyssee::class, inversedBy: 'bills', cascade: ['persist'])]
  78. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: false, onDelete: 'SET NULL')]
  79. protected Odyssee $odyssee; // TODO: sûr que c'est pas nullable?
  80. #[ORM\ManyToOne(targetEntity: Afi::class, inversedBy: 'bills', cascade: ['persist'])]
  81. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: false, onDelete: 'SET NULL')]
  82. protected Afi $afi;
  83. #[ORM\ManyToOne(targetEntity: CirilCivil::class, inversedBy: 'bills', cascade: ['persist'])]
  84. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: false, onDelete: 'SET NULL')]
  85. protected CirilCivil $cirilCivil;
  86. public function __construct()
  87. {
  88. $this->billLines = new ArrayCollection();
  89. $this->billCredits = new ArrayCollection();
  90. $this->billPayments = new ArrayCollection();
  91. $this->billingIntangibleExcludeDates = new ArrayCollection();
  92. $this->tags = new ArrayCollection();
  93. }
  94. public function getId(): ?int
  95. {
  96. return $this->id;
  97. }
  98. public function getOrganization(): ?Organization
  99. {
  100. return $this->organization;
  101. }
  102. public function setOrganization(?Organization $organization): self
  103. {
  104. $this->organization = $organization;
  105. return $this;
  106. }
  107. /**
  108. * @return Collection<int, BillLine>
  109. */
  110. public function getBillLines(): Collection
  111. {
  112. return $this->billLines;
  113. }
  114. public function addBillLine(BillLine $billLine): self
  115. {
  116. if (!$this->billLines->contains($billLine)) {
  117. $this->billLines[] = $billLine;
  118. $billLine->setBill($this);
  119. }
  120. return $this;
  121. }
  122. public function removeBillLine(BillLine $billLine): self
  123. {
  124. if ($this->billLines->removeElement($billLine)) {
  125. // set the owning side to null (unless already changed)
  126. if ($billLine->getBill() === $this) {
  127. $billLine->setBill(null);
  128. }
  129. }
  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(): ?self
  183. {
  184. return $this->bill;
  185. }
  186. public function setBill(?self $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. }