mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 02:26:58 +00:00
Make sure chart is displayed.
This commit is contained in:
@@ -47,6 +47,8 @@ class BudgetReportHelper implements BudgetReportHelperInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* TODO the query called here must be moved to a repository.
|
||||||
|
*
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
* @param Carbon $end
|
* @param Carbon $end
|
||||||
* @param Collection $accounts
|
* @param Collection $accounts
|
||||||
@@ -215,25 +217,29 @@ class BudgetReportHelper implements BudgetReportHelperInterface
|
|||||||
public function listOfPeriods(Carbon $start, Carbon $end): array
|
public function listOfPeriods(Carbon $start, Carbon $end): array
|
||||||
{
|
{
|
||||||
// define period to increment
|
// define period to increment
|
||||||
$increment = 'addDay';
|
$increment = 'addDay';
|
||||||
$format = 'Y-m-d';
|
$format = 'Y-m-d';
|
||||||
|
$displayFormat = strval(trans('config.month_and_day'));
|
||||||
// increment by month (for year)
|
// increment by month (for year)
|
||||||
if ($start->diffInMonths($end) > 1) {
|
if ($start->diffInMonths($end) > 1) {
|
||||||
$increment = 'addMonth';
|
$increment = 'addMonth';
|
||||||
$format = 'Y-m';
|
$format = 'Y-m';
|
||||||
|
$displayFormat = strval(trans('config.month'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// increment by year (for multi year)
|
// increment by year (for multi year)
|
||||||
if ($start->diffInMonths($end) > 12) {
|
if ($start->diffInMonths($end) > 12) {
|
||||||
$increment = 'addYear';
|
$increment = 'addYear';
|
||||||
$format = 'Y';
|
$format = 'Y';
|
||||||
|
$displayFormat = strval(trans('config.year'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$begin = clone $start;
|
$begin = clone $start;
|
||||||
$entries = [];
|
$entries = [];
|
||||||
while ($begin < $end) {
|
while ($begin < $end) {
|
||||||
$formatted = $begin->format($format);
|
$formatted = $begin->format($format);
|
||||||
$entries[$formatted] = $formatted;
|
$displayed = $begin->formatLocalized($displayFormat);
|
||||||
|
$entries[$formatted] = $displayed;
|
||||||
|
|
||||||
$begin->$increment();
|
$begin->$increment();
|
||||||
}
|
}
|
||||||
@@ -274,7 +280,8 @@ class BudgetReportHelper implements BudgetReportHelperInterface
|
|||||||
private function filterAllAmounts(Collection $set, int $budgetId, array $periods):array
|
private function filterAllAmounts(Collection $set, int $budgetId, array $periods):array
|
||||||
{
|
{
|
||||||
$arr = [];
|
$arr = [];
|
||||||
foreach ($periods as $period) {
|
$keys = array_keys($periods);
|
||||||
|
foreach ($keys as $period) {
|
||||||
/** @var stdClass $object */
|
/** @var stdClass $object */
|
||||||
$result = $set->filter(
|
$result = $set->filter(
|
||||||
function (TransactionJournal $object) use ($budgetId, $period) {
|
function (TransactionJournal $object) use ($budgetId, $period) {
|
||||||
|
@@ -186,6 +186,9 @@ class BudgetController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
|
* TODO use the NEW query that will be in the repository. Because that query will be shared between the budget period report (table for all budgets)
|
||||||
|
* TODO and this chart (a single budget)
|
||||||
* @param BudgetRepositoryInterface $repository
|
* @param BudgetRepositoryInterface $repository
|
||||||
* @param Budget $budget
|
* @param Budget $budget
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
@@ -196,6 +199,9 @@ class BudgetController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function period(BudgetRepositoryInterface $repository, Budget $budget, Carbon $start, Carbon $end, Collection $accounts)
|
public function period(BudgetRepositoryInterface $repository, Budget $budget, Carbon $start, Carbon $end, Collection $accounts)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// chart properties for cache:
|
// chart properties for cache:
|
||||||
$cache = new CacheProperties();
|
$cache = new CacheProperties();
|
||||||
$cache->addProperty($start);
|
$cache->addProperty($start);
|
||||||
|
@@ -12,12 +12,7 @@
|
|||||||
{% for id, info in budgets %}
|
{% for id, info in budgets %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
(<a title="{{ info.name }}" href="#" data-budget="{{ id }}" class="budget-chart-activate">{{ info.name }}</a>)
|
<a title="{{ info.name }}" href="#" data-budget="{{ id }}" class="budget-chart-activate">{{ info.name }}</a>
|
||||||
{% if id == 0 %}
|
|
||||||
<a href="{{ route('budgets.noBudget') }}">{{ info.name }}</a>
|
|
||||||
{% else %}
|
|
||||||
<a href="{{ route('budgets.show', id) }}">{{ info.name }}</a>
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
</td>
|
||||||
{% for amount in info.entries %}
|
{% for amount in info.entries %}
|
||||||
<td data-value="{{ amount }}">
|
<td data-value="{{ amount }}">
|
||||||
|
Reference in New Issue
Block a user