Remove category chart from report controller.

This commit is contained in:
James Cole
2016-05-15 16:13:05 +02:00
parent bd818b2dea
commit 6a750a998f
48 changed files with 30 additions and 434 deletions

View File

@@ -218,59 +218,6 @@ class CategoryController extends Controller
}
/**
* @param Category $category
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
*
* @return \Illuminate\Http\JsonResponse
*/
public function period(Category $category, Carbon $start, Carbon $end, Collection $accounts)
{
// chart properties for cache:
$cache = new CacheProperties();
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty($accounts);
$cache->addProperty($category->id);
$cache->addProperty('category');
$cache->addProperty('period');
if ($cache->has()) {
return Response::json($cache->get());
}
/** @var CRI $repository */
$repository = app(CRI::class);
$categoryCollection = new Collection([$category]);
// loop over period, add by users range:
$current = clone $start;
$viewRange = Preferences::get('viewRange', '1M')->data;
$format = strval(trans('config.month'));
$set = new Collection;
while ($current < $end) {
$currentStart = clone $current;
$currentEnd = Navigation::endOfPeriod($currentStart, $viewRange);
$spent = $repository->spentInPeriod($categoryCollection, $accounts, $currentStart, $currentEnd);
$earned = $repository->earnedInPeriod($categoryCollection, $accounts, $currentStart, $currentEnd);
$entry = [
$category->name,
$currentStart->formatLocalized($format),
$spent,
$earned,
];
$set->push($entry);
$currentEnd->addDay();
$current = clone $currentEnd;
}
$data = $this->generator->period($set);
$cache->store($data);
return Response::json($data);
}
/**
* @param CRI $repository
* @param Category $category

View File

@@ -314,9 +314,6 @@ class ReportController extends Controller
// find the budgets we've spent money on this period with these accounts:
$budgets = $this->budgetHelper->getBudgetsWithExpenses($start, $end, $accounts);
// find the categories we've spent money on this period with these accounts:
$categories = $this->helper->getCategoriesWithTransactions($start, $end, $accounts);
Session::flash('gaEventCategory', 'report');
Session::flash('gaEventAction', 'year');
Session::flash('gaEventLabel', $start->format('Y'));
@@ -333,7 +330,7 @@ class ReportController extends Controller
'reports.default.year',
compact(
'start', 'accountReport', 'incomes', 'reportType', 'accountIds', 'end',
'expenses', 'incomeTopLength', 'expenseTopLength', 'tags', 'budgets', 'categories'
'expenses', 'incomeTopLength', 'expenseTopLength', 'tags', 'budgets'
)
);
}

View File

@@ -31,7 +31,6 @@ use View;
*
* @package FireflyIII\Http\Controllers\Transaction
*
* TODO support piggy banks
*/
class SplitController extends Controller
{
@@ -132,9 +131,7 @@ class SplitController extends Controller
$repository->storeTransaction($journal, $transaction);
}
// TODO move to repository
$journal->completed = 1;
$journal->save();
$repository->markAsComplete($journal);
Session::flash('success', strval(trans('firefly.stored_journal', ['description' => e($journal->description)])));
Preferences::mark();

View File

@@ -18,6 +18,7 @@ use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Http\Requests\JournalFormRequest;
use FireflyIII\Http\Requests\MassDeleteJournalRequest;
use FireflyIII\Http\Requests\MassEditJournalRequest;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
@@ -165,13 +166,11 @@ class TransactionController extends Controller
'amount' => TransactionJournal::amountPositive($journal),
];
// TODO support split withdrawal
if ($journal->isWithdrawal() && TransactionJournal::destinationAccountTypeStr($journal) == 'Cash account') {
if ($journal->isWithdrawal() && $destinationAccounts->first()->accountType->type == AccountType::CASH) {
$preFilled['destination_account_name'] = '';
}
// TODO support split withdrawal
if ($journal->isDeposit() && TransactionJournal::sourceAccountTypeStr($journal) == 'Cash account') {
if ($journal->isDeposit() && $sourceAccounts->first()->accountType->type == AccountType::CASH) {
$preFilled['source_account_name'] = '';
}