src/Entity/Item.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ItemRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. #[ORM\Table(name'`escappart_item`')]
  6. #[ORM\Entity(repositoryClassItemRepository::class)]
  7. class Item
  8. {
  9.     #[ORM\Id]
  10.     #[ORM\GeneratedValue]
  11.     #[ORM\Column]
  12.     private ?int $id null;
  13.     #[ORM\Column(length255)]
  14.     private ?string $description null;
  15.     #[ORM\Column(length255)]
  16.     private ?string $price null;
  17.     #[ORM\Column]
  18.     private ?int $quantity null;
  19.     #[ORM\Column]
  20.     private ?int $discount null;
  21.     #[ORM\ManyToOne(inversedBy'items')]
  22.     #[ORM\JoinColumn(nullablefalse)]
  23.     private ?Invoice $invoice null;
  24.     #[ORM\Column(length255)]
  25.     private ?string $subtotal null;
  26.     #[ORM\Column(length255)]
  27.     private ?string $unit_price null;
  28.     
  29.     public function __construct() {
  30.         $this->price 1;
  31.         $this->subtotal 0;
  32.         $this->unit_price 0;
  33.         $this->discount 0;
  34.         $this->quantity 1;
  35.     }
  36.     public function getId(): ?int
  37.     {
  38.         return $this->id;
  39.     }
  40.     public function getDescription(): ?string
  41.     {
  42.         return $this->description;
  43.     }
  44.     public function setDescription(string $description): self
  45.     {
  46.         $this->description $description;
  47.         return $this;
  48.     }
  49.     public function getPrice(): ?string
  50.     {
  51.         return $this->price;
  52.     }
  53.     public function setPrice(string $price): self
  54.     {
  55.         $this->price $price;
  56.         return $this;
  57.     }
  58.     public function getQuantity(): ?int
  59.     {
  60.         return $this->quantity;
  61.     }
  62.     public function setQuantity(int $quantity): self
  63.     {
  64.         $this->quantity $quantity;
  65.         return $this;
  66.     }
  67.     public function getDiscount(): ?int
  68.     {
  69.         return $this->discount;
  70.     }
  71.     public function setDiscount(int $discount): self
  72.     {
  73.         $this->discount $discount;
  74.         return $this;
  75.     }
  76.     public function getInvoice(): ?Invoice
  77.     {
  78.         return $this->invoice;
  79.     }
  80.     public function setInvoice(?Invoice $invoice): self
  81.     {
  82.         $this->invoice $invoice;
  83.         return $this;
  84.     }
  85.     public function getSubtotal(): ?string
  86.     {
  87.         return $this->subtotal;
  88.     }
  89.     public function setSubtotal(string $subtotal): self
  90.     {
  91.         $this->subtotal $subtotal;
  92.         return $this;
  93.     }
  94.     public function getUnitPrice(): ?string
  95.     {
  96.         return $this->unit_price;
  97.     }
  98.     public function setUnitPrice(string $unit_price): self
  99.     {
  100.         $this->unit_price $unit_price;
  101.         return $this;
  102.     }
  103.     
  104.     public function manageImportedItem($imported_item$vat_rate): self 
  105.     {
  106.         $this->description $imported_item["description"];
  107.         $this->quantity $imported_item["qty"];
  108.         $this->price $imported_item["price"]; 
  109.         $unit_price $imported_item["price"] / $imported_item["qty"];
  110.         $this->unit_price $vat_rate == 'included' round($unit_price / ((100) + 1), 2) : $unit_price;   
  111.         $this->subtotal $this->quantity $this->unit_price;
  112.         
  113.         return $this;
  114.     }
  115.     
  116.     public function manageHotelItem(Season $season$price): self 
  117.     {
  118.         $this->description 'Location du '.$season->getNumber().' trimestre '.$season->getYear().' ('.$season->getName().')';
  119.         $this->quantity 1;
  120.         $this->price $price
  121.         $this->unit_price round($price / ((100) + 1), 2);   
  122.         $this->subtotal $this->quantity $this->unit_price;
  123.         
  124.         return $this;
  125.     } 
  126. }