Refactor code to verify these methods work #524

This commit is contained in:
James Cole 2017-01-05 08:33:22 +01:00
parent b9599d3aa1
commit af466a1d75
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
2 changed files with 6 additions and 5 deletions

View File

@ -90,7 +90,7 @@ class CategoryController extends Controller
while ($start <= $end) {
$currentEnd = Navigation::endOfPeriod($start, $range);
$spent = $repository->spentInPeriod(new Collection([$category]), $accounts, $start, $currentEnd);
$spent = $repository->spentInPeriodCollector(new Collection([$category]), $accounts, $start, $currentEnd);
$earned = $repository->earnedInPeriod(new Collection([$category]), $accounts, $start, $currentEnd);
$label = Navigation::periodShow($start, $range);
$chartData[0]['entries'][$label] = bcmul($spent, '-1');
@ -143,12 +143,13 @@ class CategoryController extends Controller
$accounts = $accountRepository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT]);
/** @var Category $category */
foreach ($categories as $category) {
$spent = $repository->spentInPeriod(new Collection([$category]), $accounts, $start, $end);
$spent = $repository->spentInPeriodCollector(new Collection([$category]), $accounts, $start, $end);
if (bccomp($spent, '0') === -1) {
$chartData[$category->name] = bcmul($spent, '-1');
}
}
$chartData[strval(trans('firefly.no_category'))] = bcmul($repository->spentInPeriodWithoutCategory(new Collection, $start, $end), '-1');
$chartData[strval(trans('firefly.no_category'))] = bcmul($repository->spentInPeriodWithoutCategoryCollector(new Collection, $start, $end), '-1');
// sort
arsort($chartData);
@ -314,7 +315,7 @@ class CategoryController extends Controller
];
while ($start <= $end) {
$spent = $repository->spentInPeriod(new Collection([$category]), $accounts, $start, $start);
$spent = $repository->spentInPeriodCollector(new Collection([$category]), $accounts, $start, $start);
$earned = $repository->earnedInPeriod(new Collection([$category]), $accounts, $start, $start);
$label = Navigation::periodShow($start, '1D');

View File

@ -123,7 +123,7 @@ class CategoryController extends Controller
$report = [];
/** @var Category $category */
foreach ($categories as $category) {
$spent = $repository->spentInPeriod(new Collection([$category]), $accounts, $start, $end);
$spent = $repository->spentInPeriodCollector(new Collection([$category]), $accounts, $start, $end);
if (bccomp($spent, '0') !== 0) {
$report[$category->id] = ['name' => $category->name, 'spent' => $spent];
}