<?php
namespace App\Entity\Gauge;
use App\Entity\Extension\HistoricalInterface;
use App\Entity\Extension\HistoricalTrait;
use App\Utils\Segment;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\Gauge\GaugeUnitPriceRepository;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=GaugeUnitPriceRepository::class)
* @ORM\Table(name="gauge_unit_price")
*/
class GaugeUnitPrice implements HistoricalInterface
{
public const MEDIUM_SIMPLE = 1; // jednotková smluvní cena média
public const MEDIUM_HIGH_TARIFF = 2; // jednotková smluvní cena média - VT
public const MEDIUM_LOW_TARIFF = 3; // jednotková smluvní cena média - NT
public const MEDIUM_WATER = 4; // jednotková smluvní cena - vodné
public const MEDIUM_SEWER = 5; // jednotková smluvní cena - stočné
/**
* @var string[]
*/
public static array $fieldNamesByMedium = [
self::MEDIUM_SIMPLE => 'unitPriceMedium',
self::MEDIUM_HIGH_TARIFF => 'unitPriceHighTariff',
self::MEDIUM_LOW_TARIFF => 'unitPriceLowTariff',
self::MEDIUM_WATER => 'unitPriceWater',
self::MEDIUM_SEWER => 'unitPriceSewer',
];
use HistoricalTrait;
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private int $id;
/**
* @var Gauge $gauge
* @ORM\ManyToOne(targetEntity="App\Entity\Gauge\Gauge", inversedBy="unitPrice")
* @ORM\JoinColumn(name="gauge_id", referencedColumnName="id", nullable=false)
*/
private Gauge $gauge;
/**
* values defined above
* @var int
* @ORM\Column(type="smallint")
*/
private int $medium;
/**
* @ORM\Column(type="float")
*/
private float $price;
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param int $id
* @return GaugeUnitPrice
*/
public function setId(int $id): GaugeUnitPrice
{
$this->id = $id;
return $this;
}
/**
* @return Gauge
*/
public function getGauge(): Gauge
{
return $this->gauge;
}
/**
* @param Gauge $gauge
* @return GaugeUnitPrice
*/
public function setGauge(Gauge $gauge): GaugeUnitPrice
{
$this->gauge = $gauge;
return $this;
}
/**
* @return int
*/
public function getMedium(): int
{
return $this->medium;
}
/**
* @param int $medium
* @return GaugeUnitPrice
*/
public function setMedium(int $medium): GaugeUnitPrice
{
$this->medium = $medium;
return $this;
}
/**
* @return float
*/
public function getPrice(): float
{
return $this->price;
}
/**
* @param float $price
* @return GaugeUnitPrice
*/
public function setPrice(float $price): GaugeUnitPrice
{
$this->price = $price;
return $this;
}
/**
* @param int $segment
* @return int
*/
public static function getMediumBySegment(int $segment): int
{
$mediumBySegment = [
Segment::SEGMENT_BASIC_CONSUMPTION => self::MEDIUM_SIMPLE,
Segment::SEGMENT_HIGH_TARIFF => self::MEDIUM_HIGH_TARIFF,
Segment::SEGMENT_LOW_TARIFF => self::MEDIUM_LOW_TARIFF,
];
if (!array_key_exists($segment, $mediumBySegment)) {
return self::MEDIUM_SIMPLE; // default
}
return $mediumBySegment[$segment];
}
}