Various code cleanup.

This commit is contained in:
James Cole
2021-04-07 07:28:43 +02:00
parent 4ddcb0c965
commit f12744ad8c
180 changed files with 714 additions and 721 deletions

View File

@@ -86,12 +86,12 @@ class AccountController extends Controller
$defaultSet = $this->repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray();
$frontPage = app('preferences')->get('frontPageAccounts', $defaultSet);
$default = app('amount')->getDefaultCurrency();
// @codeCoverageIgnoreStart
if (0 === count($frontPage->data)) {
$frontPage->data = $defaultSet;
$frontPage->save();
}
// @codeCoverageIgnoreEnd
// get accounts:
$accounts = $this->repository->getAccountsById($frontPage->data);
@@ -100,7 +100,7 @@ class AccountController extends Controller
foreach ($accounts as $account) {
$currency = $this->repository->getAccountCurrency($account);
if (null === $currency) {
$currency = $default; // @codeCoverageIgnore
$currency = $default;
}
$currentSet = [
'label' => $account->name,

View File

@@ -96,7 +96,7 @@ class UpdateController extends Controller
$selectedGroup = $collector->getGroups()->first();
if (null === $selectedGroup) {
throw new NotFoundHttpException(); // @codeCoverageIgnore
throw new NotFoundHttpException();
}
/** @var TransactionGroupTransformer $transformer */
$transformer = app(TransactionGroupTransformer::class);

View File

@@ -75,13 +75,13 @@ class DestroyController extends Controller
if (!$this->userRepository->hasRole($admin, 'owner')) {
// access denied:
throw new FireflyException('200005: You need the "owner" role to do this.'); // @codeCoverageIgnore
throw new FireflyException('200005: You need the "owner" role to do this.');
}
if ($this->repository->currencyInUse($currency)) {
throw new FireflyException('200006: Currency in use.'); // @codeCoverageIgnore
throw new FireflyException('200006: Currency in use.');
}
if ($this->repository->isFallbackCurrency($currency)) {
throw new FireflyException('200026: Currency is fallback.'); // @codeCoverageIgnore
throw new FireflyException('200026: Currency is fallback.');
}
$this->repository->destroy($currency);

View File

@@ -80,7 +80,7 @@ class StoreController extends Controller
$admin = auth()->user();
if (!$this->userRepository->hasRole($admin, 'owner')) {
throw new FireflyException('200005: You need the "owner" role to do this.'); // @codeCoverageIgnore
throw new FireflyException('200005: You need the "owner" role to do this.');
}
$data = $request->getAll();
// if currency ID is 0, find the currency by the code:

View File

@@ -86,7 +86,7 @@ class UpdateController extends Controller
$admin = auth()->user();
if (!$this->userRepository->hasRole($admin, 'owner')) {
throw new FireflyException('200005: You need the "owner" role to do this.'); // @codeCoverageIgnore
throw new FireflyException('200005: You need the "owner" role to do this.');
}
$data = $request->getAll();

View File

@@ -161,7 +161,7 @@ class ConfigurationController extends Controller
public function update(UpdateRequest $request, string $name): JsonResponse
{
if (!$this->repository->hasRole(auth()->user(), 'owner')) {
throw new FireflyException('200005: You need the "owner" role to do this.'); // @codeCoverageIgnore
throw new FireflyException('200005: You need the "owner" role to do this.');
}
$data = $request->getAll();
$shortName = str_replace('configuration.', '', $name);

View File

@@ -83,7 +83,7 @@ class UserController extends Controller
return response()->json([], 204);
}
throw new FireflyException('200025: No access to function.'); // @codeCoverageIgnore
throw new FireflyException('200025: No access to function.');
}
/**