akaunting 3.0 (the last dance)
This commit is contained in:
@ -2,22 +2,22 @@
|
||||
|
||||
namespace App\View\Components\Documents;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
use App\Models\Setting\Currency;
|
||||
use App\Models\Setting\Tax;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use App\Traits\ViewComponents;
|
||||
|
||||
class Script extends Component
|
||||
{
|
||||
use ViewComponents;
|
||||
|
||||
public const OBJECT_TYPE = 'document';
|
||||
public const DEFAULT_TYPE = 'invoice';
|
||||
public const DEFAULT_PLURAL_TYPE = 'invoices';
|
||||
|
||||
/** @var string */
|
||||
public $type;
|
||||
|
||||
/** @var string */
|
||||
public $scriptFile;
|
||||
|
||||
/** @var string */
|
||||
public $version;
|
||||
|
||||
public $document;
|
||||
|
||||
public $items;
|
||||
@ -28,21 +28,34 @@ class Script extends Component
|
||||
|
||||
public $taxes;
|
||||
|
||||
/** @var string */
|
||||
public $alias;
|
||||
|
||||
/** @var string */
|
||||
public $folder;
|
||||
|
||||
/** @var string */
|
||||
public $file;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(string $type = '', string $scriptFile = '', string $version = '', $document = false, $items = [], $currencies = [], $taxes = [])
|
||||
{
|
||||
public function __construct(
|
||||
string $type = '', $document = false, $items = [], $currencies = [], $taxes = [],
|
||||
string $alias = '', string $folder = '', string $file = ''
|
||||
) {
|
||||
$this->type = $type;
|
||||
$this->scriptFile = ($scriptFile) ? $scriptFile : 'public/js/common/documents.js';
|
||||
$this->version = $this->getVersion($version);
|
||||
$this->document = $document;
|
||||
$this->items = $items;
|
||||
$this->currencies = $this->getCurrencies($currencies);
|
||||
$this->currency_code = ($document) ? $document->currency_code : setting('default.currency');
|
||||
$this->taxes = $this->getTaxes($taxes);
|
||||
|
||||
$this->alias = $this->getAlias($type, $alias);
|
||||
$this->folder = $this->getScriptFolder($type, $folder);
|
||||
$this->file = $this->getScriptFile($type, $file);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,19 +68,6 @@ class Script extends Component
|
||||
return view('components.documents.script');
|
||||
}
|
||||
|
||||
protected function getVersion($version)
|
||||
{
|
||||
if (!empty($version)) {
|
||||
return $version;
|
||||
}
|
||||
|
||||
if ($alias = config('type.' . $this->type . '.alias')) {
|
||||
return module_version($alias);
|
||||
}
|
||||
|
||||
return version('short');
|
||||
}
|
||||
|
||||
protected function getCurrencies($currencies)
|
||||
{
|
||||
if (!empty($currencies)) {
|
||||
|
Reference in New Issue
Block a user