Document multi currency and edit currency rate issue solved..
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Abstracts\View\Components;
|
||||
use App\Abstracts\View\Components\Document as Base;
|
||||
use App\Models\Common\Contact;
|
||||
use App\Models\Document\Document;
|
||||
use App\Models\Setting\Currency;
|
||||
use App\Traits\Documents;
|
||||
use Date;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -17,6 +18,12 @@ abstract class DocumentForm extends Base
|
||||
|
||||
public $document;
|
||||
|
||||
public $currencies;
|
||||
|
||||
public $currency;
|
||||
|
||||
public $currency_code;
|
||||
|
||||
/** Advanced Component Start */
|
||||
/** @var string */
|
||||
public $categoryType;
|
||||
@@ -205,7 +212,7 @@ abstract class DocumentForm extends Base
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
$type, $document = false,
|
||||
$type, $document = false, $currencies = false, $currency = false, $currency_code = false,
|
||||
/** Advanced Component Start */
|
||||
string $categoryType = '', bool $hideRecurring = false, bool $hideCategory = false, bool $hideAttachment = false,
|
||||
/** Advanced Component End */
|
||||
@@ -235,6 +242,9 @@ abstract class DocumentForm extends Base
|
||||
) {
|
||||
$this->type = $type;
|
||||
$this->document = $document;
|
||||
$this->currencies = $this->getCurrencies($currencies);
|
||||
$this->currency = $this->getCurrency($document, $currency, $currency_code);
|
||||
$this->currency_code = $this->currency->code;
|
||||
|
||||
/** Advanced Component Start */
|
||||
$this->categoryType = $this->getCategoryType($type, $categoryType);
|
||||
@@ -314,6 +324,32 @@ abstract class DocumentForm extends Base
|
||||
/** Items Component End */
|
||||
}
|
||||
|
||||
protected function getCurrencies($currencies)
|
||||
{
|
||||
if (!empty($currencies)) {
|
||||
return $currencies;
|
||||
}
|
||||
|
||||
return Currency::enabled()->pluck('name', 'code');
|
||||
}
|
||||
|
||||
protected function getCurrency($document, $currency, $currency_code)
|
||||
{
|
||||
if (!empty($currency)) {
|
||||
return $currency;
|
||||
}
|
||||
|
||||
if (!empty($currency_code)) {
|
||||
return Currency::where('code', $currency_code)->first();
|
||||
}
|
||||
|
||||
if (!empty($document)) {
|
||||
return Currency::where('code', $document->currency_code)->first();
|
||||
}
|
||||
|
||||
return Currency::where('code', setting('default.currency'))->first();
|
||||
}
|
||||
|
||||
protected function getRouteStore($type, $routeStore)
|
||||
{
|
||||
if (!empty($routeStore)) {
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentForm as Component;
|
||||
use App\Models\Setting\Currency;
|
||||
use App\Models\Setting\Tax;
|
||||
|
||||
class Items extends Component
|
||||
@@ -15,10 +14,8 @@ class Items extends Component
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$currency = Currency::where('code', setting('default.currency'))->first();
|
||||
|
||||
$taxes = Tax::enabled()->orderBy('name')->get();
|
||||
|
||||
return view('components.documents.form.items', compact('currency', 'taxes'));
|
||||
return view('components.documents.form.items', compact('taxes'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\View\Components\Documents\Form;
|
||||
|
||||
use App\Abstracts\View\Components\DocumentForm as Component;
|
||||
use App\Models\Setting\Currency;
|
||||
|
||||
class Totals extends Component
|
||||
{
|
||||
@@ -14,9 +13,6 @@ class Totals extends Component
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$currencies = Currency::enabled()->pluck('name', 'code');
|
||||
$currency = Currency::where('code', setting('default.currency'))->first();
|
||||
|
||||
return view('components.documents.form.totals', compact('currencies', 'currency'));
|
||||
return view('components.documents.form.totals');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,14 @@ class Script extends Component
|
||||
/** @var string */
|
||||
public $version;
|
||||
|
||||
public $document;
|
||||
|
||||
public $items;
|
||||
|
||||
public $currencies;
|
||||
|
||||
public $currency_code;
|
||||
|
||||
public $taxes;
|
||||
|
||||
/**
|
||||
@@ -29,13 +33,15 @@ class Script extends Component
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(string $type = '', string $scriptFile = '', string $version = '', $items = [], $currencies = [], $taxes = [])
|
||||
public function __construct(string $type = '', string $scriptFile = '', string $version = '', $document = false, $items = [], $currencies = [], $taxes = [])
|
||||
{
|
||||
$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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user