<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
*/
class Project
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private ?int $id = null;
/**
* @ORM\Column(type="uuid", unique=true, nullable=false)
*/
private Uuid $uuid;
/**
* @ORM\Column(type="string", nullable=false)
*/
private ?string $name = null;
#[Assert\Range(min: 0.01, max: 1.00)]
/**
* @ORM\Column(type="decimal", nullable=false, precision=3, scale=2)
*/
private ?float $electricityCostPerUnit = null;
/**
* @ORM\Column(type="integer", nullable=false, options={"default":0})
*/
private int $totalElectricitySavingsPerYear = 0;
/**
* @ORM\Column(type="decimal", nullable=false, precision=8, scale=2, options={"default":"0.00"})
* @Assert\GreaterThanOrEqual(0)
* @Assert\LessThan(999999.99)
*/
private float $totalFinancialSavingsPerYear = 0;
/**
* @ORM\Column(type="decimal", nullable=false, precision=5, scale=2, options={"default":"0.00"})
* @Assert\GreaterThanOrEqual(0)
* @Assert\LessThan(999.99)
*/
private float $yearsToBreakEven = 0;
/**
* @ORM\Column(type="decimal", nullable=true, precision=8, scale=2, options={"default":"0.00"})
* @Assert\GreaterThanOrEqual(0)
* @Assert\LessThan(999999.99)
*/
private ?float $totalInvestment;
/**
* @ORM\OneToMany(targetEntity="App\Entity\EquipmentSet", mappedBy="project", orphanRemoval=true, cascade={"persist"})
*/
private Collection $equipmentSets;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Organization", inversedBy="projects")
* @ORM\JoinColumn(name="organization_id", referencedColumnName="id", nullable=false)
*/
private ?Organization $organization = null;
public function __construct(Organization $organization)
{
$this->uuid = Uuid::v1();
$this->equipmentSets = new ArrayCollection();
$this->organization = $organization;
$this->electricityCostPerUnit = $organization->getDefaultElectricityCostPerUnit();
}
public function getId(): ?int
{
return $this->id;
}
public function getUuid(): Uuid
{
return $this->uuid;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getElectricityCostPerUnit(): ?string
{
return $this->electricityCostPerUnit;
}
public function setElectricityCostPerUnit(string $electricityCostPerUnit): self
{
$this->electricityCostPerUnit = $electricityCostPerUnit;
return $this;
}
public function getTotalElectricitySavingsPerYear(): ?int
{
return $this->totalElectricitySavingsPerYear;
}
public function setTotalElectricitySavingsPerYear(int $totalElectricitySavingsPerYear): self
{
$this->totalElectricitySavingsPerYear = $totalElectricitySavingsPerYear;
return $this;
}
public function getTotalFinancialSavingsPerYear(): ?string
{
return $this->totalFinancialSavingsPerYear;
}
public function setTotalFinancialSavingsPerYear(string $totalFinancialSavingsPerYear): self
{
$this->totalFinancialSavingsPerYear = $totalFinancialSavingsPerYear;
return $this;
}
public function getYearsToBreakEven(): ?string
{
return $this->yearsToBreakEven;
}
public function setYearsToBreakEven(string $yearsToBreakEven): self
{
$this->yearsToBreakEven = $yearsToBreakEven;
return $this;
}
/**
* @return Collection|EquipmentSet[]
*/
public function getEquipmentSets(): array|Collection
{
return $this->equipmentSets;
}
public function addEquipmentSet(EquipmentSet $equipmentSet): self
{
if (!$this->equipmentSets->contains($equipmentSet)) {
$this->equipmentSets[] = $equipmentSet;
$equipmentSet->setProject($this);
}
return $this;
}
public function removeEquipmentSet(EquipmentSet $equipmentSet): self
{
$this->equipmentSets->removeElement($equipmentSet);
return $this;
}
public function getOrganization(): ?Organization
{
return $this->organization;
}
public function setOrganization(Organization $organization): self
{
$this->organization = $organization;
return $this;
}
public function getTotalInvestment()
{
return $this->totalInvestment;
}
public function setTotalInvestment($totalInvestment): void
{
$this->totalInvestment = $totalInvestment;
}
}