diff --git a/app/Http/Controllers/Transaction/BulkController.php b/app/Http/Controllers/Transaction/BulkController.php index 5646532911..bb01495103 100644 --- a/app/Http/Controllers/Transaction/BulkController.php +++ b/app/Http/Controllers/Transaction/BulkController.php @@ -56,7 +56,7 @@ class BulkController extends Controller function ($request, $next) { $this->repository = app(JournalRepositoryInterface::class); app('view')->share('title', (string) trans('firefly.transactions')); - app('view')->share('mainTitleIcon', 'fa-repeat'); + app('view')->share('mainTitleIcon', 'fa-exchange'); return $next($request); } diff --git a/app/Http/Controllers/Transaction/CreateController.php b/app/Http/Controllers/Transaction/CreateController.php index 94fcf387e9..ecd39cb1e3 100644 --- a/app/Http/Controllers/Transaction/CreateController.php +++ b/app/Http/Controllers/Transaction/CreateController.php @@ -49,7 +49,7 @@ class CreateController extends Controller $this->middleware( static function ($request, $next) { app('view')->share('title', (string) trans('firefly.transactions')); - app('view')->share('mainTitleIcon', 'fa-repeat'); + app('view')->share('mainTitleIcon', 'fa-exchange'); return $next($request); } diff --git a/app/Http/Controllers/Transaction/DeleteController.php b/app/Http/Controllers/Transaction/DeleteController.php index 585bc0a198..87e3dfc429 100644 --- a/app/Http/Controllers/Transaction/DeleteController.php +++ b/app/Http/Controllers/Transaction/DeleteController.php @@ -56,7 +56,7 @@ class DeleteController extends Controller $this->middleware( function ($request, $next) { app('view')->share('title', (string) trans('firefly.transactions')); - app('view')->share('mainTitleIcon', 'fa-repeat'); + app('view')->share('mainTitleIcon', 'fa-exchange'); $this->repository = app(TransactionGroupRepositoryInterface::class); diff --git a/app/Http/Controllers/Transaction/EditController.php b/app/Http/Controllers/Transaction/EditController.php index 9c78da80b7..cf9a413515 100644 --- a/app/Http/Controllers/Transaction/EditController.php +++ b/app/Http/Controllers/Transaction/EditController.php @@ -52,7 +52,7 @@ class EditController extends Controller static function ($request, $next) { app('view')->share('title', (string) trans('firefly.transactions')); - app('view')->share('mainTitleIcon', 'fa-repeat'); + app('view')->share('mainTitleIcon', 'fa-exchange'); return $next($request); } diff --git a/app/Http/Controllers/Transaction/IndexController.php b/app/Http/Controllers/Transaction/IndexController.php index 46b42ad72d..22355d5d6d 100644 --- a/app/Http/Controllers/Transaction/IndexController.php +++ b/app/Http/Controllers/Transaction/IndexController.php @@ -56,8 +56,8 @@ class IndexController extends Controller // translations: $this->middleware( function ($request, $next) { - app('view')->share('mainTitleIcon', 'fa-credit-card'); - app('view')->share('title', (string) trans('firefly.accounts')); + app('view')->share('mainTitleIcon', 'fa-exchange'); + app('view')->share('title', (string) trans('firefly.transactions')); $this->repository = app(JournalRepositoryInterface::class); @@ -88,7 +88,9 @@ class IndexController extends Controller $end = session('end'); } if (null === $end) { - $end = session('end'); // @codeCoverageIgnore + // get last transaction ever? + $last = $this->repository->getLast(); + $end = $last ? $last->date : session('end'); } [$start, $end] = $end < $start ? [$end, $start] : [$start, $end]; @@ -134,14 +136,15 @@ class IndexController extends Controller $repository = app(JournalRepositoryInterface::class); - $subTitleIcon = config('firefly.transactionIconsByWhat.' . $objectType); - $types = config('firefly.transactionTypesByWhat.' . $objectType); + $subTitleIcon = config('firefly.transactionIconsByType.' . $objectType); + $types = config('firefly.transactionTypesByType.' . $objectType); $page = (int) $request->get('page'); $pageSize = (int) app('preferences')->get('listPageSize', 50)->data; $path = route('transactions.index.all', [$objectType]); $first = $repository->firstNull(); $start = null === $first ? new Carbon : $first->date; - $end = new Carbon; + $last = $this->repository->getLast(); + $end = $last ? $last->date : new Carbon; $subTitle = (string) trans('firefly.all_' . $objectType); /** @var GroupCollectorInterface $collector */ diff --git a/app/Http/Controllers/Transaction/LinkController.php b/app/Http/Controllers/Transaction/LinkController.php index c9df232c4b..2b019710b8 100644 --- a/app/Http/Controllers/Transaction/LinkController.php +++ b/app/Http/Controllers/Transaction/LinkController.php @@ -57,7 +57,7 @@ class LinkController extends Controller $this->middleware( function ($request, $next) { app('view')->share('title', (string) trans('firefly.transactions')); - app('view')->share('mainTitleIcon', 'fa-repeat'); + app('view')->share('mainTitleIcon', 'fa-exchange'); $this->journalRepository = app(JournalRepositoryInterface::class); $this->repository = app(LinkTypeRepositoryInterface::class); diff --git a/app/Http/Controllers/Transaction/MassController.php b/app/Http/Controllers/Transaction/MassController.php index 977028bdb3..1de06095fa 100644 --- a/app/Http/Controllers/Transaction/MassController.php +++ b/app/Http/Controllers/Transaction/MassController.php @@ -62,7 +62,7 @@ class MassController extends Controller $this->middleware( function ($request, $next) { app('view')->share('title', (string) trans('firefly.transactions')); - app('view')->share('mainTitleIcon', 'fa-repeat'); + app('view')->share('mainTitleIcon', 'fa-exchange'); $this->repository = app(JournalRepositoryInterface::class); return $next($request); diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php index f30e33b188..d25545750b 100644 --- a/app/Repositories/Journal/JournalRepository.php +++ b/app/Repositories/Journal/JournalRepository.php @@ -407,4 +407,19 @@ class JournalRepository implements JournalRepositoryInterface return $transaction->account; } + + /** + * @return TransactionJournal|null + */ + public function getLast(): ?TransactionJournal + { + /** @var TransactionJournal $entry */ + $entry = $this->user->transactionJournals()->orderBy('date', 'DESC')->first(['transaction_journals.*']); + $result = null; + if (null !== $entry) { + $result = $entry; + } + + return $result; + } } diff --git a/app/Repositories/Journal/JournalRepositoryInterface.php b/app/Repositories/Journal/JournalRepositoryInterface.php index df05ba2b6e..e188c69002 100644 --- a/app/Repositories/Journal/JournalRepositoryInterface.php +++ b/app/Repositories/Journal/JournalRepositoryInterface.php @@ -37,6 +37,10 @@ use Illuminate\Support\Collection; */ interface JournalRepositoryInterface { + /** + * @return TransactionJournal|null + */ + public function getLast(): ?TransactionJournal; /** * TODO maybe create JSON repository? @@ -44,6 +48,7 @@ interface JournalRepositoryInterface * Search in journal descriptions. * * @param string $search + * * @return Collection */ public function searchJournalDescriptions(string $search): Collection; diff --git a/config/firefly.php b/config/firefly.php index 30cdc35a0e..5fcbe5849e 100644 --- a/config/firefly.php +++ b/config/firefly.php @@ -383,7 +383,7 @@ return [ 'Opening balance' => 'opening-balance', 'Reconciliation' => 'reconciliation', ], - 'transactionIconsByWhat' => [ + 'transactionIconsByType' => [ 'expenses' => 'fa-long-arrow-left', 'withdrawal' => 'fa-long-arrow-left', 'revenue' => 'fa-long-arrow-right',