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