src/Entity/Agreements.php line 35

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\AgreementsRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use ApiPlatform\Metadata\ApiFilter;
  10. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. use Symfony\Component\Serializer\Annotation\MaxDepth;
  13. #[ORM\Entity(repositoryClassAgreementsRepository::class)]
  14. #[ApiResource(
  15.     normalizationContext: ['groups' => ['agreements:read']],
  16.     denormalizationContext: ['groups' => ['agreements:write']],
  17.     order: ['id' => 'DESC']
  18. )]
  19. #[ApiFilter(
  20.     SearchFilter::class, 
  21.     properties: [
  22.  
  23.         'name' => 'ipartial'
  24.         'account.id' => 'exact'
  25.         'virtual' => 'exact'
  26.         'account.user.id' => 'exact'
  27.         'account.name' => 'ipartial'
  28.         'account.manager' => 'exact'
  29.     ]
  30. )]
  31. class Agreements
  32. {
  33.     #[ORM\Id]
  34.     #[ORM\GeneratedValue]
  35.     #[Groups(['agreements:read''agreements:write''agreements:read''order:read''order_product:read''price:read'])]
  36.     #[ORM\Column]
  37.     private ?int $id null;
  38.     #[Groups(['agreements:read''agreements:write''agreements:read''order:read''order_product:read''price:read'])]
  39.     #[ORM\Column(length255nullabletrue)]
  40.     private ?string $name null;
  41.     #[Groups(['agreements:read''agreements:write''agreements:read''order:read''order_product:read''price:read'])]
  42.     #[ORM\Column(length20nullabletrue)]
  43.     private ?string $code1c null;
  44.     #[Groups(['agreements:read''agreements:write'])]
  45.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  46.     private ?\DateTimeInterface $dateEntered null;
  47.     #[Groups(['agreements:read''agreements:write'])]
  48.     #[ORM\Column(length20nullabletrue)]
  49.     private ?string $type null;
  50.     #[MaxDepth(1)]
  51.     #[Groups(['agreements:read''agreements:write'])]
  52.     #[ORM\ManyToOne(inversedBy'organization')]
  53.     private ?Accounts $organization null;
  54.     #[MaxDepth(1)]
  55.     #[Groups(['agreements:read''agreements:write'])]
  56.     #[ORM\ManyToOne(inversedBy'agreements')]
  57.     private ?Accounts $account null;
  58.     #[Groups(['agreements:read''agreements:write'])]
  59.     #[ORM\Column(length20nullabletrue)]
  60.     private ?string $curency null;
  61.     #[Groups(['agreements:read''agreements:write'])]
  62.     #[ORM\Column(nullabletrue)]
  63.     private ?float $maxBorg 0;
  64.     #[Groups(['agreements:read''agreements:write'])]
  65.     #[ORM\Column(length100nullabletrue)]
  66.     private ?string $typePayment null;
  67.     #[Groups(['agreements:read''agreements:write'])]
  68.     #[ORM\Column(nullabletrue)]
  69.     private ?bool $paymentInCash null;
  70.     #[Groups(['agreements:read''agreements:write'])]
  71.     #[ORM\Column(nullabletrue)]
  72.     private ?int $dayDelay null;
  73.     #[MaxDepth(1)]
  74.     #[Groups(['agreements:read''agreements:write'])]
  75.     #[ORM\OneToMany(mappedBy'agreement'targetEntityCalculations::class, cascade:['persist'])]
  76.     private Collection $calculations;
  77.     #[MaxDepth(1)]
  78.     #[ORM\OneToMany(mappedBy'agreement'targetEntityOrders::class)]
  79.     private Collection $orders;
  80.     #[MaxDepth(1)]
  81.     #[Groups(['agreements:read''order:read'])]
  82.     #[ORM\OneToMany(mappedBy'agreement'targetEntityPrices::class)]
  83.     private Collection $prices;
  84.     #[MaxDepth(1)]
  85.     #[Groups(['agreements:read''order:read'])]
  86.     #[ORM\OneToMany(mappedBy'virtualAgreementSpecfication'targetEntityAccounts::class)]
  87.     private Collection $accounts;
  88.     #[MaxDepth(1)]
  89.     #[Groups(['agreements:read''agreements:write''order:read'])]
  90.     #[ORM\Column(nullabletrue)]
  91.     private ?bool $virtual null;
  92.     public function __construct()
  93.     {
  94.         $this->calculations = new ArrayCollection();
  95.         $this->orders = new ArrayCollection();
  96.         $this->prices = new ArrayCollection();
  97.         $this->accounts = new ArrayCollection();
  98.     }
  99.     public function getId(): ?int
  100.     {
  101.         return $this->id;
  102.     }
  103.     public function getName(): ?string
  104.     {
  105.         return $this->name;
  106.     }
  107.     public function setName(?string $name): self
  108.     {
  109.         $this->name $name;
  110.         return $this;
  111.     }
  112.     public function getCode1c(): ?string
  113.     {
  114.         return $this->code1c;
  115.     }
  116.     public function setCode1c(?string $code1c): self
  117.     {
  118.         $this->code1c $code1c;
  119.         return $this;
  120.     }
  121.     public function getDateEntered(): ?\DateTimeInterface
  122.     {
  123.         return $this->dateEntered;
  124.     }
  125.     public function setDateEntered(?\DateTimeInterface $dateEntered): self
  126.     {
  127.         $this->dateEntered $dateEntered;
  128.         return $this;
  129.     }
  130.     public function getType(): ?string
  131.     {
  132.         return $this->type;
  133.     }
  134.     public function setType(?string $type): self
  135.     {
  136.         $this->type $type;
  137.         return $this;
  138.     }
  139.     public function getOrganization(): ?Accounts
  140.     {
  141.         return $this->organization;
  142.     }
  143.     public function setOrganization(?Accounts $organization): self
  144.     {
  145.         $this->organization $organization;
  146.         return $this;
  147.     }
  148.     public function getAccount(): ?Accounts
  149.     {
  150.         return $this->account;
  151.     }
  152.     public function setAccount(?Accounts $account): self
  153.     {
  154.         $this->account $account;
  155.         return $this;
  156.     }
  157.     public function getCurency(): ?string
  158.     {
  159.         return $this->curency;
  160.     }
  161.     public function setCurency(?string $curency): self
  162.     {
  163.         $this->curency $curency;
  164.         return $this;
  165.     }
  166.     public function getMaxBorg(): ?float
  167.     {
  168.         return $this->maxBorg;
  169.     }
  170.     public function setMaxBorg(?float $maxBorg): self
  171.     {
  172.         $this->maxBorg $maxBorg;
  173.         return $this;
  174.     }
  175.     public function getTypePayment(): ?string
  176.     {
  177.         return $this->typePayment;
  178.     }
  179.     public function setTypePayment(?string $typePayment): self
  180.     {
  181.         $this->typePayment $typePayment;
  182.         return $this;
  183.     }
  184.     public function isPaymentInCash(): ?bool
  185.     {
  186.         return $this->paymentInCash;
  187.     }
  188.     public function setPaymentInCash(?bool $paymentInCash): self
  189.     {
  190.         $this->paymentInCash $paymentInCash;
  191.         return $this;
  192.     }
  193.     public function getDayDelay(): ?int
  194.     {
  195.         return $this->dayDelay;
  196.     }
  197.     public function setDayDelay(?int $dayDelay): self
  198.     {
  199.         $this->dayDelay $dayDelay;
  200.         return $this;
  201.     }
  202.     /**
  203.      * @return Collection<int, Calculations>
  204.      */
  205.     public function getCalculations(): Collection
  206.     {
  207.         return $this->calculations;
  208.     }
  209.     public function addCalculation(Calculations $calculation): self
  210.     {
  211.         if (!$this->calculations->contains($calculation)) {
  212.             $this->calculations->add($calculation);
  213.             $calculation->setAgreement($this);
  214.         }
  215.         return $this;
  216.     }
  217.     public function removeCalculation(Calculations $calculation): self
  218.     {
  219.         if ($this->calculations->removeElement($calculation)) {
  220.             // set the owning side to null (unless already changed)
  221.             if ($calculation->getAgreement() === $this) {
  222.                 $calculation->setAgreement(null);
  223.             }
  224.         }
  225.         return $this;
  226.     }
  227.     /**
  228.      * @return Collection<int, Orders>
  229.      */
  230.     public function getOrders(): Collection
  231.     {
  232.         return $this->orders;
  233.     }
  234.     public function addOrder(Orders $order): self
  235.     {
  236.         if (!$this->orders->contains($order)) {
  237.             $this->orders->add($order);
  238.             $order->setAgreement($this);
  239.         }
  240.         return $this;
  241.     }
  242.     public function removeOrder(Orders $order): self
  243.     {
  244.         if ($this->orders->removeElement($order)) {
  245.             // set the owning side to null (unless already changed)
  246.             if ($order->getAgreement() === $this) {
  247.                 $order->setAgreement(null);
  248.             }
  249.         }
  250.         return $this;
  251.     }
  252.     
  253.     /**
  254.      * @return Collection<int, Prices>
  255.      */
  256.     public function getPrices(): Collection
  257.     {
  258.         return $this->prices;
  259.     }
  260.     public function addPrice(Prices $price): static
  261.     {
  262.         if (!$this->prices->contains($price)) {
  263.             $this->prices->add($price);
  264.             $price->setAgreement($this);
  265.         }
  266.         return $this;
  267.     }
  268.     public function removePrice(Prices $price): static
  269.     {
  270.         if ($this->prices->removeElement($price)) {
  271.             // set the owning side to null (unless already changed)
  272.             if ($price->getAgreement() === $this) {
  273.                 $price->setAgreement(null);
  274.             }
  275.         }
  276.         return $this;
  277.     }
  278.     /**
  279.      * @return Collection<int, Accounts>
  280.      */
  281.     public function getAccounts(): Collection
  282.     {
  283.         return $this->accounts;
  284.     }
  285.     public function addAccount(Accounts $account): static
  286.     {
  287.         if (!$this->accounts->contains($account)) {
  288.             $this->accounts->add($account);
  289.             $account->setVirtualAgreementSpecfication($this);
  290.         }
  291.         return $this;
  292.     }
  293.     public function removeAccount(Accounts $account): static
  294.     {
  295.         if ($this->accounts->removeElement($account)) {
  296.             // set the owning side to null (unless already changed)
  297.             if ($account->getVirtualAgreementSpecfication() === $this) {
  298.                 $account->setVirtualAgreementSpecfication(null);
  299.             }
  300.         }
  301.         return $this;
  302.     }
  303.     public function isVirtual(): ?bool
  304.     {
  305.         return $this->virtual;
  306.     }
  307.     public function setVirtual(?bool $virtual): static
  308.     {
  309.         $this->virtual $virtual;
  310.         return $this;
  311.     }
  312. }