mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Fix the report chart.
This commit is contained in:
@@ -79,6 +79,62 @@ class AccountController extends Controller
|
||||
return Response::json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the balances for a given set of dates and accounts.
|
||||
*
|
||||
* TODO fix parameters.
|
||||
*
|
||||
* @param AccountRepositoryInterface $repository
|
||||
*
|
||||
* @param $url
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function report(AccountRepositoryInterface $repository, $url)
|
||||
{
|
||||
$parts = explode(';', $url);
|
||||
|
||||
// try to make a date out of parts 1 and 2:
|
||||
try {
|
||||
$start = new Carbon($parts[1]);
|
||||
$end = new Carbon($parts[2]);
|
||||
} catch (Exception $e) {
|
||||
Log::error('Could not parse date "' . $parts[1] . '" or "' . $parts[2] . '" for user #' . Auth::user()->id);
|
||||
abort(404);
|
||||
}
|
||||
if ($end < $start) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
// accounts:
|
||||
$c = count($parts);
|
||||
$list = new Collection();
|
||||
for ($i = 3; $i < $c; $i++) {
|
||||
$account = $repository->find($parts[$i]);
|
||||
if ($account) {
|
||||
$list->push($account);
|
||||
}
|
||||
}
|
||||
|
||||
// chart properties for cache:
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('all');
|
||||
$cache->addProperty('accounts');
|
||||
$cache->addProperty('default');
|
||||
$cache->addProperty($list);
|
||||
if ($cache->has()) {
|
||||
return Response::json($cache->get()); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
// make chart:
|
||||
$data = $this->generator->all($list, $start, $end);
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the balances for all the user's expense accounts.
|
||||
*
|
||||
|
@@ -258,7 +258,7 @@ class ReportController extends Controller
|
||||
'accounts',
|
||||
'incomes', 'incomeTopLength',
|
||||
'expenses', 'expenseTopLength',
|
||||
'budgets', 'balance',
|
||||
'budgets', 'balance','url',
|
||||
'categories',
|
||||
'bills'
|
||||
)
|
||||
|
@@ -284,9 +284,8 @@ Route::group(
|
||||
// accounts:
|
||||
Route::get('/chart/account/frontpage', ['uses' => 'Chart\AccountController@frontpage']);
|
||||
Route::get('/chart/account/expense', ['uses' => 'Chart\AccountController@expenseAccounts']);
|
||||
Route::get('/chart/account/month/{year}/{month}/{shared?}', ['uses' => 'Chart\AccountController@all'])->where(
|
||||
['year' => '[0-9]{4}', 'month' => '[0-9]{1,2}', 'shared' => 'shared']
|
||||
);
|
||||
Route::get('/chart/account/month/{year}/{month}/{shared?}', ['uses' => 'Chart\AccountController@all'])->where(['year' => '[0-9]{4}', 'month' => '[0-9]{1,2}', 'shared' => 'shared']);
|
||||
Route::get('/chart/account/report/{url}', ['uses' => 'Chart\AccountController@report']);
|
||||
Route::get('/chart/account/{account}', ['uses' => 'Chart\AccountController@single']);
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user