src/Entity/Charge.php line 17

  1. <?php
  2. namespace App\Entity;
  3. use App\Enum\AllocationMethod;
  4. use App\Repository\ChargeRepository;
  5. use App\Traits\TimeStampTrait;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\DBAL\Types\Types;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use App\Enum\ChargeScope;
  11. use App\Enum\ChargeType;
  12. #[ORM\Entity(repositoryClassChargeRepository::class)]
  13. #[ORM\HasLifecycleCallbacks]
  14. class Charge
  15. {
  16.     use TimeStampTrait;
  17.     #[ORM\Id]
  18.     #[ORM\GeneratedValue]
  19.     #[ORM\Column]
  20.     private ?int $id null;
  21.     #[ORM\Column(type'string'length255enumTypeChargeType::class)]
  22.     private ?ChargeType $chargeType null;
  23.     #[ORM\Column(type'string'length255enumTypeChargeScope::class)]
  24.     private ?ChargeScope $chargeScope null;
  25.     #[ORM\Column(typeTypes::DECIMALprecision10scale2nullabletrue)]
  26.     private ?string $amount null;
  27.     #[ORM\ManyToOne(inversedBy'charges')]
  28.     private ?Habitat $habitat null;
  29.     #[ORM\ManyToOne(inversedBy'charges')]
  30.     private ?Residence $residence null;
  31.     #[ORM\OneToMany(mappedBy'charge'targetEntityChargeAllocation::class)]
  32.     private Collection $chargeAllocations;
  33.     #[ORM\Column(length255nullabletrue)]
  34.     private ?string $description null;
  35.     #[ORM\Column(type'string'nullabletrueenumTypeAllocationMethod::class)]
  36.     private ?AllocationMethod $allocationMethod null;
  37.     #[ORM\Column(length25nullabletrue)]
  38.     private ?string $month null;
  39.     #[ORM\Column(length25nullabletrue)]
  40.     private ?string $year null;
  41.     #[ORM\ManyToOne(inversedBy'charges')]
  42.     private ?Location $Location null;
  43.     #[ORM\ManyToOne(inversedBy'charges')]
  44.     private ?Entreprise $marchand null;
  45.     #[ORM\Column(length255nullabletrue)]
  46.     private ?string $code null;
  47.     #[ORM\Column]
  48.     private ?bool $paid null;
  49.     #[ORM\Column(nullabletrue)]
  50.     private ?\DateTime $paidAt null;
  51.     #[ORM\ManyToOne(cascade: ['all'], fetch'EAGER'inversedBy'charges',)]
  52.     private ?Payment $payment null;
  53.     public function __construct()
  54.     {
  55.         $this->chargeAllocations = new ArrayCollection();
  56.     }
  57.     public function getId(): ?int
  58.     {
  59.         return $this->id;
  60.     }
  61.     public function getChargeType(): ?ChargeType
  62.     {
  63.         return $this->chargeType;
  64.     }
  65.     public function setChargeType(?ChargeType $chargeType): self
  66.     {
  67.         $this->chargeType $chargeType;
  68.         return $this;
  69.     }
  70.     public function getChargeScope(): ?ChargeScope
  71.     {
  72.         return $this->chargeScope;
  73.     }
  74.     public function setChargeScope(?ChargeScope $scope): self
  75.     {
  76.         $this->chargeScope $scope;
  77.         return $this;
  78.     }
  79.     public function getAmount(): ?string
  80.     {
  81.         return $this->amount;
  82.     }
  83.     public function setAmount(?string $amount): static
  84.     {
  85.         $this->amount $amount;
  86.         return $this;
  87.     }
  88.     public function getHabitat(): ?Habitat
  89.     {
  90.         return $this->habitat;
  91.     }
  92.     public function setHabitat(?Habitat $habitat): static
  93.     {
  94.         $this->habitat $habitat;
  95.         return $this;
  96.     }
  97.     public function getResidence(): ?Residence
  98.     {
  99.         return $this->residence;
  100.     }
  101.     public function setResidence(?Residence $residence): static
  102.     {
  103.         $this->residence $residence;
  104.         return $this;
  105.     }
  106.     /**
  107.      * @return Collection<int, ChargeAllocation>
  108.      */
  109.     public function getChargeAllocations(): Collection
  110.     {
  111.         return $this->chargeAllocations;
  112.     }
  113.     public function addChargeAllocation(ChargeAllocation $chargeAllocation): static
  114.     {
  115.         if (!$this->chargeAllocations->contains($chargeAllocation)) {
  116.             $this->chargeAllocations->add($chargeAllocation);
  117.             $chargeAllocation->setCharge($this);
  118.         }
  119.         return $this;
  120.     }
  121.     public function removeChargeAllocation(ChargeAllocation $chargeAllocation): static
  122.     {
  123.         if ($this->chargeAllocations->removeElement($chargeAllocation)) {
  124.             // set the owning side to null (unless already changed)
  125.             if ($chargeAllocation->getCharge() === $this) {
  126.                 $chargeAllocation->setCharge(null);
  127.             }
  128.         }
  129.         return $this;
  130.     }
  131.     public function getDescription(): ?string
  132.     {
  133.         return $this->description;
  134.     }
  135.     public function setDescription(?string $description): static
  136.     {
  137.         $this->description $description;
  138.         return $this;
  139.     }
  140.     public function getAllocationMethod(): ?AllocationMethod
  141.     {
  142.         return $this->allocationMethod;
  143.     }
  144.     public function setAllocationMethod(?AllocationMethod $method): self
  145.     {
  146.         $this->allocationMethod $method;
  147.         return $this;
  148.     }
  149.     public function getMonth(): ?string
  150.     {
  151.         return $this->month;
  152.     }
  153.     public function setMonth(?string $month): static
  154.     {
  155.         $this->month $month;
  156.         return $this;
  157.     }
  158.     public function getYear(): ?string
  159.     {
  160.         return $this->year;
  161.     }
  162.     public function setYear(?string $year): static
  163.     {
  164.         $this->year $year;
  165.         return $this;
  166.     }
  167.     public function getLocation(): ?Location
  168.     {
  169.         return $this->Location;
  170.     }
  171.     public function setLocation(?Location $Location): static
  172.     {
  173.         $this->Location $Location;
  174.         return $this;
  175.     }
  176.     public function getMarchand(): ?Entreprise
  177.     {
  178.         return $this->marchand;
  179.     }
  180.     public function setMarchand(?Entreprise $marchand): static
  181.     {
  182.         $this->marchand $marchand;
  183.         return $this;
  184.     }
  185.     public function getCode(): ?string
  186.     {
  187.         return $this->code;
  188.     }
  189.     public function setCode(?string $code): static
  190.     {
  191.         $this->code $code;
  192.         return $this;
  193.     }
  194.     public function isPaid(): ?bool
  195.     {
  196.         return $this->paid;
  197.     }
  198.     public function setPaid(bool $paid): static
  199.     {
  200.         $this->paid $paid;
  201.         return $this;
  202.     }
  203.     public function getPaidAt(): ?\DateTime
  204.     {
  205.         return $this->paidAt;
  206.     }
  207.     public function setPaidAt(?\DateTime $paidAt): static
  208.     {
  209.         $this->paidAt $paidAt;
  210.         return $this;
  211.     }
  212.     public function getPayment(): ?Payment
  213.     {
  214.         return $this->payment;
  215.     }
  216.     public function setPayment(?Payment $payment): static
  217.     {
  218.         $this->payment $payment;
  219.         return $this;
  220.     }
  221. }