mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Simplify frontpage.
This commit is contained in:
parent
dfa60ec703
commit
8df6356abf
@ -63,8 +63,8 @@ class HomeController extends Controller
|
|||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*
|
*
|
||||||
* @throws Exception
|
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function dateRange(Request $request): JsonResponse
|
public function dateRange(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
@ -105,8 +105,8 @@ class HomeController extends Controller
|
|||||||
*
|
*
|
||||||
* @param AccountRepositoryInterface $repository
|
* @param AccountRepositoryInterface $repository
|
||||||
*
|
*
|
||||||
* @throws Exception
|
|
||||||
* @return Factory|RedirectResponse|Redirector|View
|
* @return Factory|RedirectResponse|Redirector|View
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function index(AccountRepositoryInterface $repository)
|
public function index(AccountRepositoryInterface $repository)
|
||||||
{
|
{
|
||||||
@ -119,10 +119,7 @@ class HomeController extends Controller
|
|||||||
}
|
}
|
||||||
$subTitle = (string) trans('firefly.welcome_back');
|
$subTitle = (string) trans('firefly.welcome_back');
|
||||||
$transactions = [];
|
$transactions = [];
|
||||||
$frontPage = app('preferences')->get(
|
$frontPage = app('preferences')->get('frontPageAccounts', $repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray());
|
||||||
'frontPageAccounts',
|
|
||||||
$repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET])->pluck('id')->toArray()
|
|
||||||
);
|
|
||||||
/** @var Carbon $start */
|
/** @var Carbon $start */
|
||||||
$start = session('start', Carbon::now()->startOfMonth());
|
$start = session('start', Carbon::now()->startOfMonth());
|
||||||
/** @var Carbon $end */
|
/** @var Carbon $end */
|
||||||
@ -134,14 +131,15 @@ class HomeController extends Controller
|
|||||||
/** @var BillRepositoryInterface $billRepository */
|
/** @var BillRepositoryInterface $billRepository */
|
||||||
$billRepository = app(BillRepositoryInterface::class);
|
$billRepository = app(BillRepositoryInterface::class);
|
||||||
$billCount = $billRepository->getBills()->count();
|
$billCount = $billRepository->getBills()->count();
|
||||||
|
|
||||||
|
|
||||||
|
// collect groups for each transaction.
|
||||||
foreach ($accounts as $account) {
|
foreach ($accounts as $account) {
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->setAccounts(new Collection([$account]))
|
$collector->setAccounts(new Collection([$account]))->withAccountInformation()->setRange($start, $end)->setLimit(10)->setPage(1);
|
||||||
->withAccountInformation()
|
$set = $collector->getExtractedJournals();
|
||||||
->setRange($start, $end)->setLimit(10)->setPage(1);
|
$transactions[] = ['transactions' => $set, 'account' => $account];
|
||||||
$set = $collector->getGroups();
|
|
||||||
$transactions[] = [$set, $account];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
|
@ -55,43 +55,6 @@ class TransactionGroupTwig extends AbstractExtension
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return TwigFunction
|
|
||||||
*/
|
|
||||||
public function groupAmount(): TwigFunction
|
|
||||||
{
|
|
||||||
return new TwigFunction(
|
|
||||||
'groupAmount',
|
|
||||||
function (array $array): string {
|
|
||||||
$sums = $array['sums'];
|
|
||||||
$return = [];
|
|
||||||
$first = reset($array['transactions']);
|
|
||||||
$type = $first['transaction_type_type'] ?? TransactionType::WITHDRAWAL;
|
|
||||||
$colored = true;
|
|
||||||
if ($type === TransactionType::TRANSFER) {
|
|
||||||
$colored = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** @var array $sum */
|
|
||||||
foreach ($sums as $sum) {
|
|
||||||
$amount = $sum['amount'];
|
|
||||||
|
|
||||||
$sourceType = $first['source_account_type'] ?? 'invalid';
|
|
||||||
$amount = $this->signAmount($amount, $type, $sourceType);
|
|
||||||
|
|
||||||
$return[] = app('amount')->formatFlat($sum['currency_symbol'], (int)$sum['currency_decimal_places'], $amount, $colored);
|
|
||||||
}
|
|
||||||
$result = implode(', ', $return);
|
|
||||||
if ($type === TransactionType::TRANSFER) {
|
|
||||||
$result = sprintf('<span class="text-info">%s</span>', $result);
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
},
|
|
||||||
['is_safe' => ['html']]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TwigFunction
|
* @return TwigFunction
|
||||||
*/
|
*/
|
||||||
@ -333,7 +296,14 @@ class TransactionGroupTwig extends AbstractExtension
|
|||||||
return null !== $first->foreign_amount;
|
return null !== $first->foreign_amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function signAmount( string $amount, string $transactionType, string $sourceType ): string {
|
/**
|
||||||
|
* @param string $amount
|
||||||
|
* @param string $transactionType
|
||||||
|
* @param string $sourceType
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function signAmount(string $amount, string $transactionType, string $sourceType): string
|
||||||
|
{
|
||||||
|
|
||||||
// withdrawals stay negative
|
// withdrawals stay negative
|
||||||
if ($transactionType !== TransactionType::WITHDRAWAL) {
|
if ($transactionType !== TransactionType::WITHDRAWAL) {
|
||||||
|
@ -54,23 +54,24 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-4 col-md-6 col-sm-12">
|
<div class="col-lg-4 col-md-6 col-sm-12">
|
||||||
|
|
||||||
{# TRANSACTIONS #}
|
{# TRANSACTIONS #}
|
||||||
<div id="all_transactions">
|
<div id="all_transactions">
|
||||||
{% for data in transactions %}
|
{% for data in transactions %}
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="box-header with-border">
|
<div class="box-header with-border">
|
||||||
<h3 class="box-title"><a href="{{ route('accounts.show', data[1].id) }}">{{ data[1].name }}</a></h3>
|
<h3 class="box-title"><a href="{{ route('accounts.show', data.account.id) }}">{{ data.account.name }}</a></h3>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if data[0].count > 0 %}
|
{% if data.transactions|length > 0 %}
|
||||||
<div class="box-body no-padding">
|
<div class="box-body no-padding">
|
||||||
{% include 'list.groups-tiny' with {'groups': data[0],'account': data[1]} %}
|
{% include 'list.groups-tiny' with {'transactions': data.transactions,'account': data.account} %}
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="box-body">
|
<div class="box-body">
|
||||||
<p>
|
<p>
|
||||||
<em>
|
<em>
|
||||||
{{ trans('firefly.no_transactions_account', {name: data[1].name}) }}
|
{{ trans('firefly.no_transactions_account', {name: data.account.name}) }}
|
||||||
</em>
|
</em>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@ -84,23 +85,22 @@
|
|||||||
{{ 'sidebar_frontpage_create'|_ }} <span class="caret"></span>
|
{{ 'sidebar_frontpage_create'|_ }} <span class="caret"></span>
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li><a href="{{ route('transactions.create', ['withdrawal']) }}?source={{ data[1].id }}">{{ 'create_new_withdrawal'|_ }}</a></li>
|
<li><a href="{{ route('transactions.create', ['withdrawal']) }}?source={{ data.account.id }}">{{ 'create_new_withdrawal'|_ }}</a></li>
|
||||||
<li><a href="{{ route('transactions.create', ['deposit']) }}?destination={{ data[1].id }}">{{ 'create_new_deposit'|_ }}</a></li>
|
<li><a href="{{ route('transactions.create', ['deposit']) }}?destination={{ data.account.id }}">{{ 'create_new_deposit'|_ }}</a></li>
|
||||||
<li><a href="{{ route('transactions.create', ['transfer']) }}?source={{ data[1].id }}">{{ 'create_new_transfer'|_ }}</a></li>
|
<li><a href="{{ route('transactions.create', ['transfer']) }}?source={{ data.account.id }}">{{ 'create_new_transfer'|_ }}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<a type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"
|
<a type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"
|
||||||
href="{{ route('accounts.show', [data[1].id]) }}">{{ formatAmountByAccount(data[1], data[1]|balance, false) }}
|
href="{{ route('accounts.show', [data.account.id]) }}">{{ formatAmountByAccount(data.account, data.account|balance, false) }}
|
||||||
<span class="caret"></span>
|
<span class="caret"></span>
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li><a href="{{ route('accounts.show', [data[1].id]) }}">{{ 'show'|_ }}</a></li>
|
<li><a href="{{ route('accounts.show', [data.account.id]) }}">{{ 'show'|_ }}</a></li>
|
||||||
<li><a href="{{ route('accounts.reconcile', [data[1].id]) }}">{{ 'reconcile'|_ }}</a></li>
|
<li><a href="{{ route('accounts.reconcile', [data.account.id]) }}">{{ 'reconcile'|_ }}</a></li>
|
||||||
<li><a href="{{ route('accounts.edit', [data[1].id]) }}">{{ 'edit'|_ }}</a></li>
|
<li><a href="{{ route('accounts.edit', [data.account.id]) }}">{{ 'edit'|_ }}</a></li>
|
||||||
<li><a href="{{ route('accounts.delete', [data[1].id]) }}">{{ 'delete'|_ }}</a></li>
|
<li><a href="{{ route('accounts.delete', [data.account.id]) }}">{{ 'delete'|_ }}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,19 +1,55 @@
|
|||||||
<div class="list-group">
|
<div class="list-group">
|
||||||
{% for group in groups %}
|
{% for transaction in transactions %}
|
||||||
<a class="list-group-item" href="{{ route('transactions.show', [group.id]) }}">
|
<a class="list-group-item" href="{{ route('transactions.show', [transaction.transaction_group_id]) }}">
|
||||||
{% for transaction in group.transactions %}
|
{% if transaction.transaction_group_title %}
|
||||||
{{ transaction.description }}
|
{{ transaction.transaction_group_title }}:
|
||||||
<span class="pull-right small">
|
|
||||||
{{ journalArrayAmount(transaction) }}
|
|
||||||
</span>
|
|
||||||
<br/>
|
|
||||||
{% endfor %}
|
|
||||||
{% if group.count > 1 %}
|
|
||||||
|
|
||||||
<span class="pull-right small">
|
|
||||||
{{ groupAmount(group) }}
|
|
||||||
</span>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{{ transaction.description }}
|
||||||
|
|
||||||
|
<span class="pull-right small">
|
||||||
|
{% if transaction.transaction_type_type == 'Deposit' %}
|
||||||
|
{{ formatAmountBySymbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_decimal_places) }}
|
||||||
|
{% if null != transaction.foreign_amount %}
|
||||||
|
({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
||||||
|
{% endif %}
|
||||||
|
{% elseif transaction.transaction_type_type == 'Transfer' %}
|
||||||
|
<span class="text-info">
|
||||||
|
{{ formatAmountBySymbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_decimal_places, false) }}
|
||||||
|
{% if null != transaction.foreign_amount %}
|
||||||
|
({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places, false) }})
|
||||||
|
{% endif %}
|
||||||
|
</span>
|
||||||
|
{% elseif transaction.transaction_type_type == 'Opening balance' %}
|
||||||
|
{% if transaction.source_account_type == 'Initial balance account' %}
|
||||||
|
{{ formatAmountBySymbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_decimal_places) }}
|
||||||
|
{% if null != transaction.foreign_amount %}
|
||||||
|
({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
{{ formatAmountBySymbol(transaction.amount, transaction.currency_symbol, transaction.currency_decimal_places) }}
|
||||||
|
{% if null != transaction.foreign_amount %}
|
||||||
|
({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% elseif transaction.transaction_type_type == 'Reconciliation' %}
|
||||||
|
{% if transaction.source_account_type == 'Reconciliation account' %}
|
||||||
|
{{ formatAmountBySymbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_decimal_places) }}
|
||||||
|
{% if null != transaction.foreign_amount %}
|
||||||
|
({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
{{ formatAmountBySymbol(transaction.amount, transaction.currency_symbol, transaction.currency_decimal_places) }}
|
||||||
|
{% if null != transaction.foreign_amount %}
|
||||||
|
({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
{{ formatAmountBySymbol(transaction.amount, transaction.currency_symbol, transaction.currency_decimal_places) }}
|
||||||
|
{% if null != transaction.foreign_amount %}
|
||||||
|
({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
</span>
|
||||||
</a>
|
</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user