src/Entity/Accounts.php line 34

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\AccountsRepository;
  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 ApiPlatform\Core\Annotation\ApiProperty;
  14. #[ORM\Entity(repositoryClassAccountsRepository::class)]
  15. #[ApiResource(
  16.     normalizationContext: ['groups' => ['account:read']],
  17.     denormalizationContext: ['groups' => ['account:write']],
  18.     order: ['id' => 'DESC'],
  19. )]
  20. #[ApiFilter(SearchFilter::class, properties: [
  21.     'name' => 'ipartial'
  22.     'code1c' => 'exact'
  23.     'user.id' => 'exact'
  24.     'manager.id' => 'exact'
  25.     'manager.firstName' => 'ipartial',
  26.     'phone' => 'exact',
  27. ])]
  28. class Accounts
  29. {
  30.     #[ORM\Id]
  31.     #[ORM\GeneratedValue]
  32.     #[ORM\Column]
  33.     #[Groups(['account:read''order:read''order_product:read''pre_order_product:read''pre_order:read''load_invoice:read''load_invocie:read''read''account:write''write''agreements:read''user:read'])]
  34.     private ?int $id null;
  35.     #[ORM\Column(length255)]
  36.     #[Groups(['account:read''order:read''order_product:read''pre_order_product:read''pre_order:read''load_invoice:read''load_invocie:read''read''account:write''write''agreements:read''user:read'])]
  37.     private ?string $name null;
  38.     #[Groups(['account:read''read''account:write''write'])]
  39.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  40.     private ?\DateTimeInterface $date_entered null;
  41.     #[Groups(['account:read''read''account:write''write'])]
  42.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  43.     private ?\DateTimeInterface $date_modified null;
  44.     #[Groups(['account:read''read''account:write''write'])]
  45.     #[ORM\Column(nullabletrue)]
  46.     private ?int $modified_user_id null;
  47.     #[Groups(['account:read''read''account:write''write'])]
  48.     #[ORM\Column(nullabletrue)]
  49.     private ?int $created_by null;
  50.     #[Groups(['account:read''read''account:write''write'])]
  51.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  52.     private ?string $description null;
  53.     #[ORM\Column(nullabletrue)]
  54.     private ?int $deleted null;
  55.     #[Groups(['account:read''read''account:write''write'])]
  56.     #[ORM\Column(nullabletrue)]
  57.     private ?int $assigned_user_id null;
  58.     #[Groups(['account:read''read''account:write''write''user:read'])]
  59.     #[ORM\Column(length100nullabletrue)]
  60.     private ?string $edrpou null;
  61.     #[Groups(['account:read''read''account:write''write''user:read'])]
  62.     #[ORM\Column(length255nullabletrue)]
  63.     private ?string $billing_address_city null;
  64.     #[Groups(['account:read''read''account:write''write''user:read'])]
  65.     #[ORM\Column(length255nullabletrue)]
  66.     private ?string $billing_address_state null;
  67.     #[Groups(['account:read''read''account:write''write''user:read'])]
  68.     #[ORM\Column(length255nullabletrue)]
  69.     private ?string $billing_address_country null;
  70.     #[Groups(['account:read''read''account:write''write''user:read'])]
  71.     #[ORM\Column(length255nullabletrue)]
  72.     private ?string $billing_address_street null;
  73.     #[Groups(['account:read''read''account:write''write''user:read'])]
  74.     #[ORM\Column(length50nullabletrue)]
  75.     private ?string $phone null;
  76.     #[Groups(['account:read''read''account:write''write'])]
  77.     #[ORM\OneToMany(mappedBy'account'targetEntityOrders::class)]
  78.     private Collection $orders;
  79.     #[MaxDepth(1)]
  80.     #[ApiProperty(writabletrue)]
  81.     #[ORM\ManyToOne(inversedBy'accounts')]
  82.     #[Groups(['account:read''read''account:write''write'])]
  83.     private ?User $user null;
  84.     #[Groups(['account:read''read''account:write''write'])]
  85.     #[ORM\OneToMany(mappedBy'supplier'targetEntityIncomingInvoice::class)]
  86.     private Collection $invoice_supplier;
  87.     #[Groups(['account:read''read''account:write''write''user:read'])]
  88.     #[ORM\Column(length100nullabletrue)]
  89.     private ?string $ipn null;
  90.     #[Groups(['account:read''read''account:write''write''user:read'])]
  91.     #[ORM\Column(length20nullabletrue)]
  92.     private ?string $type null;
  93.     #[MaxDepth(1)]
  94.     #[Groups(['account:read''read''account:write''write'])]
  95.     #[ORM\ManyToOne(targetEntityself::class, inversedBy'accounts')]
  96.     private ?self $parent null;
  97.     #[Groups(['account:read''read''account:write''write'])]
  98.     #[MaxDepth(2)]
  99.     #[ORM\OneToMany(mappedBy'parent'targetEntityself::class)]
  100.     private Collection $accounts;
  101.     #[Groups(['account:read''read''account:write''write'])]
  102.     #[ORM\Column(length100nullabletrue)]
  103.     private ?string $director null;
  104.     #[Groups(['account:read''order:read''order_product:read''pre_order_product:read''pre_order:read''load_invoice:read''load_invocie:read''read''account:write''write''user:read'])]
  105.     #[ORM\Column(length20nullabletrue)]
  106.     private ?string $code1c null;
  107.     #[Groups(['account:read''read''account:write''write'])]
  108.     #[ORM\OneToMany(mappedBy'account'targetEntityContacts::class)]
  109.     private Collection $contacts;
  110.     #[MaxDepth(1)]
  111.     #[ORM\ManyToOne(inversedBy'managerAccounts')]
  112.     // #[Groups(['account:read', 'read', 'account:write', 'write', 'pre_order_product:read', 'pre_order:read','user:read'])]
  113.     private ?User $manager null;
  114.     #[Groups(['account:read''read''account:write''write'])]
  115.     #[MaxDepth(2)]
  116.     #[ORM\OneToMany(mappedBy'account'targetEntityPreOrder::class)]
  117.     private Collection $preOrders;
  118.     #[ORM\OneToMany(mappedBy'account'targetEntityLoadInvoice::class)]
  119.     private Collection $loadInvoices;
  120.     #[ORM\OneToMany(mappedBy'organization'targetEntityAgreements::class)]
  121.     private Collection $organization;
  122.     #[Groups(['account:read''read''account:write''write''pre_order_product:read''pre_order:read','user:read'])]
  123.     #[ORM\OneToMany(mappedBy'account'targetEntityAgreements::class)]
  124.     private Collection $agreements;
  125.     #[Groups(['account:read'])]
  126.     #[ORM\ManyToOne(inversedBy'accounts')]
  127.     private ?Agreements $virtualAgreementSpecfication null;
  128.     #[ORM\OneToMany(mappedBy'account'targetEntityAccountAddress::class)]
  129.     private Collection $accountAddresses;
  130.     #[ORM\OneToMany(mappedBy'account'targetEntityAccountWorker::class, orphanRemovaltrue)]
  131.     private Collection $accountWorkers;
  132.     #[ORM\OneToMany(mappedBy'account'targetEntityJobs::class)]
  133.     private Collection $jobs;
  134.     public function __construct()
  135.     {
  136.         $this->orders = new ArrayCollection();
  137.         $this->invoice_supplier = new ArrayCollection();
  138.         $this->accounts = new ArrayCollection();
  139.         $this->contacts = new ArrayCollection();
  140.         $this->preOrders = new ArrayCollection();
  141.         $this->loadInvoices = new ArrayCollection();
  142.         $this->organization = new ArrayCollection();
  143.         $this->agreements = new ArrayCollection();
  144.         $this->accountAddresses = new ArrayCollection();
  145.         $this->accountWorkers = new ArrayCollection();
  146.         $this->jobs = new ArrayCollection();
  147.     }
  148.     public function getId(): ?int
  149.     {
  150.         return $this->id;
  151.     }
  152.     public function getName(): ?string
  153.     {
  154.         return $this->name;
  155.     }
  156.     public function setName(string $name): self
  157.     {
  158.         $this->name $name;
  159.         return $this;
  160.     }
  161.     public function getDateEntered(): ?\DateTimeInterface
  162.     {
  163.         return $this->date_entered;
  164.     }
  165.     public function setDateEntered(?\DateTimeInterface $date_entered): self
  166.     {
  167.         $this->date_entered $date_entered;
  168.         return $this;
  169.     }
  170.     public function getDateModified(): ?\DateTimeInterface
  171.     {
  172.         return $this->date_modified;
  173.     }
  174.     public function setDateModified(?\DateTimeInterface $date_modified): self
  175.     {
  176.         $this->date_modified $date_modified;
  177.         return $this;
  178.     }
  179.     public function getModifiedUserId(): ?int
  180.     {
  181.         return $this->modified_user_id;
  182.     }
  183.     public function setModifiedUserId(?int $modified_user_id): self
  184.     {
  185.         $this->modified_user_id $modified_user_id;
  186.         return $this;
  187.     }
  188.     public function getCreatedBy(): ?int
  189.     {
  190.         return $this->created_by;
  191.     }
  192.     public function setCreatedBy(int $created_by): self
  193.     {
  194.         $this->created_by $created_by;
  195.         return $this;
  196.     }
  197.     public function getDescription(): ?string
  198.     {
  199.         return $this->description;
  200.     }
  201.     public function setDescription(?string $description): self
  202.     {
  203.         $this->description $description;
  204.         return $this;
  205.     }
  206.     public function getDeleted(): ?int
  207.     {
  208.         return $this->deleted;
  209.     }
  210.     public function setDeleted(?int $deleted): self
  211.     {
  212.         $this->deleted $deleted;
  213.         return $this;
  214.     }
  215.     public function getAssignedUserId(): ?int
  216.     {
  217.         return $this->assigned_user_id;
  218.     }
  219.     public function setAssignedUserId(?int $assigned_user_id): self
  220.     {
  221.         $this->assigned_user_id $assigned_user_id;
  222.         return $this;
  223.     }
  224.     public function getEdrpou(): ?string
  225.     {
  226.         return $this->edrpou;
  227.     }
  228.     public function setEdrpou(?string $edrpou): self
  229.     {
  230.         $this->edrpou $edrpou;
  231.         return $this;
  232.     }
  233.     public function getBillingAddressCity(): ?string
  234.     {
  235.         return $this->billing_address_city;
  236.     }
  237.     public function setBillingAddressCity(?string $billing_address_city): self
  238.     {
  239.         $this->billing_address_city $billing_address_city;
  240.         return $this;
  241.     }
  242.     public function getBillingAddressState(): ?string
  243.     {
  244.         return $this->billing_address_state;
  245.     }
  246.     public function setBillingAddressState(?string $billing_address_state): self
  247.     {
  248.         $this->billing_address_state $billing_address_state;
  249.         return $this;
  250.     }
  251.     public function getBillingAddressCountry(): ?string
  252.     {
  253.         return $this->billing_address_country;
  254.     }
  255.     public function setBillingAddressCountry(?string $billing_address_country): self
  256.     {
  257.         $this->billing_address_country $billing_address_country;
  258.         return $this;
  259.     }
  260.     public function getBillingAddressStreet(): ?string
  261.     {
  262.         return $this->billing_address_street;
  263.     }
  264.     public function setBillingAddressStreet(?string $billing_address_street): self
  265.     {
  266.         $this->billing_address_street $billing_address_street;
  267.         return $this;
  268.     }
  269.     public function getPhone(): ?string
  270.     {
  271.         return $this->phone;
  272.     }
  273.     public function setPhone(?string $phone): self
  274.     {
  275.         $this->phone $phone;
  276.         return $this;
  277.     }
  278.     /**
  279.      * @return Collection<int, Orders>
  280.      */
  281.     public function getOrders(): Collection
  282.     {
  283.         return $this->orders;
  284.     }
  285.     public function addOrder(Orders $order): self
  286.     {
  287.         if (!$this->orders->contains($order)) {
  288.             $this->orders->add($order);
  289.             $order->setAccountId($this);
  290.         }
  291.         return $this;
  292.     }
  293.     public function removeOrder(Orders $order): self
  294.     {
  295.         if ($this->orders->removeElement($order)) {
  296.             // set the owning side to null (unless already changed)
  297.             if ($order->getAccountId() === $this) {
  298.                 $order->setAccountId(null);
  299.             }
  300.         }
  301.         return $this;
  302.     }
  303.     public function getUser(): ?User
  304.     {
  305.         return $this->user;
  306.     }
  307.     public function setUser(?User $user): self
  308.     {
  309.         $this->user $user;
  310.         return $this;
  311.     }
  312.     /**
  313.      * @return Collection<int, IncomingInvoice>
  314.      */
  315.     public function getInvoiceSupplier(): Collection
  316.     {
  317.         return $this->invoice_supplier;
  318.     }
  319.     public function addInvoiceSupplier(IncomingInvoice $invoiceSupplier): self
  320.     {
  321.         if (!$this->invoice_supplier->contains($invoiceSupplier)) {
  322.             $this->invoice_supplier->add($invoiceSupplier);
  323.             $invoiceSupplier->setSupplier($this);
  324.         }
  325.         return $this;
  326.     }
  327.     public function removeInvoiceSupplier(IncomingInvoice $invoiceSupplier): self
  328.     {
  329.         if ($this->invoice_supplier->removeElement($invoiceSupplier)) {
  330.             // set the owning side to null (unless already changed)
  331.             if ($invoiceSupplier->getSupplier() === $this) {
  332.                 $invoiceSupplier->setSupplier(null);
  333.             }
  334.         }
  335.         return $this;
  336.     }
  337.     public function getIpn(): ?string
  338.     {
  339.         return $this->ipn;
  340.     }
  341.     public function setIpn(?string $ipn): self
  342.     {
  343.         $this->ipn $ipn;
  344.         return $this;
  345.     }
  346.     public function getType(): ?string
  347.     {
  348.         return $this->type;
  349.     }
  350.     public function setType(?string $type): self
  351.     {
  352.         $this->type $type;
  353.         return $this;
  354.     }
  355.     public function getParent(): ?self
  356.     {
  357.         return $this->parent;
  358.     }
  359.     public function setParent(?self $parent): self
  360.     {
  361.         $this->parent $parent;
  362.         return $this;
  363.     }
  364.     /**
  365.      * @return Collection<int, self>
  366.      */
  367.     public function getAccounts(): Collection
  368.     {
  369.         return $this->accounts;
  370.     }
  371.     public function addAccount(self $account): self
  372.     {
  373.         if (!$this->accounts->contains($account)) {
  374.             $this->accounts->add($account);
  375.             $account->setParent($this);
  376.         }
  377.         return $this;
  378.     }
  379.     public function removeAccount(self $account): self
  380.     {
  381.         if ($this->accounts->removeElement($account)) {
  382.             // set the owning side to null (unless already changed)
  383.             if ($account->getParent() === $this) {
  384.                 $account->setParent(null);
  385.             }
  386.         }
  387.         return $this;
  388.     }
  389.     public function getDirector(): ?string
  390.     {
  391.         return $this->director;
  392.     }
  393.     public function setDirector(?string $director): self
  394.     {
  395.         $this->director $director;
  396.         return $this;
  397.     }
  398.     public function getCode1c(): ?string
  399.     {
  400.         return $this->code1c;
  401.     }
  402.     public function setCode1c(?string $code1c): self
  403.     {
  404.         $this->code1c $code1c;
  405.         return $this;
  406.     }
  407.     /**
  408.      * @return Collection<int, Contacts>
  409.      */
  410.     public function getContacts(): Collection
  411.     {
  412.         return $this->contacts;
  413.     }
  414.     public function addContact(Contacts $contact): self
  415.     {
  416.         if (!$this->contacts->contains($contact)) {
  417.             $this->contacts->add($contact);
  418.             $contact->setAccount($this);
  419.         }
  420.         return $this;
  421.     }
  422.     public function removeContact(Contacts $contact): self
  423.     {
  424.         if ($this->contacts->removeElement($contact)) {
  425.             // set the owning side to null (unless already changed)
  426.             if ($contact->getAccount() === $this) {
  427.                 $contact->setAccount(null);
  428.             }
  429.         }
  430.         return $this;
  431.     }
  432.     public function getManager(): ?User
  433.     {
  434.         return $this->manager;
  435.     }
  436.     public function setManager(?User $manager): self
  437.     {
  438.         $this->manager $manager;
  439.         return $this;
  440.     }
  441.     /**
  442.      * @return Collection<int, PreOrder>
  443.      */
  444.     public function getPreOrders(): Collection
  445.     {
  446.         return $this->preOrders;
  447.     }
  448.     public function addPreOrder(PreOrder $preOrder): self
  449.     {
  450.         if (!$this->preOrders->contains($preOrder)) {
  451.             $this->preOrders->add($preOrder);
  452.             $preOrder->setAccount($this);
  453.         }
  454.         return $this;
  455.     }
  456.     public function removePreOrder(PreOrder $preOrder): self
  457.     {
  458.         if ($this->preOrders->removeElement($preOrder)) {
  459.             // set the owning side to null (unless already changed)
  460.             if ($preOrder->getAccount() === $this) {
  461.                 $preOrder->setAccount(null);
  462.             }
  463.         }
  464.         return $this;
  465.     }
  466.     /**
  467.      * @return Collection<int, LoadInvoice>
  468.      */
  469.     public function getLoadInvoices(): Collection
  470.     {
  471.         return $this->loadInvoices;
  472.     }
  473.     public function addLoadInvoice(LoadInvoice $loadInvoice): self
  474.     {
  475.         if (!$this->loadInvoices->contains($loadInvoice)) {
  476.             $this->loadInvoices->add($loadInvoice);
  477.             $loadInvoice->setAccount($this);
  478.         }
  479.         return $this;
  480.     }
  481.     public function removeLoadInvoice(LoadInvoice $loadInvoice): self
  482.     {
  483.         if ($this->loadInvoices->removeElement($loadInvoice)) {
  484.             // set the owning side to null (unless already changed)
  485.             if ($loadInvoice->getAccount() === $this) {
  486.                 $loadInvoice->setAccount(null);
  487.             }
  488.         }
  489.         return $this;
  490.     }
  491.     /**
  492.      * @return Collection<int, Agreements>
  493.      */
  494.     public function getOrganization(): Collection
  495.     {
  496.         return $this->organization;
  497.     }
  498.     public function addOrganization(Agreements $organization): self
  499.     {
  500.         if (!$this->organization->contains($organization)) {
  501.             $this->organization->add($organization);
  502.             $organization->setOrganization($this);
  503.         }
  504.         return $this;
  505.     }
  506.     public function removeOrganization(Agreements $organization): self
  507.     {
  508.         if ($this->organization->removeElement($organization)) {
  509.             // set the owning side to null (unless already changed)
  510.             if ($organization->getOrganization() === $this) {
  511.                 $organization->setOrganization(null);
  512.             }
  513.         }
  514.         return $this;
  515.     }
  516.     /**
  517.      * @return Collection<int, Agreements>
  518.      */
  519.     public function getAgreements(): Collection
  520.     {
  521.         return $this->agreements;
  522.     }
  523.     public function addAgreement(Agreements $agreement): self
  524.     {
  525.         if (!$this->agreements->contains($agreement)) {
  526.             $this->agreements->add($agreement);
  527.             $agreement->setAccount($this);
  528.         }
  529.         return $this;
  530.     }
  531.     public function removeAgreement(Agreements $agreement): self
  532.     {
  533.         if ($this->agreements->removeElement($agreement)) {
  534.             // set the owning side to null (unless already changed)
  535.             if ($agreement->getAccount() === $this) {
  536.                 $agreement->setAccount(null);
  537.             }
  538.         }
  539.         return $this;
  540.     }
  541.     public function getVirtualAgreementSpecfication(): ?Agreements
  542.     {
  543.         return $this->virtualAgreementSpecfication;
  544.     }
  545.     public function setVirtualAgreementSpecfication(?Agreements $virtualAgreementSpecfication): static
  546.     {
  547.         $this->virtualAgreementSpecfication $virtualAgreementSpecfication;
  548.         return $this;
  549.     }
  550.     /**
  551.      * @return Collection<int, AccountAddress>
  552.      */
  553.     public function getAccountAddresses(): Collection
  554.     {
  555.         return $this->accountAddresses;
  556.     }
  557.     public function addAccountAddress(AccountAddress $accountAddress): self
  558.     {
  559.         if (!$this->accountAddresses->contains($accountAddress)) {
  560.             $this->accountAddresses->add($accountAddress);
  561.             $accountAddress->setAccount($this);
  562.         }
  563.         return $this;
  564.     }
  565.     public function removeAccountAddress(AccountAddress $accountAddress): self
  566.     {
  567.         if ($this->accountAddresses->removeElement($accountAddress)) {
  568.             // set the owning side to null (unless already changed)
  569.             if ($accountAddress->getAccount() === $this) {
  570.                 $accountAddress->setAccount(null);
  571.             }
  572.         }
  573.         return $this;
  574.     }
  575.     /**
  576.      * @return Collection<int, AccountWorker>
  577.      */
  578.     public function getAccountWorkers(): Collection
  579.     {
  580.         return $this->accountWorkers;
  581.     }
  582.     public function addAccountWorker(AccountWorker $accountWorker): self
  583.     {
  584.         if (!$this->accountWorkers->contains($accountWorker)) {
  585.             $this->accountWorkers->add($accountWorker);
  586.             $accountWorker->setAccount($this);
  587.         }
  588.         return $this;
  589.     }
  590.     public function removeAccountWorker(AccountWorker $accountWorker): self
  591.     {
  592.         if ($this->accountWorkers->removeElement($accountWorker)) {
  593.             // set the owning side to null (unless already changed)
  594.             if ($accountWorker->getAccount() === $this) {
  595.                 $accountWorker->setAccount(null);
  596.             }
  597.         }
  598.         return $this;
  599.     }
  600.     /**
  601.      * @return Collection<int, Jobs>
  602.      */
  603.     public function getJobs(): Collection
  604.     {
  605.         return $this->jobs;
  606.     }
  607.     public function addJob(Jobs $job): self
  608.     {
  609.         if (!$this->jobs->contains($job)) {
  610.             $this->jobs->add($job);
  611.             $job->setAccount($this);
  612.         }
  613.         return $this;
  614.     }
  615.     public function removeJob(Jobs $job): self
  616.     {
  617.         if ($this->jobs->removeElement($job)) {
  618.             // set the owning side to null (unless already changed)
  619.             if ($job->getAccount() === $this) {
  620.                 $job->setAccount(null);
  621.             }
  622.         }
  623.         return $this;
  624.     }
  625. }