mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-23 04:46:44 +00:00
Refactor code to verify these methods work #524
This commit is contained in:
@@ -90,7 +90,7 @@ class CategoryController extends Controller
|
|||||||
|
|
||||||
while ($start <= $end) {
|
while ($start <= $end) {
|
||||||
$currentEnd = Navigation::endOfPeriod($start, $range);
|
$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);
|
$earned = $repository->earnedInPeriod(new Collection([$category]), $accounts, $start, $currentEnd);
|
||||||
$label = Navigation::periodShow($start, $range);
|
$label = Navigation::periodShow($start, $range);
|
||||||
$chartData[0]['entries'][$label] = bcmul($spent, '-1');
|
$chartData[0]['entries'][$label] = bcmul($spent, '-1');
|
||||||
@@ -143,12 +143,13 @@ class CategoryController extends Controller
|
|||||||
$accounts = $accountRepository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT]);
|
$accounts = $accountRepository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT]);
|
||||||
/** @var Category $category */
|
/** @var Category $category */
|
||||||
foreach ($categories as $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) {
|
if (bccomp($spent, '0') === -1) {
|
||||||
$chartData[$category->name] = bcmul($spent, '-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
|
// sort
|
||||||
arsort($chartData);
|
arsort($chartData);
|
||||||
@@ -314,7 +315,7 @@ class CategoryController extends Controller
|
|||||||
];
|
];
|
||||||
|
|
||||||
while ($start <= $end) {
|
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);
|
$earned = $repository->earnedInPeriod(new Collection([$category]), $accounts, $start, $start);
|
||||||
$label = Navigation::periodShow($start, '1D');
|
$label = Navigation::periodShow($start, '1D');
|
||||||
|
|
||||||
|
@@ -123,7 +123,7 @@ class CategoryController extends Controller
|
|||||||
$report = [];
|
$report = [];
|
||||||
/** @var Category $category */
|
/** @var Category $category */
|
||||||
foreach ($categories as $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) {
|
if (bccomp($spent, '0') !== 0) {
|
||||||
$report[$category->id] = ['name' => $category->name, 'spent' => $spent];
|
$report[$category->id] = ['name' => $category->name, 'spent' => $spent];
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user