Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Small code changes for @ctrl-f5's PR.
James Cole83f3eddf4413
diff --git a/app/Api/V1/Controllers/Models/Account/ShowController.php b/app/Api/V1/Controllers/Models/Account/ShowController.phpindex cb0097062e..ab0e510911 100644--- a/app/Api/V1/Controllers/Models/Account/ShowController.php+++ b/app/Api/V1/Controllers/Models/Account/ShowController.php@@ -70,48 +70,48 @@ class ShowController extends Controller*/public function index(ShowRequest $request): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();[- 'types' => $types,- 'page' => $page,- 'limit' => $limit,+ 'types' => $types,+ 'page' => $page,+ 'limit' => $limit,'offset' => $offset,- 'sort' => $sort,- 'start' => $start,- 'end' => $end,- 'date' => $date,- ] = $request->attributes->all();+ 'sort' => $sort,+ 'start' => $start,+ 'end' => $end,+ 'date' => $date,+ ]+ = $request->attributes->all();// get list of accounts. Count it and split it.$this->repository->resetAccountOrder();- $collection = $this->repository->getAccountsByType($types, $sort);- $count = $collection->count();+ $collection = $this->repository->getAccountsByType($types, $sort);+ $count = $collection->count();// continue sort:// TODO if the user sorts on DB dependent field there must be no slice before enrichment, only after.// TODO still need to figure out how to do this easily.- $accounts = $collection->slice($offset, $limit);+ $accounts = $collection->slice($offset, $limit);// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new AccountEnrichment();+ $admin = auth()->user();+ $enrichment = new AccountEnrichment();$enrichment->setSort($sort);$enrichment->setDate($date);$enrichment->setStart($start);$enrichment->setEnd($end);$enrichment->setUser($admin);- $accounts = $enrichment->enrich($accounts);+ $accounts = $enrichment->enrich($accounts);// make paginator:- $paginator = new LengthAwarePaginator($accounts, $count, $limit, $page);- $paginator->setPath(route('api.v1.accounts.index').$this->buildParams());+ $paginator = new LengthAwarePaginator($accounts, $count, $limit, $page);+ $paginator->setPath(route('api.v1.accounts.index') . $this->buildParams());/** @var AccountTransformer $transformer */$transformer = app(AccountTransformer::class);- $transformer->setParameters($this->parameters);- $resource = new FractalCollection($accounts, $transformer, self::RESOURCE_KEY);+ $resource = new FractalCollection($accounts, $transformer, self::RESOURCE_KEY);$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -128,27 +128,22 @@ class ShowController extends Controller// get list of accounts. Count it and split it.$this->repository->resetAccountOrder();$account->refresh();- $manager = $this->getManager();- [- 'start' => $start,- 'end' => $end,- 'date' => $date,- ] = $request->attributes->all();+ $manager = $this->getManager();+ [$start, $end, $date,] = $request->attributes->all();// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new AccountEnrichment();+ $admin = auth()->user();+ $enrichment = new AccountEnrichment();$enrichment->setDate($date);$enrichment->setStart($start);$enrichment->setEnd($end);$enrichment->setUser($admin);- $account = $enrichment->enrichSingle($account);+ $account = $enrichment->enrichSingle($account);/** @var AccountTransformer $transformer */$transformer = app(AccountTransformer::class);- $transformer->setParameters($this->parameters);$resource = new Item($account, $transformer, self::RESOURCE_KEY);return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);diff --git a/app/Api/V1/Controllers/Models/UserGroup/IndexController.php b/app/Api/V1/Controllers/Models/UserGroup/IndexController.phpindex 8c4ba0ddbb..cda1faa21a 100644--- a/app/Api/V1/Controllers/Models/UserGroup/IndexController.php+++ b/app/Api/V1/Controllers/Models/UserGroup/IndexController.php@@ -65,8 +65,6 @@ class IndexController extends Controller$paginator = new LengthAwarePaginator($administrations, $count, $limit, $page);$transformer = new UserGroupTransformer();- $transformer->setParameters($request->attributes); // give params to transformer-return response()->json($this->jsonApiList(self::RESOURCE_KEY, $paginator, $transformer))->header('Content-Type', self::CONTENT_TYPE)diff --git a/app/Api/V1/Requests/AggregateFormRequest.php b/app/Api/V1/Requests/AggregateFormRequest.phpindex 207ce0640d..9e9fbf7e92 100644--- a/app/Api/V1/Requests/AggregateFormRequest.php+++ b/app/Api/V1/Requests/AggregateFormRequest.php@@ -1,7 +1,7 @@<?php/*- * Copyright (c) 2021 [email protected]+ * Copyright (c) 2025 https://github.com/ctrl-f5** This file is part of Firefly III (https://github.com/firefly-iii).*diff --git a/app/Api/V1/Requests/ApiRequest.php b/app/Api/V1/Requests/ApiRequest.phpindex cb9a7b6046..e5ee028d8d 100644--- a/app/Api/V1/Requests/ApiRequest.php+++ b/app/Api/V1/Requests/ApiRequest.php@@ -1,7 +1,7 @@<?php/*- * Copyright (c) 2021 [email protected]+ * Copyright (c) 2025 https://github.com/ctrl-f5** This file is part of Firefly III (https://github.com/firefly-iii).*diff --git a/app/Api/V1/Requests/DateRangeRequest.php b/app/Api/V1/Requests/DateRangeRequest.phpindex c4e2dc87ec..a5c2a22443 100644--- a/app/Api/V1/Requests/DateRangeRequest.php+++ b/app/Api/V1/Requests/DateRangeRequest.php@@ -1,7 +1,7 @@<?php/*- * Copyright (c) 2021 [email protected]+ * Copyright (c) 2025 https://github.com/ctrl-f5** This file is part of Firefly III (https://github.com/firefly-iii).*@@ -27,14 +27,15 @@ use FireflyIII\Exceptions\ValidationException;use FireflyIII\Support\Request\ChecksLogin;use FireflyIII\Support\Request\ConvertsDataTypes;use Illuminate\Foundation\Http\FormRequest;+use Illuminate\Validation\Validator;class DateRangeRequest extends ApiRequest{public function rules(): array{return [- 'start' => 'date|after:1970-01-02|before:2038-01-17|before:end|required_with:end|' . $this->required,- 'end' => 'date|after:1970-01-02|before:2038-01-17|after:start|required_with:start|' . $this->required,+ 'start' => sprintf('date|after:1970-01-02|before:2038-01-17|before:end|required_with:end|' , $this->required),+ 'end' => sprintf('date|after:1970-01-02|before:2038-01-17|after:start|required_with:start|' , $this->required),];}diff --git a/app/Api/V1/Requests/DateRequest.php b/app/Api/V1/Requests/DateRequest.phpindex c59dd65b13..5a87fb3086 100644--- a/app/Api/V1/Requests/DateRequest.php+++ b/app/Api/V1/Requests/DateRequest.php@@ -1,7 +1,7 @@<?php/*- * Copyright (c) 2021 [email protected]+ * Copyright (c) 2025 https://github.com/ctrl-f5** This file is part of Firefly III (https://github.com/firefly-iii).*diff --git a/app/Api/V1/Requests/Models/Account/AccountTypeApiRequest.php b/app/Api/V1/Requests/Models/Account/AccountTypeApiRequest.phpindex 10576e5717..fb2348017a 100644--- a/app/Api/V1/Requests/Models/Account/AccountTypeApiRequest.php+++ b/app/Api/V1/Requests/Models/Account/AccountTypeApiRequest.php@@ -2,8 +2,8 @@declare(strict_types=1);/*- * ShowRequest.php- * Copyright (c) 2025 [email protected]+ * AccountTypeApiRequest.php+ * Copyright (c) 2025 https://github.com/ctrl-f5** This file is part of Firefly III (https://github.com/firefly-iii).*diff --git a/app/Api/V1/Requests/PaginationRequest.php b/app/Api/V1/Requests/PaginationRequest.phpindex 0dc9719929..cf88f238e7 100644--- a/app/Api/V1/Requests/PaginationRequest.php+++ b/app/Api/V1/Requests/PaginationRequest.php@@ -1,7 +1,7 @@<?php/*- * Copyright (c) 2021 [email protected]+ * Copyright (c) 2025 https://github.com/ctrl-f5** This file is part of Firefly III (https://github.com/firefly-iii).*diff --git a/app/Transformers/AbstractTransformer.php b/app/Transformers/AbstractTransformer.phpindex 054173dd0f..d741ba0cf7 100644--- a/app/Transformers/AbstractTransformer.php+++ b/app/Transformers/AbstractTransformer.php@@ -34,11 +34,17 @@ abstract class AbstractTransformer extends TransformerAbstract{protected ParameterBag $parameters;+ /**+ * @deprecated+ */final public function getParameters(): ParameterBag{return $this->parameters;}+ /**+ * @deprecated+ */final public function setParameters(ParameterBag $parameters): void{$this->parameters = $parameters;diff --git a/app/Transformers/AccountTransformer.php b/app/Transformers/AccountTransformer.phpindex c9e5d3aeee..5538e745e7 100644--- a/app/Transformers/AccountTransformer.php+++ b/app/Transformers/AccountTransformer.php@@ -30,7 +30,6 @@ use FireflyIII\Models\Account;use FireflyIII\Models\TransactionCurrency;use FireflyIII\Repositories\Account\AccountRepositoryInterface;use FireflyIII\Support\Facades\Amount;-use Symfony\Component\HttpFoundation\ParameterBag;/*** Class AccountTransformer@@ -46,7 +45,6 @@ class AccountTransformer extends AbstractTransformer*/public function __construct(){- $this->parameters = new ParameterBag();$this->repository = app(AccountRepositoryInterface::class);$this->convertToPrimary = Amount::convertToPrimary();$this->primary = Amount::getPrimaryCurrency();