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\Column]
  63.     private ?bool $visible true;
  64.     #[ORM\Column(nullabletrue)]
  65.     private ?bool $deleted false;
  66.     /**
  67.      * @return mixed
  68.      */
  69.     public function getCustomer()
  70.     {
  71.         return $this->customer;
  72.     }
  73.     /**
  74.      * @param mixed $customer
  75.      */
  76.     public function setCustomer($customer): void
  77.     {
  78.         $this->customer $customer;
  79.     }
  80.     public function __construct()
  81.     {
  82.         $this->productsSolds = new ArrayCollection();
  83.         $this->payments = new ArrayCollection();
  84.         $this->stockTransactions = new ArrayCollection();
  85.         $this->emailMessages = new ArrayCollection();
  86.         $this->historyEntries = new ArrayCollection();
  87.         $this->returns = new ArrayCollection();
  88.         $this->giftProducts = new ArrayCollection();
  89.     }
  90.     /**
  91.      * @return Collection<int, SalesReturn>
  92.      */
  93.     public function getReturns(): Collection
  94.     {
  95.         return $this->returns;
  96.     }
  97.     public function addReturn(SalesReturn $salesReturn): self
  98.     {
  99.         if (!$this->returns->contains($salesReturn)) {
  100.             $this->returns->add($salesReturn);
  101.             $salesReturn->setSale($this);
  102.         }
  103.         return $this;
  104.     }
  105.     public function removeReturn(SalesReturn $salesReturn): self
  106.     {
  107.         if ($this->returns->removeElement($salesReturn)) {
  108.             if ($salesReturn->getSale() === $this) {
  109.                 $salesReturn->setSale(null);
  110.             }
  111.         }
  112.         return $this;
  113.     }
  114.     public function getId(): ?int
  115.     {
  116.         return $this->id;
  117.     }
  118.     public function getInvoiceNumber(): ?string
  119.     {
  120.         return $this->invoiceNumber;
  121.     }
  122.     public function setInvoiceNumber(?string $invoiceNumber): self
  123.     {
  124.         $this->invoiceNumber $invoiceNumber;
  125.         return $this;
  126.     }
  127.     /**
  128.      * @return Collection<int, EmailMessage>
  129.      */
  130.     public function getEmailMessages(): Collection
  131.     {
  132.         return $this->emailMessages;
  133.     }
  134.     public function addEmailMessage(EmailMessage $emailMessage): self
  135.     {
  136.         if (!$this->emailMessages->contains($emailMessage)) {
  137.             $this->emailMessages->add($emailMessage);
  138.             $emailMessage->setSale($this);
  139.         }
  140.         return $this;
  141.     }
  142.     public function removeEmailMessage(EmailMessage $emailMessage): self
  143.     {
  144.         if ($this->emailMessages->removeElement($emailMessage)) {
  145.             if ($emailMessage->getSale() === $this) {
  146.                 $emailMessage->setSale(null);
  147.             }
  148.         }
  149.         return $this;
  150.     }
  151.     /**
  152.      * @return Collection<int, SalesHistory>
  153.      */
  154.     public function getHistoryEntries(): Collection
  155.     {
  156.         return $this->historyEntries;
  157.     }
  158.     public function addHistoryEntry(SalesHistory $historyEntry): self
  159.     {
  160.         if (!$this->historyEntries->contains($historyEntry)) {
  161.             $this->historyEntries->add($historyEntry);
  162.             $historyEntry->setSale($this);
  163.         }
  164.         return $this;
  165.     }
  166.     public function removeHistoryEntry(SalesHistory $historyEntry): self
  167.     {
  168.         if ($this->historyEntries->removeElement($historyEntry)) {
  169.             if ($historyEntry->getSale() === $this) {
  170.                 $historyEntry->setSale(null);
  171.             }
  172.         }
  173.         return $this;
  174.     }
  175.     /**
  176.      * @return mixed
  177.      */
  178.     public function getSalesDate()
  179.     {
  180.         return $this->salesDate;
  181.     }
  182.     /**
  183.      * @param mixed $salesDate
  184.      */
  185.     public function setSalesDate($salesDate): void
  186.     {
  187.         $this->salesDate $salesDate;
  188.     }
  189.     public function getTotalPurchasePrice(): ?float
  190.     {
  191.         return $this->totalPurchasePrice;
  192.     }
  193.     public function setTotalPurchasePrice(float $totalPurchasePrice): self
  194.     {
  195.         $this->totalPurchasePrice $totalPurchasePrice;
  196.         return $this;
  197.     }
  198.     /**
  199.      * @return Collection<int, ProductsSold>
  200.      */
  201.     public function getProductsSolds(): Collection
  202.     {
  203.         return $this->productsSolds;
  204.     }
  205.     public function addProductsSold(ProductsSold $productsSold): self
  206.     {
  207.         if (!$this->productsSolds->contains($productsSold)) {
  208.             $this->productsSolds[] = $productsSold;
  209.             $productsSold->setSales($this);
  210.         }
  211.         return $this;
  212.     }
  213.     public function removeProductsSold(ProductsSold $productsSold): self
  214.     {
  215.         if ($this->productsSolds->removeElement($productsSold)) {
  216.             // set the owning side to null (unless already changed)
  217.             if ($productsSold->getSales() === $this) {
  218.                 $productsSold->setSales(null);
  219.             }
  220.         }
  221.         return $this;
  222.     }
  223.     public function getSeller(): ?User
  224.     {
  225.         return $this->seller;
  226.     }
  227.     public function setSeller(?User $seller): self
  228.     {
  229.         $this->seller $seller;
  230.         return $this;
  231.     }
  232.     public function getWarehouse(): ?Warehouse
  233.     {
  234.         return $this->warehouse;
  235.     }
  236.     public function setWarehouse(?Warehouse $warehouse): self
  237.     {
  238.         $this->warehouse $warehouse;
  239.         return $this;
  240.     }
  241.     /**
  242.      * @return Collection<int, Payment>
  243.      */
  244.     public function getPayments(): Collection
  245.     {
  246.         return $this->payments;
  247.     }
  248.     public function addPayment(Payment $payment): self
  249.     {
  250.         if (!$this->payments->contains($payment)) {
  251.             $this->payments[] = $payment;
  252.             $payment->setSales($this);
  253.         }
  254.         return $this;
  255.     }
  256.     public function removePayment(Payment $payment): self
  257.     {
  258.         if ($this->payments->removeElement($payment)) {
  259.             // set the owning side to null (unless already changed)
  260.             if ($payment->getSales() === $this) {
  261.                 $payment->setSales(null);
  262.             }
  263.         }
  264.         return $this;
  265.     }
  266.     /**
  267.      * @return Collection<int, StockTransaction>
  268.      */
  269.     public function getStockTransactions(): Collection
  270.     {
  271.         return $this->stockTransactions;
  272.     }
  273.     public function addStockTransaction(StockTransaction $stockTransaction): self
  274.     {
  275.         if (!$this->stockTransactions->contains($stockTransaction)) {
  276.             $this->stockTransactions[] = $stockTransaction;
  277.             $stockTransaction->setSale($this);
  278.         }
  279.         return $this;
  280.     }
  281.     public function removeStockTransaction(StockTransaction $stockTransaction): self
  282.     {
  283.         if ($this->stockTransactions->removeElement($stockTransaction)) {
  284.             // set the owning side to null (unless already changed)
  285.             if ($stockTransaction->getSale() === $this) {
  286.                 $stockTransaction->setSale(null);
  287.             }
  288.         }
  289.         return $this;
  290.     }
  291.     public function getInvoice(): ?Invoice
  292.     {
  293.         return $this->invoice;
  294.     }
  295.     public function setInvoice(?Invoice $invoice): self
  296.     {
  297.         $this->invoice $invoice;
  298.         return $this;
  299.     }
  300.     public function getDescription(): ?string
  301.     {
  302.         return $this->description;
  303.     }
  304.     public function setDescription(?string $description): static
  305.     {
  306.         $this->description $description;
  307.         return $this;
  308.     }
  309.     public function getShippingNotes(): ?string
  310.     {
  311.         return $this->shippingNotes;
  312.     }
  313.     public function setShippingNotes(?string $shippingNotes): static
  314.     {
  315.         $this->shippingNotes $shippingNotes;
  316.         return $this;
  317.     }
  318.     public function getPaymentNotes(): ?string
  319.     {
  320.         return $this->paymentNotes;
  321.     }
  322.     public function setPaymentNotes(?string $paymentNotes): static
  323.     {
  324.         $this->paymentNotes $paymentNotes;
  325.         return $this;
  326.     }
  327.     /**
  328.      * @return mixed
  329.      */
  330.     public function getDeliveryDate()
  331.     {
  332.         return $this->deliveryDate;
  333.     }
  334.     /**
  335.      * @param mixed $deliveryDate
  336.      */
  337.     public function setDeliveryDate($deliveryDate): void
  338.     {
  339.         $this->deliveryDate $deliveryDate;
  340.     }
  341.     /**
  342.      * @return mixed
  343.      */
  344.     public function getDueDate()
  345.     {
  346.         return $this->dueDate;
  347.     }
  348.     /**
  349.      * @param mixed $dueDate
  350.      */
  351.     public function setDueDate($dueDate): void
  352.     {
  353.         $this->dueDate $dueDate;
  354.     }
  355.     /**
  356.      * @return mixed
  357.      */
  358.     public function getValidDate()
  359.     {
  360.         return $this->validDate;
  361.     }
  362.     /**
  363.      * @param mixed $validDate
  364.      */
  365.     public function setValidDate($validDate): void
  366.     {
  367.         $this->validDate $validDate;
  368.     }
  369.     public function getStatus(): ?SalesStatus
  370.     {
  371.         return $this->status;
  372.     }
  373.     public function setStatus(?SalesStatus $status): void
  374.     {
  375.         $this->status $status;
  376.     }
  377.     public function isVisible(): ?bool
  378.     {
  379.         return $this->visible;
  380.     }
  381.     public function setVisible(bool $visible): static
  382.     {
  383.         $this->visible $visible;
  384.         return $this;
  385.     }
  386.     public function isDeleted(): ?bool
  387.     {
  388.         return $this->deleted;
  389.     }
  390.     public function setDeleted(?bool $deleted): self
  391.     {
  392.         $this->deleted $deleted;
  393.         return $this;
  394.     }
  395.     /**
  396.      * @return Collection<int, GiftProduct>
  397.      */
  398.     public function getGiftProducts(): Collection
  399.     {
  400.         return $this->giftProducts;
  401.     }
  402.     public function addGiftProduct(GiftProduct $giftProduct): self
  403.     {
  404.         if (!$this->giftProducts->contains($giftProduct)) {
  405.             $this->giftProducts->add($giftProduct);
  406.             $giftProduct->setSale($this);
  407.         }
  408.         return $this;
  409.     }
  410.     public function removeGiftProduct(GiftProduct $giftProduct): self
  411.     {
  412.         if ($this->giftProducts->removeElement($giftProduct)) {
  413.             if ($giftProduct->getSale() === $this) {
  414.                 $giftProduct->setSale(null);
  415.             }
  416.         }
  417.         return $this;
  418.     }
  419. }