Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Add a button to go back to the v1 layout.
James Cole3a339382d41f
diff --git a/app/Api/V2/Controllers/Model/Account/IndexController.php b/app/Api/V2/Controllers/Model/Account/IndexController.phpindex 6fd12c51cb..c0c0632dce 100644--- a/app/Api/V2/Controllers/Model/Account/IndexController.php+++ b/app/Api/V2/Controllers/Model/Account/IndexController.php@@ -46,7 +46,7 @@ class IndexController extends Controllerfunction ($request, $next) {$this->repository = app(AccountRepositoryInterface::class);// new way of user group validation- $userGroup = $this->validateUserGroup($request);+ $userGroup = $this->validateUserGroup($request);if (null !== $userGroup) {$this->repository->setUserGroup($userGroup);}@@ -61,11 +61,11 @@ class IndexController extends Controller$this->repository->resetAccountOrder();// get accounts of the specified type, and return.- $types = $request->getAccountTypes();+ $types = $request->getAccountTypes();// get from repository$accounts = $this->repository->getAccountsInOrder($types, $request->getSortInstructions('accounts'), $request->getStartRow(), $request->getEndRow());- $total = $this->repository->countAccounts($types);+ $total = $this->repository->countAccounts($types);$count = $request->getEndRow() - $request->getStartRow();$paginator = new LengthAwarePaginator($accounts, $total, $count, $this->parameters->get('page'));$transformer = new AccountTransformer();@@ -73,6 +73,7 @@ class IndexController extends Controllerreturn response()->json($this->jsonApiList(self::RESOURCE_KEY, $paginator, $transformer))- ->header('Content-Type', self::CONTENT_TYPE);+ ->header('Content-Type', self::CONTENT_TYPE)+ ;}}diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.phpindex 2c086c4057..f52b8b4698 100644--- a/app/Http/Controllers/Controller.php+++ b/app/Http/Controllers/Controller.php@@ -69,6 +69,11 @@ abstract class Controller extends BaseController$authGuard = config('firefly.authentication_guard');$logoutUrl = config('firefly.custom_logout_url');+ // overrule v2 layout back to v1.+ if ('true' === request()->get('force_default_layout') && 'v2' === config('firefly.layout')) {+ app('view')->getFinder()->setPaths([realpath(base_path('resources/views'))]);+ }+app('view')->share('authGuard', $authGuard);app('view')->share('logoutUrl', $logoutUrl);diff --git a/app/Http/Controllers/Json/ReconcileController.php b/app/Http/Controllers/Json/ReconcileController.phpindex 0f7fde2f3b..1d3614366b 100644--- a/app/Http/Controllers/Json/ReconcileController.php+++ b/app/Http/Controllers/Json/ReconcileController.php@@ -34,7 +34,6 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;use Illuminate\Http\JsonResponse;use Illuminate\Http\Request;use Illuminate\Support\Collection;-use Log;/*** Class ReconcileController@@ -119,10 +118,10 @@ class ReconcileController extends Controller$clearedAmount = $this->processJournal($account, $accountCurrency, $journal, $clearedAmount);}}- Log::debug(sprintf('Start balance: "%s"', $startBalance));- Log::debug(sprintf('End balance: "%s"', $endBalance));- Log::debug(sprintf('Cleared amount: "%s"', $clearedAmount));- Log::debug(sprintf('Amount: "%s"', $amount));+ \Log::debug(sprintf('Start balance: "%s"', $startBalance));+ \Log::debug(sprintf('End balance: "%s"', $endBalance));+ \Log::debug(sprintf('Cleared amount: "%s"', $clearedAmount));+ \Log::debug(sprintf('Amount: "%s"', $amount));$difference = bcadd(bcadd(bcsub($startBalance, $endBalance), $clearedAmount), $amount);$diffCompare = bccomp($difference, '0');$countCleared = count($clearedJournals);diff --git a/app/Http/Controllers/Transaction/IndexController.php b/app/Http/Controllers/Transaction/IndexController.phpindex 8013113c6d..c0722fe6f1 100644--- a/app/Http/Controllers/Transaction/IndexController.php+++ b/app/Http/Controllers/Transaction/IndexController.php@@ -75,52 +75,45 @@ class IndexController extends Controller$objectType = 'transfer';}- // add a split for the (future) v2 release.- $periods = [];- $groups = [];- $subTitle = 'TODO page subtitle in v2';+ $subTitleIcon = config('firefly.transactionIconsByType.'.$objectType);+ $types = config('firefly.transactionTypesByType.'.$objectType);+ $page = (int)$request->get('page');+ $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;++ if (null === $start) {+ $start = session('start');+ $end = session('end');+ }+ if (null === $end) {+ // get last transaction ever?+ $last = $this->repository->getLast();+ $end = null !== $last ? $last->date : session('end');+ }- $subTitleIcon = config('firefly.transactionIconsByType.'.$objectType);- $types = config('firefly.transactionTypesByType.'.$objectType);- $page = (int)$request->get('page');- $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;+ [$start, $end] = $end < $start ? [$end, $start] : [$start, $end];+ $startStr = $start->isoFormat($this->monthAndDayFormat);+ $endStr = $end->isoFormat($this->monthAndDayFormat);+ $subTitle = (string)trans(sprintf('firefly.title_%s_between', $objectType), ['start' => $startStr, 'end' => $endStr]);+ $path = route('transactions.index', [$objectType, $start->format('Y-m-d'), $end->format('Y-m-d')]);+ $firstJournal = $this->repository->firstNull();+ $startPeriod = null === $firstJournal ? new Carbon() : $firstJournal->date;+ $endPeriod = clone $end;+ $periods = $this->getTransactionPeriodOverview($objectType, $startPeriod, $endPeriod);- if ('v2' !== (string)config('firefly.layout')) {- if (null === $start) {- $start = session('start');- $end = session('end');- }- if (null === $end) {- // get last transaction ever?- $last = $this->repository->getLast();- $end = null !== $last ? $last->date : session('end');- }+ /** @var GroupCollectorInterface $collector */+ $collector = app(GroupCollectorInterface::class);- [$start, $end] = $end < $start ? [$end, $start] : [$start, $end];- $startStr = $start->isoFormat($this->monthAndDayFormat);- $endStr = $end->isoFormat($this->monthAndDayFormat);- $subTitle = (string)trans(sprintf('firefly.title_%s_between', $objectType), ['start' => $startStr, 'end' => $endStr]);- $path = route('transactions.index', [$objectType, $start->format('Y-m-d'), $end->format('Y-m-d')]);- $firstJournal = $this->repository->firstNull();- $startPeriod = null === $firstJournal ? new Carbon() : $firstJournal->date;- $endPeriod = clone $end;- $periods = $this->getTransactionPeriodOverview($objectType, $startPeriod, $endPeriod);-- /** @var GroupCollectorInterface $collector */- $collector = app(GroupCollectorInterface::class);-- $collector->setRange($start, $end)- ->setTypes($types)- ->setLimit($pageSize)- ->setPage($page)- ->withBudgetInformation()- ->withCategoryInformation()- ->withAccountInformation()- ->withAttachmentInformation()- ;- $groups = $collector->getPaginatedGroups();- $groups->setPath($path);- }+ $collector->setRange($start, $end)+ ->setTypes($types)+ ->setLimit($pageSize)+ ->setPage($page)+ ->withBudgetInformation()+ ->withCategoryInformation()+ ->withAccountInformation()+ ->withAttachmentInformation()+ ;+ $groups = $collector->getPaginatedGroups();+ $groups->setPath($path);return view('transactions.index', compact('subTitle', 'objectType', 'subTitleIcon', 'groups', 'periods', 'start', 'end'));}diff --git a/app/Repositories/UserGroups/Account/AccountRepository.php b/app/Repositories/UserGroups/Account/AccountRepository.phpindex 8236c0f096..2ada2b6f5f 100644--- a/app/Repositories/UserGroups/Account/AccountRepository.php+++ b/app/Repositories/UserGroups/Account/AccountRepository.php@@ -252,10 +252,8 @@ class AccountRepository implements AccountRepositoryInterface}}- /**- * @inheritDoc- */- #[\Override] public function getAccountsInOrder(array $types, array $sort, int $startRow, int $endRow): Collection+ #[\Override]+ public function getAccountsInOrder(array $types, array $sort, int $startRow, int $endRow): Collection{$query = $this->userGroup->accounts();if (0 !== count($types)) {@@ -280,12 +278,14 @@ class AccountRepository implements AccountRepositoryInterfacereturn $query->get(['accounts.*']);}- #[\Override] public function countAccounts(array $types): int+ #[\Override]+ public function countAccounts(array $types): int{$query = $this->userGroup->accounts();if (0 !== count($types)) {$query->accountTypeIn($types);}+return $query->count();}}diff --git a/app/Repositories/UserGroups/Account/AccountRepositoryInterface.php b/app/Repositories/UserGroups/Account/AccountRepositoryInterface.phpindex cb98709818..a9b934442a 100644--- a/app/Repositories/UserGroups/Account/AccountRepositoryInterface.php+++ b/app/Repositories/UserGroups/Account/AccountRepositoryInterface.php@@ -53,15 +53,8 @@ interface AccountRepositoryInterface/*** Used in the infinite accounts list.- *- * @param array $types- * @param array $sort- * @param int $startRow- * @param int $endRow- *- * @return Collection*/-public function getAccountsInOrder(array $types, array $sort, int $startRow, int $endRow): Collection;+ public function getAccountsInOrder(array $types, array $sort, int $startRow, int $endRow): Collection;public function getActiveAccountsByType(array $types): Collection;diff --git a/config/firefly.php b/config/firefly.phpindex 42d78d0583..083ad3460c 100644--- a/config/firefly.php+++ b/config/firefly.php@@ -917,7 +917,7 @@ return ['sorting' => ['allowed' => ['transactions' => ['description', 'amount'],- 'accounts' => ['name'],+ 'accounts' => ['name'],],],];diff --git a/resources/views/v2/partials/layout/topbar.blade.php b/resources/views/v2/partials/layout/topbar.blade.phpindex 300a903b68..e3b1224665 100644--- a/resources/views/v2/partials/layout/topbar.blade.php+++ b/resources/views/v2/partials/layout/topbar.blade.php@@ -1,3 +1,9 @@+<li class="nav-item">+ <a class="nav-link" href="{{ route(Route::current()->getName(), Route::current()->parameters()) }}?force_default_layout=true">+ <i class="fa-solid fa-landmark"></i>+ </a>++</li><li class="nav-item dropdown"><a class="nav-link" data-bs-toggle="dropdown" href="#"><i class="fa-solid fa-gears"></i>