Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
JC5 committed May 1, 2020
1 parent c3c9a2f commit 9d9053d
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/Transaction/BulkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function __construct()
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);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Transaction/CreateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct()
$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);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Transaction/DeleteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function __construct()
$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);

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Transaction/EditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __construct()
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);
}
Expand Down
15 changes: 9 additions & 6 deletions app/Http/Controllers/Transaction/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public function __construct()
// 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);

Expand Down Expand Up @@ -88,7 +88,9 @@ public function index(Request $request, string $objectType, Carbon $start = null
$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];
Expand Down Expand Up @@ -134,14 +136,15 @@ public function indexAll(Request $request, string $objectType)
$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 */
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Transaction/LinkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function __construct()
$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);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Transaction/MassController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function __construct()
$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);
Expand Down
15 changes: 15 additions & 0 deletions app/Repositories/Journal/JournalRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,4 +407,19 @@ public function getDestinationAccount(TransactionJournal $journal): Account

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;
}
}
5 changes: 5 additions & 0 deletions app/Repositories/Journal/JournalRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,18 @@
*/
interface JournalRepositoryInterface
{
/**
* @return TransactionJournal|null
*/
public function getLast(): ?TransactionJournal;

/**
* TODO maybe create JSON repository?
*
* Search in journal descriptions.
*
* @param string $search
*
* @return Collection
*/
public function searchJournalDescriptions(string $search): Collection;
Expand Down
2 changes: 1 addition & 1 deletion config/firefly.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@
'Opening balance' => 'opening-balance',
'Reconciliation' => 'reconciliation',
],
'transactionIconsByWhat' => [
'transactionIconsByType' => [
'expenses' => 'fa-long-arrow-left',
'withdrawal' => 'fa-long-arrow-left',
'revenue' => 'fa-long-arrow-right',
Expand Down

0 comments on commit 9d9053d

Please sign in to comment.