|
|
@@ -4,9 +4,13 @@ declare(strict_types=1);
|
|
|
namespace App\Entity\Billing;
|
|
|
|
|
|
use ApiPlatform\Core\Annotation\ApiResource;
|
|
|
+use ApiPlatform\Core\Annotation\ApiSubresource;
|
|
|
use App\Entity\Organization\Organization;
|
|
|
use App\Repository\Billing\BillingSettingRepository;
|
|
|
+use Doctrine\Common\Collections\ArrayCollection;
|
|
|
+use Doctrine\Common\Collections\Collection;
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
+use JetBrains\PhpStorm\Pure;
|
|
|
|
|
|
#[ApiResource(
|
|
|
collectionOperations: [],
|
|
|
@@ -24,9 +28,17 @@ class BillingSetting
|
|
|
#[ORM\JoinColumn(nullable: false)]
|
|
|
private Organization $organization;
|
|
|
|
|
|
+ #[ORM\OneToMany( mappedBy: 'billingSetting', targetEntity: ResidenceArea::class, cascade: ['persist'], orphanRemoval: true)]
|
|
|
+ private Collection $residenceAreas;
|
|
|
+
|
|
|
#[ORM\Column(options: ['default' => false])]
|
|
|
private bool $applyVat = false;
|
|
|
|
|
|
+ #[Pure] public function __construct()
|
|
|
+ {
|
|
|
+ $this->residenceAreas = new ArrayCollection();
|
|
|
+ }
|
|
|
+
|
|
|
public function getId(): ?int
|
|
|
{
|
|
|
return $this->id;
|
|
|
@@ -56,4 +68,31 @@ class BillingSetting
|
|
|
|
|
|
return $this;
|
|
|
}
|
|
|
+
|
|
|
+ public function getResidenceAreas(): Collection
|
|
|
+ {
|
|
|
+ return $this->residenceAreas;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function addResidenceArea(ResidenceArea $residenceArea): self
|
|
|
+ {
|
|
|
+ if (!$this->residenceAreas->contains($residenceArea)) {
|
|
|
+ $this->residenceAreas[] = $residenceArea;
|
|
|
+ $residenceArea->setBillingSetting($this);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function removeResidenceArea(ResidenceArea $residenceArea): self
|
|
|
+ {
|
|
|
+ if ($this->residenceAreas->removeElement($residenceArea)) {
|
|
|
+ // set the owning side to null (unless already changed)
|
|
|
+ if ($residenceArea->getBillingSetting() === $this) {
|
|
|
+ $residenceArea->setBillingSetting(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
}
|