From 9deac6b1f3e0b1c8207bbfdfe6d8588408b83ba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Duli=C3=A7i?= Date: Thu, 12 Nov 2020 18:14:13 +0300 Subject: [PATCH] more default account fixes #1659 --- app/Jobs/Banking/UpdateAccount.php | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/app/Jobs/Banking/UpdateAccount.php b/app/Jobs/Banking/UpdateAccount.php index 866360db9..e2593f056 100644 --- a/app/Jobs/Banking/UpdateAccount.php +++ b/app/Jobs/Banking/UpdateAccount.php @@ -52,7 +52,17 @@ class UpdateAccount extends Job */ public function authorize() { - if (!$relationships = $this->getRelationships()) { + $relationships = $this->getRelationships(); + + if (!$this->request->get('enabled') && ($this->account->id == setting('default.account'))) { + $relationships[] = strtolower(trans_choice('general.companies', 1)); + + $message = trans('messages.warning.disabled', ['name' => $this->account->name, 'text' => implode(', ', $relationships)]); + + throw new \Exception($message); + } + + if (!$relationships) { return; } @@ -61,14 +71,6 @@ class UpdateAccount extends Job throw new \Exception($message); } - - if (!$this->request->get('enabled')) { - $relationships[] = strtolower(trans_choice('general.companies', 1)); - - $message = trans('messages.warning.disabled', ['name' => $this->account->name, 'text' => implode(', ', $relationships)]); - - throw new \Exception($message); - } } public function getRelationships() @@ -77,12 +79,6 @@ class UpdateAccount extends Job 'transactions' => 'transactions', ]; - $relationships = $this->countRelationships($this->account, $rels); - - if ($this->account->id == setting('default.account')) { - $relationships[] = strtolower(trans_choice('general.companies', 1)); - } - - return $relationships; + return $this->countRelationships($this->account, $rels); } }