mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Clean up report code.
This commit is contained in:
parent
d520849ce1
commit
be201e811d
@ -48,8 +48,9 @@ class OperationsController extends Controller
|
|||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return $cache->get();
|
return $cache->get();
|
||||||
}
|
}
|
||||||
$expenses = $this->getExpenseReport($start, $end, $accounts);
|
$entries = $this->getExpenseReport($start, $end, $accounts);
|
||||||
$result = view('reports.partials.expenses', compact('expenses'))->render();
|
$type = 'expense-entry';
|
||||||
|
$result = view('reports.partials.income-expenses', compact('entries', 'type'))->render();
|
||||||
$cache->store($result);
|
$cache->store($result);
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
@ -74,9 +75,10 @@ class OperationsController extends Controller
|
|||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return $cache->get();
|
return $cache->get();
|
||||||
}
|
}
|
||||||
$income = $this->getIncomeReport($start, $end, $accounts);
|
$entries = $this->getIncomeReport($start, $end, $accounts);
|
||||||
|
$type = 'income-entry';
|
||||||
|
$result = view('reports.partials.income-expenses', compact('entries', 'type'))->render();
|
||||||
|
|
||||||
$result = view('reports.partials.income', compact('income'))->render();
|
|
||||||
$cache->store($result);
|
$cache->store($result);
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
@ -227,15 +229,22 @@ class OperationsController extends Controller
|
|||||||
$name = $transaction->opposing_account_name;
|
$name = $transaction->opposing_account_name;
|
||||||
if (!isset($expenses[$opposingId])) {
|
if (!isset($expenses[$opposingId])) {
|
||||||
$expenses[$opposingId] = [
|
$expenses[$opposingId] = [
|
||||||
'id' => $opposingId,
|
'id' => $opposingId,
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'sum' => '0',
|
'sum' => '0',
|
||||||
'count' => 0,
|
'average' => '0',
|
||||||
|
'count' => 0,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
$expenses[$opposingId]['sum'] = bcadd($expenses[$opposingId]['sum'], $transaction->transaction_amount);
|
$expenses[$opposingId]['sum'] = bcadd($expenses[$opposingId]['sum'], $transaction->transaction_amount);
|
||||||
$expenses[$opposingId]['count']++;
|
$expenses[$opposingId]['count']++;
|
||||||
}
|
}
|
||||||
|
// do averages:
|
||||||
|
foreach ($expenses as $key => $entry) {
|
||||||
|
if ($expenses[$key]['count'] > 1) {
|
||||||
|
$expenses[$key]['average'] = bcdiv($expenses[$key]['sum'], strval($expenses[$key]['count']));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return $expenses;
|
return $expenses;
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
<table class="table table-hover">
|
|
||||||
<tbody>
|
|
||||||
{% set sum = 0 %}
|
|
||||||
{% for expense in expenses %}
|
|
||||||
{% set sum = sum + expense.sum %}
|
|
||||||
{% if loop.index > listLength %}
|
|
||||||
<tr class="overListLength">
|
|
||||||
{% else %}
|
|
||||||
<tr>
|
|
||||||
{% endif %}
|
|
||||||
<td>
|
|
||||||
<a href="{{ route('accounts.show',expense.id) }}">{{ expense.name }}</a>
|
|
||||||
{% if expense.count > 1 %}
|
|
||||||
<br/>
|
|
||||||
<small>
|
|
||||||
{{ expense.count }} {{ 'transactions'|_|lower }}
|
|
||||||
<i class="fa fa-fw text-muted fa-info-circle firefly-info-button" data-location="expense-entry"
|
|
||||||
data-account-id="{{ expense.id }}"></i>
|
|
||||||
</small>
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
{{ (expense.sum)|formatAmount }}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
<tfoot>
|
|
||||||
{% if expenses|length > listLength %}
|
|
||||||
<tr>
|
|
||||||
<td colspan="2" class="active">
|
|
||||||
<a href="#" class="listLengthTrigger">{{ trans('firefly.show_full_list',{number:incomeTopLength}) }}</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endif %}
|
|
||||||
<tr>
|
|
||||||
<td><em>{{ 'sum'|_ }}</em></td>
|
|
||||||
<td>{{ (sum)|formatAmount }}</td>
|
|
||||||
</tr>
|
|
||||||
</tfoot>
|
|
||||||
</table>
|
|
55
resources/views/reports/partials/income-expenses.twig
Normal file
55
resources/views/reports/partials/income-expenses.twig
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<table class="table table-hover sortable">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th data-defaultsign="az">{{ 'name'|_ }}</th>
|
||||||
|
<th data-defaultsign="_19">{{ 'total'|_ }}</th>
|
||||||
|
<th data-defaultsign="_19" class="hidden-xs">{{ 'average'|_ }}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% set sum = 0 %}
|
||||||
|
{% for entry in entries %}
|
||||||
|
{% set sum = sum + entry.sum %}
|
||||||
|
{% if loop.index > listLength %}
|
||||||
|
<tr class="overListLength">
|
||||||
|
{% else %}
|
||||||
|
<tr>
|
||||||
|
{% endif %}
|
||||||
|
<td data-value="{{ entry.name }}">
|
||||||
|
<a href="{{ route('accounts.show',entry.id) }}">{{ entry.name }}</a>
|
||||||
|
{% if entry.count > 1 %}
|
||||||
|
<br/>
|
||||||
|
<small>
|
||||||
|
{{ entry.count }} {{ 'transactions'|_|lower }}
|
||||||
|
<i class="fa fa-fw text-muted fa-info-circle firefly-info-button" data-location="{{ type }}"
|
||||||
|
data-account-id="{{ entry.id }}"></i>
|
||||||
|
</small>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td data-value="{{ entry.sum }}">
|
||||||
|
{{ (entry.sum)|formatAmount }}
|
||||||
|
</td>
|
||||||
|
<td class="hidden-xs" data-value="{{ entry.average }}">
|
||||||
|
{% if entry.count > 1 %}
|
||||||
|
{{ entry.average|formatAmount }}
|
||||||
|
{% else %}
|
||||||
|
—
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
{% if entries|length > listLength %}
|
||||||
|
<tr>
|
||||||
|
<td colspan="3" class="active">
|
||||||
|
<a href="#" class="listLengthTrigger">{{ trans('firefly.show_full_list',{number:incomeTopLength}) }}</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
|
<tr>
|
||||||
|
<td><em>{{ 'sum'|_ }}</em></td>
|
||||||
|
<td>{{ (sum)|formatAmount }}</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
@ -1,41 +0,0 @@
|
|||||||
<table class="table table-hover">
|
|
||||||
<tbody>
|
|
||||||
{% set sum = 0 %}
|
|
||||||
{% for row in income %}
|
|
||||||
{% set sum = sum + row.sum %}
|
|
||||||
{% if loop.index > listLength %}
|
|
||||||
<tr class="overListLength">
|
|
||||||
{% else %}
|
|
||||||
<tr>
|
|
||||||
{% endif %}
|
|
||||||
<td>
|
|
||||||
<a href="{{ route('accounts.show',row.id) }}" title="{{ row.name }}">{{ row.name }}</a>
|
|
||||||
{% if row.count > 1 %}
|
|
||||||
<br/>
|
|
||||||
<small>
|
|
||||||
{{ row.count }} {{ 'transactions'|_|lower }}
|
|
||||||
<i class="fa fa-fw text-muted fa-info-circle firefly-info-button" data-location="income-entry"
|
|
||||||
data-account-id="{{ row.id }}"></i>
|
|
||||||
</small>
|
|
||||||
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td>{{ row.sum|formatAmount }}</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
<tfoot>
|
|
||||||
{% if income|length > listLength %}
|
|
||||||
<tr>
|
|
||||||
<td colspan="2" class="active">
|
|
||||||
<a href="#" class="listLengthTrigger">{{ trans('firefly.show_full_list',{ number:listLength } ) }}</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endif %}
|
|
||||||
<tr>
|
|
||||||
<td><em>{{ 'sum'|_ }}</em></td>
|
|
||||||
<td>{{ sum|formatAmount }}</td>
|
|
||||||
</tr>
|
|
||||||
</tfoot>
|
|
||||||
</table>
|
|
Loading…
Reference in New Issue
Block a user