diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php
index 9d420ed923..530e032851 100644
--- a/app/Http/Controllers/Chart/AccountController.php
+++ b/app/Http/Controllers/Chart/AccountController.php
@@ -7,6 +7,7 @@ use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Account;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Grumpydictator\Gchart\GChart;
+use Illuminate\Support\Collection;
use Preferences;
use Response;
use Session;
@@ -19,6 +20,60 @@ use Steam;
*/
class AccountController extends Controller
{
+ /**
+ * Shows the balances for all the user's accounts.
+ *
+ * @param GChart $chart
+ * @param AccountRepositoryInterface $repository
+ *
+ * @return \Symfony\Component\HttpFoundation\Response
+ */
+ public function all(GChart $chart, AccountRepositoryInterface $repository, $year, $month, $shared = false)
+ {
+ $start = new Carbon($year . '-' . $month . '-01');
+ $end = clone $start;
+ $end->endOfMonth();
+ $chart->addColumn(trans('firefly.dayOfMonth'), 'date');
+
+ /** @var Collection $accounts */
+ $accounts = $repository->getAccounts(['Default account', 'Asset account']);
+ if ($shared === false) {
+ // remove the shared accounts from the collection:
+ /** @var Account $account */
+ foreach ($accounts as $index => $account) {
+ if ($account->getMeta('accountRole') == 'sharedAsset') {
+ $accounts->forget($index);
+ }
+ }
+ }
+
+
+ $index = 1;
+ /** @var Account $account */
+ foreach ($accounts as $account) {
+ $chart->addColumn(trans('firefly.balanceFor', ['name' => $account->name]), 'number');
+ $chart->addCertainty($index);
+ $index++;
+ }
+ $current = clone $start;
+ $current->subDay();
+ $today = Carbon::now();
+ while ($end >= $current) {
+ $row = [clone $current];
+ $certain = $current < $today;
+ foreach ($accounts as $account) {
+ $row[] = Steam::balance($account, $current);
+ $row[] = $certain;
+ }
+ $chart->addRowArray($row);
+ $current->addDay();
+ }
+ $chart->generate();
+
+ return Response::json($chart->getData());
+
+ }
+
/**
* Shows the balances for all the user's frontpage accounts.
*
diff --git a/app/Http/routes.php b/app/Http/routes.php
index 9ad733e0a5..c5b4ed80af 100644
--- a/app/Http/routes.php
+++ b/app/Http/routes.php
@@ -276,8 +276,10 @@ Route::group(
*/
// accounts:
Route::get('/chart/account/frontpage', ['uses' => 'Chart\AccountController@frontpage']);
+ Route::get('/chart/account/month/{year}/{month}/{shared?}', ['uses' => 'Chart\AccountController@all'])->where(['year' => '[0-9]{4}', 'month' => '[0-9]{1,2}', 'shared' => 'shared']);
Route::get('/chart/account/{account}', ['uses' => 'Chart\AccountController@single']);
+
// bills:
Route::get('/chart/bill/frontpage', ['uses' => 'Chart\BillController@frontpage']);
Route::get('/chart/bill/{bill}', ['uses' => 'Chart\BillController@single']);
diff --git a/public/js/reports.js b/public/js/reports.js
index 8944db46b9..0517d4951d 100644
--- a/public/js/reports.js
+++ b/public/js/reports.js
@@ -9,6 +9,8 @@ function drawChart() {
googleStackedColumnChart('chart/budget/year/' + year + shared, 'budgets');
googleStackedColumnChart('chart/category/year/' + year + shared, 'categories');
+
+ googleLineChart('/chart/account/month/' + year + '/' + month + shared, 'account-balances-chart');
}
$(function () {
@@ -39,7 +41,7 @@ function openModal(e) {
function showIncomes() {
"use strict";
- if(incomeRestShow) {
+ if (incomeRestShow) {
// hide everything, make button say "show"
$('#showIncomes').text(showTheRest);
$('.incomesCollapsed').removeClass('in').addClass('out');
@@ -59,7 +61,7 @@ function showIncomes() {
}
function showExpenses() {
- if(expenseRestShow) {
+ if (expenseRestShow) {
// hide everything, make button say "show"
$('#showExpenses').text(showTheRestExpense);
$('.expenseCollapsed').removeClass('in').addClass('out');
diff --git a/resources/twig/reports/month.twig b/resources/twig/reports/month.twig
index 1f7439570c..97d286029d 100644
--- a/resources/twig/reports/month.twig
+++ b/resources/twig/reports/month.twig
@@ -69,7 +69,15 @@
{% endblock %}
{% block scripts %}
+
+
+
+
+
+