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''job:read''account:read'])]
  36.     #[ORM\Column]
  37.     private ?int $id null;
  38.     #[Groups(['agreements:read''agreements:write''agreements:read''order:read''order_product:read''job:read''account:read'])]
  39.     #[ORM\Column(length255nullabletrue)]
  40.     private ?string $name null;
  41.     #[Groups(['agreements:read''agreements:write''agreements:read''order:read''order_product:read''job:read''account: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.     #[ORM\OneToMany(mappedBy'agreement'targetEntityPrices::class)]
  82.     private Collection $prices;
  83.     #[MaxDepth(1)]
  84.     #[Groups(['agreements:read'])]
  85.     #[ORM\OneToMany(mappedBy'virtualAgreementSpecfication'targetEntityAccounts::class)]
  86.     private Collection $accounts;
  87.     #[MaxDepth(1)]
  88.     #[Groups(['agreements:read''agreements:write'])]
  89.     #[ORM\Column(nullabletrue)]
  90.     private ?bool $virtual null;
  91.     public function __construct()
  92.     {
  93.         $this->calculations = new ArrayCollection();
  94.         $this->orders = new ArrayCollection();
  95.         $this->prices = new ArrayCollection();
  96.         $this->accounts = new ArrayCollection();
  97.     }
  98.     public function getId(): ?int
  99.     {
  100.         return $this->id;
  101.     }
  102.     public function getName(): ?string
  103.     {
  104.         return $this->name;
  105.     }
  106.     public function setName(?string $name): self
  107.     {
  108.         $this->name $name;
  109.         return $this;
  110.     }
  111.     public function getCode1c(): ?string
  112.     {
  113.         return $this->code1c;
  114.     }
  115.     public function setCode1c(?string $code1c): self
  116.     {
  117.         $this->code1c $code1c;
  118.         return $this;
  119.     }
  120.     public function getDateEntered(): ?\DateTimeInterface
  121.     {
  122.         return $this->dateEntered;
  123.     }
  124.     public function setDateEntered(?\DateTimeInterface $dateEntered): self
  125.     {
  126.         $this->dateEntered $dateEntered;
  127.         return $this;
  128.     }
  129.     public function getType(): ?string
  130.     {
  131.         return $this->type;
  132.     }
  133.     public function setType(?string $type): self
  134.     {
  135.         $this->type $type;
  136.         return $this;
  137.     }
  138.     public function getOrganization(): ?Accounts
  139.     {
  140.         return $this->organization;
  141.     }
  142.     public function setOrganization(?Accounts $organization): self
  143.     {
  144.         $this->organization $organization;
  145.         return $this;
  146.     }
  147.     public function getAccount(): ?Accounts
  148.     {
  149.         return $this->account;
  150.     }
  151.     public function setAccount(?Accounts $account): self
  152.     {
  153.         $this->account $account;
  154.         return $this;
  155.     }
  156.     public function getCurency(): ?string
  157.     {
  158.         return $this->curency;
  159.     }
  160.     public function setCurency(?string $curency): self
  161.     {
  162.         $this->curency $curency;
  163.         return $this;
  164.     }
  165.     public function getMaxBorg(): ?float
  166.     {
  167.         return $this->maxBorg;
  168.     }
  169.     public function setMaxBorg(?float $maxBorg): self
  170.     {
  171.         $this->maxBorg $maxBorg;
  172.         return $this;
  173.     }
  174.     public function getTypePayment(): ?string
  175.     {
  176.         return $this->typePayment;
  177.     }
  178.     public function setTypePayment(?string $typePayment): self
  179.     {
  180.         $this->typePayment $typePayment;
  181.         return $this;
  182.     }
  183.     public function isPaymentInCash(): ?bool
  184.     {
  185.         return $this->paymentInCash;
  186.     }
  187.     public function setPaymentInCash(?bool $paymentInCash): self
  188.     {
  189.         $this->paymentInCash $paymentInCash;
  190.         return $this;
  191.     }
  192.     public function getDayDelay(): ?int
  193.     {
  194.         return $this->dayDelay;
  195.     }
  196.     public function setDayDelay(?int $dayDelay): self
  197.     {
  198.         $this->dayDelay $dayDelay;
  199.         return $this;
  200.     }
  201.     /**
  202.      * @return Collection<int, Calculations>
  203.      */
  204.     public function getCalculations(): Collection
  205.     {
  206.         return $this->calculations;
  207.     }
  208.     public function addCalculation(Calculations $calculation): self
  209.     {
  210.         if (!$this->calculations->contains($calculation)) {
  211.             $this->calculations->add($calculation);
  212.             $calculation->setAgreement($this);
  213.         }
  214.         return $this;
  215.     }
  216.     public function removeCalculation(Calculations $calculation): self
  217.     {
  218.         if ($this->calculations->removeElement($calculation)) {
  219.             // set the owning side to null (unless already changed)
  220.             if ($calculation->getAgreement() === $this) {
  221.                 $calculation->setAgreement(null);
  222.             }
  223.         }
  224.         return $this;
  225.     }
  226.     /**
  227.      * @return Collection<int, Orders>
  228.      */
  229.     public function getOrders(): Collection
  230.     {
  231.         return $this->orders;
  232.     }
  233.     public function addOrder(Orders $order): self
  234.     {
  235.         if (!$this->orders->contains($order)) {
  236.             $this->orders->add($order);
  237.             $order->setAgreement($this);
  238.         }
  239.         return $this;
  240.     }
  241.     public function removeOrder(Orders $order): self
  242.     {
  243.         if ($this->orders->removeElement($order)) {
  244.             // set the owning side to null (unless already changed)
  245.             if ($order->getAgreement() === $this) {
  246.                 $order->setAgreement(null);
  247.             }
  248.         }
  249.         return $this;
  250.     }
  251.     
  252.     /**
  253.      * @return Collection<int, Prices>
  254.      */
  255.     public function getPrices(): Collection
  256.     {
  257.         return $this->prices;
  258.     }
  259.     public function addPrice(Prices $price): static
  260.     {
  261.         if (!$this->prices->contains($price)) {
  262.             $this->prices->add($price);
  263.             $price->setAgreement($this);
  264.         }
  265.         return $this;
  266.     }
  267.     public function removePrice(Prices $price): static
  268.     {
  269.         if ($this->prices->removeElement($price)) {
  270.             // set the owning side to null (unless already changed)
  271.             if ($price->getAgreement() === $this) {
  272.                 $price->setAgreement(null);
  273.             }
  274.         }
  275.         return $this;
  276.     }
  277.     /**
  278.      * @return Collection<int, Accounts>
  279.      */
  280.     public function getAccounts(): Collection
  281.     {
  282.         return $this->accounts;
  283.     }
  284.     public function addAccount(Accounts $account): static
  285.     {
  286.         if (!$this->accounts->contains($account)) {
  287.             $this->accounts->add($account);
  288.             $account->setVirtualAgreementSpecfication($this);
  289.         }
  290.         return $this;
  291.     }
  292.     public function removeAccount(Accounts $account): static
  293.     {
  294.         if ($this->accounts->removeElement($account)) {
  295.             // set the owning side to null (unless already changed)
  296.             if ($account->getVirtualAgreementSpecfication() === $this) {
  297.                 $account->setVirtualAgreementSpecfication(null);
  298.             }
  299.         }
  300.         return $this;
  301.     }
  302.     public function isVirtual(): ?bool
  303.     {
  304.         return $this->virtual;
  305.     }
  306.     public function setVirtual(?bool $virtual): static
  307.     {
  308.         $this->virtual $virtual;
  309.         return $this;
  310.     }
  311. }