oms-Billing/Models/BillType.php

112 lines
2.1 KiB
PHP
Executable File

<?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package Modules\Billing\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://karaka.app
*/
declare(strict_types=1);
namespace Modules\Billing\Models;
use Modules\Media\Models\Collection;
use Modules\Media\Models\NullCollection;
use phpOMS\Localization\ISO639x1Enum;
/**
* Bill type enum.
*
* @package Modules\Billing\Models
* @license OMS License 1.0
* @link https://karaka.app
* @since 1.0.0
*/
class BillType
{
/**
* Id
*
* @var int
* @since 1.0.0
*/
protected int $id = 0;
public Collection $template;
public string $numberFormat = '';
public int $transferType = BillTransferType::SALES;
public bool $transferStock = true;
/**
* Localization
*
* @var string|BillTypeL11n
*/
protected string | BillTypeL11n $l11n;
/**
* Constructor.
*
* @param string $name Name
*
* @since 1.0.0
*/
public function __construct(string $name = '')
{
$this->template = new NullCollection();
$this->setL11n($name);
}
/**
* Get id
*
* @return int
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* Set l11n
*
* @param string|BillTypeL11n $l11n Tag article l11n
* @param string $lang Language
*
* @return void
*
* @since 1.0.0
*/
public function setL11n($l11n, string $lang = ISO639x1Enum::_EN) : void
{
if ($l11n instanceof BillTypeL11n) {
$this->l11n = $l11n;
} elseif (isset($this->l11n) && $this->l11n instanceof BillTypeL11n) {
$this->l11n->name = $l11n;
} else {
$this->l11n = new BillTypeL11n();
$this->l11n->name = $l11n;
$this->l11n->setLanguage($lang);
}
}
/**
* @return string
*
* @since 1.0.0
*/
public function getL11n() : string
{
return $this->l11n instanceof BillTypeL11n ? $this->l11n->name : $this->l11n;
}
}