Some more cleaning up and fixing

This commit is contained in:
James Cole 2015-05-15 21:01:24 +02:00
parent aede03d8b2
commit aae003be33
11 changed files with 164 additions and 171 deletions

View File

@ -111,7 +111,7 @@ class GoogleChartController extends Controller
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function allBudgetsAndSpending(GChart $chart, BudgetRepositoryInterface $repository, $year)
public function allBudgetsAndSpending(GChart $chart, BudgetRepositoryInterface $repository, $year, $shared = false)
{
$budgets = $repository->getBudgets();
$chart->addColumn(trans('firefly.month'), 'date');
@ -506,14 +506,16 @@ class GoogleChartController extends Controller
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function yearInExp(GChart $chart, ReportQueryInterface $query, $year)
public function yearInExp(GChart $chart, ReportQueryInterface $query, $year, $shared = false)
{
$start = new Carbon('01-01-' . $year);
$chart->addColumn(trans('firefly.month'), 'date');
$chart->addColumn(trans('firefly.income'), 'number');
$chart->addColumn(trans('firefly.expenses'), 'number');
$includeShared = Preferences::get('includeShared', false)->data;
if ($shared == 'shared') {
$shared = true;
}
// get report query interface.
@ -523,8 +525,8 @@ class GoogleChartController extends Controller
$currentEnd = clone $start;
$currentEnd->endOfMonth();
// total income && total expenses:
$incomeSum = floatval($query->incomeInPeriod($start, $currentEnd, $includeShared)->sum('queryAmount'));
$expenseSum = floatval($query->journalsByExpenseAccount($start, $currentEnd, $includeShared)->sum('queryAmount'));
$incomeSum = floatval($query->incomeInPeriod($start, $currentEnd, $shared)->sum('queryAmount'));
$expenseSum = floatval($query->journalsByExpenseAccount($start, $currentEnd, $shared)->sum('queryAmount'));
$chart->addRow(clone $start, $incomeSum, $expenseSum);
$start->addMonth();
@ -544,14 +546,16 @@ class GoogleChartController extends Controller
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function yearInExpSum(GChart $chart, ReportQueryInterface $query, $year)
public function yearInExpSum(GChart $chart, ReportQueryInterface $query, $year, $shared = false)
{
$start = new Carbon('01-01-' . $year);
$chart->addColumn(trans('firefly.summary'), 'string');
$chart->addColumn(trans('firefly.income'), 'number');
$chart->addColumn(trans('firefly.expenses'), 'number');
$includeShared = Preferences::get('includeShared', false)->data;
if ($shared == 'shared') {
$shared = true;
}
$income = 0;
$expense = 0;
@ -563,9 +567,9 @@ class GoogleChartController extends Controller
$currentEnd = clone $start;
$currentEnd->endOfMonth();
// total income:
$incomeSum = floatval($query->incomeInPeriod($start, $currentEnd, $includeShared)->sum('queryAmount'));
$incomeSum = floatval($query->incomeInPeriod($start, $currentEnd, $shared)->sum('queryAmount'));
// total expenses:
$expenseSum = floatval($query->journalsByExpenseAccount($start, $currentEnd, $includeShared)->sum('queryAmount'));
$expenseSum = floatval($query->journalsByExpenseAccount($start, $currentEnd, $shared)->sum('queryAmount'));
$income += $incomeSum;
$expense += $expenseSum;

View File

@ -33,7 +33,7 @@ class ReportController extends Controller
$this->query = $query;
$this->helper = $helper;
View::share('title', 'Reports');
View::share('title', trans('firefly.reports'));
View::share('mainTitleIcon', 'fa-line-chart');
}
@ -246,7 +246,7 @@ class ReportController extends Controller
return view(
'reports.month',
compact(
'income', 'expenses', 'budgets', 'accounts', 'categories',
'income', 'expenses', 'budgets', 'accounts', 'categories','shared',
'date', 'subTitle', 'displaySum', 'subTitleIcon'
)
);
@ -259,14 +259,17 @@ class ReportController extends Controller
*/
public function year($year, $shared = false)
{
$subTitle = trans('firefly.reportForYear',['year' => $year]);
if ($shared == 'shared') {
$shared = true;
$subTitle = trans('firefly.reportForYearShared',['year' => $year]);
}
$date = new Carbon('01-01-' . $year);
$end = clone $date;
$end->endOfYear();
$title = 'Reports';
$subTitle = $year;
$subTitleIcon = 'fa-bar-chart';
$mainTitleIcon = 'fa-line-chart';
$balances = $this->helper->yearBalanceReport($date, $shared);
@ -274,7 +277,7 @@ class ReportController extends Controller
$groupedExpenses = $this->query->journalsByExpenseAccount($date, $end, $shared);
return view(
'reports.year', compact('date', 'groupedIncomes', 'groupedExpenses', 'year', 'balances', 'title', 'subTitle', 'subTitleIcon', 'mainTitleIcon')
'reports.year', compact('date','shared', 'groupedIncomes', 'groupedExpenses', 'year', 'balances', 'subTitle', 'subTitleIcon', 'mainTitleIcon')
);
}

View File

@ -321,23 +321,28 @@ Breadcrumbs::register(
);
Breadcrumbs::register(
'reports.year', function (Generator $breadcrumbs, Carbon $date) {
'reports.year', function (Generator $breadcrumbs, Carbon $date, $shared) {
$breadcrumbs->parent('reports.index');
$breadcrumbs->push(trans('breadcrumbs.yearly_report', ['date' => $date->year]), route('reports.year', $date->year));
if ($shared) {
$title = trans('breadcrumbs.yearly_report_shared', ['date' => $date->year]);
} else {
$title = trans('breadcrumbs.yearly_report', ['date' => $date->year]);
}
$breadcrumbs->push($title, route('reports.year', $date->year));
}
);
Breadcrumbs::register(
'reports.month', function (Generator $breadcrumbs, Carbon $date) {
$breadcrumbs->parent('reports.year', $date);
$breadcrumbs->push(trans('breadcrumbs.monthly_report', ['date' => $date->format('F Y')]), route('reports.month', [$date->year, $date->month]));
}
);
'reports.month', function (Generator $breadcrumbs, Carbon $date, $shared) {
$breadcrumbs->parent('reports.year', $date, $shared);
Breadcrumbs::register(
'reports.budget', function (Generator $breadcrumbs, Carbon $date) {
$breadcrumbs->parent('reports.index');
$breadcrumbs->push(trans('breadcrumbs.budget_report', ['date' => $date->format('F Y')]), route('reports.budget', [$date->year, $date->month]));
if ($shared) {
$title = trans('breadcrumbs.monthly_report_shared', ['date' => $date->year]);
} else {
$title = trans('breadcrumbs.monthly_report', ['date' => $date->year]);
}
$breadcrumbs->push($title, route('reports.month', [$date->year, $date->month]));
}
);

View File

@ -281,10 +281,10 @@ Route::group(
Route::get('/chart/home/bills', ['uses' => 'GoogleChartController@billsOverview']);
Route::get('/chart/account/{account}/{view?}', ['uses' => 'GoogleChartController@accountBalanceChart']);
Route::get('/chart/budget/{budget}/spending/{year?}', ['uses' => 'GoogleChartController@budgetsAndSpending']);
Route::get('/chart/budgets/spending/{year?}', ['uses' => 'GoogleChartController@allBudgetsAndSpending'])->where(['year' => '[0-9]+']);
Route::get('/chart/budgets/spending/{year}/{shared?}', ['uses' => 'GoogleChartController@allBudgetsAndSpending'])->where(['year' => '[0-9]{4}','shared' => 'shared']);
Route::get('/chart/budget/{budget}/{limitrepetition}', ['uses' => 'GoogleChartController@budgetLimitSpending']);
Route::get('/chart/reports/income-expenses/{year}', ['uses' => 'GoogleChartController@yearInExp']);
Route::get('/chart/reports/income-expenses-sum/{year}', ['uses' => 'GoogleChartController@yearInExpSum']);
Route::get('/chart/reports/income-expenses/{year}/{shared?}', ['uses' => 'GoogleChartController@yearInExp'])->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']);
Route::get('/chart/bills/{bill}', ['uses' => 'GoogleChartController@billOverview']);
Route::get('/chart/piggy-history/{piggyBank}', ['uses' => 'GoogleChartController@piggyBankHistory']);
Route::get('/chart/category/{category}/period', ['uses' => 'GoogleChartController@categoryPeriodChart']);

View File

@ -5,16 +5,14 @@ if (typeof(google) != 'undefined') {
function drawChart() {
googleColumnChart('chart/reports/income-expenses/' + year, 'income-expenses-chart');
googleColumnChart('chart/reports/income-expenses-sum/' + year, 'income-expenses-sum-chart')
googleColumnChart('chart/reports/income-expenses/' + year + shared, 'income-expenses-chart');
googleColumnChart('chart/reports/income-expenses-sum/' + year + shared, 'income-expenses-sum-chart')
googleStackedColumnChart('chart/budgets/spending/' + year, 'budgets');
googleStackedColumnChart('chart/budgets/spending/' + year + shared, 'budgets');
}
$(function () {
$('.openModal').on('click', openModal);
includeSharedToggle();
$('#includeShared').click(includeSharedSet);
});
function openModal(e) {
@ -31,32 +29,3 @@ function openModal(e) {
return false;
}
function includeSharedToggle() {
// get setting from JSON.
$.getJSON('json/show-shared-reports').success(function (data) {
console.log('GO');
if (data.value == true) {
// show shared data, update button:
//<i class="state-icon glyphicon glyphicon-check"></i>
$('#includeShared').empty().addClass('btn-info').append($('<i>').addClass('state-icon glyphicon glyphicon-check')).append(' Include shared asset accounts').show();
console.log('true');
} else {
$('#includeShared').empty().removeClass('btn-info').append($('<i>').addClass('state-icon glyphicon glyphicon-unchecked')).append(' Include shared asset accounts').show();
console.log('false');
}
}).fail(function () {
console.log('fail');
});
}
function includeSharedSet() {
// get setting from JSON.
$.getJSON('json/show-shared-reports/set').success(function (data) {
console.log('Value is now: ' + data.value);
includeSharedToggle();
}).fail(function () {
console.log('fail');
});
return false;
}

View File

@ -46,7 +46,10 @@ return [
'reports' => 'Reports',
'monthly_report' => 'Montly report for :date',
'monthly_report_shared' => 'Montly report for :date (including shared accounts)',
'yearly_report' => 'Yearly report for :date',
'yearly_report_shared' => 'Yearly report for :date (including shared accounts)',
'budget_report' => 'Budget report for :date',
'searchResult' => 'Search for ":query"',

View File

@ -86,6 +86,9 @@ return [
'half-year' => 'Every six months',
'yearly' => 'Yearly',
'reportForYear' => 'Yearly report for :year',
'reportForYearShared' => 'Yearly report for :year (including shared accounts)',
// charts:
'dayOfMonth' => 'Day of the month',
'month' => 'Month',

View File

@ -46,7 +46,9 @@ return [
'reports' => 'Overzichten',
'monthly_report' => 'Maandoverzicht :date',
'monthly_report_shared' => 'Maandoverzicht :date (inclusief gedeelde rekeningen)',
'yearly_report' => 'Jaaroverzicht :date',
'yearly_report_shared' => 'Jaaroverzicht :date (inclusief gedeelde rekeningen)',
'budget_report' => 'Budgetoverzicht :date',
'searchResult' => 'Zoeken naar ":query"',

View File

@ -86,6 +86,9 @@ return [
'half-year' => 'Elk half jaar',
'yearly' => 'Jaarlijks',
'reportForYear' => 'Jaaroverzicht :year',
'reportForYearShared' => 'Jaaroverzicht :year (inclusief gedeelde rekeningen)',
// charts:
'dayOfMonth' => 'Dag vd maand',
'month' => 'Maand',

View File

@ -1,6 +1,6 @@
{% extends "./layout/default.twig" %}
{% block content %}
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, date) }}
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, date, shared) }}
<div class="row">
<div class="col-lg-5 col-md-5 col-sm-12">

View File

@ -1,6 +1,6 @@
{% extends "./layout/default.twig" %}
{% block content %}
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, date) }}
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, date, shared) }}
<div class="row">
<div class="col-lg-10 col-md-8 col-sm-12">
@ -170,6 +170,7 @@
<script type="text/javascript">
var year = '{{year}}';
var shared = {% if shared %}'/shared'{% else %}''{% endif %};
</script>
<script type="text/javascript" src="js/reports.js"></script>