mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Cleanup.
This commit is contained in:
parent
78e80530d3
commit
217483639d
@ -388,31 +388,32 @@ class ChartController extends BaseController
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
/*
|
||||
* Get all budgets.
|
||||
*/
|
||||
// Get all budgets.
|
||||
$budgets = \Auth::user()->budgets()->orderBy('name', 'ASC')->get();
|
||||
$budgetIds = [];
|
||||
/** @var \Budget $budget */
|
||||
foreach ($budgets as $budget) {
|
||||
$budgetIds[] = $budget->id;
|
||||
/*
|
||||
* Does the budget have a limit starting on $start?
|
||||
*/
|
||||
$rep = \LimitRepetition::
|
||||
|
||||
// Does the budget have a limit starting on $start?
|
||||
$rep = \LimitRepetition::
|
||||
leftJoin('limits', 'limit_repetitions.limit_id', '=', 'limits.id')->leftJoin(
|
||||
'components', 'limits.component_id', '=', 'components.id'
|
||||
)->where('limit_repetitions.startdate', $start->format('Y-m-d'))->where(
|
||||
'components.id', $budget->id
|
||||
)->first(['limit_repetitions.*']);
|
||||
$limit = is_null($rep) ? 0.0 : floatval($rep->amount);
|
||||
$id = is_null($rep) ? null : $rep->id;
|
||||
$parameter = is_null($rep) ? 'useSession=true' : '';
|
||||
|
||||
/*
|
||||
* Date range to check for expenses made?
|
||||
*/
|
||||
if (is_null($rep)) {
|
||||
$limit = 0.0;
|
||||
$id = null;
|
||||
$parameter = 'useSession=true';
|
||||
} else {
|
||||
$limit = floatval($rep->amount);
|
||||
$id = $rep->id;
|
||||
$parameter = '';
|
||||
}
|
||||
|
||||
// Date range to check for expenses made?
|
||||
if (is_null($rep)) {
|
||||
// use the session start and end for our search query
|
||||
$expenseStart = Session::get('start');
|
||||
@ -423,17 +424,10 @@ class ChartController extends BaseController
|
||||
$expenseStart = $rep->startdate;
|
||||
$expenseEnd = $rep->enddate;
|
||||
}
|
||||
/*
|
||||
* How much have we spent on this budget?
|
||||
*/
|
||||
$expenses = $budget->transactionjournals()->before($expenseEnd)->after($expenseStart)->lessThan(0)->sum(
|
||||
'amount'
|
||||
);
|
||||
$expenses = floatval($expenses) * -1;
|
||||
// How much have we spent on this budget?
|
||||
$expenses = floatval($budget->transactionjournals()->before($expenseEnd)->after($expenseStart)->lessThan(0)->sum('amount')) * -1;
|
||||
|
||||
/*
|
||||
* Append to chart:
|
||||
*/
|
||||
// Append to chart:
|
||||
if ($limit > 0 || $expenses > 0) {
|
||||
$data['labels'][] = $budget->name;
|
||||
$data['series'][0]['data'][] = [
|
||||
@ -446,9 +440,7 @@ class ChartController extends BaseController
|
||||
];
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Add expenses that have no budget:
|
||||
*/
|
||||
// Add expenses that have no budget:
|
||||
$set = \Auth::user()->transactionjournals()->whereNotIn(
|
||||
'transaction_journals.id', function ($query) use ($start, $end) {
|
||||
$query->select('transaction_journals.id')->from('transaction_journals')
|
||||
@ -462,11 +454,8 @@ class ChartController extends BaseController
|
||||
->where('components.class', 'Budget');
|
||||
}
|
||||
)->before($end)->after($start)->lessThan(0)->transactionTypes(['Withdrawal'])->sum('amount');
|
||||
/*
|
||||
* This can be debugged by using get(['transaction_journals.*','transactions.amount']);
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
// This can be debugged by using get(['transaction_journals.*','transactions.amount']);
|
||||
$data['labels'][] = 'No budget';
|
||||
$data['series'][0]['data'][] = [
|
||||
'y' => 0,
|
||||
|
@ -1,11 +1,4 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: sander
|
||||
* Date: 19/09/14
|
||||
* Time: 21:42
|
||||
*/
|
||||
|
||||
namespace Firefly\Exception;
|
||||
|
||||
/**
|
||||
|
@ -1,11 +1,4 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: sander
|
||||
* Date: 21/09/14
|
||||
* Time: 20:58
|
||||
*/
|
||||
|
||||
namespace Firefly\Helper\Controllers;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
@ -1,11 +1,4 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: sander
|
||||
* Date: 21/09/14
|
||||
* Time: 20:58
|
||||
*/
|
||||
|
||||
namespace Firefly\Helper\Controllers;
|
||||
|
||||
/**
|
||||
|
@ -1,11 +1,4 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: sander
|
||||
* Date: 23/08/14
|
||||
* Time: 20:59
|
||||
*/
|
||||
|
||||
namespace Firefly\Storage\Reminder;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user