Code cleanup.

This commit is contained in:
James Cole
2016-05-15 18:36:40 +02:00
parent 260b611293
commit 962965b5b7
53 changed files with 55 additions and 203 deletions

View File

@@ -53,7 +53,7 @@ class AccountController extends Controller
$cache->addProperty('expenseAccounts');
$cache->addProperty('accounts');
if ($cache->has()) {
return Response::json($cache->get());
return Response::json($cache->get());
}
$accounts = $repository->getAccountsByType(['Expense account', 'Beneficiary account']);
@@ -105,7 +105,7 @@ class AccountController extends Controller
$cache->addProperty('frontpage');
$cache->addProperty('accounts');
if ($cache->has()) {
return Response::json($cache->get());
return Response::json($cache->get());
}
$frontPage = Preferences::get('frontPageAccounts', $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET])->pluck('id')->toArray());
@@ -151,7 +151,7 @@ class AccountController extends Controller
$cache->addProperty('default');
$cache->addProperty($accounts);
if ($cache->has()) {
return Response::json($cache->get());
return Response::json($cache->get());
}
foreach ($accounts as $account) {
@@ -196,7 +196,7 @@ class AccountController extends Controller
$cache->addProperty('single');
$cache->addProperty($account->id);
if ($cache->has()) {
return Response::json($cache->get());
return Response::json($cache->get());
}
$format = (string)trans('config.month_and_day');

View File

@@ -12,7 +12,6 @@ use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use Illuminate\Support\Collection;
use Log;
use Navigation;
use Preferences;
use Response;
@@ -67,7 +66,6 @@ class BudgetController extends Controller
$budgetCollection = new Collection([$budget]);
$last = Navigation::endOfX($last, $range, $final); // not to overshoot.
$entries = new Collection;
Log::debug('---- now at chart');
while ($first < $last) {
// periodspecific dates:
@@ -115,7 +113,6 @@ class BudgetController extends Controller
$entries = new Collection;
$amount = $repetition->amount;
$budgetCollection = new Collection([$budget]);
Log::debug('amount starts ' . $amount);
while ($start <= $end) {
$spent = $repository->spentInPeriod($budgetCollection, new Collection, $start, $start);
$amount = bcadd($amount, $spent);

View File

@@ -11,7 +11,6 @@ use FireflyIII\Models\Category;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface as CRI;
use FireflyIII\Support\CacheProperties;
use Illuminate\Support\Collection;
use Log;
use Navigation;
use Preferences;
use Response;
@@ -69,10 +68,9 @@ class CategoryController extends Controller
while ($start <= $end) {
$currentEnd = Navigation::endOfPeriod($start, $range);
Log::debug('Searching for expenses from ' . $start . ' to ' . $currentEnd);
$spent = $repository->spentInPeriod($categoryCollection, new Collection, $start, $currentEnd);
$earned = $repository->earnedInPeriod($categoryCollection, new Collection, $start, $currentEnd);
$date = Navigation::periodShow($start, $range);
$spent = $repository->spentInPeriod($categoryCollection, new Collection, $start, $currentEnd);
$earned = $repository->earnedInPeriod($categoryCollection, new Collection, $start, $currentEnd);
$date = Navigation::periodShow($start, $range);
$entries->push([clone $start, $date, $spent, $earned]);
$start = Navigation::addPeriod($start, $range, 0);
}
@@ -126,7 +124,6 @@ class CategoryController extends Controller
/** @var Category $category */
foreach ($categories as $category) {
$spent = $repository->spentInPeriod(new Collection([$category]), new Collection, $start, $end);
Log::debug('Spent for ' . $category->name . ' is ' . $spent . ' (' . bccomp($spent, '0') . ')');
if (bccomp($spent, '0') === -1) {
$category->spent = $spent;
$set->push($category);
@@ -255,17 +252,13 @@ class CategoryController extends Controller
$cache->addProperty('specific-period');
if ($cache->has()) {
return $cache->get();
return $cache->get();
}
$entries = new Collection;
Log::debug('Start is ' . $start . ' en end is ' . $end);
while ($start <= $end) {
Log::debug('Now at ' . $start);
$spent = $repository->spentInPeriod($categoryCollection, new Collection, $start, $start);
Log::debug('spent: ' . $spent);
$spent = $repository->spentInPeriod($categoryCollection, new Collection, $start, $start);
$earned = $repository->earnedInPeriod($categoryCollection, new Collection, $start, $start);
Log::debug('earned: ' . $earned);
$date = Navigation::periodShow($start, '1D');
$date = Navigation::periodShow($start, '1D');
$entries->push([clone $start, $date, $spent, $earned]);
$start->addDay();
}

View File

@@ -100,7 +100,7 @@ class ReportController extends Controller
$cache->addProperty($accounts);
$cache->addProperty($end);
if ($cache->has()) {
return Response::json($cache->get());
return Response::json($cache->get());
}
// always per month.