BillingSetting.php 3.5 KB

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