BillingSetting.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Billing;
  4. use ApiPlatform\Core\Annotation\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. #[Auditable]
  13. #[ApiResource(
  14. collectionOperations: [],
  15. itemOperations: ['get']
  16. )]
  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. #[ORM\OneToMany( mappedBy: 'billingSetting', targetEntity: ResidenceArea::class, cascade: ['persist'], orphanRemoval: true)]
  28. private Collection $residenceAreas;
  29. #[ORM\Column(options: ['default' => false])]
  30. private bool $applyVat = false;
  31. #[ORM\OneToMany(mappedBy: 'billingSetting', targetEntity: FamilyQuotient::class, cascade: ['persist'], orphanRemoval: true)]
  32. private Collection $familyQuotients;
  33. #[Pure] public function __construct()
  34. {
  35. $this->residenceAreas = new ArrayCollection();
  36. $this->familyQuotients = new ArrayCollection();
  37. }
  38. public function getId(): ?int
  39. {
  40. return $this->id;
  41. }
  42. public function getOrganization(): Organization
  43. {
  44. return $this->organization;
  45. }
  46. public function setOrganization(Organization $organization): self
  47. {
  48. $this->organization = $organization;
  49. return $this;
  50. }
  51. public function getApplyVat(): bool
  52. {
  53. return $this->applyVat;
  54. }
  55. public function setApplyVat(bool $applyVat): self
  56. {
  57. $this->applyVat = $applyVat;
  58. return $this;
  59. }
  60. public function getResidenceAreas(): Collection
  61. {
  62. return $this->residenceAreas;
  63. }
  64. public function addResidenceArea(ResidenceArea $residenceArea): self
  65. {
  66. if (!$this->residenceAreas->contains($residenceArea)) {
  67. $this->residenceAreas[] = $residenceArea;
  68. $residenceArea->setBillingSetting($this);
  69. }
  70. return $this;
  71. }
  72. public function removeResidenceArea(ResidenceArea $residenceArea): self
  73. {
  74. if ($this->residenceAreas->removeElement($residenceArea)) {
  75. // set the owning side to null (unless already changed)
  76. if ($residenceArea->getBillingSetting() === $this) {
  77. $residenceArea->setBillingSetting(null);
  78. }
  79. }
  80. return $this;
  81. }
  82. /**
  83. * @return Collection<int, FamilyQuotient>
  84. */
  85. public function getFamilyQuotients(): Collection
  86. {
  87. return $this->familyQuotients;
  88. }
  89. public function addFamilyQuotient(FamilyQuotient $familyQuotient): self
  90. {
  91. if (!$this->familyQuotients->contains($familyQuotient)) {
  92. $this->familyQuotients[] = $familyQuotient;
  93. $familyQuotient->setBillingSetting($this);
  94. }
  95. return $this;
  96. }
  97. public function removeFamilyQuotient(FamilyQuotient $familyQuotient): self
  98. {
  99. if ($this->familyQuotients->removeElement($familyQuotient)) {
  100. // set the owning side to null (unless already changed)
  101. if ($familyQuotient->getBillingSetting() === $this) {
  102. $familyQuotient->setBillingSetting(null);
  103. }
  104. }
  105. return $this;
  106. }
  107. }