src/Entity/Agreements.php line 40

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