This commit is contained in:
James Cole 2020-05-01 06:24:24 +02:00
parent c3c9a2f3c0
commit 9d9053d828
10 changed files with 36 additions and 13 deletions

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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 */

View File

@ -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);

View File

@ -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);

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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',