431 lines
7.5 KiB
PHP
431 lines
7.5 KiB
PHP
<?php
|
|
|
|
namespace KupShop\I18nBundle\Entity;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
/**
|
|
* @ORM\Entity
|
|
*
|
|
* @ORM\Table(name="currencies")
|
|
*
|
|
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
|
|
*/
|
|
#[\AllowDynamicProperties] // TODO: Dočasně kvůli ovečkárně, odeber mě až nebudou prasata setovat $hacked na Currency entitu
|
|
class Currency
|
|
{
|
|
/**
|
|
* @ORM\Id
|
|
*
|
|
* @ORM\Column(type="string", length=3)
|
|
*/
|
|
private $id;
|
|
|
|
/**
|
|
* @ORM\Column(type="string", length=60)
|
|
*/
|
|
private $name;
|
|
|
|
/**
|
|
* @ORM\Column(type="string", length=10)
|
|
*/
|
|
private $symbol;
|
|
|
|
/**
|
|
* @ORM\Column(name="price_round", type="smallint")
|
|
*/
|
|
private $priceRound;
|
|
|
|
/**
|
|
* @ORM\Column(name="price_round_order", type="smallint")
|
|
*/
|
|
private $priceRoundOrder;
|
|
|
|
/**
|
|
* @ORM\Column(name="price_round_direction", type="string", columnDefinition="ENUM('up', 'down', 'math')")
|
|
*/
|
|
private $priceRoundDirection;
|
|
|
|
/**
|
|
* @ORM\Column(name="price_precision", type="string", length=20)
|
|
*/
|
|
private $pricePrecision;
|
|
|
|
/**
|
|
* @ORM\Column(name="price_decimal_mark", type="string", length=1)
|
|
*/
|
|
private $priceDecimalMark;
|
|
|
|
/**
|
|
* @ORM\Column(type="decimal", precision=15, scale=8)
|
|
*/
|
|
private $rate;
|
|
|
|
/**
|
|
* @ORM\Column(type="string", columnDefinition="ENUM('Y', 'N')", options={"default":"N"})
|
|
*/
|
|
private $sync = 'N';
|
|
|
|
/**
|
|
* @ORM\Column(type="decimal", precision=15, scale=2)
|
|
*/
|
|
private $corrections;
|
|
|
|
/**
|
|
* @ORM\Column(name="sync_date_update", type="datetime")
|
|
*/
|
|
private $syncDateUpdate;
|
|
|
|
/**
|
|
* @ORM\Column(name="bata", type="float")
|
|
*/
|
|
private $bata;
|
|
|
|
/**
|
|
* @ORM\Column(name="data", type="string")
|
|
*/
|
|
private $data;
|
|
|
|
public function getBata()
|
|
{
|
|
return $this->bata;
|
|
}
|
|
|
|
public function setBata($bata): void
|
|
{
|
|
$this->bata = $bata;
|
|
}
|
|
|
|
/**
|
|
* Set name.
|
|
*
|
|
* @param string $name
|
|
*
|
|
* @return Currency
|
|
*/
|
|
public function setName($name)
|
|
{
|
|
$this->name = $name;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Get name.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getName()
|
|
{
|
|
return $this->name;
|
|
}
|
|
|
|
/**
|
|
* Set id.
|
|
*
|
|
* @param string $id
|
|
*
|
|
* @return Currency
|
|
*/
|
|
public function setId($id)
|
|
{
|
|
$this->id = $id;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Get id.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getId()
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
/**
|
|
* Set symbol.
|
|
*
|
|
* @param string $symbol
|
|
*
|
|
* @return Currency
|
|
*/
|
|
public function setSymbol($symbol)
|
|
{
|
|
$this->symbol = $symbol;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Get symbol.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getSymbol()
|
|
{
|
|
return $this->symbol;
|
|
}
|
|
|
|
/**
|
|
* Set priceRound.
|
|
*
|
|
* @param int $priceRound
|
|
*
|
|
* @return Currency
|
|
*/
|
|
public function setPriceRound($priceRound)
|
|
{
|
|
$this->priceRound = $priceRound;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Get priceRound.
|
|
*
|
|
* @return int
|
|
*/
|
|
public function getPriceRound()
|
|
{
|
|
return $this->priceRound;
|
|
}
|
|
|
|
/**
|
|
* Set priceRoundOrder.
|
|
*
|
|
* @param int $priceRoundOrder
|
|
*
|
|
* @return Currency
|
|
*/
|
|
public function setPriceRoundOrder($priceRoundOrder)
|
|
{
|
|
$this->priceRoundOrder = $priceRoundOrder;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Get priceRoundOrder.
|
|
*
|
|
* @return int
|
|
*/
|
|
public function getPriceRoundOrder()
|
|
{
|
|
return $this->priceRoundOrder;
|
|
}
|
|
|
|
/**
|
|
* Set priceRoundDirection.
|
|
*
|
|
* @param string $priceRoundDirection
|
|
*
|
|
* @return Currency
|
|
*/
|
|
public function setPriceRoundDirection($priceRoundDirection)
|
|
{
|
|
$this->priceRoundDirection = $priceRoundDirection;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Get priceRoundDirection.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getPriceRoundDirection()
|
|
{
|
|
return $this->priceRoundDirection;
|
|
}
|
|
|
|
/**
|
|
* Set pricePrecision.
|
|
*
|
|
* @param string $pricePrecision
|
|
*
|
|
* @return Currency
|
|
*/
|
|
public function setPricePrecision($pricePrecision)
|
|
{
|
|
$this->pricePrecision = $pricePrecision;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Get pricePrecision.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getPricePrecision()
|
|
{
|
|
return $this->pricePrecision;
|
|
}
|
|
|
|
/**
|
|
* Set priceDecimalMark.
|
|
*
|
|
* @param string $priceDecimalMark
|
|
*
|
|
* @return Currency
|
|
*/
|
|
public function setPriceDecimalMark($priceDecimalMark)
|
|
{
|
|
$this->priceDecimalMark = $priceDecimalMark;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Get priceDecimalMark.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getPriceDecimalMark()
|
|
{
|
|
return $this->priceDecimalMark;
|
|
}
|
|
|
|
/**
|
|
* Set rate.
|
|
*
|
|
* @param \Decimal $rate
|
|
*
|
|
* @return Currency
|
|
*/
|
|
public function setRate($rate)
|
|
{
|
|
$this->rate = toDecimal($rate);
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Get rate.
|
|
*
|
|
* @return \Decimal
|
|
*/
|
|
public function getRate()
|
|
{
|
|
return $this->rate;
|
|
}
|
|
|
|
/**
|
|
* Set sync.
|
|
*
|
|
* @param string $sync
|
|
*
|
|
* @return Currency
|
|
*/
|
|
public function setSync($sync)
|
|
{
|
|
$this->sync = $sync;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Get sync.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getSync()
|
|
{
|
|
return $this->sync;
|
|
}
|
|
|
|
/**
|
|
* Set corrections.
|
|
*
|
|
* @param \Decimal $corrections
|
|
*
|
|
* @return Currency
|
|
*/
|
|
public function setCorrections($corrections)
|
|
{
|
|
$this->corrections = $corrections;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Get corrections.
|
|
*
|
|
* @return \Decimal
|
|
*/
|
|
public function getCorrections()
|
|
{
|
|
return $this->corrections;
|
|
}
|
|
|
|
/**
|
|
* Set syncDateUpdate.
|
|
*
|
|
* @param \DateTime $syncDateUpdate
|
|
*
|
|
* @return Currency
|
|
*/
|
|
public function setSyncDateUpdate($syncDateUpdate)
|
|
{
|
|
$this->syncDateUpdate = $syncDateUpdate;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Get syncDateUpdate.
|
|
*
|
|
* @return \DateTime
|
|
*/
|
|
public function getSyncDateUpdate()
|
|
{
|
|
return $this->syncDateUpdate;
|
|
}
|
|
|
|
public function setSyncDateUpdated()
|
|
{
|
|
$this->syncDateUpdate = new \DateTime('now');
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function getData()
|
|
{
|
|
return json_decode($this->data ?? '', true);
|
|
}
|
|
|
|
/**
|
|
* @param string|null $data
|
|
*/
|
|
public function setData($data): void
|
|
{
|
|
$this->data = $data;
|
|
}
|
|
|
|
public function hasB2BSettings()
|
|
{
|
|
return $this->getData()['b2b'] ?? false;
|
|
}
|
|
|
|
public function createB2BInstance()
|
|
{
|
|
$b2bCurrency = clone $this;
|
|
|
|
$b2bValues = $this->getData()['b2b'];
|
|
|
|
if ($b2bValues) {
|
|
$b2bCurrency->setPriceRound($b2bValues['price_round']);
|
|
$b2bCurrency->setPriceRoundOrder($b2bValues['price_round_order']);
|
|
$b2bCurrency->setPriceRoundDirection($b2bValues['price_round_direction']);
|
|
$b2bCurrency->setPricePrecision($b2bValues['price_precision']);
|
|
$b2bCurrency->setPriceDecimalMark($b2bValues['price_decimal_mark']);
|
|
$b2bCurrency->setBata($b2bValues['bata']);
|
|
}
|
|
|
|
return $b2bCurrency;
|
|
}
|
|
}
|