src/Entity/SalesReturnItem.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Enum\RestockingAction;
  4. use App\Enum\ReturnItemCondition;
  5. use App\Repository\SalesReturnItemRepository;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassSalesReturnItemRepository::class)]
  9. #[ORM\Table(name'sales_return_item')]
  10. #[ORM\HasLifecycleCallbacks]
  11. class SalesReturnItem extends BaseEntity
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column(type'integer')]
  16.     private ?int $id null;
  17.     #[ORM\ManyToOne(targetEntitySalesReturn::class, inversedBy'items')]
  18.     #[ORM\JoinColumn(nullablefalseonDelete'CASCADE')]
  19.     private ?SalesReturn $salesReturn null;
  20.     #[ORM\ManyToOne(targetEntityProductsSold::class)]
  21.     #[ORM\JoinColumn(nullablefalseonDelete'CASCADE')]
  22.     private ?ProductsSold $productsSold null;
  23.     #[ORM\Column(typeTypes::DECIMALprecision15scale4)]
  24.     private string $requestedQuantity;
  25.     #[ORM\Column(typeTypes::DECIMALprecision15scale4) ]
  26.     private string $approvedQuantity;
  27.     #[ORM\Column(typeTypes::DECIMALprecision15scale4)]
  28.     private string $approvedBaseQuantity;
  29.     #[ORM\Column(typeTypes::DECIMALprecision15scale4options: ['default' => '0.0000'])]
  30.     private string $goodQuantity '0.0000';
  31.     #[ORM\Column(typeTypes::DECIMALprecision15scale4options: ['default' => '0.0000'])]
  32.     private string $goodBaseQuantity '0.0000';
  33.     #[ORM\Column(typeTypes::DECIMALprecision15scale4options: ['default' => '0.0000'])]
  34.     private string $damagedQuantity '0.0000';
  35.     #[ORM\Column(typeTypes::DECIMALprecision15scale4options: ['default' => '0.0000'])]
  36.     private string $damagedBaseQuantity '0.0000';
  37.     #[ORM\Column(typeTypes::BOOLEANoptions: ['default' => false])]
  38.     private bool $restocked false;
  39.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLEnullabletrue)]
  40.     private ?\DateTimeImmutable $restockedAt null;
  41.     #[ORM\Column(name'item_condition'length32enumTypeReturnItemCondition::class)]
  42.     private ReturnItemCondition $condition ReturnItemCondition::PRISTINE;
  43.     #[ORM\Column(length32enumTypeRestockingAction::class)]
  44.     private RestockingAction $restockingAction RestockingAction::INSPECTION;
  45.     #[ORM\Column(length180nullabletrue)]
  46.     private ?string $reason null;
  47.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  48.     private ?string $notes null;
  49.     #[ORM\OneToOne(mappedBy'salesReturnItem'targetEntityReturnDamageReport::class, cascade: ['persist''remove'])]
  50.     private ?ReturnDamageReport $damageReport null;
  51.     public function getId(): ?int
  52.     {
  53.         return $this->id;
  54.     }
  55.     public function getSalesReturn(): ?SalesReturn
  56.     {
  57.         return $this->salesReturn;
  58.     }
  59.     public function setSalesReturn(?SalesReturn $salesReturn): self
  60.     {
  61.         $this->salesReturn $salesReturn;
  62.         return $this;
  63.     }
  64.     public function getProductsSold(): ?ProductsSold
  65.     {
  66.         return $this->productsSold;
  67.     }
  68.     public function setProductsSold(ProductsSold $productsSold): self
  69.     {
  70.         $this->productsSold $productsSold;
  71.         return $this;
  72.     }
  73.     public function getRequestedQuantity(): float
  74.     {
  75.         return (float) $this->requestedQuantity;
  76.     }
  77.     public function setRequestedQuantity(float $requestedQuantity): self
  78.     {
  79.         $this->requestedQuantity = (string) $requestedQuantity;
  80.         return $this;
  81.     }
  82.     public function getApprovedQuantity(): float
  83.     {
  84.         return (float) $this->approvedQuantity;
  85.     }
  86.     public function setApprovedQuantity(float $approvedQuantity): self
  87.     {
  88.         $this->approvedQuantity = (string) $approvedQuantity;
  89.         return $this;
  90.     }
  91.     public function getApprovedBaseQuantity(): float
  92.     {
  93.         return (float) $this->approvedBaseQuantity;
  94.     }
  95.     public function setApprovedBaseQuantity(float $approvedBaseQuantity): self
  96.     {
  97.         $this->approvedBaseQuantity = (string) $approvedBaseQuantity;
  98.         return $this;
  99.     }
  100.     public function getCondition(): ReturnItemCondition
  101.     {
  102.         return $this->condition;
  103.     }
  104.     public function setCondition(ReturnItemCondition $condition): self
  105.     {
  106.         $this->condition $condition;
  107.         return $this;
  108.     }
  109.     public function getRestockingAction(): RestockingAction
  110.     {
  111.         return $this->restockingAction;
  112.     }
  113.     public function setRestockingAction(RestockingAction $restockingAction): self
  114.     {
  115.         $this->restockingAction $restockingAction;
  116.         return $this;
  117.     }
  118.     public function getReason(): ?string
  119.     {
  120.         return $this->reason;
  121.     }
  122.     public function setReason(?string $reason): self
  123.     {
  124.         $this->reason $reason;
  125.         return $this;
  126.     }
  127.     public function getNotes(): ?string
  128.     {
  129.         return $this->notes;
  130.     }
  131.     public function setNotes(?string $notes): self
  132.     {
  133.         $this->notes $notes;
  134.         return $this;
  135.     }
  136.     public function getDamageReport(): ?ReturnDamageReport
  137.     {
  138.         return $this->damageReport;
  139.     }
  140.     public function setDamageReport(?ReturnDamageReport $damageReport): self
  141.     {
  142.         if ($damageReport === null && $this->damageReport !== null) {
  143.             $this->damageReport->setSalesReturnItem(null);
  144.         }
  145.         if ($damageReport !== null && $damageReport->getSalesReturnItem() !== $this) {
  146.             $damageReport->setSalesReturnItem($this);
  147.         }
  148.         $this->damageReport $damageReport;
  149.         return $this;
  150.     }
  151.     public function getGoodQuantity(): float
  152.     {
  153.         return (float) $this->goodQuantity;
  154.     }
  155.     public function setGoodQuantity(float $goodQuantity): self
  156.     {
  157.         $this->goodQuantity = (string) $goodQuantity;
  158.         return $this;
  159.     }
  160.     public function getGoodBaseQuantity(): float
  161.     {
  162.         return (float) $this->goodBaseQuantity;
  163.     }
  164.     public function setGoodBaseQuantity(float $goodBaseQuantity): self
  165.     {
  166.         $this->goodBaseQuantity = (string) $goodBaseQuantity;
  167.         return $this;
  168.     }
  169.     public function getDamagedQuantity(): float
  170.     {
  171.         return (float) $this->damagedQuantity;
  172.     }
  173.     public function setDamagedQuantity(float $damagedQuantity): self
  174.     {
  175.         $this->damagedQuantity = (string) $damagedQuantity;
  176.         return $this;
  177.     }
  178.     public function getDamagedBaseQuantity(): float
  179.     {
  180.         return (float) $this->damagedBaseQuantity;
  181.     }
  182.     public function setDamagedBaseQuantity(float $damagedBaseQuantity): self
  183.     {
  184.         $this->damagedBaseQuantity = (string) $damagedBaseQuantity;
  185.         return $this;
  186.     }
  187.     public function isRestocked(): bool
  188.     {
  189.         return $this->restocked;
  190.     }
  191.     public function setRestocked(bool $restocked): self
  192.     {
  193.         $this->restocked $restocked;
  194.         return $this;
  195.     }
  196.     public function getRestockedAt(): ?\DateTimeImmutable
  197.     {
  198.         return $this->restockedAt;
  199.     }
  200.     public function setRestockedAt(?\DateTimeImmutable $restockedAt): self
  201.     {
  202.         $this->restockedAt $restockedAt;
  203.         return $this;
  204.     }
  205.     public function markAsRestocked(): self
  206.     {
  207.         $this->restocked true;
  208.         $this->restockedAt = new \DateTimeImmutable('now');
  209.         return $this;
  210.     }
  211.     public function __toString(): string
  212.     {
  213.         $productName $this->productsSold?->getProductName() ?? 'Unknown';
  214.         return sprintf('SalesReturnItem #%d (%s - Qty: %.2f)'$this->id ?? 0$productName$this->getApprovedQuantity());
  215.     }
  216. }