diff --git a/app/Http/routes.php b/app/Http/routes.php
index 9b659f3a69..941f44a147 100644
--- a/app/Http/routes.php
+++ b/app/Http/routes.php
@@ -285,26 +285,23 @@ Route::group(
// budgets:
Route::get('/chart/budget/frontpage', ['uses' => 'Chart\BudgetController@frontpage']);
+ Route::get('/chart/budget/year/{year}/{shared?}', ['uses' => 'Chart\BudgetController@year'])->where(['year' => '[0-9]{4}', 'shared' => 'shared']);
Route::get('/chart/budget/{budget}/{limitrepetition}', ['uses' => 'Chart\BudgetController@budgetLimit']);
// categories:
Route::get('/chart/category/frontpage', ['uses' => 'Chart\CategoryController@frontpage']);
+ Route::get('/chart/category/year/{year}/{shared?}', ['uses' => 'Chart\CategoryController@year'])->where(['year' => '[0-9]{4}', 'shared' => 'shared']);
Route::get('/chart/category/{category}/month', ['uses' => 'Chart\CategoryController@month']); // should be period.
Route::get('/chart/category/{category}/all', ['uses' => 'Chart\CategoryController@all']);
// piggy banks:
Route::get('/chart/piggyBank/{piggyBank}', ['uses' => 'Chart\PiggyBankController@history']);
-
-
- Route::get('/chart/reports/income-expenses/{year}/{shared?}', ['uses' => 'GoogleChartController@yearInExp'])->where(
+ // reports:
+ Route::get('/chart/report/in-out/{year}/{shared?}', ['uses' => 'Chart\ReportController@yearInOut'])->where(['year' => '[0-9]{4}', 'shared' => 'shared']);
+ Route::get('/chart/report/in-out-sum/{year}/{shared?}', ['uses' => 'Chart\ReportController@yearInOutSummarized'])->where(
['year' => '[0-9]{4}', 'shared' => 'shared']
);
- Route::get('/chart/reports/income-expenses-sum/{year}/{shared?}', ['uses' => 'GoogleChartController@yearInExpSum'])->where(
- ['year' => '[0-9]{4}', 'shared' => 'shared']
- );
-
-
/**
@@ -385,19 +382,6 @@ Route::group(
'/reports/modal/{account}/{year}/{month}/left-unbalanced', ['uses' => 'ReportController@modalLeftUnbalanced', 'as' => 'reports.left-unbalanced']
);
- /**
- * Report Chart Controller:
- */
- Route::get('/report/chart/in-out/{year}/{shared?}', ['uses' => 'ReportChartController@yearInOut'])->where(['year' => '[0-9]{4}', 'shared' => 'shared']);
- Route::get('/report/chart/in-out-sum/{year}/{shared?}', ['uses' => 'ReportChartController@yearInOutSummarized'])->where(
- ['year' => '[0-9]{4}', 'shared' => 'shared']
- );
-
- Route::get('/report/chart/budgets/{year}/{shared?}', ['uses' => 'ReportChartController@yearBudgets'])->where(['year' => '[0-9]{4}', 'shared' => 'shared']);
- Route::get('/report/chart/categories/{year}/{shared?}', ['uses' => 'ReportChartController@yearCategories'])->where(
- ['year' => '[0-9]{4}', 'shared' => 'shared']
- );
-
/**
* Search Controller
*/
diff --git a/public/js/reports.js b/public/js/reports.js
index 88e7e8ffd8..8944db46b9 100644
--- a/public/js/reports.js
+++ b/public/js/reports.js
@@ -4,10 +4,11 @@ if (typeof(google) != 'undefined') {
function drawChart() {
- googleColumnChart('report/chart/in-out/' + year + shared, 'income-expenses-chart');
- googleColumnChart('report/chart/in-out-sum/' + year + shared, 'income-expenses-sum-chart')
+ googleColumnChart('chart/report/in-out/' + year + shared, 'income-expenses-chart');
+ googleColumnChart('chart/report/in-out-sum/' + year + shared, 'income-expenses-sum-chart');
- googleStackedColumnChart('report/chart/budgets/' + year + shared, 'budgets');
+ googleStackedColumnChart('chart/budget/year/' + year + shared, 'budgets');
+ googleStackedColumnChart('chart/category/year/' + year + shared, 'categories');
}
$(function () {
diff --git a/resources/twig/reports/year.twig b/resources/twig/reports/year.twig
index 0b71be787c..b9acc3c2c9 100644
--- a/resources/twig/reports/year.twig
+++ b/resources/twig/reports/year.twig
@@ -164,7 +164,7 @@
{{ 'categories'|_ }}
diff --git a/tests/controllers/GoogleChartControllerTest.php b/tests/controllers/GoogleChartControllerTest.php
deleted file mode 100644
index 7e1fa9326c..0000000000
--- a/tests/controllers/GoogleChartControllerTest.php
+++ /dev/null
@@ -1,256 +0,0 @@
-be($account->user);
-
- // mock stuff:
- Steam::shouldReceive('balance')->andReturn(0);
-
- $this->call('GET', '/chart/account/' . $account->id);
- $this->assertResponseOk();
- }
-
- public function testAllAccountsBalanceChart()
- {
- $account = FactoryMuffin::create('FireflyIII\Models\Account');
- $this->be($account->user);
- $collection = new Collection;
- $collection->push($account);
-
- //mock stuff:
- Preferences::shouldReceive('get')->andReturn(new Preference);
- $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
- $repository->shouldReceive('getFrontpageAccounts')->andReturn($collection);
-
- $this->call('GET', '/chart/home/account');
- $this->assertResponseOk();
-
-
- }
-
- public function testAllBudgetsHomeChart()
- {
-
- $budget1 = FactoryMuffin::create('FireflyIII\Models\Budget');
- $budget2 = FactoryMuffin::create('FireflyIII\Models\Budget');
- $budget3 = FactoryMuffin::create('FireflyIII\Models\Budget');
- $budget4 = FactoryMuffin::create('FireflyIII\Models\Budget');
- $budgets = new Collection([$budget1, $budget2, $budget3, $budget4]);
-
- $rep1 = FactoryMuffin::create('FireflyIII\Models\LimitRepetition');
- $rep2 = FactoryMuffin::create('FireflyIII\Models\LimitRepetition');
- $rep3 = FactoryMuffin::create('FireflyIII\Models\LimitRepetition');
-
- $rep1->amount = 6;
- $rep1->save();
- $rep2->amount = 18;
- $rep2->save();
- $this->be($budget1->user);
-
-
- $coll1 = new Collection([$rep1]);
- $coll2 = new Collection([$rep2]);
- $coll3 = new Collection([$rep3]);
- $coll4 = new Collection;
-
-
- // mock stuff:
- $repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
- $repository->shouldReceive('getBudgets')->andReturn($budgets);
- $repository->shouldReceive('getBudgetLimitRepetitions')->andReturn($coll1, $coll2, $coll3, $coll4);
- $repository->shouldReceive('sumBudgetExpensesInPeriod')->andReturn(12, 12, 12, -12);
- $repository->shouldReceive('getWithoutBudgetSum')->andReturn(0);
-
- $this->call('GET', '/chart/home/budgets');
- $this->assertResponseOk();
- }
-
- public function testAllCategoriesHomeChart()
- {
- $category = FactoryMuffin::create('FireflyIII\Models\Category');
-
- $this->be($category->user);
- $category->save();
- $category->sum = 100;
- $collection = new Collection;
- $collection->push($category);
-
- // mock stuff:
- $repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
- $repository->shouldReceive('getCategoriesAndExpenses')->andReturn($collection);
- Crypt::shouldReceive('decrypt')->andReturn('Hello!');
- Crypt::shouldReceive('encrypt')->andReturn('Hello!');
-
-
- $this->call('GET', '/chart/home/categories');
- $this->assertResponseOk();
- }
-
- public function testBillOverview()
- {
- $bill = FactoryMuffin::create('FireflyIII\Models\Bill');
- $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
- $collection = new Collection;
- $collection->push($journal);
- $this->be($bill->user);
-
- // mock!
- $repository = $this->mock('FireflyIII\Repositories\Bill\BillRepositoryInterface');
- $repository->shouldReceive('getJournals')->andReturn($collection);
-
-
- // call!
- $this->call('GET', '/chart/bills/' . $bill->id);
- $this->assertResponseOk();
- }
-
- public function testBillsOverview()
- {
- $bill1 = FactoryMuffin::create('FireflyIII\Models\Bill');
- $bill2 = FactoryMuffin::create('FireflyIII\Models\Bill');
- $journal1 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
- $journal2 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
- $card1 = FactoryMuffin::create('FireflyIII\Models\Account');
- $card2 = FactoryMuffin::create('FireflyIII\Models\Account');
- $fake = FactoryMuffin::create('FireflyIII\Models\Bill');
-
-
- $bills = new Collection([$bill1, $bill2]);
- $journals = new Collection([$journal1, $journal2]);
- $cards = new Collection([$card1, $card2]);
- $emptyCollection = new Collection;
- $ranges = [['start' => new Carbon, 'end' => new Carbon]];
- $this->be($bill1->user);
-
- // mock!
- $repository = $this->mock('FireflyIII\Repositories\Bill\BillRepositoryInterface');
- $accounts = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
-
- // calls:
- $repository->shouldReceive('getActiveBills')->andReturn($bills);
- $repository->shouldReceive('getRanges')->andReturn($ranges);
- $repository->shouldReceive('getJournalsInRange')->andReturn($journals, $emptyCollection);
- $accounts->shouldReceive('getCreditCards')->andReturn($cards);
- $accounts->shouldReceive('getTransfersInRange')->andReturn($journals, $emptyCollection);
- $repository->shouldReceive('createFakeBill')->andReturn($fake);
- Steam::shouldReceive('balance')->andReturn(-1, 0);
-
- $this->call('GET', '/chart/home/bills');
- $this->assertResponseOk();
- }
-
- public function testBudgetLimitSpending()
- {
- $repetition = FactoryMuffin::create('FireflyIII\Models\LimitRepetition');
- $repetition->startdate = Carbon::now()->startOfMonth();
- $repetition->enddate = Carbon::now()->endOfMonth();
- $repetition->save();
- $budget = $repetition->budgetlimit->budget;
- $this->be($budget->user);
- ///chart/budget/{budget}/{limitrepetition}
-
- // mock!
- $repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
- $repository->shouldReceive('expensesOnDay')->andReturn(rand(1, 1000));
-
- $this->call('GET', '/chart/budget/' . $budget->id . '/' . $repetition->id);
- $this->assertResponseOk();
-
- }
-
- public function testCategoryOverviewChart()
- {
- $category = FactoryMuffin::create('FireflyIII\Models\Category');
- $pref = FactoryMuffin::create('FireflyIII\Models\Preference');
- $this->be($category->user);
- $start = new Carbon();
- $start->subDay();
- $end = new Carbon;
- $end->addWeek();
-
- // mock!
- $repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
- $repository->shouldReceive('getFirstActivityDate')->andReturn($start);
- $repository->shouldReceive('spentInPeriod')->andReturn(rand(1, 100));
- Preferences::shouldReceive('get')->andReturn($pref);
-
- Navigation::shouldReceive('startOfPeriod')->andReturn($start);
- Navigation::shouldReceive('endOfPeriod')->andReturn($start);
- Navigation::shouldReceive('addPeriod')->andReturn($end);
-
- $this->call('GET', '/chart/category/' . $category->id . '/overview');
- $this->assertResponseOk();
- }
-
- public function testCategoryPeriodChart()
- {
- $category = FactoryMuffin::create('FireflyIII\Models\Category');
- $this->be($category->user);
-
- // mock!
- $repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
- $repository->shouldReceive('spentOnDaySum')->andReturn(rand(1, 100));
-
- $this->call('GET', '/chart/category/' . $category->id . '/period');
- $this->assertResponseOk();
- }
-
- public function testPiggyBankHistory()
- {
- $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
- $this->be($piggyBank->account->user);
-
- $obj = new stdClass;
- $obj->sum = 12;
- $obj->date = new Carbon;
- $collection = new Collection([$obj]);
-
- $repository = $this->mock('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface');
- $repository->shouldReceive('getEventSummarySet')->andReturn($collection);
-
- $this->call('GET', '/chart/piggy-history/' . $piggyBank->id);
- $this->assertResponseOk();
- }
-
-}