src/Entity/Sales.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Enum\SalesStatus;
  4. use App\Repository\SalesRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassSalesRepository::class)]
  9. #[ORM\HasLifecycleCallbacks]
  10. #[ORM\Table(name'sales')]
  11. class Sales extends BaseEntity
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column(type'integer')]
  16.     private $id;
  17.     #[ORM\Column(type'string'length255nullabletrue)]
  18.     private $invoiceNumber;
  19.     #[ORM\Column(type'decimal'precision19scale4)]
  20.     private $totalPurchasePrice;
  21.     #[ORM\OneToMany(mappedBy'sales'targetEntityProductsSold::class)]
  22.     private $productsSolds;
  23.     #[ORM\ManyToOne(targetEntityUser::class, inversedBy'sales')]
  24.     #[ORM\JoinColumn(nullablefalse)]
  25.     private $seller;
  26.     #[ORM\ManyToOne(targetEntityWarehouse::class, inversedBy'sales')]
  27.     private $warehouse;
  28.     #[ORM\Column(type'date'nullabletrue)]
  29.     private $salesDate;
  30.     #[ORM\Column(type'date'nullabletrue)]
  31.     private $deliveryDate;
  32.     #[ORM\Column(type'date'nullabletrue)]
  33.     private $dueDate;
  34.     #[ORM\Column(type'date'nullabletrue)]
  35.     private $validDate;
  36.     #[ORM\ManyToOne(targetEntityCustomer::class, inversedBy'sales')]
  37.     #[ORM\JoinColumn(nullablefalse)]
  38.     private $customer;
  39.     #[ORM\OneToMany(mappedBy'sales'targetEntityPayment::class)]
  40.     private $payments;
  41.     #[ORM\OneToMany(mappedBy'sale'targetEntityStockTransaction::class)]
  42.     private $stockTransactions;
  43.     #[ORM\OneToMany(mappedBy'sale'targetEntitySalesReturn::class, cascade: ['persist'], orphanRemovaltrue)]
  44.     private Collection $returns;
  45.     #[ORM\OneToMany(mappedBy'sale'targetEntityEmailMessage::class)]
  46.     private Collection $emailMessages;
  47.     #[ORM\OneToMany(mappedBy'sale'targetEntitySalesHistory::class, cascade: ['persist'], orphanRemovaltrue)]
  48.     private Collection $historyEntries;
  49.     #[ORM\OneToMany(mappedBy'sale'targetEntityGiftProduct::class, cascade: ['persist'], orphanRemovaltrue)]
  50.     private Collection $giftProducts;
  51.     #[ORM\OneToOne(targetEntityInvoice::class, inversedBy'proforma'cascade: ['persist''remove'], orphanRemovaltrue)]
  52.     #[ORM\JoinColumn(name'invoice_id'referencedColumnName'id'nullabletrueonDelete'SET NULL')]
  53.     private ?Invoice $invoice null;
  54.     #[ORM\Column(length255nullabletrue)]
  55.     private ?string $description null;
  56.     #[ORM\Column(length255nullabletrue)]
  57.     private ?string $shippingNotes null;
  58.     #[ORM\Column(length255nullabletrue)]
  59.     private ?string $paymentNotes null;
  60.     #[ORM\Column(length255nullabletrue)]
  61.     private SalesStatus|null $status null;
  62.     #[ORM\ManyToOne(targetEntityCompany::class)]
  63.     #[ORM\JoinColumn(nullabletrue)]
  64.     private ?Company $company null;
  65.     #[ORM\Column]
  66.     private ?bool $visible true;
  67.     #[ORM\Column(nullabletrue)]
  68.     private ?bool $deleted false;
  69.     /**
  70.      * @return mixed
  71.      */
  72.     public function getCustomer()
  73.     {
  74.         return $this->customer;
  75.     }
  76.     /**
  77.      * @param mixed $customer
  78.      */
  79.     public function setCustomer($customer): void
  80.     {
  81.         $this->customer $customer;
  82.     }
  83.     public function __construct()
  84.     {
  85.         $this->productsSolds = new ArrayCollection();
  86.         $this->payments = new ArrayCollection();
  87.         $this->stockTransactions = new ArrayCollection();
  88.         $this->emailMessages = new ArrayCollection();
  89.         $this->historyEntries = new ArrayCollection();
  90.         $this->returns = new ArrayCollection();
  91.         $this->giftProducts = new ArrayCollection();
  92.     }
  93.     /**
  94.      * @return Collection<int, SalesReturn>
  95.      */
  96.     public function getReturns(): Collection
  97.     {
  98.         return $this->returns;
  99.     }
  100.     public function addReturn(SalesReturn $salesReturn): self
  101.     {
  102.         if (!$this->returns->contains($salesReturn)) {
  103.             $this->returns->add($salesReturn);
  104.             $salesReturn->setSale($this);
  105.         }
  106.         return $this;
  107.     }
  108.     public function removeReturn(SalesReturn $salesReturn): self
  109.     {
  110.         if ($this->returns->removeElement($salesReturn)) {
  111.             if ($salesReturn->getSale() === $this) {
  112.                 $salesReturn->setSale(null);
  113.             }
  114.         }
  115.         return $this;
  116.     }
  117.     public function getId(): ?int
  118.     {
  119.         return $this->id;
  120.     }
  121.     public function getInvoiceNumber(): ?string
  122.     {
  123.         return $this->invoiceNumber;
  124.     }
  125.     public function setInvoiceNumber(?string $invoiceNumber): self
  126.     {
  127.         $this->invoiceNumber $invoiceNumber;
  128.         return $this;
  129.     }
  130.     /**
  131.      * @return Collection<int, EmailMessage>
  132.      */
  133.     public function getEmailMessages(): Collection
  134.     {
  135.         return $this->emailMessages;
  136.     }
  137.     public function addEmailMessage(EmailMessage $emailMessage): self
  138.     {
  139.         if (!$this->emailMessages->contains($emailMessage)) {
  140.             $this->emailMessages->add($emailMessage);
  141.             $emailMessage->setSale($this);
  142.         }
  143.         return $this;
  144.     }
  145.     public function removeEmailMessage(EmailMessage $emailMessage): self
  146.     {
  147.         if ($this->emailMessages->removeElement($emailMessage)) {
  148.             if ($emailMessage->getSale() === $this) {
  149.                 $emailMessage->setSale(null);
  150.             }
  151.         }
  152.         return $this;
  153.     }
  154.     /**
  155.      * @return Collection<int, SalesHistory>
  156.      */
  157.     public function getHistoryEntries(): Collection
  158.     {
  159.         return $this->historyEntries;
  160.     }
  161.     public function addHistoryEntry(SalesHistory $historyEntry): self
  162.     {
  163.         if (!$this->historyEntries->contains($historyEntry)) {
  164.             $this->historyEntries->add($historyEntry);
  165.             $historyEntry->setSale($this);
  166.         }
  167.         return $this;
  168.     }
  169.     public function removeHistoryEntry(SalesHistory $historyEntry): self
  170.     {
  171.         if ($this->historyEntries->removeElement($historyEntry)) {
  172.             if ($historyEntry->getSale() === $this) {
  173.                 $historyEntry->setSale(null);
  174.             }
  175.         }
  176.         return $this;
  177.     }
  178.     /**
  179.      * @return mixed
  180.      */
  181.     public function getSalesDate()
  182.     {
  183.         return $this->salesDate;
  184.     }
  185.     /**
  186.      * @param mixed $salesDate
  187.      */
  188.     public function setSalesDate($salesDate): void
  189.     {
  190.         $this->salesDate $salesDate;
  191.     }
  192.     public function getTotalPurchasePrice(): ?float
  193.     {
  194.         return $this->totalPurchasePrice;
  195.     }
  196.     public function setTotalPurchasePrice(float $totalPurchasePrice): self
  197.     {
  198.         $this->totalPurchasePrice $totalPurchasePrice;
  199.         return $this;
  200.     }
  201.     /**
  202.      * @return Collection<int, ProductsSold>
  203.      */
  204.     public function getProductsSolds(): Collection
  205.     {
  206.         return $this->productsSolds;
  207.     }
  208.     public function addProductsSold(ProductsSold $productsSold): self
  209.     {
  210.         if (!$this->productsSolds->contains($productsSold)) {
  211.             $this->productsSolds[] = $productsSold;
  212.             $productsSold->setSales($this);
  213.         }
  214.         return $this;
  215.     }
  216.     public function removeProductsSold(ProductsSold $productsSold): self
  217.     {
  218.         if ($this->productsSolds->removeElement($productsSold)) {
  219.             // set the owning side to null (unless already changed)
  220.             if ($productsSold->getSales() === $this) {
  221.                 $productsSold->setSales(null);
  222.             }
  223.         }
  224.         return $this;
  225.     }
  226.     public function getSeller(): ?User
  227.     {
  228.         return $this->seller;
  229.     }
  230.     public function setSeller(?User $seller): self
  231.     {
  232.         $this->seller $seller;
  233.         return $this;
  234.     }
  235.     public function getWarehouse(): ?Warehouse
  236.     {
  237.         return $this->warehouse;
  238.     }
  239.     public function setWarehouse(?Warehouse $warehouse): self
  240.     {
  241.         $this->warehouse $warehouse;
  242.         return $this;
  243.     }
  244.     /**
  245.      * @return Collection<int, Payment>
  246.      */
  247.     public function getPayments(): Collection
  248.     {
  249.         return $this->payments;
  250.     }
  251.     public function addPayment(Payment $payment): self
  252.     {
  253.         if (!$this->payments->contains($payment)) {
  254.             $this->payments[] = $payment;
  255.             $payment->setSales($this);
  256.         }
  257.         return $this;
  258.     }
  259.     public function removePayment(Payment $payment): self
  260.     {
  261.         if ($this->payments->removeElement($payment)) {
  262.             // set the owning side to null (unless already changed)
  263.             if ($payment->getSales() === $this) {
  264.                 $payment->setSales(null);
  265.             }
  266.         }
  267.         return $this;
  268.     }
  269.     /**
  270.      * @return Collection<int, StockTransaction>
  271.      */
  272.     public function getStockTransactions(): Collection
  273.     {
  274.         return $this->stockTransactions;
  275.     }
  276.     public function addStockTransaction(StockTransaction $stockTransaction): self
  277.     {
  278.         if (!$this->stockTransactions->contains($stockTransaction)) {
  279.             $this->stockTransactions[] = $stockTransaction;
  280.             $stockTransaction->setSale($this);
  281.         }
  282.         return $this;
  283.     }
  284.     public function removeStockTransaction(StockTransaction $stockTransaction): self
  285.     {
  286.         if ($this->stockTransactions->removeElement($stockTransaction)) {
  287.             // set the owning side to null (unless already changed)
  288.             if ($stockTransaction->getSale() === $this) {
  289.                 $stockTransaction->setSale(null);
  290.             }
  291.         }
  292.         return $this;
  293.     }
  294.     public function getInvoice(): ?Invoice
  295.     {
  296.         return $this->invoice;
  297.     }
  298.     public function setInvoice(?Invoice $invoice): self
  299.     {
  300.         $this->invoice $invoice;
  301.         return $this;
  302.     }
  303.     public function getDescription(): ?string
  304.     {
  305.         return $this->description;
  306.     }
  307.     public function setDescription(?string $description): static
  308.     {
  309.         $this->description $description;
  310.         return $this;
  311.     }
  312.     public function getShippingNotes(): ?string
  313.     {
  314.         return $this->shippingNotes;
  315.     }
  316.     public function setShippingNotes(?string $shippingNotes): static
  317.     {
  318.         $this->shippingNotes $shippingNotes;
  319.         return $this;
  320.     }
  321.     public function getPaymentNotes(): ?string
  322.     {
  323.         return $this->paymentNotes;
  324.     }
  325.     public function setPaymentNotes(?string $paymentNotes): static
  326.     {
  327.         $this->paymentNotes $paymentNotes;
  328.         return $this;
  329.     }
  330.     /**
  331.      * @return mixed
  332.      */
  333.     public function getDeliveryDate()
  334.     {
  335.         return $this->deliveryDate;
  336.     }
  337.     /**
  338.      * @param mixed $deliveryDate
  339.      */
  340.     public function setDeliveryDate($deliveryDate): void
  341.     {
  342.         $this->deliveryDate $deliveryDate;
  343.     }
  344.     /**
  345.      * @return mixed
  346.      */
  347.     public function getDueDate()
  348.     {
  349.         return $this->dueDate;
  350.     }
  351.     /**
  352.      * @param mixed $dueDate
  353.      */
  354.     public function setDueDate($dueDate): void
  355.     {
  356.         $this->dueDate $dueDate;
  357.     }
  358.     /**
  359.      * @return mixed
  360.      */
  361.     public function getValidDate()
  362.     {
  363.         return $this->validDate;
  364.     }
  365.     /**
  366.      * @param mixed $validDate
  367.      */
  368.     public function setValidDate($validDate): void
  369.     {
  370.         $this->validDate $validDate;
  371.     }
  372.     public function getStatus(): ?SalesStatus
  373.     {
  374.         return $this->status;
  375.     }
  376.     public function setStatus(?SalesStatus $status): void
  377.     {
  378.         $this->status $status;
  379.     }
  380.     public function isVisible(): ?bool
  381.     {
  382.         return $this->visible;
  383.     }
  384.     public function setVisible(bool $visible): static
  385.     {
  386.         $this->visible $visible;
  387.         return $this;
  388.     }
  389.     public function isDeleted(): ?bool
  390.     {
  391.         return $this->deleted;
  392.     }
  393.     public function setDeleted(?bool $deleted): self
  394.     {
  395.         $this->deleted $deleted;
  396.         return $this;
  397.     }
  398.     /**
  399.      * @return Collection<int, GiftProduct>
  400.      */
  401.     public function getGiftProducts(): Collection
  402.     {
  403.         return $this->giftProducts;
  404.     }
  405.     public function addGiftProduct(GiftProduct $giftProduct): self
  406.     {
  407.         if (!$this->giftProducts->contains($giftProduct)) {
  408.             $this->giftProducts->add($giftProduct);
  409.             $giftProduct->setSale($this);
  410.         }
  411.         return $this;
  412.     }
  413.     public function removeGiftProduct(GiftProduct $giftProduct): self
  414.     {
  415.         if ($this->giftProducts->removeElement($giftProduct)) {
  416.             if ($giftProduct->getSale() === $this) {
  417.                 $giftProduct->setSale(null);
  418.             }
  419.         }
  420.         return $this;
  421.     }
  422.     public function getCompany(): ?Company
  423.     {
  424.         return $this->company;
  425.     }
  426.     public function setCompany(?Company $company): self
  427.     {
  428.         $this->company $company;
  429.         return $this;
  430.     }
  431. }