<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\AccountsRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\MaxDepth;
use ApiPlatform\Core\Annotation\ApiProperty;
#[ORM\Entity(repositoryClass: AccountsRepository::class)]
#[ApiResource(
normalizationContext: ['groups' => ['account:read']],
denormalizationContext: ['groups' => ['account:write']],
order: ['id' => 'DESC'],
)]
#[ApiFilter(SearchFilter::class, properties: [
'name' => 'ipartial',
'code1c' => 'exact',
'edrpou' => 'exact',
'user.id' => 'exact',
'manager.id' => 'exact',
'manager.firstName' => 'ipartial',
'phone' => 'exact',
'accountJobsLists.id' => 'exact',
'accountJobsLists.name' => 'exact',
'accountJobsLists.status' => 'exact',
])]
class Accounts
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[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', 'job:read', 'worker:read', 'account_job:read', 'account_worker:read'])]
private ?int $id = null;
#[ORM\Column(length: 255)]
#[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', 'job:read', 'worker:read', 'account_job:read', 'account_worker:read'])]
private ?string $name = null;
#[Groups(['account:read', 'read', 'account:write', 'write'])]
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $date_entered = null;
#[Groups(['account:read', 'read', 'account:write', 'write'])]
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $date_modified = null;
#[Groups(['account:read', 'read', 'account:write', 'write'])]
#[ORM\Column(nullable: true)]
private ?int $modified_user_id = null;
#[Groups(['account:read', 'read', 'account:write', 'write'])]
#[ORM\Column(nullable: true)]
private ?int $created_by = null;
#[Groups(['account:read', 'read', 'account:write', 'write'])]
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $description = null;
#[ORM\Column(nullable: true)]
private ?int $deleted = null;
#[Groups(['account:read', 'read', 'account:write', 'write'])]
#[ORM\Column(nullable: true)]
private ?int $assigned_user_id = null;
#[Groups(['account:read', 'read', 'account:write', 'write', 'user:read', 'account_job:read', 'account_worker:read'])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $edrpou = null;
#[Groups(['account:read', 'read', 'account:write', 'write', 'user:read'])]
#[ORM\Column(length: 255, nullable: true)]
private ?string $billing_address_city = null;
#[Groups(['account:read', 'read', 'account:write', 'write', 'user:read'])]
#[ORM\Column(length: 255, nullable: true)]
private ?string $billing_address_state = null;
#[Groups(['account:read', 'read', 'account:write', 'write', 'user:read'])]
#[ORM\Column(length: 255, nullable: true)]
private ?string $billing_address_country = null;
#[Groups(['account:read', 'read', 'account:write', 'write', 'user:read'])]
#[ORM\Column(length: 255, nullable: true)]
private ?string $billing_address_street = null;
#[Groups(['account:read', 'read', 'account:write', 'write', 'user:read'])]
#[ORM\Column(length: 50, nullable: true)]
private ?string $phone = null;
#[Groups(['read', 'account:write', 'write'])]
#[ORM\OneToMany(mappedBy: 'account', targetEntity: Orders::class, cascade:['persist', 'remove'])]
private Collection $orders;
#[MaxDepth(1)]
#[ApiProperty(writable: true)]
#[ORM\ManyToOne(inversedBy: 'accounts')]
#[Groups(['account:read', 'account:write', 'write'])]
private ?User $user = null;
#[Groups(['read', 'account:write', 'write'])]
#[ORM\OneToMany(mappedBy: 'supplier', targetEntity: IncomingInvoice::class, cascade:['persist', 'remove'])]
private Collection $invoice_supplier;
#[Groups(['account:read', 'read', 'account:write', 'write', 'user:read'])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $ipn = null;
#[Groups(['account:read', 'read', 'account:write', 'write', 'user:read'])]
#[ORM\Column(length: 20, nullable: true)]
private ?string $type = null;
#[MaxDepth(1)]
#[Groups(['account:read', 'read', 'account:write', 'write'])]
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'accounts')]
private ?self $parent = null;
#[Groups(['account:write'])]
#[MaxDepth(2)]
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)]
private Collection $accounts;
#[Groups(['account:read', 'read', 'account:write', 'write'])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $director = null;
#[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', 'worker:read', 'job:read', 'account_job:read', 'account_worker:read'])]
#[ORM\Column(length: 20, nullable: true)]
private ?string $code1c = '';
#[Groups(['account:read', 'read', 'account:write', 'write'])]
#[ORM\OneToMany(mappedBy: 'account', targetEntity: Contacts::class, cascade:['persist', 'remove'])]
private Collection $contacts;
#[MaxDepth(1)]
#[ORM\ManyToOne(inversedBy: 'managerAccounts')]
#[Groups(['account:read', 'account:write', 'order:read', 'pre_order:read'])]
private ?User $manager = null;
#[Groups(['read', 'account:write', 'write'])]
#[MaxDepth(2)]
#[ORM\OneToMany(mappedBy: 'account', targetEntity: PreOrder::class)]
private Collection $preOrders;
#[ORM\OneToMany(mappedBy: 'account', targetEntity: LoadInvoice::class)]
private Collection $loadInvoices;
#[ORM\OneToMany(mappedBy: 'organization', targetEntity: Agreements::class)]
private Collection $organization;
#[Groups(['account:read', 'read', 'account:write', 'write','user:read', 'worker:read', 'job:read'])]
#[ORM\OneToMany(mappedBy: 'account', targetEntity: Agreements::class, cascade:['persist', 'remove'])]
private Collection $agreements;
#[Groups(['account:read', 'account:write'])]
#[ORM\ManyToOne(inversedBy: 'accounts')]
private ?Agreements $virtualAgreementSpecfication = null;
#[Groups(['account:read', 'account:write'])]
#[ORM\OneToMany(mappedBy: 'account', targetEntity: AccountAddress::class)]
private Collection $accountAddresses;
#[ORM\OneToMany(mappedBy: 'account', targetEntity: AccountWorker::class, orphanRemoval: true)]
private Collection $accountWorkers;
#[ORM\OneToMany(mappedBy: 'account', targetEntity: Jobs::class)]
private Collection $jobs;
#[ORM\OneToMany(mappedBy: 'account', targetEntity: AccountJobsList::class)]
private Collection $accountJobsLists;
public function __construct()
{
$this->orders = new ArrayCollection();
$this->invoice_supplier = new ArrayCollection();
$this->accounts = new ArrayCollection();
$this->contacts = new ArrayCollection();
$this->preOrders = new ArrayCollection();
$this->loadInvoices = new ArrayCollection();
$this->organization = new ArrayCollection();
$this->agreements = new ArrayCollection();
$this->accountAddresses = new ArrayCollection();
$this->accountWorkers = new ArrayCollection();
$this->jobs = new ArrayCollection();
$this->accountJobsLists = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getDateEntered(): ?\DateTimeInterface
{
return $this->date_entered;
}
public function setDateEntered(?\DateTimeInterface $date_entered): self
{
$this->date_entered = $date_entered;
return $this;
}
public function getDateModified(): ?\DateTimeInterface
{
return $this->date_modified;
}
public function setDateModified(?\DateTimeInterface $date_modified): self
{
$this->date_modified = $date_modified;
return $this;
}
public function getModifiedUserId(): ?int
{
return $this->modified_user_id;
}
public function setModifiedUserId(?int $modified_user_id): self
{
$this->modified_user_id = $modified_user_id;
return $this;
}
public function getCreatedBy(): ?int
{
return $this->created_by;
}
public function setCreatedBy(int $created_by): self
{
$this->created_by = $created_by;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getDeleted(): ?int
{
return $this->deleted;
}
public function setDeleted(?int $deleted): self
{
$this->deleted = $deleted;
return $this;
}
public function getAssignedUserId(): ?int
{
return $this->assigned_user_id;
}
public function setAssignedUserId(?int $assigned_user_id): self
{
$this->assigned_user_id = $assigned_user_id;
return $this;
}
public function getEdrpou(): ?string
{
return $this->edrpou;
}
public function setEdrpou(?string $edrpou): self
{
$this->edrpou = $edrpou;
return $this;
}
public function getBillingAddressCity(): ?string
{
return $this->billing_address_city;
}
public function setBillingAddressCity(?string $billing_address_city): self
{
$this->billing_address_city = $billing_address_city;
return $this;
}
public function getBillingAddressState(): ?string
{
return $this->billing_address_state;
}
public function setBillingAddressState(?string $billing_address_state): self
{
$this->billing_address_state = $billing_address_state;
return $this;
}
public function getBillingAddressCountry(): ?string
{
return $this->billing_address_country;
}
public function setBillingAddressCountry(?string $billing_address_country): self
{
$this->billing_address_country = $billing_address_country;
return $this;
}
public function getBillingAddressStreet(): ?string
{
return $this->billing_address_street;
}
public function setBillingAddressStreet(?string $billing_address_street): self
{
$this->billing_address_street = $billing_address_street;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): self
{
$this->phone = $phone;
return $this;
}
/**
* @return Collection<int, Orders>
*/
public function getOrders(): Collection
{
return $this->orders;
}
public function addOrder(Orders $order): self
{
if (!$this->orders->contains($order)) {
$this->orders->add($order);
$order->setAccountId($this);
}
return $this;
}
public function removeOrder(Orders $order): self
{
if ($this->orders->removeElement($order)) {
// set the owning side to null (unless already changed)
if ($order->getAccountId() === $this) {
$order->setAccountId(null);
}
}
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
/**
* @return Collection<int, IncomingInvoice>
*/
public function getInvoiceSupplier(): Collection
{
return $this->invoice_supplier;
}
public function addInvoiceSupplier(IncomingInvoice $invoiceSupplier): self
{
if (!$this->invoice_supplier->contains($invoiceSupplier)) {
$this->invoice_supplier->add($invoiceSupplier);
$invoiceSupplier->setSupplier($this);
}
return $this;
}
public function removeInvoiceSupplier(IncomingInvoice $invoiceSupplier): self
{
if ($this->invoice_supplier->removeElement($invoiceSupplier)) {
// set the owning side to null (unless already changed)
if ($invoiceSupplier->getSupplier() === $this) {
$invoiceSupplier->setSupplier(null);
}
}
return $this;
}
public function getIpn(): ?string
{
return $this->ipn;
}
public function setIpn(?string $ipn): self
{
$this->ipn = $ipn;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): self
{
$this->type = $type;
return $this;
}
public function getParent(): ?self
{
return $this->parent;
}
public function setParent(?self $parent): self
{
$this->parent = $parent;
return $this;
}
/**
* @return Collection<int, self>
*/
public function getAccounts(): Collection
{
return $this->accounts;
}
public function addAccount(self $account): self
{
if (!$this->accounts->contains($account)) {
$this->accounts->add($account);
$account->setParent($this);
}
return $this;
}
public function removeAccount(self $account): self
{
if ($this->accounts->removeElement($account)) {
// set the owning side to null (unless already changed)
if ($account->getParent() === $this) {
$account->setParent(null);
}
}
return $this;
}
public function getDirector(): ?string
{
return $this->director;
}
public function setDirector(?string $director): self
{
$this->director = $director;
return $this;
}
public function getCode1c(): ?string
{
return $this->code1c;
}
public function setCode1c(?string $code1c): self
{
$this->code1c = $code1c;
return $this;
}
/**
* @return Collection<int, Contacts>
*/
public function getContacts(): Collection
{
return $this->contacts;
}
public function addContact(Contacts $contact): self
{
if (!$this->contacts->contains($contact)) {
$this->contacts->add($contact);
$contact->setAccount($this);
}
return $this;
}
public function removeContact(Contacts $contact): self
{
if ($this->contacts->removeElement($contact)) {
// set the owning side to null (unless already changed)
if ($contact->getAccount() === $this) {
$contact->setAccount(null);
}
}
return $this;
}
public function getManager(): ?User
{
return $this->manager;
}
public function setManager(?User $manager): self
{
$this->manager = $manager;
return $this;
}
/**
* @return Collection<int, PreOrder>
*/
public function getPreOrders(): Collection
{
return $this->preOrders;
}
public function addPreOrder(PreOrder $preOrder): self
{
if (!$this->preOrders->contains($preOrder)) {
$this->preOrders->add($preOrder);
$preOrder->setAccount($this);
}
return $this;
}
public function removePreOrder(PreOrder $preOrder): self
{
if ($this->preOrders->removeElement($preOrder)) {
// set the owning side to null (unless already changed)
if ($preOrder->getAccount() === $this) {
$preOrder->setAccount(null);
}
}
return $this;
}
/**
* @return Collection<int, LoadInvoice>
*/
public function getLoadInvoices(): Collection
{
return $this->loadInvoices;
}
public function addLoadInvoice(LoadInvoice $loadInvoice): self
{
if (!$this->loadInvoices->contains($loadInvoice)) {
$this->loadInvoices->add($loadInvoice);
$loadInvoice->setAccount($this);
}
return $this;
}
public function removeLoadInvoice(LoadInvoice $loadInvoice): self
{
if ($this->loadInvoices->removeElement($loadInvoice)) {
// set the owning side to null (unless already changed)
if ($loadInvoice->getAccount() === $this) {
$loadInvoice->setAccount(null);
}
}
return $this;
}
/**
* @return Collection<int, Agreements>
*/
public function getOrganization(): Collection
{
return $this->organization;
}
public function addOrganization(Agreements $organization): self
{
if (!$this->organization->contains($organization)) {
$this->organization->add($organization);
$organization->setOrganization($this);
}
return $this;
}
public function removeOrganization(Agreements $organization): self
{
if ($this->organization->removeElement($organization)) {
// set the owning side to null (unless already changed)
if ($organization->getOrganization() === $this) {
$organization->setOrganization(null);
}
}
return $this;
}
/**
* @return Collection<int, Agreements>
*/
public function getAgreements(): Collection
{
return $this->agreements;
}
public function addAgreement(Agreements $agreement): self
{
if (!$this->agreements->contains($agreement)) {
$this->agreements->add($agreement);
$agreement->setAccount($this);
}
return $this;
}
public function removeAgreement(Agreements $agreement): self
{
if ($this->agreements->removeElement($agreement)) {
// set the owning side to null (unless already changed)
if ($agreement->getAccount() === $this) {
$agreement->setAccount(null);
}
}
return $this;
}
public function getVirtualAgreementSpecfication(): ?Agreements
{
return $this->virtualAgreementSpecfication;
}
public function setVirtualAgreementSpecfication(?Agreements $virtualAgreementSpecfication): static
{
$this->virtualAgreementSpecfication = $virtualAgreementSpecfication;
return $this;
}
/**
* @return Collection<int, AccountAddress>
*/
public function getAccountAddresses(): Collection
{
return $this->accountAddresses;
}
public function addAccountAddress(AccountAddress $accountAddress): self
{
if (!$this->accountAddresses->contains($accountAddress)) {
$this->accountAddresses->add($accountAddress);
$accountAddress->setAccount($this);
}
return $this;
}
public function removeAccountAddress(AccountAddress $accountAddress): self
{
if ($this->accountAddresses->removeElement($accountAddress)) {
// set the owning side to null (unless already changed)
if ($accountAddress->getAccount() === $this) {
$accountAddress->setAccount(null);
}
}
return $this;
}
/**
* @return Collection<int, AccountWorker>
*/
public function getAccountWorkers(): Collection
{
return $this->accountWorkers;
}
public function addAccountWorker(AccountWorker $accountWorker): self
{
if (!$this->accountWorkers->contains($accountWorker)) {
$this->accountWorkers->add($accountWorker);
$accountWorker->setAccount($this);
}
return $this;
}
public function removeAccountWorker(AccountWorker $accountWorker): self
{
if ($this->accountWorkers->removeElement($accountWorker)) {
// set the owning side to null (unless already changed)
if ($accountWorker->getAccount() === $this) {
$accountWorker->setAccount(null);
}
}
return $this;
}
/**
* @return Collection<int, Jobs>
*/
public function getJobs(): Collection
{
return $this->jobs;
}
public function addJob(Jobs $job): self
{
if (!$this->jobs->contains($job)) {
$this->jobs->add($job);
$job->setAccount($this);
}
return $this;
}
public function removeJob(Jobs $job): self
{
if ($this->jobs->removeElement($job)) {
// set the owning side to null (unless already changed)
if ($job->getAccount() === $this) {
$job->setAccount(null);
}
}
return $this;
}
/**
* @return Collection<int, AccountJobsList>
*/
public function getAccountJobsLists(): Collection
{
return $this->accountJobsLists;
}
public function addAccountJobsList(AccountJobsList $accountJobsList): self
{
if (!$this->accountJobsLists->contains($accountJobsList)) {
$this->accountJobsLists->add($accountJobsList);
$accountJobsList->setAccount($this);
}
return $this;
}
public function removeAccountJobsList(AccountJobsList $accountJobsList): self
{
if ($this->accountJobsLists->removeElement($accountJobsList)) {
// set the owning side to null (unless already changed)
if ($accountJobsList->getAccount() === $this) {
$accountJobsList->setAccount(null);
}
}
return $this;
}
}