BillingSetting.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Billing;
  4. use ApiPlatform\Metadata\ApiResource;
  5. use App\Entity\Organization\Organization;
  6. use App\Repository\Billing\BillingSettingRepository;
  7. // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use JetBrains\PhpStorm\Pure;
  12. /**
  13. * Paramètres globaux d'une Organization concernant la facturation.
  14. */
  15. #[ApiResource(operations: [])]
  16. // #[Auditable]
  17. #[ORM\Entity(repositoryClass: BillingSettingRepository::class)]
  18. class BillingSetting
  19. {
  20. #[ORM\Id]
  21. #[ORM\Column]
  22. #[ORM\GeneratedValue]
  23. private ?int $id = null;
  24. #[ORM\OneToOne(inversedBy: 'billingSetting')]
  25. #[ORM\JoinColumn(nullable: false)]
  26. private Organization $organization;
  27. /** @var Collection<int, ResidenceArea> */
  28. #[ORM\OneToMany(targetEntity: ResidenceArea::class, mappedBy: 'billingSetting', cascade: ['persist'], orphanRemoval: true)]
  29. private Collection $residenceAreas;
  30. #[ORM\Column(options: ['default' => false])]
  31. private bool $applyVat = false;
  32. /** @var Collection<int, FamilyQuotient> */
  33. #[ORM\OneToMany(targetEntity: FamilyQuotient::class, mappedBy: 'billingSetting', cascade: ['persist'], orphanRemoval: true)]
  34. private Collection $familyQuotients;
  35. #[ORM\OneToOne(targetEntity: BillingSettingRent::class, mappedBy: 'billingSetting', cascade: ['persist', 'remove'])]
  36. protected ?BillingSettingRent $billingSettingRent;
  37. #[Pure]
  38. public function __construct()
  39. {
  40. $this->residenceAreas = new ArrayCollection();
  41. $this->familyQuotients = new ArrayCollection();
  42. }
  43. public function getId(): ?int
  44. {
  45. return $this->id;
  46. }
  47. public function getOrganization(): Organization
  48. {
  49. return $this->organization;
  50. }
  51. public function setOrganization(Organization $organization): self
  52. {
  53. $this->organization = $organization;
  54. return $this;
  55. }
  56. public function getApplyVat(): bool
  57. {
  58. return $this->applyVat;
  59. }
  60. public function setApplyVat(bool $applyVat): self
  61. {
  62. $this->applyVat = $applyVat;
  63. return $this;
  64. }
  65. public function getResidenceAreas(): Collection
  66. {
  67. return $this->residenceAreas;
  68. }
  69. public function addResidenceArea(ResidenceArea $residenceArea): self
  70. {
  71. if (!$this->residenceAreas->contains($residenceArea)) {
  72. $this->residenceAreas[] = $residenceArea;
  73. $residenceArea->setBillingSetting($this);
  74. }
  75. return $this;
  76. }
  77. public function removeResidenceArea(ResidenceArea $residenceArea): self
  78. {
  79. if ($this->residenceAreas->removeElement($residenceArea)) {
  80. // set the owning side to null (unless already changed)
  81. if ($residenceArea->getBillingSetting() === $this) {
  82. $residenceArea->setBillingSetting(null);
  83. }
  84. }
  85. return $this;
  86. }
  87. /**
  88. * @return Collection<int, FamilyQuotient>
  89. */
  90. public function getFamilyQuotients(): Collection
  91. {
  92. return $this->familyQuotients;
  93. }
  94. public function addFamilyQuotient(FamilyQuotient $familyQuotient): self
  95. {
  96. if (!$this->familyQuotients->contains($familyQuotient)) {
  97. $this->familyQuotients[] = $familyQuotient;
  98. $familyQuotient->setBillingSetting($this);
  99. }
  100. return $this;
  101. }
  102. public function removeFamilyQuotient(FamilyQuotient $familyQuotient): self
  103. {
  104. if ($this->familyQuotients->removeElement($familyQuotient)) {
  105. // set the owning side to null (unless already changed)
  106. if ($familyQuotient->getBillingSetting() === $this) {
  107. $familyQuotient->setBillingSetting(null);
  108. }
  109. }
  110. return $this;
  111. }
  112. public function getBillingSettingRent(): ?BillingSettingRent
  113. {
  114. return $this->billingSettingRent;
  115. }
  116. public function setBillingSettingRent(?BillingSettingRent $billingSettingRent): self
  117. {
  118. $this->billingSettingRent = $billingSettingRent;
  119. return $this;
  120. }
  121. }