src/Entity/Currency.php line 14

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CurrencyRepository;
  4. use App\Trait\DateTrait;
  5. use DateTimeImmutable;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. #[ORM\Entity(repositoryClass: CurrencyRepository::class)]
  11. class Currency
  12. {
  13.     use DateTrait;
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     #[Groups(['article:list', 'establishment:list', 'order:list'])]
  18.     private ?int $id = null;
  19.     #[ORM\Column(length: 255)]
  20.     #[Groups(['article:list', 'establishment:list', 'order:list'])]
  21.     private ?string $name = null;
  22.     #[ORM\Column(length: 3)]
  23.     #[Groups(['article:list', 'establishment:list', 'order:list'])]
  24.     private ?string $min = null;
  25.     #[ORM\Column(length: 10)]
  26.     #[Groups(['article:list', 'establishment:list', 'order:list'])]
  27.     private ?string $symbol = null;
  28.     #[ORM\Column]
  29.     private ?bool $isDefault = false;
  30.     #[ORM\ManyToOne(inversedBy: 'currencies')]
  31.     #[ORM\JoinColumn(nullable: true)]
  32.     private ?Establishment $establishment = null;
  33.     #[ORM\OneToMany(mappedBy: 'currency', targetEntity: WalletOperation::class, orphanRemoval: true)]
  34.     private Collection $walletOperations;
  35.     #[ORM\Column(options: ['default' => true])]
  36.     private ?bool $onFacturation = true;
  37.     public function __construct()
  38.     {
  39.         if (is_null($this->createdAt)) $this->createdAt = new DateTimeImmutable();
  40.         $this->updatedAt = new DateTimeImmutable();
  41.         $this->walletOperations = new ArrayCollection();
  42.     }
  43.     public function getId(): ?int
  44.     {
  45.         return $this->id;
  46.     }
  47.     public function getName(): ?string
  48.     {
  49.         return $this->name;
  50.     }
  51.     public function setName(string $name): self
  52.     {
  53.         $this->name = $name;
  54.         return $this;
  55.     }
  56.     public function getMin(): ?string
  57.     {
  58.         return $this->min;
  59.     }
  60.     public function setMin(string $min): self
  61.     {
  62.         $this->min = $min;
  63.         return $this;
  64.     }
  65.     public function getSymbol(): ?string
  66.     {
  67.         return $this->symbol;
  68.     }
  69.     public function setSymbol(string $symbol): self
  70.     {
  71.         $this->symbol = $symbol;
  72.         return $this;
  73.     }
  74.     public function __toString(): string
  75.     {
  76.         return $this->min;
  77.     }
  78.     public function isIsDefault(): ?bool
  79.     {
  80.         return $this->isDefault;
  81.     }
  82.     public function setIsDefault(bool $isDefault): self
  83.     {
  84.         $this->isDefault = $isDefault;
  85.         return $this;
  86.     }
  87.     public function getEstablishment(): ?Establishment
  88.     {
  89.         return $this->establishment;
  90.     }
  91.     public function setEstablishment(?Establishment $establishment): static
  92.     {
  93.         $this->establishment = $establishment;
  94.         return $this;
  95.     }
  96.     /**
  97.      * @return Collection<int, WalletOperation>
  98.      */
  99.     public function getWalletOperations(): Collection
  100.     {
  101.         return $this->walletOperations;
  102.     }
  103.     public function addWalletOperation(WalletOperation $walletOperation): static
  104.     {
  105.         if (!$this->walletOperations->contains($walletOperation)) {
  106.             $this->walletOperations->add($walletOperation);
  107.             $walletOperation->setCurrency($this);
  108.         }
  109.         return $this;
  110.     }
  111.     public function removeWalletOperation(WalletOperation $walletOperation): static
  112.     {
  113.         if ($this->walletOperations->removeElement($walletOperation)) {
  114.             // set the owning side to null (unless already changed)
  115.             if ($walletOperation->getCurrency() === $this) {
  116.                 $walletOperation->setCurrency(null);
  117.             }
  118.         }
  119.         return $this;
  120.     }
  121.     public function isOnFacturation(): ?bool
  122.     {
  123.         return $this->onFacturation;
  124.     }
  125.     public function setOnFacturation(bool $onFacturation): static
  126.     {
  127.         $this->onFacturation = $onFacturation;
  128.         return $this;
  129.     }
  130. }