mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-23 23:13:18 -06:00
Fixed some initial startup bugs when working with Homestead.
This commit is contained in:
parent
e9afd55e9d
commit
9d4cba1620
@ -18,11 +18,15 @@ class GoogleChartController extends BaseController
|
|||||||
|
|
||||||
/** @var \FireflyIII\Shared\Preferences\Preferences $preferences */
|
/** @var \FireflyIII\Shared\Preferences\Preferences $preferences */
|
||||||
$preferences = App::make('FireflyIII\Shared\Preferences\Preferences');
|
$preferences = App::make('FireflyIII\Shared\Preferences\Preferences');
|
||||||
$pref = $preferences->get('frontpageAccounts');
|
$pref = $preferences->get('frontpageAccounts', []);
|
||||||
|
|
||||||
/** @var \FireflyIII\Database\Account $acct */
|
/** @var \FireflyIII\Database\Account $acct */
|
||||||
$acct = App::make('FireflyIII\Database\Account');
|
$acct = App::make('FireflyIII\Database\Account');
|
||||||
$accounts = $acct->getByIds($pref->data);
|
if (count($pref->data) > 0) {
|
||||||
|
$accounts = $acct->getByIds($pref->data);
|
||||||
|
} else {
|
||||||
|
$accounts = $acct->getAssetAccounts();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -169,7 +173,7 @@ class GoogleChartController extends BaseController
|
|||||||
foreach ($budgets as $budget) {
|
foreach ($budgets as $budget) {
|
||||||
$chart->addColumn($budget->name, 'number');
|
$chart->addColumn($budget->name, 'number');
|
||||||
}
|
}
|
||||||
$chart->addColumn('No budget','number');
|
$chart->addColumn('No budget', 'number');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Loop budgets this year.
|
* Loop budgets this year.
|
||||||
@ -179,7 +183,7 @@ class GoogleChartController extends BaseController
|
|||||||
while ($start <= $end) {
|
while ($start <= $end) {
|
||||||
$row = [clone $start];
|
$row = [clone $start];
|
||||||
|
|
||||||
foreach($budgets as $budget) {
|
foreach ($budgets as $budget) {
|
||||||
$row[] = $bdt->spentInMonth($budget, $start);
|
$row[] = $bdt->spentInMonth($budget, $start);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,7 +192,7 @@ class GoogleChartController extends BaseController
|
|||||||
*/
|
*/
|
||||||
$endOfMonth = clone $start;
|
$endOfMonth = clone $start;
|
||||||
$endOfMonth->endOfMonth();
|
$endOfMonth->endOfMonth();
|
||||||
$set = $bdt->transactionsWithoutBudgetInDateRange($start, $endOfMonth);
|
$set = $bdt->transactionsWithoutBudgetInDateRange($start, $endOfMonth);
|
||||||
$row[] = floatval($set->sum('amount')) * -1;
|
$row[] = floatval($set->sum('amount')) * -1;
|
||||||
|
|
||||||
$chart->addRowArray($row);
|
$chart->addRowArray($row);
|
||||||
@ -202,23 +206,24 @@ class GoogleChartController extends BaseController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Component $component
|
* @param Component $component
|
||||||
* @param $year
|
* @param $year
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function componentsAndSpending(Component $component, $year) {
|
public function componentsAndSpending(Component $component, $year)
|
||||||
|
{
|
||||||
try {
|
try {
|
||||||
$start = new Carbon('01-01-' . $year);
|
$start = new Carbon('01-01-' . $year);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
App::abort(500);
|
App::abort(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($component->class == 'Budget') {
|
if ($component->class == 'Budget') {
|
||||||
/** @var \FireflyIII\Database\Budget $repos */
|
/** @var \FireflyIII\Database\Budget $repos */
|
||||||
$repos = App::make('FireflyIII\Database\Budget');
|
$repos = App::make('FireflyIII\Database\Budget');
|
||||||
} else {
|
} else {
|
||||||
/** @var \FireflyIII\Database\Category $repos */
|
/** @var \FireflyIII\Database\Category $repos */
|
||||||
$repos = App::make('FireflyIII\Database\Category');
|
$repos = App::make('FireflyIII\Database\Category');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||||
@ -229,11 +234,11 @@ class GoogleChartController extends BaseController
|
|||||||
|
|
||||||
$end = clone $start;
|
$end = clone $start;
|
||||||
$end->endOfYear();
|
$end->endOfYear();
|
||||||
while($start <= $end) {
|
while ($start <= $end) {
|
||||||
|
|
||||||
$spent = $repos->spentInMonth($component, $start);
|
$spent = $repos->spentInMonth($component, $start);
|
||||||
$repetition = $repos->repetitionOnStartingOnDate($component, $start);
|
$repetition = $repos->repetitionOnStartingOnDate($component, $start);
|
||||||
if($repetition) {
|
if ($repetition) {
|
||||||
$budgeted = floatval($repetition->amount);
|
$budgeted = floatval($repetition->amount);
|
||||||
} else {
|
} else {
|
||||||
$budgeted = null;
|
$budgeted = null;
|
||||||
@ -245,7 +250,6 @@ class GoogleChartController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$chart->generate();
|
$chart->generate();
|
||||||
return Response::json($chart->getData());
|
return Response::json($chart->getData());
|
||||||
|
|
||||||
|
@ -4,8 +4,8 @@ if (!function_exists('mf')) {
|
|||||||
function mf($n, $coloured = true)
|
function mf($n, $coloured = true)
|
||||||
{
|
{
|
||||||
|
|
||||||
$n = floatval($n);
|
$n = floatval($n);
|
||||||
$n = round($n, 2);
|
$n = round($n, 2);
|
||||||
$string = number_format($n, 2, ',', '.');
|
$string = number_format($n, 2, ',', '.');
|
||||||
|
|
||||||
if ($coloured === true && $n === 0.0) {
|
if ($coloured === true && $n === 0.0) {
|
||||||
@ -37,11 +37,12 @@ $app = new Illuminate\Foundation\Application;
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$env = $app->detectEnvironment(array(
|
$env = $app->detectEnvironment(
|
||||||
|
[
|
||||||
'local' => array('homestead', 'SMJD*'),
|
'local' => ['SMJD*'],
|
||||||
|
'homestead' => ['homestead']
|
||||||
));
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user