mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 10:33:30 +00:00
More changes to reports.
This commit is contained in:
@@ -202,30 +202,6 @@ class JsonController extends Controller
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function setSharedReports()
|
||||
{
|
||||
/** @var Preference $pref */
|
||||
$pref = Preferences::get('includeShared', false);
|
||||
$new = !$pref->data;
|
||||
Preferences::set('includeShared', $new);
|
||||
|
||||
|
||||
return Response::json(['value' => $new]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function showSharedReports()
|
||||
{
|
||||
$pref = Preferences::get('includeShared', false);
|
||||
|
||||
return Response::json(['value' => $pref->data]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a JSON list of all beneficiaries.
|
||||
*
|
||||
|
@@ -6,7 +6,6 @@ use FireflyIII\Helpers\Report\ReportQueryInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Preferences;
|
||||
use Session;
|
||||
use Steam;
|
||||
use View;
|
||||
@@ -128,7 +127,7 @@ class ReportController extends Controller
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function month($year = '2014', $month = '1')
|
||||
public function month($year = '2014', $month = '1', $shared = false)
|
||||
{
|
||||
$date = new Carbon($year . '-' . $month . '-01');
|
||||
$subTitle = 'Report for ' . $date->format('F Y');
|
||||
@@ -136,15 +135,17 @@ class ReportController extends Controller
|
||||
$displaySum = true; // to show sums in report.
|
||||
$end = clone $date;
|
||||
$start = clone $date;
|
||||
$includeShared = Preferences::get('includeShared', false)->data;
|
||||
if ($shared == 'shared') {
|
||||
$shared = true;
|
||||
}
|
||||
|
||||
// set start and end.
|
||||
$start->startOfMonth();
|
||||
$end->endOfMonth();
|
||||
|
||||
// get all income and expenses. it's OK.
|
||||
$income = $this->query->incomeInPeriod($start, $end, $includeShared);
|
||||
$expensesSet = $this->query->journalsByExpenseAccount($start, $end, $includeShared);
|
||||
$income = $this->query->incomeInPeriod($start, $end, $shared);
|
||||
$expensesSet = $this->query->journalsByExpenseAccount($start, $end, $shared);
|
||||
|
||||
/**
|
||||
* INCLUDE ORIGINAL BUDGET REPORT HERE:
|
||||
@@ -152,7 +153,7 @@ class ReportController extends Controller
|
||||
// should show shared reports?
|
||||
/** @var Preference $pref */
|
||||
$accountAmounts = []; // array with sums of spent amounts on each account.
|
||||
$accounts = $this->query->getAllAccounts($start, $end, $includeShared); // all accounts and some data.
|
||||
$accounts = $this->query->getAllAccounts($start, $end, $shared); // all accounts and some data.
|
||||
|
||||
foreach ($accounts as $account) {
|
||||
|
||||
@@ -190,7 +191,7 @@ class ReportController extends Controller
|
||||
/**
|
||||
* Start getBudgetsForMonth DONE
|
||||
*/
|
||||
$budgets = $this->helper->getBudgetsForMonth($date, $includeShared);
|
||||
$budgets = $this->helper->getBudgetsForMonth($date, $shared);
|
||||
|
||||
/**
|
||||
* End getBudgetsForMonth DONE
|
||||
@@ -204,7 +205,7 @@ class ReportController extends Controller
|
||||
|
||||
|
||||
// all transfers
|
||||
if ($includeShared === false) {
|
||||
if ($shared === false) {
|
||||
$result = $this->query->sharedExpensesByCategory($start, $end);
|
||||
$transfers = Steam::makeArray($result);
|
||||
$merged = Steam::mergeArrays($categories, $transfers);
|
||||
@@ -243,10 +244,11 @@ class ReportController extends Controller
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function year($year)
|
||||
public function year($year, $shared = false)
|
||||
{
|
||||
/** @var Preference $pref */
|
||||
$includeShared = Preferences::get('includeShared', false)->data;
|
||||
if ($shared == 'shared') {
|
||||
$shared = true;
|
||||
}
|
||||
$date = new Carbon('01-01-' . $year);
|
||||
$end = clone $date;
|
||||
$end->endOfYear();
|
||||
@@ -254,9 +256,9 @@ class ReportController extends Controller
|
||||
$subTitle = $year;
|
||||
$subTitleIcon = 'fa-bar-chart';
|
||||
$mainTitleIcon = 'fa-line-chart';
|
||||
$balances = $this->helper->yearBalanceReport($date, $includeShared);
|
||||
$groupedIncomes = $this->query->journalsByRevenueAccount($date, $end, $includeShared);
|
||||
$groupedExpenses = $this->query->journalsByExpenseAccount($date, $end, $includeShared);
|
||||
$balances = $this->helper->yearBalanceReport($date, $shared);
|
||||
$groupedIncomes = $this->query->journalsByRevenueAccount($date, $end, $shared);
|
||||
$groupedExpenses = $this->query->journalsByExpenseAccount($date, $end, $shared);
|
||||
|
||||
return view(
|
||||
'reports.year', compact('date', 'groupedIncomes', 'groupedExpenses', 'year', 'balances', 'title', 'subTitle', 'subTitleIcon', 'mainTitleIcon')
|
||||
|
@@ -306,10 +306,7 @@ Route::group(
|
||||
Route::get('/json/box/out', ['uses' => 'JsonController@boxOut', 'as' => 'json.box.out']);
|
||||
Route::get('/json/box/bills-unpaid', ['uses' => 'JsonController@boxBillsUnpaid', 'as' => 'json.box.paid']);
|
||||
Route::get('/json/box/bills-paid', ['uses' => 'JsonController@boxBillsPaid', 'as' => 'json.box.unpaid']);
|
||||
Route::get('/json/show-shared-reports', 'JsonController@showSharedReports');
|
||||
Route::get('/json/transaction-journals/{what}', 'JsonController@transactionJournals');
|
||||
Route::get('/json/show-shared-reports/set', 'JsonController@setSharedReports');
|
||||
|
||||
|
||||
/**
|
||||
* Piggy Bank Controller
|
||||
@@ -355,18 +352,14 @@ Route::group(
|
||||
* Report Controller
|
||||
*/
|
||||
Route::get('/reports', ['uses' => 'ReportController@index', 'as' => 'reports.index']);
|
||||
Route::get('/reports/{year}', ['uses' => 'ReportController@year', 'as' => 'reports.year']);
|
||||
Route::get('/reports/{year}/{month}', ['uses' => 'ReportController@month', 'as' => 'reports.month']);
|
||||
//Route::get('/reports/{year}', ['uses' => 'ReportController@year', 'as' => 'reports.year'])->where(['year' => '[0-9]{4}']);
|
||||
Route::get('/reports/{year}/{shared?}', ['uses' => 'ReportController@year', 'as' => 'reports.year'])->where(['year' => '[0-9]{4}','shared'=> 'shared']);
|
||||
Route::get('/reports/{year}/{month}/{shared?}', ['uses' => 'ReportController@month', 'as' => 'reports.month'])->where(['year' => '[0-9]{4}','month' => '[0-9]{1,2}','shared' => 'shared']);
|
||||
|
||||
// pop ups for budget report:
|
||||
Route::get('/reports/modal/{account}/{year}/{month}/no-budget', ['uses' => 'ReportController@modalNoBudget', 'as' => 'reports.no-budget']);
|
||||
Route::get(
|
||||
'/reports/modal/{account}/{year}/{month}/balanced-transfers',
|
||||
['uses' => 'ReportController@modalBalancedTransfers', 'as' => 'reports.balanced-transfers']
|
||||
);
|
||||
Route::get(
|
||||
'/reports/modal/{account}/{year}/{month}/left-unbalanced', ['uses' => 'ReportController@modalLeftUnbalanced', 'as' => 'reports.left-unbalanced']
|
||||
);
|
||||
Route::get('/reports/modal/{account}/{year}/{month}/balanced-transfers', ['uses' => 'ReportController@modalBalancedTransfers', 'as' => 'reports.balanced-transfers']);
|
||||
Route::get('/reports/modal/{account}/{year}/{month}/left-unbalanced', ['uses' => 'ReportController@modalLeftUnbalanced', 'as' => 'reports.left-unbalanced']);
|
||||
|
||||
/**
|
||||
* Search Controller
|
||||
|
@@ -1,15 +1,6 @@
|
||||
{% extends "./layout/default.twig" %}
|
||||
{% block content %}
|
||||
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }}
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
||||
<p>
|
||||
<a href="#" class="btn btn-default" id="includeShared" style="display:none;">
|
||||
<i class="state-icon glyphicon glyphicon-unchecked"></i>
|
||||
Include shared asset accounts</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||
<div class="panel panel-default">
|
||||
|
@@ -1,14 +1,7 @@
|
||||
{% extends "./layout/default.twig" %}
|
||||
{% block content %}
|
||||
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, date) }}
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
||||
<p>
|
||||
<a href="#" class="btn btn-default" id="includeShared" style="display:none;">
|
||||
<i class="state-icon glyphicon glyphicon-unchecked"></i> Include shared asset accounts</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-5 col-sm-12">
|
||||
<div class="panel panel-default">
|
||||
|
@@ -1,15 +1,7 @@
|
||||
{% extends "./layout/default.twig" %}
|
||||
{% block content %}
|
||||
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, date) }}
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
||||
<p>
|
||||
<a href="#" class="btn btn-default" id="includeShared" style="display:none;">
|
||||
<i class="state-icon glyphicon glyphicon-unchecked"></i>
|
||||
Include shared asset accounts</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-10 col-md-8 col-sm-12">
|
||||
<div class="panel panel-default">
|
||||
|
@@ -176,49 +176,6 @@ class JsonControllerTest extends TestCase
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
public function testSetSharedReports()
|
||||
{
|
||||
$pref = FactoryMuffin::create('FireflyIII\Models\Preference');
|
||||
$pref->data = false;
|
||||
$pref->save();
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$this->be($user);
|
||||
|
||||
Preferences::shouldReceive('get')->withArgs(['includeShared', false])->andReturn($pref);
|
||||
Preferences::shouldReceive('set')->withArgs(['includeShared', true]);
|
||||
|
||||
// language preference:
|
||||
$language = FactoryMuffin::create('FireflyIII\Models\Preference');
|
||||
$language->data = 'en';
|
||||
$language->save();
|
||||
Preferences::shouldReceive('get')->withAnyArgs()->andReturn($language);
|
||||
|
||||
$this->call('GET', '/json/show-shared-reports/set');
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
|
||||
public function testShowSharedReports()
|
||||
{
|
||||
$pref = FactoryMuffin::create('FireflyIII\Models\Preference');
|
||||
$pref->data = false;
|
||||
$pref->save();
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$this->be($user);
|
||||
|
||||
Preferences::shouldReceive('get')->withArgs(['showSharedReports', false])->andReturn($pref);
|
||||
|
||||
// language preference:
|
||||
$language = FactoryMuffin::create('FireflyIII\Models\Preference');
|
||||
$language->data = 'en';
|
||||
$language->save();
|
||||
Preferences::shouldReceive('get')->withAnyArgs()->andReturn($language);
|
||||
|
||||
|
||||
$this->call('GET', '/json/show-shared-reports');
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
public function testTransactionJournals()
|
||||
{
|
||||
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
|
||||
|
Reference in New Issue
Block a user