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); } }