Expand budget report #1106

This commit is contained in:
James Cole 2018-01-12 21:08:59 +01:00
parent cbeaf8e16a
commit 6fe5ce0485
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
3 changed files with 40 additions and 3 deletions

View File

@ -194,7 +194,9 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
*/
private function summarizeByBudget(Collection $collection): array
{
$result = [];
$result = [
'sum' => '0',
];
/** @var Transaction $transaction */
foreach ($collection as $transaction) {
$jrnlBudId = intval($transaction->transaction_journal_budget_id);
@ -202,6 +204,7 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
$budgetId = max($jrnlBudId, $transBudId);
$result[$budgetId] = $result[$budgetId] ?? '0';
$result[$budgetId] = bcadd($transaction->transaction_amount, $result[$budgetId]);
$result['sum'] = bcadd($result['sum'], $transaction->transaction_amount);
}
return $result;

View File

@ -133,7 +133,7 @@ class Support
}
$return[$objectId]['earned'] = $entry;
$return['sum']['earned'] = bcadd($return['sum']['earned'], $entry);
$return['sum']['earned'] = bcadd($return['sum']['earned'], $entry);
}
return $return;
@ -146,12 +146,15 @@ class Support
*/
protected function summarizeByAccount(Collection $collection): array
{
$result = [];
$result = [
'sum' => '0',
];
/** @var Transaction $transaction */
foreach ($collection as $transaction) {
$accountId = $transaction->account_id;
$result[$accountId] = $result[$accountId] ?? '0';
$result[$accountId] = bcadd($transaction->transaction_amount, $result[$accountId]);
$result['sum'] = bcadd($result['sum'], $transaction->transaction_amount);
}
return $result;

View File

@ -35,6 +35,12 @@
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr>
<td>{{ 'sum'|_ }}</td>
<td style="text-align: right;">{{ accountSummary.sum|formatAmount }}</td>
</tr>
</tfoot>
</table>
</div>
</div>
@ -65,6 +71,12 @@
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr>
<td>{{ 'sum'|_ }}</td>
<td style="text-align: right;">{{ budgetSummary.sum|formatAmount }}</td>
</tr>
</tfoot>
</table>
</div>
</div>
@ -140,7 +152,11 @@
</tr>
</thead>
<tbody>
{% set totalCount = 0 %}
{% set totalSum = 0 %}
{% for row in averageExpenses %}
{% set totalCount = totalCount+ row.count %}
{% set totalSum = totalSum + row.sum %}
{% if loop.index > listLength %}
<tr class="overListLength">
{% else %}
@ -169,6 +185,13 @@
</td>
</tr>
{% endif %}
<tr>
<td colspan="2">
{{ 'sum'|_ }}
</td>
<td style="text-align:right">{{ totalSum|formatAmount }}</td>
<td>{{ totalCount }}</td>
</tr>
</tfoot>
</table>
</div>
@ -193,7 +216,9 @@
</tr>
</thead>
<tbody>
{% set totalSum = 0 %}
{% for row in topExpenses %}
{% set totalSum = totalSum + row.transaction_amount %}
{% if loop.index > listLength %}
<tr class="overListLength">
{% else %}
@ -230,6 +255,12 @@
</td>
</tr>
{% endif %}
<tr>
<td colspan="3">
{{ 'sum'|_ }}
</td>
<td style="text-align:right">{{ totalSum|formatAmount }}</td>
</tr>
</tfoot>
</table>
</div>