diff --git a/app/View/Components/Documents/Script.php b/app/View/Components/Documents/Script.php
index 2922ceead..705927b7c 100644
--- a/app/View/Components/Documents/Script.php
+++ b/app/View/Components/Documents/Script.php
@@ -15,6 +15,9 @@ class Script extends Component
/** @var string */
public $scriptFile;
+ /** @var string */
+ public $version;
+
public $items;
public $currencies;
@@ -26,10 +29,11 @@ class Script extends Component
*
* @return void
*/
- public function __construct(string $type = '', string $scriptFile = '', $items = [], $currencies = [], $taxes = [])
+ public function __construct(string $type = '', string $scriptFile = '', string $version = '', $items = [], $currencies = [], $taxes = [])
{
$this->type = $type;
$this->scriptFile = ($scriptFile) ? $scriptFile : 'public/js/common/documents.js';
+ $this->version = $this->getVersion($version);
$this->items = $items;
$this->currencies = $this->getCurrencies($currencies);
$this->taxes = $this->getTaxes($taxes);
@@ -45,6 +49,19 @@ 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)) {
diff --git a/resources/views/components/documents/script.blade.php b/resources/views/components/documents/script.blade.php
index b7500dfad..3904335bc 100644
--- a/resources/views/components/documents/script.blade.php
+++ b/resources/views/components/documents/script.blade.php
@@ -15,4 +15,4 @@
var document_taxes = {!! $taxes !!};
-
+