mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Refactor code to verify these methods work #524
This commit is contained in:
parent
b9599d3aa1
commit
af466a1d75
@ -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');
|
||||
|
||||
|
@ -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];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user