src/Entity/InventoryItems.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\InventoryItemsRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. /**
  8.  * @ORM\Entity(repositoryClass=InventoryItemsRepository::class)
  9.  * @ORM\HasLifecycleCallbacks
  10.  */
  11. class InventoryItems
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\ManyToOne(targetEntity=InventoryProduct::class, inversedBy="inventoryItems")
  21.      * @ORM\JoinColumn(nullable=false)
  22.      */
  23.     private $product;
  24.     /**
  25.      * @ORM\Column(type="integer", nullable=true)
  26.      */
  27.     private $qty;
  28.     /**
  29.      * @ORM\Column(type="float", nullable=true)
  30.      */
  31.     private $sale_price;
  32.     /**
  33.      * @ORM\Column(type="datetime_immutable")
  34.      */
  35.     private $created_at;
  36.     /**
  37.      * @ORM\Column(type="datetime_immutable", nullable=true)
  38.      */
  39.     private $updated_at;
  40.     /**
  41.      * @ORM\Column(type="integer")
  42.      */
  43.     private $type = -1;
  44.     /**
  45.      * @ORM\OneToMany(targetEntity=RepairItems::class, mappedBy="material")
  46.      */
  47.     private $repairItems;
  48.     public static $types = [
  49.         'Bevételezés' => 1,
  50.         'Kivételezés' => -1,
  51.     ];
  52.     /**
  53.      * @ORM\ManyToOne(targetEntity=Repairs::class, inversedBy="inventoryItem")
  54.      */
  55.     private $repairs;
  56.     /**
  57.      * @ORM\Column(type="integer", nullable=true)
  58.      */
  59.     private $purchase_price;
  60.     /**
  61.      * @ORM\Column(type="integer", nullable=true)
  62.      */
  63.     private $price_sum;
  64.     public function __construct(){
  65.         if($this->created_at == null){
  66.             $this->created_at = new \DateTimeImmutable();
  67.         }
  68.         $this->repairItems = new ArrayCollection();
  69.     }
  70.     /*
  71.      * @ORM\PrePersist
  72.      */
  73.     public function setCreatedAtValue(): void
  74.     {
  75.         $this->created_at = new \DateTimeImmutable();
  76.         $this->setUpdatedAtValue();
  77.     }
  78.     /*
  79.      * @ORM\PreUpdate
  80.      */
  81.     public function setUpdatedAtValue(): void
  82.     {
  83.         $this->updated_at = new \DateTimeImmutable();
  84.     }
  85.     public function getId(): ?int
  86.     {
  87.         return $this->id;
  88.     }
  89.     public function getProduct(): ?InventoryProduct
  90.     {
  91.         return $this->product;
  92.     }
  93.     public function setProduct(?InventoryProduct $product): self
  94.     {
  95.         $this->product = $product;
  96.         return $this;
  97.     }
  98.     public function getQty(): ?int
  99.     {
  100.         return $this->qty;
  101.     }
  102.     public function setQty(?int $qty): self
  103.     {
  104.         $this->qty = $qty;
  105.         return $this;
  106.     }
  107.     public function getPurchasePrice(): ?float
  108.     {
  109.         return $this->purchase_price;
  110.     } 
  111.     public function getPurchasePriceNum(): ?float
  112.     {
  113.         return $this->purchase_price / 100;
  114.     }
  115.     public function setPurchasePrice(?float $purchase_price): self
  116.     {
  117.         $this->purchase_price = $purchase_price;
  118.         return $this;
  119.     }
  120.     public function getSalePrice(): ?float
  121.     {
  122.         return $this->sale_price;
  123.     }
  124.     public function setSalePrice(?float $sale_price): self
  125.     {
  126.         $this->sale_price = $sale_price;
  127.         return $this;
  128.     }
  129.     public function getCreatedAt(): ?\DateTimeImmutable
  130.     {
  131.         return $this->created_at;
  132.     }
  133.     public function setCreatedAt(\DateTimeImmutable $created_at): self
  134.     {
  135.         $this->created_at = $created_at;
  136.         return $this;
  137.     }
  138.     public function getUpdatedAt(): ?\DateTimeImmutable
  139.     {
  140.         return $this->updated_at;
  141.     }
  142.     public function setUpdatedAt(?\DateTimeImmutable $updated_at): self
  143.     {
  144.         $this->updated_at = $updated_at;
  145.         return $this;
  146.     }
  147.     public function __toString()
  148.     {
  149.         return $this->qty;
  150.     }
  151.     public function getType(): ?int
  152.     {
  153.         return $this->type;
  154.     }
  155.     public function setType(int $type): self
  156.     {
  157.         $this->type = $type;
  158.         return $this;
  159.     }
  160.     /**
  161.      * @return Collection<int, RepairItems>
  162.      */
  163.     public function getRepairItems(): Collection
  164.     {
  165.         return $this->repairItems;
  166.     }
  167.     public function addRepairItem(RepairItems $repairItem): self
  168.     {
  169.         if (!$this->repairItems->contains($repairItem)) {
  170.             $this->repairItems[] = $repairItem;
  171.             $repairItem->setMaterial($this);
  172.         }
  173.         return $this;
  174.     }
  175.     public function removeRepairItem(RepairItems $repairItem): self
  176.     {
  177.         if ($this->repairItems->removeElement($repairItem)) {
  178.             // set the owning side to null (unless already changed)
  179.             if ($repairItem->getMaterial() === $this) {
  180.                 $repairItem->setMaterial(null);
  181.             }
  182.         }
  183.         return $this;
  184.     }
  185.     public function getRepairs(): ?Repairs
  186.     {
  187.         return $this->repairs;
  188.     }
  189.     public function setRepairs(?Repairs $repairs): self
  190.     {
  191.         $this->repairs = $repairs;
  192.         return $this;
  193.     }
  194.     public function getPriceSum(): ?float
  195.     {
  196.         return $this->sale_price * $this->qty;
  197.     }
  198.     public function setPriceSum(int $price_sum): self
  199.     {
  200.         $this->price_sum = $price_sum;
  201.         return $this;
  202.     }
  203. }