Refactor code to use new “earned in period” method. #524

This commit is contained in:
James Cole
2017-01-05 08:40:05 +01:00
parent 4d49701203
commit 7c82f45604
2 changed files with 5 additions and 4 deletions

View File

@@ -319,6 +319,7 @@ class CategoryController extends Controller
*/
private function getGroupedEntries(Category $category): Collection
{
/** @var CategoryRepositoryInterface $repository */
$repository = app(CategoryRepositoryInterface::class);
$accountRepository = app(AccountRepositoryInterface::class);
$accounts = $accountRepository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
@@ -344,8 +345,8 @@ class CategoryController extends Controller
while ($end >= $first) {
$end = Navigation::startOfPeriod($end, $range);
$currentEnd = Navigation::endOfPeriod($end, $range);
$spent = $repository->spentInPeriod(new Collection([$category]), $accounts, $end, $currentEnd);
$earned = $repository->earnedInPeriod(new Collection([$category]), $accounts, $end, $currentEnd);
$spent = $repository->spentInPeriodCollector(new Collection([$category]), $accounts, $end, $currentEnd);
$earned = $repository->earnedInPeriodCollector(new Collection([$category]), $accounts, $end, $currentEnd);
$dateStr = $end->format('Y-m-d');
$dateName = Navigation::periodShow($end, $range);
$entries->push([$dateStr, $dateName, $spent, $earned]);