AbstractBillAccounting.php 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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\Entity]
  19. #[ORM\Table(name: 'BillAccounting')]
  20. #[ORM\InheritanceType('SINGLE_TABLE')]
  21. #[ORM\DiscriminatorColumn(name: 'discr', type: 'string')]
  22. #[ORM\DiscriminatorMap(
  23. [
  24. 'billaccounting' => BillAccounting::class,
  25. 'bill' => Bill::class,
  26. 'billcredit' => BillCredit::class,
  27. 'advancepayment' => AdvancePayment::class,
  28. ]
  29. )]
  30. class AbstractBillAccounting
  31. {
  32. #[ORM\Id]
  33. #[ORM\Column]
  34. #[ORM\GeneratedValue]
  35. protected ?int $id = null;
  36. #[ORM\ManyToOne(targetEntity: Organization::class)]
  37. #[ORM\JoinColumn(nullable: true)]
  38. protected ?Organization $organization;
  39. #[ORM\ManyToOne(inversedBy: 'billCredits')]
  40. #[ORM\JoinColumn(nullable: true)]
  41. protected ?Bill $bill;
  42. /** @var Collection<int, BillingIntangibleExcludeDate> */
  43. #[ORM\OneToMany(targetEntity: BillingIntangibleExcludeDate::class, mappedBy: 'bill', 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. /** @var Collection<int, Tagg> */
  58. #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'billAccountings', cascade: ['persist'])]
  59. #[ORM\JoinTable(name: 'tag_billAccounting')]
  60. #[ORM\JoinColumn(name: 'billAccounting_id', referencedColumnName: 'id')]
  61. #[ORM\InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id')]
  62. protected Collection $tags;
  63. #[ORM\ManyToOne(targetEntity: Access::class, cascade: [], inversedBy: 'bills')]
  64. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: false, onDelete: 'SET NULL')]
  65. protected Access $access;
  66. #[ORM\OneToOne(targetEntity: BillAccessDetail::class, cascade: ['persist'])]
  67. protected ?BillAccessDetail $accessDetail;
  68. #[ORM\OneToOne(targetEntity: BillPeriod::class, cascade: ['persist'])]
  69. protected ?BillPeriod $billPeriod;
  70. #[ORM\OneToOne(targetEntity: BillTotalDetail::class, cascade: ['persist'])]
  71. protected ?BillTotalDetail $totalDetail;
  72. #[ORM\OneToOne(targetEntity: File::class, cascade: ['persist'])]
  73. protected ?File $file;
  74. #[ORM\ManyToOne(targetEntity: Odyssee::class, cascade: ['persist'], inversedBy: 'bills')]
  75. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: false, onDelete: 'SET NULL')]
  76. protected Odyssee $odyssee; // TODO: sûr que c'est pas nullable?
  77. #[ORM\ManyToOne(targetEntity: Afi::class, cascade: ['persist'], inversedBy: 'bills')]
  78. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: false, onDelete: 'SET NULL')]
  79. protected Afi $afi;
  80. #[ORM\ManyToOne(targetEntity: CirilCivil::class, cascade: ['persist'], inversedBy: 'bills')]
  81. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: false, onDelete: 'SET NULL')]
  82. protected CirilCivil $cirilCivil;
  83. public function __construct()
  84. {
  85. $this->billingIntangibleExcludeDates = new ArrayCollection();
  86. $this->tags = new ArrayCollection();
  87. }
  88. public function getId(): ?int
  89. {
  90. return $this->id;
  91. }
  92. public function getOrganization(): ?Organization
  93. {
  94. return $this->organization;
  95. }
  96. public function setOrganization(?Organization $organization): self
  97. {
  98. $this->organization = $organization;
  99. return $this;
  100. }
  101. public function getBill(): ?Bill
  102. {
  103. return $this->bill;
  104. }
  105. public function setBill(?Bill $bill): self
  106. {
  107. $this->bill = $bill;
  108. return $this;
  109. }
  110. /**
  111. * @return Collection<int, BillingIntangibleExcludeDate>
  112. */
  113. public function getBillingIntangibleExcludeDates(): Collection
  114. {
  115. return $this->billingIntangibleExcludeDates;
  116. }
  117. public function addBillingIntangibleExcludeDate(BillingIntangibleExcludeDate $billingIntangibleExcludeDate): self
  118. {
  119. if (!$this->billingIntangibleExcludeDates->contains($billingIntangibleExcludeDate)) {
  120. $this->billingIntangibleExcludeDates[] = $billingIntangibleExcludeDate;
  121. $billingIntangibleExcludeDate->setBill($this);
  122. }
  123. return $this;
  124. }
  125. public function removeBillingIntangibleExcludeDate(BillingIntangibleExcludeDate $billingIntangibleExcludeDate): self
  126. {
  127. if ($this->billingIntangibleExcludeDates->removeElement($billingIntangibleExcludeDate)) {
  128. // set the owning side to null (unless already changed)
  129. if ($billingIntangibleExcludeDate->getBill() === $this) {
  130. $billingIntangibleExcludeDate->setBill(null);
  131. }
  132. }
  133. return $this;
  134. }
  135. public function getPes(): ?Pes
  136. {
  137. return $this->pes;
  138. }
  139. public function setPes(?Pes $pes): self
  140. {
  141. $this->pes = $pes;
  142. return $this;
  143. }
  144. public function getBergerLevrault(): ?BergerLevrault
  145. {
  146. return $this->bergerLevrault;
  147. }
  148. public function setBergerLevrault(?BergerLevrault $bergerLevrault): self
  149. {
  150. $this->bergerLevrault = $bergerLevrault;
  151. return $this;
  152. }
  153. public function getCiril(): ?Ciril
  154. {
  155. return $this->ciril;
  156. }
  157. public function setCiril(?Ciril $ciril): self
  158. {
  159. $this->ciril = $ciril;
  160. return $this;
  161. }
  162. public function getJvs(): ?Jvs
  163. {
  164. return $this->jvs;
  165. }
  166. public function setJvs(?Jvs $jvs): self
  167. {
  168. $this->jvs = $jvs;
  169. return $this;
  170. }
  171. /**
  172. * @return Collection<int, Tagg>
  173. */
  174. public function getTags(): Collection
  175. {
  176. return $this->tags;
  177. }
  178. public function addTag(Tagg $tag): self
  179. {
  180. if (!$this->tags->contains($tag)) {
  181. $this->tags[] = $tag;
  182. $tag->addBillAccounting($this);
  183. }
  184. return $this;
  185. }
  186. public function removeTag(Tagg $tag): self
  187. {
  188. if ($this->tags->removeElement($tag)) {
  189. $tag->removeBillAccounting($this);
  190. }
  191. return $this;
  192. }
  193. public function getAccess(): Access
  194. {
  195. return $this->access;
  196. }
  197. public function setAccess(Access $access): self
  198. {
  199. $this->access = $access;
  200. return $this;
  201. }
  202. public function getAccessDetail(): BillAccessDetail
  203. {
  204. return $this->accessDetail;
  205. }
  206. public function setAccessDetail(BillAccessDetail $accessDetail): self
  207. {
  208. $this->accessDetail = $accessDetail;
  209. return $this;
  210. }
  211. public function getBillPeriod(): BillPeriod
  212. {
  213. return $this->billPeriod;
  214. }
  215. public function setBillPeriod(BillPeriod $billPeriod): self
  216. {
  217. $this->billPeriod = $billPeriod;
  218. return $this;
  219. }
  220. public function getTotalDetail(): BillTotalDetail
  221. {
  222. return $this->totalDetail;
  223. }
  224. public function setTotalDetail(BillTotalDetail $totalDetail): self
  225. {
  226. $this->totalDetail = $totalDetail;
  227. return $this;
  228. }
  229. public function getFile(): File
  230. {
  231. return $this->file;
  232. }
  233. public function setFile(File $file): self
  234. {
  235. $this->file = $file;
  236. return $this;
  237. }
  238. public function getOdyssee(): Odyssee
  239. {
  240. return $this->odyssee;
  241. }
  242. public function setOdyssee(Odyssee $odyssee): self
  243. {
  244. $this->odyssee = $odyssee;
  245. return $this;
  246. }
  247. public function getAfi(): Afi
  248. {
  249. return $this->afi;
  250. }
  251. public function setAfi(Afi $afi): self
  252. {
  253. $this->afi = $afi;
  254. return $this;
  255. }
  256. public function getCirilCivil(): CirilCivil
  257. {
  258. return $this->cirilCivil;
  259. }
  260. public function setCirilCivil(CirilCivil $cirilCivil): self
  261. {
  262. $this->cirilCivil = $cirilCivil;
  263. return $this;
  264. }
  265. }