oms-ItemManagement/Models/ItemPrice.php
2022-12-26 13:35:10 +01:00

145 lines
3.0 KiB
PHP
Executable File

<?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package Modules\ItemManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\ItemManagement\Models;
use phpOMS\Localization\Money;
use phpOMS\Stdlib\Base\Exception\InvalidEnumValue;
/**
* Account class.
*
* @package Modules\ItemManagement\Models
* @license OMS License 1.0
* @link https://jingga.app
* @since 1.0.0
*/
class ItemPrice implements \JsonSerializable
{
/**
* ID.
*
* @var int
* @since 1.0.0
*/
protected int $id = 0;
public string $name = '';
public string $currency = '';
public Money $price;
public int $status = ItemPriceStatus::ACTIVE;
public int $minQuantity = 0;
public int $relativeDiscount = 0;
public int $absoluteDiscount = 0;
public int $relativeUnitDiscount = 0;
public int $absoluteUnitDiscount = 0;
public string $promocode = '';
public ?\DateTime $start = null;
public ?\DateTime $end = null;
/**
* Constructor.
*
* @since 1.0.0
*/
public function __construct()
{
}
/**
* Get id
*
* @return int
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* Get status
*
* @return int
*
* @since 1.0.0
*/
public function getStatus() : int
{
return $this->status;
}
/**
* Set status
*
* @param int $status Price status
*
* @return void
*
* @throws InvalidEnumValue
*
* @since 1.0.0
*/
public function setStatus(int $status) : void
{
if (!ItemPriceStatus::isValidValue($status)) {
throw new InvalidEnumValue((string) $status);
}
$this->status = $status;
}
/**
* {@inheritdoc}
*/
public function toArray() : array
{
return [
'id' => $this->id,
'name' => $this->name,
'currency' => $this->currency,
'price' => $this->price,
'status' => $this->status,
'minQuantity' => $this->minQuantity,
'relativeDiscount' => $this->relativeDiscount,
'absoluteDiscount' => $this->absoluteDiscount,
'relativeUnitDiscount' => $this->relativeUnitDiscount,
'absoluteUnitDiscount' => $this->absoluteUnitDiscount,
'promocode' => $this->promocode,
'start' => $this->start,
'end' => $this->end,
];
}
/**
* {@inheritdoc}
*/
public function jsonSerialize() : mixed
{
return $this->toArray();
}
}