mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Final code for #595
This commit is contained in:
parent
21c24fd7f0
commit
8ef9223d84
@ -293,7 +293,6 @@ class AccountController extends Controller
|
||||
$periods = $this->getPeriodOverview($account);
|
||||
}
|
||||
|
||||
$accountType = $account->accountType->type;
|
||||
$count = 0;
|
||||
$loop = 0;
|
||||
// grab journals, but be prepared to jump a period back to get the right ones:
|
||||
@ -327,7 +326,7 @@ class AccountController extends Controller
|
||||
|
||||
return view(
|
||||
'accounts.show',
|
||||
compact('account', 'currency', 'moment', 'accountType', 'periods', 'subTitleIcon', 'journals', 'subTitle', 'start', 'end', 'chartUri')
|
||||
compact('account', 'currency', 'moment', 'periods', 'subTitleIcon', 'journals', 'subTitle', 'start', 'end', 'chartUri')
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -100,9 +100,9 @@ class CategoryController extends Controller
|
||||
$earned = $repository->earnedInPeriod(new Collection([$category]), $accounts, $start, $currentEnd);
|
||||
$sum = bcadd($spent, $earned);
|
||||
$label = Navigation::periodShow($start, $range);
|
||||
$chartData[0]['entries'][$label] = bcmul($spent, '-1');
|
||||
$chartData[1]['entries'][$label] = $earned;
|
||||
$chartData[2]['entries'][$label] = $sum;
|
||||
$chartData[0]['entries'][$label] = round(bcmul($spent, '-1'), 12);
|
||||
$chartData[1]['entries'][$label] = round($earned, 12);
|
||||
$chartData[2]['entries'][$label] = round($sum, 12);
|
||||
$start = Navigation::addPeriod($start, $range, 0);
|
||||
}
|
||||
|
||||
@ -113,21 +113,6 @@ class CategoryController extends Controller
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CategoryRepositoryInterface $repository
|
||||
* @param Category $category
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function currentPeriod(CategoryRepositoryInterface $repository, Category $category)
|
||||
{
|
||||
$start = clone session('start', Carbon::now()->startOfMonth());
|
||||
$end = session('end', Carbon::now()->endOfMonth());
|
||||
$data = $this->makePeriodChart($repository, $category, $start, $end);
|
||||
|
||||
return Response::json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CategoryRepositoryInterface $repository
|
||||
* @param AccountRepositoryInterface $accountRepository
|
||||
@ -215,9 +200,9 @@ class CategoryController extends Controller
|
||||
$spent = $expenses[$category->id]['entries'][$period] ?? '0';
|
||||
$earned = $income[$category->id]['entries'][$period] ?? '0';
|
||||
$sum = bcadd($spent, $earned);
|
||||
$chartData[0]['entries'][$label] = bcmul($spent, '-1');
|
||||
$chartData[1]['entries'][$label] = $earned;
|
||||
$chartData[2]['entries'][$label] = $sum;
|
||||
$chartData[0]['entries'][$label] = round(bcmul($spent, '-1'), 12);
|
||||
$chartData[1]['entries'][$label] = round($earned, 12);
|
||||
$chartData[2]['entries'][$label] = round($sum, 12);
|
||||
}
|
||||
|
||||
$data = $this->generator->multiSet($chartData);
|
||||
@ -290,12 +275,11 @@ class CategoryController extends Controller
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function specificPeriod(CategoryRepositoryInterface $repository, Category $category, $date)
|
||||
public function specificPeriod(CategoryRepositoryInterface $repository, Category $category, Carbon $date)
|
||||
{
|
||||
$carbon = new Carbon($date);
|
||||
$range = Preferences::get('viewRange', '1M')->data;
|
||||
$start = Navigation::startOfPeriod($carbon, $range);
|
||||
$end = Navigation::endOfPeriod($carbon, $range);
|
||||
$start = Navigation::startOfPeriod($date, $range);
|
||||
$end = Navigation::endOfPeriod($date, $range);
|
||||
$data = $this->makePeriodChart($repository, $category, $start, $end);
|
||||
|
||||
return Response::json($data);
|
||||
@ -350,11 +334,11 @@ class CategoryController extends Controller
|
||||
$spent = $repository->spentInPeriod(new Collection([$category]), $accounts, $start, $start);
|
||||
$earned = $repository->earnedInPeriod(new Collection([$category]), $accounts, $start, $start);
|
||||
$sum = bcadd($spent, $earned);
|
||||
$label = Navigation::periodShow($start, '1D');
|
||||
$label = trim(Navigation::periodShow($start, '1D'));
|
||||
|
||||
$chartData[0]['entries'][$label] = bcmul($spent, '-1');
|
||||
$chartData[1]['entries'][$label] = $earned;
|
||||
$chartData[2]['entries'][$label] = $sum;
|
||||
$chartData[0]['entries'][$label] = round(bcmul($spent, '-1'),12);
|
||||
$chartData[1]['entries'][$label] = round($earned,12);
|
||||
$chartData[2]['entries'][$label] = round($sum,12);
|
||||
|
||||
|
||||
$start->addDay();
|
||||
|
@ -244,7 +244,7 @@ class TagController extends Controller
|
||||
$end = null;
|
||||
$periods = new Collection;
|
||||
$apiKey = env('GOOGLE_MAPS_API_KEY', '');
|
||||
$sum = '0';
|
||||
$sum = '0';
|
||||
|
||||
|
||||
// prep for "all" view.
|
||||
@ -252,7 +252,7 @@ class TagController extends Controller
|
||||
$subTitle = trans('firefly.all_journals_for_tag', ['tag' => $tag->tag]);
|
||||
$start = $repository->firstUseDate($tag);
|
||||
$end = new Carbon;
|
||||
$sum = $repository->sumOfTag($tag);
|
||||
$sum = $repository->sumOfTag($tag);
|
||||
}
|
||||
|
||||
// prep for "specific date" view.
|
||||
@ -265,6 +265,7 @@ class TagController extends Controller
|
||||
'start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]
|
||||
);
|
||||
$periods = $this->getPeriodOverview($tag);
|
||||
$sum = $repository->sumOfTag($tag, $start, $end);
|
||||
}
|
||||
|
||||
// prep for current period
|
||||
@ -304,7 +305,7 @@ class TagController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
return view('tags.show', compact('apiKey','tag', 'periods', 'subTitle', 'subTitleIcon', 'journals', 'sum', 'start', 'end', 'moment'));
|
||||
return view('tags.show', compact('apiKey', 'tag', 'periods', 'subTitle', 'subTitleIcon', 'journals', 'sum', 'start', 'end', 'moment'));
|
||||
}
|
||||
|
||||
|
||||
|
@ -77,13 +77,13 @@ Breadcrumbs::register(
|
||||
if ($moment === 'all') {
|
||||
$breadcrumbs->push(trans('firefly.everything'), route('accounts.show', [$account->id, 'all']));
|
||||
}
|
||||
// when is specific period:
|
||||
if (strlen($moment) > 0 && $moment !== 'all') {
|
||||
// when is specific period or when empty:
|
||||
if ($moment !== 'all') {
|
||||
$title = trans(
|
||||
'firefly.between_dates_breadcrumb', ['start' => $start->formatLocalized(strval(trans('config.month_and_day'))),
|
||||
'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]
|
||||
'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]
|
||||
);
|
||||
$breadcrumbs->push($title, route('accounts.show', [$account->id, $moment]));
|
||||
$breadcrumbs->push($title, route('accounts.show', [$account->id, $moment, $start, $end]));
|
||||
}
|
||||
|
||||
}
|
||||
@ -258,7 +258,7 @@ Breadcrumbs::register(
|
||||
$breadcrumbs->push(trans('firefly.everything'), route('budgets.no-budget', ['all']));
|
||||
}
|
||||
// when is specific period:
|
||||
if (strlen($moment) > 0 && $moment !== 'all') {
|
||||
if ($moment !== 'all') {
|
||||
$title = trans(
|
||||
'firefly.between_dates_breadcrumb', ['start' => $start->formatLocalized(strval(trans('config.month_and_day'))),
|
||||
'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]
|
||||
@ -334,7 +334,7 @@ Breadcrumbs::register(
|
||||
$breadcrumbs->push(trans('firefly.everything'), route('categories.show', [$category->id, 'all']));
|
||||
}
|
||||
// when is specific period:
|
||||
if (strlen($moment) > 0 && $moment !== 'all') {
|
||||
if ($moment !== 'all') {
|
||||
$title = trans(
|
||||
'firefly.between_dates_breadcrumb', ['start' => $start->formatLocalized(strval(trans('config.month_and_day'))),
|
||||
'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]
|
||||
@ -355,7 +355,7 @@ Breadcrumbs::register(
|
||||
$breadcrumbs->push(trans('firefly.everything'), route('categories.no-category', ['all']));
|
||||
}
|
||||
// when is specific period:
|
||||
if (strlen($moment) > 0 && $moment !== 'all') {
|
||||
if ($moment !== 'all') {
|
||||
$title = trans(
|
||||
'firefly.between_dates_breadcrumb', ['start' => $start->formatLocalized(strval(trans('config.month_and_day'))),
|
||||
'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]
|
||||
@ -730,7 +730,7 @@ Breadcrumbs::register(
|
||||
if ($moment === 'all') {
|
||||
$breadcrumbs->push(trans('firefly.everything'), route('tags.show', [$tag->id], $moment));
|
||||
}
|
||||
if ($moment !== '') {
|
||||
if ($moment !== 'all') {
|
||||
$title = trans(
|
||||
'firefly.between_dates_breadcrumb', ['start' => $start->formatLocalized(strval(trans('config.month_and_day'))),
|
||||
'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]
|
||||
@ -754,7 +754,7 @@ Breadcrumbs::register(
|
||||
}
|
||||
|
||||
// when is specific period:
|
||||
if (strlen($moment) > 0 && $moment !== 'all') {
|
||||
if ($moment !== 'all') {
|
||||
$title = trans(
|
||||
'firefly.between_dates_breadcrumb', ['start' => $start->formatLocalized(strval(trans('config.month_and_day'))),
|
||||
'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]
|
||||
|
@ -8,11 +8,15 @@
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
/** global: all, current, specific */
|
||||
/** global: everything, current, specific */
|
||||
|
||||
$(function () {
|
||||
"use strict";
|
||||
columnChart(all, 'all');
|
||||
columnChart(current, 'period');
|
||||
columnChart(specific, 'period-specific-period');
|
||||
|
||||
console.log('Getting charts');
|
||||
columnChart(everything, 'category-everything');
|
||||
|
||||
console.log('Specific: ' + specific);
|
||||
columnChart(specific, 'specific-period');
|
||||
|
||||
});
|
@ -186,7 +186,7 @@ function doubleYNonStackedChart(URI, container) {
|
||||
*/
|
||||
function columnChart(URI, container) {
|
||||
"use strict";
|
||||
|
||||
console.log('Going to draw column chart for ' + URI + ' in ' + container);
|
||||
var colorData = true;
|
||||
var options = defaultChartOptions;
|
||||
var chartType = 'bar';
|
||||
|
@ -97,7 +97,7 @@ return [
|
||||
'cannot_redirect_to_account' => 'Firefly III cannot redirect you to the correct page. Apologies.',
|
||||
'sum_of_expenses' => 'Sum of expenses',
|
||||
'sum_of_income' => 'Sum of income',
|
||||
'total_sum' => 'Total sum',
|
||||
'total_sum' => 'Total sum',
|
||||
'spent_in_specific_budget' => 'Spent in budget ":budget"',
|
||||
'sum_of_expenses_in_budget' => 'Spent total in budget ":budget"',
|
||||
'left_in_budget_limit' => 'Left to spend according to budgeting',
|
||||
@ -109,7 +109,11 @@ return [
|
||||
'current_period' => 'Current period',
|
||||
'show_the_current_period_and_overview' => 'Show the current period and overview',
|
||||
'pref_languages_locale' => 'For a language other than English to work properly, your operating system must be equipped with the correct locale-information. If these are not present, currency data, dates and amounts may be formatted wrong.',
|
||||
'budget_in_period' => '":name" between :start and :end',
|
||||
'budget_in_period' => 'All transactions for budget ":name" between :start and :end',
|
||||
'chart_budget_in_period' => 'Chart for all transactions for budget ":name" between :start and :end',
|
||||
'chart_account_in_period' => 'Chart for all transactions for account ":name" between :start and :end',
|
||||
'chart_category_in_period' => 'Chart for all transactions for category ":name" between :start and :end',
|
||||
'chart_category_all' => 'Chart for all transactions for category ":name"',
|
||||
'budget_in_period_breadcrumb' => 'Between :start and :end',
|
||||
'clone_withdrawal' => 'Clone this withdrawal',
|
||||
'clone_deposit' => 'Clone this deposit',
|
||||
|
@ -13,7 +13,7 @@
|
||||
{% if moment == 'all' %}
|
||||
{{ trans('firefly.chart_all_journals_for_account', {name:account.name}) }}
|
||||
{% else %}
|
||||
xxx
|
||||
{{ trans('firefly.chart_account_in_period', {name: account.name, start: start.formatLocalized(monthAndDayFormat), end: end.formatLocalized(monthAndDayFormat) }) }}
|
||||
{% endif %}
|
||||
</h3>
|
||||
<!-- ACTIONS MENU -->
|
||||
@ -116,13 +116,13 @@
|
||||
</div>
|
||||
<div class="box-body no-padding">
|
||||
<table class="table table-hover">
|
||||
{% if period.spent != 0 or (accountType == 'Asset account') %}
|
||||
{% if period.spent != 0 %}
|
||||
<tr>
|
||||
<td style="width:33%;">{{ 'spent'|_ }}</td>
|
||||
<td style="text-align: right;">{{ period.spent|formatAmount }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if period.earned != 0 or (accountType == 'Asset account') %}
|
||||
{% if period.earned != 0 %}
|
||||
<tr>
|
||||
<td style="width: 33%;">{{ 'earned'|_ }}</td>
|
||||
<td style="text-align: right;">{{ period.earned|formatAmount }}</td>
|
||||
|
@ -11,7 +11,7 @@
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">
|
||||
{% if budgetLimit %}
|
||||
XXXX
|
||||
{{ trans('firefly.chart_budget_in_period', {name: budget.name, start: budgetLimit.start_date.formatLocalized(monthAndDayFormat), end: budgetLimit.end_date.formatLocalized(monthAndDayFormat) }) }}
|
||||
{% else %}
|
||||
{{ trans('firefly.chart_all_journals_for_budget', {name:budget.name}) }}
|
||||
{% endif %}
|
||||
|
@ -6,38 +6,29 @@
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
{% if moment != 'all' and moment != '' %}
|
||||
{% if moment != 'all' %}
|
||||
{# both charts #}
|
||||
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ 'overview'|_ }} ({{ 'per_period'|_|lower }})</h3>
|
||||
<h3 class="box-title">
|
||||
{{ trans('firefly.chart_category_in_period', {name: category.name, start: start.formatLocalized(monthAndDayFormat), end: end.formatLocalized(monthAndDayFormat) }) }}
|
||||
</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<canvas id="period-specific-period" style="width:100%" height="350"></canvas>
|
||||
<canvas id="specific-period" style="width:100%;height:350px;" height="350"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ 'overview'|_ }} ({{ 'all_periods'|_|lower }})</h3>
|
||||
<h3 class="box-title">
|
||||
{{ trans('firefly.chart_category_all', {name: category.name }) }}
|
||||
</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<canvas id="all" style="width:100%;" height="350"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if moment == '' %}
|
||||
{# single chart #}
|
||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ subTitle }}</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<canvas id="period" style="width:100%;height:350px;" height="350"></canvas>
|
||||
<canvas id="category-everything" style="width:100%;height:350px;" height="350"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -47,10 +38,12 @@
|
||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ 'overview'|_ }} ({{ 'all_periods'|_|lower }})</h3>
|
||||
<h3 class="box-title">
|
||||
{{ trans('firefly.chart_category_all', {name: category.name }) }}
|
||||
</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<canvas id="all" style="width:100%;" height="350"></canvas>
|
||||
<canvas id="category-everything" style="width:100%;height:350px;" height="350"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -73,7 +66,7 @@
|
||||
</div>
|
||||
<div class="box-body">
|
||||
{% include 'list.journals-tasker' with {hideCategories: true} %}
|
||||
{% if periods %}
|
||||
{% if periods.count > 0 %}
|
||||
<p>
|
||||
<i class="fa fa-calendar" aria-hidden="true"></i>
|
||||
<a href="{{ route('categories.show', [category.id,'all']) }}">
|
||||
@ -139,7 +132,7 @@
|
||||
{% block scripts %}
|
||||
<script type="text/javascript">
|
||||
var current = '{{ route('chart.category.current', [category.id]) }}';
|
||||
var all = '{{ route('chart.category.all', [category.id]) }}';
|
||||
var everything = '{{ route('chart.category.all', [category.id]) }}';
|
||||
var specific = '{{ route('chart.category.specific', [category.id, start.format('Ymd')]) }}';
|
||||
</script>
|
||||
<script type="text/javascript" src="js/lib/Chart.bundle.min.js"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user