Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Refactor code to verify these methods work #524
James Coleaf466a1d752c
diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.phpindex 6ba325636a..15c807412f 100644--- a/app/Http/Controllers/Chart/CategoryController.php+++ b/app/Http/Controllers/Chart/CategoryController.php@@ -90,7 +90,7 @@ class CategoryController extends Controllerwhile ($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');// sortarsort($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');diff --git a/app/Http/Controllers/Report/CategoryController.php b/app/Http/Controllers/Report/CategoryController.phpindex 730deeaece..2426dd6ea6 100644--- a/app/Http/Controllers/Report/CategoryController.php+++ b/app/Http/Controllers/Report/CategoryController.php@@ -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];}