From c54c078e879708751acab10ef86b2e9b1fa19d10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Tue, 5 Oct 2021 11:16:12 +0300 Subject: [PATCH] Document form currency invalid issue solved. #rvqttv --- app/Abstracts/View/Components/DocumentForm.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/Abstracts/View/Components/DocumentForm.php b/app/Abstracts/View/Components/DocumentForm.php index fb8337d6e..2930ff1ea 100644 --- a/app/Abstracts/View/Components/DocumentForm.php +++ b/app/Abstracts/View/Components/DocumentForm.php @@ -250,7 +250,7 @@ abstract class DocumentForm extends Base $this->document = $document; $this->currencies = $this->getCurrencies($currencies); $this->currency = $this->getCurrency($document, $currency, $currency_code); - $this->currency_code = $this->currency->code; + $this->currency_code = !empty($this->currency) ? $this->currency->code : setting('default.currency'); /** Advanced Component Start */ $this->categoryType = $this->getCategoryType($type, $categoryType); @@ -348,14 +348,18 @@ abstract class DocumentForm extends Base } if (!empty($currency_code)) { - return Currency::where('code', $currency_code)->first(); + $currency = Currency::where('code', $currency_code)->first(); } - if (!empty($document)) { - return Currency::where('code', $document->currency_code)->first(); + if (empty($currency) && !empty($document)) { + $currency = Currency::where('code', $document->currency_code)->first(); } - return Currency::where('code', setting('default.currency'))->first(); + if (empty($currency)) { + $currency = Currency::where('code', setting('default.currency'))->first(); + } + + return $currency; } protected function getRouteStore($type, $routeStore)