Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Code reordering and reformatting. I should really start employing style CI.
James Cole4003cea75997
diff --git a/app/Api/V1/Controllers/Autocomplete/CurrencyController.php b/app/Api/V1/Controllers/Autocomplete/CurrencyController.phpindex a9d6d11cc4..4d1f508d67 100644--- a/app/Api/V1/Controllers/Autocomplete/CurrencyController.php+++ b/app/Api/V1/Controllers/Autocomplete/CurrencyController.php@@ -88,8 +88,9 @@ class CurrencyController extends Controller* https://api-docs.firefly-iii.org/#/autocomplete/getCurrenciesCodeAC** @param AutocompleteRequest $request- * @deprecated+ ** @return JsonResponse+ * @deprecated*/public function currenciesWithCode(AutocompleteRequest $request): JsonResponse{diff --git a/app/Api/V1/Controllers/Autocomplete/ObjectGroupController.php b/app/Api/V1/Controllers/Autocomplete/ObjectGroupController.phpindex 61d9ba3dc0..e4328a62ef 100644--- a/app/Api/V1/Controllers/Autocomplete/ObjectGroupController.php+++ b/app/Api/V1/Controllers/Autocomplete/ObjectGroupController.php@@ -58,6 +58,7 @@ class ObjectGroupController extends Controller/*** Documentation for this endpoint is at:* https://api-docs.firefly-iii.org/#/autocomplete/getObjectGroupsAC+ ** @param AutocompleteRequest $request** @return JsonResponsediff --git a/app/Api/V1/Controllers/Chart/AccountController.php b/app/Api/V1/Controllers/Chart/AccountController.phpindex 7fd8b1864e..27a2a07101 100644--- a/app/Api/V1/Controllers/Chart/AccountController.php+++ b/app/Api/V1/Controllers/Chart/AccountController.php@@ -105,9 +105,9 @@ class AccountController extends Controllerforeach ($accounts as $account) {$currency = $this->repository->getAccountCurrency($account);if (null === $currency) {- $currency = $default;+ $currency = $default;}- $currentSet = [+ $currentSet = ['label' => $account->name,'currency_id' => (string)$currency->id,'currency_code' => $currency->code,diff --git a/app/Api/V1/Controllers/Controller.php b/app/Api/V1/Controllers/Controller.phpindex 5fb3a330dc..9fdc689b61 100644--- a/app/Api/V1/Controllers/Controller.php+++ b/app/Api/V1/Controllers/Controller.php@@ -46,8 +46,8 @@ abstract class Controller extends BaseControlleruse AuthorizesRequests, DispatchesJobs, ValidatesRequests;protected const CONTENT_TYPE = 'application/vnd.api+json';- protected ParameterBag $parameters;protected array $allowedSort;+ protected ParameterBag $parameters;/*** Controller constructor.@@ -92,7 +92,7 @@ abstract class Controller extends BaseControllerif (null !== $date) {try {$obj = Carbon::parse($date);- } catch (InvalidDateException|InvalidFormatException $e) {+ } catch (InvalidDateException | InvalidFormatException $e) {// don't careLog::error(sprintf('Invalid date exception in API controller: %s', $e->getMessage()));}diff --git a/app/Api/V1/Controllers/Data/Bulk/AccountController.php b/app/Api/V1/Controllers/Data/Bulk/AccountController.phpindex 3508c9393e..a1fa0fa6a5 100644--- a/app/Api/V1/Controllers/Data/Bulk/AccountController.php+++ b/app/Api/V1/Controllers/Data/Bulk/AccountController.php@@ -58,10 +58,11 @@ class AccountController extends Controller/*** This endpoint is deprecated and not documented.- * @deprecated+ ** @param MoveTransactionsRequest $request** @return JsonResponse+ * @deprecated*/public function moveTransactions(MoveTransactionsRequest $request): JsonResponse{diff --git a/app/Api/V1/Controllers/Data/Export/ExportController.php b/app/Api/V1/Controllers/Data/Export/ExportController.phpindex 781f118768..58e1ab5090 100644--- a/app/Api/V1/Controllers/Data/Export/ExportController.php+++ b/app/Api/V1/Controllers/Data/Export/ExportController.php@@ -78,9 +78,9 @@ class ExportController extends Controller*/private function returnExport(string $key): LaravelResponse{- $date = date('Y-m-d-H-i-s');+ $date = date('Y-m-d-H-i-s');$fileName = sprintf('%s-export-%s.csv', $date, $key);- $data = $this->exporter->export();+ $data = $this->exporter->export();/** @var LaravelResponse $response */$response = response($data[$key]);diff --git a/app/Api/V1/Controllers/Insight/Transfer/AccountController.php b/app/Api/V1/Controllers/Insight/Transfer/AccountController.phpindex 141daf143e..19dc00a0fc 100644--- a/app/Api/V1/Controllers/Insight/Transfer/AccountController.php+++ b/app/Api/V1/Controllers/Insight/Transfer/AccountController.php@@ -71,6 +71,7 @@ class AccountController extends Controller$end = $request->getEnd();$assetAccounts = $request->getAssetAccounts();$transfers = $this->opsRepository->sumTransfers($start, $end, $assetAccounts);+return response()->json($transfers);}}diff --git a/app/Api/V1/Controllers/Models/Account/ShowController.php b/app/Api/V1/Controllers/Models/Account/ShowController.phpindex 71d3c53803..a5650ebf23 100644--- a/app/Api/V1/Controllers/Models/Account/ShowController.php+++ b/app/Api/V1/Controllers/Models/Account/ShowController.php@@ -84,7 +84,7 @@ class ShowController extends Controller$this->parameters->set('type', $type);// types to get, page size:- $types = $this->mapAccountTypes($this->parameters->get('type'));+ $types = $this->mapAccountTypes($this->parameters->get('type'));$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;// get list of accounts. Count it and split it.@@ -95,7 +95,7 @@ class ShowController extends Controller// continue sort:- $accounts = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);+ $accounts = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// make paginator:$paginator = new LengthAwarePaginator($accounts, $count, $pageSize, $this->parameters->get('page'));diff --git a/app/Api/V1/Controllers/Models/Account/UpdateController.php b/app/Api/V1/Controllers/Models/Account/UpdateController.phpindex 65221bbeda..49a6f2c794 100644--- a/app/Api/V1/Controllers/Models/Account/UpdateController.php+++ b/app/Api/V1/Controllers/Models/Account/UpdateController.php@@ -74,10 +74,10 @@ class UpdateController extends Controllerpublic function update(UpdateRequest $request, Account $account): JsonResponse{Log::debug(sprintf('Now in %s', __METHOD__));- $data = $request->getUpdateData();+ $data = $request->getUpdateData();$data['type'] = config('firefly.shortNamesByFullName.' . $account->accountType->type);- $account = $this->repository->update($account, $data);- $manager = $this->getManager();+ $account = $this->repository->update($account, $data);+ $manager = $this->getManager();$account->refresh();Preferences::mark();diff --git a/app/Api/V1/Controllers/Models/Attachment/DestroyController.php b/app/Api/V1/Controllers/Models/Attachment/DestroyController.phpindex 3fad5d77bd..bbf72975d9 100644--- a/app/Api/V1/Controllers/Models/Attachment/DestroyController.php+++ b/app/Api/V1/Controllers/Models/Attachment/DestroyController.php@@ -49,7 +49,7 @@ class DestroyController extends Controller$this->middleware(function ($request, $next) {/** @var User $user */- $user = auth()->user();+ $user = auth()->user();$this->repository = app(AttachmentRepositoryInterface::class);$this->repository->setUser($user);diff --git a/app/Api/V1/Controllers/Models/Attachment/UpdateController.php b/app/Api/V1/Controllers/Models/Attachment/UpdateController.phpindex f5d350b1e4..fda955b2bf 100644--- a/app/Api/V1/Controllers/Models/Attachment/UpdateController.php+++ b/app/Api/V1/Controllers/Models/Attachment/UpdateController.php@@ -52,7 +52,7 @@ class UpdateController extends Controller$this->middleware(function ($request, $next) {/** @var User $user */- $user = auth()->user();+ $user = auth()->user();$this->repository = app(AttachmentRepositoryInterface::class);$this->repository->setUser($user);diff --git a/app/Api/V1/Controllers/Models/AvailableBudget/DestroyController.php b/app/Api/V1/Controllers/Models/AvailableBudget/DestroyController.phpindex 0297e839c7..8eda2dda48 100644--- a/app/Api/V1/Controllers/Models/AvailableBudget/DestroyController.php+++ b/app/Api/V1/Controllers/Models/AvailableBudget/DestroyController.php@@ -47,7 +47,7 @@ class DestroyController extends Controller$this->middleware(function ($request, $next) {/** @var User $user */- $user = auth()->user();+ $user = auth()->user();$this->abRepository = app(AvailableBudgetRepositoryInterface::class);$this->abRepository->setUser($user);diff --git a/app/Api/V1/Controllers/Models/Bill/StoreController.php b/app/Api/V1/Controllers/Models/Bill/StoreController.phpindex 4383e8279c..d3bfd2cc04 100644--- a/app/Api/V1/Controllers/Models/Bill/StoreController.php+++ b/app/Api/V1/Controllers/Models/Bill/StoreController.php@@ -69,8 +69,8 @@ class StoreController extends Controller*/public function store(StoreRequest $request): JsonResponse{- $data = $request->getAll();- $bill = $this->repository->store($data);+ $data = $request->getAll();+ $bill = $this->repository->store($data);$manager = $this->getManager();/** @var BillTransformer $transformer */diff --git a/app/Api/V1/Controllers/Models/Bill/UpdateController.php b/app/Api/V1/Controllers/Models/Bill/UpdateController.phpindex f61e6e3b28..23e1e92cdf 100644--- a/app/Api/V1/Controllers/Models/Bill/UpdateController.php+++ b/app/Api/V1/Controllers/Models/Bill/UpdateController.php@@ -66,8 +66,8 @@ class UpdateController extends Controller*/public function update(UpdateRequest $request, Bill $bill): JsonResponse{- $data = $request->getAll();- $bill = $this->repository->update($bill, $data);+ $data = $request->getAll();+ $bill = $this->repository->update($bill, $data);$manager = $this->getManager();/** @var BillTransformer $transformer */diff --git a/app/Api/V1/Controllers/Models/Budget/ShowController.php b/app/Api/V1/Controllers/Models/Budget/ShowController.phpindex e6a9020fb6..bfe12fcc3d 100644--- a/app/Api/V1/Controllers/Models/Budget/ShowController.php+++ b/app/Api/V1/Controllers/Models/Budget/ShowController.php@@ -53,7 +53,7 @@ class ShowController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {- $this->repository = app(BudgetRepositoryInterface::class);+ $this->repository = app(BudgetRepositoryInterface::class);$this->blRepository = app(BudgetLimitRepositoryInterface::class);$this->repository->setUser(auth()->user());$this->blRepository->setUser(auth()->user());diff --git a/app/Api/V1/Controllers/Models/Category/UpdateController.php b/app/Api/V1/Controllers/Models/Category/UpdateController.phpindex ddfdf9f653..1c1975a8d4 100644--- a/app/Api/V1/Controllers/Models/Category/UpdateController.php+++ b/app/Api/V1/Controllers/Models/Category/UpdateController.php@@ -66,9 +66,9 @@ class UpdateController extends Controller*/public function update(UpdateRequest $request, Category $category): JsonResponse{- $data = $request->getAll();+ $data = $request->getAll();$category = $this->repository->update($category, $data);- $manager = $this->getManager();+ $manager = $this->getManager();/** @var CategoryTransformer $transformer */$transformer = app(CategoryTransformer::class);diff --git a/app/Api/V1/Controllers/Models/ObjectGroup/DestroyController.php b/app/Api/V1/Controllers/Models/ObjectGroup/DestroyController.phpindex fa580b6ffc..0fc6447f84 100644--- a/app/Api/V1/Controllers/Models/ObjectGroup/DestroyController.php+++ b/app/Api/V1/Controllers/Models/ObjectGroup/DestroyController.php@@ -47,7 +47,7 @@ class DestroyController extends Controller$this->middleware(function ($request, $next) {/** @var User $user */- $user = auth()->user();+ $user = auth()->user();$this->repository = app(ObjectGroupRepositoryInterface::class);$this->repository->setUser($user);diff --git a/app/Api/V1/Controllers/Models/ObjectGroup/ListController.php b/app/Api/V1/Controllers/Models/ObjectGroup/ListController.phpindex b3c3f8e603..7b3db64c16 100644--- a/app/Api/V1/Controllers/Models/ObjectGroup/ListController.php+++ b/app/Api/V1/Controllers/Models/ObjectGroup/ListController.php@@ -53,7 +53,7 @@ class ListController extends Controller$this->middleware(function ($request, $next) {/** @var User $user */- $user = auth()->user();+ $user = auth()->user();$this->repository = app(ObjectGroupRepositoryInterface::class);$this->repository->setUser($user);diff --git a/app/Api/V1/Controllers/Models/ObjectGroup/UpdateController.php b/app/Api/V1/Controllers/Models/ObjectGroup/UpdateController.phpindex 85b5e89e96..4f60d9b37e 100644--- a/app/Api/V1/Controllers/Models/ObjectGroup/UpdateController.php+++ b/app/Api/V1/Controllers/Models/ObjectGroup/UpdateController.php@@ -50,7 +50,7 @@ class UpdateController extends Controller$this->middleware(function ($request, $next) {/** @var User $user */- $user = auth()->user();+ $user = auth()->user();$this->repository = app(ObjectGroupRepositoryInterface::class);$this->repository->setUser($user);diff --git a/app/Api/V1/Controllers/Models/PiggyBank/UpdateController.php b/app/Api/V1/Controllers/Models/PiggyBank/UpdateController.phpindex b7afab8caa..a48678d439 100644--- a/app/Api/V1/Controllers/Models/PiggyBank/UpdateController.php+++ b/app/Api/V1/Controllers/Models/PiggyBank/UpdateController.php@@ -66,7 +66,7 @@ class UpdateController extends Controller*/public function update(UpdateRequest $request, PiggyBank $piggyBank): JsonResponse{- $data = $request->getAll();+ $data = $request->getAll();$piggyBank = $this->repository->update($piggyBank, $data);if (array_key_exists('current_amount', $data) && '' !== $data['current_amount']) {diff --git a/app/Api/V1/Controllers/Models/Recurrence/StoreController.php b/app/Api/V1/Controllers/Models/Recurrence/StoreController.phpindex 7573abedd2..fdf2ce0761 100644--- a/app/Api/V1/Controllers/Models/Recurrence/StoreController.php+++ b/app/Api/V1/Controllers/Models/Recurrence/StoreController.php@@ -66,9 +66,9 @@ class StoreController extends Controller*/public function store(StoreRequest $request): JsonResponse{- $data = $request->getAll();+ $data = $request->getAll();$recurrence = $this->repository->store($data);- $manager = $this->getManager();+ $manager = $this->getManager();/** @var RecurrenceTransformer $transformer */$transformer = app(RecurrenceTransformer::class);diff --git a/app/Api/V1/Controllers/Models/Recurrence/UpdateController.php b/app/Api/V1/Controllers/Models/Recurrence/UpdateController.phpindex b67a34b634..2df4087347 100644--- a/app/Api/V1/Controllers/Models/Recurrence/UpdateController.php+++ b/app/Api/V1/Controllers/Models/Recurrence/UpdateController.php@@ -66,9 +66,9 @@ class UpdateController extends Controller*/public function update(UpdateRequest $request, Recurrence $recurrence): JsonResponse{- $data = $request->getAll();+ $data = $request->getAll();$recurrence = $this->repository->update($recurrence, $data);- $manager = $this->getManager();+ $manager = $this->getManager();/** @var RecurrenceTransformer $transformer */$transformer = app(RecurrenceTransformer::class);diff --git a/app/Api/V1/Controllers/Models/Rule/StoreController.php b/app/Api/V1/Controllers/Models/Rule/StoreController.phpindex 5f46fd8d90..a51870c668 100644--- a/app/Api/V1/Controllers/Models/Rule/StoreController.php+++ b/app/Api/V1/Controllers/Models/Rule/StoreController.php@@ -68,7 +68,7 @@ class StoreController extends Controller*/public function store(StoreRequest $request): JsonResponse{- $rule = $this->ruleRepository->store($request->getAll());+ $rule = $this->ruleRepository->store($request->getAll());$manager = $this->getManager();/** @var RuleTransformer $transformer */$transformer = app(RuleTransformer::class);diff --git a/app/Api/V1/Controllers/Models/Rule/UpdateController.php b/app/Api/V1/Controllers/Models/Rule/UpdateController.phpindex 174226934d..28a25fe7d4 100644--- a/app/Api/V1/Controllers/Models/Rule/UpdateController.php+++ b/app/Api/V1/Controllers/Models/Rule/UpdateController.php@@ -70,8 +70,8 @@ class UpdateController extends Controller*/public function update(UpdateRequest $request, Rule $rule): JsonResponse{- $data = $request->getAll();- $rule = $this->ruleRepository->update($rule, $data);+ $data = $request->getAll();+ $rule = $this->ruleRepository->update($rule, $data);$manager = $this->getManager();/** @var RuleTransformer $transformer */diff --git a/app/Api/V1/Controllers/Models/RuleGroup/StoreController.php b/app/Api/V1/Controllers/Models/RuleGroup/StoreController.phpindex 56ce1cdaf8..cb1319368e 100644--- a/app/Api/V1/Controllers/Models/RuleGroup/StoreController.php+++ b/app/Api/V1/Controllers/Models/RuleGroup/StoreController.php@@ -38,7 +38,7 @@ use League\Fractal\Resource\Item;class StoreController extends Controller{- private AccountRepositoryInterface $accountRepository;+ private AccountRepositoryInterface $accountRepository;private RuleGroupRepositoryInterface $ruleGroupRepository;/**diff --git a/app/Api/V1/Controllers/Models/RuleGroup/TriggerController.php b/app/Api/V1/Controllers/Models/RuleGroup/TriggerController.phpindex 8b332a0e79..31fccaca88 100644--- a/app/Api/V1/Controllers/Models/RuleGroup/TriggerController.php+++ b/app/Api/V1/Controllers/Models/RuleGroup/TriggerController.php@@ -23,6 +23,7 @@ declare(strict_types=1);namespace FireflyIII\Api\V1\Controllers\Models\RuleGroup;+use Exception;use FireflyIII\Api\V1\Controllers\Controller;use FireflyIII\Api\V1\Requests\Models\RuleGroup\TestRequest;use FireflyIII\Api\V1\Requests\Models\RuleGroup\TriggerRequest;@@ -36,7 +37,6 @@ use Illuminate\Http\JsonResponse;use Illuminate\Pagination\LengthAwarePaginator;use League\Fractal\Pagination\IlluminatePaginatorAdapter;use League\Fractal\Resource\Collection as FractalCollection;-use Exception;/*** Class TriggerControllerdiff --git a/app/Api/V1/Controllers/Models/Tag/StoreController.php b/app/Api/V1/Controllers/Models/Tag/StoreController.phpindex bceb8e045d..fd8346887f 100644--- a/app/Api/V1/Controllers/Models/Tag/StoreController.php+++ b/app/Api/V1/Controllers/Models/Tag/StoreController.php@@ -68,7 +68,7 @@ class StoreController extends Controller*/public function store(StoreRequest $request): JsonResponse{- $rule = $this->repository->store($request->getAll());+ $rule = $this->repository->store($request->getAll());$manager = $this->getManager();/** @var TagTransformer $transformer */$transformer = app(TagTransformer::class);diff --git a/app/Api/V1/Controllers/Models/Tag/UpdateController.php b/app/Api/V1/Controllers/Models/Tag/UpdateController.phpindex 68540de27f..5bc869d5b3 100644--- a/app/Api/V1/Controllers/Models/Tag/UpdateController.php+++ b/app/Api/V1/Controllers/Models/Tag/UpdateController.php@@ -70,7 +70,7 @@ class UpdateController extends Controller*/public function update(UpdateRequest $request, Tag $tag): JsonResponse{- $rule = $this->repository->update($tag, $request->getAll());+ $rule = $this->repository->update($tag, $request->getAll());$manager = $this->getManager();/** @var TagTransformer $transformer */$transformer = app(TagTransformer::class);diff --git a/app/Api/V1/Controllers/Models/Transaction/StoreController.php b/app/Api/V1/Controllers/Models/Transaction/StoreController.phpindex 03a866b8d5..486c2eb7e6 100644--- a/app/Api/V1/Controllers/Models/Transaction/StoreController.php+++ b/app/Api/V1/Controllers/Models/Transaction/StoreController.php@@ -94,16 +94,16 @@ class StoreController extends Controller$validator = Validator::make(['transactions' => [['description' => $e->getMessage()]]], ['transactions.0.description' => new IsDuplicateTransaction]);- throw new ValidationException($validator,0, $e);+ throw new ValidationException($validator, 0, $e);} catch (FireflyException $e) {Log::warning('Caught an exception. Return error message.');Log::error($e->getMessage());$message = sprintf('Internal exception: %s', $e->getMessage());$validator = Validator::make(['transactions' => [['description' => $message]]], ['transactions.0.description' => new IsDuplicateTransaction]);- throw new ValidationException($validator,0, $e);+ throw new ValidationException($validator, 0, $e);}app('preferences')->mark();- $applyRules = $data['apply_rules'] ?? true;+ $applyRules = $data['apply_rules'] ?? true;$fireWebhooks = $data['fire_webhooks'] ?? true;event(new StoredTransactionGroup($transactionGroup, $applyRules, $fireWebhooks));diff --git a/app/Api/V1/Controllers/Models/Transaction/UpdateController.php b/app/Api/V1/Controllers/Models/Transaction/UpdateController.phpindex 2741dfaccc..7363895779 100644--- a/app/Api/V1/Controllers/Models/Transaction/UpdateController.php+++ b/app/Api/V1/Controllers/Models/Transaction/UpdateController.php@@ -80,7 +80,7 @@ class UpdateController extends Controller$manager = $this->getManager();app('preferences')->mark();- $applyRules = $data['apply_rules'] ?? true;+ $applyRules = $data['apply_rules'] ?? true;$fireWebhooks = $data['fire_webhooks'] ?? true;event(new UpdatedTransactionGroup($transactionGroup, $applyRules, $fireWebhooks));@@ -98,7 +98,7 @@ class UpdateController extends Controller$selectedGroup = $collector->getGroups()->first();if (null === $selectedGroup) {- throw new NotFoundHttpException();+ throw new NotFoundHttpException();}/** @var TransactionGroupTransformer $transformer */$transformer = app(TransactionGroupTransformer::class);diff --git a/app/Api/V1/Controllers/Models/TransactionCurrency/DestroyController.php b/app/Api/V1/Controllers/Models/TransactionCurrency/DestroyController.phpindex f933b068b5..e22ee27ecc 100644--- a/app/Api/V1/Controllers/Models/TransactionCurrency/DestroyController.php+++ b/app/Api/V1/Controllers/Models/TransactionCurrency/DestroyController.php@@ -50,7 +50,7 @@ class DestroyController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {- $this->repository = app(CurrencyRepositoryInterface::class);+ $this->repository = app(CurrencyRepositoryInterface::class);$this->userRepository = app(UserRepositoryInterface::class);$this->repository->setUser(auth()->user());@@ -75,13 +75,13 @@ class DestroyController extends Controllerif (!$this->userRepository->hasRole($admin, 'owner')) {// access denied:- throw new FireflyException('200005: You need the "owner" role to do this.');+ throw new FireflyException('200005: You need the "owner" role to do this.');}if ($this->repository->currencyInUse($currency)) {- throw new FireflyException('200006: Currency in use.');+ throw new FireflyException('200006: Currency in use.');}if ($this->repository->isFallbackCurrency($currency)) {- throw new FireflyException('200026: Currency is fallback.');+ throw new FireflyException('200026: Currency is fallback.');}$this->repository->destroy($currency);diff --git a/app/Api/V1/Controllers/Models/TransactionCurrency/UpdateController.php b/app/Api/V1/Controllers/Models/TransactionCurrency/UpdateController.phpindex 0a7f12f85e..5f50d1886b 100644--- a/app/Api/V1/Controllers/Models/TransactionCurrency/UpdateController.php+++ b/app/Api/V1/Controllers/Models/TransactionCurrency/UpdateController.php@@ -26,6 +26,7 @@ namespace FireflyIII\Api\V1\Controllers\Models\TransactionCurrency;use FireflyIII\Api\V1\Controllers\Controller;use FireflyIII\Api\V1\Requests\Models\TransactionCurrency\UpdateRequest;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\TransactionCurrency;use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;use FireflyIII\Repositories\User\UserRepositoryInterface;@@ -33,6 +34,7 @@ use FireflyIII\Support\Http\Api\AccountFilter;use FireflyIII\Support\Http\Api\TransactionFilter;use FireflyIII\Transformers\CurrencyTransformer;use Illuminate\Http\JsonResponse;+use JsonException;use League\Fractal\Resource\Item;/**@@ -126,7 +128,7 @@ class UpdateController extends Controller* @param TransactionCurrency $currency** @return JsonResponse- * @throws \FireflyIII\Exceptions\FireflyException+ * @throws FireflyException* @codeCoverageIgnore*/public function makeDefault(TransactionCurrency $currency): JsonResponse@@ -157,8 +159,8 @@ class UpdateController extends Controller* @param TransactionCurrency $currency** @return JsonResponse- * @throws \FireflyIII\Exceptions\FireflyException- * @throws \JsonException+ * @throws FireflyException+ * @throws JsonException*/public function update(UpdateRequest $request, TransactionCurrency $currency): JsonResponse{diff --git a/app/Api/V1/Controllers/Models/TransactionLink/ShowController.php b/app/Api/V1/Controllers/Models/TransactionLink/ShowController.phpindex 7eb31482f6..c24ac20190 100644--- a/app/Api/V1/Controllers/Models/TransactionLink/ShowController.php+++ b/app/Api/V1/Controllers/Models/TransactionLink/ShowController.php@@ -84,8 +84,8 @@ class ShowController extends Controller$linkType = $this->repository->findByName($name);// get list of transaction links. Count it and split it.- $collection = $this->repository->getJournalLinks($linkType);- $count = $collection->count();+ $collection = $this->repository->getJournalLinks($linkType);+ $count = $collection->count();$journalLinks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// make paginator:diff --git a/app/Api/V1/Controllers/Models/TransactionLinkType/StoreController.php b/app/Api/V1/Controllers/Models/TransactionLinkType/StoreController.phpindex 087eeae6fd..f7917138e9 100644--- a/app/Api/V1/Controllers/Models/TransactionLinkType/StoreController.php+++ b/app/Api/V1/Controllers/Models/TransactionLinkType/StoreController.php@@ -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.');+ 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:diff --git a/app/Api/V1/Controllers/Models/TransactionLinkType/UpdateController.php b/app/Api/V1/Controllers/Models/TransactionLinkType/UpdateController.phpindex d97d6a355a..5ed66ec7e9 100644--- a/app/Api/V1/Controllers/Models/TransactionLinkType/UpdateController.php+++ b/app/Api/V1/Controllers/Models/TransactionLinkType/UpdateController.php@@ -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.');+ throw new FireflyException('200005: You need the "owner" role to do this.');}$data = $request->getAll();diff --git a/app/Api/V1/Controllers/System/ConfigurationController.php b/app/Api/V1/Controllers/System/ConfigurationController.phpindex c15d499943..885175837c 100644--- a/app/Api/V1/Controllers/System/ConfigurationController.php+++ b/app/Api/V1/Controllers/System/ConfigurationController.php@@ -162,7 +162,7 @@ class ConfigurationController extends Controllerpublic 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.');+ throw new FireflyException('200005: You need the "owner" role to do this.');}$data = $request->getAll();$shortName = str_replace('configuration.', '', $name);diff --git a/app/Api/V1/Controllers/System/UserController.php b/app/Api/V1/Controllers/System/UserController.phpindex 96574b45f1..368359afe9 100644--- a/app/Api/V1/Controllers/System/UserController.php+++ b/app/Api/V1/Controllers/System/UserController.php@@ -83,7 +83,7 @@ class UserController extends Controllerreturn response()->json([], 204);}- throw new FireflyException('200025: No access to function.');+ throw new FireflyException('200025: No access to function.');}/**diff --git a/app/Api/V1/Controllers/Webhook/ShowController.php b/app/Api/V1/Controllers/Webhook/ShowController.phpindex 9707cc326b..cfa77aef1e 100644--- a/app/Api/V1/Controllers/Webhook/ShowController.php+++ b/app/Api/V1/Controllers/Webhook/ShowController.php@@ -67,11 +67,11 @@ class ShowController extends Controller*/public function index(): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();$collection = $this->repository->all();- $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;- $count = $collection->count();- $webhooks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);+ $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;+ $count = $collection->count();+ $webhooks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// make paginator:$paginator = new LengthAwarePaginator($webhooks, $count, $pageSize, $this->parameters->get('page'));diff --git a/app/Api/V1/Controllers/Webhook/StoreController.php b/app/Api/V1/Controllers/Webhook/StoreController.phpindex 9db3f162c7..ffd6c292d0 100644--- a/app/Api/V1/Controllers/Webhook/StoreController.php+++ b/app/Api/V1/Controllers/Webhook/StoreController.php@@ -61,7 +61,7 @@ class StoreController extends Controller*/public function store(CreateRequest $request): JsonResponse{- $data = $request->getData();+ $data = $request->getData();$webhook = $this->repository->store($data);$manager = $this->getManager();/** @var WebhookTransformer $transformer */diff --git a/app/Api/V1/Requests/Models/Account/UpdateRequest.php b/app/Api/V1/Requests/Models/Account/UpdateRequest.phpindex b8bcf1fa3e..d2d63e80bf 100644--- a/app/Api/V1/Requests/Models/Account/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/Account/UpdateRequest.php@@ -71,7 +71,7 @@ class UpdateRequest extends FormRequest'currency_id' => ['currency_id', 'integer'],'currency_code' => ['currency_code', 'string'],'liability_direction' => ['liability_direction', 'string'],- 'liability_amount' => ['liability_amount', 'string'],+ 'liability_amount' => ['liability_amount', 'string'],'liability_start_date' => ['liability_start_date', 'date'],];/** @var Account $account */diff --git a/app/Api/V1/Requests/Models/Budget/UpdateRequest.php b/app/Api/V1/Requests/Models/Budget/UpdateRequest.phpindex 13fe5b0176..8f9ea79f0a 100644--- a/app/Api/V1/Requests/Models/Budget/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/Budget/UpdateRequest.php@@ -78,6 +78,7 @@ class UpdateRequest extends FormRequestpublic function rules(): array{$budget = $this->route()->parameter('budget');+return ['name' => sprintf('between:1,100|uniqueObjectForUser:budgets,name,%d', $budget->id),'active' => [new IsBoolean],diff --git a/app/Api/V1/Requests/Models/BudgetLimit/UpdateRequest.php b/app/Api/V1/Requests/Models/BudgetLimit/UpdateRequest.phpindex ff54dbb91e..26859034b5 100644--- a/app/Api/V1/Requests/Models/BudgetLimit/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/BudgetLimit/UpdateRequest.php@@ -76,7 +76,7 @@ class UpdateRequest extends FormRequest* Configure the validator instance with special rules for after the basic validation rules.** @param Validator $validator-* See reference nr. 72+ * See reference nr. 72** @return void*/diff --git a/app/Api/V1/Requests/Models/Tag/UpdateRequest.php b/app/Api/V1/Requests/Models/Tag/UpdateRequest.phpindex ec94768db2..9ce9be4676 100644--- a/app/Api/V1/Requests/Models/Tag/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/Tag/UpdateRequest.php@@ -65,7 +65,7 @@ class UpdateRequest extends FormRequestpublic function rules(): array{$tag = $this->route()->parameter('tagOrId');-// See reference nr. 73+ // See reference nr. 73$rules = ['tag' => 'min:1|uniqueObjectForUser:tags,tag,' . $tag->id,'description' => 'min:1|nullable',diff --git a/app/Api/V1/Requests/Models/Transaction/StoreRequest.php b/app/Api/V1/Requests/Models/Transaction/StoreRequest.phpindex fbdec3a18d..aec8941390 100644--- a/app/Api/V1/Requests/Models/Transaction/StoreRequest.php+++ b/app/Api/V1/Requests/Models/Transaction/StoreRequest.php@@ -53,6 +53,7 @@ class StoreRequest extends FormRequestpublic function getAll(): array{Log::debug('get all data in TransactionStoreRequest');+return ['group_title' => $this->string('group_title'),'error_if_duplicate_hash' => $this->boolean('error_if_duplicate_hash'),@@ -60,7 +61,7 @@ class StoreRequest extends FormRequest'fire_webhooks' => $this->boolean('fire_webhooks', true),'transactions' => $this->getTransactionData(),];-// See reference nr. 71+ // See reference nr. 71}/**diff --git a/app/Api/V1/Requests/Models/TransactionCurrency/UpdateRequest.php b/app/Api/V1/Requests/Models/TransactionCurrency/UpdateRequest.phpindex 9b570af6f2..ad183cca80 100644--- a/app/Api/V1/Requests/Models/TransactionCurrency/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/TransactionCurrency/UpdateRequest.php@@ -55,7 +55,7 @@ class UpdateRequest extends FormRequest];return $this->getAllData($fields);-// return $return;+ // return $return;}/**diff --git a/app/Api/V1/Requests/System/UpdateRequest.php b/app/Api/V1/Requests/System/UpdateRequest.phpindex 3386d17165..17c009f9a9 100644--- a/app/Api/V1/Requests/System/UpdateRequest.php+++ b/app/Api/V1/Requests/System/UpdateRequest.php@@ -57,7 +57,7 @@ class UpdateRequest extends FormRequestreturn ['value' => $this->integer('value')];}- return ['value' => $this->string('value')];+ return ['value' => $this->string('value')];}/**@@ -80,6 +80,6 @@ class UpdateRequest extends FormRequestreturn ['value' => 'required|numeric|min:464272080'];}- return ['value' => 'required'];+ return ['value' => 'required'];}}diff --git a/app/Console/Commands/Correction/CorrectDatabase.php b/app/Console/Commands/Correction/CorrectDatabase.phpindex ee61a0bb72..6c378372f8 100644--- a/app/Console/Commands/Correction/CorrectDatabase.php+++ b/app/Console/Commands/Correction/CorrectDatabase.php@@ -76,7 +76,7 @@ class CorrectDatabase extends Command'firefly-iii:fix-recurring-transactions','firefly-iii:restore-oauth-keys','firefly-iii:fix-transaction-types',- 'firefly-iii:fix-frontpage-accounts'+ 'firefly-iii:fix-frontpage-accounts',];foreach ($commands as $command) {$this->line(sprintf('Now executing %s', $command));diff --git a/app/Console/Commands/Correction/DeleteOrphanedTransactions.php b/app/Console/Commands/Correction/DeleteOrphanedTransactions.phpindex 114353aff9..359930b51a 100644--- a/app/Console/Commands/Correction/DeleteOrphanedTransactions.php+++ b/app/Console/Commands/Correction/DeleteOrphanedTransactions.php@@ -106,7 +106,7 @@ class DeleteOrphanedTransactions extends Commandprivate function deleteFromOrphanedAccounts(): void{$set- = Transaction+ = Transaction::leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')->whereNotNull('accounts.deleted_at')->get(['transactions.*']);diff --git a/app/Console/Commands/Correction/DeleteZeroAmount.php b/app/Console/Commands/Correction/DeleteZeroAmount.phpindex 28ff944370..6ff620ce97 100644--- a/app/Console/Commands/Correction/DeleteZeroAmount.php+++ b/app/Console/Commands/Correction/DeleteZeroAmount.php@@ -53,9 +53,9 @@ class DeleteZeroAmount extends Command*/public function handle(): int{- $start = microtime(true);- $set = Transaction::where('amount', 0)->get(['transaction_journal_id'])->pluck('transaction_journal_id')->toArray();- $set = array_unique($set);+ $start = microtime(true);+ $set = Transaction::where('amount', 0)->get(['transaction_journal_id'])->pluck('transaction_journal_id')->toArray();+ $set = array_unique($set);$journals = TransactionJournal::whereIn('id', $set)->get();/** @var TransactionJournal $journal */foreach ($journals as $journal) {diff --git a/app/Console/Commands/Correction/EnableCurrencies.php b/app/Console/Commands/Correction/EnableCurrencies.phpindex d88c66bc04..b0046ee6fa 100644--- a/app/Console/Commands/Correction/EnableCurrencies.php+++ b/app/Console/Commands/Correction/EnableCurrencies.php@@ -85,8 +85,8 @@ class EnableCurrencies extends Command$found[] = (int)$entry->transaction_currency_id;}- $found = array_values(array_unique($found));- $found = array_values(+ $found = array_values(array_unique($found));+ $found = array_values(array_filter($found, function (int $currencyId) {return $currencyId !== 0;diff --git a/app/Console/Commands/Correction/FixPiggies.php b/app/Console/Commands/Correction/FixPiggies.phpindex 692493123b..22ea9c0967 100644--- a/app/Console/Commands/Correction/FixPiggies.php+++ b/app/Console/Commands/Correction/FixPiggies.php@@ -57,7 +57,7 @@ class FixPiggies extends Command{$count = 0;$start = microtime(true);- $set = PiggyBankEvent::with(['PiggyBank', 'TransactionJournal', 'TransactionJournal.TransactionType'])->get();+ $set = PiggyBankEvent::with(['PiggyBank', 'TransactionJournal', 'TransactionJournal.TransactionType'])->get();/** @var PiggyBankEvent $event */foreach ($set as $event) {diff --git a/app/Console/Commands/Correction/FixPostgresSequences.php b/app/Console/Commands/Correction/FixPostgresSequences.phpindex eec112169d..0b1862e295 100644--- a/app/Console/Commands/Correction/FixPostgresSequences.php+++ b/app/Console/Commands/Correction/FixPostgresSequences.php@@ -125,7 +125,7 @@ class FixPostgresSequences extends Command$highestId = DB::table($tableToCheck)->select(DB::raw('MAX(id)'))->first();$nextId = DB::table($tableToCheck)->select(DB::raw(sprintf('nextval(\'%s_id_seq\')', $tableToCheck)))->first();- if(null === $nextId) {+ if (null === $nextId) {$this->line(sprintf('nextval is NULL for table "%s", go to next table.', $tableToCheck));continue;}diff --git a/app/Console/Commands/Correction/FixUnevenAmount.php b/app/Console/Commands/Correction/FixUnevenAmount.phpindex 157e955164..73deae867c 100644--- a/app/Console/Commands/Correction/FixUnevenAmount.php+++ b/app/Console/Commands/Correction/FixUnevenAmount.php@@ -91,7 +91,7 @@ class FixUnevenAmount extends Command// one of the transactions is bad.$journal = TransactionJournal::find($param);if (!$journal) {- return;+ return;}/** @var Transaction $source */$source = $journal->transactions()->where('amount', '<', 0)->first();diff --git a/app/Console/Commands/Export/ExportData.php b/app/Console/Commands/Export/ExportData.phpindex 9d5f2b9d74..529758e64a 100644--- a/app/Console/Commands/Export/ExportData.php+++ b/app/Console/Commands/Export/ExportData.php@@ -36,7 +36,6 @@ use FireflyIII\Support\Export\ExportDataGenerator;use Illuminate\Console\Command;use Illuminate\Support\Collection;use InvalidArgumentException;-use League\Csv\CannotInsertRecord;use Log;/**diff --git a/app/Console/Commands/Upgrade/BudgetLimitCurrency.php b/app/Console/Commands/Upgrade/BudgetLimitCurrency.phpindex d849f5c02c..af7aa203c8 100644--- a/app/Console/Commands/Upgrade/BudgetLimitCurrency.php+++ b/app/Console/Commands/Upgrade/BudgetLimitCurrency.php@@ -26,6 +26,7 @@ namespace FireflyIII\Console\Commands\Upgrade;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\BudgetLimit;use Illuminate\Console\Command;+use JsonException;/*** Class BudgetLimitCurrency@@ -51,7 +52,7 @@ class BudgetLimitCurrency extends Command** @return int* @throws FireflyException- * @throws \JsonException+ * @throws JsonException*/public function handle(): int{@@ -106,7 +107,7 @@ class BudgetLimitCurrency extends Commandreturn (bool)$configVar->data;}- return false;+ return false;}/**diff --git a/app/Console/Commands/Upgrade/CCLiabilities.php b/app/Console/Commands/Upgrade/CCLiabilities.phpindex 4b3fb4028e..0f9f365de6 100644--- a/app/Console/Commands/Upgrade/CCLiabilities.php+++ b/app/Console/Commands/Upgrade/CCLiabilities.php@@ -104,7 +104,7 @@ class CCLiabilities extends Commandreturn (bool)$configVar->data;}- return false;+ return false;}/**diff --git a/app/Console/Commands/Upgrade/MigrateAttachments.php b/app/Console/Commands/Upgrade/MigrateAttachments.phpindex 2776779fc8..6d210b95e1 100644--- a/app/Console/Commands/Upgrade/MigrateAttachments.php+++ b/app/Console/Commands/Upgrade/MigrateAttachments.php@@ -116,7 +116,7 @@ class MigrateAttachments extends Commandreturn (bool)$configVar->data;}- return false;+ return false;}/**diff --git a/app/Console/Commands/Upgrade/MigrateJournalNotes.php b/app/Console/Commands/Upgrade/MigrateJournalNotes.phpindex 93534d2a92..698b696f28 100644--- a/app/Console/Commands/Upgrade/MigrateJournalNotes.php+++ b/app/Console/Commands/Upgrade/MigrateJournalNotes.php@@ -66,7 +66,7 @@ class MigrateJournalNotes extends Command}$count = 0;- $set = TransactionJournalMeta::whereName('notes')->get();+ $set = TransactionJournalMeta::whereName('notes')->get();/** @var TransactionJournalMeta $meta */foreach ($set as $meta) {$journal = $meta->transactionJournal;@@ -114,7 +114,7 @@ class MigrateJournalNotes extends Commandreturn (bool)$configVar->data;}- return false;+ return false;}/**diff --git a/app/Console/Commands/Upgrade/MigrateRecurrenceMeta.php b/app/Console/Commands/Upgrade/MigrateRecurrenceMeta.phpindex 2980cc2a17..a4c74d1731 100644--- a/app/Console/Commands/Upgrade/MigrateRecurrenceMeta.php+++ b/app/Console/Commands/Upgrade/MigrateRecurrenceMeta.php@@ -92,7 +92,7 @@ class MigrateRecurrenceMeta extends Commandreturn (bool)$configVar->data;}- return false;+ return false;}/**diff --git a/app/Console/Commands/Upgrade/MigrateRecurrenceType.php b/app/Console/Commands/Upgrade/MigrateRecurrenceType.phpindex 3f30915260..ad99981512 100644--- a/app/Console/Commands/Upgrade/MigrateRecurrenceType.php+++ b/app/Console/Commands/Upgrade/MigrateRecurrenceType.php@@ -85,7 +85,7 @@ class MigrateRecurrenceType extends Commandreturn (bool)$configVar->data;}- return false;+ return false;}/**diff --git a/app/Console/Commands/Upgrade/MigrateTagLocations.php b/app/Console/Commands/Upgrade/MigrateTagLocations.phpindex 765f0f874b..e5162cdbf6 100644--- a/app/Console/Commands/Upgrade/MigrateTagLocations.php+++ b/app/Console/Commands/Upgrade/MigrateTagLocations.php@@ -83,7 +83,7 @@ class MigrateTagLocations extends Commandreturn (bool)$configVar->data;}- return false;+ return false;}private function migrateTagLocations(): voiddiff --git a/app/Console/Commands/Upgrade/MigrateToGroups.php b/app/Console/Commands/Upgrade/MigrateToGroups.phpindex 8f537ecdf8..dcf11e2cca 100644--- a/app/Console/Commands/Upgrade/MigrateToGroups.php+++ b/app/Console/Commands/Upgrade/MigrateToGroups.php@@ -137,7 +137,7 @@ class MigrateToGroups extends Commandreturn (bool)$configVar->data;}- return false;+ return false;}/**diff --git a/app/Console/Commands/Upgrade/MigrateToRules.php b/app/Console/Commands/Upgrade/MigrateToRules.phpindex 364cb64df0..25f96d8c6e 100644--- a/app/Console/Commands/Upgrade/MigrateToRules.php+++ b/app/Console/Commands/Upgrade/MigrateToRules.php@@ -128,7 +128,7 @@ class MigrateToRules extends Commandreturn (bool)$configVar->data;}- return false;+ return false;}/**diff --git a/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php b/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.phpindex 30fc3efe17..e0f86f27fe 100644--- a/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php+++ b/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php@@ -123,7 +123,7 @@ class OtherCurrenciesCorrections extends Commandreturn (bool)$configVar->data;}- return false;+ return false;}/**@@ -248,10 +248,10 @@ class OtherCurrenciesCorrections extends Command{$accountId = $account->id;if (array_key_exists($accountId, $this->accountCurrencies) && 0 === $this->accountCurrencies[$accountId]) {- return null;+ return null;}if (array_key_exists($accountId, $this->accountCurrencies) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) {- return $this->accountCurrencies[$accountId];+ return $this->accountCurrencies[$accountId];}$currency = $this->accountRepos->getAccountCurrency($account);if (null === $currency) {diff --git a/app/Console/Commands/Upgrade/RenameAccountMeta.php b/app/Console/Commands/Upgrade/RenameAccountMeta.phpindex c1a6aee640..24340ff75c 100644--- a/app/Console/Commands/Upgrade/RenameAccountMeta.php+++ b/app/Console/Commands/Upgrade/RenameAccountMeta.php@@ -107,7 +107,7 @@ class RenameAccountMeta extends Commandreturn (bool)$configVar->data;}- return false;+ return false;}/**diff --git a/app/Console/Commands/Upgrade/TransactionIdentifier.php b/app/Console/Commands/Upgrade/TransactionIdentifier.phpindex 90634bf560..5ec7c1a576 100644--- a/app/Console/Commands/Upgrade/TransactionIdentifier.php+++ b/app/Console/Commands/Upgrade/TransactionIdentifier.php@@ -191,6 +191,7 @@ class TransactionIdentifier extends Commandreturn null;}+return $opposing;}diff --git a/app/Console/Commands/Upgrade/TransferCurrenciesCorrections.php b/app/Console/Commands/Upgrade/TransferCurrenciesCorrections.phpindex 37f94051a4..52c9316f3f 100644--- a/app/Console/Commands/Upgrade/TransferCurrenciesCorrections.php+++ b/app/Console/Commands/Upgrade/TransferCurrenciesCorrections.php@@ -23,6 +23,7 @@ declare(strict_types=1);namespace FireflyIII\Console\Commands\Upgrade;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\Account;use FireflyIII\Models\Transaction;use FireflyIII\Models\TransactionCurrency;@@ -132,7 +133,7 @@ class TransferCurrenciesCorrections extends Command/*** @return bool- * @throws \FireflyIII\Exceptions\FireflyException+ * @throws FireflyException*/private function isExecuted(): bool{@@ -141,7 +142,7 @@ class TransferCurrenciesCorrections extends Commandreturn (bool)$configVar->data;}- return false;+ return false;}/**@@ -271,10 +272,10 @@ class TransferCurrenciesCorrections extends Command{$accountId = $account->id;if (array_key_exists($accountId, $this->accountCurrencies) && 0 === $this->accountCurrencies[$accountId]) {- return null;+ return null;}if (array_key_exists($accountId, $this->accountCurrencies) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) {- return $this->accountCurrencies[$accountId];+ return $this->accountCurrencies[$accountId];}$currency = $this->accountRepos->getAccountCurrency($account);if (null === $currency) {diff --git a/app/Console/Commands/Upgrade/UpgradeDatabase.php b/app/Console/Commands/Upgrade/UpgradeDatabase.phpindex 9b6aa4c543..c94a6a6cd5 100644--- a/app/Console/Commands/Upgrade/UpgradeDatabase.php+++ b/app/Console/Commands/Upgrade/UpgradeDatabase.php@@ -106,7 +106,7 @@ class UpgradeDatabase extends Command// instructions'firefly:instructions update',- 'firefly-iii:verify-security-alerts'+ 'firefly-iii:verify-security-alerts',];$args = [];if ($this->option('force')) {diff --git a/app/Console/Commands/Upgrade/UpgradeLiabilities.php b/app/Console/Commands/Upgrade/UpgradeLiabilities.phpindex da7eeb5cea..d8780ddf9e 100644--- a/app/Console/Commands/Upgrade/UpgradeLiabilities.php+++ b/app/Console/Commands/Upgrade/UpgradeLiabilities.php@@ -92,59 +92,6 @@ class UpgradeLiabilities extends Commandreturn false;}- /**- * @param Account $account- * @param TransactionJournal $openingBalance- */- private function correctOpeningBalance(Account $account, TransactionJournal $openingBalance): void- {- $source = $this->getSourceTransaction($openingBalance);- $destination = $this->getDestinationTransaction($openingBalance);- if (null === $source || null === $destination) {- return;- }- // source MUST be the liability.- if ((int)$destination->account_id === (int)$account->id) {- Log::debug(sprintf('Must switch around, because account #%d is the destination.', $destination->account_id));- // so if not, switch things around:- $sourceAccountId = (int)$source->account_id;- $source->account_id = $destination->account_id;- $destination->account_id = $sourceAccountId;- $source->save();- $destination->save();- Log::debug(sprintf('Source transaction #%d now has account #%d', $source->id, $source->account_id));- Log::debug(sprintf('Dest transaction #%d now has account #%d', $destination->id, $destination->account_id));- }- }-- /**- * @param TransactionJournal $journal- *- * @return Transaction|null- */- private function getSourceTransaction(TransactionJournal $journal): ?Transaction- {- return $journal->transactions()->where('amount', '<', 0)->first();- }-- /**- * @param TransactionJournal $journal- *- * @return Transaction|null- */- private function getDestinationTransaction(TransactionJournal $journal): ?Transaction- {- return $journal->transactions()->where('amount', '>', 0)->first();- }-- /**- *- */- private function markAsExecuted(): void- {- app('fireflyconfig')->set(self::CONFIG_NAME, true);- }-/****/@@ -200,4 +147,57 @@ class UpgradeLiabilities extends Command$factory->crud($account, 'liability_direction', 'debit');}+ /**+ * @param Account $account+ * @param TransactionJournal $openingBalance+ */+ private function correctOpeningBalance(Account $account, TransactionJournal $openingBalance): void+ {+ $source = $this->getSourceTransaction($openingBalance);+ $destination = $this->getDestinationTransaction($openingBalance);+ if (null === $source || null === $destination) {+ return;+ }+ // source MUST be the liability.+ if ((int)$destination->account_id === (int)$account->id) {+ Log::debug(sprintf('Must switch around, because account #%d is the destination.', $destination->account_id));+ // so if not, switch things around:+ $sourceAccountId = (int)$source->account_id;+ $source->account_id = $destination->account_id;+ $destination->account_id = $sourceAccountId;+ $source->save();+ $destination->save();+ Log::debug(sprintf('Source transaction #%d now has account #%d', $source->id, $source->account_id));+ Log::debug(sprintf('Dest transaction #%d now has account #%d', $destination->id, $destination->account_id));+ }+ }++ /**+ * @param TransactionJournal $journal+ *+ * @return Transaction|null+ */+ private function getSourceTransaction(TransactionJournal $journal): ?Transaction+ {+ return $journal->transactions()->where('amount', '<', 0)->first();+ }++ /**+ * @param TransactionJournal $journal+ *+ * @return Transaction|null+ */+ private function getDestinationTransaction(TransactionJournal $journal): ?Transaction+ {+ return $journal->transactions()->where('amount', '>', 0)->first();+ }++ /**+ *+ */+ private function markAsExecuted(): void+ {+ app('fireflyconfig')->set(self::CONFIG_NAME, true);+ }+}diff --git a/app/Console/Commands/VerifySecurityAlerts.php b/app/Console/Commands/VerifySecurityAlerts.phpindex e49872b909..c0bd37e3b8 100644--- a/app/Console/Commands/VerifySecurityAlerts.php+++ b/app/Console/Commands/VerifySecurityAlerts.php@@ -25,8 +25,9 @@ declare(strict_types=1);namespace FireflyIII\Console\Commands;use Illuminate\Console\Command;-use Storage;+use Illuminate\Contracts\Filesystem\FileNotFoundException;use Log;+use Storage;/*** Class VerifySecurityAlerts@@ -34,24 +35,23 @@ use Log;class VerifySecurityAlerts extends Command{/**- * The name and signature of the console command.+ * The console command description.** @var string*/- protected $signature = 'firefly-iii:verify-security-alerts';-+ protected $description = 'Verify security alerts';/**- * The console command description.+ * The name and signature of the console command.** @var string*/- protected $description = 'Verify security alerts';+ protected $signature = 'firefly-iii:verify-security-alerts';/*** Execute the console command.** @return int- * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException+ * @throws FileNotFoundException*/public function handle(): int{@@ -64,6 +64,7 @@ class VerifySecurityAlerts extends Command$disk = Storage::disk('resources');if (!$disk->has('alerts.json')) {Log::debug('No alerts.json file present.');+return 0;}$content = $disk->get('alerts.json');@@ -81,6 +82,7 @@ class VerifySecurityAlerts extends Commandif ('info' === $array['level']) {Log::debug('INFO level alert');$this->info($array['message']);+return 0;}if ('warning' === $array['level']) {@@ -88,6 +90,7 @@ class VerifySecurityAlerts extends Command$this->warn('------------------------ :o');$this->warn($array['message']);$this->warn('------------------------ :o');+return 0;}if ('danger' === $array['level']) {@@ -95,6 +98,7 @@ class VerifySecurityAlerts extends Command$this->error('------------------------ :-(');$this->error($array['message']);$this->error('------------------------ :-(');+return 0;}diff --git a/app/Events/AdminRequestedTestMessage.php b/app/Events/AdminRequestedTestMessage.phpindex 821064065c..78f90858c8 100644--- a/app/Events/AdminRequestedTestMessage.php+++ b/app/Events/AdminRequestedTestMessage.php@@ -41,6 +41,7 @@ class AdminRequestedTestMessage extends Eventpublic $ipAddress;/** @var User The user */public $user;+/*** Create a new event instance.*diff --git a/app/Events/DestroyedTransactionGroup.php b/app/Events/DestroyedTransactionGroup.phpindex baca5a78f5..09c9c66107 100644--- a/app/Events/DestroyedTransactionGroup.php+++ b/app/Events/DestroyedTransactionGroup.php@@ -37,6 +37,7 @@ class DestroyedTransactionGroup extends Eventuse SerializesModels;public TransactionGroup $transactionGroup;+/*** Create a new event instance.*diff --git a/app/Events/DestroyedTransactionLink.php b/app/Events/DestroyedTransactionLink.phpindex fde76cf98c..1c9629f526 100644--- a/app/Events/DestroyedTransactionLink.php+++ b/app/Events/DestroyedTransactionLink.php@@ -22,6 +22,7 @@declare(strict_types=1);namespace FireflyIII\Events;+use FireflyIII\Models\TransactionJournalLink;use Illuminate\Queue\SerializesModels;diff --git a/app/Events/DetectedNewIPAddress.php b/app/Events/DetectedNewIPAddress.phpindex 231f1247d8..567bba32cc 100644--- a/app/Events/DetectedNewIPAddress.php+++ b/app/Events/DetectedNewIPAddress.php@@ -22,6 +22,7 @@declare(strict_types=1);namespace FireflyIII\Events;+use FireflyIII\User;use Illuminate\Queue\SerializesModels;diff --git a/app/Events/RegisteredUser.php b/app/Events/RegisteredUser.phpindex a8a8d59fd7..a49d099f88 100644--- a/app/Events/RegisteredUser.php+++ b/app/Events/RegisteredUser.php@@ -40,6 +40,7 @@ class RegisteredUser extends Eventpublic $ipAddress;/** @var User The user */public $user;+/*** Create a new event instance. This event is triggered when a new user registers.*diff --git a/app/Events/RequestedNewPassword.php b/app/Events/RequestedNewPassword.phpindex 13f04ce363..1706faa15c 100644--- a/app/Events/RequestedNewPassword.php+++ b/app/Events/RequestedNewPassword.php@@ -42,6 +42,7 @@ class RequestedNewPassword extends Eventpublic $token;/** @var User The user */public $user;+/*** Create a new event instance. This event is triggered when a users tries to reset his or her password.*diff --git a/app/Events/RequestedReportOnJournals.php b/app/Events/RequestedReportOnJournals.phpindex 8790d696aa..fc91987d1c 100644--- a/app/Events/RequestedReportOnJournals.php+++ b/app/Events/RequestedReportOnJournals.php@@ -44,6 +44,7 @@ class RequestedReportOnJournalspublic $groups;/** @var int The ID of the user. */public $userId;+/*** Create a new event instance.*diff --git a/app/Events/RequestedSendWebhookMessages.php b/app/Events/RequestedSendWebhookMessages.phpindex a46fb630e5..86193440c5 100644--- a/app/Events/RequestedSendWebhookMessages.php+++ b/app/Events/RequestedSendWebhookMessages.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Events;use Illuminate\Queue\SerializesModels;+class RequestedSendWebhookMessages extends Event{use SerializesModels;diff --git a/app/Events/RequestedVersionCheckStatus.php b/app/Events/RequestedVersionCheckStatus.phpindex cdd1aa4d76..5bc88c617d 100644--- a/app/Events/RequestedVersionCheckStatus.php+++ b/app/Events/RequestedVersionCheckStatus.php@@ -26,6 +26,7 @@ namespace FireflyIII\Events;use FireflyIII\User;use Illuminate\Queue\SerializesModels;+/*** Class RequestedVersionCheckStatus*@@ -37,6 +38,7 @@ class RequestedVersionCheckStatus extends Event/** @var User The user */public $user;+/*** Create a new event instance. This event is triggered when Firefly III wants to know* what the deal is with the version checker.diff --git a/app/Events/UserChangedEmail.php b/app/Events/UserChangedEmail.phpindex c8b3dec0b6..8f4f70090d 100644--- a/app/Events/UserChangedEmail.php+++ b/app/Events/UserChangedEmail.php@@ -44,6 +44,7 @@ class UserChangedEmail extends Eventpublic $oldEmail;/** @var User The user itself */public $user;+/*** UserChangedEmail constructor.*diff --git a/app/Exceptions/GracefulNotFoundHandler.php b/app/Exceptions/GracefulNotFoundHandler.phpindex ae3f64868c..cf8f061ca1 100644--- a/app/Exceptions/GracefulNotFoundHandler.php+++ b/app/Exceptions/GracefulNotFoundHandler.php@@ -166,7 +166,7 @@ class GracefulNotFoundHandler extends ExceptionHandler}/**- * @param Request $request+ * @param Request $request* @param Throwable $exception** @return RedirectResponse|\Illuminate\Http\Response|Redirector|Responsediff --git a/app/Factory/AccountFactory.php b/app/Factory/AccountFactory.phpindex 990631364a..0bd843e5a1 100644--- a/app/Factory/AccountFactory.php+++ b/app/Factory/AccountFactory.php@@ -49,8 +49,8 @@ class AccountFactoryprotected array $validAssetFields;protected array $validCCFields;protected array $validFields;- private array $canHaveVirtual;private array $canHaveOpeningBalance;+ private array $canHaveVirtual;private User $user;/**diff --git a/app/Factory/AccountMetaFactory.php b/app/Factory/AccountMetaFactory.phpindex 87133621b6..322d1ea144 100644--- a/app/Factory/AccountMetaFactory.php+++ b/app/Factory/AccountMetaFactory.php@@ -68,7 +68,7 @@ class AccountMetaFactorytry {$entry->delete();} catch (Exception $e) { // @phpstan-ignore-line- Log::debug(sprintf('Could not delete entry: %s', $e->getMessage()));+ Log::debug(sprintf('Could not delete entry: %s', $e->getMessage()));}return null;diff --git a/app/Factory/AttachmentFactory.php b/app/Factory/AttachmentFactory.phpindex 7c5ecedfb3..771aa695fb 100644--- a/app/Factory/AttachmentFactory.php+++ b/app/Factory/AttachmentFactory.php@@ -54,7 +54,7 @@ class AttachmentFactory/** @var Transaction $transaction */$transaction = $this->user->transactions()->find((int)$data['attachable_id']);if (null === $transaction) {- throw new FireflyException('Unexpectedly could not find transaction');+ throw new FireflyException('Unexpectedly could not find transaction');}$data['attachable_id'] = $transaction->transaction_journal_id;$model = TransactionJournal::class;diff --git a/app/Factory/RecurrenceFactory.php b/app/Factory/RecurrenceFactory.phpindex 3de96669e5..790c432a6f 100644--- a/app/Factory/RecurrenceFactory.php+++ b/app/Factory/RecurrenceFactory.php@@ -142,19 +142,19 @@ class RecurrenceFactory}/**- * @param User $user+ * @return MessageBag*/- public function setUser(User $user): void+ public function getErrors(): MessageBag{- $this->user = $user;+ return $this->errors;}/**- * @return MessageBag+ * @param User $user*/- public function getErrors(): MessageBag+ public function setUser(User $user): void{- return $this->errors;+ $this->user = $user;}diff --git a/app/Factory/TransactionJournalMetaFactory.php b/app/Factory/TransactionJournalMetaFactory.phpindex 0fb32095f6..c734664e8f 100644--- a/app/Factory/TransactionJournalMetaFactory.php+++ b/app/Factory/TransactionJournalMetaFactory.php@@ -50,7 +50,7 @@ class TransactionJournalMetaFactorytry {$entry->delete();} catch (Exception $e) { // @phpstan-ignore-line- Log::error(sprintf('Could not delete transaction journal meta: %s', $e->getMessage()));+ Log::error(sprintf('Could not delete transaction journal meta: %s', $e->getMessage()));}return null;@@ -68,7 +68,7 @@ class TransactionJournalMetaFactorytry {$entry->delete();} catch (Exception $e) { // @phpstan-ignore-line- Log::error(sprintf('Could not delete transaction journal meta: %s', $e->getMessage()));+ Log::error(sprintf('Could not delete transaction journal meta: %s', $e->getMessage()));}}diff --git a/app/Generator/Report/Audit/MonthReportGenerator.php b/app/Generator/Report/Audit/MonthReportGenerator.phpindex d12efb5eb9..393c98e782 100644--- a/app/Generator/Report/Audit/MonthReportGenerator.php+++ b/app/Generator/Report/Audit/MonthReportGenerator.php@@ -32,6 +32,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;use FireflyIII\Repositories\Journal\JournalRepositoryInterface;use Illuminate\Support\Collection;use JetBrains\PhpStorm\ArrayShape;+use JsonException;use Log;use Throwable;@@ -195,7 +196,7 @@ class MonthReportGenerator implements ReportGeneratorInterface** @return array* @throws FireflyException- * @throws \JsonException+ * @throws JsonException*/#[ArrayShape(['journals' => "array", 'currency' => "mixed", 'exists' => "bool", 'end' => "string", 'endBalance' => "mixed", 'dayBefore' => "string",'dayBeforeBalance' => "mixed"])] public function getAuditReport(Account $account, Carbon $date): arraydiff --git a/app/Generator/Report/Budget/MonthReportGenerator.php b/app/Generator/Report/Budget/MonthReportGenerator.phpindex 3b3b64d64a..63bd4ce9e8 100644--- a/app/Generator/Report/Budget/MonthReportGenerator.php+++ b/app/Generator/Report/Budget/MonthReportGenerator.php@@ -34,7 +34,7 @@ use Throwable;/*** Class MonthReportGenerator.-* See reference nr. 19+ * See reference nr. 19** @codeCoverageIgnore*/diff --git a/app/Generator/Report/Category/MonthReportGenerator.php b/app/Generator/Report/Category/MonthReportGenerator.phpindex ac717e2dcb..1a5eebd205 100644--- a/app/Generator/Report/Category/MonthReportGenerator.php+++ b/app/Generator/Report/Category/MonthReportGenerator.php@@ -35,7 +35,7 @@ use Throwable;/*** Class MonthReportGenerator.-* See reference nr. 18+ * See reference nr. 18** @codeCoverageIgnore*/diff --git a/app/Handlers/Events/AutomationHandler.php b/app/Handlers/Events/AutomationHandler.phpindex 463b5681a1..e05d596997 100644--- a/app/Handlers/Events/AutomationHandler.php+++ b/app/Handlers/Events/AutomationHandler.php@@ -50,7 +50,7 @@ class AutomationHandler$sendReport = config('firefly.send_report_journals');if (false === $sendReport) {- return true;+ return true;}Log::debug('In reportJournals.');diff --git a/app/Handlers/Events/StoredGroupEventHandler.php b/app/Handlers/Events/StoredGroupEventHandler.phpindex 8a54064090..ab85c412c3 100644--- a/app/Handlers/Events/StoredGroupEventHandler.php+++ b/app/Handlers/Events/StoredGroupEventHandler.php@@ -77,6 +77,18 @@ class StoredGroupEventHandler$newRuleEngine->fire();}+ /**+ * @param StoredTransactionGroup $event+ */+ public function recalculateCredit(StoredTransactionGroup $event): void+ {+ $group = $event->transactionGroup;+ /** @var CreditRecalculateService $object */+ $object = app(CreditRecalculateService::class);+ $object->setGroup($group);+ $object->recalculate();+ }+/*** This method processes all webhooks that respond to the "stored transaction group" trigger (100)*@@ -108,16 +120,4 @@ class StoredGroupEventHandlerevent(new RequestedSendWebhookMessages);}- /**- * @param StoredTransactionGroup $event- */- public function recalculateCredit(StoredTransactionGroup $event): void- {- $group = $event->transactionGroup;- /** @var CreditRecalculateService $object */- $object = app(CreditRecalculateService::class);- $object->setGroup($group);- $object->recalculate();- }-}diff --git a/app/Handlers/Events/UpdatedGroupEventHandler.php b/app/Handlers/Events/UpdatedGroupEventHandler.phpindex b5f9237794..3d70db5d11 100644--- a/app/Handlers/Events/UpdatedGroupEventHandler.php+++ b/app/Handlers/Events/UpdatedGroupEventHandler.php@@ -77,6 +77,18 @@ class UpdatedGroupEventHandler$newRuleEngine->fire();}+ /**+ * @param UpdatedTransactionGroup $event+ */+ public function recalculateCredit(UpdatedTransactionGroup $event): void+ {+ $group = $event->transactionGroup;+ /** @var CreditRecalculateService $object */+ $object = app(CreditRecalculateService::class);+ $object->setGroup($group);+ $object->recalculate();+ }+/*** @param UpdatedTransactionGroup $updatedGroupEvent*/@@ -100,18 +112,6 @@ class UpdatedGroupEventHandlerevent(new RequestedSendWebhookMessages);}- /**- * @param UpdatedTransactionGroup $event- */- public function recalculateCredit(UpdatedTransactionGroup $event): void- {- $group = $event->transactionGroup;- /** @var CreditRecalculateService $object */- $object = app(CreditRecalculateService::class);- $object->setGroup($group);- $object->recalculate();- }-/*** This method will make sure all source / destination accounts are the same.*diff --git a/app/Handlers/Events/UserEventHandler.php b/app/Handlers/Events/UserEventHandler.phpindex cdd587ddd9..279dc95fb3 100644--- a/app/Handlers/Events/UserEventHandler.php+++ b/app/Handlers/Events/UserEventHandler.php@@ -108,6 +108,34 @@ class UserEventHandlerreturn true;}+ /**+ * @param RegisteredUser $event+ *+ * @return bool+ * @throws FireflyException+ */+ public function createGroupMembership(RegisteredUser $event): bool+ {+ $user = $event->user;+ // create a new group.+ $group = UserGroup::create(['title' => $user->email]);+ $role = UserRole::where('title', UserRole::OWNER)->first();+ if (null === $role) {+ throw new FireflyException('The user role is unexpectedly empty. Did you run all migrations?');+ }+ GroupMembership::create(+ [+ 'user_id' => $user->id,+ 'user_group_id' => $group->id,+ 'user_role_id' => $role->id,+ ]+ );+ $user->user_group_id = $group->id;+ $user->save();++ return true;+ }+/*** Set the demo user back to English.*@@ -251,34 +279,6 @@ class UserEventHandlerreturn true;}- /**- * @param RegisteredUser $event- *- * @return bool- * @throws FireflyException- */- public function createGroupMembership(RegisteredUser $event): bool- {- $user = $event->user;- // create a new group.- $group = UserGroup::create(['title' => $user->email]);- $role = UserRole::where('title', UserRole::OWNER)->first();- if (null === $role) {- throw new FireflyException('The user role is unexpectedly empty. Did you run all migrations?');- }- GroupMembership::create(- [- 'user_id' => $user->id,- 'user_group_id' => $group->id,- 'user_role_id' => $role->id,- ]- );- $user->user_group_id = $group->id;- $user->save();-- return true;- }-/*** This method will send the user a registration mail, welcoming him or her to Firefly III.* This message is only sent when the configuration of Firefly III says so.diff --git a/app/Handlers/Events/VersionCheckEventHandler.php b/app/Handlers/Events/VersionCheckEventHandler.phpindex 40307cf453..f3295ae8bd 100644--- a/app/Handlers/Events/VersionCheckEventHandler.php+++ b/app/Handlers/Events/VersionCheckEventHandler.php@@ -61,7 +61,7 @@ class VersionCheckEventHandler/** @var UserRepositoryInterface $repository */$repository = app(UserRepositoryInterface::class);- $user = $event->user;+ $user = $event->user;if (!$repository->hasRole($user, 'owner')) {Log::debug('User is not admin, done.');@@ -88,13 +88,14 @@ class VersionCheckEventHandler/*** @param RequestedVersionCheckStatus $event+ ** @throws FireflyException*/protected function warnToCheckForUpdates(RequestedVersionCheckStatus $event): void{/** @var UserRepositoryInterface $repository */$repository = app(UserRepositoryInterface::class);- $user = $event->user;+ $user = $event->user;if (!$repository->hasRole($user, 'owner')) {Log::debug('User is not admin, done.');diff --git a/app/Helpers/Collector/Extensions/AccountCollection.php b/app/Helpers/Collector/Extensions/AccountCollection.phpindex 41f3aa35b7..762c47c7a4 100644--- a/app/Helpers/Collector/Extensions/AccountCollection.php+++ b/app/Helpers/Collector/Extensions/AccountCollection.php@@ -216,9 +216,9 @@ trait AccountCollection$this->query->leftJoin('account_types as dest_account_type', 'dest_account_type.id', '=', 'dest_account.account_type_id');// and add fields:- $this->fields[] = 'dest_account.name as destination_account_name';- $this->fields[] = 'dest_account.iban as destination_account_iban';- $this->fields[] = 'dest_account_type.type as destination_account_type';+ $this->fields[] = 'dest_account.name as destination_account_name';+ $this->fields[] = 'dest_account.iban as destination_account_iban';+ $this->fields[] = 'dest_account_type.type as destination_account_type';$this->hasAccountInfo = true;}diff --git a/app/Helpers/Collector/GroupCollector.php b/app/Helpers/Collector/GroupCollector.phpindex 3e117082ff..4fbf2e1bb2 100644--- a/app/Helpers/Collector/GroupCollector.php+++ b/app/Helpers/Collector/GroupCollector.php@@ -198,6 +198,16 @@ class GroupCollector implements GroupCollectorInterfacereturn $this;}+ /**+ * @inheritDoc+ */+ public function findNothing(): GroupCollectorInterface+ {+ $this->query->where('transaction_groups.id', -1);++ return $this;+ }+/*** Return the transaction journals without group information. Is useful in some instances.*@@ -767,14 +777,4 @@ class GroupCollector implements GroupCollectorInterfacereturn $groups;}-- /**- * @inheritDoc- */- public function findNothing(): GroupCollectorInterface- {- $this->query->where('transaction_groups.id', -1);-- return $this;- }}diff --git a/app/Helpers/Collector/GroupCollectorInterface.php b/app/Helpers/Collector/GroupCollectorInterface.phpindex 733725be92..3e58f2fa1c 100644--- a/app/Helpers/Collector/GroupCollectorInterface.php+++ b/app/Helpers/Collector/GroupCollectorInterface.php@@ -57,13 +57,6 @@ interface GroupCollectorInterface*/public function amountLess(string $amount): GroupCollectorInterface;- /**- * Ensure the search will find nothing at all, zero results.- *- * @return GroupCollectorInterface- */- public function findNothing(): GroupCollectorInterface;-/*** Get transactions where the amount is more than.*@@ -118,6 +111,13 @@ interface GroupCollectorInterface*/public function excludeSourceAccounts(Collection $accounts): GroupCollectorInterface;+ /**+ * Ensure the search will find nothing at all, zero results.+ *+ * @return GroupCollectorInterface+ */+ public function findNothing(): GroupCollectorInterface;+/*** Return the transaction journals without group information. Is useful in some instances.*@@ -478,6 +478,13 @@ interface GroupCollectorInterface*/public function withAttachmentInformation(): GroupCollectorInterface;+ /**+ * Limit results to transactions without a bill..+ *+ * @return GroupCollectorInterface+ */+ public function withBill(): GroupCollectorInterface;+/*** Include bill name + ID.*@@ -527,13 +534,6 @@ interface GroupCollectorInterface*/public function withTagInformation(): GroupCollectorInterface;- /**- * Limit results to transactions without a bill..- *- * @return GroupCollectorInterface- */- public function withBill(): GroupCollectorInterface;-/*** Limit results to a transactions without a bill.*diff --git a/app/Helpers/Fiscal/FiscalHelper.php b/app/Helpers/Fiscal/FiscalHelper.phpindex ea52ce1074..1298557deb 100644--- a/app/Helpers/Fiscal/FiscalHelper.php+++ b/app/Helpers/Fiscal/FiscalHelper.php@@ -23,6 +23,7 @@ declare(strict_types=1);namespace FireflyIII\Helpers\Fiscal;use Carbon\Carbon;+use FireflyIII\Exceptions\FireflyException;use Log;/**@@ -67,7 +68,7 @@ class FiscalHelper implements FiscalHelperInterface* @param Carbon $date** @return Carbon date object- * @throws \FireflyIII\Exceptions\FireflyException+ * @throws FireflyException*/public function startOfFiscalYear(Carbon $date): Carbon{diff --git a/app/Helpers/Help/Help.php b/app/Helpers/Help/Help.phpindex 30f21d68a1..b5b52a7e06 100644--- a/app/Helpers/Help/Help.php+++ b/app/Helpers/Help/Help.php@@ -96,7 +96,7 @@ class Help implements HelpInterfaceif ('' !== $content) {Log::debug('Content is longer than zero. Expect something.');$converter = new CommonMarkConverter();- $content = (string) $converter->convertToHtml($content);+ $content = (string)$converter->convertToHtml($content);}return $content;diff --git a/app/Helpers/Report/NetWorth.php b/app/Helpers/Report/NetWorth.phpindex 0fda556332..da485d5ca8 100644--- a/app/Helpers/Report/NetWorth.php+++ b/app/Helpers/Report/NetWorth.php@@ -30,6 +30,7 @@ use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;use FireflyIII\Support\CacheProperties;use FireflyIII\User;use Illuminate\Support\Collection;+use JsonException;use Log;/**@@ -62,7 +63,7 @@ class NetWorth implements NetWorthInterface* @param Carbon $date** @return array- * @throws \JsonException+ * @throws JsonException*/public function getNetWorthByCurrency(Collection $accounts, Carbon $date): array{@@ -73,7 +74,7 @@ class NetWorth implements NetWorthInterface$cache->addProperty('net-worth-by-currency');$cache->addProperty(implode(',', $accounts->pluck('id')->toArray()));if ($cache->has()) {- return $cache->get();+ return $cache->get();}$netWorth = [];diff --git a/app/Http/Controllers/Account/CreateController.php b/app/Http/Controllers/Account/CreateController.phpindex 1a5a3c5f96..00c4c55376 100644--- a/app/Http/Controllers/Account/CreateController.php+++ b/app/Http/Controllers/Account/CreateController.php@@ -23,6 +23,7 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers\Account;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Http\Requests\AccountFormRequest;@@ -135,7 +136,7 @@ class CreateController extends Controller* @param AccountFormRequest $request** @return RedirectResponse|Redirector- * @throws \FireflyIII\Exceptions\FireflyException+ * @throws FireflyException*/public function store(AccountFormRequest $request){diff --git a/app/Http/Controllers/Account/DeleteController.php b/app/Http/Controllers/Account/DeleteController.phpindex 4c6a1102ae..41732a441e 100644--- a/app/Http/Controllers/Account/DeleteController.php+++ b/app/Http/Controllers/Account/DeleteController.php@@ -72,7 +72,7 @@ class DeleteController extends Controllerpublic function delete(Account $account){if (!$this->isEditableAccount($account)) {- return $this->redirectAccountToAccount($account);+ return $this->redirectAccountToAccount($account);}$typeName = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type));@@ -98,7 +98,7 @@ class DeleteController extends Controllerpublic function destroy(Request $request, Account $account){if (!$this->isEditableAccount($account)) {- return $this->redirectAccountToAccount($account);+ return $this->redirectAccountToAccount($account);}$type = $account->accountType->type;diff --git a/app/Http/Controllers/Account/EditController.php b/app/Http/Controllers/Account/EditController.phpindex 78acef21d2..ccb34ce85a 100644--- a/app/Http/Controllers/Account/EditController.php+++ b/app/Http/Controllers/Account/EditController.php@@ -44,9 +44,9 @@ class EditController extends Controller{use ModelInformation;- private AttachmentHelperInterface $attachments;+ private AttachmentHelperInterface $attachments;private CurrencyRepositoryInterface $currencyRepos;- private AccountRepositoryInterface $repository;+ private AccountRepositoryInterface $repository;/*** EditController constructor.@@ -82,7 +82,7 @@ class EditController extends Controllerpublic function edit(Request $request, Account $account, AccountRepositoryInterface $repository){if (!$this->isEditableAccount($account)) {- return $this->redirectAccountToAccount($account);+ return $this->redirectAccountToAccount($account);}$objectType = config('firefly.shortNamesByFullName')[$account->accountType->type];@@ -123,11 +123,11 @@ class EditController extends Controller$request->session()->forget('accounts.edit.fromUpdate');$openingBalanceAmount = app('steam')->positive((string)$repository->getOpeningBalanceAmount($account));- if('0' === $openingBalanceAmount) {+ if ('0' === $openingBalanceAmount) {$openingBalanceAmount = '';}- $openingBalanceDate = $repository->getOpeningBalanceDate($account);- $currency = $this->repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency();+ $openingBalanceDate = $repository->getOpeningBalanceDate($account);+ $currency = $this->repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency();// include this account in net-worth charts?$includeNetWorth = $repository->getMetaValue($account, 'include_net_worth');@@ -144,7 +144,7 @@ class EditController extends Controller'opening_balance_date' => $openingBalanceDate,'liability_type_id' => $account->account_type_id,'opening_balance' => $openingBalanceAmount,- 'liability_direction' => $this->repository->getMetaValue($account, 'liability_direction'),+ 'liability_direction' => $this->repository->getMetaValue($account, 'liability_direction'),'virtual_balance' => $account->virtual_balance,'currency_id' => $currency->id,'include_net_worth' => $includeNetWorth,@@ -185,7 +185,7 @@ class EditController extends Controllerpublic function update(AccountFormRequest $request, Account $account){if (!$this->isEditableAccount($account)) {- return $this->redirectAccountToAccount($account);+ return $this->redirectAccountToAccount($account);}$data = $request->getAccountData();@@ -204,7 +204,7 @@ class EditController extends Controller}if (count($this->attachments->getMessages()->get('attachments')) > 0) {- $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));+ $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));}// redirectdiff --git a/app/Http/Controllers/Account/IndexController.php b/app/Http/Controllers/Account/IndexController.phpindex 11566bfe0f..36dc51a8c2 100644--- a/app/Http/Controllers/Account/IndexController.php+++ b/app/Http/Controllers/Account/IndexController.php@@ -25,6 +25,7 @@ namespace FireflyIII\Http\Controllers\Account;use Carbon\Carbon;use Exception;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Models\Account;use FireflyIII\Repositories\Account\AccountRepositoryInterface;@@ -72,7 +73,7 @@ class IndexController extends Controller* @param string $objectType** @return Factory|View- * @throws \FireflyIII\Exceptions\FireflyException+ * @throws FireflyException*/public function inactive(Request $request, string $objectType){@@ -160,13 +161,15 @@ class IndexController extends Controller$accounts->each(function (Account $account) use ($activities, $startBalances, $endBalances) {-// See reference nr. 68+ // See reference nr. 68$account->lastActivityDate = $this->isInArray($activities, $account->id);$account->startBalance = $this->isInArray($startBalances, $account->id);$account->endBalance = $this->isInArray($endBalances, $account->id);$account->difference = bcsub($account->endBalance, $account->startBalance);$account->interest = number_format((float)$this->repository->getMetaValue($account, 'interest'), 4, '.', '');- $account->interestPeriod = (string)trans(sprintf('firefly.interest_calc_%s', $this->repository->getMetaValue($account, 'interest_period')));+ $account->interestPeriod = (string)trans(+ sprintf('firefly.interest_calc_%s', $this->repository->getMetaValue($account, 'interest_period'))+ );$account->accountTypeString = (string)trans(sprintf('firefly.account_type_%s', $account->accountType->type));$account->location = $this->repository->getLocation($account);$account->liability_direction = $this->repository->getMetaValue($account, 'liability_direction');diff --git a/app/Http/Controllers/Account/ReconcileController.php b/app/Http/Controllers/Account/ReconcileController.phpindex 2c1772adc0..e3ae62ec91 100644--- a/app/Http/Controllers/Account/ReconcileController.php+++ b/app/Http/Controllers/Account/ReconcileController.php@@ -91,7 +91,7 @@ class ReconcileController extends Controllerpublic function reconcile(Account $account, Carbon $start = null, Carbon $end = null){if (!$this->isEditableAccount($account)) {- return $this->redirectAccountToAccount($account);+ return $this->redirectAccountToAccount($account);}if (AccountType::ASSET !== $account->accountType->type) {@@ -169,7 +169,7 @@ class ReconcileController extends Controllerpublic function submit(ReconciliationStoreRequest $request, Account $account, Carbon $start, Carbon $end){if (!$this->isEditableAccount($account)) {- return $this->redirectAccountToAccount($account);+ return $this->redirectAccountToAccount($account);}Log::debug('In ReconcileController::submit()');@@ -218,7 +218,7 @@ class ReconcileController extends Controllerprivate function createReconciliation(Account $account, Carbon $start, Carbon $end, string $difference){if (!$this->isEditableAccount($account)) {- return $this->redirectAccountToAccount($account);+ return $this->redirectAccountToAccount($account);}$reconciliation = $this->accountRepos->getReconciliation($account);diff --git a/app/Http/Controllers/Account/ShowController.php b/app/Http/Controllers/Account/ShowController.phpindex 4b7274227e..52f36a8d32 100644--- a/app/Http/Controllers/Account/ShowController.php+++ b/app/Http/Controllers/Account/ShowController.php@@ -91,7 +91,7 @@ class ShowController extends Controller$objectType = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type));if (!$this->isEditableAccount($account)) {- return $this->redirectAccountToAccount($account);+ return $this->redirectAccountToAccount($account);}/** @var Carbon $start */@@ -100,7 +100,7 @@ class ShowController extends Controller$end = $end ?? session('end');if ($end < $start) {- [$start, $end] = [$end, $start];+ [$start, $end] = [$end, $start];}$location = $this->repository->getLocation($account);$attachments = $this->repository->getAttachments($account);@@ -164,7 +164,7 @@ class ShowController extends Controllerpublic function showAll(Request $request, Account $account){if (!$this->isEditableAccount($account)) {- return $this->redirectAccountToAccount($account);+ return $this->redirectAccountToAccount($account);}$location = $this->repository->getLocation($account);$isLiability = $this->repository->isLiability($account);diff --git a/app/Http/Controllers/Admin/ConfigurationController.php b/app/Http/Controllers/Admin/ConfigurationController.phpindex f4dac83d88..036c75fef1 100644--- a/app/Http/Controllers/Admin/ConfigurationController.php+++ b/app/Http/Controllers/Admin/ConfigurationController.php@@ -64,7 +64,7 @@ class ConfigurationController extends Controller*/public function index(){- $subTitle = (string)trans('firefly.instance_configuration');+ $subTitle = (string)trans('firefly.instance_configuration');$subTitleIcon = 'fa-wrench';Log::channel('audit')->info('User visits admin config index.');diff --git a/app/Http/Controllers/Admin/HomeController.php b/app/Http/Controllers/Admin/HomeController.phpindex 718d112b1f..8a86f678d6 100644--- a/app/Http/Controllers/Admin/HomeController.php+++ b/app/Http/Controllers/Admin/HomeController.php@@ -23,6 +23,7 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers\Admin;use FireflyIII\Events\AdminRequestedTestMessage;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Http\Middleware\IsDemoUser;use FireflyIII\User;@@ -53,7 +54,7 @@ class HomeController extends Controller* Index of the admin.** @return Factory|View- * @throws \FireflyIII\Exceptions\FireflyException+ * @throws FireflyException*/public function index(){diff --git a/app/Http/Controllers/Admin/LinkController.php b/app/Http/Controllers/Admin/LinkController.phpindex fac92e9185..d4ff3b1a77 100644--- a/app/Http/Controllers/Admin/LinkController.php+++ b/app/Http/Controllers/Admin/LinkController.php@@ -161,7 +161,7 @@ class LinkController extends Controller// put previous url in session if not redirect from store (not "return_to_edit").if (true !== session('link-types.edit.fromUpdate')) {- $this->rememberPreviousUri('link-types.edit.uri');+ $this->rememberPreviousUri('link-types.edit.uri');}$request->session()->forget('link-types.edit.fromUpdate');diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.phpindex 92fcc56271..1ebe5e0100 100644--- a/app/Http/Controllers/Auth/LoginController.php+++ b/app/Http/Controllers/Auth/LoginController.php@@ -28,15 +28,17 @@ use DB;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Providers\RouteServiceProvider;+use Illuminate\Contracts\Foundation\Application;use Illuminate\Contracts\View\Factory;+use Illuminate\Contracts\View\View;use Illuminate\Foundation\Auth\AuthenticatesUsers;use Illuminate\Foundation\Auth\ThrottlesLogins;use Illuminate\Http\JsonResponse;use Illuminate\Http\RedirectResponse;use Illuminate\Http\Request;use Illuminate\Http\Response;+use Illuminate\Routing\Redirector;use Illuminate\Validation\ValidationException;-use Illuminate\View\View;use Log;/**@@ -194,7 +196,7 @@ class LoginController extends Controller** @param Request $request*- * @return Factory|\Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\View|\Illuminate\Routing\Redirector|RedirectResponse+ * @return Factory|Application|View|Redirector|RedirectResponse* @throws FireflyException*/public function showLoginForm(Request $request)diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.phpindex c5b3ce425d..1c882813fb 100644--- a/app/Http/Controllers/Auth/RegisterController.php+++ b/app/Http/Controllers/Auth/RegisterController.php@@ -27,6 +27,7 @@ use FireflyIII\Exceptions\FireflyException;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Support\Http\Controllers\CreateStuff;use FireflyIII\User;+use Illuminate\Contracts\Foundation\Application;use Illuminate\Contracts\View\Factory;use Illuminate\Foundation\Auth\RegistersUsers;use Illuminate\Http\RedirectResponse;@@ -78,7 +79,7 @@ class RegisterController extends Controller** @param Request $request*- * @return \Illuminate\Contracts\Foundation\Application|Redirector|RedirectResponse+ * @return Application|Redirector|RedirectResponse* @throws FireflyException* @throws ValidationException*/diff --git a/app/Http/Controllers/Bill/CreateController.php b/app/Http/Controllers/Bill/CreateController.phpindex 8015319b45..67c92d32ba 100644--- a/app/Http/Controllers/Bill/CreateController.php+++ b/app/Http/Controllers/Bill/CreateController.php@@ -30,6 +30,7 @@ use FireflyIII\Http\Controllers\Controller;use FireflyIII\Http\Requests\BillStoreRequest;use FireflyIII\Repositories\Bill\BillRepositoryInterface;use Illuminate\Contracts\View\Factory;+use Illuminate\Contracts\View\View;use Illuminate\Http\RedirectResponse;use Illuminate\Http\Request;use Log;@@ -68,7 +69,7 @@ class CreateController extends Controller** @param Request $request*- * @return Factory|\Illuminate\Contracts\View\View+ * @return Factory|View*/public function create(Request $request){@@ -123,7 +124,7 @@ class CreateController extends Controller}if (count($this->attachments->getMessages()->get('attachments')) > 0) {- $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));+ $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));}return redirect(route('rules.create-from-bill', [$bill->id]));diff --git a/app/Http/Controllers/Bill/EditController.php b/app/Http/Controllers/Bill/EditController.phpindex 7959115862..6c1d0916d8 100644--- a/app/Http/Controllers/Bill/EditController.php+++ b/app/Http/Controllers/Bill/EditController.php@@ -30,6 +30,7 @@ use FireflyIII\Http\Requests\BillUpdateRequest;use FireflyIII\Models\Bill;use FireflyIII\Repositories\Bill\BillRepositoryInterface;use Illuminate\Contracts\View\Factory;+use Illuminate\Contracts\View\View;use Illuminate\Http\RedirectResponse;use Illuminate\Http\Request;@@ -68,7 +69,7 @@ class EditController extends Controller* @param Request $request* @param Bill $bill*- * @return Factory|\Illuminate\Contracts\View\View+ * @return Factory|View*/public function edit(Request $request, Bill $bill){@@ -136,7 +137,7 @@ class EditController extends Controller// flash messagesif (count($this->attachments->getMessages()->get('attachments')) > 0) {- $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));+ $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));}$redirect = redirect($this->getPreviousUri('bills.edit.uri'));diff --git a/app/Http/Controllers/Bill/IndexController.php b/app/Http/Controllers/Bill/IndexController.phpindex f87f80baca..88e01a8ad8 100644--- a/app/Http/Controllers/Bill/IndexController.php+++ b/app/Http/Controllers/Bill/IndexController.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers\Bill;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Models\Bill;use FireflyIII\Repositories\Bill\BillRepositoryInterface;@@ -105,18 +106,18 @@ class IndexController extends Controller'object_group_title' => $array['object_group_title'],'bills' => [],];-// var_dump($array);exit;-// // expected today? default:-// $array['next_expected_match_diff'] = trans('firefly.not_expected_period');-// $nextExpectedMatch = new Carbon($array['next_expected_match']);-// if ($nextExpectedMatch->isToday()) {-// $array['next_expected_match_diff'] = trans('firefly.today');-// }-// $current = $array['pay_dates'][0] ?? null;-// if (null !== $current && !$nextExpectedMatch->isToday()) {-// $currentExpectedMatch = Carbon::createFromFormat('Y-m-d\TH:i:sP', $current);-// $array['next_expected_match_diff'] = $currentExpectedMatch->diffForHumans(today(), Carbon::DIFF_RELATIVE_TO_NOW);-// }+ // var_dump($array);exit;+ // // expected today? default:+ // $array['next_expected_match_diff'] = trans('firefly.not_expected_period');+ // $nextExpectedMatch = new Carbon($array['next_expected_match']);+ // if ($nextExpectedMatch->isToday()) {+ // $array['next_expected_match_diff'] = trans('firefly.today');+ // }+ // $current = $array['pay_dates'][0] ?? null;+ // if (null !== $current && !$nextExpectedMatch->isToday()) {+ // $currentExpectedMatch = Carbon::createFromFormat('Y-m-d\TH:i:sP', $current);+ // $array['next_expected_match_diff'] = $currentExpectedMatch->diffForHumans(today(), Carbon::DIFF_RELATIVE_TO_NOW);+ // }$currency = $bill->transactionCurrency ?? $defaultCurrency;$array['currency_id'] = $currency->id;@@ -143,7 +144,7 @@ class IndexController extends Controller* @param array $bills** @return array- * @throws \FireflyIII\Exceptions\FireflyException+ * @throws FireflyException*/private function getSums(array $bills): array{diff --git a/app/Http/Controllers/Budget/CreateController.php b/app/Http/Controllers/Budget/CreateController.phpindex 557f5ce739..39added774 100644--- a/app/Http/Controllers/Budget/CreateController.php+++ b/app/Http/Controllers/Budget/CreateController.php@@ -133,7 +133,7 @@ class CreateController extends Controller}if (count($this->attachments->getMessages()->get('attachments')) > 0) {- $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));+ $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));}$redirect = redirect($this->getPreviousUri('budgets.create.uri'));diff --git a/app/Http/Controllers/Budget/EditController.php b/app/Http/Controllers/Budget/EditController.phpindex 8422595a05..7f77a47c30 100644--- a/app/Http/Controllers/Budget/EditController.php+++ b/app/Http/Controllers/Budget/EditController.php@@ -144,7 +144,7 @@ class EditController extends Controller}if (count($this->attachments->getMessages()->get('attachments')) > 0) {- $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));+ $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));}if (1 === (int)$request->get('return_to_edit')) {diff --git a/app/Http/Controllers/Budget/IndexController.php b/app/Http/Controllers/Budget/IndexController.phpindex 9f1caa1de7..99472da46a 100644--- a/app/Http/Controllers/Budget/IndexController.php+++ b/app/Http/Controllers/Budget/IndexController.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers\Budget;use Carbon\Carbon;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Models\AvailableBudget;use FireflyIII\Models\Budget;@@ -90,7 +91,7 @@ class IndexController extends Controller* @param Carbon|null $end** @return Factory|View- * @throws \FireflyIII\Exceptions\FireflyException+ * @throws FireflyException*/public function index(Request $request, Carbon $start = null, Carbon $end = null){diff --git a/app/Http/Controllers/Budget/ShowController.php b/app/Http/Controllers/Budget/ShowController.phpindex 6716256a10..87be007853 100644--- a/app/Http/Controllers/Budget/ShowController.php+++ b/app/Http/Controllers/Budget/ShowController.php@@ -47,7 +47,7 @@ class ShowController extends Controlleruse PeriodOverview, AugumentData;protected JournalRepositoryInterface $journalRepos;- private BudgetRepositoryInterface $repository;+ private BudgetRepositoryInterface $repository;/*** ShowController constructor.@@ -183,7 +183,7 @@ class ShowController extends Controllerpublic function showByBudgetLimit(Request $request, Budget $budget, BudgetLimit $budgetLimit){if ($budgetLimit->budget->id !== $budget->id) {- throw new FireflyException('This budget limit is not part of this budget.');+ throw new FireflyException('This budget limit is not part of this budget.');}$page = (int)$request->get('page');diff --git a/app/Http/Controllers/Category/CreateController.php b/app/Http/Controllers/Category/CreateController.phpindex 678509283c..df8f8a9959 100644--- a/app/Http/Controllers/Category/CreateController.php+++ b/app/Http/Controllers/Category/CreateController.php@@ -107,7 +107,7 @@ class CreateController extends Controller}if (count($this->attachments->getMessages()->get('attachments')) > 0) {- $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));+ $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));}$redirect = redirect(route('categories.index'));diff --git a/app/Http/Controllers/Category/DeleteController.php b/app/Http/Controllers/Category/DeleteController.phpindex 191b5acdf2..34a4595768 100644--- a/app/Http/Controllers/Category/DeleteController.php+++ b/app/Http/Controllers/Category/DeleteController.php@@ -80,7 +80,7 @@ class DeleteController extends Controller/*** Destroy a category.*- * @param Request $request+ * @param Request $request* @param Category $category** @return RedirectResponse|Redirectordiff --git a/app/Http/Controllers/Category/EditController.php b/app/Http/Controllers/Category/EditController.phpindex 02355d2cc6..8b7db90962 100644--- a/app/Http/Controllers/Category/EditController.php+++ b/app/Http/Controllers/Category/EditController.php@@ -115,7 +115,7 @@ class EditController extends Controller}if (count($this->attachments->getMessages()->get('attachments')) > 0) {- $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));+ $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));}$redirect = redirect($this->getPreviousUri('categories.edit.uri'));diff --git a/app/Http/Controllers/Category/IndexController.php b/app/Http/Controllers/Category/IndexController.phpindex fb93dd652d..2a3dc289b3 100644--- a/app/Http/Controllers/Category/IndexController.php+++ b/app/Http/Controllers/Category/IndexController.php@@ -23,6 +23,7 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers\Category;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Models\Category;use FireflyIII\Repositories\Category\CategoryRepositoryInterface;@@ -66,7 +67,7 @@ class IndexController extends Controller* @param Request $request** @return Factory|View- * @throws \FireflyIII\Exceptions\FireflyException+ * @throws FireflyException*/public function index(Request $request){diff --git a/app/Http/Controllers/Category/NoCategoryController.php b/app/Http/Controllers/Category/NoCategoryController.phpindex 4ec98fbe81..3214089c83 100644--- a/app/Http/Controllers/Category/NoCategoryController.php+++ b/app/Http/Controllers/Category/NoCategoryController.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers\Category;use Carbon\Carbon;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Helpers\Collector\GroupCollectorInterface;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Models\TransactionType;@@ -74,7 +75,7 @@ class NoCategoryController extends Controller* @param Carbon|null $end** @return Factory|View- * @throws \FireflyIII\Exceptions\FireflyException+ * @throws FireflyException*/public function show(Request $request, Carbon $start = null, Carbon $end = null){@@ -112,7 +113,7 @@ class NoCategoryController extends Controller* @param Request $request** @return Factory|View- * @throws \FireflyIII\Exceptions\FireflyException+ * @throws FireflyException*/public function showAll(Request $request){diff --git a/app/Http/Controllers/Category/ShowController.php b/app/Http/Controllers/Category/ShowController.phpindex 5a530d19cc..59bb1483e1 100644--- a/app/Http/Controllers/Category/ShowController.php+++ b/app/Http/Controllers/Category/ShowController.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers\Category;use Carbon\Carbon;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Helpers\Collector\GroupCollectorInterface;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Models\Category;@@ -76,7 +77,7 @@ class ShowController extends Controller* @param Carbon|null $end** @return Factory|View- * @throws \FireflyIII\Exceptions\FireflyException+ * @throws FireflyException*/public function show(Request $request, Category $category, Carbon $start = null, Carbon $end = null){@@ -116,7 +117,7 @@ class ShowController extends Controller* @param Category $category** @return Factory|View- * @throws \FireflyIII\Exceptions\FireflyException+ * @throws FireflyException*/public function showAll(Request $request, Category $category){diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.phpindex 68f98a29aa..b8b03d2a7c 100644--- a/app/Http/Controllers/Chart/AccountController.php+++ b/app/Http/Controllers/Chart/AccountController.php@@ -23,6 +23,7 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers\Chart;use Carbon\Carbon;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Generator\Chart\Basic\GeneratorInterface;use FireflyIII\Helpers\Collector\GroupCollectorInterface;use FireflyIII\Http\Controllers\Controller;@@ -38,6 +39,7 @@ use FireflyIII\Support\Http\Controllers\ChartGeneration;use FireflyIII\Support\Http\Controllers\DateCalculation;use Illuminate\Http\JsonResponse;use Illuminate\Support\Collection;+use JsonException;use Log;/**@@ -83,7 +85,7 @@ class AccountController extends Controller* This chart is (multi) currency aware.** @return JsonResponse- * @throws \JsonException+ * @throws JsonException*/public function expenseAccounts(): JsonResponse{@@ -96,7 +98,7 @@ class AccountController extends Controller$cache->addProperty($end);$cache->addProperty('chart.account.expense-accounts');if ($cache->has()) {- return response()->json($cache->get());+ return response()->json($cache->get());}$start->subDay();@@ -195,7 +197,7 @@ class AccountController extends Controller* @param Carbon $end** @return JsonResponse- * @throws \JsonException+ * @throws JsonException*/public function expenseBudget(Account $account, Carbon $start, Carbon $end): JsonResponse{@@ -205,7 +207,7 @@ class AccountController extends Controller$cache->addProperty($end);$cache->addProperty('chart.account.expense-budget');if ($cache->has()) {- return response()->json($cache->get());+ return response()->json($cache->get());}/** @var GroupCollectorInterface $collector */$collector = app(GroupCollectorInterface::class);@@ -270,7 +272,7 @@ class AccountController extends Controller* @param Carbon $end** @return JsonResponse- * @throws \JsonException+ * @throws JsonException*/public function expenseCategory(Account $account, Carbon $start, Carbon $end): JsonResponse{@@ -280,7 +282,7 @@ class AccountController extends Controller$cache->addProperty($end);$cache->addProperty('chart.account.expense-category');if ($cache->has()) {- return response()->json($cache->get());+ return response()->json($cache->get());}/** @var GroupCollectorInterface $collector */@@ -325,7 +327,7 @@ class AccountController extends Controller* @param AccountRepositoryInterface $repository** @return JsonResponse- * @throws \FireflyIII\Exceptions\FireflyException+ * @throws FireflyException*/public function frontpage(AccountRepositoryInterface $repository): JsonResponse{@@ -368,7 +370,7 @@ class AccountController extends Controller* @param Carbon $end** @return JsonResponse- * @throws \JsonException+ * @throws JsonException*/public function incomeCategory(Account $account, Carbon $start, Carbon $end): JsonResponse{@@ -378,7 +380,7 @@ class AccountController extends Controller$cache->addProperty($end);$cache->addProperty('chart.account.income-category');if ($cache->has()) {- return response()->json($cache->get());+ return response()->json($cache->get());}// grab all journals:@@ -426,8 +428,8 @@ class AccountController extends Controller* @param Carbon $end** @return JsonResponse- * @throws \FireflyIII\Exceptions\FireflyException- * @throws \JsonException+ * @throws FireflyException+ * @throws JsonException*/public function period(Account $account, Carbon $start, Carbon $end): JsonResponse{@@ -438,7 +440,7 @@ class AccountController extends Controller$cache->addProperty($end);$cache->addProperty($account->id);if ($cache->has()) {- return response()->json($cache->get());+ return response()->json($cache->get());}$currencies = $this->accountRepository->getUsedCurrencies($account);@@ -465,8 +467,8 @@ class AccountController extends Controller* @param TransactionCurrency $currency** @return array- * @throws \FireflyIII\Exceptions\FireflyException- * @throws \JsonException+ * @throws FireflyException+ * @throws JsonException*/private function periodByCurrency(Carbon $start, Carbon $end, Account $account, TransactionCurrency $currency): array{@@ -518,7 +520,7 @@ class AccountController extends Controller/*** Shows the balances for a given set of dates and accounts.*-* See reference nr. 55+ * See reference nr. 55** @param Carbon $start* @param Carbon $end@@ -537,7 +539,7 @@ class AccountController extends Controller* This chart is multi-currency aware.** @return JsonResponse- * @throws \JsonException+ * @throws JsonException*/public function revenueAccounts(): JsonResponse{@@ -550,7 +552,7 @@ class AccountController extends Controller$cache->addProperty($end);$cache->addProperty('chart.account.revenue-accounts');if ($cache->has()) {- return response()->json($cache->get());+ return response()->json($cache->get());}$start->subDay();diff --git a/app/Http/Controllers/Chart/BillController.php b/app/Http/Controllers/Chart/BillController.phpindex 8fe9467b4f..b857e1a85b 100644--- a/app/Http/Controllers/Chart/BillController.php+++ b/app/Http/Controllers/Chart/BillController.php@@ -31,6 +31,7 @@ use FireflyIII\Repositories\Bill\BillRepositoryInterface;use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;use FireflyIII\Support\CacheProperties;use Illuminate\Http\JsonResponse;+use JsonException;/*** Class BillController.@@ -57,7 +58,7 @@ class BillController extends Controller* @param BillRepositoryInterface $repository** @return JsonResponse- * @throws \JsonException+ * @throws JsonException*/public function frontpage(BillRepositoryInterface $repository): JsonResponse{@@ -68,7 +69,7 @@ class BillController extends Controller$cache->addProperty($end);$cache->addProperty('chart.bill.frontpage');if ($cache->has()) {- return response()->json($cache->get());+ return response()->json($cache->get());}/** @var CurrencyRepositoryInterface $currencyRepository */$currencyRepository = app(CurrencyRepositoryInterface::class);@@ -103,7 +104,7 @@ class BillController extends Controller* @param Bill $bill** @return JsonResponse- * @throws \JsonException+ * @throws JsonException*/public function single(Bill $bill): JsonResponse{@@ -111,7 +112,7 @@ class BillController extends Controller$cache->addProperty('chart.bill.single');$cache->addProperty($bill->id);if ($cache->has()) {- return response()->json($cache->get());+ return response()->json($cache->get());}$locale = app('steam')->getLocale();diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.phpindex 400e137710..d55ebbbe19 100644--- a/app/Http/Controllers/Chart/BudgetController.php+++ b/app/Http/Controllers/Chart/BudgetController.php@@ -41,6 +41,7 @@ use FireflyIII\Support\Http\Controllers\AugumentData;use FireflyIII\Support\Http\Controllers\DateCalculation;use Illuminate\Http\JsonResponse;use Illuminate\Support\Collection;+use JsonException;/*** Class BudgetController.@@ -84,7 +85,7 @@ class BudgetController extends Controller* @param Budget $budget** @return JsonResponse- * @throws \JsonException+ * @throws JsonException*/public function budget(Budget $budget): JsonResponse{@@ -153,7 +154,7 @@ class BudgetController extends Controller* @return JsonResponse** @throws FireflyException- * @throws \JsonException+ * @throws JsonException*/public function budgetLimit(Budget $budget, BudgetLimit $budgetLimit): JsonResponse{@@ -171,7 +172,7 @@ class BudgetController extends Controller$cache->addProperty($budget->id);if ($cache->has()) {- return response()->json($cache->get());+ return response()->json($cache->get());}$locale = app('steam')->getLocale();$entries = [];@@ -204,7 +205,7 @@ class BudgetController extends Controller* @param BudgetLimit|null $budgetLimit** @return JsonResponse- * @throws \JsonException+ * @throws JsonException*/public function expenseAsset(Budget $budget, ?BudgetLimit $budgetLimit = null): JsonResponse{@@ -227,7 +228,7 @@ class BudgetController extends Controller$cache->addProperty($end);if ($cache->has()) {- return response()->json($cache->get());+ return response()->json($cache->get());}$collector->setRange($start, $end);$collector->setBudget($budget);@@ -273,7 +274,7 @@ class BudgetController extends Controller* @param BudgetLimit|null $budgetLimit** @return JsonResponse- * @throws \JsonException+ * @throws JsonException*/public function expenseCategory(Budget $budget, ?BudgetLimit $budgetLimit = null): JsonResponse{@@ -295,7 +296,7 @@ class BudgetController extends Controller$cache->addProperty($end);if ($cache->has()) {- return response()->json($cache->get());+ return response()->json($cache->get());}$collector->setRange($start, $end);$collector->setBudget($budget)->withCategoryInformation();@@ -338,7 +339,7 @@ class BudgetController extends Controller* @param BudgetLimit|null $budgetLimit** @return JsonResponse- * @throws \JsonException+ * @throws JsonException*/public function expenseExpense(Budget $budget, ?BudgetLimit $budgetLimit = null): JsonResponse{@@ -360,7 +361,7 @@ class BudgetController extends Controller$cache->addProperty($end);if ($cache->has()) {- return response()->json($cache->get());+ return response()->json($cache->get());}$collector->setRange($start, $end);$collector->setTypes([TransactionType::WITHDRAWAL])->setBudget($budget)->withAccountInformation();@@ -402,7 +403,7 @@ class BudgetController extends Controller* Shows a budget list with spent/left/overspent.** @return JsonResponse- * @throws \JsonException+ * @throws JsonException*/public function frontpage(): JsonResponse{@@ -415,7 +416,7 @@ class BudgetController extends Controller$cache->addProperty($end);$cache->addProperty('chart.budget.frontpage');if ($cache->has()) {- return response()->json($cache->get());+ return response()->json($cache->get());}$chartGenerator = app(FrontpageChartGenerator::class);@@ -440,7 +441,7 @@ class BudgetController extends Controller* @param Carbon $end** @return JsonResponse- * @throws \JsonException+ * @throws JsonException*/public function period(Budget $budget, TransactionCurrency $currency, Collection $accounts, Carbon $start, Carbon $end): JsonResponse{@@ -453,7 +454,7 @@ class BudgetController extends Controller$cache->addProperty($currency->id);$cache->addProperty('chart.budget.period');if ($cache->has()) {- return response()->json($cache->get());+ return response()->json($cache->get());}$titleFormat = app('navigation')->preferredCarbonLocalizedFormat($start, $end);$preferredRange = app('navigation')->preferredRangeFormat($start, $end);@@ -516,7 +517,7 @@ class BudgetController extends Controller* @param Carbon $end** @return JsonResponse- * @throws \JsonException+ * @throws JsonException*/public function periodNoBudget(TransactionCurrency $currency, Collection $accounts, Carbon $start, Carbon $end): JsonResponse{@@ -528,7 +529,7 @@ class BudgetController extends Controller$cache->addProperty($currency->id);$cache->addProperty('chart.budget.no-budget');if ($cache->has()) {- return response()->json($cache->get());+ return response()->json($cache->get());}// the expenses:diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.phpindex 7e1cf1239f..09c56ad6e5 100644--- a/app/Http/Controllers/Chart/CategoryController.php+++ b/app/Http/Controllers/Chart/CategoryController.php@@ -24,6 +24,7 @@ namespace FireflyIII\Http\Controllers\Chart;use Carbon\Carbon;use Exception;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Generator\Chart\Basic\GeneratorInterface;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Models\Category;@@ -38,6 +39,7 @@ use FireflyIII\Support\Http\Controllers\ChartGeneration;use FireflyIII\Support\Http\Controllers\DateCalculation;use Illuminate\Http\JsonResponse;use Illuminate\Support\Collection;+use JsonException;/*** Class CategoryController.@@ -68,8 +70,8 @@ class CategoryController extends Controller* @param Category $category** @return JsonResponse- * @throws \FireflyIII\Exceptions\FireflyException- * @throws \JsonException+ * @throws FireflyException+ * @throws JsonException*/public function all(Category $category): JsonResponse{@@ -116,7 +118,7 @@ class CategoryController extends Controller* See reference nr. 60** @return JsonResponse- * @throws \JsonException+ * @throws JsonException*/public function frontPage(): JsonResponse{@@ -149,7 +151,7 @@ class CategoryController extends Controller* @param Carbon $end** @return JsonResponse- * @throws \JsonException+ * @throws JsonException*/public function reportPeriod(Category $category, Collection $accounts, Carbon $start, Carbon $end): JsonResponse{@@ -265,7 +267,7 @@ class CategoryController extends Controller* @param Carbon $end** @return JsonResponse- * @throws \JsonException+ * @throws JsonException*/public function reportPeriodNoCategory(Collection $accounts, Carbon $start, Carbon $end): JsonResponse{@@ -292,8 +294,8 @@ class CategoryController extends Controller* @param Carbon $date** @return JsonResponse- * @throws \FireflyIII\Exceptions\FireflyException- * @throws \JsonException+ * @throws FireflyException+ * @throws JsonException*/public function specificPeriod(Category $category, Carbon $date): JsonResponse{diff --git a/app/Http/Controllers/Chart/CategoryReportController.php b/app/Http/Controllers/Chart/CategoryReportController.phpindex 19a05b6b59..8e5e359859 100644--- a/app/Http/Controllers/Chart/CategoryReportController.php+++ b/app/Http/Controllers/Chart/CategoryReportController.php@@ -318,7 +318,7 @@ class CategoryReportController extends Controller}/**-* See reference nr. 57+ * See reference nr. 57** @param Carbon $start* @param Carbon $enddiff --git a/app/Http/Controllers/Chart/DoubleReportController.php b/app/Http/Controllers/Chart/DoubleReportController.phpindex fd7a49dbe0..13a86622d6 100644--- a/app/Http/Controllers/Chart/DoubleReportController.php+++ b/app/Http/Controllers/Chart/DoubleReportController.php@@ -249,7 +249,7 @@ class DoubleReportController extends Controller}/**-* See reference nr. 51+ * See reference nr. 51** @param Collection $accounts* @param int $id@@ -274,7 +274,7 @@ class DoubleReportController extends Controller}/**-* See reference nr. 52+ * See reference nr. 52** @param Carbon $start* @param Carbon $enddiff --git a/app/Http/Controllers/Chart/ExpenseReportController.php b/app/Http/Controllers/Chart/ExpenseReportController.phpindex dd1541143a..697cfb6ee4 100644--- a/app/Http/Controllers/Chart/ExpenseReportController.php+++ b/app/Http/Controllers/Chart/ExpenseReportController.php@@ -33,6 +33,7 @@ use FireflyIII\Support\Http\Controllers\AugumentData;use FireflyIII\Support\Http\Controllers\TransactionCalculation;use Illuminate\Http\JsonResponse;use Illuminate\Support\Collection;+use JsonException;/*** Separate controller because many helper functions are shared.@@ -77,7 +78,7 @@ class ExpenseReportController extends Controller* @param Carbon $end** @return JsonResponse- * @throws \JsonException+ * @throws JsonException*/public function mainChart(Collection $accounts, Collection $expense, Carbon $start, Carbon $end): JsonResponse{@@ -88,7 +89,7 @@ class ExpenseReportController extends Controller$cache->addProperty($start);$cache->addProperty($end);if ($cache->has()) {- return response()->json($cache->get());+ return response()->json($cache->get());}$format = app('navigation')->preferredCarbonLocalizedFormat($start, $end);@@ -188,7 +189,7 @@ class ExpenseReportController extends Controller}}if (empty($newSet)) {- $newSet = $chartData;+ $newSet = $chartData;}$data = $this->generator->multiSet($newSet);$cache->store($data);diff --git a/app/Http/Controllers/Chart/PiggyBankController.php b/app/Http/Controllers/Chart/PiggyBankController.phpindex a7d1684d90..54ddd642f9 100644--- a/app/Http/Controllers/Chart/PiggyBankController.php+++ b/app/Http/Controllers/Chart/PiggyBankController.php@@ -31,6 +31,7 @@ use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;use FireflyIII\Support\CacheProperties;use FireflyIII\Support\Http\Controllers\DateCalculation;use Illuminate\Http\JsonResponse;+use JsonException;/*** Class PiggyBankController.@@ -63,7 +64,7 @@ class PiggyBankController extends Controller* @param PiggyBank $piggyBank** @return JsonResponse- * @throws \JsonException+ * @throws JsonException*/public function history(PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank): JsonResponse{@@ -72,7 +73,7 @@ class PiggyBankController extends Controller$cache->addProperty('chart.piggy-bank.history');$cache->addProperty($piggyBank->id);if ($cache->has()) {- return response()->json($cache->get());+ return response()->json($cache->get());}$set = $repository->getEvents($piggyBank);$set = $set->reverse();diff --git a/app/Http/Controllers/Chart/ReportController.php b/app/Http/Controllers/Chart/ReportController.phpindex 31efe7921a..3062386453 100644--- a/app/Http/Controllers/Chart/ReportController.php+++ b/app/Http/Controllers/Chart/ReportController.php@@ -35,6 +35,7 @@ use FireflyIII\Support\Http\Controllers\BasicDataSupport;use FireflyIII\Support\Http\Controllers\ChartGeneration;use Illuminate\Http\JsonResponse;use Illuminate\Support\Collection;+use JsonException;use Log;/**@@ -68,7 +69,7 @@ class ReportController extends Controller* @param Carbon $end** @return JsonResponse- * @throws \JsonException+ * @throws JsonException*/public function netWorth(Collection $accounts, Carbon $start, Carbon $end): JsonResponse{@@ -79,7 +80,7 @@ class ReportController extends Controller$cache->addProperty(implode(',', $accounts->pluck('id')->toArray()));$cache->addProperty($end);if ($cache->has()) {- return response()->json($cache->get());+ return response()->json($cache->get());}$locale = app('steam')->getLocale();$current = clone $start;@@ -103,7 +104,7 @@ class ReportController extends Controller});-// See reference nr. 56+ // See reference nr. 56while ($current < $end) {// get balances by date, grouped by currency.@@ -143,7 +144,7 @@ class ReportController extends Controller* @param Carbon $end** @return JsonResponse- * @throws \JsonException+ * @throws JsonException*/public function operations(Collection $accounts, Carbon $start, Carbon $end): JsonResponse{@@ -154,7 +155,7 @@ class ReportController extends Controller$cache->addProperty($accounts);$cache->addProperty($end);if ($cache->has()) {- return response()->json($cache->get());+ return response()->json($cache->get());}Log::debug('Going to do operations for accounts ', $accounts->pluck('id')->toArray());$format = app('navigation')->preferredCarbonFormat($start, $end);diff --git a/app/Http/Controllers/Chart/TagReportController.php b/app/Http/Controllers/Chart/TagReportController.phpindex 802d9c86de..3a77762e19 100644--- a/app/Http/Controllers/Chart/TagReportController.php+++ b/app/Http/Controllers/Chart/TagReportController.php@@ -323,7 +323,7 @@ class TagReportController extends Controller}/**-* See reference nr. 54+ * See reference nr. 54** @param Carbon $start* @param Carbon $enddiff --git a/app/Http/Controllers/Chart/TransactionController.php b/app/Http/Controllers/Chart/TransactionController.phpindex 27c5daea39..c7c7dac871 100644--- a/app/Http/Controllers/Chart/TransactionController.php+++ b/app/Http/Controllers/Chart/TransactionController.php@@ -32,6 +32,7 @@ use FireflyIII\Http\Controllers\Controller;use FireflyIII\Models\TransactionType;use FireflyIII\Support\CacheProperties;use Illuminate\Http\JsonResponse;+use JsonException;/*** Class TransactionController@@ -56,7 +57,7 @@ class TransactionController extends Controller* @param Carbon $end** @return JsonResponse- * @throws \JsonException+ * @throws JsonException*/public function budgets(Carbon $start, Carbon $end){@@ -65,7 +66,7 @@ class TransactionController extends Controller$cache->addProperty($end);$cache->addProperty('chart.transactions.budgets');if ($cache->has()) {- return response()->json($cache->get());+ return response()->json($cache->get());}/** @var GroupCollectorInterface $collector */$collector = app(GroupCollectorInterface::class);@@ -101,7 +102,7 @@ class TransactionController extends Controller** @return JsonResponse* @throws FireflyException- * @throws \JsonException+ * @throws JsonException*/public function categories(string $objectType, Carbon $start, Carbon $end){@@ -111,7 +112,7 @@ class TransactionController extends Controller$cache->addProperty($objectType);$cache->addProperty('chart.transactions.categories');if ($cache->has()) {- return response()->json($cache->get());+ return response()->json($cache->get());}/** @var GroupCollectorInterface $collector */$collector = app(GroupCollectorInterface::class);@@ -160,7 +161,7 @@ class TransactionController extends Controller** @return JsonResponse* @throws FireflyException- * @throws \JsonException+ * @throws JsonException*/public function destinationAccounts(string $objectType, Carbon $start, Carbon $end){@@ -170,7 +171,7 @@ class TransactionController extends Controller$cache->addProperty($objectType);$cache->addProperty('chart.transactions.destinations');if ($cache->has()) {- return response()->json($cache->get());+ return response()->json($cache->get());}/** @var GroupCollectorInterface $collector */$collector = app(GroupCollectorInterface::class);@@ -218,7 +219,7 @@ class TransactionController extends Controller** @return JsonResponse* @throws FireflyException- * @throws \JsonException+ * @throws JsonException*/public function sourceAccounts(string $objectType, Carbon $start, Carbon $end){@@ -228,7 +229,7 @@ class TransactionController extends Controller$cache->addProperty($objectType);$cache->addProperty('chart.transactions.sources');if ($cache->has()) {- return response()->json($cache->get());+ return response()->json($cache->get());}/** @var GroupCollectorInterface $collector */$collector = app(GroupCollectorInterface::class);diff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.phpindex acc35ec5bf..f601a61ea4 100644--- a/app/Http/Controllers/DebugController.php+++ b/app/Http/Controllers/DebugController.php@@ -143,7 +143,7 @@ class DebugController extends Controller$loginProvider = config('auth.providers.users.driver');$bcscale = bcscale();$layout = env('FIREFLY_III_LAYOUT');- $tz = env('TZ');+ $tz = env('TZ');// expected + found DB version:$expectedDBversion = config('firefly.db_version');diff --git a/app/Http/Controllers/Export/IndexController.php b/app/Http/Controllers/Export/IndexController.phpindex 04d7d56322..a196feadcb 100644--- a/app/Http/Controllers/Export/IndexController.php+++ b/app/Http/Controllers/Export/IndexController.php@@ -32,8 +32,6 @@ use FireflyIII\Support\Export\ExportDataGenerator;use Illuminate\Contracts\View\Factory;use Illuminate\Http\Response as LaravelResponse;use Illuminate\View\View;-use League\Csv\CannotInsertRecord;-use League\Csv\Exception;/*** Class IndexController@@ -87,7 +85,7 @@ class IndexController extends Controller$generator->setStart($firstDate);$result = $generator->export();- $name = sprintf('%s_transaction_export.csv', date('Y_m_d'));+ $name = sprintf('%s_transaction_export.csv', date('Y_m_d'));$quoted = sprintf('"%s"', addcslashes($name, '"\\'));// headers for CSV file./** @var LaravelResponse $response */diff --git a/app/Http/Controllers/HelpController.php b/app/Http/Controllers/HelpController.phpindex ecd2205c86..93fcec961c 100644--- a/app/Http/Controllers/HelpController.php+++ b/app/Http/Controllers/HelpController.php@@ -22,6 +22,7 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers;+use FireflyIII\Exceptions\FireflyException;use Illuminate\Http\JsonResponse;/**@@ -35,7 +36,7 @@ class HelpController extends Controller* @param string $route** @return JsonResponse- * @throws \FireflyIII\Exceptions\FireflyException+ * @throws FireflyException*/public function show(string $route): JsonResponse{diff --git a/app/Http/Controllers/JavascriptController.php b/app/Http/Controllers/JavascriptController.phpindex c457ba4042..76324362a8 100644--- a/app/Http/Controllers/JavascriptController.php+++ b/app/Http/Controllers/JavascriptController.php@@ -23,6 +23,7 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers;use Carbon\Carbon;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\Account;use FireflyIII\Models\AccountType;use FireflyIII\Models\TransactionCurrency;@@ -46,7 +47,7 @@ class JavascriptController extends Controller* @param CurrencyRepositoryInterface $currencyRepository** @return Response- * @throws \FireflyIII\Exceptions\FireflyException+ * @throws FireflyException*/public function accounts(AccountRepositoryInterface $repository, CurrencyRepositoryInterface $currencyRepository): Response{@@ -55,14 +56,14 @@ class JavascriptController extends Controller);$preference = app('preferences')->get('currencyPreference', config('firefly.default_currency', 'EUR'));/** @noinspection NullPointerExceptionInspection */- $default = $currencyRepository->findByCodeNull((string) $preference->data);+ $default = $currencyRepository->findByCodeNull((string)$preference->data);$data = ['accounts' => []];/** @var Account $account */foreach ($accounts as $account) {$accountId = $account->id;- $currency = (int) $repository->getMetaValue($account, 'currency_id');+ $currency = (int)$repository->getMetaValue($account, 'currency_id');/** @noinspection NullPointerExceptionInspection */$currency = 0 === $currency ? $default->id : $currency;$entry = ['preferredCurrency' => $currency, 'name' => $account->name];@@ -97,30 +98,6 @@ class JavascriptController extends Controller->header('Content-Type', 'text/javascript');}- /**- * Bit of a hack but OK.- *- * @param Request $request- *- * @return Response- */- public function variablesV2(Request $request): Response- {- /** @var Carbon $start */- $start = clone session('start', Carbon::now()->startOfMonth());- /** @var Carbon $end */- $end = clone session('end', Carbon::now()->endOfMonth());-- $data = [- 'start' => $start->format('Y-m-d'),- 'end' => $end->format('Y-m-d'),- ];-- return response()- ->view('v2.javascript.variables', $data)- ->header('Content-Type', 'text/javascript');- }-/*** Show some common variables to be used in scripts.*@@ -129,13 +106,13 @@ class JavascriptController extends Controller* @param CurrencyRepositoryInterface $currencyRepository** @return Response- * @throws \FireflyIII\Exceptions\FireflyException+ * @throws FireflyException*/public function variables(Request $request, AccountRepositoryInterface $repository, CurrencyRepositoryInterface $currencyRepository): Response{- $account = $repository->find((int) $request->get('account'));+ $account = $repository->find((int)$request->get('account'));$currency = app('amount')->getDefaultCurrency();- if(null !== $account) {+ if (null !== $account) {$currency = $repository->getAccountCurrency($account) ?? $currency;}$locale = app('steam')->getLocale();@@ -145,7 +122,7 @@ class JavascriptController extends Controller/** @noinspection NullPointerExceptionInspection */$lang = $pref->data;$dateRange = $this->getDateRangeConfig();- $uid = substr(hash('sha256', sprintf('%s-%s-%s', (string) config('app.key'), auth()->user()->id, auth()->user()->email)), 0, 12);+ $uid = substr(hash('sha256', sprintf('%s-%s-%s', (string)config('app.key'), auth()->user()->id, auth()->user()->email)), 0, 12);$data = ['currencyCode' => $currency->code,@@ -164,4 +141,28 @@ class JavascriptController extends Controller->header('Content-Type', 'text/javascript');}+ /**+ * Bit of a hack but OK.+ *+ * @param Request $request+ *+ * @return Response+ */+ public function variablesV2(Request $request): Response+ {+ /** @var Carbon $start */+ $start = clone session('start', Carbon::now()->startOfMonth());+ /** @var Carbon $end */+ $end = clone session('end', Carbon::now()->endOfMonth());++ $data = [+ 'start' => $start->format('Y-m-d'),+ 'end' => $end->format('Y-m-d'),+ ];++ return response()+ ->view('v2.javascript.variables', $data)+ ->header('Content-Type', 'text/javascript');+ }+}diff --git a/app/Http/Controllers/Json/BoxController.php b/app/Http/Controllers/Json/BoxController.phpindex ad12df6ad3..07cc1c0b75 100644--- a/app/Http/Controllers/Json/BoxController.php+++ b/app/Http/Controllers/Json/BoxController.php@@ -37,6 +37,7 @@ use FireflyIII\Repositories\Budget\OperationsRepositoryInterface;use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;use FireflyIII\Support\CacheProperties;use Illuminate\Http\JsonResponse;+use JsonException;use Log;/**@@ -51,7 +52,7 @@ class BoxController extends Controller* 2) if the user has no available amount set this period: spent per day** @return JsonResponse- * @throws \JsonException+ * @throws JsonException*/public function available(): JsonResponse{@@ -73,7 +74,7 @@ class BoxController extends Controller$cache->addProperty($today);$cache->addProperty('box-available');if ($cache->has()) {- return response()->json($cache->get());+ return response()->json($cache->get());}$leftPerDayAmount = '0';$leftToSpendAmount = '0';@@ -130,7 +131,7 @@ class BoxController extends Controller* @param CurrencyRepositoryInterface $repository** @return JsonResponse- * @throws \JsonException+ * @throws JsonException*/public function balance(CurrencyRepositoryInterface $repository): JsonResponse{@@ -144,7 +145,7 @@ class BoxController extends Controller$cache->addProperty($end);$cache->addProperty('box-balance');if ($cache->has()) {- return response()->json($cache->get());+ return response()->json($cache->get());}// prep some arrays:$incomes = [];diff --git a/app/Http/Controllers/Json/IntroController.php b/app/Http/Controllers/Json/IntroController.phpindex d7164428c8..7714e0d56c 100644--- a/app/Http/Controllers/Json/IntroController.php+++ b/app/Http/Controllers/Json/IntroController.php@@ -22,6 +22,7 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers\Json;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Support\Http\Controllers\GetConfigurationData;use Illuminate\Http\JsonResponse;@@ -103,7 +104,7 @@ class IntroController extends Controller* @param string|null $specialPage** @return JsonResponse- * @throws \FireflyIII\Exceptions\FireflyException+ * @throws FireflyException*/public function postEnable(string $route, string $specialPage = null): JsonResponse{@@ -127,7 +128,7 @@ class IntroController extends Controller* @param string|null $specialPage** @return JsonResponse- * @throws \FireflyIII\Exceptions\FireflyException+ * @throws FireflyException*/public function postFinished(string $route, string $specialPage = null): JsonResponse{diff --git a/app/Http/Controllers/Json/ReconcileController.php b/app/Http/Controllers/Json/ReconcileController.phpindex 2b328a7d62..006a1251ab 100644--- a/app/Http/Controllers/Json/ReconcileController.php+++ b/app/Http/Controllers/Json/ReconcileController.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers\Json;use Carbon\Carbon;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Helpers\Collector\GroupCollectorInterface;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Models\Account;@@ -35,6 +36,7 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;use Illuminate\Http\JsonResponse;use Illuminate\Http\Request;use Illuminate\Support\Collection;+use JsonException;use Log;use Throwable;@@ -215,8 +217,8 @@ class ReconcileController extends Controller* @param Carbon $end** @return JsonResponse- * @throws \FireflyIII\Exceptions\FireflyException- * @throws \JsonException+ * @throws FireflyException+ * @throws JsonException*/public function transactions(Account $account, Carbon $start, Carbon $end){@@ -256,6 +258,7 @@ class ReconcileController extends ControllerLog::debug(sprintf('Could not render: %s', $e->getMessage()));$html = sprintf('Could not render accounts.reconcile.transactions: %s', $e->getMessage());}+return response()->json(['html' => $html, 'startBalance' => $startBalance, 'endBalance' => $endBalance]);}diff --git a/app/Http/Controllers/Json/RuleController.php b/app/Http/Controllers/Json/RuleController.phpindex 5e5111a427..19338c5379 100644--- a/app/Http/Controllers/Json/RuleController.php+++ b/app/Http/Controllers/Json/RuleController.php@@ -56,6 +56,7 @@ class RuleController extends ControllerLog::error(sprintf('Cannot render rules.partials.action: %s', $e->getMessage()));$view = 'Could not render view.';}+return response()->json(['html' => $view]);}diff --git a/app/Http/Controllers/NewUserController.php b/app/Http/Controllers/NewUserController.phpindex 8aa942ec82..f9f74ca719 100644--- a/app/Http/Controllers/NewUserController.php+++ b/app/Http/Controllers/NewUserController.php@@ -22,6 +22,7 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Http\Requests\NewUserFormRequest;use FireflyIII\Models\AccountType;use FireflyIII\Repositories\Account\AccountRepositoryInterface;@@ -38,6 +39,7 @@ use Illuminate\View\View;class NewUserController extends Controller{use CreateStuff;+/** @var AccountRepositoryInterface The account repository */private $repository;@@ -64,7 +66,7 @@ class NewUserController extends Controller*/public function index(){- app('view')->share('title', (string) trans('firefly.welcome'));+ app('view')->share('title', (string)trans('firefly.welcome'));app('view')->share('mainTitleIcon', 'fa-fire');$types = config('firefly.accountTypesByIdentifier.asset');@@ -82,11 +84,11 @@ class NewUserController extends Controller/*** Store his new settings.*- * @param NewUserFormRequest $request+ * @param NewUserFormRequest $request* @param CurrencyRepositoryInterface $currencyRepository** @return RedirectResponse|Redirector- * @throws \FireflyIII\Exceptions\FireflyException+ * @throws FireflyException*/public function submit(NewUserFormRequest $request, CurrencyRepositoryInterface $currencyRepository){@@ -99,7 +101,7 @@ class NewUserController extends Controller// set language preference:app('preferences')->set('language', $language);// Store currency preference from input:- $currency = $currencyRepository->find((int) $request->input('amount_currency_id_bank_balance'));+ $currency = $currencyRepository->find((int)$request->input('amount_currency_id_bank_balance'));// if is null, set to EUR:if (null === $currency) {@@ -126,7 +128,7 @@ class NewUserController extends Controller'invoice_date' => false, 'internal_reference' => false, 'notes' => true, 'attachments' => true,];app('preferences')->set('transaction_journal_optional_fields', $visibleFields);- session()->flash('success', (string) trans('firefly.stored_new_accounts_new_user'));+ session()->flash('success', (string)trans('firefly.stored_new_accounts_new_user'));app('preferences')->mark();return redirect(route('index'));diff --git a/app/Http/Controllers/ObjectGroup/DeleteController.php b/app/Http/Controllers/ObjectGroup/DeleteController.phpindex 16af643222..e019a050b3 100644--- a/app/Http/Controllers/ObjectGroup/DeleteController.php+++ b/app/Http/Controllers/ObjectGroup/DeleteController.php@@ -68,7 +68,7 @@ class DeleteController extends Controller*/public function delete(ObjectGroup $objectGroup){- $subTitle = (string)trans('firefly.delete_object_group', ['title' => $objectGroup->title]);+ $subTitle = (string)trans('firefly.delete_object_group', ['title' => $objectGroup->title]);$piggyBanks = $objectGroup->piggyBanks()->count();// put previous url in session@@ -81,6 +81,7 @@ class DeleteController extends Controller* Destroy the piggy bank.** @param ObjectGroup $objectGroup+ ** @return RedirectResponse*/public function destroy(ObjectGroup $objectGroup): RedirectResponsediff --git a/app/Http/Controllers/ObjectGroup/IndexController.php b/app/Http/Controllers/ObjectGroup/IndexController.phpindex 6bc9805282..8b846f54cf 100644--- a/app/Http/Controllers/ObjectGroup/IndexController.php+++ b/app/Http/Controllers/ObjectGroup/IndexController.php@@ -28,6 +28,7 @@ use FireflyIII\Http\Controllers\Controller;use FireflyIII\Models\ObjectGroup;use FireflyIII\Repositories\ObjectGroup\ObjectGroupRepositoryInterface;use Illuminate\Contracts\View\Factory;+use Illuminate\Contracts\View\View;use Illuminate\Http\JsonResponse;use Illuminate\Http\Request;use Log;@@ -61,7 +62,7 @@ class IndexController extends Controller}/**- * @return Factory|\Illuminate\Contracts\View\View+ * @return Factory|View*/public function index(){diff --git a/app/Http/Controllers/PiggyBank/CreateController.php b/app/Http/Controllers/PiggyBank/CreateController.phpindex 6ac60fc4da..ffbdcac015 100644--- a/app/Http/Controllers/PiggyBank/CreateController.php+++ b/app/Http/Controllers/PiggyBank/CreateController.php@@ -113,7 +113,7 @@ class CreateController extends Controller}if (count($this->attachments->getMessages()->get('attachments')) > 0) {- $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));+ $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));}$redirect = redirect($this->getPreviousUri('piggy-banks.create.uri'));diff --git a/app/Http/Controllers/PiggyBank/EditController.php b/app/Http/Controllers/PiggyBank/EditController.phpindex e160a74f7f..5abdfa02fa 100644--- a/app/Http/Controllers/PiggyBank/EditController.php+++ b/app/Http/Controllers/PiggyBank/EditController.php@@ -128,7 +128,7 @@ class EditController extends Controller}if (count($this->attachments->getMessages()->get('attachments')) > 0) {- $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));+ $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));}$redirect = redirect($this->getPreviousUri('piggy-banks.edit.uri'));diff --git a/app/Http/Controllers/PiggyBank/IndexController.php b/app/Http/Controllers/PiggyBank/IndexController.phpindex 275e454005..aa0bc13642 100644--- a/app/Http/Controllers/PiggyBank/IndexController.php+++ b/app/Http/Controllers/PiggyBank/IndexController.php@@ -69,7 +69,7 @@ class IndexController extends Controller/*** Show overview of all piggy banks.-* See reference nr. 66+ * See reference nr. 66** @param Request $request*diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.phpindex 9cc2850941..f793c11c08 100644--- a/app/Http/Controllers/PreferencesController.php+++ b/app/Http/Controllers/PreferencesController.php@@ -22,6 +22,7 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\Account;use FireflyIII\Models\AccountType;use FireflyIII\Models\Preference;@@ -64,7 +65,7 @@ class PreferencesController extends Controller* @param AccountRepositoryInterface $repository** @return Factory|View- * @throws \FireflyIII\Exceptions\FireflyException+ * @throws FireflyException*/public function index(AccountRepositoryInterface $repository){@@ -145,7 +146,7 @@ class PreferencesController extends Controller* @param Request $request** @return RedirectResponse|Redirector- * @throws \FireflyIII\Exceptions\FireflyException+ * @throws FireflyException*/public function postIndex(Request $request){@@ -167,9 +168,9 @@ class PreferencesController extends Controller// custom fiscal year$customFiscalYear = 1 === (int)$request->get('customFiscalYear');- $string = strtotime((string)$request->get('fiscalYearStart'));- if(false !== $string) {- $fiscalYearStart = date('m-d', $string);+ $string = strtotime((string)$request->get('fiscalYearStart'));+ if (false !== $string) {+ $fiscalYearStart = date('m-d', $string);app('preferences')->set('customFiscalYear', $customFiscalYear);app('preferences')->set('fiscalYearStart', $fiscalYearStart);}diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.phpindex 469138d1e0..449dd65dcf 100644--- a/app/Http/Controllers/ProfileController.php+++ b/app/Http/Controllers/ProfileController.php@@ -93,49 +93,6 @@ class ProfileController extends Controller$this->middleware(IsDemoUser::class)->except(['index']);}- /**- *- */- public function logoutOtherSessions()- {- if (!$this->internalAuth) {- session()->flash('info', (string)trans('firefly.external_auth_disabled'));-- return redirect(route('profile.index'));- }-- return prefixView('profile.logout-other-sessions');- }-- /**- * @param Request $request- *- * @return Application|RedirectResponse|Redirector- * @throws AuthenticationException- */- public function postLogoutOtherSessions(Request $request)- {- if (!$this->internalAuth) {- session()->flash('info', (string)trans('firefly.external_auth_disabled'));-- return redirect(route('profile.index'));- }- $creds = [- 'email' => auth()->user()->email,- 'password' => $request->get('password'),- ];- if (Auth::once($creds)) {- Auth::logoutOtherDevices($request->get('password'));- session()->flash('info', (string)trans('firefly.other_sessions_logged_out'));-- return redirect(route('profile.index'));- }- session()->flash('error', (string)trans('auth.failed'));-- return redirect(route('profile.index'));-- }-/*** Change your email address.*@@ -388,6 +345,20 @@ class ProfileController extends Controller);}+ /**+ *+ */+ public function logoutOtherSessions()+ {+ if (!$this->internalAuth) {+ session()->flash('info', (string)trans('firefly.external_auth_disabled'));++ return redirect(route('profile.index'));+ }++ return prefixView('profile.logout-other-sessions');+ }+/*** @param Request $request*@@ -548,6 +519,49 @@ class ProfileController extends Controllerreturn redirect(route('profile.index'));}+ /**+ * See reference nr. 64+ *+ * @param string $mfaCode+ *+ * @throws FireflyException+ */+ private function addToMFAHistory(string $mfaCode): void+ {+ /** @var array $mfaHistory */+ $mfaHistory = app('preferences')->get('mfa_history', [])->data;+ $entry = [+ 'time' => time(),+ 'code' => $mfaCode,+ ];+ $mfaHistory[] = $entry;++ app('preferences')->set('mfa_history', $mfaHistory);+ $this->filterMFAHistory();+ }++ /**+ * Remove old entries from the preferences array.+ */+ private function filterMFAHistory(): void+ {+ /** @var array $mfaHistory */+ $mfaHistory = app('preferences')->get('mfa_history', [])->data;+ $newHistory = [];+ $now = time();+ foreach ($mfaHistory as $entry) {+ $time = $entry['time'];+ $code = $entry['code'];+ if ($now - $time <= 300) {+ $newHistory[] = [+ 'time' => $time,+ 'code' => $code,+ ];+ }+ }+ app('preferences')->set('mfa_history', $newHistory);+ }+/*** Submit delete account.*@@ -580,6 +594,35 @@ class ProfileController extends Controllerreturn redirect(route('index'));}+ /**+ * @param Request $request+ *+ * @return Application|RedirectResponse|Redirector+ * @throws AuthenticationException+ */+ public function postLogoutOtherSessions(Request $request)+ {+ if (!$this->internalAuth) {+ session()->flash('info', (string)trans('firefly.external_auth_disabled'));++ return redirect(route('profile.index'));+ }+ $creds = [+ 'email' => auth()->user()->email,+ 'password' => $request->get('password'),+ ];+ if (Auth::once($creds)) {+ Auth::logoutOtherDevices($request->get('password'));+ session()->flash('info', (string)trans('firefly.other_sessions_logged_out'));++ return redirect(route('profile.index'));+ }+ session()->flash('error', (string)trans('auth.failed'));++ return redirect(route('profile.index'));++ }+/*** Regenerate access token.*@@ -659,46 +702,4 @@ class ProfileController extends Controllerreturn redirect(route('login'));}-- /**- * See reference nr. 64- *- * @param string $mfaCode- * @throws FireflyException- */- private function addToMFAHistory(string $mfaCode): void- {- /** @var array $mfaHistory */- $mfaHistory = app('preferences')->get('mfa_history', [])->data;- $entry = [- 'time' => time(),- 'code' => $mfaCode,- ];- $mfaHistory[] = $entry;-- app('preferences')->set('mfa_history', $mfaHistory);- $this->filterMFAHistory();- }-- /**- * Remove old entries from the preferences array.- */- private function filterMFAHistory(): void- {- /** @var array $mfaHistory */- $mfaHistory = app('preferences')->get('mfa_history', [])->data;- $newHistory = [];- $now = time();- foreach ($mfaHistory as $entry) {- $time = $entry['time'];- $code = $entry['code'];- if ($now - $time <= 300) {- $newHistory[] = [- 'time' => $time,- 'code' => $code,- ];- }- }- app('preferences')->set('mfa_history', $newHistory);- }}diff --git a/app/Http/Controllers/Recurring/CreateController.php b/app/Http/Controllers/Recurring/CreateController.phpindex 08a995118b..1f44183101 100644--- a/app/Http/Controllers/Recurring/CreateController.php+++ b/app/Http/Controllers/Recurring/CreateController.php@@ -46,9 +46,9 @@ use Illuminate\View\View;class CreateController extends Controller{private AttachmentHelperInterface $attachments;+ private BillRepositoryInterface $billRepository;private BudgetRepositoryInterface $budgetRepos;private RecurringRepositoryInterface $recurring;- private BillRepositoryInterface $billRepository;/*** CreateController constructor.diff --git a/app/Http/Controllers/Recurring/EditController.php b/app/Http/Controllers/Recurring/EditController.phpindex 432d4b5eb2..3ddaafd699 100644--- a/app/Http/Controllers/Recurring/EditController.php+++ b/app/Http/Controllers/Recurring/EditController.php@@ -47,9 +47,9 @@ use Symfony\Component\HttpFoundation\ParameterBag;class EditController extends Controller{private AttachmentHelperInterface $attachments;+ private BillRepositoryInterface $billRepository;private BudgetRepositoryInterface $budgetRepos;private RecurringRepositoryInterface $recurring;- private BillRepositoryInterface $billRepository;/*** EditController constructor.diff --git a/app/Http/Controllers/Recurring/IndexController.php b/app/Http/Controllers/Recurring/IndexController.phpindex 367c14793a..dfcd70da3c 100644--- a/app/Http/Controllers/Recurring/IndexController.php+++ b/app/Http/Controllers/Recurring/IndexController.php@@ -68,7 +68,7 @@ class IndexController extends Controller}/**-* See reference nr. 70+ * See reference nr. 70* Show all recurring transactions.** @param Request $request@@ -121,7 +121,7 @@ class IndexController extends Controller}$paginator = new LengthAwarePaginator($recurring, $total, $pageSize, $page);$paginator->setPath(route('recurring.index'));- $today = today(config('app.timezone'));+ $today = today(config('app.timezone'));$this->verifyRecurringCronJob();diff --git a/app/Http/Controllers/Report/AccountController.php b/app/Http/Controllers/Report/AccountController.phpindex 0f8b992b97..4765b0990f 100644--- a/app/Http/Controllers/Report/AccountController.php+++ b/app/Http/Controllers/Report/AccountController.php@@ -27,6 +27,7 @@ use FireflyIII\Http\Controllers\Controller;use FireflyIII\Repositories\Account\AccountTaskerInterface;use FireflyIII\Support\CacheProperties;use Illuminate\Support\Collection;+use JsonException;use Log;use Throwable;@@ -44,7 +45,7 @@ class AccountController extends Controller* @param Carbon $end** @return mixed|string- * @throws \JsonException+ * @throws JsonException*/public function general(Collection $accounts, Carbon $start, Carbon $end){@@ -55,7 +56,7 @@ class AccountController extends Controller$cache->addProperty('account-report');$cache->addProperty($accounts->pluck('id')->toArray());if ($cache->has()) {- return $cache->get();+ return $cache->get();}/** @var AccountTaskerInterface $accountTasker */diff --git a/app/Http/Controllers/Report/BillController.php b/app/Http/Controllers/Report/BillController.phpindex 961dadd074..3996e4ba5a 100644--- a/app/Http/Controllers/Report/BillController.php+++ b/app/Http/Controllers/Report/BillController.php@@ -53,7 +53,7 @@ class BillController extends Controller$cache->addProperty('bill-report');$cache->addProperty($accounts->pluck('id')->toArray());if ($cache->has()) {- return $cache->get();+ return $cache->get();}/** @var ReportHelperInterface $helper */$helper = app(ReportHelperInterface::class);diff --git a/app/Http/Controllers/Report/BudgetController.php b/app/Http/Controllers/Report/BudgetController.phpindex eadfe8866f..693518fc67 100644--- a/app/Http/Controllers/Report/BudgetController.php+++ b/app/Http/Controllers/Report/BudgetController.php@@ -36,6 +36,7 @@ use FireflyIII\Support\Report\Budget\BudgetReportGenerator;use Illuminate\Contracts\View\Factory;use Illuminate\Support\Collection;use Illuminate\View\View;+use JsonException;use Log;use Throwable;@@ -307,7 +308,7 @@ class BudgetController extends Controller* @param Carbon $end** @return mixed|string- * @throws \JsonException+ * @throws JsonException*/public function period(Collection $accounts, Carbon $start, Carbon $end){@@ -317,7 +318,7 @@ class BudgetController extends Controller$cache->addProperty('budget-period-report');$cache->addProperty($accounts->pluck('id')->toArray());if ($cache->has()) {- return $cache->get();+ return $cache->get();}$periods = app('navigation')->listOfPeriods($start, $end);diff --git a/app/Http/Controllers/Report/CategoryController.php b/app/Http/Controllers/Report/CategoryController.phpindex c8a0fce6c4..26bc06f4d1 100644--- a/app/Http/Controllers/Report/CategoryController.php+++ b/app/Http/Controllers/Report/CategoryController.php@@ -34,6 +34,7 @@ use FireflyIII\Support\Report\Category\CategoryReportGenerator;use Illuminate\Contracts\View\Factory;use Illuminate\Support\Collection;use Illuminate\View\View;+use JsonException;use Log;use Throwable;@@ -488,7 +489,7 @@ class CategoryController extends Controller* @param Carbon $end** @return mixed|string- * @throws \JsonException+ * @throws JsonException*/public function expenses(Collection $accounts, Carbon $start, Carbon $end){@@ -498,7 +499,7 @@ class CategoryController extends Controller$cache->addProperty('category-period-expenses-report');$cache->addProperty($accounts->pluck('id')->toArray());if ($cache->has()) {- return $cache->get();+ return $cache->get();}// depending on the carbon format (a reliable way to determine the general date difference)@@ -569,7 +570,7 @@ class CategoryController extends Controller* @param Carbon $end** @return string- * @throws \JsonException+ * @throws JsonException*/public function income(Collection $accounts, Carbon $start, Carbon $end): string{@@ -579,7 +580,7 @@ class CategoryController extends Controller$cache->addProperty('category-period-income-report');$cache->addProperty($accounts->pluck('id')->toArray());if ($cache->has()) {- return $cache->get();+ return $cache->get();}// depending on the carbon format (a reliable way to determine the general date difference)@@ -648,7 +649,7 @@ class CategoryController extends Controller* @param Carbon $end** @return mixed|string- * @throws \JsonException+ * @throws JsonException*/public function operations(Collection $accounts, Carbon $start, Carbon $end){@@ -659,7 +660,7 @@ class CategoryController extends Controller$cache->addProperty('category-report');$cache->addProperty($accounts->pluck('id')->toArray());if ($cache->has()) {- return $cache->get();+ return $cache->get();}/** @var CategoryReportGenerator $generator */@@ -678,6 +679,7 @@ class CategoryController extends ControllerLog::error(sprintf('Could not render category::expenses: %s', $e->getMessage()));$result = sprintf('An error prevented Firefly III from rendering: %s. Apologies.', $e->getMessage());}+return $result;}diff --git a/app/Http/Controllers/Report/DoubleController.php b/app/Http/Controllers/Report/DoubleController.phpindex 71dc05966c..d9b1ea40ac 100644--- a/app/Http/Controllers/Report/DoubleController.php+++ b/app/Http/Controllers/Report/DoubleController.php@@ -292,7 +292,7 @@ class DoubleController extends Controller}/**-* See reference nr. 67+ * See reference nr. 67** @param Collection $accounts* @param int $iddiff --git a/app/Http/Controllers/Report/OperationsController.php b/app/Http/Controllers/Report/OperationsController.phpindex 63e5b3bdd9..7ebe75ef23 100644--- a/app/Http/Controllers/Report/OperationsController.php+++ b/app/Http/Controllers/Report/OperationsController.php@@ -27,6 +27,7 @@ use FireflyIII\Http\Controllers\Controller;use FireflyIII\Repositories\Account\AccountTaskerInterface;use FireflyIII\Support\CacheProperties;use Illuminate\Support\Collection;+use JsonException;use Log;use Throwable;@@ -66,7 +67,7 @@ class OperationsController extends Controller* @param Carbon $end** @return mixed|string- * @throws \JsonException+ * @throws JsonException*/public function expenses(Collection $accounts, Carbon $start, Carbon $end){@@ -77,7 +78,7 @@ class OperationsController extends Controller$cache->addProperty('expense-report');$cache->addProperty($accounts->pluck('id')->toArray());if ($cache->has()) {- return $cache->get();+ return $cache->get();}$report = $this->tasker->getExpenseReport($start, $end, $accounts);$type = 'expense-entry';@@ -102,7 +103,7 @@ class OperationsController extends Controller* @param Carbon $end** @return string- * @throws \JsonException+ * @throws JsonException*/public function income(Collection $accounts, Carbon $start, Carbon $end): string{@@ -113,7 +114,7 @@ class OperationsController extends Controller$cache->addProperty('income-report');$cache->addProperty($accounts->pluck('id')->toArray());if ($cache->has()) {- return $cache->get();+ return $cache->get();}$report = $this->tasker->getIncomeReport($start, $end, $accounts);$type = 'income-entry';@@ -138,7 +139,7 @@ class OperationsController extends Controller* @param Carbon $end** @return mixed|string- * @throws \JsonException+ * @throws JsonException*/public function operations(Collection $accounts, Carbon $start, Carbon $end){@@ -149,7 +150,7 @@ class OperationsController extends Controller$cache->addProperty('inc-exp-report');$cache->addProperty($accounts->pluck('id')->toArray());if ($cache->has()) {- return $cache->get();+ return $cache->get();}$incomes = $this->tasker->getIncomeReport($start, $end, $accounts);diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.phpindex 79c97dbec1..4dba93dd6c 100644--- a/app/Http/Controllers/ReportController.php+++ b/app/Http/Controllers/ReportController.php@@ -89,7 +89,7 @@ class ReportController extends Controllerpublic function auditReport(Collection $accounts, Carbon $start, Carbon $end){if ($end < $start) {- return prefixView('error')->with('message', (string)trans('firefly.end_after_start_date'));+ return prefixView('error')->with('message', (string)trans('firefly.end_after_start_date'));}$this->repository->cleanupBudgets();@@ -125,7 +125,7 @@ class ReportController extends Controllerpublic function budgetReport(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end){if ($end < $start) {- return prefixView('error')->with('message', (string)trans('firefly.end_after_start_date'));+ return prefixView('error')->with('message', (string)trans('firefly.end_after_start_date'));}$this->repository->cleanupBudgets();@@ -162,7 +162,7 @@ class ReportController extends Controllerpublic function categoryReport(Collection $accounts, Collection $categories, Carbon $start, Carbon $end){if ($end < $start) {- return prefixView('error')->with('message', (string)trans('firefly.end_after_start_date'));+ return prefixView('error')->with('message', (string)trans('firefly.end_after_start_date'));}$this->repository->cleanupBudgets();@@ -400,7 +400,7 @@ class ReportController extends Controllerpublic function tagReport(Collection $accounts, Collection $tags, Carbon $start, Carbon $end){if ($end < $start) {- return prefixView('error')->with('message', (string)trans('firefly.end_after_start_date'));+ return prefixView('error')->with('message', (string)trans('firefly.end_after_start_date'));}$this->repository->cleanupBudgets();diff --git a/app/Http/Controllers/Rule/CreateController.php b/app/Http/Controllers/Rule/CreateController.phpindex 7a51740b24..c9d2173d27 100644--- a/app/Http/Controllers/Rule/CreateController.php+++ b/app/Http/Controllers/Rule/CreateController.php@@ -265,12 +265,12 @@ class CreateController extends Controller// redirect to show bill.if ('true' === $request->get('return_to_bill') && (int)$request->get('bill_id') > 0) {- return redirect(route('bills.show', [(int)$request->get('bill_id')]));+ return redirect(route('bills.show', [(int)$request->get('bill_id')]));}// redirect to new bill creation.if ((int)$request->get('bill_id') > 0) {- return redirect($this->getPreviousUri('bills.create.uri'));+ return redirect($this->getPreviousUri('bills.create.uri'));}$redirect = redirect($this->getPreviousUri('rules.create.uri'));diff --git a/app/Http/Controllers/Rule/EditController.php b/app/Http/Controllers/Rule/EditController.phpindex ac7671bdc0..f225f59ab8 100644--- a/app/Http/Controllers/Rule/EditController.php+++ b/app/Http/Controllers/Rule/EditController.php@@ -143,7 +143,7 @@ class EditController extends Controller*/private function parseFromOperators(array $submittedOperators): array{-// See reference nr. 65+ // See reference nr. 65$operators = config('firefly.search.operators');$renderedEntries = [];$triggers = [];diff --git a/app/Http/Controllers/Rule/IndexController.php b/app/Http/Controllers/Rule/IndexController.phpindex 3826c02cbc..13a130e9b8 100644--- a/app/Http/Controllers/Rule/IndexController.php+++ b/app/Http/Controllers/Rule/IndexController.php@@ -79,8 +79,8 @@ class IndexController extends Controller}/**- * @param Request $request- * @param Rule $rule+ * @param Request $request+ * @param Rule $rule* @param RuleGroup $ruleGroup** @return JsonResponsediff --git a/app/Http/Controllers/Rule/SelectController.php b/app/Http/Controllers/Rule/SelectController.phpindex 49e208424d..b5b684fb22 100644--- a/app/Http/Controllers/Rule/SelectController.php+++ b/app/Http/Controllers/Rule/SelectController.php@@ -145,7 +145,7 @@ class SelectController extends Controller// warn if nothing.if (empty($textTriggers)) {- return response()->json(['html' => '', 'warning' => (string)trans('firefly.warning_no_valid_triggers')]);+ return response()->json(['html' => '', 'warning' => (string)trans('firefly.warning_no_valid_triggers')]);}foreach ($textTriggers as $textTrigger) {@@ -169,7 +169,7 @@ class SelectController extends Controller// Warn the user if only a subset of transactions is returned$warning = '';if (empty($collection)) {- $warning = (string)trans('firefly.warning_no_matching_transactions');+ $warning = (string)trans('firefly.warning_no_matching_transactions');}// Return json response@@ -182,6 +182,7 @@ class SelectController extends ControllerLog::error($exception->getTraceAsString());$view = sprintf('Could not render list.journals-tiny: %s', $exception->getMessage());}+return response()->json(['html' => $view, 'warning' => $warning]);}@@ -199,7 +200,7 @@ class SelectController extends Controller$triggers = $rule->ruleTriggers;if (empty($triggers)) {- return response()->json(['html' => '', 'warning' => (string)trans('firefly.warning_no_valid_triggers')]);+ return response()->json(['html' => '', 'warning' => (string)trans('firefly.warning_no_valid_triggers')]);}// create new rule engine:$newRuleEngine = app(RuleEngineInterface::class);@@ -211,7 +212,7 @@ class SelectController extends Controller$warning = '';if (empty($collection)) {- $warning = (string)trans('firefly.warning_no_matching_transactions');+ $warning = (string)trans('firefly.warning_no_matching_transactions');}// Return json response@@ -223,6 +224,7 @@ class SelectController extends ControllerLog::error(sprintf('Could not render view in testTriggersByRule(): %s', $exception->getMessage()));Log::error($exception->getTraceAsString());}+return response()->json(['html' => $view, 'warning' => $warning]);}}diff --git a/app/Http/Controllers/RuleGroup/CreateController.php b/app/Http/Controllers/RuleGroup/CreateController.phpindex bf901a11e4..7abaccc79b 100644--- a/app/Http/Controllers/RuleGroup/CreateController.php+++ b/app/Http/Controllers/RuleGroup/CreateController.php@@ -88,7 +88,7 @@ class CreateController extends Controller*/public function store(RuleGroupFormRequest $request){- $data = $request->getRuleGroupData();+ $data = $request->getRuleGroupData();$ruleGroup = $this->repository->store($data);session()->flash('success', (string)trans('firefly.created_new_rule_group', ['title' => $ruleGroup->title]));diff --git a/app/Http/Controllers/RuleGroup/DeleteController.php b/app/Http/Controllers/RuleGroup/DeleteController.phpindex d499868af9..4fb542ee02 100644--- a/app/Http/Controllers/RuleGroup/DeleteController.php+++ b/app/Http/Controllers/RuleGroup/DeleteController.php@@ -81,7 +81,7 @@ class DeleteController extends Controller/*** Actually destroy the rule group.*- * @param Request $request+ * @param Request $request* @param RuleGroup $ruleGroup** @return RedirectResponse|Redirectordiff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.phpindex 8dbba9e584..c6b3278dd2 100644--- a/app/Http/Controllers/TagController.php+++ b/app/Http/Controllers/TagController.php@@ -327,7 +327,7 @@ class TagController extends Controller}if (count($this->attachmentsHelper->getMessages()->get('attachments')) > 0) {- $request->session()->flash('info', $this->attachmentsHelper->getMessages()->get('attachments'));+ $request->session()->flash('info', $this->attachmentsHelper->getMessages()->get('attachments'));}$redirect = redirect($this->getPreviousUri('tags.create.uri'));if (1 === (int)$request->get('create_another')) {@@ -368,7 +368,7 @@ class TagController extends Controller}if (count($this->attachmentsHelper->getMessages()->get('attachments')) > 0) {- $request->session()->flash('info', $this->attachmentsHelper->getMessages()->get('attachments'));+ $request->session()->flash('info', $this->attachmentsHelper->getMessages()->get('attachments'));}$redirect = redirect($this->getPreviousUri('tags.edit.uri'));if (1 === (int)$request->get('return_to_edit')) {diff --git a/app/Http/Controllers/Transaction/BulkController.php b/app/Http/Controllers/Transaction/BulkController.phpindex 8eee5404e5..7038fc2cfa 100644--- a/app/Http/Controllers/Transaction/BulkController.php+++ b/app/Http/Controllers/Transaction/BulkController.php@@ -66,7 +66,7 @@ class BulkController extends Controller/*** Edit a set of journals in bulk.*-* See reference nr. 47+ * See reference nr. 47** @param array $journals*@@ -97,11 +97,11 @@ class BulkController extends Controller*/public function update(BulkEditJournalRequest $request){- $journalIds = $request->get('journals');- $journalIds = is_array($journalIds) ? $journalIds : [];+ $journalIds = $request->get('journals');+ $journalIds = is_array($journalIds) ? $journalIds : [];$ignoreCategory = 1 === (int)$request->get('ignore_category');- $ignoreBudget = 1 === (int)$request->get('ignore_budget');- $tagsAction = $request->get('tags_action');+ $ignoreBudget = 1 === (int)$request->get('ignore_budget');+ $tagsAction = $request->get('tags_action');$count = 0;diff --git a/app/Http/Controllers/Transaction/ConvertController.php b/app/Http/Controllers/Transaction/ConvertController.phpindex 12c50e21ca..d0c42883e4 100644--- a/app/Http/Controllers/Transaction/ConvertController.php+++ b/app/Http/Controllers/Transaction/ConvertController.php@@ -47,7 +47,7 @@ use Log;/*** Class ConvertController.*-* See reference nr. 49+ * See reference nr. 49*/class ConvertController extends Controller{@@ -91,7 +91,7 @@ class ConvertController extends Controllerpublic function index(TransactionType $destinationType, TransactionGroup $group){if (!$this->isEditableGroup($group)) {- return $this->redirectGroupToAccount($group);+ return $this->redirectGroupToAccount($group);}/** @var TransactionGroupTransformer $transformer */@@ -159,12 +159,12 @@ class ConvertController extends Controller$role = (string)$this->accountRepository->getMetaValue($account, 'account_role');$name = $account->name;if ('' === $role) {- $role = 'no_account_type';+ $role = 'no_account_type';}// maybe it's a liability thing:if (in_array($account->accountType->type, $liabilityTypes, true)) {- $role = 'l_' . $account->accountType->type;+ $role = 'l_' . $account->accountType->type;}if (AccountType::CASH === $account->accountType->type) {@@ -173,7 +173,7 @@ class ConvertController extends Controller}if (AccountType::REVENUE === $account->accountType->type) {- $role = 'revenue_account';+ $role = 'revenue_account';}$key = (string)trans('firefly.opt_group_' . $role);@@ -200,12 +200,12 @@ class ConvertController extends Controller$role = (string)$this->accountRepository->getMetaValue($account, 'account_role');$name = $account->name;if ('' === $role) {- $role = 'no_account_type';+ $role = 'no_account_type';}// maybe it's a liability thing:if (in_array($account->accountType->type, $liabilityTypes, true)) {- $role = 'l_' . $account->accountType->type;+ $role = 'l_' . $account->accountType->type;}if (AccountType::CASH === $account->accountType->type) {@@ -214,7 +214,7 @@ class ConvertController extends Controller}if (AccountType::EXPENSE === $account->accountType->type) {- $role = 'expense_account';+ $role = 'expense_account';}$key = (string)trans('firefly.opt_group_' . $role);@@ -264,7 +264,7 @@ class ConvertController extends Controller$currency = $this->accountRepository->getAccountCurrency($account) ?? $defaultCurrency;$role = (string)$this->accountRepository->getMetaValue($account, 'account_role');if ('' === $role) {- $role = 'no_account_type';+ $role = 'no_account_type';}$key = (string)trans('firefly.opt_group_' . $role);@@ -287,7 +287,7 @@ class ConvertController extends Controllerpublic function postIndex(Request $request, TransactionType $destinationType, TransactionGroup $group){if (!$this->isEditableGroup($group)) {- return $this->redirectGroupToAccount($group);+ return $this->redirectGroupToAccount($group);}/** @var TransactionJournal $journal */@@ -346,7 +346,7 @@ class ConvertController extends Controllerthrow new FireflyException(sprintf(trans('firefly.convert_invalid_destination'), $journal->id));}-// See reference nr. 50+ // See reference nr. 50$update = ['source_id' => $sourceId,diff --git a/app/Http/Controllers/Transaction/CreateController.php b/app/Http/Controllers/Transaction/CreateController.phpindex ec36340853..4fc8d3c426 100644--- a/app/Http/Controllers/Transaction/CreateController.php+++ b/app/Http/Controllers/Transaction/CreateController.php@@ -24,11 +24,13 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers\Transaction;use FireflyIII\Events\StoredTransactionGroup;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Models\TransactionGroup;use FireflyIII\Repositories\Account\AccountRepositoryInterface;use FireflyIII\Services\Internal\Update\GroupCloneService;use Illuminate\Contracts\View\Factory;+use Illuminate\Contracts\View\View;use Illuminate\Http\RedirectResponse;use Illuminate\Routing\Redirector;@@ -86,8 +88,8 @@ class CreateController extends Controller** @param string|null $objectType*- * @return Factory|\Illuminate\Contracts\View\View- * @throws \FireflyIII\Exceptions\FireflyException+ * @return Factory|View+ * @throws FireflyException*/public function create(?string $objectType){diff --git a/app/Http/Controllers/Transaction/DeleteController.php b/app/Http/Controllers/Transaction/DeleteController.phpindex 24f0bb1e47..103342d2e9 100644--- a/app/Http/Controllers/Transaction/DeleteController.php+++ b/app/Http/Controllers/Transaction/DeleteController.php@@ -73,7 +73,7 @@ class DeleteController extends Controllerpublic function delete(TransactionGroup $group){if (!$this->isEditableGroup($group)) {- return $this->redirectGroupToAccount($group);+ return $this->redirectGroupToAccount($group);}Log::debug(sprintf('Start of delete view for group #%d', $group->id));@@ -102,7 +102,7 @@ class DeleteController extends Controllerpublic function destroy(TransactionGroup $group): RedirectResponse{if (!$this->isEditableGroup($group)) {- return $this->redirectGroupToAccount($group);+ return $this->redirectGroupToAccount($group);}$journal = $group->transactionJournals->first();diff --git a/app/Http/Controllers/Transaction/EditController.php b/app/Http/Controllers/Transaction/EditController.phpindex ff9f2a9c37..64723d63d2 100644--- a/app/Http/Controllers/Transaction/EditController.php+++ b/app/Http/Controllers/Transaction/EditController.php@@ -67,15 +67,15 @@ class EditController extends Controllerapp('preferences')->mark();if (!$this->isEditableGroup($transactionGroup)) {- return $this->redirectGroupToAccount($transactionGroup);+ return $this->redirectGroupToAccount($transactionGroup);}/** @var AccountRepositoryInterface $repository */- $repository = app(AccountRepositoryInterface::class);+ $repository = app(AccountRepositoryInterface::class);$allowedOpposingTypes = config('firefly.allowed_opposing_types');- $accountToTypes = config('firefly.account_to_transaction');- $expectedSourceTypes = config('firefly.expected_source_types');- $allowedSourceDests = config('firefly.source_dests');+ $accountToTypes = config('firefly.account_to_transaction');+ $expectedSourceTypes = config('firefly.expected_source_types');+ $allowedSourceDests = config('firefly.source_dests');//$defaultCurrency = app('amount')->getDefaultCurrency();diff --git a/app/Http/Controllers/Transaction/IndexController.php b/app/Http/Controllers/Transaction/IndexController.phpindex ebb2c94618..45c4a54e15 100644--- a/app/Http/Controllers/Transaction/IndexController.php+++ b/app/Http/Controllers/Transaction/IndexController.php@@ -77,7 +77,7 @@ class IndexController extends Controller*/public function index(Request $request, string $objectType, Carbon $start = null, Carbon $end = null){- if('transfers' === $objectType) {+ if ('transfers' === $objectType) {$objectType = 'transfer';}diff --git a/app/Http/Controllers/Transaction/LinkController.php b/app/Http/Controllers/Transaction/LinkController.phpindex c2438fdd6b..cf4748cfb5 100644--- a/app/Http/Controllers/Transaction/LinkController.php+++ b/app/Http/Controllers/Transaction/LinkController.php@@ -40,7 +40,7 @@ use URL;*/class LinkController extends Controller{- private JournalRepositoryInterface $journalRepository;+ private JournalRepositoryInterface $journalRepository;private LinkTypeRepositoryInterface $repository;/**diff --git a/app/Http/Controllers/Transaction/MassController.php b/app/Http/Controllers/Transaction/MassController.phpindex 6a616aa312..aca4ad0619 100644--- a/app/Http/Controllers/Transaction/MassController.php+++ b/app/Http/Controllers/Transaction/MassController.php@@ -168,8 +168,8 @@ class MassController extends Controller{$journalIds = $request->get('journals');if (!is_array($journalIds)) {-// See reference nr. 48- throw new FireflyException('This is not an array.');+ // See reference nr. 48+ throw new FireflyException('This is not an array.');}$count = 0;/** @var string $journalId */@@ -178,7 +178,7 @@ class MassController extends Controllertry {$this->updateJournal($integer, $request);$count++;- } catch (FireflyException $e) {+ } catch (FireflyException $e) {// @ignoreException}}@@ -200,7 +200,7 @@ class MassController extends Controller{$journal = $this->repository->find($journalId);if (null === $journal) {- throw new FireflyException(sprintf('Trying to edit non-existent or deleted journal #%d', $journalId));+ throw new FireflyException(sprintf('Trying to edit non-existent or deleted journal #%d', $journalId));}$service = app(JournalUpdateService::class);// for each field, call the update service.diff --git a/app/Http/Middleware/Binder.php b/app/Http/Middleware/Binder.phpindex ace2cf4bc2..fb5255a15d 100644--- a/app/Http/Middleware/Binder.php+++ b/app/Http/Middleware/Binder.php@@ -83,7 +83,7 @@ class Binder** @param string $key* @param string $value- * @param Route $route+ * @param Route $route** @return mixed*/diff --git a/app/Http/Middleware/Installer.php b/app/Http/Middleware/Installer.phpindex 4bd9d29a01..a9184ae5d2 100644--- a/app/Http/Middleware/Installer.php+++ b/app/Http/Middleware/Installer.php@@ -107,6 +107,7 @@ class Installer}throw new FireflyException(sprintf('Could not access the database: %s', $message), 0, $e);}+//Log::debug('Everything seems OK with the tables.');return false;@@ -157,6 +158,7 @@ class Installerreturn true;}+//Log::info(sprintf('Configured DB version (%d) equals expected DB version (%d)', $dbVersion, $configVersion));return false;@@ -183,6 +185,7 @@ class Installerreturn true;}+//Log::info(sprintf('Installed Firefly III version (%s) equals expected Firefly III version (%s)', $dbVersion, $configVersion));return false;diff --git a/app/Http/Middleware/InterestingMessage.php b/app/Http/Middleware/InterestingMessage.phpindex abe5adf499..074e956bac 100644--- a/app/Http/Middleware/InterestingMessage.php+++ b/app/Http/Middleware/InterestingMessage.php@@ -90,57 +90,6 @@ class InterestingMessagereturn null !== $transactionGroupId && null !== $message;}- /**- * @param Request $request- */- private function handleAccountMessage(Request $request): void- {-- // get parameters from request.- $accountId = $request->get('account_id');- $message = $request->get('message');-- /** @var Account $account */- $account = auth()->user()->accounts()->withTrashed()->find($accountId);-- if (null === $account) {- return;- }- if ('deleted' === $message) {- session()->flash('success', (string)trans('firefly.account_deleted', ['name' => $account->name]));- }- if ('created' === $message) {- session()->flash('success', (string)trans('firefly.stored_new_account', ['name' => $account->name]));- }- if ('updated' === $message) {- session()->flash('success', (string)trans('firefly.updated_account', ['name' => $account->name]));- }- }-- /**- * @param Request $request- */- private function handleBillMessage(Request $request): void- {-- // get parameters from request.- $billId = $request->get('bill_id');- $message = $request->get('message');-- /** @var Bill $bill */- $bill = auth()->user()->bills()->withTrashed()->find($billId);-- if (null === $bill) {- return;- }- if ('deleted' === $message) {- session()->flash('success', (string)trans('firefly.deleted_bill', ['name' => $bill->name]));- }- if ('created' === $message) {- session()->flash('success', (string)trans('firefly.stored_new_bill', ['name' => $bill->name]));- }- }-/*** @param Request $request*/@@ -197,6 +146,33 @@ class InterestingMessagereturn null !== $accountId && null !== $message;}+ /**+ * @param Request $request+ */+ private function handleAccountMessage(Request $request): void+ {++ // get parameters from request.+ $accountId = $request->get('account_id');+ $message = $request->get('message');++ /** @var Account $account */+ $account = auth()->user()->accounts()->withTrashed()->find($accountId);++ if (null === $account) {+ return;+ }+ if ('deleted' === $message) {+ session()->flash('success', (string)trans('firefly.account_deleted', ['name' => $account->name]));+ }+ if ('created' === $message) {+ session()->flash('success', (string)trans('firefly.stored_new_account', ['name' => $account->name]));+ }+ if ('updated' === $message) {+ session()->flash('success', (string)trans('firefly.updated_account', ['name' => $account->name]));+ }+ }+/*** @param Request $request*@@ -210,4 +186,28 @@ class InterestingMessagereturn null !== $billId && null !== $message;}++ /**+ * @param Request $request+ */+ private function handleBillMessage(Request $request): void+ {++ // get parameters from request.+ $billId = $request->get('bill_id');+ $message = $request->get('message');++ /** @var Bill $bill */+ $bill = auth()->user()->bills()->withTrashed()->find($billId);++ if (null === $bill) {+ return;+ }+ if ('deleted' === $message) {+ session()->flash('success', (string)trans('firefly.deleted_bill', ['name' => $bill->name]));+ }+ if ('created' === $message) {+ session()->flash('success', (string)trans('firefly.stored_new_bill', ['name' => $bill->name]));+ }+ }}diff --git a/app/Http/Middleware/IsDemoUser.php b/app/Http/Middleware/IsDemoUser.phpindex 04e5457db0..1ce1bf9647 100644--- a/app/Http/Middleware/IsDemoUser.php+++ b/app/Http/Middleware/IsDemoUser.php@@ -60,7 +60,7 @@ class IsDemoUserreturn response()->redirectTo($previous);}- return response()->redirectTo(route('index'));+ return response()->redirectTo(route('index'));}return $next($request);diff --git a/app/Http/Requests/AccountFormRequest.php b/app/Http/Requests/AccountFormRequest.phpindex 66d7097a96..482c9951c6 100644--- a/app/Http/Requests/AccountFormRequest.php+++ b/app/Http/Requests/AccountFormRequest.php@@ -69,7 +69,7 @@ class AccountFormRequest extends FormRequestif (false === $this->boolean('include_net_worth')) {$data['include_net_worth'] = '0';}- if('0' === $data['opening_balance']) {+ if ('0' === $data['opening_balance']) {$data['opening_balance'] = '';}diff --git a/app/Http/Requests/ObjectGroupFormRequest.php b/app/Http/Requests/ObjectGroupFormRequest.phpindex f17d09557a..cda7aa70b2 100644--- a/app/Http/Requests/ObjectGroupFormRequest.php+++ b/app/Http/Requests/ObjectGroupFormRequest.php@@ -55,7 +55,7 @@ class ObjectGroupFormRequest extends FormRequest{/** @var ObjectGroup $objectGroup */$objectGroup = $this->route()->parameter('objectGroup');- $titleRule = 'required|between:1,255|uniqueObjectGroup';+ $titleRule = 'required|between:1,255|uniqueObjectGroup';if (null !== $objectGroup) {$titleRule = sprintf('required|between:1,255|uniqueObjectGroup:%d', $objectGroup->id);diff --git a/app/Http/Requests/ReconciliationStoreRequest.php b/app/Http/Requests/ReconciliationStoreRequest.phpindex ad5bdd5f65..81866fae41 100644--- a/app/Http/Requests/ReconciliationStoreRequest.php+++ b/app/Http/Requests/ReconciliationStoreRequest.php@@ -45,7 +45,7 @@ class ReconciliationStoreRequest extends FormRequest{$transactions = $this->get('journals');if (!is_array($transactions)) {- $transactions = [];+ $transactions = [];}$data = ['start' => $this->date('start'),diff --git a/app/Http/Requests/TestRuleFormRequest.php b/app/Http/Requests/TestRuleFormRequest.phpindex 27dd553aee..5c7b7d920b 100644--- a/app/Http/Requests/TestRuleFormRequest.php+++ b/app/Http/Requests/TestRuleFormRequest.php@@ -37,7 +37,7 @@ class TestRuleFormRequest extends FormRequest/*** Rules for this request.-* See reference nr. 46+ * See reference nr. 46** @return array*/diff --git a/app/Jobs/MailError.php b/app/Jobs/MailError.phpindex 1ecce5dba6..2c08727de5 100644--- a/app/Jobs/MailError.php+++ b/app/Jobs/MailError.php@@ -40,9 +40,9 @@ class MailError extends Job implements ShouldQueueuse InteractsWithQueue, SerializesModels;protected string $destination;- protected array $exception;+ protected array $exception;protected string $ipAddress;- protected array $userData;+ protected array $userData;/*** MailError constructor.diff --git a/app/Models/Account.php b/app/Models/Account.phpindex ececd3cca9..938f6a3d57 100644--- a/app/Models/Account.php+++ b/app/Models/Account.php@@ -99,7 +99,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @property string $location* @property string $liability_direction* @property string $current_debt- * @property int|null $user_group_id+ * @property int|null $user_group_id* @method static EloquentBuilder|Account whereUserGroupId($value)*/class Account extends Modeldiff --git a/app/Models/Attachment.php b/app/Models/Attachment.phpindex ab1a324ea6..686ae491ce 100644--- a/app/Models/Attachment.php+++ b/app/Models/Attachment.php@@ -78,7 +78,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @method static Builder|Attachment withTrashed()* @method static Builder|Attachment withoutTrashed()* @mixin Eloquent- * @property int|null $user_group_id+ * @property int|null $user_group_id* @method static \Illuminate\Database\Eloquent\Builder|Attachment whereUserGroupId($value)*/class Attachment extends Modeldiff --git a/app/Models/AvailableBudget.php b/app/Models/AvailableBudget.phpindex 05e89eb4cd..c2d514457c 100644--- a/app/Models/AvailableBudget.php+++ b/app/Models/AvailableBudget.php@@ -34,17 +34,17 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** FireflyIII\Models\AvailableBudget*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at- * @property int $user_id- * @property int $transaction_currency_id- * @property string $amount- * @property Carbon $start_date- * @property Carbon $end_date- * @property-read TransactionCurrency $transactionCurrency- * @property-read User $user+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at+ * @property int $user_id+ * @property int $transaction_currency_id+ * @property string $amount+ * @property Carbon $start_date+ * @property Carbon $end_date+ * @property-read TransactionCurrency $transactionCurrency+ * @property-read User $user* @method static \Illuminate\Database\Eloquent\Builder|AvailableBudget newModelQuery()* @method static \Illuminate\Database\Eloquent\Builder|AvailableBudget newQuery()* @method static Builder|AvailableBudget onlyTrashed()@@ -61,7 +61,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @method static Builder|AvailableBudget withTrashed()* @method static Builder|AvailableBudget withoutTrashed()* @mixin Eloquent- * @property int|null $user_group_id+ * @property int|null $user_group_id* @method static \Illuminate\Database\Eloquent\Builder|AvailableBudget whereUserGroupId($value)*/class AvailableBudget extends Modeldiff --git a/app/Models/Bill.php b/app/Models/Bill.phpindex 6581eb2312..d0af591be6 100644--- a/app/Models/Bill.php+++ b/app/Models/Bill.php@@ -94,7 +94,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @method static Builder|Bill withTrashed()* @method static Builder|Bill withoutTrashed()* @mixin Eloquent- * @property int|null $user_group_id+ * @property int|null $user_group_id* @method static \Illuminate\Database\Eloquent\Builder|Bill whereUserGroupId($value)*/class Bill extends Modeldiff --git a/app/Models/Budget.php b/app/Models/Budget.phpindex 6d07df3d48..590695cc76 100644--- a/app/Models/Budget.php+++ b/app/Models/Budget.php@@ -75,7 +75,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @method static Builder|Budget withoutTrashed()* @mixin Eloquent* @property string $email- * @property int|null $user_group_id+ * @property int|null $user_group_id* @method static \Illuminate\Database\Eloquent\Builder|Budget whereUserGroupId($value)*/class Budget extends Modeldiff --git a/app/Models/BudgetLimit.php b/app/Models/BudgetLimit.phpindex e05a37e28c..77bb3eee4c 100644--- a/app/Models/BudgetLimit.php+++ b/app/Models/BudgetLimit.php@@ -32,19 +32,19 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** FireflyIII\Models\BudgetLimit*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property int $budget_id- * @property int|null $transaction_currency_id- * @property Carbon $start_date- * @property Carbon|null $end_date- * @property string $amount- * @property string $spent- * @property string|null $period- * @property int $generated- * @property-read Budget $budget- * @property-read TransactionCurrency|null $transactionCurrency+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property int $budget_id+ * @property int|null $transaction_currency_id+ * @property Carbon $start_date+ * @property Carbon|null $end_date+ * @property string $amount+ * @property string $spent+ * @property string|null $period+ * @property int $generated+ * @property-read Budget $budget+ * @property-read TransactionCurrency|null $transactionCurrency* @method static Builder|BudgetLimit newModelQuery()* @method static Builder|BudgetLimit newQuery()* @method static Builder|BudgetLimit query()diff --git a/app/Models/Category.php b/app/Models/Category.phpindex 2623e25009..f7620877a9 100644--- a/app/Models/Category.php+++ b/app/Models/Category.php@@ -69,7 +69,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @method static Builder|Category withTrashed()* @method static Builder|Category withoutTrashed()* @mixin Eloquent- * @property int|null $user_group_id+ * @property int|null $user_group_id* @method static \Illuminate\Database\Eloquent\Builder|Category whereUserGroupId($value)*/class Category extends Modeldiff --git a/app/Models/CurrencyExchangeRate.php b/app/Models/CurrencyExchangeRate.phpindex fdc4fcd3a5..6929f4c470 100644--- a/app/Models/CurrencyExchangeRate.php+++ b/app/Models/CurrencyExchangeRate.php@@ -32,19 +32,19 @@ use Illuminate\Support\Carbon;/*** FireflyIII\Models\CurrencyExchangeRate*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property string|null $deleted_at- * @property int $user_id- * @property int $from_currency_id- * @property int $to_currency_id- * @property Carbon $date- * @property string $rate- * @property string|null $user_rate- * @property-read TransactionCurrency $fromCurrency- * @property-read TransactionCurrency $toCurrency- * @property-read User $user+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property string|null $deleted_at+ * @property int $user_id+ * @property int $from_currency_id+ * @property int $to_currency_id+ * @property Carbon $date+ * @property string $rate+ * @property string|null $user_rate+ * @property-read TransactionCurrency $fromCurrency+ * @property-read TransactionCurrency $toCurrency+ * @property-read User $user* @method static Builder|CurrencyExchangeRate newModelQuery()* @method static Builder|CurrencyExchangeRate newQuery()* @method static Builder|CurrencyExchangeRate query()diff --git a/app/Models/LinkType.php b/app/Models/LinkType.phpindex df91a6fcfa..cf6abf70a9 100644--- a/app/Models/LinkType.php+++ b/app/Models/LinkType.php@@ -35,9 +35,9 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* FireflyIII\Models\LinkType** @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at* @property string $name* @property string $outward* @property string $inwarddiff --git a/app/Models/ObjectGroup.php b/app/Models/ObjectGroup.phpindex cd14db695a..4578efc14e 100644--- a/app/Models/ObjectGroup.php+++ b/app/Models/ObjectGroup.php@@ -71,7 +71,7 @@ class ObjectGroup extends Model* @var array*/protected $casts- = [+ = ['created_at' => 'datetime','updated_at' => 'datetime','user_id' => 'integer',diff --git a/app/Models/PiggyBank.php b/app/Models/PiggyBank.phpindex 028b37cab0..2288ae7ef6 100644--- a/app/Models/PiggyBank.php+++ b/app/Models/PiggyBank.php@@ -37,14 +37,14 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* FireflyIII\Models\PiggyBank** @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at* @property int $account_id* @property string $name* @property string $targetamount- * @property Carbon|null $startdate- * @property Carbon|null $targetdate+ * @property Carbon|null $startdate+ * @property Carbon|null $targetdate* @property int $order* @property bool $active* @property bool $encrypteddiff --git a/app/Models/PiggyBankEvent.php b/app/Models/PiggyBankEvent.phpindex 480a8819bc..f3b71fe2af 100644--- a/app/Models/PiggyBankEvent.php+++ b/app/Models/PiggyBankEvent.php@@ -31,15 +31,15 @@ use Illuminate\Support\Carbon;/*** FireflyIII\Models\PiggyBankEvent*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property int $piggy_bank_id- * @property int|null $transaction_journal_id- * @property Carbon $date- * @property string $amount- * @property PiggyBank $piggyBank- * @property-read TransactionJournal|null $transactionJournal+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property int $piggy_bank_id+ * @property int|null $transaction_journal_id+ * @property Carbon $date+ * @property string $amount+ * @property PiggyBank $piggyBank+ * @property-read TransactionJournal|null $transactionJournal* @method static Builder|PiggyBankEvent newModelQuery()* @method static Builder|PiggyBankEvent newQuery()* @method static Builder|PiggyBankEvent query()diff --git a/app/Models/Recurrence.php b/app/Models/Recurrence.phpindex 2dca75f241..f96ff20744 100644--- a/app/Models/Recurrence.php+++ b/app/Models/Recurrence.php@@ -86,7 +86,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @method static Builder|Recurrence withTrashed()* @method static Builder|Recurrence withoutTrashed()* @mixin Eloquent- * @property int|null $user_group_id+ * @property int|null $user_group_id* @method static \Illuminate\Database\Eloquent\Builder|Recurrence whereUserGroupId($value)*/class Recurrence extends Modeldiff --git a/app/Models/RecurrenceRepetition.php b/app/Models/RecurrenceRepetition.phpindex f3b88354a4..c5374980b4 100644--- a/app/Models/RecurrenceRepetition.php+++ b/app/Models/RecurrenceRepetition.php@@ -33,16 +33,16 @@ use Illuminate\Support\Carbon;/*** FireflyIII\Models\RecurrenceRepetition*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at- * @property int $recurrence_id- * @property string $repetition_type- * @property string $repetition_moment- * @property int $repetition_skip- * @property int $weekend- * @property-read Recurrence $recurrence+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at+ * @property int $recurrence_id+ * @property string $repetition_type+ * @property string $repetition_moment+ * @property int $repetition_skip+ * @property int $weekend+ * @property-read Recurrence $recurrence* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceRepetition newModelQuery()* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceRepetition newQuery()* @method static Builder|RecurrenceRepetition onlyTrashed()diff --git a/app/Models/RecurrenceTransaction.php b/app/Models/RecurrenceTransaction.phpindex 49118d0c40..9617e13a2b 100644--- a/app/Models/RecurrenceTransaction.php+++ b/app/Models/RecurrenceTransaction.php@@ -35,25 +35,25 @@ use Illuminate\Support\Carbon;/*** FireflyIII\Models\RecurrenceTransaction*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at- * @property int $recurrence_id- * @property int $transaction_currency_id- * @property int|null $foreign_currency_id- * @property int $source_id- * @property int $destination_id- * @property string $amount- * @property string|null $foreign_amount- * @property string $description- * @property-read Account $destinationAccount- * @property-read TransactionCurrency|null $foreignCurrency- * @property-read Recurrence $recurrence+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at+ * @property int $recurrence_id+ * @property int $transaction_currency_id+ * @property int|null $foreign_currency_id+ * @property int $source_id+ * @property int $destination_id+ * @property string $amount+ * @property string|null $foreign_amount+ * @property string $description+ * @property-read Account $destinationAccount+ * @property-read TransactionCurrency|null $foreignCurrency+ * @property-read Recurrence $recurrence* @property-read Collection|RecurrenceTransactionMeta[] $recurrenceTransactionMeta- * @property-read int|null $recurrence_transaction_meta_count- * @property-read Account $sourceAccount- * @property-read TransactionCurrency $transactionCurrency+ * @property-read int|null $recurrence_transaction_meta_count+ * @property-read Account $sourceAccount+ * @property-read TransactionCurrency $transactionCurrency* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransaction newModelQuery()* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransaction newQuery()* @method static Builder|RecurrenceTransaction onlyTrashed()@@ -73,9 +73,9 @@ use Illuminate\Support\Carbon;* @method static Builder|RecurrenceTransaction withTrashed()* @method static Builder|RecurrenceTransaction withoutTrashed()* @mixin Eloquent- * @property int|null $transaction_type_id+ * @property int|null $transaction_type_id* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceTransaction whereTransactionTypeId($value)- * @property-read TransactionType|null $transactionType+ * @property-read TransactionType|null $transactionType*/class RecurrenceTransaction extends Model{diff --git a/app/Models/Rule.php b/app/Models/Rule.phpindex f8bbd75b2a..732b3d6cd2 100644--- a/app/Models/Rule.php+++ b/app/Models/Rule.php@@ -74,7 +74,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @method static Builder|Rule withTrashed()* @method static Builder|Rule withoutTrashed()* @mixin Eloquent- * @property int|null $user_group_id+ * @property int|null $user_group_id* @method static \Illuminate\Database\Eloquent\Builder|Rule whereUserGroupId($value)*/class Rule extends Modeldiff --git a/app/Models/RuleAction.php b/app/Models/RuleAction.phpindex a4a2932fe2..922c4445c1 100644--- a/app/Models/RuleAction.php+++ b/app/Models/RuleAction.php@@ -31,16 +31,16 @@ use Illuminate\Support\Carbon;/*** FireflyIII\Models\RuleAction*- * @property int $id+ * @property int $id* @property Carbon|null $created_at* @property Carbon|null $updated_at- * @property int $rule_id- * @property string $action_type- * @property string $action_value- * @property int $order- * @property bool $active- * @property bool $stop_processing- * @property-read Rule $rule+ * @property int $rule_id+ * @property string $action_type+ * @property string $action_value+ * @property int $order+ * @property bool $active+ * @property bool $stop_processing+ * @property-read Rule $rule* @method static Builder|RuleAction newModelQuery()* @method static Builder|RuleAction newQuery()* @method static Builder|RuleAction query()diff --git a/app/Models/RuleGroup.php b/app/Models/RuleGroup.phpindex 8481c2de12..b88d5f7bcf 100644--- a/app/Models/RuleGroup.php+++ b/app/Models/RuleGroup.php@@ -36,19 +36,19 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** FireflyIII\Models\RuleGroup*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at- * @property int $user_id- * @property string $title- * @property string|null $description- * @property int $order- * @property bool $active- * @property bool $stop_processing+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at+ * @property int $user_id+ * @property string $title+ * @property string|null $description+ * @property int $order+ * @property bool $active+ * @property bool $stop_processing* @property Collection|Rule[] $rules- * @property-read int|null $rules_count- * @property-read User $user+ * @property-read int|null $rules_count+ * @property-read User $user* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup newModelQuery()* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup newQuery()* @method static Builder|RuleGroup onlyTrashed()@@ -66,7 +66,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @method static Builder|RuleGroup withTrashed()* @method static Builder|RuleGroup withoutTrashed()* @mixin Eloquent- * @property int|null $user_group_id+ * @property int|null $user_group_id* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup whereUserGroupId($value)*/class RuleGroup extends Modeldiff --git a/app/Models/RuleTrigger.php b/app/Models/RuleTrigger.phpindex 07153a1109..234e1feefa 100644--- a/app/Models/RuleTrigger.php+++ b/app/Models/RuleTrigger.php@@ -31,16 +31,16 @@ use Illuminate\Support\Carbon;/*** FireflyIII\Models\RuleTrigger*- * @property int $id+ * @property int $id* @property Carbon|null $created_at* @property Carbon|null $updated_at- * @property int $rule_id- * @property string $trigger_type- * @property string $trigger_value- * @property int $order- * @property bool $active- * @property bool $stop_processing- * @property-read Rule $rule+ * @property int $rule_id+ * @property string $trigger_type+ * @property string $trigger_value+ * @property int $order+ * @property bool $active+ * @property bool $stop_processing+ * @property-read Rule $rule* @method static Builder|RuleTrigger newModelQuery()* @method static Builder|RuleTrigger newQuery()* @method static Builder|RuleTrigger query()diff --git a/app/Models/Tag.php b/app/Models/Tag.phpindex 6297365cea..8aa8b656b7 100644--- a/app/Models/Tag.php+++ b/app/Models/Tag.php@@ -75,7 +75,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @method static Builder|Tag withTrashed()* @method static Builder|Tag withoutTrashed()* @mixin Eloquent- * @property int|null $user_group_id+ * @property int|null $user_group_id* @method static \Illuminate\Database\Eloquent\Builder|Tag whereUserGroupId($value)*/class Tag extends Modeldiff --git a/app/Models/Transaction.php b/app/Models/Transaction.phpindex 5cfaeaf6a8..5f2d3019e7 100644--- a/app/Models/Transaction.php+++ b/app/Models/Transaction.php@@ -35,31 +35,31 @@ use Illuminate\Database\Eloquent\SoftDeletes;/*** FireflyIII\Models\Transaction*- * @property int $id- * @property \Illuminate\Support\Carbon|null $created_at- * @property \Illuminate\Support\Carbon|null $updated_at- * @property \Illuminate\Support\Carbon|null $deleted_at- * @property bool $reconciled- * @property int $account_id- * @property int $transaction_journal_id- * @property string|null $description- * @property int|null $transaction_currency_id- * @property string $modified- * @property string $modified_foreign- * @property string $date- * @property string $max_date- * @property string $amount- * @property string|null $foreign_amount- * @property int|null $foreign_currency_id- * @property int $identifier- * @property-read Account $account- * @property-read Collection|Budget[] $budgets- * @property-read int|null $budgets_count- * @property-read Collection|Category[] $categories- * @property-read int|null $categories_count- * @property-read TransactionCurrency|null $foreignCurrency- * @property-read TransactionCurrency|null $transactionCurrency- * @property-read TransactionJournal $transactionJournal+ * @property int $id+ * @property \Illuminate\Support\Carbon|null $created_at+ * @property \Illuminate\Support\Carbon|null $updated_at+ * @property \Illuminate\Support\Carbon|null $deleted_at+ * @property bool $reconciled+ * @property int $account_id+ * @property int $transaction_journal_id+ * @property string|null $description+ * @property int|null $transaction_currency_id+ * @property string $modified+ * @property string $modified_foreign+ * @property string $date+ * @property string $max_date+ * @property string $amount+ * @property string|null $foreign_amount+ * @property int|null $foreign_currency_id+ * @property int $identifier+ * @property-read Account $account+ * @property-read Collection|Budget[] $budgets+ * @property-read int|null $budgets_count+ * @property-read Collection|Category[] $categories+ * @property-read int|null $categories_count+ * @property-read TransactionCurrency|null $foreignCurrency+ * @property-read TransactionCurrency|null $transactionCurrency+ * @property-read TransactionJournal $transactionJournal* @method static Builder|Transaction after(Carbon $date)* @method static Builder|Transaction before(Carbon $date)* @method static Builder|Transaction newModelQuery()@@ -83,7 +83,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;* @method static \Illuminate\Database\Query\Builder|Transaction withTrashed()* @method static \Illuminate\Database\Query\Builder|Transaction withoutTrashed()* @mixin Eloquent- * @property int $the_count+ * @property int $the_count*/class Transaction extends Model{diff --git a/app/Models/TransactionCurrency.php b/app/Models/TransactionCurrency.phpindex ec3018c4a4..4b2c12bb04 100644--- a/app/Models/TransactionCurrency.php+++ b/app/Models/TransactionCurrency.php@@ -35,9 +35,9 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* FireflyIII\Models\TransactionCurrency** @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at* @property bool $enabled* @property string $code* @property string $namediff --git a/app/Models/TransactionGroup.php b/app/Models/TransactionGroup.phpindex d29a0ef693..10a356b41d 100644--- a/app/Models/TransactionGroup.php+++ b/app/Models/TransactionGroup.php@@ -58,7 +58,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @method static Builder|TransactionGroup withTrashed()* @method static Builder|TransactionGroup withoutTrashed()* @mixin Eloquent- * @property int|null $user_group_id+ * @property int|null $user_group_id* @method static \Illuminate\Database\Eloquent\Builder|TransactionGroup whereUserGroupId($value)*/class TransactionGroup extends Modeldiff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.phpindex f89805655a..af8e072e96 100644--- a/app/Models/TransactionJournal.php+++ b/app/Models/TransactionJournal.php@@ -24,7 +24,6 @@ namespace FireflyIII\Models;use Carbon\Carbon;use Eloquent;-use FireflyIII\Exceptions\FireflyException;use FireflyIII\User;use Illuminate\Database\Eloquent\Builder;use Illuminate\Database\Eloquent\Builder as EloquentBuilder;@@ -41,15 +40,15 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** FireflyIII\Models\TransactionJournal*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property Carbon|null $deleted_at- * @property int $user_id- * @property int $transaction_type_id- * @property int|null $transaction_group_id- * @property int|null $bill_id- * @property int|null $transaction_currency_id+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property Carbon|null $deleted_at+ * @property int $user_id+ * @property int $transaction_type_id+ * @property int|null $transaction_group_id+ * @property int|null $bill_id+ * @property int|null $transaction_currency_id* @property string $description* @property Carbon $date* @property Carbon|null $interest_date@@ -71,20 +70,20 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @property-read int|null $dest_journal_links_count* @property-read Collection|Note[] $notes* @property-read int|null $notes_count- * @property-read Collection|PiggyBankEvent[] $piggyBankEvents- * @property-read int|null $piggy_bank_events_count- * @property-read Collection|TransactionJournalLink[] $sourceJournalLinks- * @property-read int|null $source_journal_links_count- * @property-read Collection|Tag[] $tags- * @property-read int|null $tags_count- * @property-read TransactionCurrency|null $transactionCurrency- * @property-read TransactionGroup|null $transactionGroup- * @property-read Collection|TransactionJournalMeta[] $transactionJournalMeta- * @property-read int|null $transaction_journal_meta_count- * @property-read TransactionType $transactionType- * @property-read Collection|Transaction[] $transactions- * @property-read int|null $transactions_count- * @property-read User $user+ * @property-read Collection|PiggyBankEvent[] $piggyBankEvents+ * @property-read int|null $piggy_bank_events_count+ * @property-read Collection|TransactionJournalLink[] $sourceJournalLinks+ * @property-read int|null $source_journal_links_count+ * @property-read Collection|Tag[] $tags+ * @property-read int|null $tags_count+ * @property-read TransactionCurrency|null $transactionCurrency+ * @property-read TransactionGroup|null $transactionGroup+ * @property-read Collection|TransactionJournalMeta[] $transactionJournalMeta+ * @property-read int|null $transaction_journal_meta_count+ * @property-read TransactionType $transactionType+ * @property-read Collection|Transaction[] $transactions+ * @property-read int|null $transactions_count+ * @property-read User $user* @method static EloquentBuilder|TransactionJournal after(Carbon $date)* @method static EloquentBuilder|TransactionJournal before(Carbon $date)* @method static EloquentBuilder|TransactionJournal newModelQuery()@@ -113,10 +112,10 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @method static \Illuminate\Database\Query\Builder|TransactionJournal withTrashed()* @method static \Illuminate\Database\Query\Builder|TransactionJournal withoutTrashed()* @mixin Eloquent- * @property-read Collection|Location[] $locations- * @property-read int|null $locations_count- * @property int $the_count- * @property int|null $user_group_id+ * @property-read Collection|Location[] $locations+ * @property-read int|null $locations_count+ * @property int $the_count+ * @property int|null $user_group_id* @method static EloquentBuilder|TransactionJournal whereUserGroupId($value)*/class TransactionJournal extends Modeldiff --git a/app/Models/TransactionJournalLink.php b/app/Models/TransactionJournalLink.phpindex f38091319e..f7ecd1b5d2 100644--- a/app/Models/TransactionJournalLink.php+++ b/app/Models/TransactionJournalLink.php@@ -34,20 +34,20 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;/*** FireflyIII\Models\TransactionJournalLink*- * @property int $id- * @property Carbon|null $created_at- * @property Carbon|null $updated_at- * @property int $link_type_id- * @property int $source_id- * @property int $destination_id- * @property string|null $comment- * @property-read TransactionJournal $destination- * @property-read LinkType $linkType- * @property-read Collection|Note[] $notes- * @property-read int|null $notes_count- * @property-read TransactionJournal $source- * @property-read string $inward- * @property-read string $outward+ * @property int $id+ * @property Carbon|null $created_at+ * @property Carbon|null $updated_at+ * @property int $link_type_id+ * @property int $source_id+ * @property int $destination_id+ * @property string|null $comment+ * @property-read TransactionJournal $destination+ * @property-read LinkType $linkType+ * @property-read Collection|Note[] $notes+ * @property-read int|null $notes_count+ * @property-read TransactionJournal $source+ * @property-read string $inward+ * @property-read string $outward* @method static Builder|TransactionJournalLink newModelQuery()* @method static Builder|TransactionJournalLink newQuery()* @method static Builder|TransactionJournalLink query()diff --git a/app/Models/Webhook.php b/app/Models/Webhook.phpindex e4963677e9..1eb3fcb069 100644--- a/app/Models/Webhook.php+++ b/app/Models/Webhook.php@@ -71,7 +71,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @property string $secret* @method static Builder|Webhook whereSecret($value)* @method static Builder|Webhook whereTitle($value)- * @property int|null $user_group_id+ * @property int|null $user_group_id* @method static Builder|Webhook whereUserGroupId($value)*/class Webhook extends Model@@ -92,7 +92,7 @@ class Webhook extends Model// deliverypublic const DELIVERY_JSON = 300;protected $casts- = [+ = ['active' => 'boolean','trigger' => 'integer','response' => 'integer',diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.phpindex c9ff95a863..4eff73f510 100644--- a/app/Providers/EventServiceProvider.php+++ b/app/Providers/EventServiceProvider.php@@ -126,15 +126,15 @@ class EventServiceProvider extends ServiceProvider],// account related events:- StoredAccount::class => [+ StoredAccount::class => ['FireflyIII\Handlers\Events\StoredAccountEventHandler@recalculateCredit',- ],- UpdatedAccount::class => [+ ],+ UpdatedAccount::class => ['FireflyIII\Handlers\Events\UpdatedAccountEventHandler@recalculateCredit',],// LDAP related events:- Imported::class => [+ Imported::class => ['FireflyIII\Handlers\Events\LDAPEventHandler@importedUser',],];diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.phpindex 4cbd918fbe..a1e0fd81da 100644--- a/app/Repositories/Account/AccountRepository.php+++ b/app/Repositories/Account/AccountRepository.php@@ -40,6 +40,7 @@ use FireflyIII\User;use Illuminate\Database\Eloquent\Builder as EloquentBuilder;use Illuminate\Database\Eloquent\Relations\HasMany;use Illuminate\Support\Collection;+use JsonException;use Log;use Storage;@@ -115,6 +116,41 @@ class AccountRepository implements AccountRepositoryInterface}+ /**+ * @param int $accountId+ *+ * @return Account|null+ */+ public function find(int $accountId): ?Account+ {+ return $this->user->accounts()->find($accountId);+ }++ /**+ * @inheritDoc+ */+ public function findByAccountNumber(string $number, array $types): ?Account+ {+ $dbQuery = $this->user+ ->accounts()+ ->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')+ ->where('accounts.active', true)+ ->where(+ function (EloquentBuilder $q1) use ($number) {+ $json = json_encode($number);+ $q1->where('account_meta.name', '=', 'account_number');+ $q1->where('account_meta.data', '=', $json);+ }+ );++ if (!empty($types)) {+ $dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');+ $dbQuery->whereIn('account_types.type', $types);+ }++ return $dbQuery->first(['accounts.*']);+ }+/*** @param string $iban* @param array $types@@ -162,16 +198,6 @@ class AccountRepository implements AccountRepositoryInterfacereturn $account;}- /**- * @param int $accountId- *- * @return Account|null- */- public function find(int $accountId): ?Account- {- return $this->user->accounts()->find($accountId);- }-/*** @param Account $account*@@ -310,6 +336,23 @@ class AccountRepository implements AccountRepositoryInterfacereturn $factory->findOrCreate('Cash account', $type->type);}+ /**+ * @inheritDoc+ */+ public function getCreditTransactionGroup(Account $account): ?TransactionGroup+ {+ $journal = TransactionJournal+ ::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')+ ->where('transactions.account_id', $account->id)+ ->transactionTypes([TransactionType::LIABILITY_CREDIT])+ ->first(['transaction_journals.*']);+ if (null === $journal) {+ return null;+ }++ return $journal->transactionGroup;+ }+/*** @param array $types*@@ -731,7 +774,7 @@ class AccountRepository implements AccountRepositoryInterface** @return Account* @throws FireflyException- * @throws \JsonException+ * @throws JsonException*/public function update(Account $account, array $data): Account{@@ -741,46 +784,4 @@ class AccountRepository implements AccountRepositoryInterfacereturn $service->update($account, $data);}- /**- * @inheritDoc- */- public function getCreditTransactionGroup(Account $account): ?TransactionGroup- {- $journal = TransactionJournal- ::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')- ->where('transactions.account_id', $account->id)- ->transactionTypes([TransactionType::LIABILITY_CREDIT])- ->first(['transaction_journals.*']);- if (null === $journal) {- return null;- }-- return $journal->transactionGroup;- }-- /**- * @inheritDoc- */- public function findByAccountNumber(string $number, array $types): ?Account- {- $dbQuery = $this->user- ->accounts()- ->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')- ->where('accounts.active', true)- ->where(- function (EloquentBuilder $q1) use ($number) {- $json = json_encode($number);- $q1->where('account_meta.name', '=', 'account_number');- $q1->where('account_meta.data', '=', $json);- }- );-- if (!empty($types)) {- $dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');- $dbQuery->whereIn('account_types.type', $types);- }-- return $dbQuery->first(['accounts.*']);- }-}diff --git a/app/Repositories/Account/AccountRepositoryInterface.php b/app/Repositories/Account/AccountRepositoryInterface.phpindex 2985643d99..8f585ad173 100644--- a/app/Repositories/Account/AccountRepositoryInterface.php+++ b/app/Repositories/Account/AccountRepositoryInterface.php@@ -66,6 +66,13 @@ interface AccountRepositoryInterface*/public function expandWithDoubles(Collection $accounts): Collection;+ /**+ * @param int $accountId+ *+ * @return Account|null+ */+ public function find(int $accountId): ?Account;+/*** @param string $number* @param array $types@@ -90,13 +97,6 @@ interface AccountRepositoryInterface*/public function findByName(string $name, array $types): ?Account;- /**- * @param int $accountId- *- * @return Account|null- */- public function find(int $accountId): ?Account;-/*** @param Account $account*@@ -147,6 +147,13 @@ interface AccountRepositoryInterface*/public function getCashAccount(): Account;+ /**+ * @param Account $account+ *+ * @return TransactionGroup|null+ */+ public function getCreditTransactionGroup(Account $account): ?TransactionGroup;+/*** @param array $types*@@ -208,13 +215,6 @@ interface AccountRepositoryInterface*/public function getOpeningBalanceDate(Account $account): ?string;- /**- * @param Account $account- *- * @return TransactionGroup|null- */- public function getCreditTransactionGroup(Account $account): ?TransactionGroup;-/*** @param Account $account*diff --git a/app/Repositories/Account/OperationsRepositoryInterface.php b/app/Repositories/Account/OperationsRepositoryInterface.phpindex 86ccdae393..a8cc6db89b 100644--- a/app/Repositories/Account/OperationsRepositoryInterface.php+++ b/app/Repositories/Account/OperationsRepositoryInterface.php@@ -79,7 +79,7 @@ interface OperationsRepositoryInterface): array;/**- * Sum of withdrawal journals in period for a set of accounts, grouped per source / currency. Amounts are always negative.+ * Sum of withdrawal journals in period for a set of accounts, grouped per destination / currency. Amounts are always negative.** @param Carbon $start* @param Carbon $end@@ -89,12 +89,12 @@ interface OperationsRepositoryInterface** @return array*/- public function sumExpensesBySource(+ public function sumExpensesByDestination(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $expense = null, ?TransactionCurrency $currency = null): array;/**- * Sum of withdrawal journals in period for a set of accounts, grouped per destination / currency. Amounts are always negative.+ * Sum of withdrawal journals in period for a set of accounts, grouped per source / currency. Amounts are always negative.** @param Carbon $start* @param Carbon $end@@ -104,7 +104,7 @@ interface OperationsRepositoryInterface** @return array*/- public function sumExpensesByDestination(+ public function sumExpensesBySource(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $expense = null, ?TransactionCurrency $currency = null): array;@@ -133,7 +133,8 @@ interface OperationsRepositoryInterface** @return array*/- public function sumIncomeByDestination(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $revenue = null, ?TransactionCurrency $currency = null+ public function sumIncomeByDestination(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $revenue = null,+ ?TransactionCurrency $currency = null): array;/**@@ -147,7 +148,8 @@ interface OperationsRepositoryInterface** @return array*/- public function sumIncomeBySource(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $revenue = null, ?TransactionCurrency $currency = null+ public function sumIncomeBySource(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $revenue = null,+ ?TransactionCurrency $currency = null): array;/**diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.phpindex 482448deda..3edc745aaa 100644--- a/app/Repositories/Bill/BillRepository.php+++ b/app/Repositories/Bill/BillRepository.php@@ -41,6 +41,7 @@ use FireflyIII\User;use Illuminate\Database\Query\JoinClause;use Illuminate\Pagination\LengthAwarePaginator;use Illuminate\Support\Collection;+use JsonException;use Log;use Storage;@@ -623,7 +624,7 @@ class BillRepository implements BillRepositoryInterface* @param Carbon $date** @return Carbon- * @throws \JsonException+ * @throws JsonException*/public function nextDateMatch(Bill $bill, Carbon $date): Carbon{@@ -652,7 +653,7 @@ class BillRepository implements BillRepositoryInterface* @param Carbon $date** @return Carbon- * @throws \JsonException+ * @throws JsonException*/public function nextExpectedMatch(Bill $bill, Carbon $date): Carbon{diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.phpindex 706a9632c8..0a189ba555 100644--- a/app/Repositories/Budget/BudgetRepository.php+++ b/app/Repositories/Budget/BudgetRepository.php@@ -425,6 +425,48 @@ class BudgetRepository implements BudgetRepositoryInterfacereturn $budget;}+ /**+ * @param string $oldName+ * @param string $newName+ */+ private function updateRuleActions(string $oldName, string $newName): void+ {+ $types = ['set_budget',];+ $actions = RuleAction::leftJoin('rules', 'rules.id', '=', 'rule_actions.rule_id')+ ->where('rules.user_id', $this->user->id)+ ->whereIn('rule_actions.action_type', $types)+ ->where('rule_actions.action_value', $oldName)+ ->get(['rule_actions.*']);+ Log::debug(sprintf('Found %d actions to update.', $actions->count()));+ /** @var RuleAction $action */+ foreach ($actions as $action) {+ $action->action_value = $newName;+ $action->save();+ Log::debug(sprintf('Updated action %d: %s', $action->id, $action->action_value));+ }+ }++ /**+ * @param string $oldName+ * @param string $newName+ */+ private function updateRuleTriggers(string $oldName, string $newName): void+ {+ $types = ['budget_is',];+ $triggers = RuleTrigger::leftJoin('rules', 'rules.id', '=', 'rule_triggers.rule_id')+ ->where('rules.user_id', $this->user->id)+ ->whereIn('rule_triggers.trigger_type', $types)+ ->where('rule_triggers.trigger_value', $oldName)+ ->get(['rule_triggers.*']);+ Log::debug(sprintf('Found %d triggers to update.', $triggers->count()));+ /** @var RuleTrigger $trigger */+ foreach ($triggers as $trigger) {+ $trigger->trigger_value = $newName;+ $trigger->save();+ Log::debug(sprintf('Updated trigger %d: %s', $trigger->id, $trigger->trigger_value));+ }+ }+/*** @param Budget $budget* @param array $data@@ -473,46 +515,4 @@ class BudgetRepository implements BudgetRepositoryInterface$autoBudget->save();}-- /**- * @param string $oldName- * @param string $newName- */- private function updateRuleActions(string $oldName, string $newName): void- {- $types = ['set_budget',];- $actions = RuleAction::leftJoin('rules', 'rules.id', '=', 'rule_actions.rule_id')- ->where('rules.user_id', $this->user->id)- ->whereIn('rule_actions.action_type', $types)- ->where('rule_actions.action_value', $oldName)- ->get(['rule_actions.*']);- Log::debug(sprintf('Found %d actions to update.', $actions->count()));- /** @var RuleAction $action */- foreach ($actions as $action) {- $action->action_value = $newName;- $action->save();- Log::debug(sprintf('Updated action %d: %s', $action->id, $action->action_value));- }- }-- /**- * @param string $oldName- * @param string $newName- */- private function updateRuleTriggers(string $oldName, string $newName): void- {- $types = ['budget_is',];- $triggers = RuleTrigger::leftJoin('rules', 'rules.id', '=', 'rule_triggers.rule_id')- ->where('rules.user_id', $this->user->id)- ->whereIn('rule_triggers.trigger_type', $types)- ->where('rule_triggers.trigger_value', $oldName)- ->get(['rule_triggers.*']);- Log::debug(sprintf('Found %d triggers to update.', $triggers->count()));- /** @var RuleTrigger $trigger */- foreach ($triggers as $trigger) {- $trigger->trigger_value = $newName;- $trigger->save();- Log::debug(sprintf('Updated trigger %d: %s', $trigger->id, $trigger->trigger_value));- }- }}diff --git a/app/Repositories/Budget/OperationsRepository.php b/app/Repositories/Budget/OperationsRepository.phpindex 5b6686a7e0..ea82a15aa0 100644--- a/app/Repositories/Budget/OperationsRepository.php+++ b/app/Repositories/Budget/OperationsRepository.php@@ -347,6 +347,17 @@ class OperationsRepository implements OperationsRepositoryInterfacereturn $array;}+ /**+ * @return Collection+ */+ private function getBudgets(): Collection+ {+ /** @var BudgetRepositoryInterface $repos */+ $repos = app(BudgetRepositoryInterface::class);++ return $repos->getActiveBudgets();+ }+/*** For now, simply refer to whichever repository holds this function.* See reference nr. 14@@ -364,15 +375,4 @@ class OperationsRepository implements OperationsRepositoryInterfacereturn $blRepository->getBudgetLimits($budget, $start, $end);}-- /**- * @return Collection- */- private function getBudgets(): Collection- {- /** @var BudgetRepositoryInterface $repos */- $repos = app(BudgetRepositoryInterface::class);-- return $repos->getActiveBudgets();- }}diff --git a/app/Repositories/Category/CategoryRepository.php b/app/Repositories/Category/CategoryRepository.phpindex 30bec9642b..c94a7be944 100644--- a/app/Repositories/Category/CategoryRepository.php+++ b/app/Repositories/Category/CategoryRepository.php@@ -78,6 +78,18 @@ class CategoryRepository implements CategoryRepositoryInterface}}+ /**+ * Find a category or return NULL+ *+ * @param int $categoryId+ *+ * @return Category|null+ */+ public function find(int $categoryId): ?Category+ {+ return $this->user->categories()->find($categoryId);+ }+/*** Find a category.*@@ -118,18 +130,6 @@ class CategoryRepository implements CategoryRepositoryInterfacereturn $result;}- /**- * Find a category or return NULL- *- * @param int $categoryId- *- * @return Category|null- */- public function find(int $categoryId): ?Category- {- return $this->user->categories()->find($categoryId);- }-/*** @param Category $category*diff --git a/app/Repositories/Category/CategoryRepositoryInterface.php b/app/Repositories/Category/CategoryRepositoryInterface.phpindex 52966d31fd..007153ba61 100644--- a/app/Repositories/Category/CategoryRepositoryInterface.php+++ b/app/Repositories/Category/CategoryRepositoryInterface.php@@ -46,6 +46,15 @@ interface CategoryRepositoryInterface*/public function destroyAll(): void;+ /**+ * Find a category or return NULL+ *+ * @param int $categoryId+ *+ * @return Category|null+ */+ public function find(int $categoryId): ?Category;+/*** Find a category.*@@ -63,15 +72,6 @@ interface CategoryRepositoryInterface*/public function findCategory(?int $categoryId, ?string $categoryName): ?Category;- /**- * Find a category or return NULL- *- * @param int $categoryId- *- * @return Category|null- */- public function find(int $categoryId): ?Category;-/*** @param Category $category*diff --git a/app/Repositories/Category/NoCategoryRepository.php b/app/Repositories/Category/NoCategoryRepository.phpindex 73e2d28e6a..d24e528f8b 100644--- a/app/Repositories/Category/NoCategoryRepository.php+++ b/app/Repositories/Category/NoCategoryRepository.php@@ -22,6 +22,7 @@declare(strict_types=1);namespace FireflyIII\Repositories\Category;+use Carbon\Carbon;use FireflyIII\Helpers\Collector\GroupCollectorInterface;use FireflyIII\Models\TransactionType;diff --git a/app/Repositories/Category/NoCategoryRepositoryInterface.php b/app/Repositories/Category/NoCategoryRepositoryInterface.phpindex 5285ffea95..c1835114b5 100644--- a/app/Repositories/Category/NoCategoryRepositoryInterface.php+++ b/app/Repositories/Category/NoCategoryRepositoryInterface.php@@ -22,6 +22,7 @@declare(strict_types=1);namespace FireflyIII\Repositories\Category;+use Carbon\Carbon;use FireflyIII\User;use Illuminate\Support\Collection;diff --git a/app/Repositories/Category/OperationsRepository.php b/app/Repositories/Category/OperationsRepository.phpindex 3b7319a049..9e9af1504d 100644--- a/app/Repositories/Category/OperationsRepository.php+++ b/app/Repositories/Category/OperationsRepository.php@@ -22,6 +22,7 @@declare(strict_types=1);namespace FireflyIII\Repositories\Category;+use Carbon\Carbon;use FireflyIII\Helpers\Collector\GroupCollectorInterface;use FireflyIII\Models\TransactionType;@@ -98,7 +99,7 @@ class OperationsRepository implements OperationsRepositoryInterface// add journal to array:// only a subset of the fields.- $journalId = (int)$journal['transaction_journal_id'];+ $journalId = (int)$journal['transaction_journal_id'];$array[$currencyId]['categories'][$categoryId]['transaction_journals'][$journalId] = ['amount' => app('steam')->negative($journal['amount']),'date' => $journal['date'],@@ -175,7 +176,7 @@ class OperationsRepository implements OperationsRepositoryInterface// add journal to array:// only a subset of the fields.- $journalId = (int)$journal['transaction_journal_id'];+ $journalId = (int)$journal['transaction_journal_id'];$array[$currencyId]['categories'][$categoryId]['transaction_journals'][$journalId] = ['amount' => app('steam')->positive($journal['amount']),'date' => $journal['date'],diff --git a/app/Repositories/Journal/JournalAPIRepository.php b/app/Repositories/Journal/JournalAPIRepository.phpindex ea86e6f1e2..7bee05f256 100644--- a/app/Repositories/Journal/JournalAPIRepository.php+++ b/app/Repositories/Journal/JournalAPIRepository.php@@ -69,9 +69,9 @@ class JournalAPIRepository implements JournalAPIRepositoryInterfacereturn $set->each(static function (Attachment $attachment) use ($disk) {- $notes = $attachment->notes()->first();+ $notes = $attachment->notes()->first();$attachment->file_exists = $disk->exists($attachment->fileName());- $attachment->notes = $notes ? $notes->text : '';+ $attachment->notes = $notes ? $notes->text : '';return $attachment;}diff --git a/app/Repositories/Journal/JournalCLIRepository.php b/app/Repositories/Journal/JournalCLIRepository.phpindex fd1dd5aa29..8f35ff4b22 100644--- a/app/Repositories/Journal/JournalCLIRepository.php+++ b/app/Repositories/Journal/JournalCLIRepository.php@@ -30,6 +30,7 @@ use FireflyIII\Models\TransactionJournal;use FireflyIII\Support\CacheProperties;use FireflyIII\User;use Illuminate\Support\Collection;+use JsonException;use stdClass;/**@@ -117,7 +118,7 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface* @param string $field** @return null|Carbon- * @throws \JsonException+ * @throws JsonException*/public function getMetaDate(TransactionJournal $journal, string $field): ?Carbon{@@ -129,7 +130,7 @@ class JournalCLIRepository implements JournalCLIRepositoryInterfaceif ($cache->has()) {$result = null;try {- $result = new Carbon($cache->get());+ $result = new Carbon($cache->get());} catch (Exception $e) { // @phpstan-ignore-line// @ignoreException}@@ -161,7 +162,7 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface* @param string $field** @return null|string- * @throws \JsonException+ * @throws JsonException*/public function getMetaField(TransactionJournal $journal, string $field): ?string{@@ -171,7 +172,7 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface$cache->addProperty($field);if ($cache->has()) {- return $cache->get();+ return $cache->get();}$entry = $journal->transactionJournalMeta()->where('name', $field)->first();diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.phpindex 539c63ef59..ab33d71f2f 100644--- a/app/Repositories/Journal/JournalRepository.php+++ b/app/Repositories/Journal/JournalRepository.php@@ -37,6 +37,7 @@ use FireflyIII\Services\Internal\Update\JournalUpdateService;use FireflyIII\Support\CacheProperties;use FireflyIII\User;use Illuminate\Support\Collection;+use JsonException;/*** Class JournalRepository.@@ -68,18 +69,6 @@ class JournalRepository implements JournalRepositoryInterface$service->destroy($journal);}- /**- * @inheritDoc- */- public function findByType(array $types): Collection- {- return $this->user- ->transactionJournals()- ->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')- ->whereIn('transaction_types.type', $types)- ->get(['transaction_journals.*']);- }-/*** Find a specific journal.*@@ -92,6 +81,18 @@ class JournalRepository implements JournalRepositoryInterfacereturn $this->user->transactionJournals()->find($journalId);}+ /**+ * @inheritDoc+ */+ public function findByType(array $types): Collection+ {+ return $this->user+ ->transactionJournals()+ ->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')+ ->whereIn('transaction_types.type', $types)+ ->get(['transaction_journals.*']);+ }+/*** Get users first transaction journal or NULL.*@@ -129,7 +130,7 @@ class JournalRepository implements JournalRepositoryInterface* @param TransactionJournal $journal** @return string- * @throws \JsonException+ * @throws JsonException*/public function getJournalTotal(TransactionJournal $journal): string{@@ -137,7 +138,7 @@ class JournalRepository implements JournalRepositoryInterface$cache->addProperty($journal->id);$cache->addProperty('amount-positive');if ($cache->has()) {- return $cache->get();+ return $cache->get();}// saves on queries:@@ -186,7 +187,7 @@ class JournalRepository implements JournalRepositoryInterface* @param string $field** @return null|Carbon- * @throws \JsonException+ * @throws JsonException*/public function getMetaDateById(int $journalId, string $field): ?Carbon{@@ -196,7 +197,7 @@ class JournalRepository implements JournalRepositoryInterface$cache->addProperty($field);if ($cache->has()) {- return new Carbon($cache->get());+ return new Carbon($cache->get());}$entry = TransactionJournalMeta::where('transaction_journal_id', $journalId)->where('name', $field)->first();diff --git a/app/Repositories/Journal/JournalRepositoryInterface.php b/app/Repositories/Journal/JournalRepositoryInterface.phpindex 0bf2fc4373..0fe9801237 100644--- a/app/Repositories/Journal/JournalRepositoryInterface.php+++ b/app/Repositories/Journal/JournalRepositoryInterface.php@@ -50,13 +50,6 @@ interface JournalRepositoryInterface*/public function destroyJournal(TransactionJournal $journal): void;- /**- * @param array $types- *- * @return Collection- */- public function findByType(array $types): Collection;-/*** See reference nr. 1* Find a specific journal.@@ -67,6 +60,13 @@ interface JournalRepositoryInterface*/public function find(int $journalId): ?TransactionJournal;+ /**+ * @param array $types+ *+ * @return Collection+ */+ public function findByType(array $types): Collection;+/*** Get users very first transaction journal.*diff --git a/app/Repositories/LinkType/LinkTypeRepository.php b/app/Repositories/LinkType/LinkTypeRepository.phpindex 9f19877476..1b43ef17af 100644--- a/app/Repositories/LinkType/LinkTypeRepository.php+++ b/app/Repositories/LinkType/LinkTypeRepository.php@@ -80,6 +80,16 @@ class LinkTypeRepository implements LinkTypeRepositoryInterfacereturn true;}+ /**+ * @param int $linkTypeId+ *+ * @return LinkType|null+ */+ public function find(int $linkTypeId): ?LinkType+ {+ return LinkType::find($linkTypeId);+ }+/*** @param string|null $name*@@ -111,16 +121,6 @@ class LinkTypeRepository implements LinkTypeRepositoryInterfacereturn $count + $opposingCount > 0;}- /**- * @param int $linkTypeId- *- * @return LinkType|null- */- public function find(int $linkTypeId): ?LinkType- {- return LinkType::find($linkTypeId);- }-/*** See if such a link already exists (and get it).*diff --git a/app/Repositories/LinkType/LinkTypeRepositoryInterface.php b/app/Repositories/LinkType/LinkTypeRepositoryInterface.phpindex f805dcb036..17ce2decea 100644--- a/app/Repositories/LinkType/LinkTypeRepositoryInterface.php+++ b/app/Repositories/LinkType/LinkTypeRepositoryInterface.php@@ -55,6 +55,13 @@ interface LinkTypeRepositoryInterface*/public function destroyLink(TransactionJournalLink $link): bool;+ /**+ * @param int $linkTypeId+ *+ * @return LinkType|null+ */+ public function find(int $linkTypeId): ?LinkType;+/*** Find link type by name.*@@ -74,13 +81,6 @@ interface LinkTypeRepositoryInterface*/public function findLink(TransactionJournal $one, TransactionJournal $two): bool;- /**- * @param int $linkTypeId- *- * @return LinkType|null- */- public function find(int $linkTypeId): ?LinkType;-/*** See if such a link already exists (and get it).*diff --git a/app/Repositories/PiggyBank/ModifiesPiggyBanks.php b/app/Repositories/PiggyBank/ModifiesPiggyBanks.phpindex 94056fc3ae..3a631be562 100644--- a/app/Repositories/PiggyBank/ModifiesPiggyBanks.php+++ b/app/Repositories/PiggyBank/ModifiesPiggyBanks.php@@ -88,7 +88,7 @@ trait ModifiesPiggyBanks*/public function canAddAmount(PiggyBank $piggyBank, string $amount): bool{- $today = today(config('app.timezone'));+ $today = today(config('app.timezone'));$leftOnAccount = $this->leftOnAccount($piggyBank, $today);$savedSoFar = (string)$this->getRepetition($piggyBank)->currentamount;$leftToSave = bcsub($piggyBank->targetamount, $savedSoFar);diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.phpindex 7f9b1af72a..62acee3803 100644--- a/app/Repositories/PiggyBank/PiggyBankRepository.php+++ b/app/Repositories/PiggyBank/PiggyBankRepository.php@@ -55,25 +55,25 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface}/**- * Find by name or return NULL.- *- * @param string $name+ * @param int $piggyBankId** @return PiggyBank|null*/- public function findByName(string $name): ?PiggyBank+ public function find(int $piggyBankId): ?PiggyBank{- return $this->user->piggyBanks()->where('piggy_banks.name', $name)->first(['piggy_banks.*']);+ return $this->user->piggyBanks()->find($piggyBankId);}/**- * @param int $piggyBankId+ * Find by name or return NULL.+ *+ * @param string $name** @return PiggyBank|null*/- public function find(int $piggyBankId): ?PiggyBank+ public function findByName(string $name): ?PiggyBank{- return $this->user->piggyBanks()->find($piggyBankId);+ return $this->user->piggyBanks()->where('piggy_banks.name', $name)->first(['piggy_banks.*']);}/**@@ -302,6 +302,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface$currentAmount = $this->getRepetition($piggy)->currentamount ?? '0';$piggy->name = $piggy->name . ' (' . app('amount')->formatAnything($currency, $currentAmount, false) . ')';}+return $set;}diff --git a/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php b/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.phpindex 423c1cea8e..cc0f494b7e 100644--- a/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php+++ b/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php@@ -102,20 +102,20 @@ interface PiggyBankRepositoryInterfacepublic function destroyAll(): void;/**- * Find by name or return NULL.- *- * @param string $name+ * @param int $piggyBankId** @return PiggyBank|null*/- public function findByName(string $name): ?PiggyBank;+ public function find(int $piggyBankId): ?PiggyBank;/**- * @param int $piggyBankId+ * Find by name or return NULL.+ *+ * @param string $name** @return PiggyBank|null*/- public function find(int $piggyBankId): ?PiggyBank;+ public function findByName(string $name): ?PiggyBank;/*** @param int|null $piggyBankIddiff --git a/app/Repositories/Recurring/RecurringRepository.php b/app/Repositories/Recurring/RecurringRepository.phpindex 7cddb6a474..c0610fee8d 100644--- a/app/Repositories/Recurring/RecurringRepository.php+++ b/app/Repositories/Recurring/RecurringRepository.php@@ -132,15 +132,15 @@ class RecurringRepository implements RecurringRepositoryInterface** @param RecurrenceTransaction $recTransaction*- * @return null|string+ * @return null|int*/- public function getCategoryName(RecurrenceTransaction $recTransaction): ?string+ public function getCategoryId(RecurrenceTransaction $recTransaction): ?int{$return = '';/** @var RecurrenceTransactionMeta $meta */foreach ($recTransaction->recurrenceTransactionMeta as $meta) {- if ('category_name' === $meta->name) {- $return = (string)$meta->value;+ if ('category_id' === $meta->name) {+ $return = (int)$meta->value;}}@@ -152,15 +152,15 @@ class RecurringRepository implements RecurringRepositoryInterface** @param RecurrenceTransaction $recTransaction*- * @return null|int+ * @return null|string*/- public function getCategoryId(RecurrenceTransaction $recTransaction): ?int+ public function getCategoryName(RecurrenceTransaction $recTransaction): ?string{$return = '';/** @var RecurrenceTransactionMeta $meta */foreach ($recTransaction->recurrenceTransactionMeta as $meta) {- if ('category_id' === $meta->name) {- $return = (int)$meta->value;+ if ('category_name' === $meta->name) {+ $return = (string)$meta->value;}}diff --git a/app/Repositories/Recurring/RecurringRepositoryInterface.php b/app/Repositories/Recurring/RecurringRepositoryInterface.phpindex 6d9e6a36ff..347bc79448 100644--- a/app/Repositories/Recurring/RecurringRepositoryInterface.php+++ b/app/Repositories/Recurring/RecurringRepositoryInterface.php@@ -31,6 +31,7 @@ use FireflyIII\Models\RecurrenceTransaction;use FireflyIII\User;use Illuminate\Pagination\LengthAwarePaginator;use Illuminate\Support\Collection;+/*** Interface RecurringRepositoryInterface*@@ -77,18 +78,18 @@ interface RecurringRepositoryInterface** @param RecurrenceTransaction $recTransaction*- * @return null|string+ * @return null|int*/- public function getCategoryName(RecurrenceTransaction $recTransaction): ?string;+ public function getCategoryId(RecurrenceTransaction $recTransaction): ?int;/*** Get the category from a recurring transaction transaction.** @param RecurrenceTransaction $recTransaction*- * @return null|int+ * @return null|string*/- public function getCategoryId(RecurrenceTransaction $recTransaction): ?int;+ public function getCategoryName(RecurrenceTransaction $recTransaction): ?string;/*** Returns the count of journals created for this recurrence, possibly limited by time.diff --git a/app/Repositories/RuleGroup/RuleGroupRepository.php b/app/Repositories/RuleGroup/RuleGroupRepository.phpindex 253f93b685..f4b76585b6 100644--- a/app/Repositories/RuleGroup/RuleGroupRepository.php+++ b/app/Repositories/RuleGroup/RuleGroupRepository.php@@ -190,26 +190,15 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface->get(['rules.*']);}- /**- * @return int- */- public function getHighestOrderRuleGroup(): int- {- $entry = $this->user->ruleGroups()->max('order');-- return (int)$entry;- }-/*** @param string|null $filter** @return Collection*/- public function getRuleGroupsWithRules(?string $filter): Collection+ public function getAllRuleGroupsWithRules(?string $filter): Collection{$groups = $this->user->ruleGroups()->orderBy('order', 'ASC')- ->where('active', true)->with(['rules' => static function (HasMany $query) {@@ -253,15 +242,26 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface);}+ /**+ * @return int+ */+ public function getHighestOrderRuleGroup(): int+ {+ $entry = $this->user->ruleGroups()->max('order');++ return (int)$entry;+ }+/*** @param string|null $filter** @return Collection*/- public function getAllRuleGroupsWithRules(?string $filter): Collection+ public function getRuleGroupsWithRules(?string $filter): Collection{$groups = $this->user->ruleGroups()->orderBy('order', 'ASC')+ ->where('active', true)->with(['rules' => static function (HasMany $query) {diff --git a/app/Repositories/RuleGroup/RuleGroupRepositoryInterface.php b/app/Repositories/RuleGroup/RuleGroupRepositoryInterface.phpindex b3f3b90985..06f8e329a3 100644--- a/app/Repositories/RuleGroup/RuleGroupRepositoryInterface.php+++ b/app/Repositories/RuleGroup/RuleGroupRepositoryInterface.php@@ -103,25 +103,25 @@ interface RuleGroupRepositoryInterfacepublic function getActiveUpdateRules(RuleGroup $group): Collection;/**- * @return int- */- public function getHighestOrderRuleGroup(): int;-- /**+ * Also inactive groups.+ ** @param string|null $filter** @return Collection*/- public function getRuleGroupsWithRules(?string $filter): Collection;+ public function getAllRuleGroupsWithRules(?string $filter): Collection;++ /**+ * @return int+ */+ public function getHighestOrderRuleGroup(): int;/**- * Also inactive groups.- ** @param string|null $filter** @return Collection*/- public function getAllRuleGroupsWithRules(?string $filter): Collection;+ public function getRuleGroupsWithRules(?string $filter): Collection;/*** @param RuleGroup $groupdiff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.phpindex bd05564f1b..616932d492 100644--- a/app/Repositories/Tag/TagRepository.php+++ b/app/Repositories/Tag/TagRepository.php@@ -100,23 +100,23 @@ class TagRepository implements TagRepositoryInterface}/**- * @param string $tag+ * @param int $tagId** @return Tag|null*/- public function findByTag(string $tag): ?Tag+ public function find(int $tagId): ?Tag{- return $this->user->tags()->where('tag', $tag)->first();+ return $this->user->tags()->find($tagId);}/**- * @param int $tagId+ * @param string $tag** @return Tag|null*/- public function find(int $tagId): ?Tag+ public function findByTag(string $tag): ?Tag{- return $this->user->tags()->find($tagId);+ return $this->user->tags()->where('tag', $tag)->first();}/**diff --git a/app/Repositories/Tag/TagRepositoryInterface.php b/app/Repositories/Tag/TagRepositoryInterface.phpindex d4e550623f..1a546821b3 100644--- a/app/Repositories/Tag/TagRepositoryInterface.php+++ b/app/Repositories/Tag/TagRepositoryInterface.php@@ -63,18 +63,18 @@ interface TagRepositoryInterfacepublic function expenseInPeriod(Tag $tag, Carbon $start, Carbon $end): array;/**- * @param string $tag+ * @param int $tagId** @return Tag|null*/- public function findByTag(string $tag): ?Tag;+ public function find(int $tagId): ?Tag;/**- * @param int $tagId+ * @param string $tag** @return Tag|null*/- public function find(int $tagId): ?Tag;+ public function findByTag(string $tag): ?Tag;/*** @param Tag $tagdiff --git a/app/Repositories/TransactionGroup/TransactionGroupRepository.php b/app/Repositories/TransactionGroup/TransactionGroupRepository.phpindex 04b76655ec..cec90bef6d 100644--- a/app/Repositories/TransactionGroup/TransactionGroupRepository.php+++ b/app/Repositories/TransactionGroup/TransactionGroupRepository.php@@ -22,6 +22,7 @@declare(strict_types=1);namespace FireflyIII\Repositories\TransactionGroup;+use Carbon\Carbon;use DB;use Exception;@@ -359,12 +360,12 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterfacereturn $factory->create($data);} catch (DuplicateTransactionException $e) {Log::warning('Group repository caught group factory with a duplicate exception!');- throw new DuplicateTransactionException($e->getMessage(),0, $e);+ throw new DuplicateTransactionException($e->getMessage(), 0, $e);} catch (FireflyException $e) {Log::warning('Group repository caught group factory with an exception!');Log::error($e->getMessage());Log::error($e->getTraceAsString());- throw new FireflyException($e->getMessage(),0, $e);+ throw new FireflyException($e->getMessage(), 0, $e);}}@@ -380,6 +381,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface{/** @var GroupUpdateService $service */$service = app(GroupUpdateService::class);+return $service->update($transactionGroup, $data);}diff --git a/app/Repositories/User/UserRepository.php b/app/Repositories/User/UserRepository.phpindex 45232e4af8..ef13628a1f 100644--- a/app/Repositories/User/UserRepository.php+++ b/app/Repositories/User/UserRepository.php@@ -170,23 +170,23 @@ class UserRepository implements UserRepositoryInterface}/**- * @param string $email+ * @param int $userId** @return User|null*/- public function findByEmail(string $email): ?User+ public function find(int $userId): ?User{- return User::where('email', $email)->first();+ return User::find($userId);}/**- * @param int $userId+ * @param string $email** @return User|null*/- public function find(int $userId): ?User+ public function findByEmail(string $email): ?User{- return User::find($userId);+ return User::where('email', $email)->first();}/**diff --git a/app/Repositories/User/UserRepositoryInterface.php b/app/Repositories/User/UserRepositoryInterface.phpindex 5eafdbab9f..6cc9122f42 100644--- a/app/Repositories/User/UserRepositoryInterface.php+++ b/app/Repositories/User/UserRepositoryInterface.php@@ -103,18 +103,18 @@ interface UserRepositoryInterfacepublic function destroy(User $user): bool;/**- * @param string $email+ * @param int $userId** @return User|null*/- public function findByEmail(string $email): ?User;+ public function find(int $userId): ?User;/**- * @param int $userId+ * @param string $email** @return User|null*/- public function find(int $userId): ?User;+ public function findByEmail(string $email): ?User;/*** Returns the first user in the DB. Generally only works when there is just one.diff --git a/app/Rules/IsDateOrTime.php b/app/Rules/IsDateOrTime.phpindex 44f47a032f..6eee28a3c7 100644--- a/app/Rules/IsDateOrTime.php+++ b/app/Rules/IsDateOrTime.php@@ -69,7 +69,7 @@ class IsDateOrTime implements RuleLog::error(sprintf('"%s" is not a valid date: %s', $value, $e->getMessage()));return false;- } catch(InvalidFormatException $e) {+ } catch (InvalidFormatException $e) {Log::error(sprintf('"%s" is of an invalid format: %s', $value, $e->getMessage()));return false;@@ -84,7 +84,7 @@ class IsDateOrTime implements RuleLog::error(sprintf('"%s" is not a valid date or time: %s', $value, $e->getMessage()));return false;- } catch(InvalidFormatException $e) {+ } catch (InvalidFormatException $e) {Log::error(sprintf('"%s" is of an invalid format: %s', $value, $e->getMessage()));return false;diff --git a/app/Rules/IsDuplicateTransaction.php b/app/Rules/IsDuplicateTransaction.phpindex 44ffafb6b3..2bfb59089d 100644--- a/app/Rules/IsDuplicateTransaction.php+++ b/app/Rules/IsDuplicateTransaction.php@@ -22,6 +22,7 @@declare(strict_types=1);namespace FireflyIII\Rules;+use Illuminate\Contracts\Validation\Rule;/**diff --git a/app/Rules/IsTransferAccount.php b/app/Rules/IsTransferAccount.phpindex cca24a5b62..ec3d9fbf52 100644--- a/app/Rules/IsTransferAccount.php+++ b/app/Rules/IsTransferAccount.php@@ -23,6 +23,7 @@declare(strict_types=1);namespace FireflyIII\Rules;+use FireflyIII\Models\TransactionType;use FireflyIII\Validation\AccountValidator;use Illuminate\Contracts\Validation\Rule;diff --git a/app/Rules/IsValidAttachmentModel.php b/app/Rules/IsValidAttachmentModel.phpindex cdaaab047c..d2e0349693 100644--- a/app/Rules/IsValidAttachmentModel.php+++ b/app/Rules/IsValidAttachmentModel.php@@ -22,6 +22,7 @@declare(strict_types=1);namespace FireflyIII\Rules;+use FireflyIII\Models\Account;use FireflyIII\Models\Bill;use FireflyIII\Models\Budget;diff --git a/app/Rules/IsValidBulkClause.php b/app/Rules/IsValidBulkClause.phpindex b01201c6c9..7a8bda7692 100644--- a/app/Rules/IsValidBulkClause.php+++ b/app/Rules/IsValidBulkClause.php@@ -33,8 +33,8 @@ use JsonException;*/class IsValidBulkClause implements Rule{- private array $rules;private string $error;+ private array $rules;/*** @param string $type@@ -45,6 +45,14 @@ class IsValidBulkClause implements Rule$this->error = (string)trans('firefly.belongs_user');}+ /**+ * @return string+ */+ public function message(): string+ {+ return $this->error;+ }+/*** @param string $attribute* @param mixed $value@@ -57,15 +65,8 @@ class IsValidBulkClause implements Ruleif (false === $result) {return false;}- return true;- }- /**- * @return string- */- public function message(): string- {- return $this->error;+ return true;}/**@@ -106,7 +107,7 @@ class IsValidBulkClause implements Rule'value' => $this->rules[$clause][$arrayKey],]);if ($validator->fails()) {- $this->error = sprintf('%s: %s: %s',$clause, $arrayKey, join(', ', ($validator->errors()->get('value'))));+ $this->error = sprintf('%s: %s: %s', $clause, $arrayKey, join(', ', ($validator->errors()->get('value'))));return false;}diff --git a/app/Rules/LessThanPiggyTarget.php b/app/Rules/LessThanPiggyTarget.phpindex 914667a22c..e19589ea74 100644--- a/app/Rules/LessThanPiggyTarget.php+++ b/app/Rules/LessThanPiggyTarget.php@@ -21,6 +21,7 @@*/declare(strict_types=1);+namespace FireflyIII\Rules;use Illuminate\Contracts\Validation\Rule;diff --git a/app/Rules/UniqueAccountNumber.php b/app/Rules/UniqueAccountNumber.phpindex dd5c1c2554..f8b4102c6b 100644--- a/app/Rules/UniqueAccountNumber.php+++ b/app/Rules/UniqueAccountNumber.php@@ -87,10 +87,10 @@ class UniqueAccountNumber implements Rulepublic function passes($attribute, $value): bool{if (!auth()->check()) {- return true;+ return true;}if (null === $this->expectedType) {- return true;+ return true;}$maxCounts = $this->getMaxOccurrences();diff --git a/app/Rules/UniqueIban.php b/app/Rules/UniqueIban.phpindex 7958170cff..e6e37f98de 100644--- a/app/Rules/UniqueIban.php+++ b/app/Rules/UniqueIban.php@@ -84,10 +84,10 @@ class UniqueIban implements Rulepublic function passes($attribute, $value): bool{if (!auth()->check()) {- return true;+ return true;}if (null === $this->expectedType) {- return true;+ return true;}$maxCounts = $this->getMaxOccurrences();diff --git a/app/Rules/ValidJournals.php b/app/Rules/ValidJournals.phpindex 3482fc7579..888e5697c7 100644--- a/app/Rules/ValidJournals.php+++ b/app/Rules/ValidJournals.php@@ -21,6 +21,7 @@*/declare(strict_types=1);+namespace FireflyIII\Rules;use FireflyIII\Models\TransactionJournal;diff --git a/app/Rules/ValidRecurrenceRepetitionValue.php b/app/Rules/ValidRecurrenceRepetitionValue.phpindex ae9547d777..14ba5cca50 100644--- a/app/Rules/ValidRecurrenceRepetitionValue.php+++ b/app/Rules/ValidRecurrenceRepetitionValue.php@@ -22,6 +22,7 @@declare(strict_types=1);namespace FireflyIII\Rules;+use Carbon\Carbon;use Illuminate\Contracts\Validation\Rule;use InvalidArgumentException;diff --git a/app/Services/Internal/Destroy/AccountDestroyService.php b/app/Services/Internal/Destroy/AccountDestroyService.phpindex cc557d541f..aed55bb705 100644--- a/app/Services/Internal/Destroy/AccountDestroyService.php+++ b/app/Services/Internal/Destroy/AccountDestroyService.php@@ -41,7 +41,7 @@ use stdClass;class AccountDestroyService{/**- * @param Account $account+ * @param Account $account* @param Account|null $moveTo** @return voiddiff --git a/app/Services/Internal/Support/AccountServiceTrait.php b/app/Services/Internal/Support/AccountServiceTrait.phpindex 5fdd24e19e..4ce0545519 100644--- a/app/Services/Internal/Support/AccountServiceTrait.php+++ b/app/Services/Internal/Support/AccountServiceTrait.php@@ -101,7 +101,7 @@ trait AccountServiceTrait/*** Update meta data for account. Depends on type which fields are valid.*-* See reference nr. 97+ * See reference nr. 97** @param Account $account* @param array $data@@ -207,22 +207,95 @@ trait AccountServiceTrait}/**- * Delete TransactionGroup with opening balance in it.- ** @param Account $account+ * @param array $data+ *+ * @return TransactionGroup+ * @throws FireflyException+ * @deprecated*/- protected function deleteOBGroup(Account $account): void+ protected function createOBGroup(Account $account, array $data): TransactionGroup{- Log::debug(sprintf('deleteOB() for account #%d', $account->id));- $openingBalanceGroup = $this->getOBGroup($account);+ Log::debug('Now going to create an OB group.');+ $language = app('preferences')->getForUser($account->user, 'language', 'en_US')->data;+ $sourceId = null;+ $sourceName = null;+ $destId = null;+ $destName = null;+ $amount = array_key_exists('opening_balance', $data) ? $data['opening_balance'] : '0';- // opening balance data? update it!- if (null !== $openingBalanceGroup) {- Log::debug('Opening balance journal found, delete journal.');- /** @var TransactionGroupDestroyService $service */- $service = app(TransactionGroupDestroyService::class);- $service->destroy($openingBalanceGroup);+ // amount is positive.+ if (1 === bccomp($amount, '0')) {+ Log::debug(sprintf('Amount is %s, which is positive. Source is a new IB account, destination is #%d', $amount, $account->id));+ $sourceName = trans('firefly.initial_balance_description', ['account' => $account->name], $language);+ $destId = $account->id;+ }+ // amount is not positive+ if (-1 === bccomp($amount, '0')) {+ Log::debug(sprintf('Amount is %s, which is negative. Destination is a new IB account, source is #%d', $amount, $account->id));+ $destName = trans('firefly.initial_balance_account', ['account' => $account->name], $language);+ $sourceId = $account->id;}+ // amount is 0+ if (0 === bccomp($amount, '0')) {+ Log::debug('Amount is zero, so will not make an OB group.');+ throw new FireflyException('Amount for new opening balance was unexpectedly 0.');+ }++ // make amount positive, regardless:+ $amount = app('steam')->positive($amount);++ // get or grab currency:+ $currency = $this->accountRepository->getAccountCurrency($account);+ if (null === $currency) {+ $currency = app('default')->getDefaultCurrencyByUser($account->user);+ }++ // submit to factory:+ $submission = [+ 'group_title' => null,+ 'user' => $account->user_id,+ 'transactions' => [+ [+ 'type' => 'Opening balance',+ 'date' => $data['opening_balance_date'],+ 'source_id' => $sourceId,+ 'source_name' => $sourceName,+ 'destination_id' => $destId,+ 'destination_name' => $destName,+ 'user' => $account->user_id,+ 'currency_id' => $currency->id,+ 'order' => 0,+ 'amount' => $amount,+ 'foreign_amount' => null,+ 'description' => trans('firefly.initial_balance_description', ['account' => $account->name]),+ 'budget_id' => null,+ 'budget_name' => null,+ 'category_id' => null,+ 'category_name' => null,+ 'piggy_bank_id' => null,+ 'piggy_bank_name' => null,+ 'reconciled' => false,+ 'notes' => null,+ 'tags' => [],+ ],+ ],+ ];+ Log::debug('Going for submission in createOBGroup', $submission);++ /** @var TransactionGroupFactory $factory */+ $factory = app(TransactionGroupFactory::class);+ $factory->setUser($account->user);++ try {+ $group = $factory->create($submission);+ } catch (DuplicateTransactionException $e) {+ Log::error($e->getMessage());+ Log::error($e->getTraceAsString());+ throw new FireflyException($e->getMessage(), 0, $e);+ }++ return $group;}/**@@ -244,29 +317,48 @@ trait AccountServiceTrait}/**- * Returns the opening balance group, or NULL if it does not exist.+ * Returns the credit transaction group, or NULL if it does not exist.** @param Account $account** @return TransactionGroup|null*/- protected function getOBGroup(Account $account): ?TransactionGroup+ protected function getCreditTransaction(Account $account): ?TransactionGroup{- return $this->accountRepository->getOpeningBalanceGroup($account);+ Log::debug(sprintf('Now at %s', __METHOD__));++ return $this->accountRepository->getCreditTransactionGroup($account);}/**- * Returns the credit transaction group, or NULL if it does not exist.+ * Delete TransactionGroup with opening balance in it.+ *+ * @param Account $account+ */+ protected function deleteOBGroup(Account $account): void+ {+ Log::debug(sprintf('deleteOB() for account #%d', $account->id));+ $openingBalanceGroup = $this->getOBGroup($account);++ // opening balance data? update it!+ if (null !== $openingBalanceGroup) {+ Log::debug('Opening balance journal found, delete journal.');+ /** @var TransactionGroupDestroyService $service */+ $service = app(TransactionGroupDestroyService::class);+ $service->destroy($openingBalanceGroup);+ }+ }++ /**+ * Returns the opening balance group, or NULL if it does not exist.** @param Account $account** @return TransactionGroup|null*/- protected function getCreditTransaction(Account $account): ?TransactionGroup+ protected function getOBGroup(Account $account): ?TransactionGroup{- Log::debug(sprintf('Now at %s', __METHOD__));-- return $this->accountRepository->getCreditTransactionGroup($account);+ return $this->accountRepository->getOpeningBalanceGroup($account);}/**@@ -293,68 +385,6 @@ trait AccountServiceTraitreturn $currency;}- /**- * Update or create the opening balance group.- * Since opening balance and date can still be empty strings, it may fail.- *- * @param Account $account- * @param string $openingBalance- * @param Carbon $openingBalanceDate- *- * @return TransactionGroup- * @throws FireflyException- */- protected function updateOBGroupV2(Account $account, string $openingBalance, Carbon $openingBalanceDate): TransactionGroup- {- Log::debug(sprintf('Now in %s', __METHOD__));- // create if not exists:- $obGroup = $this->getOBGroup($account);- if (null === $obGroup) {- return $this->createOBGroupV2($account, $openingBalance, $openingBalanceDate);- }-- // if exists, update:- $currency = $this->accountRepository->getAccountCurrency($account);- if (null === $currency) {- $currency = app('default')->getDefaultCurrencyByUser($account->user);- }-- // simply grab the first journal and change it:- $journal = $this->getObJournal($obGroup);- $obTransaction = $this->getOBTransaction($journal, $account);- $accountTransaction = $this->getNotOBTransaction($journal, $account);- $journal->date = $openingBalanceDate;- $journal->transactionCurrency()->associate($currency);--- // if amount is negative:- if (1 === bccomp('0', $openingBalance)) {- // account transaction loses money:- $accountTransaction->amount = app('steam')->negative($openingBalance);- $accountTransaction->transaction_currency_id = $currency->id;-- // OB account transaction gains money- $obTransaction->amount = app('steam')->positive($openingBalance);- $obTransaction->transaction_currency_id = $currency->id;- }- if (-1 === bccomp('0', $openingBalance)) {- // account gains money:- $accountTransaction->amount = app('steam')->positive($openingBalance);- $accountTransaction->transaction_currency_id = $currency->id;-- // OB account loses money:- $obTransaction->amount = app('steam')->negative($openingBalance);- $obTransaction->transaction_currency_id = $currency->id;- }- // save both- $accountTransaction->save();- $obTransaction->save();- $journal->save();- $obGroup->refresh();-- return $obGroup;- }-/*** Create the opposing "credit liability" transaction for credit liabilities.*@@ -408,44 +438,6 @@ trait AccountServiceTraitreturn $clGroup;}- /**-* See reference nr. 98- *- * @param TransactionJournal $journal- * @param Account $account- *- * @return Transaction- * @throws FireflyException- */- private function getOBTransaction(TransactionJournal $journal, Account $account): Transaction- {- /** @var Transaction $transaction */- $transaction = $journal->transactions()->where('account_id', '!=', $account->id)->first();- if (null === $transaction) {- throw new FireflyException(sprintf('Could not get OB transaction for journal #%d', $journal->id));- }-- return $transaction;- }-- /**- * @param TransactionJournal $journal- * @param Account $account- *- * @return Transaction- * @throws FireflyException- */- private function getNotOBTransaction(TransactionJournal $journal, Account $account): Transaction- {- /** @var Transaction $transaction */- $transaction = $journal->transactions()->where('account_id', $account->id)->first();- if (null === $transaction) {- throw new FireflyException(sprintf('Could not get non-OB transaction for journal #%d', $journal->id));- }-- return $transaction;- }-/*** @param Account $account* @param string $openingBalance@@ -454,35 +446,17 @@ trait AccountServiceTrait* @return TransactionGroup* @throws FireflyException*/- protected function createOBGroupV2(Account $account, string $openingBalance, Carbon $openingBalanceDate): TransactionGroup+ protected function createCreditTransaction(Account $account, string $openingBalance, Carbon $openingBalanceDate): TransactionGroup{- Log::debug('Now going to create an OB group.');- $language = app('preferences')->getForUser($account->user, 'language', 'en_US')->data;- $sourceId = null;- $sourceName = null;- $destId = null;- $destName = null;+ Log::debug('Now going to create an createCreditTransaction.');- // amount is positive.- if (1 === bccomp($openingBalance, '0')) {- Log::debug(sprintf('Amount is %s, which is positive. Source is a new IB account, destination is #%d', $openingBalance, $account->id));- $sourceName = trans('firefly.initial_balance_description', ['account' => $account->name], $language);- $destId = $account->id;- }- // amount is not positive- if (-1 === bccomp($openingBalance, '0')) {- Log::debug(sprintf('Amount is %s, which is negative. Destination is a new IB account, source is #%d', $openingBalance, $account->id));- $destName = trans('firefly.initial_balance_account', ['account' => $account->name], $language);- $sourceId = $account->id;- }- // amount is 0if (0 === bccomp($openingBalance, '0')) {- Log::debug('Amount is zero, so will not make an OB group.');- throw new FireflyException('Amount for new opening balance was unexpectedly 0.');+ Log::debug('Amount is zero, so will not make an liability credit group.');+ throw new FireflyException('Amount for new liability credit was unexpectedly 0.');}- // make amount positive, regardless:- $amount = app('steam')->positive($openingBalance);+ $language = app('preferences')->getForUser($account->user, 'language', 'en_US')->data;+ $amount = app('steam')->positive($openingBalance);// get or grab currency:$currency = $this->accountRepository->getAccountCurrency($account);@@ -496,18 +470,18 @@ trait AccountServiceTrait'user' => $account->user_id,'transactions' => [[- 'type' => 'Opening balance',+ 'type' => 'Liability credit','date' => $openingBalanceDate,- 'source_id' => $sourceId,- 'source_name' => $sourceName,- 'destination_id' => $destId,- 'destination_name' => $destName,+ 'source_id' => null,+ 'source_name' => trans('firefly.liability_credit_description', ['account' => $account->name], $language),+ 'destination_id' => $account->id,+ 'destination_name' => null,'user' => $account->user_id,'currency_id' => $currency->id,'order' => 0,'amount' => $amount,'foreign_amount' => null,- 'description' => trans('firefly.initial_balance_description', ['account' => $account->name]),+ 'description' => trans('firefly.liability_credit_description', ['account' => $account->name]),'budget_id' => null,'budget_name' => null,'category_id' => null,@@ -520,7 +494,7 @@ trait AccountServiceTrait],],];- Log::debug('Going for submission in createOBGroupV2', $submission);+ Log::debug('Going for submission in createCreditTransaction', $submission);/** @var TransactionGroupFactory $factory */$factory = app(TransactionGroupFactory::class);@@ -538,6 +512,9 @@ trait AccountServiceTrait}/**+ * Update or create the opening balance group.+ * Since opening balance and date can still be empty strings, it may fail.+ ** @param Account $account* @param string $openingBalance* @param Carbon $openingBalanceDate@@ -545,81 +522,66 @@ trait AccountServiceTrait* @return TransactionGroup* @throws FireflyException*/- protected function createCreditTransaction(Account $account, string $openingBalance, Carbon $openingBalanceDate): TransactionGroup+ protected function updateOBGroupV2(Account $account, string $openingBalance, Carbon $openingBalanceDate): TransactionGroup{- Log::debug('Now going to create an createCreditTransaction.');-- if (0 === bccomp($openingBalance, '0')) {- Log::debug('Amount is zero, so will not make an liability credit group.');- throw new FireflyException('Amount for new liability credit was unexpectedly 0.');+ Log::debug(sprintf('Now in %s', __METHOD__));+ // create if not exists:+ $obGroup = $this->getOBGroup($account);+ if (null === $obGroup) {+ return $this->createOBGroupV2($account, $openingBalance, $openingBalanceDate);}- $language = app('preferences')->getForUser($account->user, 'language', 'en_US')->data;- $amount = app('steam')->positive($openingBalance);-- // get or grab currency:+ // if exists, update:$currency = $this->accountRepository->getAccountCurrency($account);if (null === $currency) {$currency = app('default')->getDefaultCurrencyByUser($account->user);}- // submit to factory:- $submission = [- 'group_title' => null,- 'user' => $account->user_id,- 'transactions' => [- [- 'type' => 'Liability credit',- 'date' => $openingBalanceDate,- 'source_id' => null,- 'source_name' => trans('firefly.liability_credit_description', ['account' => $account->name], $language),- 'destination_id' => $account->id,- 'destination_name' => null,- 'user' => $account->user_id,- 'currency_id' => $currency->id,- 'order' => 0,- 'amount' => $amount,- 'foreign_amount' => null,- 'description' => trans('firefly.liability_credit_description', ['account' => $account->name]),- 'budget_id' => null,- 'budget_name' => null,- 'category_id' => null,- 'category_name' => null,- 'piggy_bank_id' => null,- 'piggy_bank_name' => null,- 'reconciled' => false,- 'notes' => null,- 'tags' => [],- ],- ],- ];- Log::debug('Going for submission in createCreditTransaction', $submission);+ // simply grab the first journal and change it:+ $journal = $this->getObJournal($obGroup);+ $obTransaction = $this->getOBTransaction($journal, $account);+ $accountTransaction = $this->getNotOBTransaction($journal, $account);+ $journal->date = $openingBalanceDate;+ $journal->transactionCurrency()->associate($currency);- /** @var TransactionGroupFactory $factory */- $factory = app(TransactionGroupFactory::class);- $factory->setUser($account->user);- try {- $group = $factory->create($submission);- } catch (DuplicateTransactionException $e) {- Log::error($e->getMessage());- Log::error($e->getTraceAsString());- throw new FireflyException($e->getMessage(), 0, $e);+ // if amount is negative:+ if (1 === bccomp('0', $openingBalance)) {+ // account transaction loses money:+ $accountTransaction->amount = app('steam')->negative($openingBalance);+ $accountTransaction->transaction_currency_id = $currency->id;++ // OB account transaction gains money+ $obTransaction->amount = app('steam')->positive($openingBalance);+ $obTransaction->transaction_currency_id = $currency->id;}+ if (-1 === bccomp('0', $openingBalance)) {+ // account gains money:+ $accountTransaction->amount = app('steam')->positive($openingBalance);+ $accountTransaction->transaction_currency_id = $currency->id;- return $group;- }+ // OB account loses money:+ $obTransaction->amount = app('steam')->negative($openingBalance);+ $obTransaction->transaction_currency_id = $currency->id;+ }+ // save both+ $accountTransaction->save();+ $obTransaction->save();+ $journal->save();+ $obGroup->refresh();+ return $obGroup;+ }/*** @param Account $account- * @param array $data+ * @param string $openingBalance+ * @param Carbon $openingBalanceDate** @return TransactionGroup* @throws FireflyException- * @deprecated*/- protected function createOBGroup(Account $account, array $data): TransactionGroup+ protected function createOBGroupV2(Account $account, string $openingBalance, Carbon $openingBalanceDate): TransactionGroup{Log::debug('Now going to create an OB group.');$language = app('preferences')->getForUser($account->user, 'language', 'en_US')->data;@@ -627,28 +589,27 @@ trait AccountServiceTrait$sourceName = null;$destId = null;$destName = null;- $amount = array_key_exists('opening_balance', $data) ? $data['opening_balance'] : '0';// amount is positive.- if (1 === bccomp($amount, '0')) {- Log::debug(sprintf('Amount is %s, which is positive. Source is a new IB account, destination is #%d', $amount, $account->id));+ if (1 === bccomp($openingBalance, '0')) {+ Log::debug(sprintf('Amount is %s, which is positive. Source is a new IB account, destination is #%d', $openingBalance, $account->id));$sourceName = trans('firefly.initial_balance_description', ['account' => $account->name], $language);$destId = $account->id;}// amount is not positive- if (-1 === bccomp($amount, '0')) {- Log::debug(sprintf('Amount is %s, which is negative. Destination is a new IB account, source is #%d', $amount, $account->id));+ if (-1 === bccomp($openingBalance, '0')) {+ Log::debug(sprintf('Amount is %s, which is negative. Destination is a new IB account, source is #%d', $openingBalance, $account->id));$destName = trans('firefly.initial_balance_account', ['account' => $account->name], $language);$sourceId = $account->id;}// amount is 0- if (0 === bccomp($amount, '0')) {+ if (0 === bccomp($openingBalance, '0')) {Log::debug('Amount is zero, so will not make an OB group.');throw new FireflyException('Amount for new opening balance was unexpectedly 0.');}// make amount positive, regardless:- $amount = app('steam')->positive($amount);+ $amount = app('steam')->positive($openingBalance);// get or grab currency:$currency = $this->accountRepository->getAccountCurrency($account);@@ -663,7 +624,7 @@ trait AccountServiceTrait'transactions' => [['type' => 'Opening balance',- 'date' => $data['opening_balance_date'],+ 'date' => $openingBalanceDate,'source_id' => $sourceId,'source_name' => $sourceName,'destination_id' => $destId,@@ -686,7 +647,7 @@ trait AccountServiceTrait],],];- Log::debug('Going for submission in createOBGroup', $submission);+ Log::debug('Going for submission in createOBGroupV2', $submission);/** @var TransactionGroupFactory $factory */$factory = app(TransactionGroupFactory::class);@@ -704,7 +665,7 @@ trait AccountServiceTrait}/**-* See reference nr. 99+ * See reference nr. 99** @param TransactionGroup $group*@@ -721,4 +682,42 @@ trait AccountServiceTraitreturn $journal;}++ /**+ * See reference nr. 98+ *+ * @param TransactionJournal $journal+ * @param Account $account+ *+ * @return Transaction+ * @throws FireflyException+ */+ private function getOBTransaction(TransactionJournal $journal, Account $account): Transaction+ {+ /** @var Transaction $transaction */+ $transaction = $journal->transactions()->where('account_id', '!=', $account->id)->first();+ if (null === $transaction) {+ throw new FireflyException(sprintf('Could not get OB transaction for journal #%d', $journal->id));+ }++ return $transaction;+ }++ /**+ * @param TransactionJournal $journal+ * @param Account $account+ *+ * @return Transaction+ * @throws FireflyException+ */+ private function getNotOBTransaction(TransactionJournal $journal, Account $account): Transaction+ {+ /** @var Transaction $transaction */+ $transaction = $journal->transactions()->where('account_id', $account->id)->first();+ if (null === $transaction) {+ throw new FireflyException(sprintf('Could not get non-OB transaction for journal #%d', $journal->id));+ }++ return $transaction;+ }}diff --git a/app/Services/Internal/Support/BillServiceTrait.php b/app/Services/Internal/Support/BillServiceTrait.phpindex 65c232481c..c992e0b4e7 100644--- a/app/Services/Internal/Support/BillServiceTrait.php+++ b/app/Services/Internal/Support/BillServiceTrait.php@@ -48,9 +48,9 @@ trait BillServiceTraitreturn;}$ruleIds = $bill->user->rules()->get(['id'])->pluck('id')->toArray();- $set = RuleAction::whereIn('rule_id', $ruleIds)- ->where('action_type', 'link_to_bill')- ->where('action_value', $oldName)->get();+ $set = RuleAction::whereIn('rule_id', $ruleIds)+ ->where('action_type', 'link_to_bill')+ ->where('action_value', $oldName)->get();/** @var RuleAction $ruleAction */foreach ($set as $ruleAction) {@@ -59,6 +59,7 @@ trait BillServiceTrait$ruleAction->save();}}+/*** @param Bill $bill* @param string $notediff --git a/app/Services/Internal/Support/CreditRecalculateService.php b/app/Services/Internal/Support/CreditRecalculateService.phpindex 300fda53ae..20d9ba78db 100644--- a/app/Services/Internal/Support/CreditRecalculateService.php+++ b/app/Services/Internal/Support/CreditRecalculateService.php@@ -40,8 +40,8 @@ class CreditRecalculateService{private ?Account $account;private ?TransactionGroup $group;- private array $work;private AccountRepositoryInterface $repository;+ private array $work;/*** CreditRecalculateService constructor.@@ -79,50 +79,6 @@ class CreditRecalculateService$this->processWork();}- /**- *- */- private function processWork(): void- {- $this->repository = app(AccountRepositoryInterface::class);- foreach ($this->work as $account) {- $this->processWorkAccount($account);- }- Log::debug(sprintf('Done with %s', __METHOD__));- }-- /**- * @param Account $account- */- private function processWorkAccount(Account $account): void- {- Log::debug(sprintf('Now in %s(#%d)', __METHOD__, $account->id));-- // get opening balance (if present)- $this->repository->setUser($account->user);- $startOfDebt = $this->repository->getOpeningBalanceAmount($account) ?? '0';- $leftOfDebt = app('steam')->positive($startOfDebt);-- /** @var AccountMetaFactory $factory */- $factory = app(AccountMetaFactory::class);- $factory->crud($account, 'start_of_debt', $startOfDebt);-- // get direction of liability:- $direction = (string)$this->repository->getMetaValue($account, 'liability_direction');-- // now loop all transactions (except opening balance and credit thing)- $transactions = $account->transactions()->get();- /** @var Transaction $transaction */- foreach ($transactions as $transaction) {- $leftOfDebt = $this->processTransaction($account, $direction, $transaction, $leftOfDebt);- }- $factory->crud($account, 'current_debt', $leftOfDebt);--- Log::debug(sprintf('Done with %s(#%d)', __METHOD__, $account->id));- }--/****/@@ -221,19 +177,46 @@ class CreditRecalculateService}/**- * @param Account|null $account+ **/- public function setAccount(?Account $account): void+ private function processWork(): void{- $this->account = $account;+ $this->repository = app(AccountRepositoryInterface::class);+ foreach ($this->work as $account) {+ $this->processWorkAccount($account);+ }+ Log::debug(sprintf('Done with %s', __METHOD__));}/**- * @param TransactionGroup $group+ * @param Account $account*/- public function setGroup(TransactionGroup $group): void+ private function processWorkAccount(Account $account): void{- $this->group = $group;+ Log::debug(sprintf('Now in %s(#%d)', __METHOD__, $account->id));++ // get opening balance (if present)+ $this->repository->setUser($account->user);+ $startOfDebt = $this->repository->getOpeningBalanceAmount($account) ?? '0';+ $leftOfDebt = app('steam')->positive($startOfDebt);++ /** @var AccountMetaFactory $factory */+ $factory = app(AccountMetaFactory::class);+ $factory->crud($account, 'start_of_debt', $startOfDebt);++ // get direction of liability:+ $direction = (string)$this->repository->getMetaValue($account, 'liability_direction');++ // now loop all transactions (except opening balance and credit thing)+ $transactions = $account->transactions()->get();+ /** @var Transaction $transaction */+ foreach ($transactions as $transaction) {+ $leftOfDebt = $this->processTransaction($account, $direction, $transaction, $leftOfDebt);+ }+ $factory->crud($account, 'current_debt', $leftOfDebt);+++ Log::debug(sprintf('Done with %s(#%d)', __METHOD__, $account->id));}/**@@ -292,5 +275,21 @@ class CreditRecalculateServicereturn $amount;}+ /**+ * @param Account|null $account+ */+ public function setAccount(?Account $account): void+ {+ $this->account = $account;+ }++ /**+ * @param TransactionGroup $group+ */+ public function setGroup(TransactionGroup $group): void+ {+ $this->group = $group;+ }+}diff --git a/app/Services/Internal/Support/JournalServiceTrait.php b/app/Services/Internal/Support/JournalServiceTrait.phpindex ce621bc415..92389b9b76 100644--- a/app/Services/Internal/Support/JournalServiceTrait.php+++ b/app/Services/Internal/Support/JournalServiceTrait.php@@ -96,7 +96,7 @@ trait JournalServiceTrait$search = null;// first attempt, find by ID.if (null !== $data['id']) {- $search = $this->accountRepository->find((int) $data['id']);+ $search = $this->accountRepository->find((int)$data['id']);if (null !== $search && in_array($search->accountType->type, $types, true)) {Log::debug(sprintf('Found "account_id" object: #%d, "%s" of type %s', $search->id, $search->name, $search->accountType->type)@@ -174,10 +174,10 @@ trait JournalServiceTraitif (null === $account && null !== $data['number']) {Log::debug(sprintf('Searching for account number "%s".', $data['number']));// find by preferred type.- $source = $this->accountRepository->findByAccountNumber((string) $data['number'], [$types[0]]);+ $source = $this->accountRepository->findByAccountNumber((string)$data['number'], [$types[0]]);// or any expected type.- $source = $source ?? $this->accountRepository->findByAccountNumber((string) $data['number'], $types);+ $source = $source ?? $this->accountRepository->findByAccountNumber((string)$data['number'], $types);if (null !== $source) {Log::debug(sprintf('Found account: #%d, %s', $source->id, $source->name));@@ -214,7 +214,7 @@ trait JournalServiceTrait// final attempt, create it.if (AccountType::ASSET === $preferredType) {- throw new FireflyException(sprintf('TransactionFactory: Cannot create asset account with these values: %s',json_encode($data)));+ throw new FireflyException(sprintf('TransactionFactory: Cannot create asset account with these values: %s', json_encode($data)));}// fix name of account if only IBAN is given:if ('' === (string)$data['name'] && '' !== (string)$data['iban']) {@@ -227,7 +227,7 @@ trait JournalServiceTrait$data['name'] = $data['number'];}// if name is still NULL, return NULL.- if(null === $data['name']) {+ if (null === $data['name']) {return null;}$data['name'] = $data['name'] ?? '(no name)';diff --git a/app/Services/Internal/Support/TransactionTypeTrait.php b/app/Services/Internal/Support/TransactionTypeTrait.phpindex 650b75ccdb..b21f9f03dc 100644--- a/app/Services/Internal/Support/TransactionTypeTrait.php+++ b/app/Services/Internal/Support/TransactionTypeTrait.php@@ -48,8 +48,8 @@ trait TransactionTypeTrait$factory = app(TransactionTypeFactory::class);$transactionType = $factory->find($type);if (null === $transactionType) {- Log::error(sprintf('Could not find transaction type for "%s"', $type));- throw new FireflyException(sprintf('Could not find transaction type for "%s"', $type));+ Log::error(sprintf('Could not find transaction type for "%s"', $type));+ throw new FireflyException(sprintf('Could not find transaction type for "%s"', $type));}return $transactionType;diff --git a/app/Services/Internal/Update/AccountUpdateService.php b/app/Services/Internal/Update/AccountUpdateService.phpindex 7c45a6a5d7..ed7ff3d51c 100644--- a/app/Services/Internal/Update/AccountUpdateService.php+++ b/app/Services/Internal/Update/AccountUpdateService.php@@ -31,12 +31,11 @@ use FireflyIII\Models\Location;use FireflyIII\Repositories\Account\AccountRepositoryInterface;use FireflyIII\Services\Internal\Support\AccountServiceTrait;use FireflyIII\User;-use JsonException;use Log;/*** Class AccountUpdateService-* See reference nr. 90+ * See reference nr. 90*/class AccountUpdateService{@@ -46,8 +45,8 @@ class AccountUpdateServiceprotected array $validAssetFields;protected array $validCCFields;protected array $validFields;- private array $canHaveVirtual;private array $canHaveOpeningBalance;+ private array $canHaveVirtual;private User $user;/**diff --git a/app/Services/Internal/Update/CategoryUpdateService.php b/app/Services/Internal/Update/CategoryUpdateService.phpindex dd975d48d1..95128dba5c 100644--- a/app/Services/Internal/Update/CategoryUpdateService.php+++ b/app/Services/Internal/Update/CategoryUpdateService.php@@ -39,6 +39,7 @@ use Log;class CategoryUpdateService{private $user;+/*** Constructor.*/@@ -137,6 +138,7 @@ class CategoryUpdateService->where('rt_meta.value', $oldName)->update(['rt_meta.value' => $newName]);}+/*** @param Category $category* @param array $datadiff --git a/app/Services/Internal/Update/GroupCloneService.php b/app/Services/Internal/Update/GroupCloneService.phpindex 8bf0eb443f..cd6bb7e107 100644--- a/app/Services/Internal/Update/GroupCloneService.php+++ b/app/Services/Internal/Update/GroupCloneService.php@@ -50,6 +50,7 @@ class GroupCloneServiceforeach ($group->transactionJournals as $journal) {$this->cloneJournal($journal, $newGroup, (int)$group->id);}+return $newGroup;}diff --git a/app/Services/Internal/Update/JournalUpdateService.php b/app/Services/Internal/Update/JournalUpdateService.phpindex 021690345e..423c2311ce 100644--- a/app/Services/Internal/Update/JournalUpdateService.php+++ b/app/Services/Internal/Update/JournalUpdateService.php@@ -167,6 +167,21 @@ class JournalUpdateService$this->transactionJournal->refresh();}+ /**+ * @return bool+ */+ private function removeReconciliation(): bool+ {+ if (count($this->data) > 1) {+ return true;+ }+ if (1 === count($this->data) && true === array_key_exists('transaction_journal_id', $this->data)) {+ return true;+ }++ return false;+ }+/*** @return bool*/@@ -760,19 +775,4 @@ class JournalUpdateService$this->sourceTransaction->refresh();$this->destinationTransaction->refresh();}-- /**- * @return bool- */- private function removeReconciliation(): bool- {- if (count($this->data) > 1) {- return true;- }- if (1 === count($this->data) && true === array_key_exists('transaction_journal_id', $this->data)) {- return true;- }-- return false;- }}diff --git a/app/Services/Internal/Update/RecurrenceUpdateService.php b/app/Services/Internal/Update/RecurrenceUpdateService.phpindex c1d597d77b..1841c256f1 100644--- a/app/Services/Internal/Update/RecurrenceUpdateService.php+++ b/app/Services/Internal/Update/RecurrenceUpdateService.php@@ -49,7 +49,7 @@ class RecurrenceUpdateService/*** Updates a recurrence.*-* See reference nr. 88+ * See reference nr. 88** @param Recurrence $recurrence* @param array $data@@ -217,7 +217,7 @@ class RecurrenceUpdateService}/**-* See reference nr. 89+ * See reference nr. 89** @param Recurrence $recurrence* @param array $transactions@@ -296,7 +296,7 @@ class RecurrenceUpdateService// can be removed when v1 is retired.if (array_key_exists('category_name', $current) && '' === (string)$current['category_name']) {$current['category_name'] = null;- $current['category_id'] = 0;+ $current['category_id'] = 0;}if (array_key_exists('category_id', $current)) {diff --git a/app/Support/Amount.php b/app/Support/Amount.phpindex 7bea63e335..077c44de71 100644--- a/app/Support/Amount.php+++ b/app/Support/Amount.php@@ -23,10 +23,12 @@ declare(strict_types=1);namespace FireflyIII\Support;use Crypt;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\TransactionCurrency;use FireflyIII\User;use Illuminate\Contracts\Encryption\DecryptException;use Illuminate\Support\Collection;+use JsonException;use NumberFormatter;/**@@ -109,15 +111,15 @@ class Amount/*** @return string- * @throws \FireflyIII\Exceptions\FireflyException- * @throws \JsonException+ * @throws FireflyException+ * @throws JsonException*/public function getCurrencyCode(): string{$cache = new CacheProperties;$cache->addProperty('getCurrencyCode');if ($cache->has()) {- return $cache->get();+ return $cache->get();}$currencyPreference = app('preferences')->get('currencyPreference', config('firefly.default_currency', 'EUR'));@@ -147,8 +149,8 @@ class Amount* @param User $user** @return TransactionCurrency- * @throws \FireflyIII\Exceptions\FireflyException- * @throws \JsonException+ * @throws FireflyException+ * @throws JsonException*/public function getDefaultCurrencyByUser(User $user): TransactionCurrency{@@ -156,7 +158,7 @@ class Amount$cache->addProperty('getDefaultCurrency');$cache->addProperty($user->id);if ($cache->has()) {- return $cache->get();+ return $cache->get();}$currencyPreference = app('preferences')->getForUser($user, 'currencyPreference', config('firefly.default_currency', 'EUR'));$currencyPrefStr = $currencyPreference ? $currencyPreference->data : 'EUR';diff --git a/app/Support/Authentication/RemoteUserGuard.php b/app/Support/Authentication/RemoteUserGuard.phpindex e5cd72cdc9..81846576f3 100644--- a/app/Support/Authentication/RemoteUserGuard.php+++ b/app/Support/Authentication/RemoteUserGuard.php@@ -31,6 +31,7 @@ use Illuminate\Contracts\Auth\Guard;use Illuminate\Contracts\Auth\UserProvider;use Illuminate\Contracts\Foundation\Application;use Log;+/*** Class RemoteUserGuard*/diff --git a/app/Support/Authentication/RemoteUserProvider.php b/app/Support/Authentication/RemoteUserProvider.phpindex c028e98895..4a660214ca 100644--- a/app/Support/Authentication/RemoteUserProvider.php+++ b/app/Support/Authentication/RemoteUserProvider.php@@ -23,6 +23,7 @@declare(strict_types=1);namespace FireflyIII\Support\Authentication;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\User;use Illuminate\Contracts\Auth\Authenticatable;@@ -56,10 +57,10 @@ class RemoteUserProvider implements UserProviderLog::debug(sprintf('User with email "%s" not found. Will be created.', $identifier));$user = User::create([- 'blocked' => false,+ 'blocked' => false,'blocked_code' => null,- 'email' => $identifier,- 'password' => bcrypt(Str::random(64)),+ 'email' => $identifier,+ 'password' => bcrypt(Str::random(64)),]);}diff --git a/app/Support/Binder/AccountList.php b/app/Support/Binder/AccountList.phpindex d355a46ca3..b6f09d676b 100644--- a/app/Support/Binder/AccountList.php+++ b/app/Support/Binder/AccountList.php@@ -36,7 +36,7 @@ class AccountList implements BinderInterface/*** @param string $value- * @param Route $route+ * @param Route $route** @return Collection* @throws NotFoundHttpExceptiondiff --git a/app/Support/Binder/BudgetList.php b/app/Support/Binder/BudgetList.phpindex ff2ed2ffdc..d07b1feee6 100644--- a/app/Support/Binder/BudgetList.php+++ b/app/Support/Binder/BudgetList.php@@ -35,7 +35,7 @@ class BudgetList implements BinderInterface{/*** @param string $value- * @param Route $route+ * @param Route $route** @return Collection* @throws NotFoundHttpExceptiondiff --git a/app/Support/Binder/CategoryList.php b/app/Support/Binder/CategoryList.phpindex bf03596597..56c2f0ce34 100644--- a/app/Support/Binder/CategoryList.php+++ b/app/Support/Binder/CategoryList.php@@ -51,7 +51,7 @@ class CategoryList implements BinderInterface$list = array_unique(array_map('\intval', explode(',', $value)));if (empty($list)) {- throw new NotFoundHttpException;+ throw new NotFoundHttpException;}/** @var Collection $collection */diff --git a/app/Support/Binder/DynamicConfigKey.php b/app/Support/Binder/DynamicConfigKey.phpindex c8d83f5a4b..a9a6bc0730 100644--- a/app/Support/Binder/DynamicConfigKey.php+++ b/app/Support/Binder/DynamicConfigKey.php@@ -32,12 +32,14 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;class DynamicConfigKey{- public static array $accepted = [- 'configuration.is_demo_site',- 'configuration.permission_update_check',- 'configuration.single_user_mode',- 'configuration.last_update_check',- ];+ public static array $accepted+ = [+ 'configuration.is_demo_site',+ 'configuration.permission_update_check',+ 'configuration.single_user_mode',+ 'configuration.last_update_check',+ ];+/*** @param string $value* @param Route $routediff --git a/app/Support/Binder/EitherConfigKey.php b/app/Support/Binder/EitherConfigKey.phpindex b344771c96..7e129348ea 100644--- a/app/Support/Binder/EitherConfigKey.php+++ b/app/Support/Binder/EitherConfigKey.php@@ -23,6 +23,7 @@declare(strict_types=1);namespace FireflyIII\Support\Binder;+use Illuminate\Routing\Route;use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;@@ -31,21 +32,23 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;*/class EitherConfigKey{- public static array $static = [- 'firefly.version',- 'firefly.api_version',- 'firefly.default_location',- 'firefly.account_to_transaction',- 'firefly.allowed_opposing_types',- 'firefly.accountRoles',- 'firefly.valid_liabilities',- 'firefly.interest_periods',- 'firefly.bill_periods',- 'firefly.enable_external_map',- 'firefly.expected_source_types',- 'firefly.credit_card_types',- 'app.timezone',- ];+ public static array $static+ = [+ 'firefly.version',+ 'firefly.api_version',+ 'firefly.default_location',+ 'firefly.account_to_transaction',+ 'firefly.allowed_opposing_types',+ 'firefly.accountRoles',+ 'firefly.valid_liabilities',+ 'firefly.interest_periods',+ 'firefly.bill_periods',+ 'firefly.enable_external_map',+ 'firefly.expected_source_types',+ 'firefly.credit_card_types',+ 'app.timezone',+ ];+/*** @param string $value* @param Route $routediff --git a/app/Support/Binder/JournalList.php b/app/Support/Binder/JournalList.phpindex d06dce5d41..cda7cc3c17 100644--- a/app/Support/Binder/JournalList.php+++ b/app/Support/Binder/JournalList.php@@ -63,13 +63,14 @@ class JournalList implements BinderInterface/*** @param string $value+ ** @return array*/protected static function parseList(string $value): array{$list = array_unique(array_map('\intval', explode(',', $value)));if (empty($list)) {- throw new NotFoundHttpException;+ throw new NotFoundHttpException;}return $list;diff --git a/app/Support/Chart/Category/FrontpageChartGenerator.php b/app/Support/Chart/Category/FrontpageChartGenerator.phpindex 8ff317aefb..9aeb91d2de 100644--- a/app/Support/Chart/Category/FrontpageChartGenerator.php+++ b/app/Support/Chart/Category/FrontpageChartGenerator.php@@ -184,6 +184,7 @@ class FrontpageChartGeneratorreturn $return;}+/*** @param array $currencyData* @param array $monetaryDatadiff --git a/app/Support/Chart/Category/WholePeriodChartGenerator.php b/app/Support/Chart/Category/WholePeriodChartGenerator.phpindex a4afe0c8d4..ffd0a4ce9d 100644--- a/app/Support/Chart/Category/WholePeriodChartGenerator.php+++ b/app/Support/Chart/Category/WholePeriodChartGenerator.php@@ -115,7 +115,7 @@ class WholePeriodChartGenerator}/**-* See reference nr. 32+ * See reference nr. 32** @param Carbon $start* @param Carbon $end@@ -128,13 +128,13 @@ class WholePeriodChartGenerator$step = '1D';$months = $start->diffInMonths($end);if ($months > 3) {- $step = '1W';+ $step = '1W';}if ($months > 24) {- $step = '1M';+ $step = '1M';}if ($months > 100) {- $step = '1Y';+ $step = '1Y';}return $step;diff --git a/app/Support/Cronjobs/AbstractCronjob.php b/app/Support/Cronjobs/AbstractCronjob.phpindex 45cdce0a98..1783889cb9 100644--- a/app/Support/Cronjobs/AbstractCronjob.php+++ b/app/Support/Cronjobs/AbstractCronjob.php@@ -32,15 +32,13 @@ use Carbon\Carbon;*/abstract class AbstractCronjob{- public int $timeBetweenRuns = 43200;- protected Carbon $date;- protected bool $force;-+ public bool $jobErrored;public bool $jobFired;public bool $jobSucceeded;- public bool $jobErrored;-public ?string $message;+ public int $timeBetweenRuns = 43200;+ protected Carbon $date;+ protected bool $force;/*** AbstractCronjob constructor.@@ -65,7 +63,7 @@ abstract class AbstractCronjob*/final public function setDate(Carbon $date): void{- $newDate = clone $date;+ $newDate = clone $date;$this->date = $newDate;}diff --git a/app/Support/Cronjobs/AutoBudgetCronjob.php b/app/Support/Cronjobs/AutoBudgetCronjob.phpindex bfd5118f36..ada8681278 100644--- a/app/Support/Cronjobs/AutoBudgetCronjob.php+++ b/app/Support/Cronjobs/AutoBudgetCronjob.php@@ -23,6 +23,7 @@declare(strict_types=1);namespace FireflyIII\Support\Cronjobs;+use Carbon\Carbon;use FireflyIII\Jobs\CreateAutoBudgetLimits;use FireflyIII\Models\Configuration;@@ -43,7 +44,7 @@ class AutoBudgetCronjob extends AbstractCronjob$config = app('fireflyconfig')->get('last_ab_job', 0);$lastTime = (int)$config->data;$diff = time() - $lastTime;- $diffForHumans = Carbon::now()->diffForHumans(Carbon::createFromTimestamp($lastTime),null, true);+ $diffForHumans = Carbon::now()->diffForHumans(Carbon::createFromTimestamp($lastTime), null, true);if (0 === $lastTime) {Log::info('Auto budget cron-job has never fired before.');}@@ -53,6 +54,7 @@ class AutoBudgetCronjob extends AbstractCronjobif (false === $this->force) {Log::info('The auto budget cron-job will not fire now.');$this->message = sprintf('It has been %s since the auto budget cron-job has fired. It will not fire now.', $diffForHumans);+return;}diff --git a/app/Support/Cronjobs/RecurringCronjob.php b/app/Support/Cronjobs/RecurringCronjob.phpindex 4c00551e3d..665a15bc27 100644--- a/app/Support/Cronjobs/RecurringCronjob.php+++ b/app/Support/Cronjobs/RecurringCronjob.php@@ -44,7 +44,7 @@ class RecurringCronjob extends AbstractCronjob$config = app('fireflyconfig')->get('last_rt_job', 0);$lastTime = (int)$config->data;$diff = time() - $lastTime;- $diffForHumans = Carbon::now()->diffForHumans(Carbon::createFromTimestamp($lastTime), null,true);+ $diffForHumans = Carbon::now()->diffForHumans(Carbon::createFromTimestamp($lastTime), null, true);if (0 === $lastTime) {Log::info('Recurring transactions cron-job has never fired before.');diff --git a/app/Support/Export/ExportDataGenerator.php b/app/Support/Export/ExportDataGenerator.phpindex 4ccc0be661..62d083b016 100644--- a/app/Support/Export/ExportDataGenerator.php+++ b/app/Support/Export/ExportDataGenerator.php@@ -61,6 +61,8 @@ use League\Csv\Writer;*/class ExportDataGenerator{+ private const ADD_RECORD_ERR = 'Could not add record to set: %s';+ private const EXPORT_ERR = 'Could not export to string: %s';private Collection $accounts;private Carbon $end;private bool $exportAccounts;@@ -75,9 +77,6 @@ class ExportDataGeneratorprivate Carbon $start;private User $user;- private const ADD_RECORD_ERR = 'Could not add record to set: %s';- private const EXPORT_ERR = 'Could not export to string: %s';-public function __construct(){$this->accounts = new Collection;@@ -644,7 +643,7 @@ class ExportDataGenerator*/private function exportTransactions(): string{-// See reference nr. 41+ // See reference nr. 41$header = ['user_id', 'group_id', 'journal_id', 'created_at', 'updated_at', 'group_title', 'type', 'amount', 'foreign_amount', 'currency_code','foreign_currency_code', 'description', 'date', 'source_name', 'source_iban', 'source_type', 'destination_name', 'destination_iban','destination_type', 'reconciled', 'category', 'budget', 'bill', 'tags', 'notes',diff --git a/app/Support/FireflyConfig.php b/app/Support/FireflyConfig.phpindex 9eb829bd22..eb9b9c0ce2 100644--- a/app/Support/FireflyConfig.php+++ b/app/Support/FireflyConfig.php@@ -52,16 +52,6 @@ class FireflyConfig}}- /**- * @param string $name- *- * @return bool- */- public function has(string $name): bool- {- return Configuration::where('name', $name)->count() === 1;- }-/*** @param string $name* @param bool|string|int|null $default@@ -96,6 +86,40 @@ class FireflyConfigreturn $this->set($name, $default);}+ /**+ * @param string $name+ * @param mixed $value+ *+ * @return Configuration+ */+ public function set(string $name, $value): Configuration+ {+ try {+ $config = Configuration::whereName($name)->whereNull('deleted_at')->first();+ } catch (QueryException | Exception $e) { // @phpstan-ignore-line+ $item = new Configuration;+ $item->name = $name;+ $item->data = $value;++ return $item;+ }++ if (null === $config) {+ $item = new Configuration;+ $item->name = $name;+ $item->data = $value;+ $item->save();+ Cache::forget('ff-config-' . $name);++ return $item;+ }+ $config->data = $value;+ $config->save();+ Cache::forget('ff-config-' . $name);++ return $config;+ }+/*** @param string $name* @param mixed $default@@ -120,13 +144,12 @@ class FireflyConfig/*** @param string $name- * @param mixed $value*- * @return Configuration+ * @return bool*/- public function put(string $name, $value): Configuration+ public function has(string $name): bool{- return $this->set($name, $value);+ return Configuration::where('name', $name)->count() === 1;}/**@@ -135,31 +158,8 @@ class FireflyConfig** @return Configuration*/- public function set(string $name, $value): Configuration+ public function put(string $name, $value): Configuration{- try {- $config = Configuration::whereName($name)->whereNull('deleted_at')->first();- } catch (QueryException | Exception $e) { // @phpstan-ignore-line- $item = new Configuration;- $item->name = $name;- $item->data = $value;-- return $item;- }-- if (null === $config) {- $item = new Configuration;- $item->name = $name;- $item->data = $value;- $item->save();- Cache::forget('ff-config-' . $name);-- return $item;- }- $config->data = $value;- $config->save();- Cache::forget('ff-config-' . $name);-- return $config;+ return $this->set($name, $value);}}diff --git a/app/Support/Form/AccountForm.php b/app/Support/Form/AccountForm.phpindex 1ee2f33919..74102fb38a 100644--- a/app/Support/Form/AccountForm.php+++ b/app/Support/Form/AccountForm.php@@ -22,6 +22,7 @@declare(strict_types=1);namespace FireflyIII\Support\Form;+use FireflyIII\Models\Account;use FireflyIII\Models\AccountType;use FireflyIII\Repositories\Account\AccountRepositoryInterface;@@ -33,8 +34,8 @@ use Throwable;** All form methods that are account related.*-* See reference nr. 29-* See reference nr. 30+ * See reference nr. 29+ * See reference nr. 30*/class AccountForm{@@ -160,6 +161,7 @@ class AccountFormreturn $this->select($name, $grouped, $value, $options);}+/*** Same list but all liabilities as well.*diff --git a/app/Support/Form/CurrencyForm.php b/app/Support/Form/CurrencyForm.phpindex ac7e10cade..54bc0a6597 100644--- a/app/Support/Form/CurrencyForm.php+++ b/app/Support/Form/CurrencyForm.php@@ -72,7 +72,7 @@ class CurrencyFormunset($options['currency'], $options['placeholder']);// perhaps the currency has been sent to us in the field $amount_currency_id_$name (amount_currency_id_amount)- $preFilled = session('preFilled');+ $preFilled = session('preFilled');if (!is_array($preFilled)) {$preFilled = [];}@@ -105,7 +105,7 @@ class CurrencyForm}/**-* See reference nr. 23+ * See reference nr. 23** @param string $name* @param mixed $value@@ -119,7 +119,7 @@ class CurrencyForm}/**-* See reference nr. 24+ * See reference nr. 24** @param string $name* @param string $view@@ -174,7 +174,7 @@ class CurrencyForm}/**-* See reference nr. 25+ * See reference nr. 25** @param string $name* @param mixed $value@@ -199,7 +199,7 @@ class CurrencyForm}/**-* See reference nr. 26+ * See reference nr. 26** @param string $name* @param mixed $valuediff --git a/app/Support/Form/PiggyBankForm.php b/app/Support/Form/PiggyBankForm.phpindex 2586268a12..e4165cb49b 100644--- a/app/Support/Form/PiggyBankForm.php+++ b/app/Support/Form/PiggyBankForm.php@@ -22,20 +22,21 @@declare(strict_types=1);namespace FireflyIII\Support\Form;+use FireflyIII\Models\PiggyBank;use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;/*** Class PiggyBankForm*-* See reference nr. 27+ * See reference nr. 27*/class PiggyBankForm{use FormSupport;/**-* See reference nr. 28+ * See reference nr. 28** @param string $name* @param mixed $valuediff --git a/app/Support/Form/RuleForm.php b/app/Support/Form/RuleForm.phpindex 4ffd8dbd6b..a757d5b983 100644--- a/app/Support/Form/RuleForm.php+++ b/app/Support/Form/RuleForm.php@@ -22,6 +22,7 @@declare(strict_types=1);namespace FireflyIII\Support\Form;+use FireflyIII\Models\RuleGroup;use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;use Form;@@ -29,7 +30,7 @@ use Illuminate\Support\HtmlString;/*** Class RuleForm-* See reference nr. 31+ * See reference nr. 31*/class RuleForm{diff --git a/app/Support/Http/Controllers/AugumentData.php b/app/Support/Http/Controllers/AugumentData.phpindex 7ef49e57cf..644d5d39a7 100644--- a/app/Support/Http/Controllers/AugumentData.php+++ b/app/Support/Http/Controllers/AugumentData.php@@ -37,6 +37,7 @@ use FireflyIII\Repositories\Budget\OperationsRepositoryInterface;use FireflyIII\Repositories\Category\CategoryRepositoryInterface;use FireflyIII\Support\CacheProperties;use Illuminate\Support\Collection;+use JsonException;/*** Trait AugumentData@@ -190,7 +191,7 @@ trait AugumentData* @param Carbon $end** @return Collection- * @throws \JsonException+ * @throws JsonException*/protected function getLimits(Budget $budget, Carbon $start, Carbon $end): Collection // get data + augment with info{@@ -207,7 +208,7 @@ trait AugumentData$cache->addProperty('get-limits');if ($cache->has()) {- return $cache->get();+ return $cache->get();}$set = $blRepository->getBudgetLimits($budget, $start, $end);diff --git a/app/Support/Http/Controllers/ChartGeneration.php b/app/Support/Http/Controllers/ChartGeneration.phpindex 373aee5b73..930269e701 100644--- a/app/Support/Http/Controllers/ChartGeneration.php+++ b/app/Support/Http/Controllers/ChartGeneration.php@@ -24,12 +24,14 @@ declare(strict_types=1);namespace FireflyIII\Support\Http\Controllers;use Carbon\Carbon;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Generator\Chart\Basic\GeneratorInterface;use FireflyIII\Models\Account;use FireflyIII\Repositories\Account\AccountRepositoryInterface;use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;use FireflyIII\Support\CacheProperties;use Illuminate\Support\Collection;+use JsonException;use Log;/**@@ -45,8 +47,8 @@ trait ChartGeneration* @param Carbon $end** @return array- * @throws \FireflyIII\Exceptions\FireflyException- * @throws \JsonException+ * @throws FireflyException+ * @throws JsonException*/protected function accountBalanceChart(Collection $accounts, Carbon $start, Carbon $end): array // chart helper method.{@@ -58,7 +60,7 @@ trait ChartGeneration$cache->addProperty('chart.account.account-balance-chart');$cache->addProperty($accounts);if ($cache->has()) {- return $cache->get();+ return $cache->get();}Log::debug('Regenerate chart.account.account-balance-chart from scratch.');$locale = app('steam')->getLocale();@@ -74,7 +76,7 @@ trait ChartGeneration$chartData = [];/** @var Account $account */foreach ($accounts as $account) {-// See reference nr. 33+ // See reference nr. 33$currency = $repository->find((int)$accountRepos->getMetaValue($account, 'currency_id'));if (null === $currency) {$currency = $default;diff --git a/app/Support/Http/Controllers/CreateStuff.php b/app/Support/Http/Controllers/CreateStuff.phpindex 28188f75ee..039d5c853c 100644--- a/app/Support/Http/Controllers/CreateStuff.php+++ b/app/Support/Http/Controllers/CreateStuff.php@@ -85,7 +85,7 @@ trait CreateStuff$assetAccount = ['name' => (string)trans('firefly.cash_wallet', [], $language),'iban' => null,- 'account_type_name' => 'asset',+ 'account_type_name' => 'asset','virtual_balance' => 0,'account_type_id' => null,'active' => true,@@ -115,7 +115,7 @@ trait CreateStuff}// switch on class existence.- $keys= [];+ $keys = [];Log::info(sprintf('PHP version is %s', phpversion()));if (class_exists(LegacyRSA::class)) {// PHP 7@@ -152,7 +152,7 @@ trait CreateStuff$savingsAccount = ['name' => (string)trans('firefly.new_savings_account', ['bank_name' => $request->get('bank_name')], $language),'iban' => null,- 'account_type_name' => 'asset',+ 'account_type_name' => 'asset','account_type_id' => null,'virtual_balance' => 0,'active' => true,diff --git a/app/Support/Http/Controllers/DateCalculation.php b/app/Support/Http/Controllers/DateCalculation.phpindex 68d1ae743c..05d2b44421 100644--- a/app/Support/Http/Controllers/DateCalculation.php+++ b/app/Support/Http/Controllers/DateCalculation.php@@ -88,17 +88,18 @@ trait DateCalculation$step = '1D';$months = $start->diffInMonths($end);if ($months > 3) {- $step = '1W';+ $step = '1W';}if ($months > 24) {- $step = '1M';+ $step = '1M';}if ($months > 100) {- $step = '1Y';+ $step = '1Y';}return $step;}+/*** Get a list of the periods that will occur after this date. For example,* March 2018, April 2018, etc.diff --git a/app/Support/Http/Controllers/GetConfigurationData.php b/app/Support/Http/Controllers/GetConfigurationData.phpindex 5493ae41ee..eb473a1f47 100644--- a/app/Support/Http/Controllers/GetConfigurationData.php+++ b/app/Support/Http/Controllers/GetConfigurationData.php@@ -22,7 +22,9 @@declare(strict_types=1);namespace FireflyIII\Support\Http\Controllers;+use Carbon\Carbon;+use FireflyIII\Exceptions\FireflyException;use Log;/**@@ -85,7 +87,7 @@ trait GetConfigurationData* Get config for date range.** @return array- * @throws \FireflyIII\Exceptions\FireflyException+ * @throws FireflyException*/protected function getDateRangeConfig(): array // get configuration + get preferences.{diff --git a/app/Support/Http/Controllers/ModelInformation.php b/app/Support/Http/Controllers/ModelInformation.phpindex d91cbb83a4..57fe491464 100644--- a/app/Support/Http/Controllers/ModelInformation.php+++ b/app/Support/Http/Controllers/ModelInformation.php@@ -115,7 +115,7 @@ trait ModelInformation*/protected function getTriggersForBill(Bill $bill): array // get info and augument{-// See reference nr. 39+ // See reference nr. 39$operators = config('firefly.search.operators');$triggers = [];foreach ($operators as $key => $operator) {@@ -167,7 +167,7 @@ trait ModelInformation*/private function getTriggersForJournal(TransactionJournal $journal): array{-// See reference nr. 40+ // See reference nr. 40$operators = config('firefly.search.operators');$triggers = [];foreach ($operators as $key => $operator) {diff --git a/app/Support/Http/Controllers/PeriodOverview.php b/app/Support/Http/Controllers/PeriodOverview.phpindex da65f3bfa4..f67ed67074 100644--- a/app/Support/Http/Controllers/PeriodOverview.php+++ b/app/Support/Http/Controllers/PeriodOverview.php@@ -33,6 +33,7 @@ use FireflyIII\Models\TransactionType;use FireflyIII\Repositories\Journal\JournalRepositoryInterface;use FireflyIII\Support\CacheProperties;use Illuminate\Support\Collection;+use JsonException;use Log;/**@@ -78,7 +79,7 @@ trait PeriodOverview** @return array* @throws FireflyException- * @throws \JsonException+ * @throws JsonException*/protected function getAccountPeriodOverview(Account $account, Carbon $start, Carbon $end): array{@@ -270,7 +271,7 @@ trait PeriodOverview** @return array* @throws FireflyException- * @throws \JsonException+ * @throws JsonException*/protected function getCategoryPeriodOverview(Category $category, Carbon $start, Carbon $end): array{@@ -349,7 +350,7 @@ trait PeriodOverview** @return array* @throws FireflyException- * @throws \JsonException+ * @throws JsonException*/protected function getNoBudgetPeriodOverview(Carbon $start, Carbon $end): array{@@ -403,7 +404,7 @@ trait PeriodOverview** @return array* @throws FireflyException- * @throws \JsonException+ * @throws JsonException*/protected function getNoCategoryPeriodOverview(Carbon $theDate): array{@@ -484,7 +485,7 @@ trait PeriodOverview** @return array* @throws FireflyException- * @throws \JsonException+ * @throws JsonException*/protected function getTagPeriodOverview(Tag $tag, Carbon $start, Carbon $end): array // period overview for tags.{@@ -559,7 +560,7 @@ trait PeriodOverview** @return array* @throws FireflyException- * @throws \JsonException+ * @throws JsonException*/protected function getTransactionPeriodOverview(string $transactionType, Carbon $start, Carbon $end): array{diff --git a/app/Support/Http/Controllers/RenderPartialViews.php b/app/Support/Http/Controllers/RenderPartialViews.phpindex d0829339d9..ad177f8c37 100644--- a/app/Support/Http/Controllers/RenderPartialViews.php+++ b/app/Support/Http/Controllers/RenderPartialViews.php@@ -72,6 +72,7 @@ trait RenderPartialViewsLog::error(sprintf('Could not render: %s', $e->getMessage()));$view = 'Firefly III could not render the view. Please see the log files.';}+return $view;}@@ -92,6 +93,7 @@ trait RenderPartialViewsLog::error(sprintf('Cannot render reports.options.tag: %s', $e->getMessage()));$result = 'Could not render view.';}+return $result;}@@ -122,6 +124,7 @@ trait RenderPartialViewsLog::error(sprintf('Could not render: %s', $e->getMessage()));$view = 'Firefly III could not render the view. Please see the log files.';}+return $view;}@@ -169,6 +172,7 @@ trait RenderPartialViewsLog::error(sprintf('Cannot render reports.options.category: %s', $e->getMessage()));$result = 'Could not render view.';}+return $result;}@@ -209,6 +213,7 @@ trait RenderPartialViewsLog::error(sprintf('Cannot render reports.options.tag: %s', $e->getMessage()));$result = 'Could not render view.';}+return $result;}@@ -241,6 +246,7 @@ trait RenderPartialViewsLog::error(sprintf('Could not render: %s', $e->getMessage()));$view = 'Firefly III could not render the view. Please see the log files.';}+return $view;}@@ -292,7 +298,7 @@ trait RenderPartialViews*/protected function getCurrentTriggers(Rule $rule): array // get info from object and present.{-// See reference nr. 38+ // See reference nr. 38$operators = config('firefly.search.operators');$triggers = [];foreach ($operators as $key => $operator) {@@ -362,6 +368,7 @@ trait RenderPartialViewsLog::error(sprintf('Could not render: %s', $e->getMessage()));$view = 'Firefly III could not render the view. Please see the log files.';}+return $view;}@@ -379,6 +386,7 @@ trait RenderPartialViewsLog::error(sprintf('Cannot render reports.options.no-options: %s', $e->getMessage()));$result = 'Could not render view.';}+return $result;}@@ -400,6 +408,7 @@ trait RenderPartialViewsLog::error(sprintf('Cannot render reports.options.tag: %s', $e->getMessage()));$result = 'Could not render view.';}+return $result;}}diff --git a/app/Support/Http/Controllers/RequestInformation.php b/app/Support/Http/Controllers/RequestInformation.phpindex 280893eb71..05b7c73bf3 100644--- a/app/Support/Http/Controllers/RequestInformation.php+++ b/app/Support/Http/Controllers/RequestInformation.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Support\Http\Controllers;use Carbon\Carbon;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Exceptions\ValidationException;use FireflyIII\Helpers\Help\HelpInterface;use FireflyIII\Http\Requests\TestRuleFormRequest;@@ -113,25 +114,7 @@ trait RequestInformationreturn $content;}- return '<p>' . trans('firefly.route_has_no_help') . '</p>';- }-- /**- * @return string- */- final protected function getPageName(): string // get request info- {- return str_replace('.', '_', RouteFacade::currentRouteName());- }-- /**- * Get the specific name of a page for intro.- *- * @return string- */- final protected function getSpecificPageName(): string // get request info- {- return null === RouteFacade::current()->parameter('objectType') ? '' : '_' . RouteFacade::current()->parameter('objectType');+ return '<p>' . trans('firefly.route_has_no_help') . '</p>';}/**@@ -162,7 +145,7 @@ trait RequestInformation* Returns if user has seen demo.** @return bool- * @throws \FireflyIII\Exceptions\FireflyException+ * @throws FireflyException*/final protected function hasSeenDemo(): bool // get request info + get preference{@@ -181,12 +164,30 @@ trait RequestInformation$shownDemo = app('preferences')->get($key, false)->data;}if (!is_bool($shownDemo)) {- $shownDemo = true;+ $shownDemo = true;}return $shownDemo;}+ /**+ * @return string+ */+ final protected function getPageName(): string // get request info+ {+ return str_replace('.', '_', RouteFacade::currentRouteName());+ }++ /**+ * Get the specific name of a page for intro.+ *+ * @return string+ */+ final protected function getSpecificPageName(): string // get request info+ {+ return null === RouteFacade::current()->parameter('objectType') ? '' : '_' . RouteFacade::current()->parameter('objectType');+ }+/*** Check if date is outside session range.*diff --git a/app/Support/Http/Controllers/RuleManagement.php b/app/Support/Http/Controllers/RuleManagement.phpindex 01ab4e63ff..53bbc1300b 100644--- a/app/Support/Http/Controllers/RuleManagement.php+++ b/app/Support/Http/Controllers/RuleManagement.php@@ -78,7 +78,7 @@ trait RuleManagement*/protected function getPreviousTriggers(Request $request): array{-// See reference nr. 34+ // See reference nr. 34$operators = config('firefly.search.operators');$triggers = [];foreach ($operators as $key => $operator) {@@ -123,7 +123,7 @@ trait RuleManagement*/protected function parseFromOperators(array $submittedOperators): array{-// See reference nr. 35+ // See reference nr. 35$operators = config('firefly.search.operators');$renderedEntries = [];$triggers = [];diff --git a/app/Support/Http/Controllers/UserNavigation.php b/app/Support/Http/Controllers/UserNavigation.phpindex d25e11b200..28428810b4 100644--- a/app/Support/Http/Controllers/UserNavigation.php+++ b/app/Support/Http/Controllers/UserNavigation.php@@ -60,7 +60,7 @@ trait UserNavigationLog::debug(sprintf('The URI is %s', $uri));if (str_contains($uri, 'jscript')) {- $uri = $this->redirectUri;+ $uri = $this->redirectUri;Log::debug(sprintf('URI is now %s (uri contains jscript)', $uri));}diff --git a/app/Support/Navigation.php b/app/Support/Navigation.phpindex 145ac905ed..437c0e23e0 100644--- a/app/Support/Navigation.php+++ b/app/Support/Navigation.php@@ -159,6 +159,57 @@ class Navigationreturn $periods;}+ /**+ * @param Carbon $theDate+ * @param string $repeatFreq+ *+ * @return Carbon+ */+ public function startOfPeriod(Carbon $theDate, string $repeatFreq): Carbon+ {+ $date = clone $theDate;++ $functionMap = [+ '1D' => 'startOfDay',+ 'daily' => 'startOfDay',+ '1W' => 'startOfWeek',+ 'week' => 'startOfWeek',+ 'weekly' => 'startOfWeek',+ 'month' => 'startOfMonth',+ '1M' => 'startOfMonth',+ 'monthly' => 'startOfMonth',+ '3M' => 'firstOfQuarter',+ 'quarter' => 'firstOfQuarter',+ 'quarterly' => 'firstOfQuarter',+ 'year' => 'startOfYear',+ 'yearly' => 'startOfYear',+ '1Y' => 'startOfYear',+ ];+ if (array_key_exists($repeatFreq, $functionMap)) {+ $function = $functionMap[$repeatFreq];+ $date->$function();++ return $date;+ }+ if ('half-year' === $repeatFreq || '6M' === $repeatFreq) {+ $month = $date->month;+ $date->startOfYear();+ if ($month >= 7) {+ $date->addMonths(6);+ }++ return $date;+ }++ if ('custom' === $repeatFreq) {+ return $date; // the date is already at the start.+ }+ Log::error(sprintf('Cannot do startOfPeriod for $repeat_freq "%s"', $repeatFreq));++ return $theDate;++ }+/*** @param Carbon $end* @param string $repeatFreq@@ -313,6 +364,29 @@ class Navigationreturn $entries;}+ /**+ * If the date difference between start and end is less than a month, method returns "Y-m-d". If the difference is less than a year,+ * method returns "Y-m". If the date difference is larger, method returns "Y".+ *+ * @param Carbon $start+ * @param Carbon $end+ *+ * @return string+ */+ public function preferredCarbonFormat(Carbon $start, Carbon $end): string+ {+ $format = 'Y-m-d';+ if ($start->diffInMonths($end) > 1) {+ $format = 'Y-m';+ }++ if ($start->diffInMonths($end) > 12) {+ $format = 'Y';+ }++ return $format;+ }+/*** @param Carbon $theDate* @param string $repeatFrequency@@ -354,29 +428,6 @@ class Navigation}- /**- * If the date difference between start and end is less than a month, method returns "Y-m-d". If the difference is less than a year,- * method returns "Y-m". If the date difference is larger, method returns "Y".- *- * @param Carbon $start- * @param Carbon $end- *- * @return string- */- public function preferredCarbonFormat(Carbon $start, Carbon $end): string- {- $format = 'Y-m-d';- if ($start->diffInMonths($end) > 1) {- $format = 'Y-m';- }-- if ($start->diffInMonths($end) > 12) {- $format = 'Y';- }-- return $format;- }-/*** If the date difference between start and end is less than a month, method returns trans(config.month_and_day). If the difference is less than a year,* method returns "config.month". If the date difference is larger, method returns "config.year".@@ -470,57 +521,6 @@ class Navigationreturn $format;}- /**- * @param Carbon $theDate- * @param string $repeatFreq- *- * @return Carbon- */- public function startOfPeriod(Carbon $theDate, string $repeatFreq): Carbon- {- $date = clone $theDate;-- $functionMap = [- '1D' => 'startOfDay',- 'daily' => 'startOfDay',- '1W' => 'startOfWeek',- 'week' => 'startOfWeek',- 'weekly' => 'startOfWeek',- 'month' => 'startOfMonth',- '1M' => 'startOfMonth',- 'monthly' => 'startOfMonth',- '3M' => 'firstOfQuarter',- 'quarter' => 'firstOfQuarter',- 'quarterly' => 'firstOfQuarter',- 'year' => 'startOfYear',- 'yearly' => 'startOfYear',- '1Y' => 'startOfYear',- ];- if (array_key_exists($repeatFreq, $functionMap)) {- $function = $functionMap[$repeatFreq];- $date->$function();-- return $date;- }- if ('half-year' === $repeatFreq || '6M' === $repeatFreq) {- $month = $date->month;- $date->startOfYear();- if ($month >= 7) {- $date->addMonths(6);- }-- return $date;- }-- if ('custom' === $repeatFreq) {- return $date; // the date is already at the start.- }- Log::error(sprintf('Cannot do startOfPeriod for $repeat_freq "%s"', $repeatFreq));-- return $theDate;-- }-/*** @param Carbon $theDate* @param string $repeatFreqdiff --git a/app/Support/NullArrayObject.php b/app/Support/NullArrayObject.phpindex 6a25fb8608..60d20319db 100644--- a/app/Support/NullArrayObject.php+++ b/app/Support/NullArrayObject.php@@ -22,10 +22,12 @@declare(strict_types=1);namespace FireflyIII\Support;+use ArrayObject;/*** Class NullArrayObject+ ** @codeCoverageIgnore*/class NullArrayObject extends ArrayObjectdiff --git a/app/Support/ParseDateString.php b/app/Support/ParseDateString.phpindex 3fe2b018fb..bca98b29d6 100644--- a/app/Support/ParseDateString.php+++ b/app/Support/ParseDateString.php@@ -21,6 +21,7 @@*/declare(strict_types=1);+namespace FireflyIII\Support;use Carbon\Carbon;@@ -47,6 +48,30 @@ class ParseDateString'end of this year',];+ /**+ * @param string $date+ *+ * @return bool+ */+ public function isDateRange(string $date): bool+ {+ $date = strtolower($date);+ // not 10 chars:+ if (10 !== strlen($date)) {+ return false;+ }+ // all x'es+ if ('xxxx-xx-xx' === strtolower($date)) {+ return false;+ }+ // no x'es+ if (!str_contains($date, 'xx') && !str_contains($date, 'xxxx')) {+ return false;+ }++ return true;+ }+/*** @param string $date*@@ -89,35 +114,99 @@ class ParseDateStringreturn new Carbon('1984-09-17');}// maybe a year, nothing else?- if (4 === strlen($date) && is_numeric($date) && (int) $date > 1000 && (int) $date <= 3000) {+ if (4 === strlen($date) && is_numeric($date) && (int)$date > 1000 && (int)$date <= 3000) {return new Carbon(sprintf('%d-01-01', $date));}throw new FireflyException(sprintf('[d]Not a recognised date format: "%s"', $date));}+ /**+ * @param string $keyword+ *+ * @return Carbon+ */+ protected function parseKeyword(string $keyword): Carbon+ {+ $today = Carbon::today()->startOfDay();++ return match ($keyword) {+ default => $today,+ 'yesterday' => $today->subDay(),+ 'tomorrow' => $today->addDay(),+ 'start of this week' => $today->startOfWeek(),+ 'end of this week' => $today->endOfWeek(),+ 'start of this month' => $today->startOfMonth(),+ 'end of this month' => $today->endOfMonth(),+ 'start of this quarter' => $today->startOfQuarter(),+ 'end of this quarter' => $today->endOfQuarter(),+ 'start of this year' => $today->startOfYear(),+ 'end of this year' => $today->endOfYear(),+ };+ }+/*** @param string $date*- * @return bool+ * @return Carbon*/- public function isDateRange(string $date): bool+ protected function parseDefaultDate(string $date): Carbon{- $date = strtolower($date);- // not 10 chars:- if (10 !== strlen($date)) {- return false;- }- // all x'es- if ('xxxx-xx-xx' === strtolower($date)) {- return false;- }- // no x'es- if (!str_contains($date, 'xx') && !str_contains($date, 'xxxx')) {- return false;+ return Carbon::createFromFormat('Y-m-d', $date);+ }++ /**+ * @param string $date+ *+ * @return Carbon+ */+ protected function parseRelativeDate(string $date): Carbon+ {+ Log::debug(sprintf('Now in parseRelativeDate("%s")', $date));+ $parts = explode(' ', $date);+ $today = Carbon::today()->startOfDay();+ $functions = [+ [+ 'd' => 'subDays',+ 'w' => 'subWeeks',+ 'm' => 'subMonths',+ 'q' => 'subQuarters',+ 'y' => 'subYears',+ ], [+ 'd' => 'addDays',+ 'w' => 'addWeeks',+ 'm' => 'addMonths',+ 'q' => 'addQuarters',+ 'y' => 'addYears',+ ],+ ];++ foreach ($parts as $part) {+ Log::debug(sprintf('Now parsing part "%s"', $part));+ $part = trim($part);++ // verify if correct+ $pattern = '/[+-]\d+[wqmdy]/';+ $res = preg_match($pattern, $part);+ if (0 === $res || false === $res) {+ Log::error(sprintf('Part "%s" does not match regular expression. Will be skipped.', $part));+ continue;+ }+ $direction = str_starts_with($part, '+') ? 1 : 0;+ $period = $part[strlen($part) - 1];+ $number = (int)substr($part, 1, -1);+ if (!array_key_exists($period, $functions[$direction])) {+ Log::error(sprintf('No method for direction %d and period "%s".', $direction, $period));+ continue;+ }+ $func = $functions[$direction][$period];+ Log::debug(sprintf('Will now do %s(%d) on %s', $func, $number, $today->format('Y-m-d')));+ $today->$func($number);+ Log::debug(sprintf('Resulting date is %s', $today->format('Y-m-d')));+}- return true;+ return $today;}/**@@ -211,77 +300,6 @@ class ParseDateStringreturn false;}- /**- * @param string $date- *- * @return bool- */- protected function isMonthYearRange(string $date): bool- {- // if regex for YYYY-MM-xx:- $pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-xx$/';- if (preg_match($pattern, $date)) {- Log::debug(sprintf('"%s" is a month/year range.', $date));-- return true;- }- Log::debug(sprintf('"%s" is not a month/year range.', $date));-- return false;- }-- /**- * @param string $date- *- * @return bool- */- protected function isYearRange(string $date): bool- {- // if regex for YYYY-xx-xx:- $pattern = '/^(19|20)\d\d-xx-xx$/';- if (preg_match($pattern, $date)) {- Log::debug(sprintf('"%s" is a year range.', $date));-- return true;- }- Log::debug(sprintf('"%s" is not a year range.', $date));-- return false;- }- /**- * @param string $date- *- * @return Carbon- */- protected function parseDefaultDate(string $date): Carbon- {- return Carbon::createFromFormat('Y-m-d', $date);- }-- /**- * @param string $keyword- *- * @return Carbon- */- protected function parseKeyword(string $keyword): Carbon- {- $today = Carbon::today()->startOfDay();-- return match ($keyword) {- default => $today,- 'yesterday' => $today->subDay(),- 'tomorrow' => $today->addDay(),- 'start of this week' => $today->startOfWeek(),- 'end of this week' => $today->endOfWeek(),- 'start of this month' => $today->startOfMonth(),- 'end of this month' => $today->endOfMonth(),- 'start of this quarter' => $today->startOfQuarter(),- 'end of this quarter' => $today->endOfQuarter(),- 'start of this year' => $today->startOfYear(),- 'end of this year' => $today->endOfYear(),- };- }-/*** @param string $date* @param Carbon $journalDate@@ -292,7 +310,7 @@ class ParseDateString{// because 31 would turn February into March unexpectedly and the exact day is irrelevant here.$day = $journalDate->format('d');- if ((int) $day > 28) {+ if ((int)$day > 28) {$day = '28';}@@ -311,82 +329,21 @@ class ParseDateString/*** @param string $date- * @param Carbon $journalDate*- * @return array- */- protected function parseMonthYearRange(string $date, Carbon $journalDate): array- {- // because 31 would turn February into March unexpectedly and the exact day is irrelevant here.- $day = $journalDate->format('d');- if ((int) $day > 28) {- $day = '28';- }-- // format of string is YYYY-MM-xx- $validDate = str_replace(['xx'], [$day], $date);- Log::debug(sprintf('parseMonthYearRange: Parsed "%s" into "%s"', $date, $validDate));- $start = Carbon::createFromFormat('Y-m-d', $validDate)->startOfMonth();- $end = Carbon::createFromFormat('Y-m-d', $validDate)->endOfMonth();-- return [- 'start' => $start,- 'end' => $end,- ];- }-- /**- * @param string $date- *- * @return Carbon+ * @return bool*/- protected function parseRelativeDate(string $date): Carbon+ protected function isYearRange(string $date): bool{- Log::debug(sprintf('Now in parseRelativeDate("%s")', $date));- $parts = explode(' ', $date);- $today = Carbon::today()->startOfDay();- $functions = [- [- 'd' => 'subDays',- 'w' => 'subWeeks',- 'm' => 'subMonths',- 'q' => 'subQuarters',- 'y' => 'subYears',- ], [- 'd' => 'addDays',- 'w' => 'addWeeks',- 'm' => 'addMonths',- 'q' => 'addQuarters',- 'y' => 'addYears',- ],- ];-- foreach ($parts as $part) {- Log::debug(sprintf('Now parsing part "%s"', $part));- $part = trim($part);-- // verify if correct- $pattern = '/[+-]\d+[wqmdy]/';- $res = preg_match($pattern, $part);- if (0 === $res || false === $res) {- Log::error(sprintf('Part "%s" does not match regular expression. Will be skipped.', $part));- continue;- }- $direction = str_starts_with($part, '+') ? 1 : 0;- $period = $part[strlen($part) - 1];- $number = (int) substr($part, 1, -1);- if (!array_key_exists($period, $functions[$direction])) {- Log::error(sprintf('No method for direction %d and period "%s".', $direction, $period));- continue;- }- $func = $functions[$direction][$period];- Log::debug(sprintf('Will now do %s(%d) on %s', $func, $number, $today->format('Y-m-d')));- $today->$func($number);- Log::debug(sprintf('Resulting date is %s', $today->format('Y-m-d')));+ // if regex for YYYY-xx-xx:+ $pattern = '/^(19|20)\d\d-xx-xx$/';+ if (preg_match($pattern, $date)) {+ Log::debug(sprintf('"%s" is a year range.', $date));+ return true;}+ Log::debug(sprintf('"%s" is not a year range.', $date));- return $today;+ return false;}/**@@ -430,6 +387,27 @@ class ParseDateStringreturn false;}+ /**+ * @param string $date+ * @param Carbon $journalDate+ *+ * @return array+ */+ private function parseMonthDayRange(string $date, Carbon $journalDate): array+ {+ // Any year.+ // format of string is xxxx-MM-DD+ $validDate = str_replace(['xxxx'], [$journalDate->year], $date);+ Log::debug(sprintf('parseMonthDayRange: Parsed "%s" into "%s"', $date, $validDate));+ $start = Carbon::createFromFormat('Y-m-d', $validDate)->startOfDay();+ $end = Carbon::createFromFormat('Y-m-d', $validDate)->endOfDay();++ return [+ 'start' => $start,+ 'end' => $end,+ ];+ }+/*** @param string $date*@@ -455,12 +433,12 @@ class ParseDateString** @return array*/- private function parseMonthDayRange(string $date, Carbon $journalDate): array+ private function parseDayYearRange(string $date, Carbon $journalDate): array{// Any year.- // format of string is xxxx-MM-DD- $validDate = str_replace(['xxxx'], [$journalDate->year], $date);- Log::debug(sprintf('parseMonthDayRange: Parsed "%s" into "%s"', $date, $validDate));+ // format of string is YYYY-xx-DD+ $validDate = str_replace(['xx'], [$journalDate->format('m')], $date);+ Log::debug(sprintf('parseDayYearRange: Parsed "%s" into "%s"', $date, $validDate));$start = Carbon::createFromFormat('Y-m-d', $validDate)->startOfDay();$end = Carbon::createFromFormat('Y-m-d', $validDate)->endOfDay();@@ -470,20 +448,44 @@ class ParseDateString];}+ /**+ * @param string $date+ *+ * @return bool+ */+ protected function isMonthYearRange(string $date): bool+ {+ // if regex for YYYY-MM-xx:+ $pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-xx$/';+ if (preg_match($pattern, $date)) {+ Log::debug(sprintf('"%s" is a month/year range.', $date));++ return true;+ }+ Log::debug(sprintf('"%s" is not a month/year range.', $date));++ return false;+ }+/*** @param string $date* @param Carbon $journalDate** @return array*/- private function parseDayYearRange(string $date, Carbon $journalDate): array+ protected function parseMonthYearRange(string $date, Carbon $journalDate): array{- // Any year.- // format of string is YYYY-xx-DD- $validDate = str_replace(['xx'], [$journalDate->format('m')], $date);- Log::debug(sprintf('parseDayYearRange: Parsed "%s" into "%s"', $date, $validDate));- $start = Carbon::createFromFormat('Y-m-d', $validDate)->startOfDay();- $end = Carbon::createFromFormat('Y-m-d', $validDate)->endOfDay();+ // because 31 would turn February into March unexpectedly and the exact day is irrelevant here.+ $day = $journalDate->format('d');+ if ((int)$day > 28) {+ $day = '28';+ }++ // format of string is YYYY-MM-xx+ $validDate = str_replace(['xx'], [$day], $date);+ Log::debug(sprintf('parseMonthYearRange: Parsed "%s" into "%s"', $date, $validDate));+ $start = Carbon::createFromFormat('Y-m-d', $validDate)->startOfMonth();+ $end = Carbon::createFromFormat('Y-m-d', $validDate)->endOfMonth();return ['start' => $start,diff --git a/app/Support/Preferences.php b/app/Support/Preferences.phpindex de81c8e269..8f9a91862f 100644--- a/app/Support/Preferences.php+++ b/app/Support/Preferences.php@@ -38,6 +38,19 @@ use Session;*/class Preferences{+ /**+ * @return Collection+ */+ public function all(): Collection+ {+ $user = auth()->user();+ if (null === $user) {+ return new Collection;+ }++ return Preference::where('user_id', $user->id)->get();+ }+/*** @param User $user* @param string $search@@ -81,45 +94,14 @@ class Preferences}/**+ * @param User $user* @param string $name- * @param mixed $default- *- * @return Preference|null- * @throws FireflyException- */- public function get(string $name, $default = null): ?Preference- {- /** @var User|null $user */- $user = auth()->user();- if (null === $user) {- $preference = new Preference;- $preference->data = $default;-- return $preference;- }-- return $this->getForUser($user, $name, $default);- }-- /**- * @param string $name- * @param mixed $default- *- * @return Preference|null- * @throws FireflyException*/- public function getFresh(string $name, $default = null): ?Preference+ public function forget(User $user, string $name): void{- /** @var User|null $user */- $user = auth()->user();- if (null === $user) {- $preference = new Preference;- $preference->data = $default;-- return $preference;- }-- return $this->getFreshForUser($user, $name, $default);+ $key = sprintf('preference%s%s', $user->id, $name);+ Cache::forget($key);+ Cache::put($key, '', 5);}/**@@ -146,16 +128,38 @@ class Preferences}/**- * @return Collection+ * @param string $name+ * @param mixed $default+ *+ * @return Preference|null+ * @throws FireflyException*/- public function all(): Collection+ public function getFresh(string $name, $default = null): ?Preference{+ /** @var User|null $user */$user = auth()->user();- if(null === $user) {- return new Collection;+ if (null === $user) {+ $preference = new Preference;+ $preference->data = $default;++ return $preference;}- return Preference::where('user_id', $user->id)->get();+ return $this->getFreshForUser($user, $name, $default);+ }++ /**+ * @param User $user+ * @param string $name+ * @param null $default+ *+ * @return Preference|null+ * See reference nr. 44+ * @throws FireflyException+ */+ public function getFreshForUser(User $user, string $name, $default = null): ?Preference+ {+ return $this->getForUser($user, $name, $default);}/**@@ -168,7 +172,7 @@ class Preferences*/public function getForUser(User $user, string $name, $default = null): ?Preference{- $preference = Preference::where('user_id', $user->id)->where('name', $name)->first(['id','user_id', 'name', 'data', 'updated_at', 'created_at']);+ $preference = Preference::where('user_id', $user->id)->where('name', $name)->first(['id', 'user_id', 'name', 'data', 'updated_at', 'created_at']);if (null !== $preference && null === $preference->data) {try {$preference->delete();@@ -194,15 +198,44 @@ class Preferences/*** @param User $user* @param string $name- * @param null $default+ * @param mixed $value*- * @return Preference|null-* See reference nr. 44+ * @return Preference* @throws FireflyException*/- public function getFreshForUser(User $user, string $name, $default = null): ?Preference+ public function setForUser(User $user, string $name, $value): Preference{- return $this->getForUser($user, $name, $default);+ $fullName = sprintf('preference%s%s', $user->id, $name);+ Cache::forget($fullName);+ /** @var Preference|null $pref */+ $pref = Preference::where('user_id', $user->id)->where('name', $name)->first(['id', 'name', 'data', 'updated_at', 'created_at']);++ if (null !== $pref && null === $value) {+ try {+ $pref->delete();+ } catch (Exception $e) {+ throw new FireflyException(sprintf('Could not delete preference: %s', $e->getMessage()), 0, $e);+ }++ return new Preference;+ }+ if (null === $value) {+ return new Preference;+ }+ if (null === $pref) {+ $pref = new Preference;+ $pref->user_id = $user->id;+ $pref->name = $name;+ }+ $pref->data = $value;+ try {+ $pref->save();+ } catch (PDOException $e) {+ throw new FireflyException(sprintf('Could not save preference: %s', $e->getMessage()), 0, $e);+ }+ Cache::forever($fullName, $pref);++ return $pref;}/**@@ -224,88 +257,55 @@ class Preferencesreturn hash('sha256', $lastActivity);}- /**- *- */- public function mark(): void- {- $this->set('lastActivity', microtime());- Session::forget('first');- }-/*** @param string $name- * @param mixed $value+ * @param mixed $default*- * @return Preference+ * @return Preference|null* @throws FireflyException*/- public function set(string $name, $value): Preference+ public function get(string $name, $default = null): ?Preference{+ /** @var User|null $user */$user = auth()->user();if (null === $user) {- // make new preference, return it:- $pref = new Preference;- $pref->name = $name;- $pref->data = $value;+ $preference = new Preference;+ $preference->data = $default;- return $pref;+ return $preference;}- return $this->setForUser(auth()->user(), $name, $value);+ return $this->getForUser($user, $name, $default);}/**- * @param User $user- * @param string $name+ **/- public function forget(User $user, string $name): void+ public function mark(): void{- $key = sprintf('preference%s%s', $user->id, $name);- Cache::forget($key);- Cache::put($key, '', 5);+ $this->set('lastActivity', microtime());+ Session::forget('first');}/**- * @param User $user* @param string $name* @param mixed $value** @return Preference* @throws FireflyException*/- public function setForUser(User $user, string $name, $value): Preference+ public function set(string $name, $value): Preference{- $fullName = sprintf('preference%s%s', $user->id, $name);- Cache::forget($fullName);- /** @var Preference|null $pref */- $pref = Preference::where('user_id', $user->id)->where('name', $name)->first(['id', 'name', 'data', 'updated_at', 'created_at']);-- if (null !== $pref && null === $value) {- try {- $pref->delete();- } catch (Exception $e) {- throw new FireflyException(sprintf('Could not delete preference: %s', $e->getMessage()), 0, $e);- }-- return new Preference;- }- if (null === $value) {- return new Preference;- }- if(null === $pref) {- $pref = new Preference;- $pref->user_id = $user->id;+ $user = auth()->user();+ if (null === $user) {+ // make new preference, return it:+ $pref = new Preference;$pref->name = $name;+ $pref->data = $value;++ return $pref;}- $pref->data = $value;- try {- $pref->save();- } catch(PDOException $e) {- throw new FireflyException(sprintf('Could not save preference: %s', $e->getMessage()), 0, $e);- }- Cache::forever($fullName, $pref);- return $pref;+ return $this->setForUser(auth()->user(), $name, $value);}}diff --git a/app/Support/Report/Category/CategoryReportGenerator.php b/app/Support/Report/Category/CategoryReportGenerator.phpindex 5e4f9e45d1..cdaf8ac5e1 100644--- a/app/Support/Report/Category/CategoryReportGenerator.php+++ b/app/Support/Report/Category/CategoryReportGenerator.php@@ -22,6 +22,7 @@declare(strict_types=1);namespace FireflyIII\Support\Report\Category;+use Carbon\Carbon;use FireflyIII\Repositories\Category\NoCategoryRepositoryInterface;use FireflyIII\Repositories\Category\OperationsRepositoryInterface;diff --git a/app/Support/Repositories/Recurring/CalculateRangeOccurrences.php b/app/Support/Repositories/Recurring/CalculateRangeOccurrences.phpindex 58530fec37..87d1f78ee7 100644--- a/app/Support/Repositories/Recurring/CalculateRangeOccurrences.php+++ b/app/Support/Repositories/Recurring/CalculateRangeOccurrences.php@@ -56,6 +56,7 @@ trait CalculateRangeOccurrencesreturn $return;}+/*** Get the number of daily occurrences for a recurring transaction until date $end is reached. Will skip every $skipMod-1 occurrences.*@@ -88,6 +89,7 @@ trait CalculateRangeOccurrencesreturn $return;}+/*** Get the number of daily occurrences for a recurring transaction until date $end is reached. Will skip every $skipMod-1 occurrences.*diff --git a/app/Support/Repositories/Recurring/CalculateXOccurrences.php b/app/Support/Repositories/Recurring/CalculateXOccurrences.phpindex 18265fcf02..e8ff1fc664 100644--- a/app/Support/Repositories/Recurring/CalculateXOccurrences.php+++ b/app/Support/Repositories/Recurring/CalculateXOccurrences.php@@ -23,6 +23,7 @@declare(strict_types=1);namespace FireflyIII\Support\Repositories\Recurring;+use Carbon\Carbon;/**@@ -58,6 +59,7 @@ trait CalculateXOccurrencesreturn $return;}+/*** Calculates the number of monthly occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip* over $skipMod -1 recurrences.@@ -94,6 +96,7 @@ trait CalculateXOccurrencesreturn $return;}+/*** Calculates the number of NDOM occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip* over $skipMod -1 recurrences.@@ -131,6 +134,7 @@ trait CalculateXOccurrencesreturn $return;}+/*** Calculates the number of weekly occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip* over $skipMod -1 recurrences.@@ -172,6 +176,7 @@ trait CalculateXOccurrencesreturn $return;}+/*** Calculates the number of yearly occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip* over $skipMod -1 recurrences.diff --git a/app/Support/Repositories/Recurring/CalculateXOccurrencesSince.php b/app/Support/Repositories/Recurring/CalculateXOccurrencesSince.phpindex 2554a66acd..b3d4c56a35 100644--- a/app/Support/Repositories/Recurring/CalculateXOccurrencesSince.php+++ b/app/Support/Repositories/Recurring/CalculateXOccurrencesSince.php@@ -23,6 +23,7 @@declare(strict_types=1);namespace FireflyIII\Support\Repositories\Recurring;+use Carbon\Carbon;use Log;@@ -61,6 +62,7 @@ trait CalculateXOccurrencesSincereturn $return;}+/*** Calculates the number of monthly occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip* over $skipMod -1 recurrences.@@ -103,6 +105,7 @@ trait CalculateXOccurrencesSincereturn $return;}+/*** Calculates the number of NDOM occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip* over $skipMod -1 recurrences.@@ -142,6 +145,7 @@ trait CalculateXOccurrencesSincereturn $return;}+/*** Calculates the number of weekly occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip* over $skipMod -1 recurrences.@@ -186,6 +190,7 @@ trait CalculateXOccurrencesSincereturn $return;}+/*** Calculates the number of yearly occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip* over $skipMod -1 recurrences.diff --git a/app/Support/Request/ConvertsDataTypes.php b/app/Support/Request/ConvertsDataTypes.phpindex 880d8ed6f2..3ce46b1500 100644--- a/app/Support/Request/ConvertsDataTypes.php+++ b/app/Support/Request/ConvertsDataTypes.php@@ -32,6 +32,30 @@ use Log;*/trait ConvertsDataTypes{+ /**+ * Return integer value.+ *+ * @param string $field+ *+ * @return int+ */+ public function integer(string $field): int+ {+ return (int)$this->get($field);+ }++ /**+ * Return string value.+ *+ * @param string $field+ *+ * @return string+ */+ public function string(string $field): string+ {+ return $this->clearString((string)($this->get($field) ?? ''), false);+ }+/*** @param string|null $string* @param bool $keepNewlines@@ -40,7 +64,7 @@ trait ConvertsDataTypes*/public function clearString(?string $string, bool $keepNewlines = true): ?string{- if(null === $string) {+ if (null === $string) {return null;}$search = [@@ -98,30 +122,6 @@ trait ConvertsDataTypesreturn trim($string);}- /**- * Return integer value.- *- * @param string $field- *- * @return int- */- public function integer(string $field): int- {- return (int)$this->get($field);- }-- /**- * Return string value.- *- * @param string $field- *- * @return string- */- public function string(string $field): string- {- return $this->clearString((string)($this->get($field) ?? ''), false);- }-/*** Return string value with newlines.*diff --git a/app/Support/Search/AccountSearch.php b/app/Support/Search/AccountSearch.phpindex 62b4c9a3bd..5a111c40ea 100644--- a/app/Support/Search/AccountSearch.php+++ b/app/Support/Search/AccountSearch.php@@ -23,6 +23,7 @@declare(strict_types=1);namespace FireflyIII\Support\Search;+use FireflyIII\User;use Illuminate\Database\Eloquent\Builder;use Illuminate\Support\Collection;@@ -61,11 +62,11 @@ class AccountSearch implements GenericSearchInterfacepublic function search(): Collection{- $searchQuery = $this->user->accounts()- ->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id')- ->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')- ->whereIn('account_types.type', $this->types);- $like = sprintf('%%%s%%', $this->query);+ $searchQuery = $this->user->accounts()+ ->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id')+ ->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')+ ->whereIn('account_types.type', $this->types);+ $like = sprintf('%%%s%%', $this->query);$originalQuery = $this->query;switch ($this->field) {default:diff --git a/app/Support/Search/GenericSearchInterface.php b/app/Support/Search/GenericSearchInterface.phpindex 86273122a1..60b4539da7 100644--- a/app/Support/Search/GenericSearchInterface.php+++ b/app/Support/Search/GenericSearchInterface.php@@ -23,6 +23,7 @@declare(strict_types=1);namespace FireflyIII\Support\Search;+use Illuminate\Support\Collection;/**diff --git a/app/Support/Search/OperatorQuerySearch.php b/app/Support/Search/OperatorQuerySearch.phpindex 002f96cb8e..e0d38266d2 100644--- a/app/Support/Search/OperatorQuerySearch.php+++ b/app/Support/Search/OperatorQuerySearch.php@@ -50,7 +50,6 @@ use Gdbots\QueryParser\Node\Phrase;use Gdbots\QueryParser\Node\Subquery;use Gdbots\QueryParser\Node\Url;use Gdbots\QueryParser\Node\Word;-use Gdbots\QueryParser\ParsedQuery;use Gdbots\QueryParser\QueryParser;use Illuminate\Pagination\LengthAwarePaginator;use Illuminate\Support\Collection;@@ -68,6 +67,7 @@ class OperatorQuerySearch implements SearchInterfaceprivate GroupCollectorInterface $collector;private CurrencyRepositoryInterface $currencyRepository;private Carbon $date;+ private array $invalidOperators;private int $limit;private Collection $operators;private int $page;@@ -75,7 +75,6 @@ class OperatorQuerySearch implements SearchInterfaceprivate TagRepositoryInterface $tagRepository;private array $validOperators;private array $words;- private array $invalidOperators;/*** OperatorQuerySearch constructor.@@ -101,6 +100,14 @@ class OperatorQuerySearch implements SearchInterface$this->currencyRepository = app(CurrencyRepositoryInterface::class);}+ /**+ * @return array+ */+ public function getInvalidOperators(): array+ {+ return $this->invalidOperators;+ }+/*** @inheritDoc* @codeCoverageIgnore@@ -193,14 +200,6 @@ class OperatorQuerySearch implements SearchInterface$this->collector->setLimit($this->limit);}- /**- * @return array- */- public function getInvalidOperators(): array- {- return $this->invalidOperators;- }-/*** @inheritDoc* @codeCoverageIgnorediff --git a/app/Support/Search/SearchInterface.php b/app/Support/Search/SearchInterface.phpindex 40ca2e7050..a50f35c833 100644--- a/app/Support/Search/SearchInterface.php+++ b/app/Support/Search/SearchInterface.php@@ -33,19 +33,19 @@ use Illuminate\Support\Collection;interface SearchInterface{/**- * @return Collection+ * @return array*/- public function getModifiers(): Collection;+ public function getInvalidOperators(): array;/*** @return Collection*/- public function getOperators(): Collection;+ public function getModifiers(): Collection;/**- * @return array+ * @return Collection*/- public function getInvalidOperators(): array;+ public function getOperators(): Collection;/*** @return stringdiff --git a/app/Support/Steam.php b/app/Support/Steam.phpindex c912b1a556..5287febaee 100644--- a/app/Support/Steam.php+++ b/app/Support/Steam.php@@ -41,56 +41,6 @@ use stdClass;class Steam{- /**- * Gets balance at the end of current month by default- *- * @param Account $account- * @param Carbon $date- * @param TransactionCurrency|null $currency- *- * @return string- * @throws JsonException- */- public function balance(Account $account, Carbon $date, ?TransactionCurrency $currency = null): string- {- // abuse chart properties:- $cache = new CacheProperties;- $cache->addProperty($account->id);- $cache->addProperty('balance');- $cache->addProperty($date);- $cache->addProperty($currency ? $currency->id : 0);- if ($cache->has()) {- return $cache->get();- }- /** @var AccountRepositoryInterface $repository */- $repository = app(AccountRepositoryInterface::class);- if (null === $currency) {- $currency = $repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrencyByUser($account->user);- }- // first part: get all balances in own currency:- $transactions = $account->transactions()- ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')- ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))- ->where('transactions.transaction_currency_id', $currency->id)- ->get(['transactions.amount'])->toArray();- $nativeBalance = $this->sumTransactions($transactions, 'amount');- // get all balances in foreign currency:- $transactions = $account->transactions()- ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')- ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))- ->where('transactions.foreign_currency_id', $currency->id)- ->where('transactions.transaction_currency_id', '!=', $currency->id)- ->get(['transactions.foreign_amount'])->toArray();- $foreignBalance = $this->sumTransactions($transactions, 'foreign_amount');- $balance = bcadd($nativeBalance, $foreignBalance);- $virtual = null === $account->virtual_balance ? '0' : (string)$account->virtual_balance;- $balance = bcadd($balance, $virtual);-- $cache->store($balance);-- return $balance;- }-/*** @param Account $account* @param Carbon $date@@ -106,7 +56,7 @@ class Steam$cache->addProperty('balance-no-virtual');$cache->addProperty($date);if ($cache->has()) {- return $cache->get();+ return $cache->get();}/** @var AccountRepositoryInterface $repository */$repository = app(AccountRepositoryInterface::class);@@ -177,7 +127,7 @@ class Steam$cache->addProperty($start);$cache->addProperty($end);if ($cache->has()) {- return $cache->get();+ return $cache->get();}$start->subDay();@@ -208,11 +158,11 @@ class Steam->whereNull('transaction_journals.deleted_at')->get([ // @phpstan-ignore-line- 'transaction_journals.date',- 'transactions.transaction_currency_id',- DB::raw('SUM(transactions.amount) AS modified'),- 'transactions.foreign_currency_id',- DB::raw('SUM(transactions.foreign_amount) AS modified_foreign'),+ 'transaction_journals.date',+ 'transactions.transaction_currency_id',+ DB::raw('SUM(transactions.amount) AS modified'),+ 'transactions.foreign_currency_id',+ DB::raw('SUM(transactions.foreign_amount) AS modified_foreign'),]);@@ -244,35 +194,53 @@ class Steam}/**- * @param Account $account- * @param Carbon $date+ * Gets balance at the end of current month by default*- * @return array+ * @param Account $account+ * @param Carbon $date+ * @param TransactionCurrency|null $currency+ *+ * @return string* @throws JsonException*/- public function balancePerCurrency(Account $account, Carbon $date): array+ public function balance(Account $account, Carbon $date, ?TransactionCurrency $currency = null): string{// abuse chart properties:$cache = new CacheProperties;$cache->addProperty($account->id);- $cache->addProperty('balance-per-currency');+ $cache->addProperty('balance');$cache->addProperty($date);+ $cache->addProperty($currency ? $currency->id : 0);if ($cache->has()) {- return $cache->get();+ return $cache->get();}- $query = $account->transactions()- ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')- ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))- ->groupBy('transactions.transaction_currency_id');- $balances = $query->get(['transactions.transaction_currency_id', DB::raw('SUM(transactions.amount) as sum_for_currency')]); // @phpstan-ignore-line- $return = [];- /** @var stdClass $entry */- foreach ($balances as $entry) {- $return[(int)$entry->transaction_currency_id] = $entry->sum_for_currency;+ /** @var AccountRepositoryInterface $repository */+ $repository = app(AccountRepositoryInterface::class);+ if (null === $currency) {+ $currency = $repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrencyByUser($account->user);}- $cache->store($return);+ // first part: get all balances in own currency:+ $transactions = $account->transactions()+ ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')+ ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))+ ->where('transactions.transaction_currency_id', $currency->id)+ ->get(['transactions.amount'])->toArray();+ $nativeBalance = $this->sumTransactions($transactions, 'amount');+ // get all balances in foreign currency:+ $transactions = $account->transactions()+ ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')+ ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))+ ->where('transactions.foreign_currency_id', $currency->id)+ ->where('transactions.transaction_currency_id', '!=', $currency->id)+ ->get(['transactions.foreign_amount'])->toArray();+ $foreignBalance = $this->sumTransactions($transactions, 'foreign_amount');+ $balance = bcadd($nativeBalance, $foreignBalance);+ $virtual = null === $account->virtual_balance ? '0' : (string)$account->virtual_balance;+ $balance = bcadd($balance, $virtual);- return $return;+ $cache->store($balance);++ return $balance;}/**@@ -294,7 +262,7 @@ class Steam$cache->addProperty('balances');$cache->addProperty($date);if ($cache->has()) {- return $cache->get();+ return $cache->get();}// need to do this per account.@@ -327,7 +295,7 @@ class Steam$cache->addProperty('balances-per-currency');$cache->addProperty($date);if ($cache->has()) {- return $cache->get();+ return $cache->get();}// need to do this per account.@@ -342,6 +310,38 @@ class Steamreturn $result;}+ /**+ * @param Account $account+ * @param Carbon $date+ *+ * @return array+ * @throws JsonException+ */+ public function balancePerCurrency(Account $account, Carbon $date): array+ {+ // abuse chart properties:+ $cache = new CacheProperties;+ $cache->addProperty($account->id);+ $cache->addProperty('balance-per-currency');+ $cache->addProperty($date);+ if ($cache->has()) {+ return $cache->get();+ }+ $query = $account->transactions()+ ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')+ ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))+ ->groupBy('transactions.transaction_currency_id');+ $balances = $query->get(['transactions.transaction_currency_id', DB::raw('SUM(transactions.amount) as sum_for_currency')]); // @phpstan-ignore-line+ $return = [];+ /** @var stdClass $entry */+ foreach ($balances as $entry) {+ $return[(int)$entry->transaction_currency_id] = $entry->sum_for_currency;+ }+ $cache->store($return);++ return $return;+ }+/*** @param array $accounts*@@ -365,6 +365,51 @@ class Steamreturn $list;}+ /**+ * Get user's locale.+ *+ * @return string+ * @throws FireflyException+ */+ public function getLocale(): string // get preference+ {+ $locale = app('preferences')->get('locale', config('firefly.default_locale', 'equal'))->data;+ if ('equal' === $locale) {+ $locale = $this->getLanguage();+ }++ // Check for Windows to replace the locale correctly.+ if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {+ $locale = str_replace('_', '-', $locale);+ }++ return $locale;+ }++ /**+ * Get user's language.+ *+ * @return string+ * @throws FireflyException+ */+ public function getLanguage(): string // get preference+ {+ return app('preferences')->get('language', config('firefly.default_language', 'en_US'))->data;+ }++ /**+ * @param string $locale+ *+ * @return array+ */+ public function getLocaleArray(string $locale): array+ {+ return [+ sprintf('%s.utf8', $locale),+ sprintf('%s.UTF-8', $locale),+ ];+ }+/*** @param string $amount*@@ -446,49 +491,4 @@ class Steamreturn $amount;}- /**- * Get user's language.- *- * @return string- * @throws FireflyException- */- public function getLanguage(): string // get preference- {- return app('preferences')->get('language', config('firefly.default_language', 'en_US'))->data;- }-- /**- * Get user's locale.- *- * @return string- * @throws FireflyException- */- public function getLocale(): string // get preference- {- $locale = app('preferences')->get('locale', config('firefly.default_locale', 'equal'))->data;- if ('equal' === $locale) {- $locale = $this->getLanguage();- }-- // Check for Windows to replace the locale correctly.- if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {- $locale = str_replace('_', '-', $locale);- }-- return $locale;- }-- /**- * @param string $locale- *- * @return array- */- public function getLocaleArray(string $locale): array- {- return [- sprintf('%s.utf8', $locale),- sprintf('%s.UTF-8', $locale),- ];- }-}diff --git a/app/Support/Twig/AmountFormat.php b/app/Support/Twig/AmountFormat.phpindex a0f3f3d4b1..b874ba32ac 100644--- a/app/Support/Twig/AmountFormat.php+++ b/app/Support/Twig/AmountFormat.php@@ -93,7 +93,7 @@ class AmountFormat extends AbstractExtension* Will format the amount by the currency related to the given account.** @return TwigFunction-* See reference nr. 42+ * See reference nr. 42*/protected function formatAmountByAccount(): TwigFunction{diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.phpindex 5c3b7d8d72..df8e37cf58 100644--- a/app/Support/Twig/General.php+++ b/app/Support/Twig/General.php@@ -212,7 +212,7 @@ class General extends AbstractExtension$converter = new CommonMarkConverter(['allow_unsafe_links' => false, 'max_nesting_level' => 3, 'html_input' => 'escape'], $environment);- return (string) $converter->convertToHtml($text);+ return (string)$converter->convertToHtml($text);}, ['is_safe' => ['html']]);}diff --git a/app/Support/Twig/Translation.php b/app/Support/Twig/Translation.phpindex dafafca369..96dcd50083 100644--- a/app/Support/Twig/Translation.php+++ b/app/Support/Twig/Translation.php@@ -65,7 +65,7 @@ class Translation extends AbstractExtensionreturn new TwigFunction('journalLinkTranslation',static function (string $direction, string $original) {- $key = sprintf('firefly.%s_%s', $original, $direction);+ $key = sprintf('firefly.%s_%s', $original, $direction);$translation = trans($key);if ($key === $translation) {return $original;diff --git a/app/TransactionRules/Actions/ConvertToTransfer.php b/app/TransactionRules/Actions/ConvertToTransfer.phpindex d13e00a083..4d9f3063a4 100644--- a/app/TransactionRules/Actions/ConvertToTransfer.php+++ b/app/TransactionRules/Actions/ConvertToTransfer.php@@ -91,7 +91,7 @@ class ConvertToTransfer implements ActionInterfacereturn $this->convertDepositArray($journal, $asset);}- return false;+ return false;}/**diff --git a/app/TransactionRules/Actions/ConvertToWithdrawal.php b/app/TransactionRules/Actions/ConvertToWithdrawal.phpindex fa028db3f9..ea9faf6ec4 100644--- a/app/TransactionRules/Actions/ConvertToWithdrawal.php+++ b/app/TransactionRules/Actions/ConvertToWithdrawal.php@@ -73,7 +73,7 @@ class ConvertToWithdrawal implements ActionInterfacereturn $this->convertTransferArray($journal);}- return false;+ return false;}private function convertDepositArray(array $journal): booldiff --git a/app/TransactionRules/Actions/SetSourceAccount.php b/app/TransactionRules/Actions/SetSourceAccount.phpindex 6a7bf3e232..42e6c83356 100644--- a/app/TransactionRules/Actions/SetSourceAccount.php+++ b/app/TransactionRules/Actions/SetSourceAccount.php@@ -55,8 +55,8 @@ class SetSourceAccount implements ActionInterface*/public function actOnArray(array $journal): bool{- $user = User::find($journal['user_id']);- $type = $journal['transaction_type_type'];+ $user = User::find($journal['user_id']);+ $type = $journal['transaction_type_type'];/** @var TransactionJournal|null $object */$object = $user->transactionJournals()->find((int)$journal['transaction_journal_id']);$this->repository = app(AccountRepositoryInterface::class);diff --git a/app/TransactionRules/Actions/UpdatePiggybank.php b/app/TransactionRules/Actions/UpdatePiggybank.phpindex 4a274e91ac..6e4dcc0392 100644--- a/app/TransactionRules/Actions/UpdatePiggybank.php+++ b/app/TransactionRules/Actions/UpdatePiggybank.php@@ -98,7 +98,11 @@ class UpdatePiggybank implements ActionInterfacereturn true;}- Log::info(sprintf('Piggy bank is not linked to source ("#%d") or destination ("#%d"), so no action will be taken.', $source->account_id, $destination->account_id));+ Log::info(+ sprintf(+ 'Piggy bank is not linked to source ("#%d") or destination ("#%d"), so no action will be taken.', $source->account_id, $destination->account_id+ )+ );return true;}diff --git a/app/TransactionRules/Engine/SearchRuleEngine.php b/app/TransactionRules/Engine/SearchRuleEngine.phpindex 0604f46076..51bee50b61 100644--- a/app/TransactionRules/Engine/SearchRuleEngine.php+++ b/app/TransactionRules/Engine/SearchRuleEngine.php@@ -164,59 +164,6 @@ class SearchRuleEngine implements RuleEngineInterface$this->operators = [];}- /**- * Returns true if the rule has been triggered.- *- * @param Rule $rule- *- * @return bool- * @throws FireflyException- */- private function fireRule(Rule $rule): bool- {- Log::debug(sprintf('Now going to fire rule #%d', $rule->id));- if (false === $rule->active) {- Log::debug(sprintf('Rule #%d is not active!', $rule->id));-- return false;- }- if (true === $rule->strict) {- Log::debug(sprintf('Rule #%d is a strict rule.', $rule->id));-- return $this->fireStrictRule($rule);- }- Log::debug(sprintf('Rule #%d is not strict rule.', $rule->id));-- return $this->fireNonStrictRule($rule);- }-- /**- * Return true if the rule is fired (the collection is larger than zero).- *- * @param Rule $rule- *- * @return bool- * @throws FireflyException- */- private function fireStrictRule(Rule $rule): bool- {- Log::debug(sprintf('SearchRuleEngine::fireStrictRule(%d)!', $rule->id));- $collection = $this->findStrictRule($rule);-- $this->processResults($rule, $collection);- Log::debug(sprintf('SearchRuleEngine:: done processing strict rule #%d', $rule->id));-- $result = $collection->count() > 0;- if (true === $result) {- Log::debug(sprintf('SearchRuleEngine:: rule #%d was triggered (on %d transaction(s)).', $rule->id, $collection->count()));-- return true;- }- Log::debug(sprintf('SearchRuleEngine:: rule #%d was not triggered (on %d transaction(s)).', $rule->id, $collection->count()));-- return false;- }-/*** Finds the transactions a strict rule will execute on.*@@ -339,6 +286,138 @@ class SearchRuleEngine implements RuleEngineInterfacereturn today(config('app.timezone'));}+ /**+ * @param Rule $rule+ *+ * @return Collection+ */+ private function findNonStrictRule(Rule $rule): Collection+ {+ // start a search query for individual each trigger:+ $total = new Collection;+ $count = 0;++ /** @var Collection $triggers */+ $triggers = $rule->ruleTriggers;++ /** @var RuleTrigger $ruleTrigger */+ foreach ($triggers as $ruleTrigger) {+ if (false === $ruleTrigger->active) {+ continue;+ }+ if ('user_action' === $ruleTrigger->trigger_type) {+ Log::debug('Skip trigger type.');+ continue;+ }+ $searchArray = [];+ $needsContext = config(sprintf('firefly.search.operators.%s.needs_context', $ruleTrigger->trigger_type)) ?? true;+ if (false === $needsContext) {+ Log::debug(sprintf('SearchRuleEngine:: non strict, will search for: %s:true', $ruleTrigger->trigger_type));+ $searchArray[$ruleTrigger->trigger_type] = 'true';+ }+ if (true === $needsContext) {+ Log::debug(sprintf('SearchRuleEngine:: non strict, will search for: %s:"%s"', $ruleTrigger->trigger_type, $ruleTrigger->trigger_value));+ $searchArray[$ruleTrigger->trigger_type] = sprintf('"%s"', $ruleTrigger->trigger_value);+ }++ // then, add local operators as well:+ foreach ($this->operators as $operator) {+ Log::debug(sprintf('SearchRuleEngine:: add local added operator: %s:"%s"', $operator['type'], $operator['value']));+ $searchArray[$operator['type']] = sprintf('"%s"', $operator['value']);+ }++ // build and run the search engine.+ $searchEngine = app(SearchInterface::class);+ $searchEngine->setUser($this->user);+ $searchEngine->setPage(1);+ $searchEngine->setLimit(31337);++ foreach ($searchArray as $type => $value) {+ $searchEngine->parseQuery(sprintf('%s:%s', $type, $value));+ }++ $result = $searchEngine->searchTransactions();+ $collection = $result->getCollection();+ Log::debug(sprintf('Found in this run, %d transactions', $collection->count()));+ $total = $total->merge($collection);+ Log::debug(sprintf('Total collection is now %d transactions', $total->count()));+ $count++;+ }+ Log::debug(sprintf('Total collection is now %d transactions', $total->count()));+ Log::debug(sprintf('Done running %d trigger(s)', $count));++ // make collection unique+ $unique = $total->unique(+ function (array $group) {+ $str = '';+ foreach ($group['transactions'] as $transaction) {+ $str = sprintf('%s%d', $str, $transaction['transaction_journal_id']);+ }+ $key = sprintf('%d%s', $group['id'], $str);+ Log::debug(sprintf('Return key: %s ', $key));++ return $key;+ }+ );++ Log::debug(sprintf('SearchRuleEngine:: Found %d transactions using search engine.', $unique->count()));++ return $unique;+ }++ /**+ * Returns true if the rule has been triggered.+ *+ * @param Rule $rule+ *+ * @return bool+ * @throws FireflyException+ */+ private function fireRule(Rule $rule): bool+ {+ Log::debug(sprintf('Now going to fire rule #%d', $rule->id));+ if (false === $rule->active) {+ Log::debug(sprintf('Rule #%d is not active!', $rule->id));++ return false;+ }+ if (true === $rule->strict) {+ Log::debug(sprintf('Rule #%d is a strict rule.', $rule->id));++ return $this->fireStrictRule($rule);+ }+ Log::debug(sprintf('Rule #%d is not strict rule.', $rule->id));++ return $this->fireNonStrictRule($rule);+ }++ /**+ * Return true if the rule is fired (the collection is larger than zero).+ *+ * @param Rule $rule+ *+ * @return bool+ * @throws FireflyException+ */+ private function fireStrictRule(Rule $rule): bool+ {+ Log::debug(sprintf('SearchRuleEngine::fireStrictRule(%d)!', $rule->id));+ $collection = $this->findStrictRule($rule);++ $this->processResults($rule, $collection);+ Log::debug(sprintf('SearchRuleEngine:: done processing strict rule #%d', $rule->id));++ $result = $collection->count() > 0;+ if (true === $result) {+ Log::debug(sprintf('SearchRuleEngine:: rule #%d was triggered (on %d transaction(s)).', $rule->id, $collection->count()));++ return true;+ }+ Log::debug(sprintf('SearchRuleEngine:: rule #%d was not triggered (on %d transaction(s)).', $rule->id, $collection->count()));++ return false;+ }+/*** @param Rule $rule* @param Collection $collection@@ -444,85 +523,6 @@ class SearchRuleEngine implements RuleEngineInterfacereturn $collection->count() > 0;}- /**- * @param Rule $rule- *- * @return Collection- */- private function findNonStrictRule(Rule $rule): Collection- {- // start a search query for individual each trigger:- $total = new Collection;- $count = 0;-- /** @var Collection $triggers */- $triggers = $rule->ruleTriggers;-- /** @var RuleTrigger $ruleTrigger */- foreach ($triggers as $ruleTrigger) {- if (false === $ruleTrigger->active) {- continue;- }- if ('user_action' === $ruleTrigger->trigger_type) {- Log::debug('Skip trigger type.');- continue;- }- $searchArray = [];- $needsContext = config(sprintf('firefly.search.operators.%s.needs_context', $ruleTrigger->trigger_type)) ?? true;- if (false === $needsContext) {- Log::debug(sprintf('SearchRuleEngine:: non strict, will search for: %s:true', $ruleTrigger->trigger_type));- $searchArray[$ruleTrigger->trigger_type] = 'true';- }- if (true === $needsContext) {- Log::debug(sprintf('SearchRuleEngine:: non strict, will search for: %s:"%s"', $ruleTrigger->trigger_type, $ruleTrigger->trigger_value));- $searchArray[$ruleTrigger->trigger_type] = sprintf('"%s"', $ruleTrigger->trigger_value);- }-- // then, add local operators as well:- foreach ($this->operators as $operator) {- Log::debug(sprintf('SearchRuleEngine:: add local added operator: %s:"%s"', $operator['type'], $operator['value']));- $searchArray[$operator['type']] = sprintf('"%s"', $operator['value']);- }-- // build and run the search engine.- $searchEngine = app(SearchInterface::class);- $searchEngine->setUser($this->user);- $searchEngine->setPage(1);- $searchEngine->setLimit(31337);-- foreach ($searchArray as $type => $value) {- $searchEngine->parseQuery(sprintf('%s:%s', $type, $value));- }-- $result = $searchEngine->searchTransactions();- $collection = $result->getCollection();- Log::debug(sprintf('Found in this run, %d transactions', $collection->count()));- $total = $total->merge($collection);- Log::debug(sprintf('Total collection is now %d transactions', $total->count()));- $count++;- }- Log::debug(sprintf('Total collection is now %d transactions', $total->count()));- Log::debug(sprintf('Done running %d trigger(s)', $count));-- // make collection unique- $unique = $total->unique(- function (array $group) {- $str = '';- foreach ($group['transactions'] as $transaction) {- $str = sprintf('%s%d', $str, $transaction['transaction_journal_id']);- }- $key = sprintf('%d%s', $group['id'], $str);- Log::debug(sprintf('Return key: %s ', $key));-- return $key;- }- );-- Log::debug(sprintf('SearchRuleEngine:: Found %d transactions using search engine.', $unique->count()));-- return $unique;- }-/*** @param RuleGroup $group*diff --git a/app/Transformers/AccountTransformer.php b/app/Transformers/AccountTransformer.phpindex 438f066229..2d99589767 100644--- a/app/Transformers/AccountTransformer.php+++ b/app/Transformers/AccountTransformer.php@@ -24,8 +24,10 @@ declare(strict_types=1);namespace FireflyIII\Transformers;use Carbon\Carbon;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\Account;use FireflyIII\Repositories\Account\AccountRepositoryInterface;+use JsonException;/*** Class AccountTransformer@@ -51,8 +53,8 @@ class AccountTransformer extends AbstractTransformer* @param Account $account** @return array- * @throws \FireflyIII\Exceptions\FireflyException- * @throws \JsonException+ * @throws FireflyException+ * @throws JsonException*/public function transform(Account $account): array{@@ -121,7 +123,7 @@ class AccountTransformer extends AbstractTransformer'liability_direction' => $liabilityDirection,'interest' => $interest,'interest_period' => $interestPeriod,- 'current_debt' => $this->repository->getMetaValue($account,'current_debt'),+ 'current_debt' => $this->repository->getMetaValue($account, 'current_debt'),'include_net_worth' => $includeNetWorth,'longitude' => $longitude,'latitude' => $latitude,@@ -214,7 +216,7 @@ class AccountTransformer extends AbstractTransformer** @return array*-* See reference nr. 20+ * See reference nr. 20*/private function getOpeningBalance(Account $account, string $accountType): array{diff --git a/app/Transformers/AttachmentTransformer.php b/app/Transformers/AttachmentTransformer.phpindex 2d579f01cb..5d858ddd25 100644--- a/app/Transformers/AttachmentTransformer.php+++ b/app/Transformers/AttachmentTransformer.php@@ -22,6 +22,7 @@declare(strict_types=1);namespace FireflyIII\Transformers;+use FireflyIII\Models\Attachment;use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;diff --git a/app/Transformers/AvailableBudgetTransformer.php b/app/Transformers/AvailableBudgetTransformer.phpindex 9ed54128b1..69ed09f4fa 100644--- a/app/Transformers/AvailableBudgetTransformer.php+++ b/app/Transformers/AvailableBudgetTransformer.php@@ -97,7 +97,7 @@ class AvailableBudgetTransformer extends AbstractTransformerprivate function getSpentInBudgets(): array{$allActive = $this->repository->getActiveBudgets();- $sums = $this->opsRepository->sumExpenses($this->parameters->get('start'), $this->parameters->get('end'), null, $allActive);+ $sums = $this->opsRepository->sumExpenses($this->parameters->get('start'), $this->parameters->get('end'), null, $allActive);return array_values($sums);}diff --git a/app/Transformers/BudgetLimitTransformer.php b/app/Transformers/BudgetLimitTransformer.phpindex 264a53433e..dfcc2e43ba 100644--- a/app/Transformers/BudgetLimitTransformer.php+++ b/app/Transformers/BudgetLimitTransformer.php@@ -62,7 +62,7 @@ class BudgetLimitTransformer extends AbstractTransformer{$repository = app(OperationsRepository::class);$repository->setUser($budgetLimit->budget->user);- $expenses = $repository->sumExpenses(+ $expenses = $repository->sumExpenses($budgetLimit->start_date, $budgetLimit->end_date, null, new Collection([$budgetLimit->budget]), $budgetLimit->transactionCurrency);$currency = $budgetLimit->transactionCurrency;diff --git a/app/Transformers/BudgetTransformer.php b/app/Transformers/BudgetTransformer.phpindex c6f08544aa..4fcc75d2db 100644--- a/app/Transformers/BudgetTransformer.php+++ b/app/Transformers/BudgetTransformer.php@@ -22,6 +22,7 @@declare(strict_types=1);namespace FireflyIII\Transformers;+use FireflyIII\Models\AutoBudget;use FireflyIII\Models\Budget;use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;diff --git a/app/Transformers/CategoryTransformer.php b/app/Transformers/CategoryTransformer.phpindex 4ece2543ca..129e95d357 100644--- a/app/Transformers/CategoryTransformer.php+++ b/app/Transformers/CategoryTransformer.php@@ -22,6 +22,7 @@declare(strict_types=1);namespace FireflyIII\Transformers;+use FireflyIII\Models\Category;use FireflyIII\Repositories\Category\CategoryRepositoryInterface;use FireflyIII\Repositories\Category\OperationsRepositoryInterface;diff --git a/app/Transformers/LinkTypeTransformer.php b/app/Transformers/LinkTypeTransformer.phpindex 9bdf19cb2f..13f3b36eb5 100644--- a/app/Transformers/LinkTypeTransformer.php+++ b/app/Transformers/LinkTypeTransformer.php@@ -22,6 +22,7 @@declare(strict_types=1);namespace FireflyIII\Transformers;+use FireflyIII\Models\LinkType;/**diff --git a/app/Transformers/ObjectGroupTransformer.php b/app/Transformers/ObjectGroupTransformer.phpindex e6509fcc30..d8c19bc2bd 100644--- a/app/Transformers/ObjectGroupTransformer.php+++ b/app/Transformers/ObjectGroupTransformer.php@@ -22,6 +22,7 @@declare(strict_types=1);namespace FireflyIII\Transformers;+use FireflyIII\Models\ObjectGroup;use FireflyIII\Repositories\ObjectGroup\ObjectGroupRepositoryInterface;diff --git a/app/Transformers/PiggyBankEventTransformer.php b/app/Transformers/PiggyBankEventTransformer.phpindex ef4e34ed2b..7f5af318fe 100644--- a/app/Transformers/PiggyBankEventTransformer.php+++ b/app/Transformers/PiggyBankEventTransformer.php@@ -22,6 +22,7 @@declare(strict_types=1);namespace FireflyIII\Transformers;+use FireflyIII\Models\PiggyBankEvent;use FireflyIII\Repositories\Account\AccountRepositoryInterface;use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;diff --git a/app/Transformers/PiggyBankTransformer.php b/app/Transformers/PiggyBankTransformer.phpindex 1116f3b63c..43abb9da39 100644--- a/app/Transformers/PiggyBankTransformer.php+++ b/app/Transformers/PiggyBankTransformer.php@@ -22,6 +22,7 @@declare(strict_types=1);namespace FireflyIII\Transformers;+use FireflyIII\Models\ObjectGroup;use FireflyIII\Models\PiggyBank;use FireflyIII\Repositories\Account\AccountRepositoryInterface;@@ -48,6 +49,7 @@ class PiggyBankTransformer extends AbstractTransformer$this->currencyRepos = app(CurrencyRepositoryInterface::class);$this->piggyRepos = app(PiggyBankRepositoryInterface::class);}+/*** Transform the piggy bank.*diff --git a/app/Transformers/PreferenceTransformer.php b/app/Transformers/PreferenceTransformer.phpindex f48b92f3e8..c085fbffd7 100644--- a/app/Transformers/PreferenceTransformer.php+++ b/app/Transformers/PreferenceTransformer.php@@ -22,6 +22,7 @@declare(strict_types=1);namespace FireflyIII\Transformers;+use FireflyIII\Models\Preference;/**diff --git a/app/Transformers/RecurrenceTransformer.php b/app/Transformers/RecurrenceTransformer.phpindex 77c4394dc3..0bbbb4d37b 100644--- a/app/Transformers/RecurrenceTransformer.php+++ b/app/Transformers/RecurrenceTransformer.php@@ -42,11 +42,11 @@ use Log;*/class RecurrenceTransformer extends AbstractTransformer{+ private BillRepositoryInterface $billRepos;private BudgetRepositoryInterface $budgetRepos;private CategoryFactory $factory;private PiggyBankRepositoryInterface $piggyRepos;private RecurringRepositoryInterface $repository;- private BillRepositoryInterface $billRepos;/*** RecurrenceTransformer constructor.diff --git a/app/Transformers/RuleTransformer.php b/app/Transformers/RuleTransformer.phpindex af403daaae..c21599ed35 100644--- a/app/Transformers/RuleTransformer.php+++ b/app/Transformers/RuleTransformer.php@@ -22,6 +22,7 @@declare(strict_types=1);namespace FireflyIII\Transformers;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\Rule;use FireflyIII\Models\RuleAction;diff --git a/app/Transformers/TagTransformer.php b/app/Transformers/TagTransformer.phpindex 0f3e00d862..56978c9793 100644--- a/app/Transformers/TagTransformer.php+++ b/app/Transformers/TagTransformer.php@@ -22,6 +22,7 @@declare(strict_types=1);namespace FireflyIII\Transformers;+use FireflyIII\Models\Location;use FireflyIII\Models\Tag;@@ -34,7 +35,7 @@ class TagTransformer extends AbstractTransformer/*** Transform a tag.*-* See reference nr. 21+ * See reference nr. 21** @param Tag $tag*diff --git a/app/Transformers/TransactionLinkTransformer.php b/app/Transformers/TransactionLinkTransformer.phpindex e53bf42c72..b9f3ede0bf 100644--- a/app/Transformers/TransactionLinkTransformer.php+++ b/app/Transformers/TransactionLinkTransformer.php@@ -22,6 +22,7 @@declare(strict_types=1);namespace FireflyIII\Transformers;+use FireflyIII\Models\TransactionJournalLink;use FireflyIII\Repositories\Journal\JournalRepositoryInterface;diff --git a/app/Transformers/UserTransformer.php b/app/Transformers/UserTransformer.phpindex 83aee3177a..39277ad186 100644--- a/app/Transformers/UserTransformer.php+++ b/app/Transformers/UserTransformer.php@@ -22,6 +22,7 @@declare(strict_types=1);namespace FireflyIII\Transformers;+use FireflyIII\Repositories\User\UserRepositoryInterface;use FireflyIII\User;diff --git a/app/Transformers/WebhookAttemptTransformer.php b/app/Transformers/WebhookAttemptTransformer.phpindex 4e8c8a3990..082828e8ce 100644--- a/app/Transformers/WebhookAttemptTransformer.php+++ b/app/Transformers/WebhookAttemptTransformer.php@@ -22,6 +22,7 @@declare(strict_types=1);namespace FireflyIII\Transformers;+use FireflyIII\Models\WebhookAttempt;/**diff --git a/app/User.php b/app/User.phpindex 875f950a6b..ac707d8d60 100644--- a/app/User.php+++ b/app/User.php@@ -151,10 +151,10 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;* @method static Builder|User whereGuid($value)* @method static Builder|User whereTwoFactorRecoveryCodes($value)* @method static Builder|User whereTwoFactorSecret($value)- * @property int|null $user_group_id- * @property-read \Illuminate\Database\Eloquent\Collection|GroupMembership[] $groupMemberships- * @property-read int|null $group_memberships_count- * @property-read UserGroup|null $userGroup+ * @property int|null $user_group_id+ * @property-read \Illuminate\Database\Eloquent\Collection|GroupMembership[] $groupMemberships+ * @property-read int|null $group_memberships_count+ * @property-read UserGroup|null $userGroup* @method static Builder|User whereUserGroupId($value)*/class User extends Authenticatable@@ -222,133 +222,164 @@ class User extends Authenticatable/*** @codeCoverageIgnore+ * Link to attachments** @return HasMany*/- public function groupMemberships(): HasMany+ public function attachments(): HasMany{- return $this->hasMany(GroupMembership::class)->with(['userGroup','userRole']);+ return $this->hasMany(Attachment::class);}/*** @codeCoverageIgnore- * Link to attachments+ * Link to available budgets** @return HasMany*/- public function attachments(): HasMany+ public function availableBudgets(): HasMany{- return $this->hasMany(Attachment::class);+ return $this->hasMany(AvailableBudget::class);}/*** @codeCoverageIgnore- *- * Link to webhooks+ * Link to bills.** @return HasMany*/- public function webhooks(): HasMany+ public function bills(): HasMany{- return $this->hasMany(Webhook::class);+ return $this->hasMany(Bill::class);}/**- * @param string $role+ * @codeCoverageIgnore+ * Link to budgets.*- * @return bool+ * @return HasMany*/- public function hasRole(string $role): bool+ public function budgets(): HasMany{- return $this->roles()->where('name', $role)->count() === 1;+ return $this->hasMany(Budget::class);}/*** @codeCoverageIgnore- * Link to available budgets+ * Link to categories** @return HasMany*/- public function availableBudgets(): HasMany+ public function categories(): HasMany{- return $this->hasMany(AvailableBudget::class);+ return $this->hasMany(Category::class);}/*** @codeCoverageIgnore- * Link to bills.+ * Link to currency exchange rates** @return HasMany*/- public function bills(): HasMany+ public function currencyExchangeRates(): HasMany{- return $this->hasMany(Bill::class);+ return $this->hasMany(CurrencyExchangeRate::class);}/*** @codeCoverageIgnore- * Link to budgets.+ * Generates access token.*- * @return HasMany+ * @return string+ * @throws Exception*/- public function budgets(): HasMany+ public function generateAccessToken(): string{- return $this->hasMany(Budget::class);+ $bytes = random_bytes(16);++ return bin2hex($bytes);}/**- * @codeCoverageIgnore- * Link to object groups.+ * Get the models LDAP domain.*- * @return HasMany+ * @return string*/- public function objectGroups(): HasMany+ public function getLdapDomain(){- return $this->hasMany(ObjectGroup::class);+ return $this->{$this->getLdapDomainColumn()};}/**- * @codeCoverageIgnore- * Link to categories+ * Get the database column name of the domain.*- * @return HasMany+ * @return string*/- public function categories(): HasMany+ public function getLdapDomainColumn(){- return $this->hasMany(Category::class);+ return 'domain';}/**- * @codeCoverageIgnore- * @return BelongsTo+ * Get the models LDAP GUID.+ *+ * @return string*/- public function userGroup(): BelongsTo+ public function getLdapGuid(){- return $this->belongsTo(UserGroup::class,);+ return $this->{$this->getLdapGuidColumn()};}++ /**+ * Get the models LDAP GUID database column name.+ *+ * @return string+ */+ public function getLdapGuidColumn()+ {+ return 'objectguid';+ }+/*** @codeCoverageIgnore- * Link to currency exchange rates** @return HasMany*/- public function currencyExchangeRates(): HasMany+ public function groupMemberships(): HasMany{- return $this->hasMany(CurrencyExchangeRate::class);+ return $this->hasMany(GroupMembership::class)->with(['userGroup', 'userRole']);+ }++ /**+ * @param string $role+ *+ * @return bool+ */+ public function hasRole(string $role): bool+ {+ return $this->roles()->where('name', $role)->count() === 1;}/*** @codeCoverageIgnore- * Generates access token.+ * Link to roles.*- * @return string- * @throws Exception+ * @return BelongsToMany*/- public function generateAccessToken(): string+ public function roles(): BelongsToMany{- $bytes = random_bytes(16);+ return $this->belongsToMany(Role::class);+ }- return bin2hex($bytes);+ /**+ * @codeCoverageIgnore+ * Link to object groups.+ *+ * @return HasMany+ */+ public function objectGroups(): HasMany+ {+ return $this->hasMany(ObjectGroup::class);}/**@@ -384,17 +415,6 @@ class User extends Authenticatablereturn $this->hasMany(Recurrence::class);}- /**- * @codeCoverageIgnore- * Link to roles.- *- * @return BelongsToMany- */- public function roles(): BelongsToMany- {- return $this->belongsToMany(Role::class);- }-/*** @codeCoverageIgnore* Link to rule groups.@@ -430,6 +450,32 @@ class User extends Authenticatableevent(new RequestedNewPassword($this, $token, $ipAddress));}+ /**+ * Set the models LDAP domain.+ *+ * @param string $domain+ *+ * @return void+ */+ public function setLdapDomain($domain)+ {+ $this->{$this->getLdapDomainColumn()} = $domain;+ }++ /**+ * Set the models LDAP GUID.+ *+ * @param string $guid+ *+ * @return void+ */+ public function setLdapGuid($guid)+ {+ $this->{$this->getLdapGuidColumn()} = $guid;+ }++ // start LDAP related code+/*** @codeCoverageIgnore* Link to tags.@@ -474,70 +520,25 @@ class User extends Authenticatablereturn $this->hasManyThrough(Transaction::class, TransactionJournal::class);}- // start LDAP related code-- /**- * Get the database column name of the domain.- *- * @return string- */- public function getLdapDomainColumn()- {- return 'domain';- }-- /**- * Get the models LDAP domain.- *- * @return string- */- public function getLdapDomain()- {- return $this->{$this->getLdapDomainColumn()};- }-/**- * Set the models LDAP domain.- *- * @param string $domain- *- * @return void- */- public function setLdapDomain($domain)- {- $this->{$this->getLdapDomainColumn()} = $domain;- }-- /**- * Get the models LDAP GUID database column name.- *- * @return string- */- public function getLdapGuidColumn()- {- return 'objectguid';- }-- /**- * Get the models LDAP GUID.- *- * @return string+ * @codeCoverageIgnore+ * @return BelongsTo*/- public function getLdapGuid()+ public function userGroup(): BelongsTo{- return $this->{$this->getLdapGuidColumn()};+ return $this->belongsTo(UserGroup::class,);}/**- * Set the models LDAP GUID.+ * @codeCoverageIgnore*- * @param string $guid+ * Link to webhooks*- * @return void+ * @return HasMany*/- public function setLdapGuid($guid)+ public function webhooks(): HasMany{- $this->{$this->getLdapGuidColumn()} = $guid;+ return $this->hasMany(Webhook::class);}// end LDAP related code}diff --git a/app/Validation/Account/DepositValidation.php b/app/Validation/Account/DepositValidation.phpindex ecc3d6156e..d168e3add6 100644--- a/app/Validation/Account/DepositValidation.php+++ b/app/Validation/Account/DepositValidation.php@@ -32,6 +32,22 @@ use Log;*/trait DepositValidation{+ /**+ * @param array $accountTypes+ *+ * @return bool+ */+ abstract protected function canCreateTypes(array $accountTypes): bool;++ /**+ * @param array $validTypes+ * @param int $accountId+ * @param string $accountName+ *+ * @return Account|null+ */+ abstract protected function findExistingAccount(array $validTypes, int $accountId, string $accountName): ?Account;+/*** @param int|null $accountId* @param mixed $accountName@@ -78,22 +94,6 @@ trait DepositValidationreturn $result;}- /**- * @param array $accountTypes- *- * @return bool- */- abstract protected function canCreateTypes(array $accountTypes): bool;-- /**- * @param array $validTypes- * @param int $accountId- * @param string $accountName- *- * @return Account|null- */- abstract protected function findExistingAccount(array $validTypes, int $accountId, string $accountName): ?Account;-/*** @param int|null $accountId* @param string|null $accountNamediff --git a/app/Validation/Account/LiabilityValidation.php b/app/Validation/Account/LiabilityValidation.phpindex f8990f4190..2c19b5e0a1 100644--- a/app/Validation/Account/LiabilityValidation.php+++ b/app/Validation/Account/LiabilityValidation.php@@ -35,31 +35,6 @@ use Log;trait LiabilityValidation{- /**- * Source of an liability credit must be a liability.- *- * @param string|null $accountName- *- * @return bool- */- protected function validateLCSource(?string $accountName): bool- {- $result = true;- Log::debug(sprintf('Now in validateLCDestination("%s")', $accountName));- if ('' === $accountName || null === $accountName) {- $result = false;- }- if (true === $result) {- // set the source to be a (dummy) revenue account.- $account = new Account;- $accountType = AccountType::whereType(AccountType::LIABILITY_CREDIT)->first();- $account->accountType = $accountType;- $this->source = $account;- }-- return $result;- }-/*** @param int|null $accountId*@@ -96,4 +71,29 @@ trait LiabilityValidationreturn $result ?? false;}+ /**+ * Source of an liability credit must be a liability.+ *+ * @param string|null $accountName+ *+ * @return bool+ */+ protected function validateLCSource(?string $accountName): bool+ {+ $result = true;+ Log::debug(sprintf('Now in validateLCDestination("%s")', $accountName));+ if ('' === $accountName || null === $accountName) {+ $result = false;+ }+ if (true === $result) {+ // set the source to be a (dummy) revenue account.+ $account = new Account;+ $accountType = AccountType::whereType(AccountType::LIABILITY_CREDIT)->first();+ $account->accountType = $accountType;+ $this->source = $account;+ }++ return $result;+ }+}diff --git a/app/Validation/Account/OBValidation.php b/app/Validation/Account/OBValidation.phpindex 3f61b4d5a4..8b934cda2f 100644--- a/app/Validation/Account/OBValidation.php+++ b/app/Validation/Account/OBValidation.php@@ -33,6 +33,13 @@ use Log;*/trait OBValidation{+ /**+ * @param array $accountTypes+ *+ * @return bool+ */+ abstract protected function canCreateTypes(array $accountTypes): bool;+/*** @param int|null $accountId* @param mixed $accountName@@ -79,13 +86,6 @@ trait OBValidationreturn $result;}- /**- * @param array $accountTypes- *- * @return bool- */- abstract protected function canCreateTypes(array $accountTypes): bool;-/*** Source of an opening balance can either be an asset account* or an "initial balance account". The latter can be created.diff --git a/app/Validation/Account/TransferValidation.php b/app/Validation/Account/TransferValidation.phpindex 70554a6f1c..e656883645 100644--- a/app/Validation/Account/TransferValidation.php+++ b/app/Validation/Account/TransferValidation.php@@ -31,6 +31,22 @@ use Log;*/trait TransferValidation{+ /**+ * @param array $accountTypes+ *+ * @return bool+ */+ abstract protected function canCreateTypes(array $accountTypes): bool;++ /**+ * @param array $validTypes+ * @param int $accountId+ * @param string $accountName+ *+ * @return Account|null+ */+ abstract protected function findExistingAccount(array $validTypes, int $accountId, string $accountName): ?Account;+/*** @param int|null $accountId* @param mixed $accountName@@ -71,22 +87,6 @@ trait TransferValidationreturn true;}- /**- * @param array $accountTypes- *- * @return bool- */- abstract protected function canCreateTypes(array $accountTypes): bool;-- /**- * @param array $validTypes- * @param int $accountId- * @param string $accountName- *- * @return Account|null- */- abstract protected function findExistingAccount(array $validTypes, int $accountId, string $accountName): ?Account;-/*** @param int|null $accountId* @param string|null $accountNamediff --git a/app/Validation/Account/WithdrawalValidation.php b/app/Validation/Account/WithdrawalValidation.phpindex f3b5efa66f..49878cb253 100644--- a/app/Validation/Account/WithdrawalValidation.php+++ b/app/Validation/Account/WithdrawalValidation.php@@ -32,6 +32,22 @@ use Log;*/trait WithdrawalValidation{+ /**+ * @param array $accountTypes+ *+ * @return bool+ */+ abstract protected function canCreateTypes(array $accountTypes): bool;++ /**+ * @param array $validTypes+ * @param int $accountId+ * @param string $accountName+ *+ * @return Account|null+ */+ abstract protected function findExistingAccount(array $validTypes, int $accountId, string $accountName): ?Account;+/*** @param int|null $accountId* @param string|null $accountName@@ -103,13 +119,6 @@ trait WithdrawalValidationreturn true === $this->canCreateTypes($validTypes);}- /**- * @param array $accountTypes- *- * @return bool- */- abstract protected function canCreateTypes(array $accountTypes): bool;-/*** @param int|null $accountId* @param string|null $accountName@@ -143,13 +152,4 @@ trait WithdrawalValidationreturn true;}-- /**- * @param array $validTypes- * @param int $accountId- * @param string $accountName- *- * @return Account|null- */- abstract protected function findExistingAccount(array $validTypes, int $accountId, string $accountName): ?Account;}diff --git a/app/Validation/AccountValidator.php b/app/Validation/AccountValidator.phpindex 7856a3e512..d440cfd786 100644--- a/app/Validation/AccountValidator.php+++ b/app/Validation/AccountValidator.php@@ -30,11 +30,11 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;use FireflyIII\User;use FireflyIII\Validation\Account\AccountValidatorProperties;use FireflyIII\Validation\Account\DepositValidation;+use FireflyIII\Validation\Account\LiabilityValidation;use FireflyIII\Validation\Account\OBValidation;use FireflyIII\Validation\Account\ReconciliationValidation;use FireflyIII\Validation\Account\TransferValidation;use FireflyIII\Validation\Account\WithdrawalValidation;-use FireflyIII\Validation\Account\LiabilityValidation;use Log;/**@@ -202,21 +202,6 @@ class AccountValidatorreturn false;}- /**- * @param string $accountType- *- * @return bool- */- protected function canCreateType(string $accountType): bool- {- $canCreate = [AccountType::EXPENSE, AccountType::REVENUE, AccountType::INITIAL_BALANCE, AccountType::LIABILITY_CREDIT];- if (in_array($accountType, $canCreate, true)) {- return true;- }-- return false;- }-/*** @param array $validTypes* @param int $accountId@@ -242,4 +227,19 @@ class AccountValidatorreturn null;}+ /**+ * @param string $accountType+ *+ * @return bool+ */+ protected function canCreateType(string $accountType): bool+ {+ $canCreate = [AccountType::EXPENSE, AccountType::REVENUE, AccountType::INITIAL_BALANCE, AccountType::LIABILITY_CREDIT];+ if (in_array($accountType, $canCreate, true)) {+ return true;+ }++ return false;+ }+}diff --git a/app/Validation/Api/Data/Bulk/ValidatesBulkTransactionQuery.php b/app/Validation/Api/Data/Bulk/ValidatesBulkTransactionQuery.phpindex 71c88d91d9..66175ddb8f 100644--- a/app/Validation/Api/Data/Bulk/ValidatesBulkTransactionQuery.php+++ b/app/Validation/Api/Data/Bulk/ValidatesBulkTransactionQuery.php@@ -66,10 +66,11 @@ trait ValidatesBulkTransactionQuery}if ($source->accountType->type !== $dest->accountType->type) {$validator->errors()->add('query', (string)trans('validation.invalid_query_account_type'));+return;}// must have same currency:- if($repository->getAccountCurrency($source)->id !== $repository->getAccountCurrency($dest)->id) {+ if ($repository->getAccountCurrency($source)->id !== $repository->getAccountCurrency($dest)->id) {$validator->errors()->add('query', (string)trans('validation.invalid_query_currency'));}}diff --git a/app/Validation/AutoBudget/ValidatesAutoBudgetRequest.php b/app/Validation/AutoBudget/ValidatesAutoBudgetRequest.phpindex 8ad87b7e61..b449eaf527 100644--- a/app/Validation/AutoBudget/ValidatesAutoBudgetRequest.php+++ b/app/Validation/AutoBudget/ValidatesAutoBudgetRequest.php@@ -50,6 +50,7 @@ trait ValidatesAutoBudgetRequest// basic float check:if (!is_numeric($amount)) {$validator->errors()->add('auto_budget_amount', (string)trans('validation.amount_required_for_auto_budget'));+return;}diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.phpindex a8febacce8..69f6b11762 100644--- a/app/Validation/FireflyValidator.php+++ b/app/Validation/FireflyValidator.php@@ -172,7 +172,7 @@ class FireflyValidator extends Validator"\u{3000}", // ideographic space"\u{FEFF}", // zero width no -break space'-',- '?'+ '?',];$replace = '';$value = str_replace($search, $replace, $value);@@ -198,6 +198,7 @@ class FireflyValidator extends Validator$message = sprintf('Could not validate IBAN check value "%s" (IBAN "%s")', $iban, $value);Log::error($message);Log::error($e->getTraceAsString());+return false;}diff --git a/app/Validation/GroupValidation.php b/app/Validation/GroupValidation.phpindex a8dac63d20..78fc3760eb 100644--- a/app/Validation/GroupValidation.php+++ b/app/Validation/GroupValidation.php@@ -36,6 +36,13 @@ use Log;trait GroupValidation{+ /**+ * @param Validator $validator+ *+ * @return array+ */+ abstract protected function getTransactionsArray(Validator $validator): array;+/*** Adds an error to the "description" field when the user has submitted no descriptions and no* journal description.@@ -104,13 +111,6 @@ trait GroupValidation}}- /**- * @param Validator $validator- *- * @return array- */- abstract protected function getTransactionsArray(Validator $validator): array;-/*** Do the validation required by validateJournalIds.*diff --git a/app/Validation/TransactionValidation.php b/app/Validation/TransactionValidation.phpindex 14f7ce6912..fe26e44eca 100644--- a/app/Validation/TransactionValidation.php+++ b/app/Validation/TransactionValidation.php@@ -330,7 +330,7 @@ trait TransactionValidation/*** All types of splits must be equal.*- * @param Validator $validator+ * @param Validator $validator*/public function validateTransactionTypesForUpdate(Validator $validator): void{